bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] Re: Autoconf and differences between GNU getopt and OpenBSD


From: Paul Eggert
Subject: [Bug-gnulib] Re: Autoconf and differences between GNU getopt and OpenBSD getopt
Date: Fri, 15 Oct 2004 13:04:31 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> But it seems bad style to replace a system getopt unless there is
> something wrong with it?  In the POSIX sense, I mean.

The getopt module has long meant GNU getopt.  If there's a need for a
different module that checks only for POSIX functionality, we could
write one; but I don't see the need, at least for GNU applications,
since the GNU coding standards suggest that programs support long
options.

Also, if there's a need for a different module that checks for the
intersection of GNU and BSD getopt, we could write that module as
well.  That would be reasonable, if someone wants to do it.

In the meantime, though, let's just fix gnulib/m4/getopt.m4 so that it
checks for BSD incompatibilities with GNU getopt.  I installed the
following: it's a bit of a hack, but it should work for now.

2004-10-15  Paul Eggert  <address@hidden>

        * getopt.m4 (gl_GETOPT): Detect and reject the incompatible BSD
        implementation of getopt_long.  Problem reported by Alexander Taler in:
        http://lists.gnu.org/archive/html/bug-gnulib/2004-10/msg00103.html

Index: m4/getopt.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/getopt.m4,v
retrieving revision 1.3
diff -p -u -r1.3 getopt.m4
--- m4/getopt.m4        12 Aug 2004 08:03:11 -0000      1.3
+++ m4/getopt.m4        15 Oct 2004 20:01:11 -0000
@@ -1,4 +1,4 @@
-# getopt.m4 serial 3
+# getopt.m4 serial 4
 dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -38,6 +38,10 @@ AC_DEFUN([gl_GETOPT],
   AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
   AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
 
+  dnl BSD getopt_long uses an incompatible method to reset option processing,
+  dnl and (as of 2004-10-15) mishandles optional option-arguments.
+  AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
+
   if test -n "$GETOPT_H"; then
      gl_GETOPT_SUBSTITUTE
   fi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]