m4-patches
[Top][All Lists]
Advanced

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

update use of getopt on master branch


From: Eric Blake
Subject: update use of getopt on master branch
Date: Thu, 26 Nov 2009 14:47:21 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It's been a while since I've devoted any time to the m4 master branch, as
evidenced by this submodule jump of 635 commits in gnulib.  One of the
biggest problems was figuring out how to use gnulib-gnu instead of the
deprecated gnulib module; and in the meantime, gen_tempname changed
signatures (twice) and the gnulib testsuite started pulling in rpl_setenv,
which caused a link error on cygwin 1.5 if modules/stdlib didn't also use
it.  There's still an outstanding bug report that the testsuite is too
strict on parsing expected output from getopt failures, which is only made
worse by the fact that getopt no longer needs replacement on modern BSDs,
even though they spell error messages differently.  I'll work on that next.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksO92kACgkQ84KuGfSFAYCvIwCdEg8RIpihc8hMJwBD21xbCkXR
tsAAnRahoJPdIu0Z2YWqPrHmr//EFbeH
=lgMC
-----END PGP SIGNATURE-----
>From 7873c5c3cd64575aec4b69de326aa683309d4ba4 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 26 Nov 2009 12:58:05 -0700
Subject: [PATCH] Update to newer gnulib.

* gnulib: Update.
* ltdl/m4/gnulib-cache.m4: Import inttypes, setenv, and unsetenv
modules.
* modules/m4.c (m4_make_temp): Adjust gen_tempname client.
* bootstrap (src_modules): Pick up getopt-gnu and its
dependencies.
* configure.ac (gl_VERSION_ETC): Support ./configure
--with-packager.
(AC_CHECK_FUNCS_ONCE): Rely on gnulib for setenv, unsetenv.
* ltdl/m4/m4-getopt.m4: Rewrite to match current gnulib.
* Makefile.am (src/getopt.h): Likewise.
* modules/stdlib.c (setenv, unsetenv): Rely on gnulib.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   16 ++++++++++++++
 Makefile.am             |   19 ++++++++++++----
 bootstrap               |   13 ++++++++--
 configure.ac            |    3 +-
 gnulib                  |    2 +-
 ltdl/m4/gnulib-cache.m4 |    5 +++-
 ltdl/m4/m4-getopt.m4    |   53 +++++++---------------------------------------
 modules/m4.c            |    2 +-
 modules/stdlib.c        |   22 +-----------------
 9 files changed, 58 insertions(+), 77 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 21b662c..d59f51a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-11-26  Eric Blake  <address@hidden>
+
+       Update to newer gnulib.
+       * gnulib: Update.
+       * ltdl/m4/gnulib-cache.m4: Import inttypes, setenv, and unsetenv
+       modules.
+       * modules/m4.c (m4_make_temp): Adjust gen_tempname client.
+       * bootstrap (src_modules): Pick up getopt-gnu and its
+       dependencies.
+       * configure.ac (gl_VERSION_ETC): Support ./configure
+       --with-packager.
+       (AC_CHECK_FUNCS_ONCE): Rely on gnulib for setenv, unsetenv.
+       * ltdl/m4/m4-getopt.m4: Rewrite to match current gnulib.
+       * Makefile.am (src/getopt.h): Likewise.
+       * modules/stdlib.c (setenv, unsetenv): Rely on gnulib.
+
 2009-08-24  Eric Blake  <address@hidden>

        Pick up gnulib fixes for sub-process execution.
diff --git a/Makefile.am b/Makefile.am
index 6e207a9..fdaab47 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -101,17 +101,26 @@ src_m4_DEPENDENCIES = $(PREOPEN_DEPENDENCIES) m4/libm4.la
 ##                 --- PASTED MANUALLY FROM GNULIB ---                  ##
 ##     To avoid adding unnecessary objects to libm4.la these gnulib     ##
 ##     modules are not imported by gnulib-tool, but added manually.     ##
-##  (from: gnulib-tool --extract-automake-snippet getopt version-etc)   ##
+##     (from: gnulib-tool --extract-automake-snippet getopt-posix)      ##
 ##                                                                      ##
+if GETOPT
 BUILT_SOURCES  += src/$(GETOPT_H)
-EXTRA_DIST     += src/getopt.in.h src/getopt_int.h
+endif
+EXTRA_DIST     += src/getopt.c src/getopt1.c src/getopt.in.h src/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: src/$(GETOPT_H)
 src/getopt.h: src/getopt.in.h
-       cp $(srcdir)/src/getopt.in.h address@hidden
-       mv address@hidden $@
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+             < $(srcdir)/src/getopt.in.h; \
+       } > address@hidden && \
+       mv -f address@hidden $@
 MOSTLYCLEANFILES += src/getopt.h src/getopt.h-t
 ##                                                                      ##
 ##                     --- END OF PASTED GNULIB ---                     ##
diff --git a/bootstrap b/bootstrap
index c243ba3..ee53aa7 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh

-# bootstrap (GNU M4) version 2009-06-15
+# bootstrap (GNU M4) version 2009-11-25
 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
 # Foundation, Inc.
 # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
@@ -69,7 +69,13 @@ bailout_cb=:

 # List dependencies here too; we don't extract them, otherwise dependent
 # modules could end up being imported to src/ *and* gnu/!
-src_modules='getopt version-etc-fsf version-etc xstrtol'
+src_modules='
+getopt-gnu
+getopt-posix
+version-etc-fsf
+version-etc
+xstrtol
+'

 dirname="s,/[^/]*$,,"
 basename="s,^.*/,,g"
@@ -380,7 +386,8 @@ $CONFIG_SHELL gnulib/gnulib-tool --update \

 func_echo "fetching modules for src directory"

-for file in `$CONFIG_SHELL gnulib/gnulib-tool --extract-filelist $src_modules`
+for file in `$CONFIG_SHELL gnulib/gnulib-tool --extract-filelist $src_modules \
+  | sort -u`
 do

     dest=`echo $file | $SED "$basename"`
diff --git a/configure.ac b/configure.ac
index d5f186b..32eb9da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,6 +157,8 @@ M4_GNU_GETTEXT
 ## --------------- ##
 M4_INIT

+gl_VERSION_ETC
+
 # Gnulib doesn't always do things quite the way M4 would like...
 M4_ERROR
 M4_GETOPT
@@ -207,7 +209,6 @@ M4_SYS_STACKOVF
 AC_STRUCT_TM
 AC_FUNC_STRFTIME
 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
-AC_CHECK_FUNCS_ONCE([setenv unsetenv putenv clearenv])


 ## ------------------ ##
diff --git a/gnulib b/gnulib
index 2d8b95d..dfd793f 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 2d8b95d62cc4d6524fa6c4dbc3138d88a5839159
+Subproject commit dfd793fab03429ee3510958eee1ed33de282fbcc
diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4
index ec907ec..3ea93ba 100644
--- a/ltdl/m4/gnulib-cache.m4
+++ b/ltdl/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu 
--source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --tests-base=tests/gnu 
--aux-dir=build-aux --with-tests --libtool --macro-prefix=M4 assert autobuild 
avltree-oset binary-io bitrotate clean-temp cloexec close-stream closein 
config-h configmake dirname error execute exit fdl-1.3 fflush filenamecat 
flexmember fopen fopen-safer freadptr freadseek fseeko gendocs gettext 
git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memcmp2 memmem 
mkstemp obstack obstack-printf-posix pipe progname propername quote regex 
regexprops-generic rename snprintf-posix sprintf-posix stdbool stdlib-safer 
strnlen strtod strtol tempname unlocked-io vasnprintf-posix verify verror 
wait-process xalloc xalloc-die xmemdup0 xprintf-posix xstrndup xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu 
--source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --tests-base=tests/gnu 
--aux-dir=build-aux --with-tests --libtool --macro-prefix=M4 assert autobuild 
avltree-oset binary-io bitrotate clean-temp cloexec close-stream closein 
config-h configmake dirname error execute exit fdl-1.3 fflush filenamecat 
flexmember fopen fopen-safer freadptr freadseek fseeko gendocs gettext 
git-version-gen gnumakefile gnupload gpl-3.0 intprops inttypes memchr2 memcmp2 
memmem mkstemp obstack obstack-printf-posix pipe progname propername quote 
regex regexprops-generic rename setenv snprintf-posix sprintf-posix stdbool 
stdlib-safer strnlen strtod strtol tempname unlocked-io unsetenv 
vasnprintf-posix verify verror wait-process xalloc xalloc-die xmemdup0 
xprintf-posix xstrndup xvasprintf-posix

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
@@ -51,6 +51,7 @@ gl_MODULES([
   gnupload
   gpl-3.0
   intprops
+  inttypes
   memchr2
   memcmp2
   memmem
@@ -64,6 +65,7 @@ gl_MODULES([
   regex
   regexprops-generic
   rename
+  setenv
   snprintf-posix
   sprintf-posix
   stdbool
@@ -73,6 +75,7 @@ gl_MODULES([
   strtol
   tempname
   unlocked-io
+  unsetenv
   vasnprintf-posix
   verify
   verror
diff --git a/ltdl/m4/m4-getopt.m4 b/ltdl/m4/m4-getopt.m4
index a58764e..9c606dd 100644
--- a/ltdl/m4/m4-getopt.m4
+++ b/ltdl/m4/m4-getopt.m4
@@ -2,7 +2,7 @@
 # m4-getopt.m4 -- Use the installed version of getopt.h if available.
 # Written by Gary V. Vaughan <address@hidden>
 #
-# Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc
+# Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc
 #
 # This file is part of GNU M4.
 #
@@ -19,53 +19,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-# serial 2
+# serial 3

 # M4_GETOPT
 # ---------
 # Use the installed version of getopt.h if available.
 AC_DEFUN([M4_GETOPT],
-[GETOPT_H=
-AC_SUBST([GETOPT_H])
-
-AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h], [AC_INCLUDES_DEFAULT])
-
-if test -z "$GETOPT_H"; then
-  AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
-fi
-
-dnl BSD getopt_log uses an incompatible method to reset option processing,
-dnl and (as of 2004-10-15) mishandles optional option-arguments.
-if test -z "$GETOPT_H"; then
-  AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
-fi
-
-if test -z "$GETOPT_H"; then
-  AC_CACHE_CHECK([for working gnu getopt function], [gl_cv_func_gnu_getopt],
-    [AC_RUN_IFELSE(
-      [AC_LANG_PROGRAM([#include <getopt.h>],
-       [[
-         char *myargv[3];
-         myargv[0] = "conftest";
-         myargv[1] = "-+";
-         myargv[2] = 0;
-         return getopt (2, myargv, "+a") != '?';
-       ]])],
-      [gl_cv_func_gnu_getopt=yes],
-      [gl_cv_func_gnu_getopt=no],
-      [dnl cross compiling - pessimistically gues based on decls
-       dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
-       dnl option string (as of 2005-05-05).
-       AC_CHECK_DECL([getopt_clip],
-        [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
-        [#include <getopt.h>])])])
-  test X"$gl_cv_func_gnu_getopt" = Xno && GETOPT_H=getopt.h
-fi
-
-if test -n "$GETOPT_H"; then
-  AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
-    [Define to rpl_ if the getopt replacement function should be used.])
-fi
-
-AM_CONDITIONAL([GETOPT], [test -n "$GETOPT_H"])
+[
+  m4_divert_text([INIT_PREPARE], [M4_replace_getopt=])
+  m4_pushdef([AC_LIBOBJ], [M4_replace_getopt=:])
+  AC_REQUIRE([gl_FUNC_GETOPT_GNU])
+  m4_popdef([AC_LIBOBJ])
+  AM_CONDITIONAL([GETOPT], [test -n "$M4_replace_getopt"])
 ])# M4_GETOPT
diff --git a/modules/m4.c b/modules/m4.c
index 0597fe7..fa75c49 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -742,7 +742,7 @@ m4_make_temp (m4 *context, m4_obstack *obs, const 
m4_call_info *caller,

   /* Make the temporary object.  */
   errno = 0;
-  fd = gen_tempname (name, dir ? GT_DIR : GT_FILE);
+  fd = gen_tempname (name, 0, 0, dir ? GT_DIR : GT_FILE);
   if (fd < 0)
     {
       /* This use of _() will need to change if xgettext ever changes
diff --git a/modules/stdlib.c b/modules/stdlib.c
index 3fce71f..65df448 100644
--- a/modules/stdlib.c
+++ b/modules/stdlib.c
@@ -112,24 +112,8 @@ M4BUILTIN_HANDLER (setenv)
                         &overwrite))
       return;

-#if HAVE_SETENV
+  /* TODO - error checking.  */
   setenv (M4ARG (1), M4ARG (2), overwrite);
-#else
-#if HAVE_PUTENV
-  if (!overwrite && getenv (M4ARG (1)) != NULL)
-    return;
-
-  assert (obstack_object_size (obs) == 0);
-  obstack_grow (obs, M4ARG (1), M4ARGLEN (1));
-  obstack_1grow (obs, '=');
-  obstack_grow0 (obs, M4ARG (2), M4ARGLEN (2));
-
-  {
-    char *env = (char *) obstack_finish (obs);
-    putenv (env);
-  }
-#endif /* HAVE_PUTENV */
-#endif /* HAVE_SETENV */
 }

 /**
@@ -137,10 +121,8 @@ M4BUILTIN_HANDLER (setenv)
  **/
 M4BUILTIN_HANDLER (unsetenv)
 {
-
-#if HAVE_UNSETENV
+  /* TODO - error checking.  */
   unsetenv (M4ARG (1));
-#endif /* HAVE_UNSETENV */
 }

 /**
-- 
1.6.5.rc1


reply via email to

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