From c420b83ee5b06a25545b68c485629e657b8049b4 Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Tue, 25 May 2010 20:57:14 +0000 Subject: [PATCH] find_val_for_string() is only used in prefs.c so remove the prototype and make it static. When reading enum preferences, use the current value of the preference as the default value of the preference instead of a hard-coded 1. This way if we couldn't find the appropriate value we'll don't end up changing the preference to something that may or may not make sense. svn path=/trunk/; revision=32950 --- epan/prefs-int.h | 6 +----- epan/prefs.c | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/epan/prefs-int.h b/epan/prefs-int.h index 7d3d28fd9c..3769dce666 100644 --- a/epan/prefs-int.h +++ b/epan/prefs-int.h @@ -42,7 +42,7 @@ struct pref_module { }; /* - * Module used for protocol preferences. + * Module used for protocol preferences. * With MSVC and a libwireshark.dll, we need a special declaration. */ WS_VAR_IMPORT module_t *protocols_module; @@ -97,10 +97,6 @@ struct preference { void *control; /* handle for GUI control for this preference */ }; -gint find_val_for_string(const char *needle, const enum_val_t *haystack, - gint default_value); - - /* read_prefs_file: read in a generic config file and do a callback to */ /* pref_set_pair_fct() for every key/value pair found */ typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, gchar *value, void *private_data); diff --git a/epan/prefs.c b/epan/prefs.c index 7d81946ff6..5ac2a702d8 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -988,9 +988,9 @@ prefs_clear_string_list(GList *sl) * Otherwise, the default value that was passed as the third argument is * returned. */ -gint +static gint find_val_for_string(const char *needle, const enum_val_t *haystack, - gint default_value) + gint default_value) { int i; @@ -2551,8 +2551,8 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_) case PREF_ENUM: /* XXX - give an error if it doesn't match? */ - enum_val = find_val_for_string(value, - pref->info.enum_info.enumvals, 1); + enum_val = find_val_for_string(value, pref->info.enum_info.enumvals, + *pref->varp.enump); if (*pref->varp.enump != enum_val) { module->prefs_changed = TRUE; *pref->varp.enump = enum_val;