Replace some fprintf()s by the simpler fput{c,s}().
[cparser] / token.c
diff --git a/token.c b/token.c
index 52ff730..946f510 100644 (file)
--- a/token.c
+++ b/token.c
@@ -32,7 +32,7 @@
 static symbol_t *token_symbols[T_LAST_TOKEN];
 static symbol_t *pp_token_symbols[TP_LAST_TOKEN];
 
-source_position_t builtin_source_position = { "<built-in>", 0 };
+const source_position_t builtin_source_position = { "<built-in>", 0 };
 
 void init_tokens(void)
 {
@@ -51,13 +51,15 @@ void init_tokens(void)
                assert(T_##x >= 0 && T_##x < T_LAST_TOKEN);                \
                symbol               = symbol_table_insert(str);           \
                symbol->ID           = T_##x;                              \
-               token_symbols[T_##x] = symbol;                             \
+               if (token_symbols[T_##x] == NULL)                          \
+                       token_symbols[T_##x] = symbol;                         \
        }
 
 #define TS(x,str,val)                                              \
        assert(T_##x >= 0 && T_##x < T_LAST_TOKEN);                    \
        symbol               = symbol_table_insert(str);               \
-       token_symbols[T_##x] = symbol;
+       if (token_symbols[T_##x] == NULL)                              \
+               token_symbols[T_##x] = symbol;                             \
 
 #include "tokens.inc"
 
@@ -68,12 +70,14 @@ void init_tokens(void)
        assert(TP_##x >= 0 && TP_##x < TP_LAST_TOKEN);                 \
        symbol                   = symbol_table_insert(str);           \
        symbol->pp_ID            = TP_##x;                             \
-       pp_token_symbols[TP_##x] = symbol;
+       if (pp_token_symbols[TP_##x] == NULL)                          \
+               pp_token_symbols[TP_##x] = symbol;
 
 #define TS(x,str,val)                                              \
        assert(TP_##x >= 0 && TP_##x < T_LAST_TOKEN);                  \
        symbol                   = symbol_table_insert(str);           \
-       pp_token_symbols[TP_##x] = symbol;
+       if (pp_token_symbols[TP_##x] == NULL)                          \
+               pp_token_symbols[TP_##x] = symbol;
 
 #include "tokens_preprocessor.inc"