Add some fflush() for avoid loosing comme characters
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 19 Nov 2017 13:45:46 +0000 (14:45 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 19 Nov 2017 13:45:46 +0000 (14:45 +0100)
with fprintf().

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
lexer/lexical_analyzer.c
lexer/print_helper.c
lexer/syntactic_analyzer.c

index 42ab960eab1287665d4802d77a2532a4dcde2723..7c85b4c4973dc8e12a530e3a4112991d3100d4c2 100644 (file)
@@ -209,6 +209,7 @@ error:
                   __func__,
                   tokenTypestr[tokenType]);
     }
                   __func__,
                   tokenTypestr[tokenType]);
     }
+    fflush(stderr);
     tokenType = FIN;
     exit(EXIT_FAILURE);
 }
     tokenType = FIN;
     exit(EXIT_FAILURE);
 }
index 23684d5e22e6785fdd30fc7925b82bbb5e26cac0..9f97a8fffe6f6acecd827d9382b5e8313ede6404 100644 (file)
@@ -10,6 +10,7 @@ void pr_warning(const char* format, ...) {
     va_start(args, format);
     fprintf(stdout, format, args);
     va_end(args);
     va_start(args, format);
     fprintf(stdout, format, args);
     va_end(args);
+    fflush(stdout);
 }
 
 void pr_error(const char *format, ...) {
 }
 
 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);
     va_start(args, format);
     fprintf(stderr, format, args);
     va_end(args);
+    fflush(stderr);
 }
 
 #if DEBUG
 }
 
 #if DEBUG
@@ -27,6 +29,7 @@ void pr_debug(const char *format, ...) {
     va_start(args, format);
     fprintf(stderr, format, args);
     va_end(args);
     va_start(args, format);
     fprintf(stderr, format, args);
     va_end(args);
+    fflush(stderr);
 }
 #else
 void pr_debug(const char *format, ...);
 }
 #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);
     va_start(args, format);
     fwprintf(stdout, format, args);
     va_end(args);
+    fflush(stdout);
 }
 
 void wpr_error(const wchar_t *format, ...) {
 }
 
 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);
     va_start(args, format);
     fwprintf(stderr, format, args);
     va_end(args);
+    fflush(stderr);
 }
 
 void wprint_token() {
 }
 
 void wprint_token() {
@@ -54,4 +59,5 @@ void wprint_token() {
     } else {
         fwprintf(target, L"%20s\n", tokenTypestr[tokenType]);
     }
     } else {
         fwprintf(target, L"%20s\n", tokenTypestr[tokenType]);
     }
+    fflush(target);
 }
 }
index 2d3880ff963fa1cccac02f2c3371d9d989b751cd..8d2d2e93837565b1fe4f60085ee01623c377180f 100644 (file)
@@ -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]);
     } 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
         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]);
             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]);
             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
         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]);
             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]);
             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
         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]);
         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
         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]);
         analyze_S1();
     } else if (tokenType != FIN) {
         fprintf(stderr, "%s follows error on %s\n", __func__, tokenTypestr[tokenType]);
+        fflush(stderr);
         exit(EXIT_FAILURE);
     }
     #if DEBUG
         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]);
     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
         exit(EXIT_FAILURE);
     }
     fprintf(stdout, "successful syntactic analysis\n");
     #if DEBUG
     fprintf(stdout, "leaving %s\n", __func__);
     #endif
+    fflush(stdout);
 }
 }