[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getopt_long test failure on OpenBSD 5.0
From: |
Bruno Haible |
Subject: |
getopt_long test failure on OpenBSD 5.0 |
Date: |
Sat, 23 Jun 2012 17:08:54 +0200 |
User-agent: |
KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; ) |
On OpenBSD 5.0, I'm seeing this test failure in a testdir for module
'getopt-gnu':
test-getopt_long.h:232: assertion failed
FAIL: test-getopt
The issue is with disambiguation, say, when the user enters --foo
and the available options are --foobar and --foobaz but they have the same
actions.
This fixes it by introducing a new test
"checking for working GNU getopt_long function"
On glibc and Cygwin 1.7:
checking for working GNU getopt_long function... yes
On OpenBSD 5.0:
checking for working GNU getopt_long function... no
2012-06-23 Bruno Haible <address@hidden>
getopt-gnu: Handle suboptimal getopt_long's abbreviation handling.
* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): If getopt_long exists but
does not handle abbreviated long options with equivalent
disambiguations, set gl_replace_getopt to yes.
* doc/posix-functions/getopt.texi: Mention the OpenBSD 5.0 problem.
--- doc/posix-functions/getopt.texi.orig Sat Jun 23 17:04:28 2012
+++ doc/posix-functions/getopt.texi Sat Jun 23 16:20:24 2012
@@ -48,6 +48,10 @@
The function @code{getopt_long} is missing on some platforms:
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, MSVC 9, Interix 3.5.
@item
+The function @code{getopt_long} does not support abbreviated long options
+where all disambiguations are equivalent on some platforms:
+OpenBSD 5.0.
address@hidden
The function @code{getopt_long_only} is missing on some platforms:
Mac OS X 10.3, FreeBSD 5.2.1, NetBSD 5.0, AIX 5.1, HP-UX 11, IRIX 6.5,
OSF/1 5.1, Solaris 9, mingw, MSVC 9, Interix 3.5.
--- m4/getopt.m4.orig Sat Jun 23 17:04:28 2012
+++ m4/getopt.m4 Sat Jun 23 16:17:07 2012
@@ -1,4 +1,4 @@
-# getopt.m4 serial 41
+# getopt.m4 serial 42
dnl Copyright (C) 2002-2006, 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -319,6 +319,48 @@
])
if test "$gl_cv_func_getopt_gnu" = "no"; then
gl_replace_getopt=yes
+ else
+ AC_CACHE_CHECK([for working GNU getopt_long function],
+ [gl_cv_func_getopt_long_gnu],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <getopt.h>
+ #include <stddef.h>
+ #include <string.h>
+ ]],
+ [[static const struct option long_options[] =
+ {
+ { "xtremely-",no_argument, NULL, 1003 },
+ { "xtra", no_argument, NULL, 1001 },
+ { "xtreme", no_argument, NULL, 1002 },
+ { "xtremely", no_argument, NULL, 1003 },
+ { NULL, 0, NULL, 0 }
+ };
+ /* This code fails on OpenBSD 5.0. */
+ {
+ static char program[] = "program";
+ static char xtremel[] = "--xtremel";
+ char *argv[] = { program, xtremel, NULL };
+ int option_index;
+ optind = 1; opterr = 0;
+ if (getopt_long (2, argv, "", long_options, &option_index)
!= 1003)
+ return 1;
+ }
+ return 0;
+ ]])],
+ [gl_cv_func_getopt_long_gnu=yes],
+ [gl_cv_func_getopt_long_gnu=no],
+ [dnl Cross compiling. Guess no on OpenBSD, yes otherwise.
+ case "$host_os" in
+ openbsd*) gl_cv_func_getopt_long_gnu="guessing no";;
+ *) gl_cv_func_getopt_long_gnu="guessing yes";;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_getopt_long_gnu" in
+ *yes) ;;
+ *) gl_replace_getopt=yes ;;
+ esac
fi
fi
])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- getopt_long test failure on OpenBSD 5.0,
Bruno Haible <=