summaryrefslogtreecommitdiff
path: root/stdio-common/fxprintf.c
AgeCommit message (Collapse)Author
2018-02-21Mechanically remove _IO_ name aliases for types and constants.Zack Weinberg
This patch mechanically removes all remaining uses, and the definitions, of the following libio name aliases: name replaced with ---- ------------- _IO_FILE FILE _IO_fpos_t __fpos_t _IO_fpos64_t __fpos64_t _IO_size_t size_t _IO_ssize_t ssize_t or __ssize_t _IO_off_t off_t _IO_off64_t off64_t _IO_pid_t pid_t _IO_uid_t uid_t _IO_wint_t wint_t _IO_va_list va_list or __gnuc_va_list _IO_BUFSIZ BUFSIZ _IO_cookie_io_functions_t cookie_io_functions_t __io_read_fn cookie_read_function_t __io_write_fn cookie_write_function_t __io_seek_fn cookie_seek_function_t __io_close_fn cookie_close_function_t I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because the definitions of fpos_t and fpos64_t depend on the largefile mode. I used __ssize_t and __gnuc_va_list in a handful of headers where namespace cleanliness might be relevant even though they're internal-use-only. In all other cases, I used the public-namespace name. There are a tiny handful of places where I left a use of 'struct _IO_FILE' alone, because it was being used together with 'struct _IO_FILE_plus' or 'struct _IO_FILE_complete' in the same arithmetic expression. Because this patch was almost entirely done with search and replace, I may have introduced indentation botches. I did proofread the diff, but I may have missed something. The ChangeLog below calls out all of the places where this was not a pure search-and-replace change. Installed stripped libraries and executables are unchanged by this patch, except that some assertions in vfscanf.c change line numbers. * libio/libio.h (_IO_FILE): Delete; all uses changed to FILE. (_IO_fpos_t): Delete; all uses changed to __fpos_t. (_IO_fpos64_t): Delete; all uses changed to __fpos64_t. (_IO_size_t): Delete; all uses changed to size_t. (_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t. (_IO_off_t): Delete; all uses changed to off_t. (_IO_off64_t): Delete; all uses changed to off64_t. (_IO_pid_t): Delete; all uses changed to pid_t. (_IO_uid_t): Delete; all uses changed to uid_t. (_IO_wint_t): Delete; all uses changed to wint_t. (_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list. (_IO_BUFSIZ): Delete; all uses changed to BUFSIZ. (_IO_cookie_io_functions_t): Delete; all uses changed to cookie_io_functions_t. (__io_read_fn): Delete; all uses changed to cookie_read_function_t. (__io_write_fn): Delete; all uses changed to cookie_write_function_t. (__io_seek_fn): Delete; all uses changed to cookie_seek_function_t. (__io_close_fn): Delete: all uses changed to cookie_close_function_t. * libio/iofopncook.c: Remove unnecessary forward declarations. * libio/iolibio.h: Correct outdated commentary. * malloc/malloc.c (__malloc_stats): Remove unnecessary casts. * stdio-common/fxprintf.c (__fxprintf_nocancel): Remove unnecessary casts. * stdio-common/getline.c: Use _IO_getdelim directly. Don't redefine ssize_t. * stdio-common/printf_fp.c, stdio_common/printf_fphex.c * stdio-common/printf_size.c: Don't redefine size_t or FILE. Remove outdated comments. * stdio-common/vfscanf.c: Don't redefine va_list.
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-04-07getopt: clean up error reportingZack Weinberg
getopt can print a whole bunch of error messages, and when used standalone (from gnulib) it uses fprintf to do that. But fprintf is a cancellation point and getopt isn't, and also applying fprintf to a stream in wide-character mode is not allowed. glibc has an internal function called __fxprintf that writes a narrow format string to a stream regardless of mode, but it only handles ASCII format strings, and it's still a cancellation point. getopt's messages are translated, so they might not be ASCII. So getopt has an error message to an asprintf buffer, monkeys with internal flag bits on stderr to disable cancellation, and then calls __fxprintf(stderr, "%s", buffer). There isn't even a helper function, the code is duplicated every time. This patch fixes __fxprintf to handle arbitrary multibyte format strings, and adds a variant __fxprintf_nocancel that does the same thing but also isn't a cancellation point. (It still _works_ by monkeying with internal flag bits on the FILE, but that's not really a layering violation for code in stdio-common.) All of the #ifdef _LIBC blocks can then be reduced to their standalone versions with a little help from some macros at the top of the file. I also wrote a test case to verify that getopt really isn't a cancellation point, and I'm glad I did, because it found two bugs, one of which wasn't even to do with cancellation (see previous patch). * stdio-common/fxprintf.c (__fxprintf_nocancel): New function. (locked_vfxprintf): New helper function. Handle arbitrary multibyte strings, not just ASCII. * include/stdio.h: Declare __fxprintf_nocancel. * posix/getopt.c: When _LIBC is defined, define fprintf to __fxprintf_nocancel, flockfile to _IO_flockfile, and funlockfile to _IO_funlockfile. When neither _LIBC nor _POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and funlockfile as no-ops. (_getopt_internal_r): Remove all internal #ifdef _LIBC blocks; the standalone error-printing code can now be used for libc as well. Add an flockfile/funlockfile pair around one case where the error message is printed in several chunks. Don't use fputc. * posix/tst-getopt-cancel.c: New test. * posix/Makefile: Run it.
2017-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
2016-01-04Update copyright dates with scripts/update-copyrights.Joseph Myers
2015-01-02Update copyright dates with scripts/update-copyrights.Joseph Myers
2014-01-01Update copyright notices with scripts/update-copyrightsAllan McRae
2013-01-02Update copyright notices with scripts/update-copyrights.Joseph Myers
2012-05-24Remove use of INTDEF/INTUSE in libioAndreas Schwab
2012-02-09Replace FSF snail mail address with URLs.Paul Eggert
2005-08-08* stdio-common/fxprintf.c: Include libioP.h.Ulrich Drepper
2005-07-28* stdio-common/fxprintf.c (__fxprintf): Add INTUSE to _IO_vfprintfUlrich Drepper
call. * gmon/gmon.c (write_gmon): Use __snprintf rather than snprintf.
2005-07-22* stdio-common/fxprintf.c (__fxprintf): Declare functions more local.Ulrich Drepper
2005-07-22 Jakub Jelinek <jakub@redhat.com> * wcsmbs/bits/wchar2.h (__vfwprintf_chk, __vwprintf_chk): Use __gnuc_va_list rather than _G_va_list.
2005-07-21* wcsmbs/bits/wchar2.h (swprintf): Remove format argument.Ulrich Drepper
* debug/tst-chk1.c (do_test): Add test for swprintf with format being the last argument. 2005-07-21 Thorsten Kukuk <kukuk@suse.de> * debug/getgroups_chk.c (__getgroups_chk): Fix return value. * stdio-common/fxprintf.c: Include string.h.
2005-07-20* include/stdio.h (__fxprintf): Remove wfmt argument.Ulrich Drepper
* stdio-common/fxprintf.c: Include assert.h, ctype.h and wchar.h. (__fxprintf): Remove wfmt argument, create wfmt format string on the fly from fmt. * argp/argp-fmtstream.c: Adjust all __fxprintf callers. * argp/argp-help.c: Likewise. * assert/assert-perr.c: Likewise. * assert/assert.c: Likewise. * gmon/gmon.c: Likewise. * inet/rcmd.c: Likewise. * malloc/obstack.c: Likewise. * misc/error.c: Likewise. * misc/getpass.c: Likewise. * posix/getopt.c: Likewise. * resolv/res_hconf.c: Likewise. * stdio-common/perror.c: Likewise. * stdio-common/psignal.c: Likewise. * stdlib/fmtmsg.c: Likewise. * sunrpc/auth_unix.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/clnt_unix.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/svc_unix.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sysdeps/generic/wordexp.c: Likewise.
2005-07-19* stdio-common/Makefile (aux): Add fxprintf.Ulrich Drepper
* stdio-common/fxprintf.c: New file. * include/stdio.h: Add declaration for stdio.h. * argp/argp-fmtstream.c: Use __fxprintf instead of inline stream orientation test and two separate function calls. * argp/argp-help.c: Likewise. * assert/assert-perr.c: Likewise. * assert/assert.c: Likewise. * gmon/gmon.c: Likewise. * inet/rcmd.c: Likewise. * malloc/obstack.c: Likewise. * misc/error.c: Likewise. * misc/getpass.c: Likewise. * posix/getopt.c: Likewise. * resolv/res_hconf.c: Likewise. * stdio-common/perror.c: Likewise. * stdio-common/psignal.c: Likewise. * stdlib/fmtmsg.c: Likewise. * sunrpc/auth_unix.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/clnt_unix.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/svc_unix.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sysdeps/generic/wordexp.c: Likewise. * misc/Makefile: Add rules to build and run tst-error1. * misc/tst-error1.c: New file. * misc/error.c: Fix memory leak and possibly endless loop.
2004-12-22(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.Ulrich Drepper
2007-07-122.5-18.1Jakub Jelinek