From: Pascal Bart Date: Thu, 30 Aug 2001 18:51:56 +0000 (+0000) Subject: * src/main.c: Include macrotab.h. X-Git-Tag: pre-merge-of-1-29-branch~41 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/8f451ef727ff90cdd31ee23eb6d408a931d4e5b3 * src/main.c: Include macrotab.h. * src/macrotab.h (macro_entry_s): Constify fields. Adjust functions prototypes. * src/macrotab.c (macro_insert): Constify key and value. (macro_find): Constify key. (macro_insert): Include 'xalloc.h' (macro_insert): Use XMALLOC. (macro_find): Constify return value. * src/output.c (output_table_data): Rename table to table_data. (output_parser): Constify macro_key, macro_value. --- diff --git a/ChangeLog b/ChangeLog index 54ddc726..a26be138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-08-30 Pascal Bart + + * src/main.c: Include macrotab.h. + * src/macrotab.h (macro_entry_s): Constify fields. + Adjust functions prototypes. + * src/macrotab.c (macro_insert): Constify key and value. + (macro_find): Constify key. + (macro_insert): Include 'xalloc.h' + (macro_insert): Use XMALLOC. + (macro_find): Constify return value. + * src/output.c (output_table_data): Rename table to table_data. + (output_parser): Constify macro_key, macro_value. + 2001-08-30 Marc Autret * src/reader.c (parse_skel_decl): New. diff --git a/src/macrotab.c b/src/macrotab.c index 91944ac2..03353e66 100644 --- a/src/macrotab.c +++ b/src/macrotab.c @@ -20,6 +20,7 @@ #include +#include "xalloc.h" #include "system.h" #include "hash.h" #include "files.h" @@ -110,16 +111,16 @@ macro_init (void) } void -macro_insert (char* key, char* value) +macro_insert (const char *key, const char *value) { - macro_entry_t* pair = (macro_entry_t*) xmalloc (sizeof (macro_entry_t)); + macro_entry_t* pair = XMALLOC (macro_entry_t, 1); pair->key = key; pair->value = value; hash_insert (¯o_table, pair); } -char* -macro_find (char* key) +const char* +macro_find (const char *key) { macro_entry_t pair = { key, 0 }; macro_entry_t* result = hash_find_item (¯o_table, &pair); diff --git a/src/macrotab.h b/src/macrotab.h index 6c3a364f..0a40a0ea 100644 --- a/src/macrotab.h +++ b/src/macrotab.h @@ -25,12 +25,12 @@ typedef struct macro_entry_s { - char* key; - char* value; + const char* key; + const char* value; } macro_entry_t; void macro_init PARAMS ((void)); -void macro_insert PARAMS ((char* key, char* value)); -char* macro_find PARAMS ((char* key)); +void macro_insert PARAMS ((const char *key, const char *value)); +const char* macro_find PARAMS ((const char *key)); #endif /* not MACROTAB_H_ */ diff --git a/src/main.c b/src/main.c index 6a89f5c8..8592b294 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,7 @@ #include "LR0.h" #include "conflicts.h" #include "print_graph.h" +#include "macrotab.h" /* The name this program was run with, for messages. */ char *program_name; diff --git a/src/output.c b/src/output.c index 21711cb1..c8830c4e 100644 --- a/src/output.c +++ b/src/output.c @@ -130,7 +130,7 @@ struct obstack output_obstack; static inline void output_table_data (struct obstack* oout, - short* table, + short* table_data, short first, short begin, short end) @@ -149,7 +149,7 @@ output_table_data (struct obstack* oout, } else ++j; - obstack_fgrow1 (oout, "%6d", table[i]); + obstack_fgrow1 (oout, "%6d", table_data[i]); } obstack_1grow (oout, 0); } @@ -984,8 +984,8 @@ output_parser (void) else if ((c = getc (fskel)) == '%') { /* Read the macro. */ - char* macro_key = 0; - char* macro_value = 0; + const char* macro_key = 0; + const char* macro_value = 0; while (isalnum (c = getc (fskel)) || c == '_') obstack_1grow (¯o_obstack, c); obstack_1grow (¯o_obstack, 0);