]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
autopoint: make macro trace in autom4te robuster
authorDaiki Ueno <ueno@gnu.org>
Mon, 12 Aug 2013 14:19:55 +0000 (16:19 +0200)
committerDaiki Ueno <ueno@gnu.org>
Mon, 12 Aug 2013 15:00:26 +0000 (17:00 +0200)
gettext-tools/misc/ChangeLog
gettext-tools/misc/autopoint.in
gettext-tools/misc/gettextize.in

index bd4de9adc900c3d1b1b882b54a4e270e65970513..ea9134c2a379401e0012a0e5ac7817fd70d573d7 100644 (file)
@@ -1,3 +1,12 @@
+2013-08-12  Daiki Ueno  <ueno@gnu.org>
+
+       autopoint: make macro trace in autom4te robuster
+       * autopoint.in (func_trace): Ignore M4sugar macros which may abort
+       autom4te and read gettext.m4 to trace AM_GNU_GETTEXT_* macros.
+       * gettextize.in (func_trace): New function ported from autopoint.in.
+       Reported by Sami Kerola in
+       <https://lists.gnu.org/archive/html/bug-gettext/2013-07/msg00002.html>.
+
 2013-07-21  Daiki Ueno  <ueno@gnu.org>
 
        * autopoint.in (omitintl): Don't set it 'no' when no
index 1ea960a7cca5616885a79c4d0ff962424b8ef630..51f85511bf5c27a8852a2e1dd935c8b2ae08efce 100644 (file)
@@ -140,32 +140,19 @@ fi
 # traces an Autoconf macro call and outputs the arguments to stdout.
 func_trace ()
 {
-  case "$1" in
-    AC_*)
-      # For Autoconf standard macros, autom4te --trace can be used.
-      autom4te --no-cache --language=Autoconf-without-aclocal-m4 --trace="$1":\$% "$configure_in"
-      ;;
-    *)
-      # Otherwise, manually extract macro calls in configure.ac with
-      # sed.  This is less reliable than the above way and does not
-      # support multiple calls.
-      sed_extract_arguments='
-s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
-/'"$1"'(/ {
-  ta
-  :a
-    s/)/)/
-    tb
-    s/\\$//
-    N
-    ba
-  :b
-  s,^.*'"$1"'([[ ]*\([^]"$`\\)]*\).*$,\1,p
-}
-d'
-      sed -e "$sed_extract_arguments" "$configure_in"
-      ;;
-  esac
+  echo '\
+dnl ignore M4sugar macros which may abort autom4te
+m4_undefine([m4_assert])
+m4_undefine([m4_fatal])
+m4_undefine([m4_warn])
+m4_undefine([m4_errprintn])
+m4_undefine([m4_exit])
+dnl macros which needs to be traced without aclocal.m4
+m4_define([AM_GNU_GETTEXT], [])
+m4_define([AM_GNU_GETTEXT_VERSION], [])
+' \
+  | autom4te --no-cache --language=Autoconf-without-aclocal-m4 \
+    --trace="$1":\$% - "$2"
 }
 
 # func_usage
@@ -288,7 +275,7 @@ fi
 
 # Check whether the -V option and the version number in configure.in match.
 # At least one of the two must be given. If both are given, they must agree.
-xver=`func_trace AM_GNU_GETTEXT_VERSION`
+xver=`func_trace AM_GNU_GETTEXT_VERSION "$configure_in"`
 if test -z "$xver" && test -f intl/VERSION; then
   xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'`
 fi
@@ -326,15 +313,15 @@ case "$ver" in
 esac
 
 # Check in which directory config.rpath, mkinstalldirs etc. belong.
-auxdir=`func_trace AC_CONFIG_AUX_DIR`
+auxdir=`func_trace AC_CONFIG_AUX_DIR "$configure_in"`
 if test -n "$auxdir"; then
   auxdir="$auxdir/"
 fi
 
 # Check in which directory the *.m4 macros belong.
-macrodirs=`func_trace AC_CONFIG_MACRO_DIR_TRACE`
+macrodirs=`func_trace AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
 if test -z "$macrodirs"; then
-  macrodirs=`func_trace AC_CONFIG_MACRO_DIR`
+  macrodirs=`func_trace AC_CONFIG_MACRO_DIR "$configure_in"`
 fi
 for arg in $macrodirs; do
   m4dir="$arg"
@@ -362,7 +349,7 @@ fi
 
 # Check whether to omit the intl/ directory.
 omitintl=
-xargs=`func_trace AM_GNU_GETTEXT`
+xargs=`func_trace AM_GNU_GETTEXT "$configure_in"`
 for arg in $xargs; do
   if test 'external' = "$arg"; then
     omitintl=yes
@@ -371,7 +358,7 @@ for arg in $xargs; do
 done
 
 # Check in which directory or directories the po/* infrastructure belongs.
-configfiles=`func_trace AC_CONFIG_FILES`
+configfiles=`func_trace AC_CONFIG_FILES "$configure_in"`
 # PO directories have a Makefile.in generated from Makefile.in.in.
 # Treat a directory as a PO directory if and only if it has a
 # POTFILES.in file. This allows packages to have multiple PO
index 63190428aab3c5ad0a982128a821c132e3bfc8a2..6278a3d907cf0eca653c9679b37478b21450a717 100644 (file)
@@ -30,8 +30,6 @@ prefix="@prefix@"
 datarootdir="@datarootdir@"
 gettext_dir="@datadir@/gettext"
 
-autom4te="autom4te --no-cache --language=Autoconf-without-aclocal-m4"
-
 # func_tmpdir
 # creates a temporary directory.
 # Sets variable
@@ -138,6 +136,25 @@ if test "@RELOCATABLE@" = yes; then
   gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
 fi
 
+# func_trace macro
+# traces an Autoconf macro call and outputs the arguments to stdout.
+func_trace ()
+{
+  echo '\
+dnl ignore M4sugar macros which may abort autom4te
+m4_undefine([m4_assert])
+m4_undefine([m4_fatal])
+m4_undefine([m4_warn])
+m4_undefine([m4_errprintn])
+m4_undefine([m4_exit])
+dnl macros which needs to be traced without aclocal.m4
+m4_define([AM_GNU_GETTEXT], [])
+m4_define([AM_GNU_GETTEXT_VERSION], [])
+' \
+  | autom4te --no-cache --language=Autoconf-without-aclocal-m4 \
+    --trace="$1":\$% - "$2"
+}
+
 # func_usage
 # outputs to stdout the --help usage message.
 func_usage ()
@@ -311,15 +328,15 @@ if test $force -eq 0; then
 fi
 
 # Check in which directory config.rpath etc. belong.
-auxdir=`$autom4te --trace=AC_CONFIG_AUX_DIR:\$% "$configure_in"`
+auxdir=`func_trace AC_CONFIG_AUX_DIR "$configure_in"`
 if test -n "$auxdir"; then
   auxdir="$auxdir/"
 fi
 
 # Check in which directory gettext.m4 etc. belong.
-macrodirs=`$autom4te --trace=AC_CONFIG_MACRO_DIR_TRACE:\$% "$configure_in"`
+macrodirs=`func_trace AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
 if test -z "$macrodirs"; then
-  macrodirs=`$autom4te --trace=AC_CONFIG_MACRO_DIR:\$% "$configure_in"`
+  macrodirs=`func_trace AC_CONFIG_MACRO_DIR "$configure_in"`
 fi
 for arg in $macrodirs; do
   m4dir="$arg"
@@ -656,9 +673,15 @@ if test -n "$intldir"; then
 else
   echo "Not copying intl/ directory."
   # Tell the user what to put into configure.ac, if it is not already there.
-  if grep '^AM_GNU_GETTEXT([[]\?external[]]\?[         ]*[,)]' "$srcdir/$configure_in" > /dev/null; then
-    :
-  else
+  external=
+  xargs=`func_trace AM_GNU_GETTEXT "$srcdir/$configure_in"`
+  for arg in $xargs; do
+    if test 'external' = "$arg"; then
+      external=yes
+      break
+    fi
+  done
+  if test -z "$external"; then
     please="$please
 Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration
 to look for an external libintl.