aboutsummaryrefslogtreecommitdiffstats
path: root/epan/prefs.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2007-11-27 18:52:51 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2007-11-27 18:52:51 +0000
commit4d005106f956ff792cd46cb90050f5ebf13f133e (patch)
tree593646c7e1eb44302243659672c5fc691f0d4272 /epan/prefs.c
parent3a9435a5c8f4833aeebc0a120f4fd0657e25db3e (diff)
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our own versions if they're missing from GLib (as is the case with GLib 1.x). In the code to build the list of named fields for Diameter, don't use g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping in the hash function and use g_ascii_strcasecmp() in the compare function. We do this because there is no guarantee that toupper(), tolower(), and functions that use them will, for example, map between "I" and "i" in all locales; in Turkish locales, for example, there are, in both upper case and lower case, versions of "i" with and without a dot, and the upper-case version of "i" is "I"-with-a-dot and the lower-case version of "I" is "i"-without-a-dot. This causes strings that should match not to match. This finishes fixing bug 2010 - an earlier checkin prevented the crash (as there are other ways to produce the same crash, e.g. a bogus dictionary.xml file), but didn't fix the case-insensitive string matching. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23623 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/prefs.c')
-rw-r--r--epan/prefs.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index e447aed95c..684d1494d5 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -51,6 +51,10 @@
#include <epan/prefs-int.h>
#include <epan/uat-int.h>
+#ifdef NEED_G_ASCII_STRCASECMP_H
+#include "g_ascii_strcasecmp.h"
+#endif
+
/* Internal functions */
static module_t *find_subtree(module_t *parent, const char *name);
static module_t *prefs_register_module_or_subtree(module_t *parent,
@@ -120,7 +124,7 @@ module_compare_name(gconstpointer p1_arg, gconstpointer p2_arg)
const module_t *p1 = p1_arg;
const module_t *p2 = p2_arg;
- return g_strcasecmp(p1->name, p2->name);
+ return g_ascii_strcasecmp(p1->name, p2->name);
}
static gint
@@ -129,7 +133,7 @@ module_compare_title(gconstpointer p1_arg, gconstpointer p2_arg)
const module_t *p1 = p1_arg;
const module_t *p2 = p2_arg;
- return g_strcasecmp(p1->title, p2->title);
+ return g_ascii_strcasecmp(p1->title, p2->title);
}
/*
@@ -1016,12 +1020,12 @@ find_val_for_string(const char *needle, const enum_val_t *haystack,
int i;
for (i = 0; haystack[i].name != NULL; i++) {
- if (strcasecmp(needle, haystack[i].name) == 0) {
+ if (g_ascii_strcasecmp(needle, haystack[i].name) == 0) {
return haystack[i].value;
}
}
for (i = 0; haystack[i].name != NULL; i++) {
- if (strcasecmp(needle, haystack[i].description) == 0) {
+ if (g_ascii_strcasecmp(needle, haystack[i].description) == 0) {
return haystack[i].value;
}
}
@@ -1764,28 +1768,28 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
prefs.st_server_bg.green = GREEN_COMPONENT(cval);
prefs.st_server_bg.blue = BLUE_COMPONENT(cval);
} else if (strcmp(pref_name, PRS_GUI_SCROLLBAR_ON_RIGHT) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_scrollbar_on_right = TRUE;
}
else {
prefs.gui_scrollbar_on_right = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_PLIST_SEL_BROWSE) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_plist_sel_browse = TRUE;
}
else {
prefs.gui_plist_sel_browse = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_PTREE_SEL_BROWSE) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_ptree_sel_browse = TRUE;
}
else {
prefs.gui_ptree_sel_browse = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_ALTERN_COLORS) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_altern_colors = TRUE;
}
else {
@@ -1801,7 +1805,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
prefs.gui_hex_dump_highlight_style =
find_index_from_string_array(value, gui_hex_dump_highlight_style_text, 1);
} else if (strcmp(pref_name, PRS_GUI_FILTER_TOOLBAR_IN_STATUSBAR) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.filter_toolbar_show_in_statusbar = TRUE;
}
else {
@@ -1843,21 +1847,21 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
g_free(prefs.gui_colorized_bg);
prefs.gui_colorized_bg = g_strdup(value);
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_POSITION) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_geometry_save_position = TRUE;
}
else {
prefs.gui_geometry_save_position = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_SIZE) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_geometry_save_size = TRUE;
}
else {
prefs.gui_geometry_save_size = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_MAXIMIZED) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_geometry_save_maximized = TRUE;
}
else {
@@ -1889,21 +1893,21 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
} else if (strcmp(pref_name, PRS_GUI_FILEOPEN_PREVIEW) == 0) {
prefs.gui_fileopen_preview = strtoul(value, NULL, 10);
} else if (strcmp(pref_name, PRS_GUI_ASK_UNSAVED) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_ask_unsaved = TRUE;
}
else {
prefs.gui_ask_unsaved = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_FIND_WRAP) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_find_wrap = TRUE;
}
else {
prefs.gui_find_wrap = FALSE;
}
} else if (strcmp(pref_name, PRS_GUI_USE_PREF_SAVE) == 0) {
- if (strcasecmp(value, "true") == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
prefs.gui_use_pref_save = TRUE;
}
else {
@@ -1950,13 +1954,13 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
g_free(prefs.capture_devices_hide);
prefs.capture_devices_hide = g_strdup(value);
} else if (strcmp(pref_name, PRS_CAP_PROM_MODE) == 0) {
- prefs.capture_prom_mode = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
+ prefs.capture_prom_mode = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_REAL_TIME) == 0) {
- prefs.capture_real_time = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
+ prefs.capture_real_time = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_AUTO_SCROLL) == 0) {
- prefs.capture_auto_scroll = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
+ prefs.capture_auto_scroll = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_SHOW_INFO) == 0) {
- prefs.capture_show_info = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
+ prefs.capture_show_info = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
/* handle the global options */
} else if (strcmp(pref_name, PRS_NAME_RESOLVE) == 0 ||
@@ -1967,9 +1971,9 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
*
* Otherwise, we treat it as a list of name types we want to resolve.
*/
- if (strcasecmp(value, "true") == 0)
+ if (g_ascii_strcasecmp(value, "true") == 0)
prefs.name_resolve = RESOLV_ALL;
- else if (strcasecmp(value, "false") == 0)
+ else if (g_ascii_strcasecmp(value, "false") == 0)
prefs.name_resolve = RESOLV_NONE;
else {
prefs.name_resolve = RESOLV_NONE; /* start out with none set */
@@ -2231,7 +2235,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
case PREF_BOOL:
/* XXX - give an error if it's neither "true" nor "false"? */
- if (strcasecmp(value, "true") == 0)
+ if (g_ascii_strcasecmp(value, "true") == 0)
bval = TRUE;
else
bval = FALSE;