summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/strutil.c20
-rw-r--r--epan/strutil.h18
-rw-r--r--gtk/new_packet_list.c6
3 files changed, 23 insertions, 21 deletions
diff --git a/epan/strutil.c b/epan/strutil.c
index b9f11c86c8..62c2b163b1 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -1015,11 +1015,11 @@ IA5_7BIT_decode(unsigned char * dest, const unsigned char* src, int len)
}
/*
- * This function takes a string and copies it, inserting an underscore before
- * every underscore in it.
+ * This function takes a string and copies it, inserting a 'chr' before
+ * every 'chr' in it.
*/
gchar*
-ws_strdup_escape_underscore (const gchar *str)
+ws_strdup_escape_char (const gchar *str, const gchar chr)
{
gchar *p, *q, *new_str;
@@ -1027,13 +1027,13 @@ ws_strdup_escape_underscore (const gchar *str)
return NULL;
p = (gchar *)str;
- /* Worst case: A string that is full of underscores */
+ /* Worst case: A string that is full of 'chr' */
q = new_str = g_malloc (strlen(str) * 2 + 1);
while(*p != 0)
{
- if(*p == '_')
- *q++ = '_';
+ if(*p == chr)
+ *q++ = chr;
*q++ = *p++;
}
@@ -1044,10 +1044,10 @@ ws_strdup_escape_underscore (const gchar *str)
/*
* This function takes a string and copies it, removing any occurences of double
- * underscores with a single underscore.
+ * 'chr' with a single 'chr'.
*/
gchar*
-ws_strdup_unescape_underscore (const gchar *str)
+ws_strdup_unescape_char (const gchar *str, const char chr)
{
gchar *p, *q, *new_str;
@@ -1055,13 +1055,13 @@ ws_strdup_unescape_underscore (const gchar *str)
return NULL;
p = (gchar *)str;
- /* Worst case: A string that contains no underscores */
+ /* Worst case: A string that contains no 'chr' */
q = new_str = g_malloc (strlen(str) + 1);
while(*p != 0)
{
*q++ = *p;
- if ((*p == '_') && (*(p+1) == '_'))
+ if ((*p == chr) && (*(p+1) == chr))
p += 2;
else
p++;
diff --git a/epan/strutil.h b/epan/strutil.h
index 83c040a06e..38da893a25 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -239,21 +239,23 @@ char * escape_string(char *dst, const char *string);
void IA5_7BIT_decode(unsigned char * dest, const unsigned char* src, int len);
-/** Copy a string, escaping the underscores in it
+/** Copy a string, escaping the 'chr' characters in it
*
* @param str The string to be copied
- * @return A copy of the string with every original underscore being
- * transformed into double underscores.
+ * @param char The character to be escaped
+ * @return A copy of the string with every original 'chr' being
+ * transformed into double 'chr'.
*/
-gchar* ws_strdup_escape_underscore (const gchar *str);
+gchar* ws_strdup_escape_char (const gchar *str, const gchar chr);
-/** Copy a string, unescaping the underscores in it
+/** Copy a string, unescaping the 'chr' characters in it
*
* @param str The string to be copied
- * @return A copy of the string with every occurence of double underscores in
- * the original string being copied as a single underscore.
+ * @param char The character to be escaped
+ * @return A copy of the string with every occurence of double 'chr' in
+ * the original string being copied as a single 'chr'.
*/
-gchar* ws_strdup_unescape_underscore (const gchar *str);
+gchar* ws_strdup_unescape_char (const gchar *str, const gchar chr);
/** Replace values in a string
*
diff --git a/gtk/new_packet_list.c b/gtk/new_packet_list.c
index 06bfaae217..c54c83ace2 100644
--- a/gtk/new_packet_list.c
+++ b/gtk/new_packet_list.c
@@ -237,7 +237,7 @@ col_title_change_ok (GtkWidget *w, gpointer parent_w)
occurrence_text = gtk_entry_get_text(GTK_ENTRY(g_object_get_data (G_OBJECT(w), COL_EDIT_OCCURRENCE_TE)));
occurrence = (gint)strtol(occurrence_text, NULL, 10);
- escaped_title = ws_strdup_escape_underscore(title);
+ escaped_title = ws_strdup_escape_char(title, '_');
gtk_tree_view_column_set_title(col, escaped_title);
g_free(escaped_title);
@@ -317,7 +317,7 @@ static void
col_details_edit_dlg (gint col_id, GtkTreeViewColumn *col)
{
const gchar *title = gtk_tree_view_column_get_title(col);
- gchar *unescaped_title = ws_strdup_unescape_underscore(title);
+ gchar *unescaped_title = ws_strdup_unescape_char(title, '_');
GtkWidget *label, *field_lb, *occurrence_lb;
GtkWidget *title_te, *format_cmb, *field_te, *occurrence_te;
@@ -790,7 +790,7 @@ create_view_and_model(void)
} else {
tooltip_text = g_strdup(col_format_desc(cfile.cinfo.col_fmt[i]));
}
- escaped_title = ws_strdup_escape_underscore(cfile.cinfo.col_title[i]);
+ escaped_title = ws_strdup_escape_char(cfile.cinfo.col_title[i], '_');
gtk_tree_view_column_set_title(col, escaped_title);
g_free (escaped_title);
gtk_tree_view_column_set_clickable(col, TRUE);