bug-gettext
[Top][All Lists]
Advanced

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

[bug-gettext] [PATCH] Refactor Autoconf trace in autopoint


From: Daiki Ueno
Subject: [bug-gettext] [PATCH] Refactor Autoconf trace in autopoint
Date: Wed, 01 May 2013 18:34:53 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

I noticed that autopoint --force copies unnecessary 'intl' directory if
there are extra whitespaces before AM_GNU_GETTEXT([external]).

This patch fixes that and generalize the Autoconf trace stuff in
autopoint.in.

---
 gettext-tools/misc/autopoint.in | 59 +++++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/gettext-tools/misc/autopoint.in b/gettext-tools/misc/autopoint.in
index 745fdb4..63f1598 100644
--- a/gettext-tools/misc/autopoint.in
+++ b/gettext-tools/misc/autopoint.in
@@ -138,6 +138,29 @@ 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 a macro call and outputs the arguments to stdout.
+# This is only useful for macros provided by aclocal.m4.  For Autoconf
+# macros use "$autom4te --trace".
+func_trace ()
+{
+  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"
+}
+
 # func_usage
 # outputs to stdout the --help usage message.
 func_usage ()
@@ -258,15 +281,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.
-sed_extract_AM_GNU_GETTEXT_VERSION_argument='
-s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
-/AM_GNU_GETTEXT_VERSION/ {
-    s,^.*AM_GNU_GETTEXT_VERSION(\([^()]*\)).*$,xver=\1,
-    s,^xver=\[\(.*\)\]$,xver=\1,
-    p
-}
-d'
-eval `sed "$sed_extract_AM_GNU_GETTEXT_VERSION_argument" "$configure_in"`
+xver=`func_trace AM_GNU_GETTEXT_VERSION`
 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
@@ -339,25 +354,17 @@ if test -z "$m4dir" && test -f Makefile.am; then
 fi
 
 # Check whether to omit the intl/ directory.
-omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 
's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 
1q`
-omitintl=`if test 'external' = "$omitintl"; then echo yes; fi`
+omitintl=no
+xargs=`func_trace AM_GNU_GETTEXT`
+for arg in $xargs; do
+  if test 'external' = "$arg"; then
+    omitintl=yes
+    break
+  fi
+done
 
 # Check in which directory or directories the po/* infrastructure belongs.
-sed_extract_config_files='s,#.*$,,
-s,^dnl .*$,,
-s, dnl .*$,,
-/AC_CONFIG_FILES(/ {
-  ta
-  :a
-    s/)/)/
-    tb
-    s/\\$//
-    N
-    ba
-  :b
-  s,^.*AC_CONFIG_FILES([[ ]*\([^]"$`\\)]*\).*$,\1,p
-}'
-configfiles=`cat "$configure_in" | sed -n -e "$sed_extract_config_files"`
+configfiles=`func_trace AC_CONFIG_FILES`
 # 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
-- 
1.8.1.4




reply via email to

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