diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-01-03 19:42:21 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-01-03 19:58:23 +0100 |
commit | 31b8b8f1799e43b5accf471e0f9645c832ffb8a3 (patch) | |
tree | 372a3f3eead5c764cfc0a5e04851f04bcb5b336f /examples | |
parent | e2199d0fb2e83d908b7a300da0ad00bea0d30e46 (diff) | |
download | bison-31b8b8f1799e43b5accf471e0f9645c832ffb8a3.tar.gz |
glr: example: flush the output
* examples/c/glr/c++-types.y: Flush stdout so that the logs (on
stderr) and the effective output (on stdout) mix correctly.
While at it, be a bit more const-correct.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/glr/c++-types.y | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y index 2d52b2b1..f99e0426 100644 --- a/examples/c/glr/c++-types.y +++ b/examples/c/glr/c++-types.y @@ -64,8 +64,8 @@ static Node *new_nterm (char const *, Node *, Node *, Node *); static Node *new_term (char *); static void free_node (Node *); - static char *node_to_string (Node *); - static void node_print (FILE *, Node *); + static char *node_to_string (const Node *); + static void node_print (FILE *, const Node *); static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1); static void yyerror (YYLTYPE const * const llocp, const char *msg); @@ -95,6 +95,7 @@ prog : %empty fputs (": ", stdout); node_print (stdout, $2); putc ('\n', stdout); + fflush (stdout); free_node ($2); } ; @@ -255,7 +256,7 @@ free_node (Node *node) } static char * -node_to_string (Node *node) +node_to_string (const Node *node) { char *res; if (!node) @@ -280,7 +281,8 @@ node_to_string (Node *node) return res; } -static void node_print (FILE *out, Node *n) +static void +node_print (FILE *out, const Node *n) { char *str = node_to_string (n); fputs (str, out); |