From 34231e94bf05e703994e7617faff53abdf1c9e72 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 29 Nov 1997 19:28:31 +0000 Subject: 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. --- lib/libc/stdio/snprintf.c | 5 +++-- lib/libc/stdio/vsnprintf.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/libc/stdio') 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 @@ -45,6 +45,7 @@ static char rcsid[] = "$OpenBSD: snprintf.c,v 1.3 1997/07/25 20:30:11 mickey Exp #include #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 +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; -- cgit v1.2.3