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 r

⟦75825d29c⟧ TextFile

    Length: 1185 (0x4a1)
    Types: TextFile
    Names: »readline.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/stat/src/readline.c« 

TextFile

/* LINTLIBRARY */
#include "unixstat.h"
FUN(reasline,read a line frlom a file,5.0,1985)

/* fills buf with next line from ioptr so that line continuations are allowed */
/* a line continues if the first character on the next line is ' ' or '\t'    */
/* a backslash at the visible end of line reads the next line; blanks ignored */
/* returns EOF or the string length.  Trailing newlines are removed */
readline (buf, ioptr)
char	*buf;
FILE	*ioptr;
	{
	int 	C;
	char	*bufptr;
	if (fgets (bufptr = buf, BUFSIZ, ioptr) == NULL) return (EOF);
getline:
	while (*bufptr) bufptr++;
	while (bufptr > buf && isspace (*(bufptr-1))) bufptr--;
	if (bufptr > buf && *(bufptr-1) == '\\')
		bufptr--;
	else
		{
		*bufptr = '\0';
		C = getc (ioptr);
		ungetc (C, ioptr);
		if (C != ' ' && C != '\t') return (bufptr-buf);
		}
	*bufptr++ = ' ';
	while ((C = getc (ioptr)) == ' ' || C == '\t');
	*bufptr++ = (C == EOF) ? '\0' : C;
	if (fgets (bufptr, BUFSIZ - (bufptr - buf), ioptr) == NULL)
		bufptr = '\0';
	goto getline;
	}

#ifdef STANDALONE
main ()
	{
	char	line[BUFSIZ];
	int 	len;
	while ((len = readline (line, stdin)) != EOF)
		{
		printf ("%d\n", len);
		puts (line);
		}
	exit (0);
	}
#endif