getword(): When ignoring a line, also ignore followingnon-blank
lines that don't begin with '%'. Continuation lines were never being
ignored. (mlvdv)
SCCS-vsn: contrib/bib/src/streams.c 2.4
-static char sccsid[] = "@(#)streams.c 2.3 %G%";
+static char sccsid[] = "@(#)streams.c 2.4 %G%";
/* getword(stream,p,ignore):
read next sequence of nonspaces on current line into *p.
null if no more words on current line.
/* getword(stream,p,ignore):
read next sequence of nonspaces on current line into *p.
null if no more words on current line.
- %x (x in ignore) terminates line.
+ %x (x in ignore) terminates line and any following non-blank lines that
+ don't begin with '%'
all words of the form %a are returned as null.
*p is a null terminated string (char p[maxstr]).
*/
all words of the form %a are returned as null.
*p is a null terminated string (char p[maxstr]).
*/
char *p, *ignore;
{ char c;
char *oldp, *stop;
char *p, *ignore;
{ char c;
char *oldp, *stop;
oldp= p;
stop= p+maxstr-1;
oldp= p;
stop= p+maxstr-1;
if (oldp[0]=='%')
{ oldp[0]= NULL;
if (index(ignore, oldp[1]) != NULL)
if (oldp[0]=='%')
{ oldp[0]= NULL;
if (index(ignore, oldp[1]) != NULL)
- while (c!='\n') c=getc(stream);
+ { do{ while (c!='\n') c=getc(stream);
+ save= ftell(stream);
+ c= getc(stream);
+ } while (c!= EOF && !isspace(c) && c!='%');
+ pos(save);
+ }
pos(x);
start= x;
/* find start of first non-blank record */
pos(x);
start= x;
/* find start of first non-blank record */
- { c= getc(stream);
- if (c=='\n') start= ftell(stream);
- else if (!isspace(c)) break;
+ { if (c=='\n') {start= ftell(stream); c= getc(stream);}
+ else if (c=='#') while (c!='\n') c=getc(stream);
+ else if (!isspace(c)) break;
+ else c= getc(stream);
}
if (feof(stream)) { pos(start); start= EOF; }
}
if (feof(stream)) { pos(start); start= EOF; }