ref: 1af75a9c4d18e2913ef10fdf4ce98b6193d1e032
parent: a16181de44abd57ab0d6a699ea8dabf823a01868
author: Quentin Rameau <quinq@fifth.space>
date: Fri Jun 3 06:55:50 EDT 2016
[cc2] add support for reading from filename argument
--- 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 @@
}
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();