From 75dda6d424d6add1124eeaa6329b18a08e17fe2e Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Wed, 24 Jan 2018 13:57:38 -0500 Subject: [PATCH] lex: don't initialize yyin & yyout statically --- usr/src/cmd/sgs/lex/common/header.c | 2 +- usr/src/cmd/sgs/lex/common/parser.y | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/usr/src/cmd/sgs/lex/common/header.c b/usr/src/cmd/sgs/lex/common/header.c index 422e296656..9eb24a572b 100644 --- a/usr/src/cmd/sgs/lex/common/header.c +++ b/usr/src/cmd/sgs/lex/common/header.c @@ -276,7 +276,7 @@ chd1(void) else (void) fprintf(fout, "extern char *yysptr, yysbuf[];\n"); (void) fprintf(fout, "int yytchar;\n"); - (void) fprintf(fout, "FILE *yyin = {stdin}, *yyout = {stdout};\n"); + (void) fprintf(fout, "FILE *yyin, *yyout;\n"); (void) fprintf(fout, "extern int yylineno;\n"); (void) fprintf(fout, "struct yysvf { \n"); (void) fprintf(fout, "\tstruct yywork *yystoff;\n"); diff --git a/usr/src/cmd/sgs/lex/common/parser.y b/usr/src/cmd/sgs/lex/common/parser.y index ffca4771c4..383e23505c 100644 --- a/usr/src/cmd/sgs/lex/common/parser.y +++ b/usr/src/cmd/sgs/lex/common/parser.y @@ -328,7 +328,11 @@ yylex(void) lgate(); if(!ratfor)(void) fprintf(fout,"# "); (void) fprintf(fout,"define YYNEWLINE %d\n",ctable['\n']); - if(!ratfor)(void) fprintf(fout,"int yylex(){\nint nstr; extern int yyprevious;\n"); + if(!ratfor) { + (void) fprintf(fout,"int yylex(){\nint nstr; extern int yyprevious;\n"); + (void) fprintf(fout,"if (yyin == NULL) yyin = stdin;\n"); + (void) fprintf(fout,"if (yyout == NULL) yyout = stdout;\n"); + } sectbegin = TRUE; i = treesize*(sizeof(*name)+sizeof(*left)+ sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA; -- 2.11.4.GIT