Back out part related to "return 0 if n == 0" and return EOF as before.
The main argument is that it is impossible to determine if %n evaluated or not when snprintf return 0, because it can happens for both n == 0 and n == 1. Although EOF here is good indication of the end of process, if n is decreased in the loop... Since it is already supposed in many places that EOF *is* negative, f.e. from Single Unix specs for snprintf "return ... a negative value if an output error was encountered" this not makes situation worse.
This commit is contained in:
parent
e73e3ecc2a
commit
42a7fea93b
@ -39,7 +39,7 @@
|
||||
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: snprintf.c,v 1.5 1997/02/22 15:02:29 peter Exp $";
|
||||
"$Id: snprintf.c,v 1.6 1997/12/24 12:31:31 ache Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -65,8 +65,6 @@ snprintf(str, n, fmt, va_alist)
|
||||
va_list ap;
|
||||
FILE f;
|
||||
|
||||
if (n == 0)
|
||||
return (0);
|
||||
if ((int)n < 1)
|
||||
return (EOF);
|
||||
n--;
|
||||
|
@ -39,7 +39,7 @@
|
||||
static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: vsnprintf.c,v 1.5 1997/02/22 15:02:45 peter Exp $";
|
||||
"$Id: vsnprintf.c,v 1.6 1997/12/24 12:31:32 ache Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -54,8 +54,6 @@ vsnprintf(str, n, fmt, ap)
|
||||
int ret;
|
||||
FILE f;
|
||||
|
||||
if (n == 0)
|
||||
return (0);
|
||||
if ((int)n < 1)
|
||||
return (EOF);
|
||||
n--;
|
||||
|
Loading…
Reference in New Issue
Block a user