* 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.
This commit is contained in:
Pascal Bart
2001-08-30 18:51:56 +00:00
parent 5086915ebd
commit 8f451ef727
5 changed files with 27 additions and 12 deletions

View File

@@ -1,3 +1,16 @@
2001-08-30 Pascal Bart <pascal.bart@epita.fr>
* 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 <autret_m@epita.fr> 2001-08-30 Marc Autret <autret_m@epita.fr>
* src/reader.c (parse_skel_decl): New. * src/reader.c (parse_skel_decl): New.

View File

@@ -20,6 +20,7 @@
#include <string.h> #include <string.h>
#include "xalloc.h"
#include "system.h" #include "system.h"
#include "hash.h" #include "hash.h"
#include "files.h" #include "files.h"
@@ -110,16 +111,16 @@ macro_init (void)
} }
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->key = key;
pair->value = value; pair->value = value;
hash_insert (&macro_table, pair); hash_insert (&macro_table, pair);
} }
char* const char*
macro_find (char* key) macro_find (const char *key)
{ {
macro_entry_t pair = { key, 0 }; macro_entry_t pair = { key, 0 };
macro_entry_t* result = hash_find_item (&macro_table, &pair); macro_entry_t* result = hash_find_item (&macro_table, &pair);

View File

@@ -25,12 +25,12 @@
typedef struct macro_entry_s typedef struct macro_entry_s
{ {
char* key; const char* key;
char* value; const char* value;
} macro_entry_t; } macro_entry_t;
void macro_init PARAMS ((void)); void macro_init PARAMS ((void));
void macro_insert PARAMS ((char* key, char* value)); void macro_insert PARAMS ((const char *key, const char *value));
char* macro_find PARAMS ((char* key)); const char* macro_find PARAMS ((const char *key));
#endif /* not MACROTAB_H_ */ #endif /* not MACROTAB_H_ */

View File

@@ -34,6 +34,7 @@
#include "LR0.h" #include "LR0.h"
#include "conflicts.h" #include "conflicts.h"
#include "print_graph.h" #include "print_graph.h"
#include "macrotab.h"
/* The name this program was run with, for messages. */ /* The name this program was run with, for messages. */
char *program_name; char *program_name;

View File

@@ -130,7 +130,7 @@ struct obstack output_obstack;
static inline void static inline void
output_table_data (struct obstack* oout, output_table_data (struct obstack* oout,
short* table, short* table_data,
short first, short first,
short begin, short begin,
short end) short end)
@@ -149,7 +149,7 @@ output_table_data (struct obstack* oout,
} }
else else
++j; ++j;
obstack_fgrow1 (oout, "%6d", table[i]); obstack_fgrow1 (oout, "%6d", table_data[i]);
} }
obstack_1grow (oout, 0); obstack_1grow (oout, 0);
} }
@@ -984,8 +984,8 @@ output_parser (void)
else if ((c = getc (fskel)) == '%') else if ((c = getc (fskel)) == '%')
{ {
/* Read the macro. */ /* Read the macro. */
char* macro_key = 0; const char* macro_key = 0;
char* macro_value = 0; const char* macro_value = 0;
while (isalnum (c = getc (fskel)) || c == '_') while (isalnum (c = getc (fskel)) || c == '_')
obstack_1grow (&macro_obstack, c); obstack_1grow (&macro_obstack, c);
obstack_1grow (&macro_obstack, 0); obstack_1grow (&macro_obstack, 0);