autoconf-patches
[Top][All Lists]
Advanced

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

Re: carriage return line endings vs. literal ^M in status.m4


From: Jim Meyering
Subject: Re: carriage return line endings vs. literal ^M in status.m4
Date: Sat, 05 Apr 2008 15:08:24 +0200

Ralf Wildenhues <address@hidden> wrote:
> * Jim Meyering wrote on Sat, Apr 05, 2008 at 02:54:37PM CEST:
>> Ralf Wildenhues <address@hidden> wrote:
>> >
>> > How about this slightly simpler patch instead?  If you don't like it,
>> > then I think your patch is a definite improvement, and is OK by me.
>>
>> I prefer yours and almost went that way myself, but wonder if it's
>> portable enough.  I don't see any other uses of 'if...fi <', in autoconf.
>
> Yes, that's pretty portable.  IIRC it may create a subshell, but that
> doesn't matter here.

"pretty portable" may not be enough for autoconf ;-)
Since there seem to be no other uses of that idiom
in autoconf, I'm leery about introducing the first.
Of course, if it's known to be sufficiently portable,
I prefer your more compact patch.  Here's mine again,
with more comments:

>From ace9e3f93c64c7649eb6c76d248d4316e4ba9215 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 5 Apr 2008 11:27:06 +0200
Subject: [PATCH] Work around CR EOL markers on OS/2 (www.ecomstation.com Ecs v2 
rc4)

* lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): When CR
is the EOL marker, skip a step that would remove and translate
carriage return bytes.  Reported by Elbert Pol.

Signed-off-by: Jim Meyering <address@hidden>
---
 ChangeLog              |    8 ++++++++
 lib/autoconf/status.m4 |   19 +++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df454bc..6703cc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-04-05  Jim Meyering  <address@hidden>
+
+       Do not use a literal carriage return (it may be the EOL marker).
+       * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Rather than
+       a literal ^M, derive the byte using echo and tr.
+       Using the literal would not work on a system using carriage
+       return as end-of-line marker.
+
 2008-04-03  Eric Blake  <address@hidden>

        Fix version number generation in man pages.
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index b4dec08..59eedcc 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -539,9 +539,24 @@ m4_ifdef([_AC_SUBST_FILES],
 [\$ac_cs_awk_pipe_fini])
 _ACAWK
 _ACEOF
+dnl See if CR is the EOL marker.  If not, remove any EOL-related
+dnl ^M bytes and escape any remaining ones.  If so, just use mv.
+dnl In case you're wondering how ^M bytes can make it into subs1.awk,
+dnl [from Ralf Wildenhues] one way is if you have e.g.,
+dnl AC_SUBST([variable_that_contains_cr], ["
+dnl "])
+dnl The original aim was that users should be able to substitute any
+dnl characters they like (except for \0).  And the above is not so
+dnl unlikely if the configure script itself happens to be converted
+dnl to w32 text mode.
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" < "$tmp/subs1.awk" > 
"$tmp/subs.awk" \
-  || AC_MSG_ERROR([could not setup config files machinery])
+ac_awk_err=0
+sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1 \
+  && { sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" \
+        < "$tmp/subs1.awk" > "$tmp/subs.awk" || ac_awk_err=1; } \
+  || { mv "$tmp/subs1.awk"   "$tmp/subs.awk" || ac_awk_err=1; }
+test $ac_awk_err = 1 \
+  && AC_MSG_ERROR([could not setup config files machinery])
 _ACEOF

 # VPATH may cause trouble with some makes, so we remove $(srcdir),
--
1.5.5.rc3.1.gaece




reply via email to

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