[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line length limitations
From: |
libtool |
Subject: |
Re: Line length limitations |
Date: |
Thu, 7 Jun 2001 02:16:52 -0500 |
User-agent: |
Mutt/1.1.12i |
On Wed, Jun 06, 2001 at 07:47:43PM -0700, Bruce Korb wrote:
> address@hidden wrote:
> >
> > 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.
>
> I suggest doing a binary search by doubling the line size
> each iteration. You are correct. You are spending too much
> time inside of the loop. :-) Use this in the loop:
>
> cat /tmp/$$-sed-in /tmp/$$-sed-in > /tmp/$$-sed-tmp
> mv -f /tmp/$$-sed-tmp /tmp/$$-sed-in
Now it's really quick. I'm worried that doubling is too fast but I
think we should be OK.
--
albert chin (address@hidden)
-- snip snip
#!/bin/sh
trap "rm -f /tmp/$$-sed-out /tmp/$$-sed-in /tmp/$$-sed-in-nl \
/tmp/$$" 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
_count=0
for _sed in /bin/sed /usr/xpg4/bin/sed; do
test ! -f ${_sed} && break
cp /dev/null /tmp/$$-sed-in
_count=0
echo $ac_n "0123456789$ac_c" >/tmp/$$-sed-in
while /bin/true; do
echo "sed: $_sed, _count: $_count"
cat /tmp/$$-sed-in /tmp/$$-sed-in >/tmp/$$
mv /tmp/$$ /tmp/$$-sed-in
cp /tmp/$$-sed-in /tmp/$$-sed-in-nl
echo >>/tmp/$$-sed-in-nl
${_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 10 && break
_count=`expr $_count + 1`
if test $_count -gt $_max; then
_max=$_count
_best_sed=$_sed
fi
done
done
echo $_best_sed