summaryrefslogtreecommitdiff
path: root/libio/obprintf.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2018-03-04 12:17:44 -0500
committerZack Weinberg <zackw@panix.com>2018-05-31 21:28:17 -0400
commit3e20ce75755f7eef5fb85692e5b8733380d50ba4 (patch)
tree389270890b0b8da284049f5f2fc7f534dacca42b /libio/obprintf.c
parented9f16d99b1dc13b1b0bc78497a6457c17e3084d (diff)
downloadglibc-3e20ce75755f7eef5fb85692e5b8733380d50ba4.tar.gz
Add __v*printf_internal with flags arguments.
There are a lot more printf variants than there are scanf variants, and the code for setting up and tearing down their custom FILE variants around the call to __vf(w)printf is more complicated and variable. Therefore, I have added _internal versions of all the v*printf variants, rather than introducing helper routines so that they can all directly call __vf(w)printf_internal, as was done with scanf. Several of the affected public functions had _IO_ name aliases that were not exported (but, in one case, appeared in libio.h anyway); I was originally planning to leave them as aliases to avoid having to touch internal callers, but it turns out ldbl_*_alias only work for exported symbols, so they've all been removed instead. And as it turns out there were hardly any internal callers. _IO_vsprintf *is* exported, so that one sticks around. * libio/libioP.h (__vfprintf_internal, __vfwprintf_internal) (__vasprintf_internal, __vdprintf_internal, __obstack_vprintf_internal) (__vsprintf_internal, __vsnprintf_internal, __vswprintf_internal): New functions. (PRINTF_LDBL_IS_DBL, PRINTF_FORTIFY): New constants. (_IO_vasprintf, _IO_vdprintf, _IO_vsnprintf): Remove prototypes. * stdio-common/vfprintf-internal.c: Rename from vfprintf.c. Include wctype.h here if COMPILE_WPRINTF is defined. Define __vfprintf_internal or __vfwprintf_internal, depending on COMPILE_WPRINTF. Temporarily, on entry to this function, update mode_flags according to the environmental settings corresponding to PRINTF_LDBL_IS_DBL and PRINTF_FORTIFY. (LDBL_IS_DBL, DO_FORTIFY): New macros. Throughout, use LDBL_IS_DBL instead of __ldbl_is_dbl, and DO_FORTIFY instead of checking _IO_FLAGS2_FORTIFY on the destination FILE. * stdio-common/vfwprintf-internal.c: Rename from vfwprintf.c. Include vfprintf-internal.c. Don't include wctype.h. * stdio-common/vfprintf.c: New file. Just define __vfprintf as a wrapper around __vfprintf_internal, with aliases _IO_vfprintf and vfprintf. * stdio-common/vfwprintf.c: New file. Just define __vfwprintf as a wrapper around __vfwprintf_internal, with aliases _IO_vfwprintf and vfwprintf. * stdio-common/Makefile: Add vfprintf-internal and vfwprintf-internal. * libio/iovdprintf.c (_IO_vdprintf): Rename to __vdprintf_internal and add mode_flags argument; use __vfprintf_internal. (__vdprintf): New function. Alias vdprintf to this. * libio/iovsprintf.c (_IO_vsprintf, __vsprintf): Similarly. * libio/vasprintf.c (_IO_vasprintf, __vasprintf): Similarly. * libio/obprintf.c (_IO_obstack_vprintf, __obstack_vprintf): Similarly. (__obstack_printf): Use __obstack_printf_internal. * libio/vsnprintf.c (_IO_vsnprintf, ___vsnprintf): Similarly, with public aliases __vsnprintf and vsnprintf. * libio/vswprintf (_IO_vswprintf, __vswprintf): Similarly, with public aliases _IO_vsprintf and vsprintf. * libio/swprintf.c (__swprintf): Use __vswprintf_internal. * stdio-common/asprintf.c (__asprintf): Use __vasprintf_internal. * stdio-common/dprintf.c (__dprintf): Use __vdprintf_internal. * stdio-common/snprintf.c (__snprintf): Use __vsprintf_internal. * stdio-common/sprintf.c (__sprintf): Use __vsprintf_internal. * debug/obprintf_chk.c, debug/vasprintf_chk.c, debug/vdprintf_chk.c * debug/vsnprintf_chk.c, debug/vsprintf_chk.c, hurd/vpprintf.c * stdio-common/fprintf.c, stdio-common/fxprintf.c * stdio-common/printf.c: Use __vfprintf_internal. * debug/fwprintf_chk.c, debug/vfwprintf_chk.c, debug/vswprintf_chk.c * debug/vwprintf_chk.c, debug/wprintf_chk.c, libio/fwprintf.c * libio/vwprintf.c, libio/wprintf.c: Use __vfwprintf_internal. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Use __vsprintf_internal, __obstack_vprintf_internal, __vasprintf_internal, __vdprintf_internal, __vsnprintf_internal, __vswprintf_internal, __vfprintf_internal, and __vfwprintf_internal. * libio/libio.h: Remove libc_hidden_proto for _IO_vfprintf. Remove declaration of _IO_vfwprintf. * libio/iolibio.h: Remove libc_hidden_proto for _IO_vsprintf. Remove declarations of _IO_vswprintf, _IO_obstack_printf, and _IO_obstack_printf. * include/stdio.h: Add libc_hidden_proto for __vsnprintf and prototype for __vasprintf. * argp/argp-fmtstream.c: Use __vsnprintf, not _IO_vsnprintf. * argp/argp-help.c: Use __vasprintf, not _IO_vasprintf. * argp/argp-namefrob.c: Update to match.
Diffstat (limited to 'libio/obprintf.c')
-rw-r--r--libio/obprintf.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libio/obprintf.c b/libio/obprintf.c
index a74f9467a2..6bb51a411a 100644
--- a/libio/obprintf.c
+++ b/libio/obprintf.c
@@ -117,7 +117,8 @@ const struct _IO_jump_t _IO_obstack_jumps libio_vtable attribute_hidden =
int
-_IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+__obstack_vprintf_internal (struct obstack *obstack, const char *format,
+ va_list args, unsigned int mode_flags)
{
struct obstack_FILE
{
@@ -164,7 +165,8 @@ _IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
new_f.ofile.obstack = obstack;
- result = _IO_vfprintf (&new_f.ofile.file.file, format, args);
+ result = __vfprintf_internal (&new_f.ofile.file.file, format, args,
+ mode_flags);
/* Shrink the buffer to the space we really currently need. */
obstack_blank_fast (obstack, (new_f.ofile.file.file._IO_write_ptr
@@ -172,17 +174,22 @@ _IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
return result;
}
-ldbl_weak_alias (_IO_obstack_vprintf, obstack_vprintf)
+int
+__obstack_vprintf (struct obstack *obstack, const char *format, va_list ap)
+{
+ return __obstack_vprintf_internal (obstack, format, ap, 0);
+}
+ldbl_weak_alias (__obstack_vprintf, obstack_vprintf)
int
-_IO_obstack_printf (struct obstack *obstack, const char *format, ...)
+__obstack_printf (struct obstack *obstack, const char *format, ...)
{
int result;
va_list ap;
va_start (ap, format);
- result = _IO_obstack_vprintf (obstack, format, ap);
+ result = __obstack_vprintf_internal (obstack, format, ap, 0);
va_end (ap);
return result;
}
-ldbl_weak_alias (_IO_obstack_printf, obstack_printf)
+ldbl_weak_alias (__obstack_printf, obstack_printf)