annotate m4/getopt.m4 @ 16977:3a473ed554b1

getloadavg, getopt: fix commentary re configure.in Autoconf is deprecating the name 'configure.in', so change it to to the new name 'configure.ac' in a couple of places. * lib/getloadavg.c: configure.in -> configure.ac, in comment. * m4/getopt.m4 (gl_GETOPT_IFELSE, gl_GETOPT_SUBSTITUTE_HEADER) (gl_PREREQ_GETOPT): Remove obsolete commentary re Emacs configure.in. Emacs has renamed it to configure.ac, and it no longer refers to these macros anyway.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 09 Jul 2012 01:17:51 -0700
parents 6c13c6060f77
children 426baed51787
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
1 # getopt.m4 serial 43
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 16122
diff changeset
2 dnl Copyright (C) 2002-2006, 2008-2012 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
3 dnl This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
7 # Request a POSIX compliant getopt function.
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
8 AC_DEFUN([gl_FUNC_GETOPT_POSIX],
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
9 [
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
10 m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
11810
d2c9dd185002 Ensure that getopt() gets declared by <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 11809
diff changeset
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14968
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
12 dnl Other modules can request the gnulib implementation of the getopt
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
13 dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS.
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
14 dnl argp.m4 does this.
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
15 m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
16 gl_GETOPT_IFELSE([], [])
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
17 REPLACE_GETOPT=1
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
18 ], [
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
19 REPLACE_GETOPT=0
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
20 gl_GETOPT_IFELSE([
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
21 REPLACE_GETOPT=1
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
22 ],
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
23 [])
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
24 ])
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
25 if test $REPLACE_GETOPT = 1; then
14969
9ac32f9b5582 getopt: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14968
diff changeset
26 dnl Arrange for getopt.h to be created.
9ac32f9b5582 getopt: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14968
diff changeset
27 gl_GETOPT_SUBSTITUTE_HEADER
14968
87792dbdedee getopt, argp: Respect rules for use of AC_LIBOBJ.
Bruno Haible <bruno@clisp.org>
parents: 14212
diff changeset
28 fi
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
29 ])
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
30
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
31 # Request a POSIX compliant getopt function with GNU extensions (such as
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
32 # options with optional arguments) and the functions getopt_long,
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
33 # getopt_long_only.
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
34 AC_DEFUN([gl_FUNC_GETOPT_GNU],
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
35 [
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
36 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
37
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
38 AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
39 ])
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
40
11813
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
41 AC_DEFUN([gl_GETOPT_IFELSE],
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
42 [
11813
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
43 AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
44 AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
45 ])
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
46
11813
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
47 # Determine whether to replace the entire getopt facility.
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
48 AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 [
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
50 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13646
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
51 AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
52
11818
8e0abc42d59f Ensure that optarg etc. get declared by <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 11816
diff changeset
53 dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
8e0abc42d59f Ensure that optarg etc. get declared by <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 11816
diff changeset
54 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
8e0abc42d59f Ensure that optarg etc. get declared by <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 11816
diff changeset
55
12070
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
56 gl_CHECK_NEXT_HEADERS([getopt.h])
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
57 if test $ac_cv_header_getopt_h = yes; then
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
58 HAVE_GETOPT_H=1
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
59 else
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
60 HAVE_GETOPT_H=0
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
61 fi
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
62 AC_SUBST([HAVE_GETOPT_H])
f098f1865179 getopt: fix inclusion guards for cygwin
Eric Blake <ebb9@byu.net>
parents: 11987
diff changeset
63
11809
0e2c54ee1521 Clarify logic; Separate gl_replace_getopt and GETOPT_H.
Bruno Haible <bruno@clisp.org>
parents: 11808
diff changeset
64 gl_replace_getopt=
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
65
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
66 dnl Test whether <getopt.h> is available.
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
67 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
11809
0e2c54ee1521 Clarify logic; Separate gl_replace_getopt and GETOPT_H.
Bruno Haible <bruno@clisp.org>
parents: 11808
diff changeset
68 AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
6052
29087842aa86 * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Do not override the results
Paul Eggert <eggert@cs.ucla.edu>
parents: 6007
diff changeset
69 fi
29087842aa86 * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Do not override the results
Paul Eggert <eggert@cs.ucla.edu>
parents: 6007
diff changeset
70
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
71 dnl Test whether the function getopt_long is available.
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
72 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
11809
0e2c54ee1521 Clarify logic; Separate gl_replace_getopt and GETOPT_H.
Bruno Haible <bruno@clisp.org>
parents: 11808
diff changeset
73 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
74 fi
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
75
13228
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
76 dnl POSIX 2008 does not specify leading '+' behavior, but see
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
77 dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
78 dnl the next version of POSIX. For now, we only guarantee leading '+'
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
79 dnl behavior with getopt-gnu.
11809
0e2c54ee1521 Clarify logic; Separate gl_replace_getopt and GETOPT_H.
Bruno Haible <bruno@clisp.org>
parents: 11808
diff changeset
80 if test -z "$gl_replace_getopt"; then
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
81 AC_CACHE_CHECK([whether getopt is POSIX compatible],
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
82 [gl_cv_func_getopt_posix],
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
83 [
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
84 dnl Merging these three different test programs into a single one
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
85 dnl would require a reset mechanism. On BSD systems, it can be done
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
86 dnl through 'optreset'; on some others (glibc), it can be done by
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
87 dnl setting 'optind' to 0; on others again (HP-UX, IRIX, OSF/1,
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
88 dnl Solaris 9, musl libc), there is no such mechanism.
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
89 if test $cross_compiling = no; then
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
90 dnl Sanity check. Succeeds everywhere (except on MSVC,
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
91 dnl which lacks <unistd.h> and getopt() entirely).
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
92 AC_RUN_IFELSE(
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
93 [AC_LANG_SOURCE([[
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
94 #include <unistd.h>
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
95 #include <stdlib.h>
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
96 #include <string.h>
14212
005668eb5243 getopt: omit HAVE_OPTRESET, HAVE_GETOPT_CLIP from config.h
Paul Eggert <eggert@cs.ucla.edu>
parents: 14211
diff changeset
97
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
98 int
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
99 main ()
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
100 {
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
101 static char program[] = "program";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
102 static char a[] = "-a";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
103 static char foo[] = "foo";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
104 static char bar[] = "bar";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
105 char *argv[] = { program, a, foo, bar, NULL };
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
106 int c;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
107
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
108 c = getopt (4, argv, "ab");
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
109 if (!(c == 'a'))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
110 return 1;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
111 c = getopt (4, argv, "ab");
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
112 if (!(c == -1))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
113 return 2;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
114 if (!(optind == 2))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
115 return 3;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
116 return 0;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
117 }
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
118 ]])],
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
119 [gl_cv_func_getopt_posix=maybe],
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
120 [gl_cv_func_getopt_posix=no])
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
121 if test $gl_cv_func_getopt_posix = maybe; then
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
122 dnl Sanity check with '+'. Succeeds everywhere (except on MSVC,
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
123 dnl which lacks <unistd.h> and getopt() entirely).
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
124 AC_RUN_IFELSE(
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
125 [AC_LANG_SOURCE([[
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
126 #include <unistd.h>
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
127 #include <stdlib.h>
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
128 #include <string.h>
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
129
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
130 int
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
131 main ()
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
132 {
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
133 static char program[] = "program";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
134 static char donald[] = "donald";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
135 static char p[] = "-p";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
136 static char billy[] = "billy";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
137 static char duck[] = "duck";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
138 static char a[] = "-a";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
139 static char bar[] = "bar";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
140 char *argv[] = { program, donald, p, billy, duck, a, bar, NULL };
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
141 int c;
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
142
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
143 c = getopt (7, argv, "+abp:q:");
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
144 if (!(c == -1))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
145 return 4;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
146 if (!(strcmp (argv[0], "program") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
147 return 5;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
148 if (!(strcmp (argv[1], "donald") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
149 return 6;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
150 if (!(strcmp (argv[2], "-p") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
151 return 7;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
152 if (!(strcmp (argv[3], "billy") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
153 return 8;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
154 if (!(strcmp (argv[4], "duck") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
155 return 9;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
156 if (!(strcmp (argv[5], "-a") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
157 return 10;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
158 if (!(strcmp (argv[6], "bar") == 0))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
159 return 11;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
160 if (!(optind == 1))
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
161 return 12;
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
162 return 0;
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
163 }
11987
56ceeef91c22 Remove obsolete macros from several modules.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents: 11819
diff changeset
164 ]])],
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
165 [gl_cv_func_getopt_posix=maybe],
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
166 [gl_cv_func_getopt_posix=no])
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
167 fi
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
168 if test $gl_cv_func_getopt_posix = maybe; then
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
169 dnl Detect Mac OS X 10.5, AIX 7.1, mingw bug.
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
170 AC_RUN_IFELSE(
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
171 [AC_LANG_SOURCE([[
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
172 #include <unistd.h>
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
173 #include <stdlib.h>
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
174 #include <string.h>
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
175
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
176 int
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
177 main ()
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
178 {
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
179 static char program[] = "program";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
180 static char ab[] = "-ab";
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
181 char *argv[3] = { program, ab, NULL };
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
182 if (getopt (2, argv, "ab:") != 'a')
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
183 return 13;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
184 if (getopt (2, argv, "ab:") != '?')
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
185 return 14;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
186 if (optopt != 'b')
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
187 return 15;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
188 if (optind != 2)
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
189 return 16;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
190 return 0;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
191 }
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
192 ]])],
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
193 [gl_cv_func_getopt_posix=yes],
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
194 [gl_cv_func_getopt_posix=no])
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
195 fi
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
196 else
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
197 case "$host_os" in
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
198 darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
199 *) gl_cv_func_getopt_posix="guessing yes";;
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
200 esac
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
201 fi
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
202 ])
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
203 case "$gl_cv_func_getopt_posix" in
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
204 *no) gl_replace_getopt=yes ;;
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
205 esac
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
206 fi
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
207
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
208 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
209 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
210 [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
211 # optstring is necessary for programs like m4 that have POSIX-mandated
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
212 # semantics for supporting options interspersed with files.
12473
81590e0c5feb test-getopt: enhance test
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
213 # Also, since getopt_long is a GNU extension, we require optind=0.
13646
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
214 # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
215 # so take care to revert to the correct (non-)export state.
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
216 dnl GNU Coding Standards currently allow awk but not env; besides, env
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
217 dnl is ambiguous with environment values that contain newlines.
13652
63612cd2a9b1 getopt: optimize previous patch
Eric Blake <eblake@redhat.com>
parents: 13646
diff changeset
218 gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
63612cd2a9b1 getopt: optimize previous patch
Eric Blake <eblake@redhat.com>
parents: 13646
diff changeset
219 case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
13646
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
220 xx) gl_had_POSIXLY_CORRECT=exported ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
221 x) gl_had_POSIXLY_CORRECT=yes ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
222 *) gl_had_POSIXLY_CORRECT= ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
223 esac
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
224 POSIXLY_CORRECT=1
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
225 export POSIXLY_CORRECT
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
226 AC_RUN_IFELSE(
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
227 [AC_LANG_PROGRAM([[#include <getopt.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
228 #include <stddef.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
229 #include <string.h>
15433
2b7d01b95963 getopt-gnu: suppress core dumps from detection code
Pádraig Brady <P@draigBrady.com>
parents: 15363
diff changeset
230 ]GL_NOCRASH[
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
231 ]], [[
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
232 int result = 0;
15433
2b7d01b95963 getopt-gnu: suppress core dumps from detection code
Pádraig Brady <P@draigBrady.com>
parents: 15363
diff changeset
233
2b7d01b95963 getopt-gnu: suppress core dumps from detection code
Pádraig Brady <P@draigBrady.com>
parents: 15363
diff changeset
234 nocrash_init();
2b7d01b95963 getopt-gnu: suppress core dumps from detection code
Pádraig Brady <P@draigBrady.com>
parents: 15363
diff changeset
235
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
236 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
16935
498a2211d839 Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents: 16914
diff changeset
237 and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
238 OSF/1 5.1, Solaris 10. */
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
239 {
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
240 static char conftest[] = "conftest";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
241 static char plus[] = "-+";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
242 char *argv[3] = { conftest, plus, NULL };
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
243 opterr = 0;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
244 if (getopt (2, argv, "+a") != '?')
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
245 result |= 1;
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
246 }
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
247 /* This code succeeds on glibc 2.8, mingw,
16935
498a2211d839 Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents: 16914
diff changeset
248 and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
249 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
250 {
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
251 static char program[] = "program";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
252 static char p[] = "-p";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
253 static char foo[] = "foo";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
254 static char bar[] = "bar";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
255 char *argv[] = { program, p, foo, bar, NULL };
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
256
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
257 optind = 1;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
258 if (getopt (4, argv, "p::") != 'p')
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
259 result |= 2;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
260 else if (optarg != NULL)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
261 result |= 4;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
262 else if (getopt (4, argv, "p::") != -1)
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
263 result |= 6;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
264 else if (optind != 2)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
265 result |= 8;
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
266 }
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
267 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
268 {
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
269 static char program[] = "program";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
270 static char foo[] = "foo";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
271 static char p[] = "-p";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
272 char *argv[] = { program, foo, p, NULL };
12473
81590e0c5feb test-getopt: enhance test
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
273 optind = 0;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
274 if (getopt (3, argv, "-p") != 1)
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
275 result |= 16;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
276 else if (getopt (3, argv, "-p") != 'p')
16914
80e5b1a6673a getopt-gnu: Fix exit code overflow in autoconf test.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
277 result |= 16;
12371
9f4c9181d1d6 getopt-gnu: flush out another BSD bug
Eric Blake <ebb9@byu.net>
parents: 12085
diff changeset
278 }
13228
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
279 /* This code fails on glibc 2.11. */
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
280 {
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
281 static char program[] = "program";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
282 static char b[] = "-b";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
283 static char a[] = "-a";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
284 char *argv[] = { program, b, a, NULL };
13228
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
285 optind = opterr = 0;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
286 if (getopt (3, argv, "+:a:b") != 'b')
16914
80e5b1a6673a getopt-gnu: Fix exit code overflow in autoconf test.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
287 result |= 32;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
288 else if (getopt (3, argv, "+:a:b") != ':')
16914
80e5b1a6673a getopt-gnu: Fix exit code overflow in autoconf test.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
289 result |= 32;
13228
de461a3f23f5 getopt-gnu: match recent glibc fixes and posix ruling
Eric Blake <eblake@redhat.com>
parents: 13226
diff changeset
290 }
15359
be44fb90ec88 getopt-gnu: avoid crash in glibc getopt
Eric Blake <eblake@redhat.com>
parents: 14969
diff changeset
291 /* This code dumps core on glibc 2.14. */
be44fb90ec88 getopt-gnu: avoid crash in glibc getopt
Eric Blake <eblake@redhat.com>
parents: 14969
diff changeset
292 {
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
293 static char program[] = "program";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
294 static char w[] = "-W";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
295 static char dummy[] = "dummy";
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
296 char *argv[] = { program, w, dummy, NULL };
15359
be44fb90ec88 getopt-gnu: avoid crash in glibc getopt
Eric Blake <eblake@redhat.com>
parents: 14969
diff changeset
297 optind = opterr = 1;
15363
0bbb2481b43a getopt: more portable argv creation
Eric Blake <eblake@redhat.com>
parents: 15360
diff changeset
298 if (getopt (3, argv, "W;") != 'W')
16914
80e5b1a6673a getopt-gnu: Fix exit code overflow in autoconf test.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
299 result |= 64;
15359
be44fb90ec88 getopt-gnu: avoid crash in glibc getopt
Eric Blake <eblake@redhat.com>
parents: 14969
diff changeset
300 }
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13652
diff changeset
301 return result;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
302 ]])],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
303 [gl_cv_func_getopt_gnu=yes],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12371
diff changeset
304 [gl_cv_func_getopt_gnu=no],
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
305 [dnl Cross compiling. Assume the worst, even on glibc platforms.
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
306 gl_cv_func_getopt_gnu="guessing no"
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
307 ])
13646
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
308 case $gl_had_POSIXLY_CORRECT in
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
309 exported) ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
310 yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
311 *) AS_UNSET([POSIXLY_CORRECT]) ;;
3e732dcfec0c getopt: handle POSIXLY_CORRECT set but not exported
Eric Blake <eblake@redhat.com>
parents: 13493
diff changeset
312 esac
11819
245c367e63f4 New modules 'getopt-posix', 'getopt-gnu'.
Bruno Haible <bruno@clisp.org>
parents: 11818
diff changeset
313 ])
16949
6c13c6060f77 getopt-posix: No longer guarantee that option processing is resettable.
Bruno Haible <bruno@clisp.org>
parents: 16937
diff changeset
314 if test "$gl_cv_func_getopt_gnu" != yes; then
11809
0e2c54ee1521 Clarify logic; Separate gl_replace_getopt and GETOPT_H.
Bruno Haible <bruno@clisp.org>
parents: 11808
diff changeset
315 gl_replace_getopt=yes
16937
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
316 else
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
317 AC_CACHE_CHECK([for working GNU getopt_long function],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
318 [gl_cv_func_getopt_long_gnu],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
319 [AC_RUN_IFELSE(
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
320 [AC_LANG_PROGRAM(
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
321 [[#include <getopt.h>
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
322 #include <stddef.h>
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
323 #include <string.h>
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
324 ]],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
325 [[static const struct option long_options[] =
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
326 {
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
327 { "xtremely-",no_argument, NULL, 1003 },
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
328 { "xtra", no_argument, NULL, 1001 },
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
329 { "xtreme", no_argument, NULL, 1002 },
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
330 { "xtremely", no_argument, NULL, 1003 },
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
331 { NULL, 0, NULL, 0 }
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
332 };
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
333 /* This code fails on OpenBSD 5.0. */
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
334 {
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
335 static char program[] = "program";
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
336 static char xtremel[] = "--xtremel";
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
337 char *argv[] = { program, xtremel, NULL };
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
338 int option_index;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
339 optind = 1; opterr = 0;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
340 if (getopt_long (2, argv, "", long_options, &option_index) != 1003)
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
341 return 1;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
342 }
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
343 return 0;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
344 ]])],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
345 [gl_cv_func_getopt_long_gnu=yes],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
346 [gl_cv_func_getopt_long_gnu=no],
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
347 [dnl Cross compiling. Guess no on OpenBSD, yes otherwise.
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
348 case "$host_os" in
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
349 openbsd*) gl_cv_func_getopt_long_gnu="guessing no";;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
350 *) gl_cv_func_getopt_long_gnu="guessing yes";;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
351 esac
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
352 ])
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
353 ])
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
354 case "$gl_cv_func_getopt_long_gnu" in
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
355 *yes) ;;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
356 *) gl_replace_getopt=yes ;;
1c62478e5da0 getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
Bruno Haible <bruno@clisp.org>
parents: 16935
diff changeset
357 esac
5478
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
358 fi
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
359 fi
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360 ])
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
361
11813
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
362 AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
363 [
11813
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
364 GETOPT_H=getopt.h
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
365 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
366 [Define to rpl_ if the getopt replacement functions and variables
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
367 should be used.])
c26f42c45dd6 Reorder macros.
Bruno Haible <bruno@clisp.org>
parents: 11810
diff changeset
368 AC_SUBST([GETOPT_H])
6007
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
369 ])
5b580599ba01 Add support to getopt for Emacs, which doesn't use LIBOBJS in the
Paul Eggert <eggert@cs.ucla.edu>
parents: 5838
diff changeset
370
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
371 # Prerequisites of lib/getopt*.
6587
453776fca04b Work around porting bugs reported by Dieter in
Paul Eggert <eggert@cs.ucla.edu>
parents: 6052
diff changeset
372 AC_DEFUN([gl_PREREQ_GETOPT],
453776fca04b Work around porting bugs reported by Dieter in
Paul Eggert <eggert@cs.ucla.edu>
parents: 6052
diff changeset
373 [
453776fca04b Work around porting bugs reported by Dieter in
Paul Eggert <eggert@cs.ucla.edu>
parents: 6052
diff changeset
374 AC_CHECK_DECLS_ONCE([getenv])
453776fca04b Work around porting bugs reported by Dieter in
Paul Eggert <eggert@cs.ucla.edu>
parents: 6052
diff changeset
375 ])