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));
}
*/
{
+ 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;