]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
autopoint: Use SED-based trace for non-standard Autoconf macros
authorDaiki Ueno <ueno@gnu.org>
Thu, 27 Mar 2014 09:20:52 +0000 (18:20 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 27 Mar 2014 09:21:14 +0000 (18:21 +0900)
gettext-tools/misc/ChangeLog
gettext-tools/misc/autopoint.in
gettext-tools/misc/gettextize.in

index 308a8af5b97a06701f50dbbf3d14f4552c52d65e..ba769c1f42b063913751f98b6049df80f6a2714d 100644 (file)
@@ -1,3 +1,12 @@
+2014-03-27  Daiki Ueno  <ueno@gnu.org>
+
+       autopoint: Use SED-based trace for non-standard Autoconf macros
+       Reported by Sean McGovern in <https://savannah.gnu.org/bugs/?41913>.
+       * autopoint.in (func_trace_sed): New function; use it to trace
+       AM_GNU_GETTEXT and AM_GNU_GETTEXT_VERSION.
+       * gettextize.in (func_trace_sed): New function; use it to trace
+       AM_GNU_GETTEXT.
+
 2014-03-26  Daiki Ueno  <ueno@gnu.org>
 
        * autopoint.in: Allow user to specify the directory in which
index 68ec39c86a786abc047c49b1b052ab0f46fa1fe4..240c509f77bb5d923f03f9eeefd9d9dd5116bf5d 100644 (file)
@@ -136,8 +136,8 @@ 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 macro configure.ac
+# traces a standard Autoconf macro call and outputs the arguments to stdout.
 func_trace ()
 {
   echo '\
@@ -149,14 +149,35 @@ m4_undefine([m4_errprintn])
 m4_undefine([m4_exit])
 m4_undefine([m4_include])
 m4_undefine([m4_esyscmd])
-dnl macros which needs to be traced without aclocal.m4
-m4_define([AM_GNU_GETTEXT], [])
-m4_define([AM_GNU_GETTEXT_VERSION], [])
 ' \
   | ${AUTOM4TE:-autom4te} --no-cache --language=Autoconf-without-aclocal-m4 \
     --trace="$1":\$% - "$2" 2>/dev/null
 }
 
+# func_trace_sed macro configure.ac
+# traces a non-standard Autoconf macro call and outputs the arguments to stdout.
+func_trace_sed ()
+{
+  # 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" "$2"
+}
+
 # func_usage
 # outputs to stdout the --help usage message.
 func_usage ()
@@ -277,7 +298,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 "$configure_in"`
+xver=`func_trace_sed 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
@@ -355,7 +376,7 @@ fi
 
 # Check whether to omit the intl/ directory.
 omitintl=
-xargs=`func_trace AM_GNU_GETTEXT "$configure_in"`
+xargs=`func_trace_sed AM_GNU_GETTEXT "$configure_in"`
 save_IFS="$IFS"; IFS=:
 for arg in $xargs; do
   if test 'external' = "$arg"; then
index 390c37e2d4c190e2bd48ba8bf93ab5dc23e4b4ae..19c6467b9040c0d0aa4250accd7ba241fa604468 100644 (file)
@@ -136,7 +136,7 @@ if test "@RELOCATABLE@" = yes; then
   gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
 fi
 
-# func_trace macro
+# func_trace macro configure.ac
 # traces an Autoconf macro call and outputs the arguments to stdout.
 func_trace ()
 {
@@ -149,14 +149,35 @@ m4_undefine([m4_errprintn])
 m4_undefine([m4_exit])
 m4_undefine([m4_include])
 m4_undefine([m4_esyscmd])
-dnl macros which needs to be traced without aclocal.m4
-m4_define([AM_GNU_GETTEXT], [])
-m4_define([AM_GNU_GETTEXT_VERSION], [])
 ' \
   | ${AUTOM4TE:-autom4te} --no-cache --language=Autoconf-without-aclocal-m4 \
     --trace="$1":\$% - "$2" 2>/dev/null
 }
 
+# func_trace_sed macro configure.ac
+# traces a non-standard Autoconf macro call and outputs the arguments to stdout.
+func_trace_sed ()
+{
+  # 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" "$2"
+}
+
 # func_usage
 # outputs to stdout the --help usage message.
 func_usage ()
@@ -676,7 +697,7 @@ else
   echo "Not copying intl/ directory."
   # Tell the user what to put into configure.ac, if it is not already there.
   external=
-  xargs=`func_trace AM_GNU_GETTEXT "$srcdir/$configure_in"`
+  xargs=`func_trace_sed AM_GNU_GETTEXT "$srcdir/$configure_in"`
   save_IFS="$IFS"; IFS=:
   for arg in $xargs; do
     if test 'external' = "$arg"; then