delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2010/01/16/08:15:17

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Rugxulo <rugxulo AT gmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: AutoConf "\\r" woes (again)
Date: Sat, 16 Jan 2010 04:51:26 -0800 (PST)
Organization: http://groups.google.com
Lines: 144
Message-ID: <ef035ce0-af55-48d8-9567-c6a991f92fad@j19g2000yqk.googlegroups.com>
NNTP-Posting-Host: 65.13.115.246
Mime-Version: 1.0
X-Trace: posting.google.com 1263646286 21290 127.0.0.1 (16 Jan 2010 12:51:26 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Sat, 16 Jan 2010 12:51:26 +0000 (UTC)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: j19g2000yqk.googlegroups.com; posting-host=65.13.115.246;
posting-account=p5rsXQoAAAB8KPnVlgg9E_vlm2dvVhfO
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US)
AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0,gzip(gfe),gzip(gfe)
Bytes: 5537
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

(quoting Ralf.Wildenhues_CXE_gmx_PUNKTO_de):

Hello Rugxulo, Andris,

I need your help for a bit of Autoconf testing for me; see below.

Background: Peter reported an Autoconf regression on OS X:
<http://lists.gnu.org/archive/html/bug-autoconf/2009-12/msg00022.html>

that came from this patch:
<http://lists.gnu.org/archive/html/bug-autoconf/2009-03/msg00047.html>
(bug also reported here:
<http://lists.gnu.org/archive/html/bug-autoconf/2009-07/
msg00013.html>)

I've looked at the issue now.  The patch we've applied is wrong.
Let's
fix it.

The logic is supposed to work this way:

1) This code tries to create a variable containing the carriage return
character:

ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
  eval ac_cr=\$\'\\r\'
fi

Back in Autoconf 2.63, this code was:

ac_cr='^M'

with a literal carriage return in it.

2) This code (and I've undone said patch above here) tries to find out
whether awk's print function expands the string literal "\r" to a
carriage return, or a literal carriage return is needed for that:

ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
  ac_cs_awk_cr='\\r'
else
  ac_cs_awk_cr=$ac_cr
fi

It sets the variable $ac_cs_awk_cr in such a way that, when used in
the
replacement part of a sed 's' command, it causes sed to insert a
literal
into the output that makes awk expand it to a carriage return.

This is where said patch went wrong: the logic never meant to use '\r'
which some sed's but not all expand to a literal carriage return; IOW,
we were relying on, and fooled by, undefined behavior in sed here.

3) This code is meant to cause config.status to replace literal
carriage
return characters in substituted variables into strings that awk will
expand to carriage returns in the config.files, while avoiding to
munge
end-of-line (EOL):

if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
  cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \

The idea was that, on systems where EOL is CR-LF, the sed "s/$ac_cr\
$//"
would still prevent us from matching any carriage returns at EOL.



You both reported that, on your DJGPP installations, this causes '\r'
strings to appear at the end of each line in the $tmp/subs.awk file.

I have a DJGPP installation now, but I cannot reproduce this failure
with Autoconf 2.65: for me, the first line of code in (1) expands to a
literal carriage return, DJGPP awk understands that, and the code in
(3)
is never invoked.

I'm not quite sure whether that is just due to the changes of the code
in (1), or whether there are other differences between our systems.

Can you please try the following: grap Autoconf 2.65 from ftp.gnu.org,
apply the patch below, build and install it on DJGPP, and see whether
it works on this example package?

cat >configure.ac <<\EOF
AC_INIT([foo], [1])
AC_CONFIG_FILES([foo])
AC_OUTPUT
EOF
cat >foo.in <<\EOF
@PACKAGE_STRING@
EOF
autoconf
./configure
cat foo

If that does not work, then we may need to change the code in (3) to
something like

if test -z "$DJDIR" && sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1;
then
  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
  cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \

Thanks,
Ralf

PS: I still need to test on w32 systems before re-enabling carriage
return in the "Substitute and define special characters" test.


    Fix substitution of carriage return on Darwin.

    * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Set
    ac_cs_awk_cr to '\\r', so that sed portably expands this to '\r'
    rather than a literal carriage return, to fix substitution on
    Darwin.  Regression introduced in 2.63b.
    Report by Peter O'Gorman.

diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index f74bd34..3c6cf38 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -364,7 +364,7 @@ if test "x$ac_cr" = x; then
 fi
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\r'
+  ac_cs_awk_cr='\\r'
 else
   ac_cs_awk_cr=$ac_cr
 fi

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019