From 096220df5d30ed92e2280731f98fd8014d78c44d Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sun, 1 Nov 2009 01:04:31 +0100 Subject: [PATCH] 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. Signed-off-by: Ralf Wildenhues --- ChangeLog | 7 +++++++ lib/autoconf/status.m4 | 4 ++-- tests/torture.at | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39854166..2640226d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-10-31 Ralf Wildenhues + 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. + Fix testsuite failure on AIX 4.3.3. * lib/autoconf/general.m4 (_AC_RUN_LOG_LIMIT): Remove conftest.err also if it is empty. diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 84ee6c3d..e921d97f 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 8f220131..ea3acd49 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], [@bar@ ]) AT_DATA([Baz.in], [@baz@ ]) +AT_DATA([Boo.in], [@b147@ +@b148@ +@b149@ +@b295@ +@b296@ +@b297@ +]) 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 <