DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T g

⟦2e49039fe⟧ TextFile

    Length: 986 (0x3da)
    Types: TextFile
    Names: »getline.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/rman/daemon/getline.c« 

TextFile

#ifndef lint
static char RCSid[] = "$Header: getline.c,v 1.1 85/08/04 13:59:54 broome Exp $";
#endif

/*
 * $Log:    getline.c,v $
 * Revision 1.1  85/08/04  13:59:54  broome
 * Initial revision
 * 
 */

#include <stdio.h>

/*
 *  Read at most _maxlen_ characters into the buffer pointed to by line.
 *  Strips newlines, allows escaped newlines, turns tabs to spaces, and
 *  eats comments beginning with a `#' sign.
 */

getline (line, maxlen, fp)
char *line; 
int  maxlen;
FILE *fp;
{
    register int ch, len = maxlen, comment = 0;

    while (len && (ch = getc (fp)) != EOF) {
        if (ch == '\n')
            break;
        if (ch == '#')
            comment = 1;
        if (comment)
            continue;
        if (ch == '\\')
            if ((ch = getc (fp)) == '\n')
                continue;
        if (ch == '\t')
            ch = ' ';
        *line++ = ch;
        len--;
    }
    if (ch == EOF)   /* at EOF */
        return (0);
    *line = '\0';
    return (1);
}