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:26:28 +0200

Ralf Wildenhues <address@hidden> wrote:

> * Jim Meyering wrote on Sat, Apr 05, 2008 at 03:08:24PM CEST:
>> Ralf Wildenhues <address@hidden> wrote:
>> >>
>> >> 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 ;-)
>
> It's very portable.  Really.

(curious, not argumentative) How do you know?

>> Since there seem to be no other uses of that idiom
>> in autoconf, I'm leery about introducing the first.
>
> We use
>   for var in $list; do
>     $cmds
>   done | $cmd
>
> a lot in autotools, and it's just the same thing.

It's the same concept, sure.  But not the same syntax, and guaranteed
not to be the same parser rule in every bourne shell's grammar.

That said, I'm happy to go either way.
I'm confident your syntax will work with all systems I care about.

For reference, here is a sequence of two patches, mine, then, on top
of that, Ralf's:

>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


>From dfbcf3aaa01e0b1681067d877d79440a17545274 Mon Sep 17 00:00:00 2001
From: Ralf Wildenheus <address@hidden>
Date: Sat, 5 Apr 2008 15:21:53 +0200
Subject: [PATCH] (_AC_OUTPUT_FILES_PREPARE): Emit minimal shell code.

---
 lib/autoconf/status.m4 |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 59eedcc..bf00aaa 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -550,13 +550,12 @@ 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
-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])
+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" ||
+  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]