When using the vsnprintf() implementation, '\0'-terminate the resulting

1999-04-18  Havoc Pennington  <hp@pobox.com>

	* gutils.c (g_snprintf): When using the vsnprintf()
		implementation, '\0'-terminate the resulting string
			and return its length rather than -1.
This commit is contained in:
Havoc Pennington 1999-04-19 01:05:17 +00:00 committed by Havoc Pennington
parent cd49c36373
commit f5722475f1
10 changed files with 62 additions and 2 deletions

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -1,3 +1,9 @@
1999-04-18 Havoc Pennington <hp@pobox.com>
* gutils.c (g_snprintf): When using the vsnprintf()
implementation, '\0'-terminate the resulting string
and return its length rather than -1.
Fri Apr 16 06:52:07 1999 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_unexp_token): feature G_TOKEN_EOF as a valid

View File

@ -139,7 +139,13 @@ g_snprintf (gchar *str,
va_start (args, fmt);
retval = vsnprintf (str, n, fmt, args);
va_end (args);
if (retval < 0)
{
str[n-1] = '\0';
retval = strlen (str);
}
return retval;
#else /* !HAVE_VSNPRINTF */
gchar *printed;

View File

@ -139,7 +139,13 @@ g_snprintf (gchar *str,
va_start (args, fmt);
retval = vsnprintf (str, n, fmt, args);
va_end (args);
if (retval < 0)
{
str[n-1] = '\0';
retval = strlen (str);
}
return retval;
#else /* !HAVE_VSNPRINTF */
gchar *printed;