2010-04-13 Eric Blake <eblake@redhat.com>
+ getopt-posix: avoid spurious failure on Solaris
+ * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Check for getopt_clip as
+ an indicator that setting optind=1 is sufficient for reset.
+
getopt-posix: avoid spurious failure on FreeBSD
* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Check for optreset even
in POSIX mode, since the m4 test uses it.
-# getopt.m4 serial 25
+# getopt.m4 serial 26
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 Existence of the variable, in and of itself, is not a reason to replace
dnl getopt, but knowledge of the variable is needed to determine how to
dnl reset and whether a reset reparses the environment.
+ dnl Solaris supports neither optreset nor optind=0, but keeps no state that
+ dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip.
if test -z "$gl_replace_getopt"; then
- AC_CHECK_DECLS([optreset], [], [],
+ AC_CHECK_DECLS([optreset], [],
+ [AC_CHECK_DECLS([getopt_clip], [], [],
+ [[#include <getopt.h>]])
+ ],
[[#include <getopt.h>]])
fi
#include <stdlib.h>
#include <string.h>
-#if !HAVE_DECL_OPTRESET
+#if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP
# define OPTIND_MIN 0
#else
# define OPTIND_MIN 1