commit dd21e6a1c3601821e00992066fd65b5fe24c0e3f
Author:     Quentin Rameau <[email protected]>
AuthorDate: Fri Jun 3 10:55:50 2016 +0200
Commit:     Quentin Rameau <[email protected]>
CommitDate: Fri Jun 3 11:00:51 2016 +0200

    [cc2] add support for reading from filename argument

diff --git a/cc2/main.c b/cc2/main.c
index cc51c2e..75786ab 100644
--- a/cc2/main.c
+++ b/cc2/main.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../inc/cc.h"
 #include "arch.h"
 #include "cc2.h"
 #include "error.h"
@@ -33,8 +34,15 @@ repeat:
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
+       if (argc > 2)
+               die("usage: cc2 [irfile]");
+
+       if (argv[1]) {
+               if (!freopen(argv[1], "r", stdin))
+                       die("cc2: cannot open %s", argv[1]);
+       }
 
        while (moreinput()) {
                parse();

Reply via email to