From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <22e43e02e32dd37beb7f8c52105e45b6@quintile.net> From: "Steve Simon" Date: Wed, 19 Sep 2012 09:48:51 +0100 To: 9fans@9fans.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] Brdline() and continuation lines Topicbox-Message-UUID: ba41295a-ead7-11e9-9d60-3106f5b1d025 Hi, Anyone worked out an idiom that would allow me to use Brdline()/Blinelen() to read a file which contains continuation lines? I want to read a text file which consists of lines terminated by newlines, but lines with leading whitespace are considered to be continuation lines. Brdline() is very neat allowing me to parse input lines inside the Biobuf buffer without copying them to "user space", however if I do a Brdline(), get a line and then attempt to do another Brdline() I am in danger of releaseing the buffer space used by the first read. I am happy if the answer is "Brdline() cannot do this", I just feel like I am missing a trick, and there is elegant solution. -Steve From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 19 Sep 2012 09:35:51 -0400 To: 9fans@9fans.net Message-ID: <18674d790afd2a7602091b8d8e704712@brasstown.quanstro.net> In-Reply-To: <22e43e02e32dd37beb7f8c52105e45b6@quintile.net> References: <22e43e02e32dd37beb7f8c52105e45b6@quintile.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Brdline() and continuation lines Topicbox-Message-UUID: ba4e5ada-ead7-11e9-9d60-3106f5b1d025 > Anyone worked out an idiom that would allow me to > use Brdline()/Blinelen() to read a file which > contains continuation lines? > > I want to read a text file which consists of lines terminated > by newlines, but lines with leading whitespace are considered > to be continuation lines. > > Brdline() is very neat allowing me to parse input lines inside the > Biobuf buffer without copying them to "user space", however if I > do a Brdline(), get a line and then attempt to do another Brdline() > I am in danger of releaseing the buffer space used by the first read. > > I am happy if the answer is "Brdline() cannot do this", I just feel like > I am missing a trick, and there is elegant solution. /* * Bgetrune seems like overkill, but avoids passing up bad runes. */ int Brdlinec(Biobuf *b, char *s, char *e) { char *p; int x, slash; Rune r; for(p = s; e-p > UTFmax+1;){ x = Bgetrune(b); if(x == -1) return -1; r = x; if(r == '\\'){ x = Bgetrune(b); if(x == -1) return -1; if(x == '\n') continue; p += runetochar(p, &r); r = x; }else if(r == '\n') break; p += runetochar(p, r); } *p = 0; return p-e; } From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <22e43e02e32dd37beb7f8c52105e45b6@quintile.net> References: <22e43e02e32dd37beb7f8c52105e45b6@quintile.net> Date: Wed, 19 Sep 2012 14:49:25 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=047d7b603c125fb57d04ca0e46dc Subject: Re: [9fans] Brdline() and continuation lines Topicbox-Message-UUID: ba573a92-ead7-11e9-9d60-3106f5b1d025 --047d7b603c125fb57d04ca0e46dc Content-Type: text/plain; charset=UTF-8 I don't see how it can do it. On 19 September 2012 09:48, Steve Simon wrote: > I am happy if the answer is "Brdline() cannot do this", I just feel like > I am missing a trick, and there is elegant solution. > --047d7b603c125fb57d04ca0e46dc Content-Type: text/html; charset=UTF-8 I don't see how it can do it.

On 19 September 2012 09:48, Steve Simon <steve@quintile.net> wrote:
I am happy if the answer is "Brdline() cannot do this", I just feel like
I am missing a trick, and there is elegant solution.

--047d7b603c125fb57d04ca0e46dc--