diff --git a/src/filter.c b/src/filter.c index edf1ed84b..b9782f043 100644 --- a/src/filter.c +++ b/src/filter.c @@ -268,7 +268,7 @@ int filter_tee_header (struct filter *chain) fprintf (to_h, "#define %sIN_HEADER 1\n\n", ctrl.prefix); fprintf (to_h, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", - headerfilename ? headerfilename : ""); + env.headerfilename != NULL ? env.headerfilename : ""); } @@ -363,7 +363,7 @@ int filter_fix_linedirs (struct filter *chain) env.outfilename != NULL ? env.outfilename : "") == 0 || strcmp (fname, - headerfilename ? headerfilename : "") + env.headerfilename != NULL ? env.headerfilename : "") == 0) { char *s1, *s2; diff --git a/src/flexdef.h b/src/flexdef.h index ea049c118..c39bacca0 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -384,7 +384,7 @@ struct ctrl_bundle_t { // otherwise, use fread(). char *yyclass; // yyFlexLexer subclass to use for YY_DECL bool yytext_is_array; // if true (i.e., %array directive), then declare - // yytext as a array instead of a character pointer. + // yytext as array instead of a character pointer. // Nice and inefficient. }; @@ -396,6 +396,7 @@ struct env_bundle_t { bool backing_up_report; // (-b flag), generate "lex.backup" file // listing backing-up states bool did_outfilename; // whether outfilename was explicitly set + char *headerfilename; // name of the .h file to generate bool nowarn; // (-w) do not generate warnings int performance_hint; // if > 0 (i.e., -p flag), generate a report // relating to scanner performance; @@ -447,7 +448,6 @@ extern struct flex_backend_t *backend; * yyin - input file * infilename - name of input file * outfilename - name of output file - * headerfilename - name of the .h file to generate * input_files - array holding names of input files * num_input_files - size of input_files array * program_name - name with which program was invoked @@ -464,7 +464,7 @@ extern struct flex_backend_t *backend; extern int datapos, dataline, linenum; extern int skel_ind; -extern char *infilename, *headerfilename; +extern char *infilename; extern char *extra_type; extern char **input_files; extern int num_input_files; diff --git a/src/main.c b/src/main.c index 1750607bb..f6a4d2c46 100644 --- a/src/main.c +++ b/src/main.c @@ -56,7 +56,7 @@ int skel_ind = 0; char *action_array; int action_size, defs1_offset, prolog_offset, action_offset, action_index; -char *infilename = NULL, *headerfilename = NULL; +char *infilename = NULL; char *extra_type = NULL; int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; @@ -324,7 +324,7 @@ void check_options (void) /* Setup the filter chain. */ - output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); + output_chain = filter_create_int(NULL, filter_tee_header, env.headerfilename); if ( !(m4 = getenv("M4"))) { char *slash; m4 = M4; @@ -941,7 +941,7 @@ void flexinit (int argc, char **argv) break; case OPT_HEADER_FILE: - headerfilename = arg; + env.headerfilename = arg; break; case OPT_META_ECS: @@ -1571,7 +1571,7 @@ void usage (void) if (!env.did_outfilename) { snprintf (outfile_path, sizeof(outfile_path), outfile_template, - ctrl.prefix, ctrl.C_plus_plus ? "cc" : "c"); + ctrl.prefix, backend->suffix()); env.outfilename = outfile_path; } diff --git a/src/parse.y b/src/parse.y index ae4b82fee..1a7e1bbef 100644 --- a/src/parse.y +++ b/src/parse.y @@ -205,7 +205,7 @@ option : TOK_OUTFILE '=' NAME | TOK_YYCLASS '=' NAME { ctrl.yyclass = xstrdup(nmstr); } | TOK_HEADER_FILE '=' NAME - { headerfilename = xstrdup(nmstr); } + { env.headerfilename = xstrdup(nmstr); } | TOK_TABLES_FILE '=' NAME { tablesext = true; tablesfilename = xstrdup(nmstr); } ;