[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
clean up m4sh.m4, then optimize AS_PATH_WALK
From: |
Eric Blake |
Subject: |
clean up m4sh.m4, then optimize AS_PATH_WALK |
Date: |
Sat, 01 Apr 2006 09:40:07 -0700 |
User-agent: |
Thunderbird 1.5 (Windows/20051201) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Two part patch: first, rearrange chunks of m4 to be alphabetical (as
implied by the comments), and fix a couple of typos. Then, make it
possible to skip non-existent directories when doing a PATH walk. Why?
Because without it, AS_DETECT_BETTER_SHELL throws /usr/bin/posix at the
front of the path walk, and on platforms without this directory, this adds
four shells to as_candidate_shells that cannot exist, wasting four
subshells in the subsequent _AS_RUN just to determine that $as_shell can't
be run because it doesn't exist.
2006-04-01 Eric Blake <address@hidden>
* lib/m4sugar/m4sh.m4 (_AS_PATH_WALK): Optimize non-existant
directories, unless optional third argument supplied.
(AS_UNAME): Don't optimize PATH walk.
* lib/m4sugar/m4sh.m4: Sort sections as implied by the comments,
and fix some typos.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFELqzn84KuGfSFAYARAmMFAKCQR8ZFEyBupgSXbYjA/6d8W39fOACgzIeW
HJlEito+1mfkhDWJBe2CS1Y=
=5ARH
-----END PGP SIGNATURE-----
Index: m4sh.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.167
diff -u -p -r1.167 m4sh.m4
--- m4sh.m4 1 Apr 2006 16:09:13 -0000 1.167
+++ m4sh.m4 1 Apr 2006 16:36:33 -0000
@@ -326,15 +326,15 @@ _AS_PATH_SEPARATOR_PREPARE
_AS_UNSET_PREPARE
# IFS
-# We need space, tab and new line, in precisely that order.
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
as_nl='
'
-IFS=" $as_nl"
+IFS=" "" $as_nl"
-# Find who we are. Look in the path if we contain no path at all
-# relative or not.
+# Find who we are. Look in the path if we contain no directory separator.
case $[0] in
*[[\\/]]* ) as_myself=$[0] ;;
*) _AS_PATH_WALK([],
@@ -423,6 +423,30 @@ m4_defun([AS_PREPARE],
# This section is lexicographically sorted.
+# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
+# ----------------------------------------------------
+# Expand into
+# | case WORD in
+# | PATTERN1) IF-MATCHED1 ;;
+# | ...
+# | *) DEFAULT ;;
+# | esac
+m4_define([_AS_CASE],
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
+ [$#], 1, [ *) $1 ;;],
+ [$#], 2, [ $1) m4_default([$2], [:]) ;;],
+ [ $1) m4_default([$2], [:]) ;;
+$0(m4_shiftn(2, $@))])dnl
+])
+m4_defun([AS_CASE],
+[m4_ifval([$2$3],
+[case $1 in
+_AS_CASE(m4_shift($@))
+esac
+])dnl
+])# AS_CASE
+
+
# AS_EXIT([EXIT-CODE = 1])
# ------------------------
# Exit and set exit code to EXIT-CODE in the way that it's seen
@@ -470,30 +494,6 @@ fi
])# AS_IF
-# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
-# ----------------------------------------------------
-# Expand into
-# | case WORD in
-# | PATTERN1) IF-MATCHED1 ;;
-# | ...
-# | *) DEFAULT ;;
-# | esac
-m4_define([_AS_CASE],
-[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
- [$#], 1, [ *) $1 ;;],
- [$#], 2, [ $1) m4_default([$2], [:]) ;;],
- [ $1) m4_default([$2], [:]) ;;
-$0(m4_shiftn(2, $@))])dnl
-])
-m4_defun([AS_CASE],
-[m4_ifval([$2$3],
-[case $1 in
-_AS_CASE(m4_shift($@))
-esac
-])dnl
-])# AS_CASE
-
-
# _AS_UNSET_PREPARE
# -----------------
# AS_UNSET depends upon $as_unset: compute it.
@@ -652,6 +652,53 @@ m4_define([AS_ERROR],
# This section is lexicographically sorted.
+# AS_BASENAME(FILE-NAME)
+# ----------------------
+# Simulate the command 'basename FILE-NAME'. Not all systems have basename.
+# Also see the comments for AS_DIRNAME.
+
+m4_defun([AS_BASENAME_EXPR],
+[AS_REQUIRE([_AS_EXPR_PREPARE])dnl
+$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
+ X[]$1 : 'X\(//\)$' \| \
+ X[]$1 : 'X\(/\)' \| \
+ . : '\(.\)'])
+
+m4_defun([AS_BASENAME_SED],
+[echo X/[]$1 |
+ sed ['/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q']])
+
+m4_defun([AS_BASENAME],
+[AS_REQUIRE([_$0_PREPARE])dnl
+$as_basename $1 ||
+AS_BASENAME_EXPR([$1]) 2>/dev/null ||
+AS_BASENAME_SED([$1])])
+
+
+# _AS_BASENAME_PREPARE
+# --------------------
+# Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
+m4_defun([_AS_BASENAME_PREPARE],
+[if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+])# _AS_BASENAME_PREPARE
+
+
# AS_DIRNAME(FILE-NAME)
# ---------------------
# Simulate the command 'dirname FILE-NAME'. Not all systems have dirname.
@@ -697,41 +744,6 @@ AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
AS_DIRNAME_SED([$1])])
-# AS_BASENAME(FILE-NAME)
-# ----------------------
-# Simulate the command 'basename FILE-NAME'. Not all systems have basename.
-# Also see the comments for AS_DIRNAME.
-
-m4_defun([AS_BASENAME_EXPR],
-[AS_REQUIRE([_AS_EXPR_PREPARE])dnl
-$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
- X[]$1 : 'X\(//\)$' \| \
- X[]$1 : 'X\(/\)' \| \
- . : '\(.\)'])
-
-m4_defun([AS_BASENAME_SED],
-[echo X/[]$1 |
- sed ['/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q']])
-
-m4_defun([AS_BASENAME],
-[AS_REQUIRE([_$0_PREPARE])dnl
-$as_basename $1 ||
-AS_BASENAME_EXPR([$1]) 2>/dev/null ||
-AS_BASENAME_SED([$1])])
-
-
# AS_EXECUTABLE_P
# ---------------
# Check whether a file is executable.
@@ -741,17 +753,6 @@ m4_defun([AS_EXECUTABLE_P],
])# AS_EXECUTABLE_P
-# _AS_BASENAME_PREPARE
-# --------------------
-# Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
-m4_defun([_AS_BASENAME_PREPARE],
-[if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-])# _AS_BASENAME_PREPARE
-
# _AS_EXPR_PREPARE
# ----------------
# QNX 4.25 expr computes and issue the right result but exits with failure.
@@ -823,7 +824,7 @@ _AS_LINENO_WORKS || {
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
+ # original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
@@ -858,6 +859,46 @@ rm -f conf$$ conf$$.exe conf$$.file
])# _AS_LN_S_PREPARE
+# AS_LN_S(FILE, LINK)
+# -------------------
+# FIXME: Should we add the glue code to handle properly relative symlinks
+# simulated with `ln' or `cp'?
+m4_defun([AS_LN_S],
+[AS_REQUIRE([_AS_LN_S_PREPARE])dnl
+$as_ln_s $1 $2
+])
+
+
+# _AS_MKDIR_P_PREPARE
+# -------------------
+m4_defun([_AS_MKDIR_P_PREPARE],
+[if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+])# _AS_MKDIR_P_PREPARE
+
+# AS_MKDIR_P(DIR)
+# ---------------
+# Emulate `mkdir -p' with plain `mkdir'.
+m4_define([AS_MKDIR_P],
+[AS_REQUIRE([_$0_PREPARE])dnl
+{ if $as_mkdir_p; then
+ test -d $1 || mkdir -p $1
+ else
+ as_dir=$1
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`AS_DIRNAME("$as_dir")`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || AS_ERROR([cannot create directory $1]); }dnl
+])# AS_MKDIR_P
+
+
# _AS_PATH_SEPARATOR_PREPARE
# --------------------------
# Compute the path separator.
@@ -904,44 +945,21 @@ IFS=$as_save_IFS
])
-# AS_LN_S(FILE, LINK)
-# -------------------
-# FIXME: Should we add the glue code to handle properly relative symlinks
-# simulated with `ln' or `cp'?
-m4_defun([AS_LN_S],
-[AS_REQUIRE([_AS_LN_S_PREPARE])dnl
-$as_ln_s $1 $2
-])
-
-
-# _AS_MKDIR_P_PREPARE
-# -------------------
-m4_defun([_AS_MKDIR_P_PREPARE],
-[if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-])# _AS_MKDIR_P_PREPARE
-
-# AS_MKDIR_P(DIR)
-# ---------------
-# Emulate `mkdir -p' with plain `mkdir'.
-m4_define([AS_MKDIR_P],
-[AS_REQUIRE([_$0_PREPARE])dnl
-{ if $as_mkdir_p; then
- test -d $1 || mkdir -p $1
- else
- as_dir=$1
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`AS_DIRNAME("$as_dir")`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || AS_ERROR([cannot create directory $1]); }dnl
-])# AS_MKDIR_P
+# AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
+# ----------------------------------------
+# Set VAR to DIR-NAME/FILE-NAME.
+# Optimize the common case where $2 or $3 is '.'.
+m4_define([AS_SET_CATFILE],
+[case $2 in
+.) $1=$3;;
+*)
+ case $3 in
+ .) $1=$2;;
+ [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
+ *) $1=$2/$3;;
+ esac;;
+esac[]dnl
+])# AS_SET_CATFILE
# _AS_TEST_PREPARE
@@ -965,23 +983,6 @@ rm -f conf$$.file
])# _AS_TEST_PREPARE
-# AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
-# ----------------------------------------
-# Set VAR to DIR-NAME/FILE-NAME.
-# Optimize the common case where $2 or $3 is '.'.
-m4_define([AS_SET_CATFILE],
-[case $2 in
-.) $1=$3;;
-*)
- case $3 in
- .) $1=$2;;
- [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
- *) $1=$2/$3;;
- esac;;
-esac[]dnl
-])# AS_SET_CATFILE
-
-
## ------------------ ##
@@ -1015,6 +1016,63 @@ m4_define([_AS_BOX_INDIR],
_ASBOX])
+# AS_HELP_STRING(LHS, RHS, [COLUMN])
+# ----------------------------------
+#
+# Format a help string so that it looks pretty when
+# the user executes "script --help". This macro takes three
+# arguments, a "left hand side" (LHS), a "right hand side" (RHS), and
+# the COLUMN which is a string of white spaces which leads to the
+# the RHS column (default: 26 white spaces).
+#
+# The resulting string is suitable for use in other macros that require
+# a help string (e.g. AC_ARG_WITH).
+#
+# Here is the sample string from the Autoconf manual (Node: External
+# Software) which shows the proper spacing for help strings.
+#
+# --with-readline support fancy command line editing
+# ^ ^ ^
+# | | |
+# | column 2 column 26
+# |
+# column 0
+#
+# A help string is made up of a "left hand side" (LHS) and a "right
+# hand side" (RHS). In the example above, the LHS is
+# "--with-readline", while the RHS is "support fancy command line
+# editing".
+#
+# If the LHS contains more than (COLUMN - 3) characters, then the LHS is
+# terminated with a newline so that the RHS starts on a line of its own
+# beginning with COLUMN. In the default case, this corresponds to an
+# LHS with more than 23 characters.
+#
+# Therefore, in the example, if the LHS were instead
+# "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
+# expand into:
+#
+#
+# --with-readline-blah-blah-blah
+# ^ ^ support fancy command line editing
+# | | ^
+# | column 2 |
+# column 0 column 26
+#
+#
+# m4_text_wrap hacks^Wworks around the fact that m4_format does not
+# know quadrigraphs.
+#
+m4_define([AS_HELP_STRING],
+[m4_pushdef([AS_Prefix], m4_default([$3], [ ]))dnl
+m4_pushdef([AS_Prefix_Format],
+ [ %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [ %-23s ]
+m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnl
+m4_popdef([AS_Prefix_Format])dnl
+m4_popdef([AS_Prefix])dnl
+])
+
+
# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
# -----------------------------------------------------
# If EXPRESSION has shell indirections ($var or `expr`), expand
@@ -1163,63 +1221,6 @@ esac[]dnl
])
-# AS_HELP_STRING(LHS, RHS, [COLUMN])
-# ----------------------------------
-#
-# Format a help string so that it looks pretty when
-# the user executes "script --help". This macro takes three
-# arguments, a "left hand side" (LHS), a "right hand side" (RHS), and
-# the COLUMN which is a string of white spaces which leads to the
-# the RHS column (default: 26 white spaces).
-#
-# The resulting string is suitable for use in other macros that require
-# a help string (e.g. AC_ARG_WITH).
-#
-# Here is the sample string from the Autoconf manual (Node: External
-# Software) which shows the proper spacing for help strings.
-#
-# --with-readline support fancy command line editing
-# ^ ^ ^
-# | | |
-# | column 2 column 26
-# |
-# column 0
-#
-# A help string is made up of a "left hand side" (LHS) and a "right
-# hand side" (RHS). In the example above, the LHS is
-# "--with-readline", while the RHS is "support fancy command line
-# editing".
-#
-# If the LHS contains more than (COLUMN - 3) characters, then the LHS is
-# terminated with a newline so that the RHS starts on a line of its own
-# beginning with COLUMN. In the default case, this corresponds to an
-# LHS with more than 23 characters.
-#
-# Therefore, in the example, if the LHS were instead
-# "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
-# expand into:
-#
-#
-# --with-readline-blah-blah-blah
-# ^ ^ support fancy command line editing
-# | | ^
-# | column 2 |
-# column 0 column 26
-#
-#
-# m4_text_wrap hacks^Wworks around the fact that m4_format does not
-# know quadrigraphs.
-#
-m4_define([AS_HELP_STRING],
-[m4_pushdef([AS_Prefix], m4_default([$3], [ ]))dnl
-m4_pushdef([AS_Prefix_Format],
- [ %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [ %-23s ]
-m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnl
-m4_popdef([AS_Prefix_Format])dnl
-m4_popdef([AS_Prefix])dnl
-])
-
-
## ------------------------------------ ##
## Common m4/sh character translation. ##
--- m4sh.m4.orig 2006-04-01 09:36:10.948750000 -0700
+++ m4sh.m4 2006-04-01 09:36:58.058125000 -0700
@@ -918,9 +918,10 @@
])# _AS_PATH_SEPARATOR_PREPARE
-# _AS_PATH_WALK([PATH = $PATH], BODY)
-# -----------------------------------
-# Walk through PATH running BODY for each `as_dir'.
+# _AS_PATH_WALK([PATH = $PATH], BODY, [NO-OPTIMIZE])
+# --------------------------------------------------
+# Walk through PATH running BODY for each `as_dir'. Skip non-existent
+# directories unless NO-OPTIMIZE is specified.
#
# Still very private as its interface looks quite bad.
#
@@ -939,6 +940,7 @@
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
+ m4_ifvaln([$3], [], [test -d "$as_dir" || continue])dnl
$2
done
IFS=$as_save_IFS
@@ -1133,7 +1135,7 @@
_ASUNAME
-_AS_PATH_WALK([$PATH], [echo "PATH: $as_dir"])
+_AS_PATH_WALK([$PATH], [echo "PATH: $as_dir"], [:])
}])
- clean up m4sh.m4, then optimize AS_PATH_WALK,
Eric Blake <=
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Stepan Kasal, 2006/04/01
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Eric Blake, 2006/04/01
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Stepan Kasal, 2006/04/01
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Ralf Wildenhues, 2006/04/02
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Stepan Kasal, 2006/04/03
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Ralf Wildenhues, 2006/04/04
- Re: clean up m4sh.m4, then optimize AS_PATH_WALK, Ralf Wildenhues, 2006/04/07