Remove more stdio copy/paste.
Change-Id: Ia92629b75d2c153ecf1cec711e2f9575eef604ab
diff --git a/libc/Android.bp b/libc/Android.bp
index 0a76e87..2ea6789 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -17,8 +17,6 @@
"bionic/system_properties_compat.c",
"stdio/fread.c",
"stdio/refill.c",
- "stdio/snprintf.c",
- "stdio/sprintf.c",
"stdio/stdio.cpp",
"stdio/stdio_ext.cpp",
"stdlib/atexit.c",
@@ -36,36 +34,26 @@
"bionic/time64.c",
]
+libc_common_flags = [
+ "-D_LIBC=1",
+ "-Wall",
+ "-Wextra",
+ "-Wunused",
+ "-Wno-deprecated-declarations",
+
+ // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
+ "-Werror=pointer-to-int-cast",
+ "-Werror=int-to-pointer-cast",
+ "-Werror=type-limits",
+ "-Werror",
+]
+
// Define some common cflags
// ========================================================
cc_defaults {
name: "libc_defaults",
- cflags: [
- "-D_LIBC=1",
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Wno-deprecated-declarations",
-
- // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
- "-Werror=pointer-to-int-cast",
- "-Werror=int-to-pointer-cast",
- "-Werror=type-limits",
- "-Werror",
- ],
- // TODO: split out the asflags.
- asflags: [
- "-D_LIBC=1",
- "-Wall",
- "-Wextra",
- "-Wunused",
-
- // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
- "-Werror=pointer-to-int-cast",
- "-Werror=int-to-pointer-cast",
- "-Werror=type-limits",
- "-Werror",
- ],
+ cflags: libc_common_flags,
+ asflags: libc_common_flags,
conlyflags: ["-std=gnu99"],
cppflags: [],
include_dirs: ["external/jemalloc/include"],
@@ -416,7 +404,6 @@
"upstream-openbsd/lib/libc/net/ntohl.c",
"upstream-openbsd/lib/libc/net/ntohs.c",
"upstream-openbsd/lib/libc/net/res_random.c",
- "upstream-openbsd/lib/libc/stdio/asprintf.c",
"upstream-openbsd/lib/libc/stdio/fflush.c",
"upstream-openbsd/lib/libc/stdio/fgetln.c",
"upstream-openbsd/lib/libc/stdio/fgets.c",
@@ -442,7 +429,6 @@
"upstream-openbsd/lib/libc/stdio/puts.c",
"upstream-openbsd/lib/libc/stdio/rget.c",
"upstream-openbsd/lib/libc/stdio/setvbuf.c",
- "upstream-openbsd/lib/libc/stdio/sscanf.c",
"upstream-openbsd/lib/libc/stdio/tempnam.c",
"upstream-openbsd/lib/libc/stdio/tmpnam.c",
"upstream-openbsd/lib/libc/stdio/ungetc.c",
@@ -454,7 +440,6 @@
"upstream-openbsd/lib/libc/stdio/vfwprintf.c",
"upstream-openbsd/lib/libc/stdio/vfwscanf.c",
"upstream-openbsd/lib/libc/stdio/vsnprintf.c",
- "upstream-openbsd/lib/libc/stdio/vsprintf.c",
"upstream-openbsd/lib/libc/stdio/vsscanf.c",
"upstream-openbsd/lib/libc/stdio/vswprintf.c",
"upstream-openbsd/lib/libc/stdio/vswscanf.c",
@@ -542,12 +527,6 @@
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
- multilib: {
- lib32: {
- // LP32 cruft
- srcs: ["upstream-openbsd/lib/libc/stdio/putw.c"],
- },
- },
arch: {
arm: {
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 1c6c845..53efef0 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -377,4 +377,12 @@
#endif // !defined(__BRILLO__) && !defined (__LP64__)
+#if !defined(__LP64__)
+// LP32's <stdio.h> had putw (but not getw).
+// TODO: does brillo intentionally include this, or is there a missing `nobrillo`?
+int putw(int value, FILE* fp) {
+ return fwrite(&value, sizeof(value), 1, fp) == 1 ? 0 : EOF;
+}
+#endif
+
} // extern "C"
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 1bbd669..097be3a 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -264,7 +264,7 @@
__errordecl(__fwrite_too_big_error, "fwrite called with size * count bigger than buffer");
__errordecl(__fwrite_overflow, "fwrite called with overflowing size * count");
-#if defined(__BIONIC_FORTIFY)
+#if defined(__BIONIC_FORTIFY) && !defined(__BIONIC_NO_STDIO_FORTIFY)
#if __ANDROID_API__ >= 17
__BIONIC_FORTIFY_INLINE
diff --git a/libc/stdio/snprintf.c b/libc/stdio/snprintf.c
deleted file mode 100644
index 9a25ef2..0000000
--- a/libc/stdio/snprintf.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $OpenBSD: snprintf.c,v 1.14 2005/10/10 12:00:52 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#undef _FORTIFY_SOURCE
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include "local.h"
-
-int
-snprintf(char *str, size_t n, const char *fmt, ...)
-{
- va_list ap;
- int ret;
- char dummy;
- FILE f;
- struct __sfileext fext;
-
- /* While snprintf(3) specifies size_t stdio uses an int internally */
- if (n > INT_MAX)
- n = INT_MAX;
- /* Stdio internals do not deal correctly with zero length buffer */
- if (n == 0) {
- str = &dummy;
- n = 1;
- }
- _FILEEXT_SETUP(&f, &fext);
- f._file = -1;
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = n - 1;
- va_start(ap, fmt);
- ret = __vfprintf(&f, fmt, ap);
- va_end(ap);
- *f._p = '\0';
- return (ret);
-}
diff --git a/libc/stdio/sprintf.c b/libc/stdio/sprintf.c
deleted file mode 100644
index 1245552..0000000
--- a/libc/stdio/sprintf.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* $OpenBSD: sprintf.c,v 1.13 2005/10/10 12:00:52 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <limits.h>
-#include "local.h"
-
-#if defined(APIWARN)
-__warn_references(sprintf,
- "warning: sprintf() is often misused, please use snprintf()");
-#endif
-
-int
-sprintf(char *str, const char *fmt, ...)
-{
- int ret;
- va_list ap;
- FILE f;
- struct __sfileext fext;
-
- _FILEEXT_SETUP(&f, &fext);
- f._file = -1;
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = INT_MAX;
- va_start(ap, fmt);
- ret = __vfprintf(&f, fmt, ap);
- va_end(ap);
- *f._p = '\0';
- return (ret);
-}
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 23a54de..c673611 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*/
+#define __BIONIC_NO_STDIO_FORTIFY
#include <stdio.h>
#include <errno.h>
@@ -643,6 +644,10 @@
return fp;
}
+int asprintf(char** s, const char* fmt, ...) {
+ PRINTF_IMPL(vasprintf(s, fmt, ap));
+}
+
char* ctermid(char* s) {
return s ? strcpy(s, _PATH_TTY) : const_cast<char*>(_PATH_TTY);
}
@@ -769,6 +774,18 @@
return setvbuf(fp, nullptr, _IOLBF, 0);
}
+int snprintf(char* s, size_t n, const char* fmt, ...) {
+ PRINTF_IMPL(vsnprintf(s, n, fmt, ap));
+}
+
+int sprintf(char* s, const char* fmt, ...) {
+ PRINTF_IMPL(vsnprintf(s, INT_MAX, fmt, ap));
+}
+
+int sscanf(const char* s, const char* fmt, ...) {
+ PRINTF_IMPL(vsscanf(s, fmt, ap));
+}
+
int swprintf(wchar_t* s, size_t n, const wchar_t* fmt, ...) {
PRINTF_IMPL(vswprintf(s, n, fmt, ap));
}
@@ -785,6 +802,10 @@
return vfscanf(stdin, fmt, ap);
}
+int vsprintf(char* s, const char* fmt, va_list ap) {
+ return vsnprintf(s, INT_MAX, fmt, ap);
+}
+
int vwprintf(const wchar_t* fmt, va_list ap) {
return vfwprintf(stdout, fmt, ap);
}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/asprintf.c b/libc/upstream-openbsd/lib/libc/stdio/asprintf.c
deleted file mode 100644
index 4823677..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/asprintf.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $OpenBSD: asprintf.c,v 1.22 2015/12/28 22:08:18 mmcc Exp $ */
-
-/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include "local.h"
-
-int
-asprintf(char **str, const char *fmt, ...)
-{
- int ret;
- va_list ap;
- FILE f;
- struct __sfileext fext;
- unsigned char *_base;
-
- _FILEEXT_SETUP(&f, &fext);
- f._file = -1;
- f._flags = __SWR | __SSTR | __SALC;
- f._bf._base = f._p = malloc(128);
- if (f._bf._base == NULL)
- goto err;
- f._bf._size = f._w = 127; /* Leave room for the NUL */
- va_start(ap, fmt);
- ret = __vfprintf(&f, fmt, ap);
- va_end(ap);
- if (ret == -1)
- goto err;
- *f._p = '\0';
- _base = realloc(f._bf._base, ret + 1);
- if (_base == NULL)
- goto err;
- *str = (char *)_base;
- return (ret);
-
-err:
- free(f._bf._base);
- f._bf._base = NULL;
- *str = NULL;
- errno = ENOMEM;
- return (-1);
-}
-DEF_WEAK(asprintf);
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putw.c b/libc/upstream-openbsd/lib/libc/stdio/putw.c
deleted file mode 100644
index 47941a4..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putw.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $OpenBSD: putw.c,v 1.10 2009/11/21 09:53:44 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#include <stdio.h>
-#include "local.h"
-#include "fvwrite.h"
-
-int
-putw(int w, FILE *fp)
-{
- struct __suio uio;
- struct __siov iov;
- int ret;
-
- iov.iov_base = &w;
- iov.iov_len = uio.uio_resid = sizeof(w);
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- FLOCKFILE(fp);
- _SET_ORIENTATION(fp, -1);
- ret = __sfvwrite(fp, &uio);
- FUNLOCKFILE(fp);
- return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/sscanf.c b/libc/upstream-openbsd/lib/libc/stdio/sscanf.c
deleted file mode 100644
index e371ca6..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/sscanf.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $OpenBSD: sscanf.c,v 1.14 2011/11/08 18:30:42 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include "local.h"
-
-/* ARGSUSED */
-static int
-eofread(void *cookie, char *buf, int len)
-{
-
- return (0);
-}
-
-/* SCANFLIKE2 */
-int
-sscanf(const char *str, const char *fmt, ...)
-{
- int ret;
- va_list ap;
- FILE f;
- struct __sfileext fext;
-
- _FILEEXT_SETUP(&f, &fext);
- f._flags = __SRD;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._r = strlen(str);
- f._read = eofread;
- f._lb._base = NULL;
- va_start(ap, fmt);
- ret = __svfscanf(&f, fmt, ap);
- va_end(ap);
- return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c
deleted file mode 100644
index 308ff37..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $OpenBSD: vsprintf.c,v 1.16 2009/11/09 00:18:28 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include "local.h"
-
-#if defined(APIWARN)
-__warn_references(vsprintf,
- "warning: vsprintf() is often misused, please use vsnprintf()");
-#endif
-
-int
-vsprintf(char *str, const char *fmt, __va_list ap)
-{
- int ret;
- FILE f;
- struct __sfileext fext;
-
- _FILEEXT_SETUP(&f, &fext);
- f._file = -1;
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *)str;
- f._bf._size = f._w = INT_MAX;
- ret = __vfprintf(&f, fmt, ap);
- *f._p = '\0';
- return (ret);
-}