summaryrefslogtreecommitdiffstats
path: root/lex-c.l
diff options
context:
space:
mode:
Diffstat (limited to 'lex-c.l')
-rw-r--r--lex-c.l19
1 files changed, 17 insertions, 2 deletions
diff --git a/lex-c.l b/lex-c.l
index b74f169..243c9ab 100644
--- a/lex-c.l
+++ b/lex-c.l
@@ -1,4 +1,4 @@
-/* --c-mode-- */
+/* --*-c-mode-*-- */
%{
@@ -83,5 +83,20 @@ NIDCHAR [^_a-zA-Z0-9]
%%
int main(int argc, char *argv[]) {
- yylex();
+
+ if (argc <= 1)
+ yylex();
+ else {
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (!(freopen(argv[i], "r", stdin))) {
+ fprintf(stderr, "Failed to open file: %s\n", strerror(errno));
+ return 1;
+ }
+ yylex();
+ }
+ }
+
+ return 0;
}