9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <russcox@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Brdline
Date: Tue,  1 Feb 2005 20:06:36 -0500	[thread overview]
Message-ID: <ee9e417a050201170652f61fcd@mail.gmail.com> (raw)
In-Reply-To: <dd5dca40f6611c422e2dcefcf37a3564@ar.aichi-u.ac.jp>

try using Brdstr instead.



On Wed, 2 Feb 2005 09:37:14 +0900, arisawa@ar.aichi-u.ac.jp
<arisawa@ar.aichi-u.ac.jp> wrote:
> Hello,
>
> The following program falls into endless loop if we execute
>         echo -n alice | 8.out
> Try.
>
> #include <u.h>
> #include <libc.h>
> #include <bio.h>
>
> void
> main()
> {       Biobuf in;
>         char *p;
>         int lines;
>         Binit(&in, 0, OREAD);
>         lines = 0;
>         for(;;){
>                 p = Brdline(&in, '\n');
>                 if(p == nil){
>                         if(Blinelen(&in) == 0)
>                                 break;
>                 }else
>                         lines++;
>         }
>         print("lines=%d\n",lines);
> }
>
> I have been desired to have such a Brdline
> that can work even if we execute:
>         echo -n alice | 8.out
>
> Current Brdline requires delim as second argument,
> and the worse the delim is left untouched *mostly*
> at Blinelen -1
> We must replace it using Blinelen by '\0' if we want the
> returned value to be used as string.
> This makes program difficult if input data doesn't have delim.
>
> My imagination of new Brdline (or some other name) is:
>
> void
> main()
> {       Biobuf in;
>         char *p;
>         Binit(&in,0,OREAD);
>         while((p = Brdline(&in)))
>                 print("%s", p);
> }
>
> '\n' is automatically replaced by '\0',
> and '\0' is automatically appended at EOF.
> p is nil only at EOF.
> some function will be required to detect buffer full.
> if buffer full the next Brdline should return the
> pointer of the character that is replaced by '\0'
> after fixing the value.
>
> Kenji Arisawa
>


  reply	other threads:[~2005-02-02  1:06 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-02  0:37 arisawa
2005-02-02  1:06 ` Russ Cox [this message]
2006-01-16 11:35 Gorka guardiola
2006-01-16 12:30 ` Charles Forsyth
2006-01-16 13:27   ` Bruce Ellis
2006-01-16 13:37     ` Gorka guardiola
2006-01-16 13:57       ` Charles Forsyth
2006-01-16 14:24         ` Bruce Ellis
2006-01-17  0:56         ` erik quanstrom
2006-01-17  1:35           ` Russ Cox
2006-01-17  1:42             ` erik quanstrom
2006-01-17  1:47               ` Russ Cox
2006-01-17 10:01               ` Charles Forsyth
2006-01-17 16:45                 ` Bruce Ellis
2006-01-18  5:38                   ` Simon Williams
2006-01-18  5:49                     ` Bruce Ellis
2006-01-18  5:54                     ` Paul Lalonde
2006-01-18  6:11                       ` Bruce Ellis
2006-01-18 14:25                         ` Bruce Ellis
2006-01-18 15:26                           ` Ronald G Minnich
2006-01-18 23:06                             ` Adrian Tritschler
2006-01-19  1:20                               ` Bruce Ellis
2006-01-18 15:45                         ` Paul Lalonde
2006-01-18 16:41                           ` Bruce Ellis
2006-01-18 16:47                           ` Wes Kussmaul
2006-01-18 16:57                             ` Bruce Ellis
2006-01-18 17:37                               ` David Leimbach
2006-01-18 17:50                                 ` Bruce Ellis
2006-01-18 18:00                               ` Sape Mullender
2006-01-18 17:01                             ` Paul Lalonde
2006-01-18 17:30                               ` Charles Forsyth
2006-01-18 18:04                               ` Wes Kussmaul
2006-01-18 20:22                                 ` Skip Tavakkolian
2006-01-18 20:31                                   ` andrey mirtchovski
2006-01-18 23:01                                     ` Bruce Ellis
2006-01-18 22:56                                   ` Joel Salomon
2006-01-18 15:25                       ` Brantley Coile
2006-01-18 16:35                         ` Paul Lalonde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9e417a050201170652f61fcd@mail.gmail.com \
    --to=russcox@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).