From: John Millaway Date: Tue, 14 Feb 2006 03:32:28 +0000 (+0000) Subject: Patch for full file system failure. X-Git-Tag: flex-2-5-33~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5b8d4db354f0b8f19091aa960a911fdf55bc3b0;p=flex Patch for full file system failure. --- diff --git a/filter.c b/filter.c index b2cf320..0018721 100644 --- a/filter.c +++ b/filter.c @@ -293,12 +293,23 @@ int filter_tee_header (struct filter *chain) fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h); fflush (to_h); - fclose (to_h); + if (ferror (to_h)) + lerrsf (_("error writing output file %s"), + (char *) chain->extra); + + else if (fclose (to_h)) + lerrsf (_("error closing output file %s"), + (char *) chain->extra); } fflush (to_c); - fclose (to_c); + if (ferror (to_c)) + lerrsf (_("error writing output file %s"), + outfilename ? outfilename : ""); + else if (fclose (to_c)) + lerrsf (_("error closing output file %s"), + outfilename ? outfilename : ""); while (wait (0) > 0) ; @@ -380,6 +391,13 @@ int filter_fix_linedirs (struct filter *chain) lineno++; } fflush (stdout); + if (ferror (stdout)) + lerrsf (_("error writing output file %s"), + outfilename ? outfilename : ""); + + else if (fclose (stdout)) + lerrsf (_("error closing output file %s"), + outfilename ? outfilename : ""); return 0; } diff --git a/gen.c b/gen.c index 5f4b4aa..b78f595 100644 --- a/gen.c +++ b/gen.c @@ -1982,7 +1982,7 @@ void make_tables () do_indent (); out_str ("for ( yyl = %s; yyl < yyleng; ++yyl )\n", yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" : - "(yy_more_len)") : "0"); + "YY_G(yy_more_len)") : "0"); indent_up (); indent_puts ("if ( yytext[yyl] == '\\n' )"); indent_up (); diff --git a/libyywrap.c b/libyywrap.c index 6345d9d..8561a43 100644 --- a/libyywrap.c +++ b/libyywrap.c @@ -21,8 +21,7 @@ /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ /* PURPOSE. */ - -int yywrap () +int yywrap (void) { return 1; } diff --git a/main.c b/main.c index 0527595..101ead8 100644 --- a/main.c +++ b/main.c @@ -148,7 +148,7 @@ int flex_main (argc, argv) int argc; char *argv[]; { - int i, exit_status; + int i, exit_status, child_status; /* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The * return value of setjmp, if non-zero, is the desired exit code PLUS ONE. @@ -163,9 +163,17 @@ int flex_main (argc, argv) fflush(stdout); fclose(stdout); } - while (wait(0) > 0){ + while (wait(&child_status) > 0){ + if (!WIFEXITED (child_status) + || WEXITSTATUS (child_status) != 0){ + /* report an error of a child + */ + if( exit_status <= 1 ) + exit_status = 2; + + } } - return exit_status - 1; + return exit_status - 1; } flexinit (argc, argv); @@ -1602,7 +1610,6 @@ void readin () outn ("#else"); outn (yy_stdinit); outn ("#endif"); - outn ("#endif"); } else {