From 37e447f278b37c1138115ee9400ba9f6b418a07a Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 29 May 1999 10:28:06 +0000 Subject: [PATCH] Backslashify also '"' characters. * gstrfuncs.c (g_strescape): Backslashify also '"' characters. * glib.h: Document g_strescape. --- ChangeLog | 10 ++++++++-- ChangeLog.pre-2-0 | 10 ++++++++-- ChangeLog.pre-2-10 | 10 ++++++++-- ChangeLog.pre-2-12 | 10 ++++++++-- ChangeLog.pre-2-2 | 10 ++++++++-- ChangeLog.pre-2-4 | 10 ++++++++-- ChangeLog.pre-2-6 | 10 ++++++++-- ChangeLog.pre-2-8 | 10 ++++++++-- glib.h | 4 ++++ glib/glib.h | 4 ++++ glib/gstrfuncs.c | 13 ++++++++----- gstrfuncs.c | 13 ++++++++----- 12 files changed, 88 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84a4059..cea0ff8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 84a4059..cea0ff8 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,10 +1,16 @@ +1999-05-29 Tor Lillqvist + + * gstrfuncs.c (g_strescape): Backslashify also '"' characters. + + * glib.h: Document g_strescape. + 1999-05-12 Tor Lillqvist * glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to _fstat. - * README.win32: Advice also to remove -lmoldname from the - patch to the egcs-1.1.2 spec file patch. + * README.win32: Advice also to remove -lmoldname in the + patch to the egcs-1.1.2 spec file. Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson diff --git a/glib.h b/glib.h index b1a4148..2587368 100644 --- a/glib.h +++ b/glib.h @@ -1551,7 +1551,11 @@ gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ gchar* g_strjoin (const gchar *separator, ...); /* NULL terminated */ +/* Return a duplicate of the string with \ and " characters escaped by + * a \. The returned string should be freed with g_free(). + */ gchar* g_strescape (gchar *string); + gpointer g_memdup (gconstpointer mem, guint byte_size); diff --git a/glib/glib.h b/glib/glib.h index b1a4148..2587368 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -1551,7 +1551,11 @@ gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ gchar* g_strjoin (const gchar *separator, ...); /* NULL terminated */ +/* Return a duplicate of the string with \ and " characters escaped by + * a \. The returned string should be freed with g_free(). + */ gchar* g_strescape (gchar *string); + gpointer g_memdup (gconstpointer mem, guint byte_size); diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index d490dff..2de42ae 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -1074,25 +1074,28 @@ g_strescape (gchar *string) { gchar *q; gchar *escaped; - guint backslashes = 0; + guint escapes_needed = 0; gchar *p = string; g_return_val_if_fail (string != NULL, NULL); while (*p != '\000') - backslashes += (*p++ == '\\'); + { + escapes_needed += (*p == '\\' || *p == '"'); + p++; + } - if (!backslashes) + if (!escapes_needed) return g_strdup (string); - escaped = g_new (gchar, strlen (string) + backslashes + 1); + escaped = g_new (gchar, strlen (string) + escapes_needed + 1); p = string; q = escaped; while (*p != '\000') { - if (*p == '\\') + if (*p == '\\' || *p == '"') *q++ = '\\'; *q++ = *p++; } diff --git a/gstrfuncs.c b/gstrfuncs.c index d490dff..2de42ae 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -1074,25 +1074,28 @@ g_strescape (gchar *string) { gchar *q; gchar *escaped; - guint backslashes = 0; + guint escapes_needed = 0; gchar *p = string; g_return_val_if_fail (string != NULL, NULL); while (*p != '\000') - backslashes += (*p++ == '\\'); + { + escapes_needed += (*p == '\\' || *p == '"'); + p++; + } - if (!backslashes) + if (!escapes_needed) return g_strdup (string); - escaped = g_new (gchar, strlen (string) + backslashes + 1); + escaped = g_new (gchar, strlen (string) + escapes_needed + 1); p = string; q = escaped; while (*p != '\000') { - if (*p == '\\') + if (*p == '\\' || *p == '"') *q++ = '\\'; *q++ = *p++; } -- 2.7.4