[Redbutton-devel] SF.net SVN: redbutton: [368] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-08-31 14:56:28
|
Revision: 368
http://redbutton.svn.sourceforge.net/redbutton/?rev=368&view=rev
Author: skilvington
Date: 2007-08-31 07:56:23 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
don't have to cat input files into mhegc anymore
Modified Paths:
--------------
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/mhegc.c 2007-08-31 14:56:23 UTC (rev 368)
@@ -52,7 +52,13 @@
}
}
- if(optind != argc)
+ /*
+ * a single param is the name of a source file
+ * default is to read from stdin
+ */
+ if(optind == argc - 1)
+ set_input_file(argv[optind]);
+ else if(optind != argc)
usage(prog_name);
parse_InterchangedObject(&state);
@@ -100,7 +106,7 @@
void
usage(char *prog_name)
{
- fprintf(stderr, "Usage: %s [-vv]\n", prog_name);
+ fprintf(stderr, "Usage: %s [-vv] [<input_file>]\n", prog_name);
exit(EXIT_FAILURE);
}
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.h.header 2007-08-31 14:56:23 UTC (rev 368)
@@ -7,6 +7,8 @@
struct state { int dummy; };
typedef int token_t;
+void set_input_file(char *);
+
token_t peek_token(void);
void expect_token(token_t, char *);
token_t next_token(void);
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.l.footer 2007-08-31 14:56:23 UTC (rev 368)
@@ -1,6 +1,18 @@
. return INVALID;
%%
+void
+set_input_file(char *src_name)
+{
+ if((yyin = fopen(src_name, "r")) == NULL)
+ {
+ fprintf(stderr, "Unable to read %s: %s\n", src_name, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ return;
+}
+
/* don't use #define in case they are macros too */
token_t
peek_token(void)
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.l.header 2007-08-31 14:56:23 UTC (rev 368)
@@ -1,6 +1,8 @@
%{
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
#include "parser.h"
#include "tokens.h"
extern int yylineno;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|