diff options
author | Stephen Fisher <steve@stephen-fisher.com> | 2011-04-13 16:56:24 +0000 |
---|---|---|
committer | Stephen Fisher <steve@stephen-fisher.com> | 2011-04-13 16:56:24 +0000 |
commit | 9246c41703309b14121e2e646324a50e16e79bbe (patch) | |
tree | d9119b221ad5ac22649facb16b9cc172842a4704 /epan/strutil.c | |
parent | 763603d3b6717cc5d35c5e117af165ddef9438ff (diff) |
Change ws_strdup_escape_underscore() function to be more general, by
accepting any character as the escaped character. Change existing
uses to use '_' for the underscore escaping.
svn path=/trunk/; revision=36627
Diffstat (limited to 'epan/strutil.c')
-rw-r--r-- | epan/strutil.c | 20 |
1 files changed, 10 insertions, 10 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++; |