|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1239 (0x4d7)
Types: TextFile
Notes: UNIX file
Names: »input.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »cmd/tsort/input.c«
#include <stdio.h>
#include <ctype.h>
#include "tsort.h"
void
getcon(fp)
FILE *fp;
{
register char *wrd;
struct word *wordp1, *wordp2;
struct wordlist *rel;
char *getwrd();
for (;;) {
wrd = getwrd(fp);
if (wrd == NULL)
break;
wordp1 = insert(wrd);
wrd = getwrd(fp);
if (wrd == NULL)
die("odd number of fields input");
wordp2 = insert(wrd);
if (wordp1 != wordp2) {
rel = newwordl(wordp1);
rel->next = wordp2->ancestors;
wordp2->ancestors = rel;
}
}
words = cmphash();
}
/*
* Getwrd is used to get the next word from the FILE pointed to
* by "fp". Word is defined as non-white-space. If the end of
* file is reached, then getwrd returns an empty string. Note
* that since getwrd returns a pointer to a static area, the result
* must be copyied before the next call.
*/
static char *
getwrd(fp)
register FILE *fp;
{
register int ch;
static char word[MAXWORD];
register char *wrdp;
while ((ch = getc(fp)) != EOF && isascii(ch) && isspace(ch))
;
if (ch == EOF)
return (NULL);
for (wrdp = word; !(isascii(ch) && isspace(ch)); ch = getc(fp)) {
if (ch == EOF)
break;
if (wrdp >= &word[MAXWORD - 1])
die("word too long");
*wrdp++ = ch;
}
*wrdp = '\0';
return (word);
}