2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
2004-04-22 Matthias Clasen <mclasen@redhat.com>
+ * tests/testglib.c (main): Add testcases for g_message() involving
+ non-printable and unsafe characters.
+
+ * glib/gmessages.c (escape_string): Don't assume that
+ string->str remains unchanged over g_string_insert()
+ calls. (#139030, Christophe Saout)
+
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
locale-specific decimal separator directly follows a
number. (#138424, Nickolay V. Shmyrev)
if (wc == (gunichar)-1 || wc == (gunichar)-2)
{
gchar *tmp;
-
- g_string_erase (string, p - string->str, 1);
+ guint pos;
+
+ pos = p - string->str;
+
/* Emit invalid UTF-8 as hex escapes
*/
tmp = g_strdup_printf ("\\x%02x", (guint)(guchar)*p);
- g_string_insert (string, p - string->str, tmp);
- g_free (tmp);
+ g_string_erase (string, pos, 1);
+ g_string_insert (string, pos, tmp);
- p += 4; /* Skip over escape sequence */
+ p = string->str + (pos + 4); /* Skip over escape sequence */
+ g_free (tmp);
continue;
}
if (wc == '\r')
if (!safe)
{
gchar *tmp;
+ guint pos;
+
+ pos = p - string->str;
- g_string_erase (string, p - string->str, g_utf8_next_char (p) - p);
/* Largest char we escape is 0x0a, so we don't have to worry
* about 8-digit \Uxxxxyyyy
*/
tmp = g_strdup_printf ("\\u%04x", wc);
- g_string_insert (string, p - string->str, tmp);
+ g_string_erase (string, pos, g_utf8_next_char (p) - p);
+ g_string_insert (string, pos, tmp);
g_free (tmp);
- p += 6; /* Skip over escape sequence */
+ p = string->str + (pos + 6); /* Skip over escape sequence */
}
else
p = g_utf8_next_char (p);
g_message ("the next warning is a test:");
string = NULL;
g_print (string);
+ g_message ("non-printable UTF-8: \"\xc3\xa4\xda\x85\"");
+ g_message ("unsafe chars: \"\x10\x11\x12\n\t\x7f\x81\x82\x83\"");
g_print ("checking endian macros (host is ");
#if G_BYTE_ORDER == G_BIG_ENDIAN