[Top][All Lists]

[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: Sun, 21 May 2006 00:46:32 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> So then the total limit of the script size I found on Solaris (described
> in that other mail in this thread that was pending for some hours)
> really is a new issue.

If it's just Solaris, we should be able to work around it by using
AC_PROG_SED, as it should check for that bug (it currently doesn't,
but it should).

> All my testing of seds a couple of months ago showed that labels do not
> count as commands.

Sorry, I didn't know that.  I guess we can undo my patch then,
but add a comment.

Here's a first cut to do this.  I haven't tested it and I assume
it's not the full job, but it should give you an idea.

Index: doc/autoconf.texi
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1018
diff -p -u -r1.1018 autoconf.texi
--- doc/autoconf.texi   20 May 2006 05:39:03 -0000      1.1018
+++ doc/autoconf.texi   21 May 2006 07:45:40 -0000
@@ -3632,9 +3632,8 @@ is found, and otherwise to @samp{:} (do 
 @defmac AC_PROG_SED
 @ovindex SED
-Set output variable @code{SED} to a Sed implementation on @env{PATH} that
-truncates as few characters as possible.  If @sc{gnu} Sed is found,
-use that instead.
+Set output variable @code{SED} to a Sed implementation on
address@hidden that conforms to Posix without arbitrary length limits.
 @end defmac
 @defmac AC_PROG_YACC
@@ -13207,9 +13206,12 @@ them.
 Unicos 9 @command{sed} loops endlessly on patterns like @samp{.*\n.*}.
 Sed scripts should not use branch labels longer than 8 characters and
-should not contain comments.  HP-UX sed has a limit of 99 commands and
+should not contain comments.  HP-UX sed has a limit of 99 commands
+(not counting @samp{:} commands) and
 48 labels, which can not be circumvented by using more than one script
 file.  It can execute up to 19 reads with the @samp{r} command per cycle.
+Solaris @command{/usr/ucb/sed} does not allow scripts longer than 6810
+bytes, and its @command{/usr/xpg4/bin/sed} dumps core with long scripts.
 Avoid redundant @samp{;}, as some @command{sed} implementations, such as
 address@hidden 1.4.2's, incorrectly try to interpret the second
Index: lib/autoconf/programs.m4
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.54
diff -p -u -r1.54 programs.m4
--- lib/autoconf/programs.m4    19 May 2006 08:11:27 -0000      1.54
+++ lib/autoconf/programs.m4    21 May 2006 07:45:40 -0000
@@ -812,9 +812,15 @@ adjust the code.])
 # as few characters as possible.  Prefer GNU sed if found.
 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
-    [_AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
+    [dnl ac_script should contain more than 99 commands and more than
+     dnl 6810 bytes, to catch limits in Solaris 8 /usr/ucb/sed.
+     ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
        [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
-               ["$ac_path_SED" -e 's/a$//'])])])
+               ["$ac_path_SED" -e "$ac_script"])])])
Index: lib/autoconf/status.m4
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.103
diff -p -u -r1.103 status.m4
--- lib/autoconf/status.m4      19 May 2006 21:02:10 -0000      1.103
+++ lib/autoconf/status.m4      21 May 2006 07:45:40 -0000
@@ -303,7 +303,7 @@ AC_DEFUN([AC_CONFIG_FILES], [_AC_CONFIG_
 # -----------------
 # Evaluate to an m4 number equal to the maximum number of commands to put
-# in any single sed program.
+# in any single sed program, not counting ":" commands.
 # Some seds have small command number limits, like on Digital OSF/1 and HP-UX.
@@ -660,7 +660,7 @@ echo 's/ $//
 [s,^[   #]*u.*,/* & */,]' >>conftest.defines
 # Break up conftest.defines:
-ac_max_sed_lines=m4_eval(_AC_SED_CMD_LIMIT - 4)
+ac_max_sed_lines=m4_eval(_AC_SED_CMD_LIMIT - 3)
 # First sed command is:         sed -f defines.sed $ac_file_inputs >"$tmp/out1"
 # Second one is:        sed -f defines.sed "$tmp/out1" >"$tmp/out2"

reply via email to

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