Ansi-fy getopt function and variable declarations.
authorMahlon E. Smith <mahlon@martini.nu>
Wed, 28 Sep 2011 09:04:16 -0700
changeset 9 bdf20e6eefd7
parent 8 8d0f25ef038e
child 10 d07309450285
Ansi-fy getopt function and variable declarations.
main.c
parser.c
volta.h
--- a/main.c	Wed Sep 28 09:04:16 2011 -0700
+++ b/main.c	Wed Sep 28 09:04:16 2011 -0700
@@ -54,9 +54,11 @@
 
 	/* get_opt vars */
 	int opt = 0;
-	opterr  = 0;
+	extern char *optarg;
+	extern int opterr, optind, optopt;
 
 	/* parse options */
+	opterr = 0;
 	while ( (opt = getopt( argc, argv, "d:f:hv" )) != -1 ) {
 		switch ( opt ) {
 
--- a/parser.c	Wed Sep 28 09:04:16 2011 -0700
+++ b/parser.c	Wed Sep 28 09:04:16 2011 -0700
@@ -1,5 +1,5 @@
 
-/* #line 1 "parser.rl" */
+#line 1 "parser.rl"
 /* vim: set noet nosta sw=4 ts=4 ft=ragel : */
 /*
 Copyright (c) 2011, Mahlon E. Smith <mahlon@martini.nu>
@@ -60,10 +60,10 @@
 #include "volta.h"
 
 
-/* #line 80 "parser.rl" */
+#line 80 "parser.rl"
 
 
-/* #line 67 "parser.c" */
+#line 67 "parser.c"
 static const int redirector_start = 1;
 static const int redirector_first_final = 13;
 static const int redirector_error = 0;
@@ -71,7 +71,7 @@
 static const int redirector_en_main = 1;
 
 
-/* #line 82 "parser.rl" */
+#line 82 "parser.rl"
 
 /*
 %%{
@@ -133,14 +133,14 @@
 
 	/* enter state machine */
 	
-/* #line 137 "parser.c" */
+#line 137 "parser.c"
 	{
 	cs = redirector_start;
 	}
 
-/* #line 143 "parser.rl" */
+#line 143 "parser.rl"
 	
-/* #line 144 "parser.c" */
+#line 144 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -203,7 +203,7 @@
 		goto tr7;
 	goto st0;
 tr7:
-/* #line 68 "parser.rl" */
+#line 68 "parser.rl"
 	{
 		printf( "I saw: %s", p+1 );
 	}
@@ -212,7 +212,7 @@
 	if ( ++p == pe )
 		goto _test_eof7;
 case 7:
-/* #line 216 "parser.c" */
+#line 216 "parser.c"
 	switch( (*p) ) {
 		case 10: goto st13;
 		case 43: goto st8;
@@ -314,7 +314,7 @@
 	_out: {}
 	}
 
-/* #line 144 "parser.rl" */
+#line 144 "parser.rl"
 
 	/* reset the request */
 	/* c_request = reset_request; */
--- a/volta.h	Wed Sep 28 09:04:16 2011 -0700
+++ b/volta.h	Wed Sep 28 09:04:16 2011 -0700
@@ -85,6 +85,7 @@
  * Function prototypes
  *
  */
+int getopt( int, char * const [], const char *);
 
 void usage( char *prg );
 void debug( int level, char *file, int line, const char *fmt, ... );