diff options
author | John Millaway <john43@users.sourceforge.net> | 2006-02-14 03:32:28 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2006-02-14 03:32:28 +0000 |
commit | d5b8d4db354f0b8f19091aa960a911fdf55bc3b0 (patch) | |
tree | 98a2ed43fefdea189c29d19b14cfc6d856e3f793 | |
parent | 9d660e2b9b934f82b90072a7be69301799d44c40 (diff) |
Patch for full file system failure.
-rw-r--r-- | filter.c | 22 | ||||
-rw-r--r-- | gen.c | 2 | ||||
-rw-r--r-- | libyywrap.c | 3 | ||||
-rw-r--r-- | main.c | 15 |
4 files changed, 33 insertions, 9 deletions
@@ -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 : "<stdout>"); + else if (fclose (to_c)) + lerrsf (_("error closing output file %s"), + outfilename ? outfilename : "<stdout>"); 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 : "<stdout>"); + + else if (fclose (stdout)) + lerrsf (_("error closing output file %s"), + outfilename ? outfilename : "<stdout>"); return 0; } @@ -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; } @@ -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 { |