libtool-patches
[Top][All Lists]
Advanced

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

HEAD: func_quote_for_expand and Solaris 2.6 /bin/sed


From: Ralf Wildenhues
Subject: HEAD: func_quote_for_expand and Solaris 2.6 /bin/sed
Date: Thu, 8 Feb 2007 22:32:46 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On HEAD, quote.test currently fails on Solaris 2.6, because the
sed_double_backslash script is not portable its /bin/sed, which
is not POSIX conforming.  This script in general.m4sh is the culprit:

| # Re-`\' parameter expansions in output of double_quote_subst that were
| # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
| # in input to double_quote_subst, that '$' was protected from expansion.
| # Since each input `\' is now two `\'s, look for any number of runs of
| # four `\'s followed by two `\'s and then a '$'.  `\' that '$'.  Note
| # that the embedded single quotes serve only to enhance readability.
| sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/;
|                 s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/g'

(note the doubled [[]] due to M4 quoting).

With respect to the limitations listed in
<http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Usual-Tools.html#index-g_t_0040command_007bsed_007d-1292>,
this runs afoul of both nested \(...\) and using * on more than one
character.  What's more, /bin/sed doesn't even understand \{m,n\}
correctly.  I'm a bit out of ideas how to fix this easily, while
maintaining full generality at the same time.

We could ask Autoconf to prop up AC_PROG_SED to test for all these
issues -- /usr/ucb/sed and /usr/xpg4/bin/sed do not have them -- but
the other sed's have other issues for which we may not like them,
such as a small input/command/line length limit.  But we want both.
(Actually, eventually we want to throw func_quote_for_eval away and
redo, as it's a hack.  But not now: fixing this regression only now.)

So I propose this hack that should cover the interesting cases up
to 10 backslashes in the input; so should that already consist of
doubled backslashes, we are still ok up to 5 of them.

Any problems with this?

Cheers,
Ralf

2007-02-08  Ralf Wildenhues  <address@hidden>

        * libltdl/config/general.m4sh (sed_double_backslash): Replace
        POSIX sed script with a hack that treats up to 10 backslashes
        in the input correctly and is portable to Solaris /bin/sed.

cvs diff: Diffing libltdl/config
Index: libltdl/config/general.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.4
diff -u -r1.4 general.m4sh
--- libltdl/config/general.m4sh 18 May 2006 05:43:00 -0000      1.4
+++ libltdl/config/general.m4sh 8 Feb 2007 21:19:25 -0000
@@ -1,7 +1,7 @@
 m4_if([# general.m4sh -- general shell script boiler plate -*- Autoconf -*-
 # Written by Gary V. Vaughan <address@hidden>, 2004
 
-# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -100,10 +100,29 @@
 # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
 # in input to double_quote_subst, that '$' was protected from expansion.
 # Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.  Note
-# that the embedded single quotes serve only to enhance readability.
-sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/;
-                s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/g'
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'. 
+#
+# Note in the first, non-portable but general version, the embedded single
+# quotes serve only to enhance readability.
+#sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/;
+#                s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/g'
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/^$bs2$dollar/$bs&/
+  s/^$bs4$bs2$dollar/$bs&/
+  s/^$bs4$bs4$bs2$dollar/$bs&/
+  s/^$bs4$bs4$bs4$bs2$dollar/$bs&/
+  s/^$bs4$bs4$bs4$bs4$bs2$dollar/$bs&/
+  s/^$bs4$bs4$bs4$bs4$bs4$bs2$dollar/$bs&/
+  s/\\([[^$bs]]\\)\\($bs2$dollar\\)/\\1$bs\\2/g
+  s/\\([[^$bs]]\\)\\($bs4$bs2$dollar\\)/\\1$bs\\2/g
+  s/\\([[^$bs]]\\)\\($bs4$bs4$bs2$dollar\\)/\\1$bs\\2/g
+  s/\\([[^$bs]]\\)\\($bs4$bs4$bs4$bs2$dollar\\)/\\1$bs\\2/g
+  s/\\([[^$bs]]\\)\\($bs4$bs4$bs4$bs4$bs2$dollar\\)/\\1$bs\\2/g
+  s/\\([[^$bs]]\\)\\($bs4$bs4$bs4$bs4$bs4$bs2$dollar\\)/\\1$bs\\2/g"
 
 # Standard options:
 opt_dry_run=false




reply via email to

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