[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uCl
From: |
Paul Eggert |
Subject: |
[Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt? |
Date: |
Thu, 12 Aug 2004 01:16:51 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Simon Josefsson <address@hidden> writes:
>>> FWIW, I have tested the getopt patch now, on many platforms, as it is
>>> part of some recently released packages.
OK, thanks. I tested this with GNU tar, which uses argp, and found
several argp-related problems (one of which you mentioned in your
second message). I installed the following patch, which consists of
the getopt changes you suggested along with some argp changes to
match.
We should probably let this shake out a few days before plumping for
its inclusion into glibc. I haven't yet tested it with coreutils or
diffutils (neither of which use argp).
2004-08-12 Paul Eggert <address@hidden>
* modules/argp (Files): Add m4/unlocked-io.m4.
(Depends-on): Add extensions.
2004-08-12 Simon Josefsson <address@hidden>
* modules/getopt (Files): Rename getopt.h to getopt_.h.
(Makefile.am): Rewrite, use logic from argz.
(Include): Use <getopt.h> instead of "getopt.h".
2004-08-12 Paul Eggert <address@hidden>
* lib/argp-help.c, argp-parse.c: Use "gettext.h" instead of
its complicated substitute.
* lib/argp-help.c: Include <errno.h>, for program_invocation_short_name
and program_invocation_name.
Use "gettext.h" instead of its complicated substitute.
(__argp_basename) [!_LIBC]: Remove; the only use was
replaced by its body.
(__argp_short_program_name): Change condition from
!defined __argp_short_program_name to
! (defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME),
to match argp-namefrob.h.
(__argp_failure): Don't assume strerror_r returns char *
* lib/argp-parse.c (N_): Define unconditionally.
(argp_default_options): Fill out initializers with 0 to avoid
gcc warnings.
2004-08-12 Simon Josefsson <address@hidden>
* lib/getopt.c, lib/getopt1.c: Remove ELIDE_CODE hack.
* lib/getopt_.h: Renamed from getopt.h.
2004-08-12 Paul Eggert <address@hidden>
* m4/argp.m4 (gl_ARGP): Do not check for argp.h or argp_parse; nobody
uses HAVE_ARGP_H or HAVE_ARGP_PARSE.
Require gl_FUNC_GLIBC_UNLOCKED_IO, gl_USE_SYSTEM_EXTENSIONS.
Check for program_invocation_name, program_invocation_short_name,
flockfile, funlockfile, features.h, _getopt_long_only_r.
2004-08-12 Simon Josefsson <address@hidden>
* m4/getopt.m4 (gl_GETOPT_SUBSTITUTE): New macro,
as discussed with Paul Eggert in threads rooted at
<http://lists.gnu.org/archive/html/bug-gnulib/2004-06/msg00039.html>
and
<http://lists.gnu.org/archive/html/bug-gnulib/2004-07/msg00001.html>.
Before, the test was empty, and relied on ELIDE_CODE in source
code.)
(gl_PREREQ_GETOPT): New macro.
(gl_GETOPT): Use them.
* config/srclist.txt: Remove getopt.c, getopt.h (renamed to getopt_.h),
getopt1.c.
Index: lib/argp-help.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/argp-help.c,v
retrieving revision 1.10
diff -p -u -r1.10 argp-help.c
--- lib/argp-help.c 7 Aug 2004 06:43:34 -0000 1.10
+++ lib/argp-help.c 12 Aug 2004 07:54:26 -0000
@@ -26,6 +26,7 @@
#endif
#include <alloca.h>
+#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -37,30 +38,13 @@
# include <wchar.h>
#endif
-#ifndef _
-/* This is for other GNU distributions with internationalized messages. */
-# if defined HAVE_LIBINTL_H || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef dgettext
-# define dgettext(domain, msgid) \
- INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
-# endif
-# else
-# define dgettext(domain, msgid) (msgid)
-# endif
-#endif
-
-#ifndef _LIBC
-# if HAVE_STRERROR_R
-# if !HAVE_DECL_STRERROR_R
-char *strerror_r (int errnum, char *buf, size_t buflen);
-# endif
-# else
-# if !HAVE_DECL_STRERROR
-char *strerror (int errnum);
-# endif
-# endif
+#ifdef _LIBC
+# include <libintl.h>
+# undef dgettext
+# define dgettext(domain, msgid) \
+ INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
+#else
+# include "gettext.h"
#endif
#include "argp.h"
@@ -1674,20 +1658,13 @@ void __argp_help (const struct argp *arg
weak_alias (__argp_help, argp_help)
#endif
-#ifndef __argp_short_program_name
-char *__argp_basename (char *name)
-{
- char *short_name = strrchr (name, '/');
- return short_name ? short_name + 1 : name;
-}
-
+#if ! (defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
char *
__argp_short_program_name (void)
{
-# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
- return program_invocation_short_name;
-# elif HAVE_DECL_PROGRAM_INVOCATION_NAME
- return __argp_basename (program_invocation_name);
+# if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ char *name = strrchr (program_invocation_name, '/');
+ return name ? name + 1 : program_invocation_name;
# else
/* FIXME: What now? Miles suggests that it is better to use NULL,
but currently the value is passed on directly to fputs_unlocked,
@@ -1858,13 +1835,20 @@ __argp_failure (const struct argp_state
else
#endif
{
+ char const *s = NULL;
putc_unlocked (':', stream);
putc_unlocked (' ', stream);
-#if defined _LIBC || defined HAVE_STRERROR_R
- fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
-#else
- fputs (strerror (errnum), stream);
+#if _LIBC || (HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P)
+ s = __strerror_r (errnum, buf, sizeof buf);
+#elif HAVE_DECL_STRERROR_R
+ if (__strerror_r (errnum, buf, sizeof buf) == 0)
+ s = buf;
+#endif
+#if !_LIBC
+ if (! s && ! (s = strerror (errnum)))
+ s = "Unknown system error"; /* FIXME: translate this */
#endif
+ fputs (s, stream);
}
}
Index: lib/argp-parse.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/argp-parse.c,v
retrieving revision 1.8
diff -p -u -r1.8 argp-parse.c
--- lib/argp-parse.c 18 May 2004 05:18:41 -0000 1.8
+++ lib/argp-parse.c 12 Aug 2004 07:54:26 -0000
@@ -29,24 +29,15 @@
#include <getopt.h>
#include <getopt_int.h>
-#ifndef _
-/* This is for other GNU distributions with internationalized messages.
- When compiling libc, the _ macro is predefined. */
-# if defined HAVE_LIBINTL_H || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef dgettext
-# define dgettext(domain, msgid) \
- INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
-# endif
-# else
-# define dgettext(domain, msgid) (msgid)
-# define gettext(msgid) (msgid)
-# endif
-#endif
-#ifndef N_
-# define N_(msgid) (msgid)
+#ifdef _LIBC
+# include <libintl.h>
+# undef dgettext
+# define dgettext(domain, msgid) \
+ INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
+#else
+# include "gettext.h"
#endif
+#define N_(msgid) (msgid)
#include "argp.h"
#include "argp-namefrob.h"
@@ -85,11 +76,11 @@ static volatile int _argp_hang;
static const struct argp_option argp_default_options[] =
{
{"help", '?', 0, 0, N_("Give this help list"), -1},
- {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message")},
- {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program
name")},
+ {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0},
+ {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program
name"), 0},
{"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
- N_("Hang for SECS seconds (default 3600)")},
- {0, 0}
+ N_("Hang for SECS seconds (default 3600)"), 0},
+ {NULL, 0, 0, 0, NULL, 0}
};
static error_t
@@ -150,7 +141,7 @@ static const struct argp argp_default_ar
static const struct argp_option argp_version_options[] =
{
{"version", 'V', 0, 0, N_("Print program version"), -1},
- {0, 0}
+ {NULL, 0, 0, 0, NULL, 0}
};
static error_t
Index: lib/getopt.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getopt.c,v
retrieving revision 1.42
diff -p -u -r1.42 getopt.c
--- lib/getopt.c 11 Mar 2004 13:04:48 -0000 1.42
+++ lib/getopt.c 12 Aug 2004 07:54:26 -0000
@@ -32,25 +32,6 @@
#include <stdio.h>
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-# include <gnu-versions.h>
-# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-# define ELIDE_CODE
-# endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
@@ -1181,7 +1162,6 @@ getopt (int argc, char *const *argv, con
0);
}
-#endif /* Not ELIDE_CODE. */
#ifdef TEST
Index: lib/getopt1.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getopt1.c,v
retrieving revision 1.16
diff -p -u -r1.16 getopt1.c
--- lib/getopt1.c 9 Mar 2004 19:42:23 -0000 1.16
+++ lib/getopt1.c 12 Aug 2004 07:54:26 -0000
@@ -30,25 +30,6 @@
#include <stdio.h>
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
@@ -96,7 +77,6 @@ _getopt_long_only_r (int argc, char *con
1, d);
}
-#endif /* Not ELIDE_CODE. */
#ifdef TEST
Index: m4/argp.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/argp.m4,v
retrieving revision 1.2
diff -p -u -r1.2 argp.m4
--- m4/argp.m4 10 Oct 2003 19:41:12 -0000 1.2
+++ m4/argp.m4 12 Aug 2004 07:54:26 -0000
@@ -1,5 +1,5 @@
-# argp.m4 serial 2
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+# argp.m4 serial 3
+dnl Copyright (C) 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
dnl Public License, this file may be distributed as part of a program
@@ -8,7 +8,12 @@ dnl the same distribution terms as the r
AC_DEFUN([gl_ARGP],
[
- AC_CHECK_HEADERS([argp.h linewrap.h])
- AC_CHECK_FUNCS(argp_parse)
AC_REQUIRE([AC_C_INLINE])
+ AC_REQUIRE([gl_FUNC_GLIBC_UNLOCKED_IO])
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ AC_CHECK_DECLS([program_invocation_name, program_invocation_short_name],,,
+ [#include <errno.h>])
+ AC_CHECK_FUNCS_ONCE([flockfile funlockfile])
+ AC_CHECK_HEADERS_ONCE([features.h linewrap.h])
+ AC_CHECK_FUNC(_getopt_long_only_r, :, [gl_GETOPT_SUBSTITUTE])
])
Index: m4/getopt.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/getopt.m4,v
retrieving revision 1.2
diff -p -u -r1.2 getopt.m4
--- m4/getopt.m4 9 Sep 2003 18:36:53 -0000 1.2
+++ m4/getopt.m4 12 Aug 2004 07:54:26 -0000
@@ -1,13 +1,47 @@
-# getopt.m4 serial 2
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# getopt.m4 serial 3
+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
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
+# The getopt module assume you want GNU getopt, with getopt_long etc,
+# rather than vanilla POSIX getopt. This means your your code should
+# always include <getopt.h> for the getopt prototypes.
+
+AC_DEFUN([gl_GETOPT_SUBSTITUTE],
+[
+ GETOPT_H=getopt.h
+ AC_LIBOBJ([getopt])
+ AC_LIBOBJ([getopt1])
+ AC_DEFINE([optarg], [rpl_optarg],
+ [Define to rpl_optarg if the replacement variable should be used.])
+ AC_DEFINE([optind], [rpl_optind],
+ [Define to rpl_optind if the replacement variable should be used.])
+ AC_DEFINE([optopt], [rpl_optopt],
+ [Define to rpl_optopt if the replacement variable should be used.])
+ AC_DEFINE([getopt], [rpl_getopt],
+ [Define to rpl_getopt if the replacement function should be used.])
+ AC_DEFINE([getopt_long], [rpl_getopt_long],
+ [Define to rpl_getopt_long if the replacement function should be used.])
+ AC_DEFINE([getopt_long_only], [rpl_getopt_long_only],
+ [Define to rpl_getopt_long_only if the replacement function should be
used.])
+ AC_SUBST([GETOPT_H])
+])
+
AC_DEFUN([gl_GETOPT],
[
- dnl Prerequisites of lib/getopt.c.
- :
+ gl_PREREQ_GETOPT
+
+ GETOPT_H=
+ AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
+ AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
+
+ if test -n "$GETOPT_H"; then
+ gl_GETOPT_SUBSTITUTE
+ fi
])
+
+# Prerequisites of lib/getopt*.
+AC_DEFUN([gl_PREREQ_GETOPT], [:])
Index: modules/argp
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/argp,v
retrieving revision 1.5
diff -p -u -r1.5 argp
--- modules/argp 18 May 2004 05:18:41 -0000 1.5
+++ modules/argp 12 Aug 2004 07:54:26 -0000
@@ -15,6 +15,7 @@ lib/argp-pv.c
lib/argp-pvh.c
lib/argp-xinl.c
m4/argp.m4
+m4/unlocked-io.m4
Depends-on:
alloca
@@ -25,6 +26,7 @@ mempcpy
strndup
restrict
strcase
+extensions
configure.ac:
gl_ARGP
Index: modules/getopt
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/getopt,v
retrieving revision 1.5
diff -p -u -r1.5 getopt
--- modules/getopt 12 Apr 2004 20:12:33 -0000 1.5
+++ modules/getopt 12 Aug 2004 07:54:26 -0000
@@ -2,7 +2,7 @@ Description:
Process command line arguments.
Files:
-lib/getopt.h
+lib/getopt_.h
lib/getopt.c
lib/getopt1.c
lib/getopt_int.h
@@ -15,10 +15,19 @@ configure.ac:
gl_GETOPT
Makefile.am:
-lib_SOURCES += getopt.h getopt.c getopt1.c getopt_int.h
+BUILT_SOURCES += $(GETOPT_H)
+EXTRA_DIST += getopt_.h getopt_int.h
+
+# We need the following in order to create an <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+all-local $(lib_OBJECTS): $(GETOPT_H)
+getopt.h: getopt_.h
+ cp $(srcdir)/getopt_.h address@hidden
+ mv address@hidden $@
+MOSTLYCLEANFILES += getopt.h getopt.h-t
Include:
-"getopt.h"
+<getopt.h>
Maintainer:
all, glibc
Index: config/srclist.txt
===================================================================
RCS file: /cvsroot/gnulib/gnulib/config/srclist.txt,v
retrieving revision 1.40
diff -p -u -r1.40 srclist.txt
--- config/srclist.txt 22 Jun 2004 18:28:25 -0000 1.40
+++ config/srclist.txt 12 Aug 2004 08:08:08 -0000
@@ -80,18 +80,18 @@ $LIBCSRC/argp/argp-eexst.c lib gpl
$LIBCSRC/argp/argp-fmtstream.c lib gpl
$LIBCSRC/argp/argp-fmtstream.h lib gpl
$LIBCSRC/argp/argp-fs-xinl.c lib gpl
-# Currently not quite the same, due to alloca-related patch in gnulib.
+# Currently not quite the same.
#$LIBCSRC/argp/argp-help.c lib gpl
$LIBCSRC/argp/argp-namefrob.h lib gpl
-# Currently not quite the same, due to alloca-related patch in gnulib.
+# Currently not quite the same.
#$LIBCSRC/argp/argp-parse.c lib gpl
$LIBCSRC/argp/argp-pv.c lib gpl
$LIBCSRC/argp/argp-pvh.c lib gpl
$LIBCSRC/argp/argp-xinl.c lib gpl
$LIBCSRC/argp/argp.h lib gpl
-$LIBCSRC/posix/getopt.c lib gpl
-$LIBCSRC/posix/getopt.h lib gpl
-$LIBCSRC/posix/getopt1.c lib gpl
+#$LIBCSRC/posix/getopt.c lib gpl
+#$LIBCSRC/posix/getopt.h lib gpl (getopt_.h in gnulib)
+#$LIBCSRC/posix/getopt1.c lib gpl
$LIBCSRC/posix/getopt_int.h lib gpl
# c89 changes $LIBCSRC/string/strdup.c lib gpl
$LIBCSRC/sysdeps/generic/strtoll.c lib gpl
- [Bug-gnulib] argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Paul Eggert, 2004/08/07
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Simon Josefsson, 2004/08/07
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Paul Eggert, 2004/08/08
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Simon Josefsson, 2004/08/08
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?,
Paul Eggert <=
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Simon Josefsson, 2004/08/12
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Paul Eggert, 2004/08/12
- [Bug-gnulib] Re: [Bug-tar] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Sergey Poznyakoff, 2004/08/12
- [Bug-gnulib] Re: [Bug-tar] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Paul Eggert, 2004/08/12
- [Bug-gnulib] Re: [Bug-tar] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Sergey Poznyakoff, 2004/08/13
- [Bug-gnulib] Re: argp-help.c patch for GNU tar; any more thoughts on uClibc getopt?, Simon Josefsson, 2004/08/12