Add COL_CUSTOM_PRIME_REGEX
authorStig Bjørlykke <stig@bjorlykke.org>
Sun, 20 Dec 2015 20:01:29 +0000 (21:01 +0100)
committerStig Bjørlykke <stig@bjorlykke.org>
Sun, 20 Dec 2015 20:26:20 +0000 (20:26 +0000)
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>
epan/column-info.h
epan/column-utils.c
ui/gtk/filter_dlg.c
ui/qt/syntax_line_edit.cpp

index f2c0ef25fe38b0addc027b2853dc9a29d5b24b25..45533ab72a06d5ee82e4ba71123fec4ce2cbbaea 100644 (file)
@@ -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 {
index 61f6d84589c5c5b929c4ab17921050aeac5f5349..604587e3d1adf43434a23f2c4c00792386dee6cc 100644 (file)
@@ -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);
 }
 
index 941da3aec6792b8e70578ee830f83fa18d138d9c..36f27b240f7afbd42e53ba7d9f37fc52ade86612 100644 (file)
@@ -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) {
index bd2e16a4a5226b82f451e6cd9648d1990c1284fc..502968755720375a8b40714e874bc00f3ca0edd5 100644 (file)
@@ -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) {