9 Biobuf *fp[32]; /* hard limit to avoid infinite recursion */
14 s_allocinstack(char *file)
19 fp = Bopen(file, OREAD);
23 sp = malloc(sizeof *sp);
30 s_freeinstack(Sinstack *sp)
33 Bterm(sp->fp[sp->depth--]);
37 /* Append an input line to a String.
39 * Empty lines and leading whitespace are removed.
42 rdline(Biobuf *fp, String *to)
49 /* eat leading white */
50 while(c==' ' || c=='\t' || c=='\n' || c=='\r')
86 /* Append an input line to a String.
88 * Returns a pointer to the character string (or 0).
89 * Leading whitespace and newlines are removed.
90 * Lines starting with #include cause us to descend into the new file.
91 * Empty lines and other lines starting with '#' are ignored.
94 s_rdinstack(Sinstack *sp, String *to)
100 fp = sp->fp[sp->depth];
109 return s_rdinstack(sp, to);
112 if(strncmp(p, "#include", 8) == 0 && (p[8] == ' ' || p[8] == '\t')){
116 /* sanity (and looping) */
117 if(sp->depth >= nelem(sp->fp))
118 sysfatal("s_recgetline: includes too deep");
121 while(*p == ' ' || *p == '\t')
124 nfp = Bopen(p, OREAD);
128 sp->fp[sp->depth] = nfp;
129 return s_rdinstack(sp, to);
136 /* take care of comments */