Skip to content

Commit

Permalink
avoid _m4eof lines in generated bison code while printing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxmark committed Dec 31, 2019
1 parent 5ea7eb5 commit 5e61567
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* 2.4.x versions include bison version 2.7
* 2.5.x versions include bison version 3.x

### version 2.5.21
* avoid _m4eof lines in generated bison code while printing warnings

### version 2.5.20
* recovered invoking win_bison from different folders

Expand Down
9 changes: 9 additions & 0 deletions common/m4/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ static int sysval;
#include "vasnprintf.h"
/* cat content */
char *cat_string = NULL;
FILE* cat_out = NULL;

static void
m4_syscmd (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
Expand All @@ -977,6 +978,14 @@ m4_syscmd (struct obstack *obs M4_GNUC_UNUSED, int argc, token_data **argv)
if (old_cat_string != cat_string)
free(old_cat_string);

if (cat_out)
{
fprintf(cat_out, "%s", cat_string);
fflush(cat_out);
free(cat_string);
cat_string = NULL;
}

sysval = 0;
return;
}
Expand Down
12 changes: 3 additions & 9 deletions common/m4/m4.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ process_file (const char *name, FILE* in)
#define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:d::egil:o:st:"
#endif

extern char *cat_string;
extern FILE* cat_out;

int
main_m4 (int argc, char *const *argv, FILE* in, FILE* out)
Expand All @@ -381,6 +381,8 @@ main_m4 (int argc, char *const *argv, FILE* in, FILE* out)
const char *frozen_file_to_write = NULL;
const char *macro_sequence = "";

cat_out = out;

//set_program_name (argv[0]);
retcode = EXIT_SUCCESS;
//atexit (close_stdin);
Expand Down Expand Up @@ -692,14 +694,6 @@ main_m4 (int argc, char *const *argv, FILE* in, FILE* out)
undivert_all ();
}

if (cat_string)
{
fprintf(out, "%s", cat_string);
fflush(out);
free(cat_string);
cat_string = NULL;
}

output_exit ();
free_macro_sequence ();
// exit (retcode);
Expand Down

0 comments on commit 5e61567

Please sign in to comment.