summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-08-07 17:42:49 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-08-07 17:42:49 +0000
commit4fddafd8fca0d05717adb5204cea795c43bacfe9 (patch)
tree012120a9c876f65227be580b1fadad280199dc12 /lib/libc/stdio
parentd979bd14657315932ad5c6e70bcb81b039f10687 (diff)
Local changes that should not have gone in
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/Makefile.inc4
-rw-r--r--lib/libc/stdio/asnprintf.c106
-rw-r--r--lib/libc/stdio/fvwrite.c9
-rw-r--r--lib/libc/stdio/vasnprintf.c90
4 files changed, 4 insertions, 205 deletions
diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc
index 8a2903a3e54..b4507a3c56c 100644
--- a/lib/libc/stdio/Makefile.inc
+++ b/lib/libc/stdio/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.9 1999/08/07 17:35:58 millert Exp $
+# $OpenBSD: Makefile.inc,v 1.10 1999/08/07 17:42:48 millert Exp $
# stdio sources
.PATH: ${LIBCSRCDIR}/stdio
@@ -14,7 +14,7 @@ SRCS+= asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c sscanf.c \
stdio.c tempnam.c tmpfile.c tmpnam.c ungetc.c vasprintf.c vfprintf.c \
vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c \
- wbuf.c wsetup.c flockfile.c asnprintf.c vasnprintf.c
+ wbuf.c wsetup.c flockfile.c
MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fopen.3 fputs.3 \
fread.3 fseek.3 funopen.3 getc.3 mktemp.3 perror.3 printf.3 putc.3 \
diff --git a/lib/libc/stdio/asnprintf.c b/lib/libc/stdio/asnprintf.c
deleted file mode 100644
index 13db368376f..00000000000
--- a/lib/libc/stdio/asnprintf.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* $OpenBSD: asnprintf.c,v 1.1 1999/08/07 17:35:58 millert Exp $ */
-
-/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: asnprintf.c,v 1.1 1999/08/07 17:35:58 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-int
-#if __STDC__
-asnprintf(char **str, size_t n, char const *fmt, ...)
-#else
-asnprintf(str, n, fmt, va_alist)
- char **str;
- size_t n;
- const char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
- unsigned char *_base;
-
- /* While snprintf(3) specifies size_t stdio uses an int internally */
- if (n > INT_MAX)
- n = INT_MAX;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- f._file = -1;
- f._flags = __SWR | __SSTR;
- if (n > 0) {
- f._flags |= __SALC | __SAMX;
- f._bf._base = f._p = (unsigned char *)malloc(128);
- if (f._bf._base == NULL)
- goto err;
- f._bf._size = f._w = 127; /* Leave room for the NUL */
- f._blksize = n - 1;
- } else {
- f._bf._base = f._p = NULL;
- f._bf._size = f._w = 0;
- }
- ret = vfprintf(&f, fmt, ap);
- if (ret == -1)
- goto err;
- if (n > 0) {
- *f._p = '\0';
- va_end(ap);
- if (ret + 1 < n) {
- _base = realloc(f._bf._base, ret + 1);
- if (_base == NULL)
- goto err;
- else
- f._bf._base = _base;
- }
- }
- *str = f._bf._base;
- return (ret);
-
-err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
- *str = NULL;
- errno = ENOMEM;
- return (-1);
-}
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 444b33a6d59..0f7b20f9eed 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fvwrite.c,v 1.9 1999/08/07 17:35:58 millert Exp $";
+static char rcsid[] = "$OpenBSD: fvwrite.c,v 1.10 1999/08/07 17:42:48 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -111,9 +111,7 @@ __sfvwrite(fp, uio)
do {
GETIOV(;);
if ((fp->_flags & (__SALC | __SSTR)) ==
- (__SALC | __SSTR) && fp->_w < len &&
- ((fp->_flags & __SAMX) == 0 || fp->_bf._size
- <= fp->_blksize)) {
+ (__SALC | __SSTR) && fp->_w < len) {
size_t blen = fp->_p - fp->_bf._base;
unsigned char *_base;
int _size;
@@ -123,9 +121,6 @@ __sfvwrite(fp, uio)
do {
_size = (_size << 1) + 1;
} while (_size < blen + len);
- /* Apply maximum if v?asnprintf */
- if ((fp->_flags & __SAMX))
- _size = MIN(_size, fp->_blksize);
_base = realloc(fp->_bf._base, _size + 1);
if (_base == NULL)
goto err;
diff --git a/lib/libc/stdio/vasnprintf.c b/lib/libc/stdio/vasnprintf.c
deleted file mode 100644
index 831eb5a5f04..00000000000
--- a/lib/libc/stdio/vasnprintf.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $OpenBSD: vasnprintf.c,v 1.1 1999/08/07 17:35:58 millert Exp $ */
-
-/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: vasnprintf.c,v 1.1 1999/08/07 17:35:58 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <limits.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-vasnprintf(str, n, fmt, ap)
- char **str;
- size_t n;
- const char *fmt;
- _BSD_VA_LIST_ ap;
-{
- int ret;
- FILE f;
- unsigned char *_base;
-
- /* While snprintf(3) specifies size_t stdio uses an int internally */
- if (n > INT_MAX)
- n = INT_MAX;
- f._file = -1;
- f._flags = __SWR | __SSTR;
- if (n > 0) {
- f._flags |= __SALC | __SAMX;
- f._bf._base = f._p = (unsigned char *)malloc(128);
- if (f._bf._base == NULL)
- goto err;
- f._bf._size = f._w = 127; /* Leave room for the NULL */
- f._blksize = n - 1;
- } else {
- f._bf._base = f._p = NULL;
- f._bf._size = f._w = 0;
- }
- ret = vfprintf(&f, fmt, ap);
- if (ret == -1)
- goto err;
- if (n > 0) {
- *f._p = '\0';
- if (ret + 1 < n) {
- _base = realloc(f._bf._base, f._bf._size + 1);
- if (_base == NULL)
- goto err;
- else
- f._bf._base = _base;
- }
- }
- *str = f._bf._base;
- return (ret);
-
-err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
- *str = NULL;
- errno = ENOMEM;
- return (-1);
-}