Annotation of 3BSD/libc/stdio/fgets.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: 
        !             3: char *
        !             4: fgets(s, n, iop)
        !             5: char *s;
        !             6: register FILE *iop;
        !             7: {
        !             8:        register c;
        !             9:        register char *cs;
        !            10: 
        !            11:        cs = s;
        !            12:        while (--n>0 && (c = getc(iop))>=0) {
        !            13:                *cs++ = c;
        !            14:                if (c=='\n')
        !            15:                        break;
        !            16:        }
        !            17:        if (c<0 && cs==s)
        !            18:                return(NULL);
        !            19:        *cs++ = '\0';
        !            20:        return(s);
        !            21: }

unix.superglobalmegacorp.com

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