autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non portable sed scripts


From: Paul Eggert
Subject: Re: non portable sed scripts
Date: Tue, 23 May 2006 16:32:18 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> the 2.59 shell selection algorithm would probably(?) have selected
> /bin/sh as shell, whereas, due to changes we did because of OSF,
> /usr/bin/posix/sh is preferred now.

Ouch.  Good catch.

> I hope we get away with this.

I don't think we will, since the bug occurs every 1024 bytes, and many
define.sed scripts are longer than that.

I installed this patch, which works around this particular problem by
not using shell expansion at all in the here-documents used to create
defines.sed.  However, other instances of this problem lurk in
AC_LANG_SOURCE(C), _AC_INIT_HELP, _AC_DEFINE_Q, AC_LANG_CONFTEST,
_AC_OUTPUT_FILES_PREPARE, _AC_OUTPUT_FILE, and
_AC_OUTPUT_CONFIG_STATUS, with the last 3 being the most worrisome.

Perhaps Tim could check whether this patch fixes his problem?
If not, other patches are probably also needed.

I just now noticed that this patch removes the undocumented
ac_word_regexp var.  That was a fairly recent addition, though (June
2005), and I couldn't find evidence in Google of other packages using
it.

2006-05-23  Paul Eggert  <address@hidden>

        * lib/autoconf/status.m4 (_AC_OUTPUT_HEADER): Don't use shell
        expansion in the here-documents used by config.status, as that
        runs afoul of the Korn shell version M-12/28/93d bug described in
        the Autoconf manual, and this in turn causes a Coreutils 5.95 build to
        fail as described by Tim Rice and diagnosed by Ralf Wildenhues in
        <http://lists.gnu.org/archive/html/bug-autoconf/2006-05/msg00082.html>.

--- lib/autoconf/status.m4      23 May 2006 08:27:32 -0000      1.106
+++ lib/autoconf/status.m4      23 May 2006 23:30:57 -0000      1.108
@@ -601,27 +601,6 @@ m4_define([_AC_OUTPUT_HEADER],
   #
   # CONFIG_HEADER
   #
-
-  # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
-  # NAME is the cpp macro being defined, VALUE is the value it is being given.
-  # PARAMS is the parameter list in the macro definition--in most cases, it's
-  # just an empty string.
-  #
-dnl Quote, for the `[ ]' and `define'.
-[  ac_dA='s,^\([        #]*\)[^         ]*\([   ]*'
-  ac_dB='\)[    (].*,\1define\2'
-  ac_dC=' '
-  ac_dD=' ,']
-dnl ac_dD used to contain `;t' at the end, but that was both slow and 
incorrect.
-dnl 1) Since the script must be broken into chunks containing 100 commands,
-dnl the extra command meant extra calls to sed.
-dnl 2) The code was incorrect: in the unusual case where a symbol has multiple
-dnl different AC_DEFINEs, the last one should be honored.
-dnl
-dnl ac_dB works because every line has a space appended.  ac_dD reinserts
-dnl the space, because some symbol may have been AC_DEFINEd several times.
-
-  [ac_word_regexp=[_$as_cr_Letters][_$as_cr_alnum]*]
 _ACEOF
 
 # Transform confdefs.h into a sed script `conftest.defines', that
@@ -637,6 +616,26 @@ echo 's/$/ /' >conftest.defines
 dnl
 dnl Quote, for `[ ]' and `define'.
 [ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([  #]*\\)[^        ]*\\([  ]*'
+ac_dB='\\)[     (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,']
+dnl ac_dD used to contain `;t' at the end, but that was both slow and 
incorrect.
+dnl 1) Since the script must be broken into chunks containing 100 commands,
+dnl the extra command meant extra calls to sed.
+dnl 2) The code was incorrect: in the unusual case where a symbol has multiple
+dnl different AC_DEFINEs, the last one should be honored.
+dnl
+dnl ac_dB works because every line has a space appended.  ac_dD reinserts
+dnl the space, because some symbol may have been AC_DEFINEd several times.
+dnl
+dnl The first use of ac_dA has a space prepended, so that the second
+dnl use does not match the initial 's' of $ac_dA.
+[
 uniq confdefs.h |
   sed -n '
        t rset
@@ -646,9 +645,8 @@ uniq confdefs.h |
        d
        :ok
        s/[\\&,]/\\&/g
-       s/[\\$`]/\\&/g
-       s/^\('"$ac_word_re"'\)\(([^()]*)\)[      
]*\(.*\)/${ac_dA}\1$ac_dB\2${ac_dC}\3$ac_dD/p
-       s/^\('"$ac_word_re"'\)[  ]*\(.*\)/${ac_dA}\1$ac_dB${ac_dC}\2$ac_dD/p
+       s/^\('"$ac_word_re"'\)\(([^()]*)\)[      ]*\(.*\)/ 
'"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+       s/^\('"$ac_word_re"'\)[  
]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
   ' >>conftest.defines
 ]
 # Remove the space that was appended to ease matching.
@@ -682,12 +680,14 @@ while :
 do
   # Write a here document:
   dnl Quote, for the `[ ]' and `define'.
-  echo ['    # First, check the format of the line:
-    cat >"$tmp/defines.sed" <<CEOF
-/^[     ]*#[    ]*undef[        ][      ]*$ac_word_regexp[      ]*$/b def
-/^[     ]*#[    ]*define[       ][      ]*$ac_word_regexp[(     ]/b def
+[  cat >>$CONFIG_STATUS <<_ACEOF
+    # First, check the format of the line:
+    cat >"\$tmp/defines.sed" <<\\CEOF
+/^[     ]*#[    ]*undef[        ][      ]*$ac_word_re[  ]*\$/b def
+/^[     ]*#[    ]*define[       ][      ]*$ac_word_re[(         ]/b def
 b
-:def'] >>$CONFIG_STATUS
+:def
+_ACEOF]
   sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
   echo 'CEOF
     sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS




reply via email to

[Prev in Thread] Current Thread [Next in Thread]