[hackers] [scc] [cc2] add support for reading from filename argument || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 3 Jun 2016 11:03:23 +0200 (CEST)

commit dd21e6a1c3601821e00992066fd65b5fe24c0e3f
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Jun 3 10:55:50 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
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
_AT_@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../inc/cc.h"
 #include "arch.h"
 #include "cc2.h"
 #include "error.h"
_AT_@ -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();
Received on Fri Jun 03 2016 - 11:03:23 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 03 2016 - 11:12:17 CEST