mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-24 16:16:52 +02:00
Use g_vasprintf() and g_string_append_len(), thus enabling embedded nuls
2003-06-06 Matthias Clasen <maclas@gmx.de> * glib/gstring.c (g_string_append_printf_internal): Use g_vasprintf() and g_string_append_len(), thus enabling embedded nuls in the result of g_string_printf(). (#92492, Owen Taylor) * tests/string-test.c: Add a test for embedded nuls in the result of g_string_printf().
This commit is contained in:
parent
53efcd835d
commit
cc777da9c1
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
2003-06-06 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_append_printf_internal): Use
|
||||||
|
g_vasprintf() and g_string_append_len(), thus enabling embedded
|
||||||
|
nuls in the result of g_string_printf(). (#92492, Owen Taylor)
|
||||||
|
|
||||||
|
* tests/string-test.c: Add a test for embedded nuls in the
|
||||||
|
result of g_string_printf().
|
||||||
|
|
||||||
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
* glib/gprintf.[ch]: Synchronize argument names with headers and docs.
|
||||||
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
(g_vasprintf): An implementation of vasprintf(), code was lifted
|
||||||
from g_strdup_vprintf(). (#112365)
|
from g_strdup_vprintf(). (#112365)
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
#include "gprintf.h"
|
||||||
|
|
||||||
|
|
||||||
struct _GStringChunk
|
struct _GStringChunk
|
||||||
@ -780,9 +781,10 @@ g_string_append_printf_internal (GString *string,
|
|||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
|
gint length;
|
||||||
|
|
||||||
buffer = g_strdup_vprintf (fmt, args);
|
length = g_vasprintf (&buffer, fmt, args);
|
||||||
g_string_append (string, buffer);
|
g_string_append_len (string, buffer, length);
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +208,10 @@ main (int argc,
|
|||||||
g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0);
|
g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0);
|
||||||
g_string_insert(string1, 1, "QED");
|
g_string_insert(string1, 1, "QED");
|
||||||
g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0);
|
g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0);
|
||||||
|
g_string_printf (string1, "fiddle%cxyzzy", '\0');
|
||||||
|
g_assert (string1->len == 12);
|
||||||
|
g_assert (memcmp (string1->str, "fiddle\0xyzzy", 13) == 0);
|
||||||
|
|
||||||
g_string_free (string1, TRUE);
|
g_string_free (string1, TRUE);
|
||||||
g_string_free (string2, TRUE);
|
g_string_free (string2, TRUE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user