[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] more cleanup before adding shell functions
From: |
Eric Blake |
Subject: |
Re: [PATCH] more cleanup before adding shell functions |
Date: |
Thu, 9 Oct 2008 17:01:16 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
> Hmmm. Since AS_SHELL_SANITIZE does not use $as_me, maybe a better approach
is
> to make _AS_ECHO_LOG, AS_MESSAGE, _AS_LINENO_PREPARE, and AS_TMPDIR (ie. the
> actual clients of $as_me) be the ones that AS_REQUIRE([_AS_ME_PREPARE]).
>
> I'm okay if you push as is (I can write the followup that shuffles around who
> calls AS_REQUIRE([_AS_ME_PREPARE], if you don't get to it before you push).
Here's what I'm pushing. I tested with TESTSUITEFLAGS='-d -k m4sh' before and
after the patch, then ran diffstat on the recursive diff of the two
testsuite.dir:
testsuite.dir/049/expout | 2 -
testsuite.dir/049/reference | 36 ---------------------
testsuite.dir/049/test-2.lineno | 56 ++++++---------------------------
testsuite.dir/049/test/test-1 | 34 --------------------
testsuite.dir/049/test/test-2 | 34 --------------------
testsuite.dir/049/testsuite.log | 4 +-
testsuite.dir/050/script | 27 ---------------
testsuite.dir/050/testsuite.log | 2 -
testsuite.dir/051/script | 34 --------------------
testsuite.dir/051/testsuite.log | 2 -
testsuite.dir/052/script | 21 ------------
testsuite.dir/052/testsuite.log | 2 -
testsuite.dir/053/script | 28 +++++++---------
testsuite.dir/053/testsuite.log | 2 -
testsuite.dir/054/script | 66 ++++++++++++++++++---------------------
testsuite.dir/054/testsuite.log | 2 -
testsuite.dir/055/script | 2 -
testsuite.dir/055/testsuite.log | 2 -
testsuite.dir/056/script | 2 -
testsuite.dir/056/testsuite.log | 2 -
testsuite.dir/057/script | 2 -
testsuite.dir/057/testsuite.log | 2 -
testsuite.dir/058/script | 4 --
testsuite.dir/058/testsuite.log | 2 -
testsuite.dir/059/script | 2 -
testsuite.dir/059/testsuite.log | 2 -
testsuite.dir/060/script | 34 --------------------
testsuite.dir/060/testsuite.log | 2 -
testsuite.dir/061/script | 34 --------------------
testsuite.dir/061/testsuite.log | 2 -
testsuite.dir/062/script | 34 --------------------
testsuite.dir/062/testsuite.log | 2 -
I also manually inspected the diffs, and nothing jumped out at me as an
incorrect change (some of the initialization was rearranged, and most changes
were either deletion of unused code, or fallout from changed __oline__/LINENO
due to smaller scripts). The testsuite.log diffs generally showed a speedup on
the scripts that ended up smaller because of fewer forks during initialization
checks; I tested on cygwin where forking is particularly noticeable. For
example:
-49. m4sh.at:27: 49. LINENO (m4sh.at:27): ok (0m21.609s 0m21.800s)
+49. m4sh.at:27: 49. LINENO (m4sh.at:27): ok (0m17.214s 0m18.124s)
From: Eric Blake <address@hidden>
Date: Thu, 9 Oct 2008 10:58:11 -0600
Subject: [PATCH] Only prepare $as_me if it will be used.
* lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Avoid unconditional
preparation.
(_AS_ECHO_LOG): Depend on $LINENO preparation.
(AS_MESSAGE): Depend on $as_me preparation.
(AS_TMPDIR): Use AS_ERROR, rather than a hand-rolled copy.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 9 +++++++++
lib/m4sugar/m4sh.m4 | 24 ++++++++++--------------
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e4176e8..258315b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-09 Eric Blake <address@hidden>
+
+ Only prepare $as_me if it will be used.
+ * lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Avoid unconditional
+ preparation.
+ (_AS_ECHO_LOG): Depend on $LINENO preparation.
+ (AS_MESSAGE): Depend on $as_me preparation.
+ (AS_TMPDIR): Use AS_ERROR, rather than a hand-rolled copy.
+
2008-10-09 Paolo Bonzini <address@hidden>
* m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Delay setting as_me
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index b64a6cf..6926f02 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -220,9 +220,9 @@ dnl Remove any tests from suggested that are also required
[CONFIG_SHELL=$as_shell
as_have_required=yes
m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break],
- [AS_IF([_AS_RUN(m4_set_contents([_AS_DETECT_SUGGESTED_BODY]),
- ["$as_shell" 2> /dev/null])],
- [break])])])
+ [AS_IF([_AS_RUN(m4_set_contents([_AS_DETECT_SUGGESTED_BODY]),
+ ["$as_shell" 2> /dev/null])],
+ [break])])])
done
AS_IF([test "x$CONFIG_SHELL" != x],
@@ -457,9 +457,6 @@ export LC_ALL
LANGUAGE=C
export LANGUAGE
-dnl Delay this until after shell functions are defined.
-AS_REQUIRE([_AS_ME_PREPARE])
-
# CDPATH.
$as_unset CDPATH
])# AS_SHELL_SANITIZE
@@ -646,7 +643,8 @@ m4_define([_AS_ECHO],
# --------------------
# Log the string to AS_MESSAGE_LOG_FD.
m4_define([_AS_ECHO_LOG],
-[_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])])
+[AS_REQUIRE([_AS_LINENO_PREPARE])dnl
+_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])])
# _AS_ECHO_N_PREPARE
@@ -682,7 +680,8 @@ m4_define([_AS_ECHO_N],
# AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
# ----------------------------------------
m4_define([AS_MESSAGE],
-[m4_ifset([AS_MESSAGE_LOG_FD],
+[AS_REQUIRE([_AS_ME_PREPARE])dnl
+m4_ifset([AS_MESSAGE_LOG_FD],
[{ _AS_ECHO_LOG([$1])
_AS_ECHO([$as_me: $1], [$2]);}],
[_AS_ECHO([$as_me: $1], [$2])])[]dnl
@@ -1332,7 +1331,8 @@ m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
# Create as safely as possible a temporary directory in DIRECTORY
# which name is inspired by PREFIX (should be 2-4 chars max).
m4_define([AS_TMPDIR],
-[# Create a (secure) tmp directory for tmp files.
+[AS_REQUIRE([_AS_ME_PREPARE])dnl
+# Create a (secure) tmp directory for tmp files.
m4_if([$2], [], [: ${TMPDIR=/tmp}])
{
tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX")
2>/dev/null` &&
@@ -1341,11 +1341,7 @@ m4_if([$2], [], [: ${TMPDIR=/tmp}])
{
tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
(umask 077 && mkdir "$tmp")
-} ||
-{
- AS_ECHO(["$as_me: cannot create a temporary directory in m4_default([$2],
[$TMPDIR])"]) >&2
- AS_EXIT
-}dnl
+} || AS_ERROR([cannot create a temporary directory in m4_default([$2],
[$TMPDIR])])dnl
])# AS_TMPDIR
--
1.6.0.2
Re: [PATCH] more cleanup before adding shell functions, Paul Eggert, 2008/10/09