diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-11-29 19:28:31 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-11-29 19:28:31 +0000 |
commit | 34231e94bf05e703994e7617faff53abdf1c9e72 (patch) | |
tree | 7c245c0a56fc6053c66305d0714db7a28bd7de05 /lib/libc/stdio | |
parent | bfccdb13aad2a0596bf90d32cc892cb4a5fa8ac5 (diff) |
Return -1, not EOF for size < 1. XPG4.2 specifies the return value
should be < 1. While EOF is currently defined as -1 it is bad form
to assume this.
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/snprintf.c | 5 | ||||
-rw-r--r-- | lib/libc/stdio/vsnprintf.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c index cab4690cd3b..2afabe725a0 100644 --- a/lib/libc/stdio/snprintf.c +++ b/lib/libc/stdio/snprintf.c @@ -35,7 +35,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: snprintf.c,v 1.3 1997/07/25 20:30:11 mickey Exp $"; +static char rcsid[] = "$OpenBSD: snprintf.c,v 1.4 1997/11/29 19:28:29 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -45,6 +45,7 @@ static char rcsid[] = "$OpenBSD: snprintf.c,v 1.3 1997/07/25 20:30:11 mickey Exp #include <varargs.h> #endif +int #ifdef __STDC__ snprintf(char *str, size_t n, char const *fmt, ...) #else @@ -60,7 +61,7 @@ snprintf(str, n, fmt, va_alist) FILE f; if ((int)n < 1) - return (EOF); + return (-1); #ifdef __STDC__ va_start(ap, fmt); #else diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c index e01e32d4723..85e456290b2 100644 --- a/lib/libc/stdio/vsnprintf.c +++ b/lib/libc/stdio/vsnprintf.c @@ -35,11 +35,12 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: vsnprintf.c,v 1.2 1996/08/19 08:33:14 tholo Exp $"; +static char rcsid[] = "$OpenBSD: vsnprintf.c,v 1.3 1997/11/29 19:28:30 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> +int vsnprintf(str, n, fmt, ap) char *str; size_t n; @@ -50,7 +51,7 @@ vsnprintf(str, n, fmt, ap) FILE f; if ((int)n < 1) - return (EOF); + return (-1); f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *)str; f._bf._size = f._w = n - 1; |