[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module: xprintf
From: |
Bruno Haible |
Subject: |
Re: new module: xprintf |
Date: |
Sat, 20 Oct 2007 15:29:00 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Jim,
> I've just added a new module:
>
> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=78da34d40e6a2
Thanks; this module is necessary.
Two suggestions:
- Add a call to va_end() that matches the va_start() call. POSIX says:
"Each invocation of the va_start() and va_copy() macros shall be matched
by a corresponding invocation of the va_end() macro in the same function."
- I would make it clearer in the error message that the error is about
formatted output. I don't feel that "write error" is good enough, given
that the usual reasons for failing printf(), when !ferror(stream), are:
EINVAL - invalid format string
EILSEQ - cannot convert a wide character string
ENOMEM - out of memory
and these are not immediately related to writing on the stream.
How about this?
*** lib/xprintf.c.orig 2007-10-20 15:27:04.000000000 +0200
--- lib/xprintf.c 2007-10-20 15:20:34.000000000 +0200
***************
*** 38,44 ****
va_start (args, format);
int err = vprintf (format, args);
if (err < 0 && ! ferror (stdout))
! error (exit_failure, errno, gettext ("write error"));
return err;
}
--- 38,45 ----
va_start (args, format);
int err = vprintf (format, args);
if (err < 0 && ! ferror (stdout))
! error (exit_failure, errno, gettext ("cannot perform formatted output"));
! va_end (args);
return err;
}
***************
*** 52,58 ****
va_start (args, format);
int err = vfprintf (stream, format, args);
if (err < 0 && ! ferror (stream))
! error (exit_failure, errno, gettext ("write error"));
return err;
}
--- 53,60 ----
va_start (args, format);
int err = vfprintf (stream, format, args);
if (err < 0 && ! ferror (stream))
! error (exit_failure, errno, gettext ("cannot perform formatted output"));
! va_end (args);
return err;
}
Re: new module: xprintf, Bruno Haible, 2007/10/28