[glib] Fix to handle '\v' (vertical tab) by g_strescape() and g_strcompress().
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix to handle '\v' (vertical tab) by g_strescape() and g_strcompress().
- Date: Wed, 28 Dec 2011 02:49:54 +0000 (UTC)
commit 8ca2647c7405d06231ca5e0cfa47621e5086a65a
Author: Ravi Sankar Guntur <ravi g samsung com>
Date: Tue Dec 20 14:49:53 2011 +0530
Fix to handle '\v' (vertical tab) by g_strescape() and g_strcompress().
fix enables g_strescape() and g_strcompress() to handle '\v' along with other
special characters - '\b', '\f', '\n', '\r', '\t', '\'.
https://bugzilla.gnome.org/show_bug.cgi?id=664830
Signed-off-by: Ravi Sankar Guntur <ravi g samsung com>
glib/gstrfuncs.c | 9 ++++++++-
glib/tests/strfuncs.c | 16 ++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 63e1be9..19365b2 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -2022,6 +2022,9 @@ g_strcompress (const gchar *source)
case 't':
*q++ = '\t';
break;
+ case 'v':
+ *q++ = '\v';
+ break;
default: /* Also handles \" and \\ */
*q++ = *p;
break;
@@ -2042,7 +2045,7 @@ out:
* @source: a string to escape
* @exceptions: a string of characters not to escape in @source
*
- * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\'
+ * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
* and '"' in the string @source by inserting a '\' before
* them. Additionally all characters in the range 0x01-0x1F (everything
* below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
@@ -2109,6 +2112,10 @@ g_strescape (const gchar *source,
*q++ = '\\';
*q++ = 't';
break;
+ case '\v':
+ *q++ = '\\';
+ *q++ = 'v';
+ break;
case '\\':
*q++ = '\\';
*q++ = '\\';
diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c
index 3387734..358bc58 100644
--- a/glib/tests/strfuncs.c
+++ b/glib/tests/strfuncs.c
@@ -374,9 +374,9 @@ test_strcompress_strescape (void)
g_test_trap_assert_failed ();
}
- str = g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z");
+ str = g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\v\\003\\177\\234\\313\\12345z");
g_assert (str != NULL);
- g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\003\177\234\313\12345z");
+ g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\v\003\177\234\313\12345z");
g_free (str);
/* test escape */
@@ -389,22 +389,22 @@ test_strcompress_strescape (void)
g_test_trap_assert_failed ();
}
- str = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313", NULL);
+ str = g_strescape ("abc\\\"\b\f\n\r\t\v\003\177\234\313", NULL);
g_assert (str != NULL);
- g_assert_cmpstr (str, ==, "abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313");
+ g_assert_cmpstr (str, ==, "abc\\\\\\\"\\b\\f\\n\\r\\t\\v\\003\\177\\234\\313");
g_free (str);
- str = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313",
+ str = g_strescape ("abc\\\"\b\f\n\r\t\v\003\177\234\313",
"\b\f\001\002\003\004");
g_assert (str != NULL);
- g_assert_cmpstr (str, ==, "abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313");
+ g_assert_cmpstr (str, ==, "abc\\\\\\\"\b\f\\n\\r\\t\\v\003\\177\\234\\313");
g_free (str);
/* round trip */
- tmp = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313", NULL);
+ tmp = g_strescape ("abc\\\"\b\f\n\r\t\v\003\177\234\313", NULL);
str = g_strcompress (tmp);
g_assert (str != NULL);
- g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\003\177\234\313");
+ g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\v\003\177\234\313");
g_free (str);
g_free (tmp);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]