* tests/calc.m4 (calc.y): Do not assign to stdin, as it's not

portable.
This commit is contained in:
Akim Demaille
2000-09-19 12:37:58 +00:00
parent cbd25751d4
commit 05a1d24b1e
2 changed files with 11 additions and 4 deletions

View File

@@ -54,11 +54,13 @@ exp: NUM { $$ = $1; }
| '(' exp ')' { $$ = $2; }
;
%%
FILE *yyin = stdin;
int
main (int argn, const char **argv)
{
if (argn == 2)
stdin = fopen (argv[1], "r");
yyin = fopen (argv[1], "r");
if (!stdin)
{
perror (argv[1]);
@@ -110,13 +112,13 @@ yylex ()
int c;
/* Skip white space. */
while ((c = getchar ()) == ' ' || c == '\t')
while ((c = getc (yyin)) == ' ' || c == '\t')
;
/* process numbers */
if (c == '.' || isdigit (c))
{
ungetc (c, stdin);
yylval = read_signed_integer (stdin);
ungetc (c, yyin);
yylval = read_signed_integer (yyin);
return NUM;
}
/* Return end-of-file. */