2007-10-03 Eric Blake <ebb9@byu.net>
+ Optimize checking for identifiers.
+ * lib/m4sugar/m4sh.m4 (AS_IDENTIFIER_IF, _AS_IDENTIFIER_IF): New
+ macros, more efficient than regex on m4_re_word.
+ * lib/autoconf/general.m4 (AC_SUBST, AC_DEFINE_TRACE_LITERAL):
+ Rewrite in terms of new macro. As a side-effect, AC_DEFINE can
+ now use @&t@.
+ * configure: Regenerate.
+
Remove some XFAILs, and make AT_SETUP output line up.
* lib/autotest/general.m4 (AT_SETUP): Only expand description
once; thereafter, use its expansion, properly quoted.
if test "x$CONFIG_SHELL" != x; then
for as_var in BASH_ENV ENV
- do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
- done
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+ do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ done
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
- test -d "$1/.";
+ test -d "$1/.";
else
case $1 in
- -*)set "./$1";;
+ -*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
- test -d "$1/.";
+ test -d "$1/.";
else
case $1 in
- -*)set "./$1";;
+ -*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
# Used by --trace to collect the list of AC_DEFINEd macros.
m4_define([AC_DEFINE_TRACE_LITERAL],
[m4_pattern_allow([^$1$])dnl
-m4_bmatch([$1], ^m4_defn([m4_re_word])$, [],
+AS_IDENTIFIER_IF([$1], [],
[m4_warn([syntax], [AC_DEFINE: not an identifier: $1])])dnl
])# AC_DEFINE_TRACE_LITERAL
# empty value, not an empty second argument.
#
m4_define([AC_SUBST],
-[m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$, [],
+[AS_IDENTIFIER_IF([$1], [],
[AC_FATAL([$0: `$1' is not a valid shell variable name])])dnl
AC_SUBST_TRACE([$1])dnl
m4_pattern_allow([^$1$])dnl
])# AS_HELP_STRING
+# AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
+# ----------------------------------------------------
+# If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
+# matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
+# otherwise IF-NOT-IDENT.
+#
+# This is generally faster than the alternative:
+# m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
+# [$2], [$3])
+#
+# Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
+# inline its expansion up front. Only use a regular expression if we
+# detect a potential quadrigraph.
+#
+# First, check if the entire string matches m4_cr_symbol2. Only then do
+# we worry if the first character also matches m4_cr_symbol1 (ie. does not
+# match m4_cr_digit).
+m4_define([AS_IDENTIFIER_IF],
+[m4_if(m4_index([$1], [@]), [-1],
+ [_$0($@)],
+ [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
+m4_define([_AS_IDENTIFIER_IF],
+[m4_if([$1], [], [$3],
+ m4_translit([$1], ]m4_dquote(m4_defn([m4_cr_symbols2]))[), [],
+ [m4_if(m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[)), [0], [$2], [$3])],
+ [$3])])
+
# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
# -----------------------------------------------------
# If EXPRESSION has shell indirections ($var or `expr`), expand