autoconf-patches
[Top][All Lists]
Advanced

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

HP-UX and OSF sed limitations


From: Ralf Wildenhues
Subject: HP-UX and OSF sed limitations
Date: Fri, 3 Mar 2006 21:11:33 +0100
User-agent: Mutt/1.5.9i

(1)
The Tru64 UNIX 4.0D sed(1) manpage claims
|   [Digital]  The sed command can process up to 99 commands in a file.

The /bin/sed on this alphaev5-dec-osf4.0d supports 999 commands and 48
labels, though.  Empty lines do not count as commands, neither does a
closing brace `}' nor a comment, nor (obviously?) a label; IOW all
strictly "zero-address commands" (in GNU sed lingo).

Per cycle, up to 19 `r' commands may be executed (i.e., there can be
more `r' commands but only 19 reads may actually happen per cycle).

Multiple scripts (passed with -f) can not be used to circumvent either
of these limits.

Same thing on alphaev67-dec-osf5.1.  I do not have access to nor know of
an OSF/Digital system that exposes the 99 commands limit stated in the
manpage.


(2)
Now to HP-UX sed.  Old Autoconf lore and the manual pages claim it to
have a limit of 100 commands.  This is not true.  My testing on both
HP-UX 10.20 and 11.23 indicates that it supports 99 commands and
otherwise shares all characteristics stated above for OSF1 sed.


(3)
There is currently a failure in the config.status code: the config-files
part may put 100 sed commands in one file.  Exposed by the `Torturing
config.status' test.  The config-headers code was OK since it calculated
a label as command and used one label per file.  ;-)

(4)
We may optimize a bit knowing that we don't need to count `}' and `:'.
The patch below is sharp in size for config headers, but probably not
sharp for config files; I did not have the heart to debug the
complicated part again, so I went for rather safe changes only; in any
case it should be very close to optimal.

(5)
We output
  /blabla/{ r [...]
but this not portable.  Fixed below.

(6)
The `Torturing config.status' test was broken in that it did not check
the output of the AC_CONFIG_FILES substitution.  Fixed below.  While at
it, I also put 100 AC_SUBST_FILE in the test for good measure.


Are there any other sed implementations known which have lower limits?
Does anybody have access to aforementioned Digital UNIX which exposes
the 99 command limit?  The sed FAQ[1] did not list any further
restrictions applicable to config.status code.

OK to apply this patch?

Cheers,
Ralf

[1] http://sed.sf.net/sedfaq.html

        * lib/autoconf/status.m4 (_AC_SED_CMD_LIMIT): The limit for
        HP-UX sed is 99 commands, not 100.
        (_AC_OUTPUT_FILES_PREPARE): Do not count the `}' of an
        _AC_SUBST_FILES fragment.  Separate `{' and `r' commands by
        newline for portability.
        * tests/torture.at (Torturing config.status): Also test 100
        AC_SUBST_FILE invocations.  Fix test to actually verify the
        AC_CONFIG_FILES output.
        * doc/autoconf.texi (Limitations of Usual Tools): Document HP-UX
        command, label, and read-file `r' limits.  Unify HP-UX spelling.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.954
diff -u -r1.954 autoconf.texi
--- doc/autoconf.texi   22 Feb 2006 20:18:23 -0000      1.954
+++ doc/autoconf.texi   2 Mar 2006 20:07:38 -0000
@@ -11818,7 +12224,7 @@
 foo
 @end example
 
-Some Awk implementations, such as HPUX 11.0's native one, mishandle anchors:
+Some Awk implementations, such as HP-UX 11.0's native one, mishandle anchors:
 
 @example
 $ @kbd{echo xfoo | $AWK '/foo|^bar/ @{ print @}'}
@@ -12475,7 +12881,9 @@
 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.
+should not contain comments.  HP-UX sed has a limit of 99 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 `r' command per cycle.
 
 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/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.85
diff -u -r1.85 status.m4
--- lib/autoconf/status.m4      1 Mar 2006 19:54:34 -0000       1.85
+++ lib/autoconf/status.m4      3 Mar 2006 20:09:32 -0000
@@ -303,8 +303,8 @@
 #
 # Some seds have small command number limits, like on Digital OSF/1 and HP-UX.
 m4_define([_AC_SED_CMD_LIMIT],
-dnl One cannot portably go further than 100 commands because of HP-UX.
-[100])
+dnl One cannot portably go further than 99 commands because of HP-UX.
+[99])
 
 
 # _AC_OUTPUT_FILES_PREPARE
@@ -343,7 +343,7 @@
 
 m4_foreach_w([_AC_Var], m4_defn([_AC_SUBST_FILES]),
 [dnl End fragments at beginning of loop so that last fragment is not ended.
-m4_if(m4_eval(_AC_SED_CMD_NUM + 4 > _AC_SED_CMD_LIMIT), 1,
+m4_if(m4_eval(_AC_SED_CMD_NUM + 3 > _AC_SED_CMD_LIMIT), 1,
 [dnl Fragment is full and not the last one, so no need for the final un-escape.
 dnl Increment fragment number.
 m4_define([_AC_SED_FRAG_NUM], m4_incr(_AC_SED_FRAG_NUM))dnl
@@ -359,10 +359,11 @@
 _ACEOF
 ]m4_define([_AC_SED_CMD_NUM], 2)m4_define([_AC_SED_FRAG])dnl
 ])dnl Last fragment ended.
-m4_define([_AC_SED_CMD_NUM], m4_eval(_AC_SED_CMD_NUM + 4))dnl
+m4_define([_AC_SED_CMD_NUM], m4_eval(_AC_SED_CMD_NUM + 3))dnl
 m4_define([_AC_SED_FRAG],
 m4_defn([_AC_SED_FRAG])dnl
-[/^[   address@hidden@[        ]*$/{ r $]_AC_Var[
+[/^[   address@hidden@[        ]*$/{
+r $]_AC_Var[
 d
 }
 ])dnl
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.54
diff -u -r1.54 torture.at
--- tests/torture.at    25 Jul 2005 18:10:25 -0000      1.54
+++ tests/torture.at    3 Mar 2006 20:08:47 -0000
@@ -363,9 +363,9 @@
 ## Torturing config.status.  ##
 ## ------------------------- ##
 
-## Require 100 AC_DEFINE and AC_SUBST with a significantly big value.
-## This is mostly to check that Autoconf produces portable sed scripts
-## in config.status.  sed is used to skip the first two lines
+## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
+## big value.  This is mostly to check that Autoconf produces portable sed
+## scripts in config.status.  sed is used to skip the first two lines
 ## `Generated by...'.
 
 # We use m4_for many times.
@@ -402,9 +402,17 @@
 AT_DATA([dummy.in],
 [m4_for([AT_Count], 1, 100, 1,
 address@hidden(AT_Count)@
address@hidden@
 ])])
 
 
+i=1
+while test $i != 101; do
+  echo "content of file $i" > file_$i
+  i=`expr $i + 1`
+done
+
+
 # ------------ #
 # configure.ac #
 # ------------ #
@@ -430,7 +438,10 @@
 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
                   AC_DESCRIPTION)
-AC_SUBST(AC_DUMMY_VAR($1))])
+AC_SUBST(AC_DUMMY_VAR($1))
+AC_SUBST_FILE([f]$1)
+f$1=file_$1
+])
 
 AC_INIT
 AC_CONFIG_HEADERS(config.h:config.hin)
@@ -471,8 +482,11 @@
 AT_DATA([expout],
 [m4_for(AT_Count, 1, 100, 1,
 [AT_BIG_VALUE
+content of file AT_Count
 ])])
 
+AT_CHECK([cat dummy], 0, expout)
+
 AT_CLEANUP
 
 




reply via email to

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