[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Micro optimzation of config.status substitution.
From: |
Ralf Wildenhues |
Subject: |
Micro optimzation of config.status substitution. |
Date: |
Sat, 31 Oct 2009 17:42:13 +0100 |
User-agent: |
Mutt/1.5.20 (2009-08-09) |
I noticed a small opportunity for optimization in the config.staus code:
currently, when we
AC_SUBST([var], [value-that-has-148-characters])
we create awk code like
S["var"]="value-that-has-148-characters"\
""
IOW, we needlessly concatenate with an empty string. The fix is
obvious. ;-)
I'm taking the opportunity to expose the code paths involved in the
testsuite; using backslashes because they need to be escaped for awk.
Any reason against applying this? Tested on a few hosts.
Thanks,
Ralf
Micro-optimization of config.status substitution.
* lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): No need to
concatenate an empty second string, when we have exactly 148
characters to substitute.
* tests/torture.at (Substitute a 2000-byte string): Add test
exposure for runs of backslashes near the 148 character limit.
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 906f062..8ce7f84 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -462,7 +462,7 @@ s/'"$ac_delim"'$//
t delim
:nl
h
-s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\).*/\1/
+s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
@@ -476,7 +476,7 @@ s/.\{]_AC_AWK_LITERAL_LIMIT[\}//
t nl
:delim
h
-s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\).*/\1/
+s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
diff --git a/tests/torture.at b/tests/torture.at
index df73081..cea6325 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -729,6 +729,9 @@ AT_CLEANUP
# So we'll just test a 2000-byte value, and for awk, we test a line with
# almost 1000 words, and one variable with 5 lines of 2000 bytes each:
# multi-line values should allow to get around the limitations.
+# We also test runs of around 148 backslashes: they need to be escaped,
+# and 148 is the portable limit for awk string literals. config.status
+# uses concatenation to generate longer strings.
AT_SETUP([Substitute a 2000-byte string])
@@ -738,6 +741,13 @@ AT_DATA([Bar.in], address@hidden@
])
AT_DATA([Baz.in], address@hidden@
])
+AT_DATA([Boo.in], address@hidden@
address@hidden@
address@hidden@
address@hidden@
address@hidden@
address@hidden@
+])
AT_DATA([configure.ac],
[[AC_INIT
@@ -747,13 +757,38 @@ baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
"
baz=$baz$baz$baz$baz$baz
AC_SUBST([baz])
+b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+b147=$b29$b29$b29$b29$b29'\\'
+b148=$b147'\'
+b149=$b148'\'
+b295=$b147$b147'\'
+b296=$b295'\'
+b297=$b296'\'
+AC_SUBST([b147])
+AC_SUBST([b148])
+AC_SUBST([b149])
+AC_SUBST([b295])
+AC_SUBST([b296])
+AC_SUBST([b297])
AC_PROG_AWK
-AC_CONFIG_FILES([Foo Bar Baz])
+AC_CONFIG_FILES([Foo Bar Baz Boo])
AC_OUTPUT
]])
cp "$abs_top_srcdir/build-aux/install-sh" .
+b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+b147=$b29$b29$b29$b29$b29'\\'
+b295=$b147$b147'\'
+cat >Boo-exp <<EOF
+$b147
+$b147\\
+$b147\\\\
+$b295
+$b295\\
+$b295\\\\
+EOF
+
AT_CHECK_AUTOCONF
# Check both awk and the result of AC_PROG_AWK
for awk_arg in Foo= AWK=awk; do
@@ -766,6 +801,7 @@ for awk_arg in Foo= AWK=awk; do
[m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
)])
AT_CHECK([cat Baz], 0, [stdout])
+ AT_CHECK([diff Boo-exp Boo])
done
AT_CLEANUP
- Micro optimzation of config.status substitution.,
Ralf Wildenhues <=