1: #ifndef lint
2: static char sccsid[] = "@(#)cfgets.c 5.3 (Berkeley) 6/19/85";
3: #endif
4:
5: /*
6: * get nonblank, non-comment, (possibly continued) line. Alan S. Watt
7: */
8:
9: #include <stdio.h>
10: #define '#'
11: #define CONTINUE '\\'
12: #define EOLN '\n'
13: #define EOS '\0'
14:
15: /*LINTLIBRARY*/
16:
17: char *
18: cfgets(buf, siz, fil)
19: register char *buf;
20: int siz;
21: FILE *fil;
22: {
23: register char *s;
24: register i, c, len;
25: char *fgets();
26:
27: for (i=0,s=buf; i = (fgets(s, siz-i, fil) != NULL); i = s - buf) {
28:
29: /* get last character of line */
30: c = s[len = (strlen(s) - 1)];
31:
32: /* skip comments; make sure end of comment line seen */
33: if (*s == COMMENT) {
34: while (c != EOLN && c != EOF)
35: c = getc(fil);
36: *s = EOS;
37: }
38:
39: /* skip blank lines */
40: else if (*s != EOLN) {
41: s += len;
42:
43: /* continue lines ending with CONTINUE */
44: if (c != EOLN || *--s != CONTINUE)
45: break;
46: }
47: }
48:
49: return i ? buf : NULL;
50: }
51:
52: #ifdef TEST
53: main()
54: {
55: char buf[512];
56:
57: while (cfgets(buf, sizeof buf, stdin))
58: fputs(buf, stdout);
59: }
60: #endif TEST
Defined functions
cfgets
defined in line
17; used 11 times
main
defined in line
53;
never used
Defined variables
sccsid
defined in line
2;
never used
Defined macros
defined in line
10; used 1 times
EOLN
defined in line
12; used 3 times
EOS
defined in line
13; used 1 times