From 31d0e60498b82939d84b0ad223c5c765e587260f Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Thu, 6 Apr 2006 18:16:56 +0000 Subject: [PATCH] * lib/autoconf/general.m4 (_AC_CACHE_DUMP): Fix the detection of whether `set' quotes correctly: redirect stderr of the tested `set', and use a subshell, for Ultrix; use `sed' instead of `grep' for zsh `set' which may write binary output; match only at the beginning of a line, to avoid false positives. In order to avoid false positives by unrelated variables with multiline content, put the dump algorithm in a subshell and unset all variables containing newlines (except some which are special to the shell). Warn about cache variables that are unset. --- ChangeLog | 19 +++++++++++++++++++ lib/autoconf/general.m4 | 31 ++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d15b489f..d2e697cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ +2006-04-06 Stepan Kasal , + Eric Blake , + Paul Eggert , + Ralf Wildenhues + + * lib/autoconf/general.m4 (_AC_CACHE_DUMP): Fix the detection of + whether `set' quotes correctly: redirect stderr of the tested + `set', and use a subshell, for Ultrix; use `sed' instead of + `grep' for zsh `set' which may write binary output; match only + at the beginning of a line, to avoid false positives. + In order to avoid false positives by unrelated variables with + multiline content, put the dump algorithm in a subshell and + unset all variables containing newlines (except some which are + special to the shell). Warn about cache variables that are + unset. + 2006-04-06 Ralf Wildenhues + * config/config.guess, config/config.sub, config/texinfo.tex: + Sync from upstream. + * tests/mktests.sh: Reword comments. * tests/mktests.sh: Only skip internal macros starting with diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index b44dd925..c88c3f57 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1821,26 +1821,39 @@ fi m4_define([_AC_CACHE_DUMP], [# The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n ['s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p']`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) AC_MSG_WARN([Cache variable $ac_var contains a newline.]) ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ ["s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"] - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - ["s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"] + sed -n ["/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"] ;; - esac; -}dnl + esac +)dnl ])# _AC_CACHE_DUMP