libtool
[Top][All Lists]
Advanced

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

Re: Line length limitations


From: libtool
Subject: Re: Line length limitations
Date: Wed, 6 Jun 2001 14:03:40 -0500
User-agent: Mutt/1.1.12i

On Wed, Jun 06, 2001 at 01:10:14AM -0300, Alexandre Oliva wrote:
> On Jun  5, 2001, Robert Boehne <address@hidden> wrote:
> 
> > So I'm sure how to check the limits under SGI without
> > the 'wc' command.
> 
> Use cmp.

Ok, I wrote a short test script to do what I want. I have made the
decision not to tie the limit of sed to the command-line length limit
by having sed take its input from a file rather than a pipe (echo |
sed). So, I currently append 30 characters at a time to a file and
have sed strip off the last character. I then cmp this against what
the correct output should be. The problem with this is that I
currently use 3 files and it's slow (too many forks):
  1. /tmp/sed-in (non-newline terminated)
  2. /tmp/sed-in-nl (newline terminated) because sed wants a NL. We
     cmp this against /tmp/sed-out.
  3. /tmp/sed-out (output sed gave us)

My test script is appended below. If this is the correct course of
action, I'll work up a patch.

-- 
albert chin (address@hidden)

-- snip snip
#!/bin/sh

trap "rm -f /tmp/$$-sed-in /tmp/$$-sed-in-nl /tmp/$$-sed-out" 0 2 13

if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  # Stardent Vistra SVR4 grep lacks -e, says address@hidden
  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn
/dev/null; then
    ac_n= ac_c='
' ac_t='        '
  else
    ac_n=-n ac_c= ac_t=
  fi
else
  ac_n= ac_c='\c' ac_t=
fi

_max=0
for _sed in /bin/sed /usr/xpg4/bin/sed; do
  test ! -f ${_sed} && break

  cp /dev/null /tmp/$$-sed-in

  _count=0
  while /bin/true; do
    echo "sed: $_sed, _count: $_count"

    echo $ac_n "012345678901234567890123456789$ac_c" >>/tmp/$$-sed-in
    cp /tmp/$$-sed-in /tmp/$$-sed-in-nl
    echo >>/tmp/$$-sed-in-nl

    # There is no 'a' in sed-in but sed has to do something
    ${_sed} -e 's/^a//' < /tmp/$$-sed-in-nl >/tmp/$$-sed-out
    test $? -ne 0 && break
    cmp -s /tmp/$$-sed-out /tmp/$$-sed-in-nl
    test $? -ne 0 && break

    # 10000 chars as input seems more than enough
    test $_count -gt 333 && break

    _count=`expr $_count + 1`
    if test $_count -gt $_max; then
      _max=$_count
      _best_sed=$_sed
    fi
  done
done

echo $_best_sed



reply via email to

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