summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-12-20 21:01:29 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2015-12-20 20:26:20 +0000
commit8fe68db9440d2c93f49282cbb4ffa154fc36782d (patch)
tree4e9278640c49a39cb9be97d8233575d6101ab25f
parentc067ba606eb88c4493353375d2198b9bc8b648a9 (diff)
downloadwireshark-8fe68db9440d2c93f49282cbb4ffa154fc36782d.tar.gz
Add COL_CUSTOM_PRIME_REGEX
Use this as a common regex to split multi-field custom columns. Change-Id: I40f76743284c5981c95d2e47d6d1d2a7f357d2ea Reviewed-on: https://code.wireshark.org/review/12753 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
-rw-r--r--epan/column-info.h1
-rw-r--r--epan/column-utils.c2
-rw-r--r--ui/gtk/filter_dlg.c3
-rw-r--r--ui/qt/syntax_line_edit.cpp3
4 files changed, 6 insertions, 3 deletions
diff --git a/epan/column-info.h b/epan/column-info.h
index f2c0ef25fe..45533ab72a 100644
--- a/epan/column-info.h
+++ b/epan/column-info.h
@@ -36,6 +36,7 @@ extern "C" {
#define COL_MAX_LEN 256
#define COL_MAX_INFO_LEN 4096
+#define COL_CUSTOM_PRIME_REGEX " *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *"
/** Column expression */
typedef struct {
diff --git a/epan/column-utils.c b/epan/column-utils.c
index 61f6d84589..604587e3d1 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -64,7 +64,7 @@ col_setup(column_info *cinfo, const gint num_cols)
cinfo->col_first[i] = -1;
cinfo->col_last[i] = -1;
}
- cinfo->prime_regex = g_regex_new(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
+ cinfo->prime_regex = g_regex_new(COL_CUSTOM_PRIME_REGEX,
G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED, NULL);
}
diff --git a/ui/gtk/filter_dlg.c b/ui/gtk/filter_dlg.c
index 941da3aec6..36f27b240f 100644
--- a/ui/gtk/filter_dlg.c
+++ b/ui/gtk/filter_dlg.c
@@ -28,6 +28,7 @@
#include <wsutil/filesystem.h>
#include <epan/prefs.h>
+#include <epan/column-info.h>
#include "ui/filters.h"
#include "ui/simple_dialog.h"
@@ -1349,7 +1350,7 @@ filter_te_syntax_check_cb(GtkWidget *w, gpointer user_data _U_)
gchar **fields;
guint i_field = 0;
- fields = g_regex_split_simple(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
+ fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX,
strval, G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
for (i_field =0; i_field < g_strv_length(fields); i_field += 1) {
diff --git a/ui/qt/syntax_line_edit.cpp b/ui/qt/syntax_line_edit.cpp
index bd2e16a4a5..5029687557 100644
--- a/ui/qt/syntax_line_edit.cpp
+++ b/ui/qt/syntax_line_edit.cpp
@@ -26,6 +26,7 @@
#include <epan/prefs.h>
#include <epan/proto.h>
#include <epan/dfilter/dfilter.h>
+#include <epan/column-info.h>
#include "syntax_line_edit.h"
@@ -189,7 +190,7 @@ void SyntaxLineEdit::checkCustomColumn(QString fields)
return;
}
- splitted_fields = g_regex_split_simple(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *",
+ splitted_fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX,
fields.toUtf8().constData(), G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
for (i_field =0; i_field < g_strv_length(splitted_fields); i_field += 1) {