aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-02-16 03:10:46 +0000
committerGuy Harris <guy@alum.mit.edu>2015-02-16 03:10:56 +0000
commit876c322df8b6a944cb4358c313c4fc46afe99719 (patch)
tree73982a6ed110e59e911365b0983b92fa10a3caf9 /epan
parent45674b7a0402e8ee980de4a845b6d1a3753e2e7a (diff)
Revert "Fix duplicate Display Filter Macro check"
This reverts commit f5902a677e24ff96869d3c335f4fb8aaa6d0e543. This is not a simple cherry-pick; backporting this fix will have to be done manually. Change-Id: I53efc06a8e35c6b1aa793edf4e702cabee2e929b Reviewed-on: https://code.wireshark.org/review/7151 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dfilter/dfilter-macro.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index 234e2cea00..7f805859ad 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -403,7 +403,7 @@ const gchar* dfilter_macro_apply(const gchar* text, gchar** error) {
return dfilter_macro_apply_recurse(text, 0, error);
}
-static void macro_update(void* mp, gchar** error _U_) {
+static void macro_update(void* mp, gchar** error) {
dfilter_macro_t* m = (dfilter_macro_t*)mp;
GPtrArray* parts;
GArray* args_pos;
@@ -411,9 +411,22 @@ static void macro_update(void* mp, gchar** error _U_) {
gchar* w;
gchar* part;
int argc = 0;
+ guint i;
DUMP_MACRO(m);
+ *error = NULL;
+
+ for (i = 0; i < num_macros; i++) {
+ if (m == &(macros[i])) continue;
+
+ if ( g_str_equal(m->name,macros[i].name) ) {
+ *error = g_strdup_printf("macro '%s' exists already", m->name);
+ m->usable = FALSE;
+ return;
+ }
+ }
+
/* Invalidate the display filter in case it's in use */
if (dfilter_macro_uat && dfilter_macro_uat->post_update_cb)
dfilter_macro_uat->post_update_cb();
@@ -578,9 +591,7 @@ static void* macro_copy(void* dest, const void* orig, size_t len _U_) {
return d;
}
-static gboolean macro_name_chk(void *mp, const char *in_name, guint name_len,
- const void *u1 _U_, const void *u2 _U_, char **error) {
- dfilter_macro_t* m = (dfilter_macro_t*)mp;
+static gboolean macro_name_chk(void* r _U_, const char* in_name, guint name_len, const void* u1 _U_, const void* u2 _U_, char** error) {
guint i;
if (name_len == 0) {
@@ -595,22 +606,6 @@ static gboolean macro_name_chk(void *mp, const char *in_name, guint name_len,
}
}
- /* When loading (!m->name) or when adding/changing the an item with a
- * different name, check for uniqueness. NOTE: if a duplicate already
- * exists (because the user manually edited the file), then this will
- * not trigger a warning. */
- if (!m->name || !g_str_equal(m->name, in_name)) {
- for (i = 0; i < num_macros; i++) {
- /* This a string field which is always NUL-terminated,
- * so no need to check name_len. */
- if (g_str_equal(in_name, macros[i].name)) {
- *error = g_strdup_printf("macro '%s' already exists",
- in_name);
- return FALSE;
- }
- }
- }
-
return TRUE;
}