/[bison]/bison/src/muscle_tab.c
ViewVC logotype

Diff of /bison/src/muscle_tab.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by akim, Tue Nov 12 08:05:59 2002 UTC revision 1.29 by eggert, Wed Dec 11 06:36:41 2002 UTC
# Line 19  Line 19 
19     Boston, MA 02111-1307, USA.  */     Boston, MA 02111-1307, USA.  */
20    
21  #include "system.h"  #include "system.h"
22  #include "hash.h"  
23  #include "quotearg.h"  #include <hash.h>
24    #include <quotearg.h>
25    
26  #include "files.h"  #include "files.h"
27  #include "muscle_tab.h"  #include "muscle_tab.h"
28  #include "getargs.h"  #include "getargs.h"
29    
30    typedef struct
31    {
32      const char *key;
33      char *value;
34    } muscle_entry;
35    
36  /* An obstack used to create some entries.  */  /* An obstack used to create some entries.  */
37  struct obstack muscle_obstack;  struct obstack muscle_obstack;
# Line 37  struct hash_table *muscle_table = NULL; Line 44  struct hash_table *muscle_table = NULL;
44  static bool  static bool
45  hash_compare_muscles (void const *x, void const *y)  hash_compare_muscles (void const *x, void const *y)
46  {  {
47    const muscle_entry_t *m1 = x;    muscle_entry const *m1 = x;
48    const muscle_entry_t *m2 = y;    muscle_entry const *m2 = y;
49    return strcmp (m1->key, m2->key) == 0;    return strcmp (m1->key, m2->key) == 0;
50  }  }
51    
52  static unsigned int  static unsigned int
53  hash_muscle (const void *x, unsigned int tablesize)  hash_muscle (const void *x, unsigned int tablesize)
54  {  {
55    const muscle_entry_t *m = x;    muscle_entry const *m = x;
56    return hash_string (m->key, tablesize);    return hash_string (m->key, tablesize);
57  }  }
58    
# Line 90  muscle_free (void) Line 97  muscle_free (void)
97  void  void
98  muscle_insert (const char *key, char *value)  muscle_insert (const char *key, char *value)
99  {  {
100    muscle_entry_t probe;    muscle_entry probe;
101    muscle_entry_t *entry = NULL;    muscle_entry *entry = NULL;
102    
103    probe.key = key;    probe.key = key;
104    entry = hash_lookup (muscle_table, &probe);    entry = hash_lookup (muscle_table, &probe);
# Line 99  muscle_insert (const char *key, char *va Line 106  muscle_insert (const char *key, char *va
106    if (!entry)    if (!entry)
107      {      {
108        /* First insertion in the hash. */        /* First insertion in the hash. */
109        entry = XMALLOC (muscle_entry_t, 1);        entry = XMALLOC (muscle_entry, 1);
110        entry->key = key;        entry->key = key;
111        hash_insert (muscle_table, entry);        hash_insert (muscle_table, entry);
112      }      }
# Line 116  muscle_insert (const char *key, char *va Line 123  muscle_insert (const char *key, char *va
123  void  void
124  muscle_grow (const char *key, const char *val, const char *separator)  muscle_grow (const char *key, const char *val, const char *separator)
125  {  {
126    muscle_entry_t probe;    muscle_entry probe;
127    muscle_entry_t *entry = NULL;    muscle_entry *entry = NULL;
128    
129    probe.key = key;    probe.key = key;
130    entry = hash_lookup (muscle_table, &probe);    entry = hash_lookup (muscle_table, &probe);
# Line 125  muscle_grow (const char *key, const char Line 132  muscle_grow (const char *key, const char
132    if (!entry)    if (!entry)
133      {      {
134        /* First insertion in the hash. */        /* First insertion in the hash. */
135        entry = XMALLOC (muscle_entry_t, 1);        entry = XMALLOC (muscle_entry, 1);
136        entry->key = key;        entry->key = key;
137        hash_insert (muscle_table, entry);        hash_insert (muscle_table, entry);
138        entry->value = xstrdup (val);        entry->value = xstrdup (val);
# Line 171  void muscle_pair_list_grow (const char * Line 178  void muscle_pair_list_grow (const char *
178  char*  char*
179  muscle_find (const char *key)  muscle_find (const char *key)
180  {  {
181    muscle_entry_t probe;    muscle_entry probe;
182    muscle_entry_t *result = NULL;    muscle_entry *result = NULL;
183    
184    probe.key = key;    probe.key = key;
185    result = hash_lookup (muscle_table, &probe);    result = hash_lookup (muscle_table, &probe);
# Line 185  muscle_find (const char *key) Line 192  muscle_find (const char *key)
192  `------------------------------------------------*/  `------------------------------------------------*/
193    
194  static int  static int
195  muscle_m4_output (muscle_entry_t *entry, FILE *out)  muscle_m4_output (muscle_entry *entry, FILE *out)
196  {  {
197    fprintf (out, "m4_define([b4_%s],\n", entry->key);    fprintf (out, "m4_define([b4_%s],\n", entry->key);
198    fprintf (out, "[[%s]])\n\n\n", entry->value);    fprintf (out, "[[%s]])\n\n\n", entry->value);

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26