From: Jérôme Benoit Date: Sun, 19 Nov 2017 13:45:46 +0000 (+0100) Subject: Add some fflush() for avoid loosing comme characters X-Git-Url: https://git.piment-noir.org/?p=TP_AL_C.git;a=commitdiff_plain;h=6c47be3237ab266b1cba4e3051afaaaa55e07e52 Add some fflush() for avoid loosing comme characters with fprintf(). Signed-off-by: Jérôme Benoit --- diff --git a/lexer/lexical_analyzer.c b/lexer/lexical_analyzer.c index 42ab960..7c85b4c 100644 --- a/lexer/lexical_analyzer.c +++ b/lexer/lexical_analyzer.c @@ -209,6 +209,7 @@ error: __func__, tokenTypestr[tokenType]); } + fflush(stderr); tokenType = FIN; exit(EXIT_FAILURE); } diff --git a/lexer/print_helper.c b/lexer/print_helper.c index 23684d5..9f97a8f 100644 --- a/lexer/print_helper.c +++ b/lexer/print_helper.c @@ -10,6 +10,7 @@ void pr_warning(const char* format, ...) { va_start(args, format); fprintf(stdout, format, args); va_end(args); + fflush(stdout); } void pr_error(const char *format, ...) { @@ -18,6 +19,7 @@ void pr_error(const char *format, ...) { va_start(args, format); fprintf(stderr, format, args); va_end(args); + fflush(stderr); } #if DEBUG @@ -27,6 +29,7 @@ void pr_debug(const char *format, ...) { va_start(args, format); fprintf(stderr, format, args); va_end(args); + fflush(stderr); } #else void pr_debug(const char *format, ...); @@ -38,6 +41,7 @@ void wpr_warning(const wchar_t *format, ...) { va_start(args, format); fwprintf(stdout, format, args); va_end(args); + fflush(stdout); } void wpr_error(const wchar_t *format, ...) { @@ -46,6 +50,7 @@ void wpr_error(const wchar_t *format, ...) { va_start(args, format); fwprintf(stderr, format, args); va_end(args); + fflush(stderr); } void wprint_token() { @@ -54,4 +59,5 @@ void wprint_token() { } else { fwprintf(target, L"%20s\n", tokenTypestr[tokenType]); } + fflush(target); } diff --git a/lexer/syntactic_analyzer.c b/lexer/syntactic_analyzer.c index 2d3880f..8d2d2e9 100644 --- a/lexer/syntactic_analyzer.c +++ b/lexer/syntactic_analyzer.c @@ -29,6 +29,7 @@ static void analyze_TEXT() { } else if (tokenType != MOTCLE && tokenType != NPARA && tokenType != SECTION && \ tokenType != SSECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } #if DEBUG @@ -58,10 +59,12 @@ static void analyze_P() { analyze_P(); } else if (tokenType != SECTION && tokenType != SSECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } } else if (tokenType != SECTION && tokenType != SSECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } #if DEBUG @@ -91,10 +94,12 @@ static void analyze_HEAD() { analyze_TEXT(); } else if (tokenType != NPARA && tokenType != SECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } } else if (tokenType != NPARA && tokenType != SECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } #if DEBUG @@ -148,6 +153,7 @@ static void analyze_S2() { analyze_S2(); } else if (tokenType != SECTION && tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } #if DEBUG @@ -166,6 +172,7 @@ static void analyze_S1() { analyze_S1(); } else if (tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } #if DEBUG @@ -199,10 +206,12 @@ void analyze_AXIOME() { analyze_BODY(); if (tokenType != FIN) { fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]); + fflush(stderr); exit(EXIT_FAILURE); } fprintf(stdout, "successful syntactic analysis\n"); #if DEBUG fprintf(stdout, "leaving %s\n", __func__); #endif + fflush(stdout); }