scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit dd21e6a1c3601821e00992066fd65b5fe24c0e3f
parent e353903fa9ba4bbd405ca46c6ac651c8c8fb3cc2
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri,  3 Jun 2016 10:55:50 +0200

[cc2] add support for reading from filename argument

Diffstat:
cc2/main.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 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();