From: Daiki Ueno Date: Thu, 27 Mar 2014 09:20:52 +0000 (+0900) Subject: autopoint: Use SED-based trace for non-standard Autoconf macros X-Git-Tag: v0.19~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58cccf8252d95e12bbfc795445ae3a1c4ada57be;p=thirdparty%2Fgettext.git autopoint: Use SED-based trace for non-standard Autoconf macros --- diff --git a/gettext-tools/misc/ChangeLog b/gettext-tools/misc/ChangeLog index 308a8af5b..ba769c1f4 100644 --- a/gettext-tools/misc/ChangeLog +++ b/gettext-tools/misc/ChangeLog @@ -1,3 +1,12 @@ +2014-03-27 Daiki Ueno + + autopoint: Use SED-based trace for non-standard Autoconf macros + Reported by Sean McGovern in . + * 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 * autopoint.in: Allow user to specify the directory in which diff --git a/gettext-tools/misc/autopoint.in b/gettext-tools/misc/autopoint.in index 68ec39c86..240c509f7 100644 --- a/gettext-tools/misc/autopoint.in +++ b/gettext-tools/misc/autopoint.in @@ -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 diff --git a/gettext-tools/misc/gettextize.in b/gettext-tools/misc/gettextize.in index 390c37e2d..19c6467b9 100644 --- a/gettext-tools/misc/gettextize.in +++ b/gettext-tools/misc/gettextize.in @@ -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