mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 12:55:48 +01:00
Make gnulib vfprintf return the number of bytes actually written
To be honest, i don't remember what problems were caused by it returning the number of bytes it *wanted* to write instead of the number of bytes it actually wrote. Probably related to the fact that fwrite could independently fail, and ignoring its return value ignores that error. https://bugzilla.gnome.org/show_bug.cgi?id=748064
This commit is contained in:
parent
82c2461e3d
commit
b7774b182d
@ -88,16 +88,16 @@ int _g_gnulib_vprintf (char const *format, va_list args)
|
|||||||
int _g_gnulib_vfprintf (FILE *file, char const *format, va_list args)
|
int _g_gnulib_vfprintf (FILE *file, char const *format, va_list args)
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
size_t length;
|
size_t length, rlength;
|
||||||
|
|
||||||
result = vasnprintf (NULL, &length, format, args);
|
result = vasnprintf (NULL, &length, format, args);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fwrite (result, 1, length, file);
|
rlength = fwrite (result, 1, length, file);
|
||||||
free (result);
|
free (result);
|
||||||
|
|
||||||
return length;
|
return rlength;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _g_gnulib_vsprintf (char *string, char const *format, va_list args)
|
int _g_gnulib_vsprintf (char *string, char const *format, va_list args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user