Annotation of researchv9/libc/fio/fiordline.c, revision 1.1

1.1     ! root        1: #define        FIO_IMP
        !             2: #include       "fio.h"
        !             3: #include       <libc.h>
        !             4: 
        !             5: char *
        !             6: Frdline(fd)
        !             7: {
        !             8:        register unsigned char *p;
        !             9:        register Fbuffer *f = Ffb[fd];
        !            10:        register n;
        !            11:        register char *nextnl;
        !            12: 
        !            13:        FIOSET(f, fd);
        !            14:        while((nextnl = memchr(f->next, '\n', (COUNT)(f->end-f->next))) == 0){
        !            15:                if(f->next == f->buf){
        !            16:                        if(f->end >= &f->buf[FIOBSIZE])
        !            17:                                f->end = &f->buf[FIOBSIZE-64];  /* full buffer, no newline */
        !            18:                } else {
        !            19:                        n = f->next-f->buf;
        !            20:                        memcpy(f->buf, f->next, (COUNT)(FIOBSIZE-n));
        !            21:                        f->next -= n;
        !            22:                        f->end -= n;
        !            23:                }
        !            24:                if(Ffillbuf(fd) <= 0)
        !            25:                        return((char *)0);
        !            26:        }
        !            27:        f->lnext = f->next;
        !            28:        f->next = (unsigned char *)(nextnl+1);
        !            29:        *nextnl = 0;
        !            30:        f->rdlast = 1;
        !            31:        return((char *)f->lnext);
        !            32: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.