From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 17 Mar 2009 02:31:42 +0100 From: Martin Neubauer To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20090317013142.GA990@shodan.homeunix.net> References: <5d375e920903161626o78226952j8a6088c1373cfbe3@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d375e920903161626o78226952j8a6088c1373cfbe3@mail.gmail.com> User-Agent: Mutt/1.4.2.3i Subject: Re: [9fans] Strange rc bug for the 9fans bug-squashing squad Topicbox-Message-UUID: bca9231c-ead4-11e9-9d60-3106f5b1d025 Hi, I think the following gives a clue: % cmp f f2 f f2 differ: char 8193 The following snippet from the Xbackq code seems to be the culprit: char wd[8193]; int c; char *s, *ewd=&wd[8192], *stop; ... while((c = rchr(f))!=EOF){ if(strchr(stop, c) || s==ewd){ if(s!=wd){ *s='\0'; v = newword(wd, v); s = wd; } } else *s++=c; } Keeping the loop from dropping characters is trivial. Getting rid of the inserted space probably requires a dynamic buffer. I might give it a shot. Regards, Martin * Uriel (uriel99@gmail.com) wrote: > At first I thought very big rc variables seem to become strangely corrupted. > > % for(i in `{seq 1000}) { echo 0123456789 >> f } > % ifs='' {x=`{cat f}} > % echo -n $x > f2 > % diff f f2 > 745c745 > < 0123456789 > --- > > 01234567 9 > > But the bug seems to be in `{ } because replacing the use of the x var > with simply: > > % ifs='' { echo -n `{cat f} > f2} > > Produces the same results. > > Longer strings get more random(?) characters 'blanked'. > > The results are identical in p9p and native plan9. > > I looked a bit around the rc source that seemed relevant, but didn't > see any obvious errors, but I don't fully understand the code. > > Peace > > uriel