about summary refs log tree commit diff
path: root/posix/getopt.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-021-1/+1
| | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-011-1/+1
|
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-011-1/+1
| | | | | | | * 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.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-011-1/+1
| | | | | | | * 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.
* getopt: annotate files with relationship to gnulib.Zack Weinberg2017-04-071-4/+2
| | | | | | | | | | | | | | As the final act in this patchset, adjust the "This file is part of the GNU C Library" message at the top of each file to indicate which files are synced with gnulib. * posix/bits/getopt_core.h, posix/bits/getopt_ext.h * posix/getopt.c, posix/getopt1.c, posix/getopt_int.h: Mention in top-of-file boilerplate that these files are shared with gnulib. * posix/getopt.h, posix/bits/getopt_posix.h: Mention in top-of-file boilerplate that these files are NOT shared with gnulib, unlike the rest of the getopt implementation.
* getopt: merge _GL_UNUSED annotations from gnulibZack Weinberg2017-04-071-1/+2
| | | | | | | | | | | | | | | | gnulib now has annotations on at least some functions to cater to compilation with -Wunused-parameter. In order to follow suit cleanly, I've added to libc-symbols.h some of the _GL_* macros that gnulib-common.m4 puts into config.h. (I don't think they belong in sys/cdefs.h, at least not without further thought.) At this point all gnulib-side changes to getopt.c have been merged. * include/libc-symbols.h: For gnulib compatibility, define _GL_UNUSED, _GL_UNUSED_LABEL, _GL_ATTRIBUTE_PURE, and _GL_ATTRIBUTE_CONST. * posix/getopt.c (_getopt_initialize): Mark argc and argv parameters with _GL_UNUSED.
* getopt: merge from gnulib: alloca avoidanceZack Weinberg2017-04-071-126/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In one place, glibc's getopt uses alloca to construct a linked list of possibilities for an "ambiguous" long option. In gnulib, malloc should be used instead. Providing for both cases complicates things a fair bit. Instead of merging straight across, therefore, I have chosen to rewrite it using a boolean vector instead of a linked list. There is then only one allocation that might need freeing; in glibc it can honor __libc_use_alloca as usual, and in gnulib we define __libc_use_alloca to always be false, so we don't need ifdefs in the middle of the function. This should also be slightly more efficient in the normal case of long options being fully spelled out -- I think most people aren't even aware they _can_ sometimes abbreviate long options. One interesting consequence is that the list of possibilities is now printed in exactly the order they appear in the list of long options, instead of the first possibility being shuffled to the end. This shouldn't be a big deal but it did break one test that relied on the exact text of this error message. (The reason the previous patch was "in aid of" merging from gnulib is I didn't want to have to make this change in two places.) (The patch looks bigger than it really is because there's a fair bit of reindentation and code rearrangement.) * posix/getopt.c: When used standalone, define __libc_use_alloca as always false and alloca to abort if called. (process_long_option): Rewrite handling of ambiguous long options to use a single boolean vector, not a linked list; use __libc_use_alloca to decide whether to allocate this using alloca. * posix/tst-getopt_long1.c: Adjust text of expected error message.
* getopt: refactor long-option handlingZack Weinberg2017-04-071-297/+204
| | | | | | | | | | | | | | | There were two copies of the bulk of the code to handle long options. Now there is only one. (Yes, this is in aid of merging from gnulib.) The change to bug-getopt4.c clarifies the error messages when the test fails. * posix/getopt.c (process_long_option): New function split out from _getopt_internal_r. (_getopt_internal_r): Replace both copies of the long-option processing code with calls to process_long_option. * posix/bug-getopt4.c (one_test): Print argv[0] in error messages. (do_test): Differentiate argv[0] in the two subtests.
* getopt: tidy up _getopt_initialize a bitZack Weinberg2017-04-071-12/+6
| | | | | | | | | | | | | | | | _getopt_data.__posixly_correct is completely redundant to _getopt_data.__ordering, and some work that logically belongs in _getopt_initialize was being done by _getopt_internal_r, making the code harder to understand. As a side effect, getenv will no longer be called if the first character of the options string is '+' or '-', which is probably a Good Thing. (Perhaps we should have a flag character that specifically asks for the permutation behavior?) * posix/getopt_int.h (_getopt_data): Remove __posixly_correct field. * posix/getopt.c (_getopt_internal_r): Move some initialization code... (_getopt_initialize): ...here. Don't set d->__posixly_correct.
* getopt: merge from gnulib: function prototype adjustmentsZack Weinberg2017-04-071-29/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For standards compliance, getopt, getopt_long, and getopt_long_only in glibc have to take 'char *const *argv' even though they can mutate the array. gnulib has tried to clean this up as much as possible: all the internal functions use 'char **argv', and when used standalone, so do getopt_long and getopt_long_only. Also brought over are __nonnull annotations, corrections to documentation, and apparently it is no longer necessary to worry about conflicting prototypes for getopt. The macroification of the definitions of getopt and __posix_getopt goes beyond what is currently in gnulib. At this point getopt1.c and getopt_int.h are identical to their gnulib versions. * posix/getopt.h: Add backup definition of __nonnull for consistency with gnulib. Define __getopt_argv_const to const if not already defined. (getopt): Update doc comment from gnulib. Prototype unconditionally. Add __nonnull annotation. (__posix_getopt): Add __nonnull annotation. (getopt_long, getopt_long_only): Use __getopt_argv_const in prototypes for consistency with gnulib. Add __nonnull annotations. * posix/getopt.c (_getopt_initialize, _getopt_internal_r) (getopt_internal): Change 'argv' argument to type 'char **'. Remove now-unnecessary casts. (getopt, __posix_getopt): Eliminate repetition with a macro. Cast 'argv' to 'char **' when calling _getopt_internal. * posix/getopt1.c (getopt_long, getopt_long_only): Use __getopt_argv_const for consistency with gnulib. Cast 'argv' to 'char **' when calling _getopt_internal. (_getopt_long_r, _getopt_long_only_r): Change 'argv' argument to type 'char **'. (main): Constify 'long_options'. * posix/getopt_int.h (getopt_internal, _getopt_internal_r) (_getopt_long_r, _getopt_long_only_r): Change 'argv' argument to type 'char **'.
* getopt: clean up error reportingZack Weinberg2017-04-071-309/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* getopt: fix fencepost error in ambiguous-W-option handlingZack Weinberg2017-04-071-1/+0
| | | | | | | | | | | | | | | | | getopt_long contains an undocumented (AFAICT) feature in which, if you put "W;" in the short-options list, then '-W foo' and '-Wfoo' are treated as equivalent to '--foo'. This is implemented with a partial second copy of the code for handling long options, and that code increments optind one too many times when recovering from an ambiguous abbreviated option, which can cause the main loop to walk past the end of argv and crash. I discovered this while writing a test case that tries to exercise all of getopt's error reporting paths; I wouldn't be surprised to learn that this feature is never used by real applications. * posix/getopt.c (_getopt_internal_r): Don't increment d->optind a second time when reporting ambiguous -W options.
* getopt: merge straightforward changes from gnulibZack Weinberg2017-04-071-81/+41
| | | | | | | | | | | | | | | | | This covers changes with little or no consequences when the code is used in glibc. * posix/getopt_int.h: Include getopt.h. Use impl-namespace names for all arguments to _getopt_internal and _getopt_internal_r. Declare __ordering enum outside the struct. Harmonize comments with gnulib. * posix/getopt1.c: Simplify #ifdeffage at top of file. Remove ELIDE_CODE logic entirely. Move inclusion of stdlib.h to #ifdef TEST block and make unconditional. Do not define NULL. * posix/getopt.c: Partial merge from gnulib, covering the initial includes and global declarations, commentary, and a couple of semantically-neutral code changes.
* getopt: merge from gnulib: don't use `...' quotesZack Weinberg2017-04-071-31/+31
| | | | | | | | | | | | I'm not sure whether this is official GNU style now, but `...' quotes haven't looked properly balanced in most people's terminal fonts since 2001ish? and gnulib has chosen to switch over to '...' quotes. I'm merging this separately from the other changes in gnulib because it's very mechanical. * posix/getopt.c, posix/getopt.h, posix/getopt1.c, posix/getopt_int.h: Use '...' instead of `...' for quotation marks inside comments and strings.
* getopt: remove USE_NONOPTION_FLAGSZack Weinberg2017-04-071-95/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc's implementation of getopt includes code to parse an environment variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the current process's PID in decimal); but all of it has been #ifdefed out since 2001, with no official way to turn it back on. According to commentary in our config.h.in, bash version 2.0 set this environment variable to indicate argv elements that were the result of glob expansion and therefore should not be treated as options, but the feature was "disabled later" because "it caused problems". According to bash's CHANGES file, "later" was release 2.01; it gives no more detail about what the problems were. Version 2.0 of bash was released on the last day of 1996, and version 2.01 in June of 1997. Twenty years later, I think it is safe to assume that this environment variable isn't coming back. * config.h.in (USE_NONOPTION_FLAGS): Remove. * csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks. * sysdeps/mach/hurd/i386/init-first.c: Likewise. * posix/getopt_int.h: Likewise. * posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the __libc_argc and __libc_argv externs, which were only used by #ifdef USE_NONOPTION_FLAGS blocks. * posix/getopt_init.c: Remove file. * posix/Makefile (routines): Remove getopt_init. * include/getopt.h: Don't declare __getopt_initialize_environment. * manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in a comment.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-011-1/+1
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2016-01-041-1/+1
|
* Fix open_memstream namespace (bug 18498).Joseph Myers2015-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | open_memstream is new in the 2008 edition of POSIX. However, the older functions getopt, closelog and fmtmsg all bring in references to it. This patch fixes this in the usual way, making open_memstream into a weak alias of __open_memstream and calling __open_memstream from the relevant places. Tested for x86_64 and x86 (testsuite, and that disassembly of installed shared libraries is unchanged by the patch). 32-bit builds produce an XPASS for conform/POSIX/unistd.h/linknamespace after this patch (because the only cause of failure left there now is 64-bit specific); that will disappear once the 64-bit failure is resolved and the XFAIL removed at that time. [BZ #18498] * libio/memstream.c (open_memstream): Rename to __open_memstream and define as weak alias of __open_memstream. * include/stdio.h (__open_memstream): Declare. Use libc_hidden_proto. (open_memstream): Don't use libc_hidden_proto. * misc/syslog.c (__vsyslog_chk): Call __open_memstream instead of open_memstream. * posix/getopt.c (_getopt_internal_r): Likewise. * conform/Makefile (test-xfail-XPG3/stdio.h/linknamespace): Remove variable. (test-xfail-XPG4/stdio.h/linknamespace): Likewise. (test-xfail-UNIX98/stdio.h/linknamespace): Likewise. (test-xfail-XOPEN2K/unistd.h/linknamespace): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-021-1/+1
|
* Use glibc_likely instead __builtin_expect.Ondřej Bílka2014-02-101-1/+1
|
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-011-1/+1
|
* Avoid use of "register" as optimization hint.Joseph Myers2013-06-071-2/+2
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-021-2/+1
|
* Replace FSF snail mail address with URLs.Paul Eggert2012-02-091-3/+2
|
* Cleanup of configuration optionsUlrich Drepper2011-09-101-19/+19
| | | | Make several tool features mandatory and simplify the code.
* Handle W; without long options in getoptUlrich Drepper2011-07-061-2/+7
|
* Provide more helpful error message in getoptUlrich Drepper2011-05-151-19/+60
| | | | If provide with an ambiguous long option we now show all the possibilities.
* getopt mishandles optstring of "+:"Eric Blake2010-04-071-2/+4
|
* getopt mistakenly allows '-;' as short optionEric Blake2010-04-071-1/+1
|
* Fix -W with optional parameters in getopt.Eric Blake2010-04-071-1/+6
| | | | | | According to the getopt documentation, if "W;" is part of optstring, then '-W foo' should behave like '--foo'. But if "foo" uses an optional_argument, this is not the case, since optarg is not NULL when using -W.
* Fix printing error messages in getopt.Ulrich Drepper2010-04-041-12/+13
|
* * include/features.h: If no feature selection given and we selectUlrich Drepper2009-02-261-8/+22
| | | | | | | | | | | | | | | | | | | | | by default a POSIX mode, also define __USE_POSIX_IMPLICITLY. * posix/Versions: Export __posix_getopt. * posix/getopt.c (_getopt_initialize): Take additional parameter. Use it to alternatively initialize __posixly_correct. (_getopt_internal_r): Take addition parameter. Pass on to _getopt_initialize. (_getopt_internal): Take addition parameter. Pass on to _getopt_internal_r. (getopt): Pass additional zero to _getopt_internal. (__posix_getopt): New function. * posix/getopt.h: Add redirection for getopt. * posix/getopt1.c (getopt_long): Pass additional zero to _getopt_internal. (getopt_long_only): Likewise. (_getopt_long_r): Pass additional zero to _getopt_internal_r. (_getopt_long_only_r): Likewise. * posix/getopt_int.h: Adjust declarations of _getopt_internal and _getopt_internal_r.
* * posix/getopt.c (_getopt_internal_r): Remove old POSIX-demandedUlrich Drepper2008-03-291-19/+5
| | | | | error message. POSIX today does not require the messages to be in a specific form. Suggested by Jim Meyering <jim@meyering.net>.
* [BZ #5762]Ulrich Drepper2008-03-081-33/+32
| | | | | | | | | | | | | | | | | | | | | | | * posix/getopt.c (_getopt_internal_r): Clarify error message by putting offending option character in quotes. Clean up error messages. * po/be.po: Adjust msgstr in translation file. * po/bg.po: Likewise. * po/ca.po: Likewise. * po/cs.po: Likewise. * po/da.po: Likewise. * po/de.po: Likewise. * po/es.po: Likewise. * po/fr.po: Likewise. * po/hr.po: Likewise. * po/ko.po: Likewise. * po/nl.po: Likewise. * po/rw.po: Likewise. * po/sk.po: Likewise. * po/sv.po: Likewise. * po/tr.po: Likewise. * po/zh_CN.po: Likewise. * po/zh_TW.po: Likewise.
* * include/stdio.h (__fxprintf): Remove wfmt argument.Ulrich Drepper2005-07-201-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * wcsmbs/bits/wchar2.h: Add definitions for wcrtomb, mbsrtowcs,Ulrich Drepper2005-07-201-40/+10
| | | | | | | | | | | | | | | | wcsrtombs, mbsnrtowcs, and wcsnrtombs. * debug/Makefile (routines): Add wcrtomb_chk, mbsrtowcs_chk, wcsrtombs_chk, mbsnrtowcs_chk, and wcsnrtombs_chk. * debug/Versions: Add __wcrtomb_chk, __mbsrtowcs_chk, __wcsrtombs_chk, __mbsnrtowcs_chk, and __wcsnrtombs_chk. * debug/tst-chk1.c: Add tests for new functions. * debug/mbsnrtowcs_chk.c: New file. * debug/mbsrtowcs_chk.c: New file. * debug/wcrtomb_chk.c: New file. * debug/wcsnrtombs_chk.c: New file. * debug/wcsrtombs_chk.c: New file. * include/stdio.h: Add declaration for __fxprintf.
* (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.Ulrich Drepper2004-12-221-10/+40
|
* 2.5-18.1Jakub Jelinek2007-07-121-40/+10
|
* Update.Ulrich Drepper2004-03-101-1/+1
| | | | | | 2004-03-10 Ulrich Drepper <drepper@redhat.com> * posix/getopt.c (_): Don't define here for glibc.
* Update.Ulrich Drepper2004-03-091-297/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2004-03-08 Paul Eggert <eggert@cs.ucla.edu> Merge from gnulib. We now assume C89 or better. * posix/getopt1.c (const): Remove. * posix/getopt.c (const): Likewise. * posix/getopt1.c (getopt_long, _getopt_long_r, getopt_long_only, _getopt_long_only_r, main): Use prototypes, not old-style definitions. * posix/getopt.c (exchange, _getopt_initialize, _getopt_internal_r, _getopt_internal, getopt, main): Likewise. * posix/getopt.h (getopt, getopt_long, getopt_long_only): Likewise. * posix/getopt.c [!defined VMS || !HAVE_STRING_H]: Include <string.h> regardless. No need for <strings.h>. [!defined _LIBC]: Include "gettext.h" rather than rolling it ourselves. (_): Define to gettext always. (my_index): Remove: all uses changed to strchr. (strlen): Remove declaration. * posix/getopt.h (struct option.name): Always const char *. 2004-03-08 Marcus Brinkmann <marcus@gnu.org> * posix/getopt.h (_getopt_internal): Move to ... * posix/getopt_int.h: ... here. New file. * include/getopt_int.h: New file. * include/getopt.h: Remove libc_hidden_proto for getopt_long and getopt_long_only. * posix/getopt1.c: Include "getopt_int.h". Remove libc_hidden_def for getopt_long and getopt_long_only. (_getopt_long_r, _getopt_long_only_r): New functions. * posix/getopt.c: Include "getopt_int.h". (__getopt_initialized): Variable removed. (nextchar, ordering, posixly_correct, first_nonopt, last_nonopt): Static variables removed. (nonoption_flags_max_len, nonoption_flags_len) [_LIBC && USE_NONOPTION_FLAGS]: Static variables removed. (getopt_data): New static variable. (SWAP_FLAGS): Use d->__nonoption_flags_len instead nonoption_flags_len. (exchange): Add new argument D of type struct getopt_data *. Replace optind with d->optind, optarg with d->optarg, opterr with d->opterr, optopt with d->optopt, nextchar with d->__nextchar, first_nonopt with d->__first_nonopt, last_nonopt with d->__last_nonopt, d->ordering with d->__ordering, d->posixly_correct with d->__posixly_correct (which is now an int instead a string, so fix users), nonoption_flags_len with d->__nonoption_flags_len, nonoption_flags_max_len with d->__nonoption_flags_max_len. (_getopt_initialize): Likewise. (_getopt_internal): Rename to ... (_getopt_internal_r): ... this. Also add new argument D of type struct getopt_data * and use of members of D rather than global or static variables as described for exchange() above. Add new argument to invocations of _getopt_initialize and exchange. (_getopt_internal): Reimplement in terms of _getopt_internal_r. * argp/argp-parse.c: Include <getopt_int.h>. [_LIBC]: Do not include <bits/libc-lock.h>. [!_LIBC && HAVE_CTHREADS_H]: Do not include <cthreads.h>. [!_LIBC] (_argp_hang): Make static. (getopt_lock, LOCK_GETOPT, UNLOCK_GETOPT): Remove. (_argp_unlock_xxx): Remove. (parser_init): Do not use LOCK_GETOPT. (parser_finalize): Do not use UNLOCK_GETOPT. (struct parser): New member OPT_DATA. (parser_init): Initialize parser->opt_data. Use parser->opt_data.opterr instead of opterr. (parser_parse_opt): Use parser->opt_data.optarg instead optarg. (parser_parse_next): Likewise. Use parser->opt_data.optind instead optind. Use parser->opt_data.optopt instead of optopt. Call _getopt_long_only_r and _getopt_long_r instead of getopt_long_only and getopt_long, and pass the extra argument.
* Update.Ulrich Drepper2003-09-121-1/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2003-09-12 Ulrich Drepper <drepper@redhat.com> * grp/Makefile (CFLAGS-getgrgid_r.c, CFLAGS-getgrnam_r.c, CFLAGS-fgetgrent.c, CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c, CFLAGS-initgroups.c, CFLAGS-getgrgid.c): Add -fexceptions. * inet/Makefile (CFLAGS-either_ntoh.c, CFLAGS-either_hton.c, CFLAGS-getnetgrent.c, CFLAGS-getnetgrent_r.c): Likewise. * io/Makefile (CFLAGS-posix_fallocate.c, CFLAGS-posix_fallocate64.c): Likewise. * misc/Makefile (CFLAGS-err.c): Likewise. * posix/Makefile (CFLAGS-getaddrinfo.c, CFLAGS-spawn.c, CFLAGS-spawnp.c, CFLAGS-spawni.c, CFLAGS-pause.c, CFLAGS-glob.c, CFLAGS-glob64.c): Likewise. * pwd/Makefile (CFLAGS-getpw.c): Likewise. * shadow/Makefile (CFLAGS-fgetspent.c, CFLAGS-fgetspent_r.c, CFLAGS-putspent.c, CFLAGS-getspnam.c, CFLAGS-getspnam_r.c): Likewise. * stdio-common/Makefile (CFLAGS-cuserid.c): Likewise. * sunrpc/Makefile (CFLAGS-openchild.c): Likewise. * stdlib/Makefile (CFLAGS-mkstemp.c): Remove definition. * libio/stdio.h: Remove __THROW from cuserid prototype. * locale/loadarchive.c: Use only non-cancelable interfaces. * resolv/herror.c (herror): Likewise. * malloc/hooks.c: Before using IO stream mark stream so it uses only non-cancelable interfaces. * malloc/malloc.c: Likewise. * posix/getopt.c: Likewise. 2003-09-11 Jakub Jelinek <jakub@redhat.com> * Makerules (LDFLAGS-c.so): Remove -u __register_frame. 2003-09-12 Ulrich Drepper <drepper@redhat.com> * stdio-common/stdio_ext.h: Mark most functions with __THROW. * misc/err.h: Remove __THROW from all prototypes. * posix/getopt.h (__THROW): Define if not already defined. Add __THROW to the getopt functions. 2003-09-11 Ulrich Drepper <drepper@redhat.com> * io/Makefile (CFLAGS-lockf.c): Add -fexceptions. (CFLAGS-fts.c): Likewise. * io/fcntl.h: Remove __THROW from lockf prototypes. * io/fts.h: Remove most __THROW.
* Update.Ulrich Drepper2002-03-121-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/stdlib.h (__libc_drand48_data): Declare as hidden. * stdlib/drand48.c: Remove declaration of __libc_drand48_data here. * stdlib/erand48.c: Likewise. * stdlib/jrand48.c: Likewise. * stdlib/lcong48.c: Likewise. * stdlib/lrand48.c: Likewise. * stdlib/mrand48.c: Likewise. * stdlib/nrand48.c: Likewise. * stdlib/seed48.c: Likewise. * stdlib/srand48.c: Likewise. * stdio-common/_itoa.c (_itoa_base_table): Declare as hidden. (_itoa_lower_digits_internal): New declaration. (_itoa_upper_digits_internal): New declaration. (_itoa): Use INTUSE to acces _itoa_upper_digits and _itoa_lower_digits. * stdio-common.h (_itoa_lower_digits_internal): New declaration. (_itoa_upper_digits_internal): New declaration. (_itoa_word): Use INTUSE to acces _itoa_upper_digits and _itoa_lower_digits. * stdio-common/itoa-digits.c: Use INTVARDEF with _itoa_lower_digits. * stdio-common/itoa-udigits.c: Use INTVARDEF with _itoa_upper_digits. * elf/dl-minimal.c (_itoa): Declare _itoa_lower_digits as hidden. * elf/dl-reloc.c (_dl_reloc_bad_type): Likewise. * stdio-common/_itowa.c (_itoa_base_table): Declare as hidden. (_itowa_lower_digits): Likewise. (_itowa_upper_digits): Likewise. * stdio-common/_itowa.h (_itowa_lower_digits): Likewise. (_itowa_upper_digits): Likewise. * intl/plural-exp.h (attribute_hidden): Define as empty macro if not already defined. (GERMANIC_PLURAL): Declare as hidden. * posix/getopt.c (__getopt_initialized): Declare as hidden. (attribute_hidden): Define as empty macro if not already defined. * iconv/gconv_int.h (__gconv_path_elem): Declare hidden. (__gconv_max_path_elem_len): Likewise. (__gconv_path_envvar): Likewise. * math/Makefile (gmp-objs): Remove mp_clz_tab. * stdlib/Makefile (aux): Remove mp_clz_tab. * stdlib/mp_clz_tab.c: Removed. Not needed anywhere. * stdlib/exit.h (__exit_funcs): Declare as hidden.
* Update.Ulrich Drepper2001-12-061-87/+108
| | | | | | | | | | | | | | | | | 2001-12-06 Ulrich Drepper <drepper@redhat.com> * libio/vasprintf.c (_IO_vasprintf): Free buffer on failure. * assert/assert.c: Check result of __asprintf call and don't use string if it failed. * assert/assert-perr.c: Likewise. * inet/rcmd.c: Likewise. * locale/programs/localedef.c (main): Check result of construct_output_path and exit if it failed. (construct_output_path): Check result of asprintf and mkdir calls and fail if they failed. * posix/getopt.c: Check result of __asprintf calls and fail if they failed. Patch by Dmitry V. Levin <ldv@alt-linux.org>.
* Update.Ulrich Drepper2001-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2001-10-26 Ulrich Drepper <drepper@redhat.com> * string/strxfrm.c [USE_IN_EXTENDED_LOCALE_MODEL]: Correctly get nrules value. 2001-10-24 H.J. Lu <hjl@gnu.org> * sysdeps/generic/bits/dlfcn.h (DL_CALL_FCT): Cast to void *. Use __BEGIN_DECLS/__END_DECLS around prototypes. * sysdeps/mips/bits/dlfcn.h (DL_CALL_FCT): Likewise. 2001-10-21 Jim Meyering <meyering@lucent.com> * malloc/obstack.c (_): Honor the setting of ENABLE_NLS. Otherwise, this code would end up calling gettext even in packages built with --disable-nls. * posix/getopt.c (_): Likewise. * posix/regex.c (_): Likewise. 2001-10-26 Ulrich Drepper <drepper@redhat.com> * resolv/gethnamaddr.c (gethostbyaddr): Use ip6.addr for reverse lookup not ip6.int. * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyaddr_r): Likewise. Reported by Martin.v.Loewis@t-online.de [PR libc/2598]. 2001-10-19 Jakub Jelinek <jakub@redhat.com> * misc/sys/cdefs.h (__attribute_used__): Define. * elf/rtld.c (_dl_start): Add __attribute_used__. * elf/dl-runtime.c (fixup, profile_fixup): Likewise.
* Update.Ulrich Drepper2001-08-171-31/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libio/tst-ungetwc2.c (main): Define str const. * include/wchar.h: Add prototypes for __fwprintf and __vfwprintf. * libio/fwprintf.c: Also define __fwprintf. * stdio-common/vfprintf.c [COMPILE_WPRINTF]: Also define __vfwprintf. * argp/argp-fmtstream.c: Handle wide oriented stderr stream. * assert/assert-perr.c: Likewise. * assert/assert.c: Likewise. * gmon/gmon.c: Likewise. * inet/rcmd.c: Likewise. * malloc/obstack.c: Likewise. * misc/err.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/err.c: Handle wide oriented stderr stream.
* Remove store_args_and_env which is not needed is USE_NONOPTION_FLAGS is ↵Ulrich Drepper2001-08-131-22/+9
| | | | undefined anyhow. Use __libc_argc and __libc_argv variables.
* 2001-08-11 Roland McGrath <roland@frob.com>Roland McGrath2001-08-111-1/+1
| | | | | * posix/getopt.c (nonoption_flags_max_len, nonoption_flags_len): Make these defns conditional on [USE_NONOPTION_FLAGS].
* Update.Ulrich Drepper2001-08-111-6/+12
| | | | | | | | | | | | | | 2001-08-11 Ulrich Drepper <drepper@redhat.com> * config.h.in: Add #undef line for USE_NONOPTION_FLAGS. * posix/getopt_init.c: Produce code only if USE_NONOPTION_FLAGS is defined. * posix/getopt.c: Use __getopt_nonoption_flags only if USE_NONOPTION_FLAGS is defined. * sysdeps/mach/hurd/i386/init-first.c: Use __getopt_clean_environment only if USE_NONOPTION_FLAGS is defined. * sysdeps/mach/hurd/mips/init-first.c: Likewise. * sysdeps/unix/sysv/linux/init-first.c: Likewise.