Give a better error message for invalid characters in preference module names.

And make the message for an invalid character in a preference name more
like it, by putting the offending name in quotes.

Change-Id: I40db8b87eae5e46a1d49213a9a45861b6b3565af
Reviewed-on: https://code.wireshark.org/review/21092
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-04-14 12:34:18 -07:00
parent 74784bdb3e
commit c398858205
1 changed files with 6 additions and 4 deletions

View File

@ -517,9 +517,11 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
* on the command line, and shouldn't require quoting,
* shifting, etc.
*/
for (p = name; (c = *p) != '\0'; p++)
g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
c == '-' || c == '.');
for (p = name; (c = *p) != '\0'; p++) {
if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
c == '-' || c == '.'))
g_error("Preference module \"%s\" contains invalid characters", name);
}
/*
* Make sure there's not already a module with that
@ -916,7 +918,7 @@ register_preference(module_t *module, const char *name, const char *title,
*/
for (p = name; *p != '\0'; p++)
if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
g_error("Preference %s.%s contains invalid characters", module->name, name);
g_error("Preference \"%s.%s\" contains invalid characters", module->name, name);
/*
* Make sure there's not already a preference with that