mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
Backslashify also '"' characters.
* gstrfuncs.c (g_strescape): Backslashify also '"' characters. * glib.h: Document g_strescape.
This commit is contained in:
parent
e334434a9d
commit
37e447f278
10
ChangeLog
10
ChangeLog
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
1999-05-29 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
|
* gstrfuncs.c (g_strescape): Backslashify also '"' characters.
|
||||||
|
|
||||||
|
* glib.h: Document g_strescape.
|
||||||
|
|
||||||
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
1999-05-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
* glib.h (Win32): Map fileno to _fileno for mingw32. Map fstat to
|
||||||
_fstat.
|
_fstat.
|
||||||
|
|
||||||
* README.win32: Advice also to remove -lmoldname from the
|
* README.win32: Advice also to remove -lmoldname in the
|
||||||
patch to the egcs-1.1.2 spec file patch.
|
patch to the egcs-1.1.2 spec file.
|
||||||
|
|
||||||
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
Wed May 12 00:23:55 CDT 1999 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
4
glib.h
4
glib.h
@ -1551,7 +1551,11 @@ gchar* g_strconcat (const gchar *string1,
|
|||||||
...); /* NULL terminated */
|
...); /* NULL terminated */
|
||||||
gchar* g_strjoin (const gchar *separator,
|
gchar* g_strjoin (const gchar *separator,
|
||||||
...); /* NULL terminated */
|
...); /* 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);
|
gchar* g_strescape (gchar *string);
|
||||||
|
|
||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
|
@ -1551,7 +1551,11 @@ gchar* g_strconcat (const gchar *string1,
|
|||||||
...); /* NULL terminated */
|
...); /* NULL terminated */
|
||||||
gchar* g_strjoin (const gchar *separator,
|
gchar* g_strjoin (const gchar *separator,
|
||||||
...); /* NULL terminated */
|
...); /* 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);
|
gchar* g_strescape (gchar *string);
|
||||||
|
|
||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
|
@ -1074,25 +1074,28 @@ g_strescape (gchar *string)
|
|||||||
{
|
{
|
||||||
gchar *q;
|
gchar *q;
|
||||||
gchar *escaped;
|
gchar *escaped;
|
||||||
guint backslashes = 0;
|
guint escapes_needed = 0;
|
||||||
gchar *p = string;
|
gchar *p = string;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
while (*p != '\000')
|
while (*p != '\000')
|
||||||
backslashes += (*p++ == '\\');
|
{
|
||||||
|
escapes_needed += (*p == '\\' || *p == '"');
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!backslashes)
|
if (!escapes_needed)
|
||||||
return g_strdup (string);
|
return g_strdup (string);
|
||||||
|
|
||||||
escaped = g_new (gchar, strlen (string) + backslashes + 1);
|
escaped = g_new (gchar, strlen (string) + escapes_needed + 1);
|
||||||
|
|
||||||
p = string;
|
p = string;
|
||||||
q = escaped;
|
q = escaped;
|
||||||
|
|
||||||
while (*p != '\000')
|
while (*p != '\000')
|
||||||
{
|
{
|
||||||
if (*p == '\\')
|
if (*p == '\\' || *p == '"')
|
||||||
*q++ = '\\';
|
*q++ = '\\';
|
||||||
*q++ = *p++;
|
*q++ = *p++;
|
||||||
}
|
}
|
||||||
|
13
gstrfuncs.c
13
gstrfuncs.c
@ -1074,25 +1074,28 @@ g_strescape (gchar *string)
|
|||||||
{
|
{
|
||||||
gchar *q;
|
gchar *q;
|
||||||
gchar *escaped;
|
gchar *escaped;
|
||||||
guint backslashes = 0;
|
guint escapes_needed = 0;
|
||||||
gchar *p = string;
|
gchar *p = string;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
while (*p != '\000')
|
while (*p != '\000')
|
||||||
backslashes += (*p++ == '\\');
|
{
|
||||||
|
escapes_needed += (*p == '\\' || *p == '"');
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!backslashes)
|
if (!escapes_needed)
|
||||||
return g_strdup (string);
|
return g_strdup (string);
|
||||||
|
|
||||||
escaped = g_new (gchar, strlen (string) + backslashes + 1);
|
escaped = g_new (gchar, strlen (string) + escapes_needed + 1);
|
||||||
|
|
||||||
p = string;
|
p = string;
|
||||||
q = escaped;
|
q = escaped;
|
||||||
|
|
||||||
while (*p != '\000')
|
while (*p != '\000')
|
||||||
{
|
{
|
||||||
if (*p == '\\')
|
if (*p == '\\' || *p == '"')
|
||||||
*q++ = '\\';
|
*q++ = '\\';
|
||||||
*q++ = *p++;
|
*q++ = *p++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user