Skip to content

Commit

Permalink
Methodize a suffix computation and move headerfile into ctrl.
Browse files Browse the repository at this point in the history
This cleans up some loose ends before the next big move.

westes#54 in the retargeting patch series. westes#53 slipped out unnumbered.
  • Loading branch information
eric-s-raymond committed Oct 2, 2020
1 parent 9dbc704 commit c5d0e40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 : "<stdout>");
env.headerfilename != NULL ? env.headerfilename : "<stdout>");

}

Expand Down Expand Up @@ -363,7 +363,7 @@ int filter_fix_linedirs (struct filter *chain)
env.outfilename != NULL ? env.outfilename : "<stdout>")
== 0
|| strcmp (fname,
headerfilename ? headerfilename : "<stdout>")
env.headerfilename != NULL ? env.headerfilename : "<stdout>")
== 0) {

char *s1, *s2;
Expand Down
6 changes: 3 additions & 3 deletions src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
;
Expand Down

0 comments on commit c5d0e40

Please sign in to comment.