Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ucbvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!decvax!ucbvax!daemon From: kateveni@Shasta Newsgroups: net.nlang.greek Subject: GRK distribution: file main.c -- file 4 of 6 Message-ID: <353@ucbvax.UUCP> Date: Fri, 20-Apr-84 18:30:28 EST Article-I.D.: ucbvax.353 Posted: Fri Apr 20 18:30:28 1984 Date-Received: Sat, 21-Apr-84 07:26:12 EST Sender: daemon@ucbvax.UUCP Organization: U.C. Berkeley Lines: 42 From: Manolis Katevenis #include int curarg, /* index into argv[] for argument (file) currently * under processing */ maxarg; /* the maximum value that curarg can take */ char **g_argv; /* global (external) version of argv[] */ main(argc, argv) int argc; char *argv[]; { int nofiles; /* boolean flag */ curarg = 0 ; /* this is BEFORE processing of the first * argument (file) has begun */ maxarg = argc-1 ; g_argv = argv ; nofiles = yywrap() ; /* open first argument (file), or do * nothing if no arguments exist */ if ( maxarg>0 && nofiles ) { fprintf(stderr, "grk: all arguments were bad -- quit.\n"); exit(1); } yylex() ; /* call the LEX-scanner; IT will call yywrap() * when each end-of-file is reached */ } yywrap() { if ( curarg++ < maxarg ) /* more file(s) to be opened */ { if ( freopen(g_argv[curarg], "r", stdin) != NULL ) /* default LEX-scanner reads from standard- * input; thus, we "re-open" stdin -- the * alternative would be to redefine yyin */ return(0); /* successful opening -- else: */ fprintf(stderr, "grk: can't open %s -- discarded it.\n", g_argv[curarg] ); return(yywrap()); /* try to open the next one */ } else /* no more files to be opened */ return(1); }