From 779fe568fc6dbc1f62988b6e4fd49247ec1c84f1 Mon Sep 17 00:00:00 2001 From: dtrg Date: Fri, 24 Jun 2005 22:10:24 +0000 Subject: [PATCH] Removed an assumption that 'stdin' is a constant, which it's not on Linux. (You can't use it as an initialiser when declaring a global variable.) --- util/ceg/EM_parser/common/scan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/ceg/EM_parser/common/scan.c b/util/ceg/EM_parser/common/scan.c index a5e367924..fa8fbe94c 100644 --- a/util/ceg/EM_parser/common/scan.c +++ b/util/ceg/EM_parser/common/scan.c @@ -29,17 +29,19 @@ int yylineno = 1; static char buf[BUF_SIZE], /* Bufer to save backc()-characters */ *bufptr = buf; /* Pointer to space for backc()-character */ -static FILE *infile = stdin; +static FILE *infile = NULL; static char nextc() { + FILE* fp = infile ? infile : stdin; + if ( bufptr > buf) return( *--bufptr); else - return( getc( infile)); + return( getc( fp)); } @@ -93,11 +95,12 @@ FILE *new; */ { + FILE* fp = infile ? infile : stdin; char *ptr; FILE *old; /* Clean buf[] */ for ( ptr = buf; ptr < bufptr; ptr++) - if ( ungetc( *ptr, infile) == EOF && *ptr != EOF) + if ( ungetc( *ptr, fp) == EOF && *ptr != EOF) return( NULL); bufptr = buf;