mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* src/files.c (tr): Change return type to void.
* src/muscle_tab.c (muscle_insert): Free storage in case muscle_grow has been called previously for the same key. (muscle_find): Return storage instead of value so that --enable-gcc-warnings doesn't produce warnings that the return discards const. aver that the value and storage are the same since storage could potentially be NULL when value is not. * tests/testsuite.at (AT_CHECK): Treat an unspecified exit value the same as 0.
This commit is contained in:
@@ -137,7 +137,7 @@ xfclose (FILE *ptr)
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
/* In the string S, replace all characters FROM by TO. */
|
||||
static char *
|
||||
static void
|
||||
tr (char *s, char from, char to)
|
||||
{
|
||||
for (; *s; s++)
|
||||
|
||||
@@ -123,9 +123,11 @@ muscle_insert (char const *key, char const *value)
|
||||
entry = xmalloc (sizeof *entry);
|
||||
entry->key = key;
|
||||
hash_insert (muscle_table, entry);
|
||||
entry->storage = NULL;
|
||||
}
|
||||
else
|
||||
free (entry->storage);
|
||||
entry->value = value;
|
||||
entry->storage = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,9 +209,11 @@ void muscle_pair_list_grow (const char *muscle,
|
||||
obstack_free (&muscle_obstack, pair);
|
||||
}
|
||||
|
||||
/*-------------------------------.
|
||||
| Find the value of muscle KEY. |
|
||||
`-------------------------------*/
|
||||
/*----------------------------------------------------------------------------.
|
||||
| Find the value of muscle KEY. Abort if muscle_insert was invoked more |
|
||||
| recently than muscle_grow for KEY since muscle_find can't return a |
|
||||
| char const *. |
|
||||
`----------------------------------------------------------------------------*/
|
||||
|
||||
char *
|
||||
muscle_find (const char *key)
|
||||
@@ -219,7 +223,12 @@ muscle_find (const char *key)
|
||||
|
||||
probe.key = key;
|
||||
result = hash_lookup (muscle_table, &probe);
|
||||
return result ? result->value : NULL;
|
||||
if (result)
|
||||
{
|
||||
aver (result->value == result->storage);
|
||||
return result->storage;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user