summaryrefslogtreecommitdiff
path: root/tests/test-getopt_long.h
Commit message (Collapse)AuthorAgeFilesLines
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* getopt-gnu: avoid crash in glibc getoptEric Blake2011-07-071-0/+19
| | | | | | | | | | | | | | | Use of "W;" in an option string may be rare, but we might as well avoid crashing on it. * m4/getopt.m4 (gl_GETOPT_CHECK_HEADRS): Detect the problem. * tests/test-getopt.h (test_getopt): Enhance test. * tests/test-getopt_long.h (test_getopt_long): Likewise. * doc/posix-functions/getopt.texi (getopt): Document it. * doc/glibc-functions/getopt_long.texi (getopt_long): Likewise. * doc/glibc-functions/getopt_long_only.texi (getopt_long_only): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-1/+1
| | | | Run the new "make update-copyright" rule.
* tests: fix compiler warningsEric Blake2010-11-031-1/+1
| | | | | | | | | | | | Detected by icc. The first three files are real test bugs, the last merely silences a warning about mixing an int with an enum type. * tests/test-getopt.h (test_getopt): Fix condition. * tests/test-getopt_long.h (test_getopt_long): Likewise. * tests/test-pipe2.c (main): Likewise. * tests/test-quotearg-simple.c (main): Avoid icc warning. Signed-off-by: Eric Blake <eblake@redhat.com>
* getopt-gnu: match recent glibc fixes and posix rulingEric Blake2010-04-131-6/+11
| | | | | | | | | | | | | | | | | | | | The POSIX folks admitted that codifying the behavior of GNU getopt on a leading '+' in optstring is worthwhile, for writing programs such as env(1) even when POSIXLY_CORRECT is not defined. http://austingroupbugs.net/view.php?id=191 However, the ruling is an enhancement request for the next version of POSIX, and is not binding on platforms that comply with POSIX 2008, so it should only be enforced for getopt-gnu. * tests/test-getopt.h (test_getopt): Strengthen tests of leading '+' handling, when requesting extensions. * tests/test-getopt_long.h (test_getopt_long): Strengthen test of 'W;' handling. * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Detect glibc 2.11 bug. * doc/posix-functions/getopt.texi (getopt): Document this. * doc/glibc-functions/getopt_long.texi (getopt_long): Likewise. * doc/glibc-functions/getopt_long_only.texi (getopt_long_only): Likewise.
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* test-getopt: enhance testEric Blake2009-12-221-28/+1091
| | | | | | | | | | | | | | | | | | | | Add coverage of optind==0 for getopt_long, since coreutils depends on it. Also test an optstring containing "W;", since that tends to expose corner-case bugs (even in glibc, so the test is weaker than it could be). * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Require that getopt_long supports optind=0. * tests/test-getopt.c (OPTIND_MIN): Move... * tests/test-getopt.h (OPTIND_MIN): ...here. * tests/test-getopt_long.h (test_getopt_long): Add more coverage. Require that optind=0 works, since modern BSD supports it in addition to optreset, and since coreutils expects it. (test_getopt_long_only): New test. * doc/glibc-functions/getopt_long.texi (getopt_long): Document glibc shortcomings with 'W;', and enforcement of optind=0. * doc/glibc-functions/getopt_long_only.texi (getopt_long_only): Likewise.
* Use spaces for indentation, not tabs.Bruno Haible2009-12-101-95/+95
|
* getopt-gnu: flush out another BSD bugEric Blake2009-11-271-7/+95
| | | | | | | | | | | | | | | | | | | | | | | | | POSIX requires 'echo foo > bar; m4 -Dfoo=1 bar -Dfoo=2 bar' to output '1' then '2'. To achieve this, m4 relies on the GNU getopt{,_long} extension of a leading '-'. However, BSD getopt fails to honor this extension when POSIXLY_CORRECT. Also, BSD getopt fails to reparse POSIXLY_CORRECT from the environment even when a reset is requested (whether by optreset=1 or by optind=0). * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Test for the bug. * tests/test-getopt.c (main): Check POSIXLY_CORRECT first, to flush out BSD bug. * tests/test-getopt.h (test_getopt): End lists with NULL. * tests/test-getopt_long.h (test_getopt_long): Likewise. (test_getopt_long_posix): Enhance test. * modules/getopt-posix-tests (Depends-on): Add stdbool. * doc/glibc-functions/getopt_long.texi (getopt_long): Mention getopt-gnu. * doc/glibc-functions/getopt_long_only.texi (getopt_long_only): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* tests: avoid several compiler warningsEric Blake2009-10-221-43/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests/test-getcwd.c (main): Avoid buffer underflow. * tests/test-getdate.c (main): String literals are not safe with putenv, so use setenv. Declare unused argument. * modules/getdate-tests (Depends-on): Add setenv. * tests/test-argv-iter.c (main): Declare unused argument. Avoid problems with string literals in char *. * tests/test-hash.c (main): Avoid shadowing declaration. (insert_new): Treat string literals as char const *. * tests/test-getopt.h (test_getopt): Likewise. (getopt_loop): Alter types to minimize casting elsewhere. * tests/test-getopt_long.h (test_getopt_long, getopt_long_loop) (test_getopt_long_posix): Likewise. (do_getopt_long): Add wrapper to minimize casting. * tests/test-atexit.c (clear_temp_file): Use void. * tests/test-areadlink-with-size.c (main): Declare unused arguments. * tests/test-areadlink.c (main): Likewise. * tests/test-areadlinkat-with-size.c (main): Likewise. * tests/test-areadlinkat.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-dirent-safer.c (main): Likewise. * tests/test-dirname.c (main): Likewise. * tests/test-dup2.c (main): Likewise. * tests/test-fchdir.c (main): Likewise. * tests/test-fcntl-h.c (main): Likewise. * tests/test-fcntl-safer.c (main): Likewise. * tests/test-fdopendir.c (main): Likewise. * tests/test-fdutimensat.c (main): Likewise. * tests/test-fflush.c (main): Likewise. * tests/test-filenamecat.c (main): Likewise. * tests/test-filevercmp.c (main): Likewise. * tests/test-fopen-safer.c (main): Likewise. * tests/test-fopen.c (main): Likewise. * tests/test-fpending.c (main): Likewise. * tests/test-fpurge.c (main): Likewise. * tests/test-freading.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-fsync.c (main): Likewise. * tests/test-futimens.c (main): Likewise. * tests/test-getndelim2.c (main): Likewise. * tests/test-gettimeofday.c (main): Likewise. * tests/test-getopt.c (main): Likewise. * tests/test-i-ring.c (main): Likewise. * tests/test-inttypes.c (main): Likewise. * tests/test-link.c (main): Likewise. * tests/test-lstat.c (main): Likewise. * tests/test-math.c (main): Likewise. * tests/test-md5.c (main): Likewise. * tests/test-memchr2.c (main): Likewise. * tests/test-memrchr.c (main): Likewise. * tests/test-mkdir.c (main): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-mkfifoat.c (main): Likewise. * tests/test-open.c (main): Likewise. * tests/test-openat-safer.c (main): Likewise. * tests/test-openat.c (main): Likewise. * tests/test-quotearg.c (main): Likewise. * tests/test-rawmemchr.c (main): Likewise. * tests/test-readlink.c (main): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-rename.c (main): Likewise. * tests/test-renameat.c (main): Likewise. * tests/test-rmdir.c (main): Likewise. * tests/test-sha1.c (main): Likewise. * tests/test-signal.c (main): Likewise. * tests/test-sigaction.c (main): Likewise. * tests/test-stat.c (main): Likewise. * tests/test-stat-time.c (main): Likewise. * tests/test-stddef.c (main): Likewise. * tests/test-stdint.c (main): Likewise. * tests/test-stdio.c (main): Likewise. * tests/test-stdlib.c (main): Likewise. * tests/test-strchrnul.c (main): Likewise. * tests/test-strerror.c (main): Likewise. * tests/test-string.c (main): Likewise. * tests/test-strtod.c (main): Likewise. * tests/test-strverscmp.c (main): Likewise. * tests/test-symlink.c (main): Likewise. * tests/test-symlinkat.c (main): Likewise. * tests/test-sys_stat.c (main): Likewise. * tests/test-sys_time.c (main): Likewise. * tests/test-time.c (main): Likewise. * tests/test-unistd.c (main): Likewise. * tests/test-unlink.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-utimens.c (main): Likewise. * tests/test-utimensat.c (main): Likewise. * tests/test-version-etc.c (main): Likewise. * tests/test-wchar.c (main): Likewise. * tests/test-wctype.c (main): Likewise. * tests/test-xprintf-posix.c (main): Likewise. * tests/test-posixtm.c (main): Likewise. (STREQ): Delete unused macro. * tests/test-linkat.c (main): Declare unused arguments. Avoid shadowed variables. * tests/test-memchr.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* getopt-gnu: add another testEric Blake2009-10-061-0/+21
| | | | | | | | | | | | | Ensure that POSIXLY_CORRECT does not interfere with optional argument behavior; older BSD implementations botched this. * tests/test-getopt_long.h (test_getopt_long_posix): New test, to guarantee behavior relied on by m4. * tests/test-getopt.c (main): Use it. * modules/getopt-posix-tests (Depends-on): Add setenv. See http://lists.gnu.org/archive/html/bug-m4/2006-09/msg00028.html. Signed-off-by: Eric Blake <ebb9@byu.net>
* Tests for modules 'getopt-posix', 'getopt-gnu'.Bruno Haible2009-08-131-0/+937