X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fgetopt.m4;h=a19805eaa4041a41462fd3001146e4dd70ad8f73;hb=2d44e171101261b1bd3c29e46a0a7a03b919286e;hp=264b57f9f2fe06e80ddd1c465b3bae76aa29ffee;hpb=c0c5acfbe255f5542bc1c81c7aec223d95e504a6;p=gnulib.git diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 264b57f9f..a19805eaa 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -1,5 +1,5 @@ # getopt.m4 serial 24 -dnl Copyright (C) 2002-2006, 2008-2009 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -88,6 +88,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], dnl strings starts with '+' and it's not the first call. Some internal state dnl is left over from earlier calls, and neither setting optind = 0 nor dnl setting optreset = 1 get rid of this internal state. + dnl POSIX is silent on optind vs. optreset, so we allow either behavior. if test -z "$gl_replace_getopt"; then AC_CACHE_CHECK([whether getopt is POSIX compatible], [gl_cv_func_getopt_posix], @@ -187,18 +188,14 @@ main () [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the # optstring is necessary for programs like m4 that have POSIX-mandated # semantics for supporting options interspersed with files. + # Also, since getopt_long is a GNU extension, we require optind=0. gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes} POSIXLY_CORRECT=1 export POSIXLY_CORRECT AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[#include - #include - #include -#if !HAVE_DECL_OPTRESET -# define OPTIND_MIN 0 -#else -# define OPTIND_MIN (optreset = 1) -#endif + [AC_LANG_PROGRAM([[#include + #include + #include ]], [[ /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, @@ -231,17 +228,17 @@ main () /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ { char *argv[] = { "program", "foo", "-p", NULL }; - optind = OPTIND_MIN; + optind = 0; if (getopt (3, argv, "-p") != 1) return 6; if (getopt (3, argv, "-p") != 'p') return 7; } return 0; - ]])], - [gl_cv_func_getopt_gnu=yes], - [gl_cv_func_getopt_gnu=no], - [dnl Cross compiling. Guess based on host and declarations. + ]])], + [gl_cv_func_getopt_gnu=yes], + [gl_cv_func_getopt_gnu=no], + [dnl Cross compiling. Guess based on host and declarations. case $host_os:$ac_cv_have_decl_optreset in *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;; *:yes) gl_cv_func_getopt_gnu=no;;