Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!panos From: panos@utcsri.UUCP (Panos Economopoulos) Newsgroups: net.nlang.greek Subject: Greek Typesetting #6 - Programa Manwli Kateveni - main.c Message-ID: <1604@utcsri.UUCP> Date: Tue, 5-Nov-85 13:21:04 EST Article-I.D.: utcsri.1604 Posted: Tue Nov 5 13:21:04 1985 Date-Received: Tue, 5-Nov-85 13:48:07 EST Distribution: net Organization: CSRI, University of Toronto Lines: 49 #includeint 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); } -- Panos Economopoulos UUCP: {decvax,linus,ihnp4,uw-beaver,allegra,utzoo}!utcsri!panos CSNET: panos@toronto