static char sccsid
[] = "@(#)streams.c 2.4 3/5/87";
/* 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 and any following non-blank lines that
all words of the form %a are returned as null.
*p is a null terminated string (char p[maxstr]).
} while (isspace(c
) && c
!='\n');
if (index(ignore
, oldp
[1]) != NULL
)
{ do{ while (c
!='\n') c
=getc(stream
);
} while (c
!= EOF
&& !isspace(c
) && c
!='%');
/* recsize(stream,start):
returns length of record beginning at start
(record ends at blank line or eof)
assumes and retains stream positioned at start
long int recsize(stream
,start
)
{ char c
; /* length = # of chars from start to beginning */
long int length
; /* of current line. c in current line. */
int nonspaces
; /* nonspaces = # of nonspaces in current line. */
while ( (c
!='\n' || nonspaces
!=0) && c
!=EOF
)
{ length
= ftell(stream
)-start
;
else if (!isspace(c
)) nonspaces
++;
/* nextrecord(stream,x): seeks in stream for first non-blank line
at or after char x in stream. seeks to eof if x is past last record.
x is the index of a character in the file (not eof).
returns position in stream. (returns EOF, if seeks to EOF)
long int nextrecord(stream
,x
)
{ long int start
; /* position of the beginning of the line */
char c
; /* containing c */
/* find start of first non-blank record */
{ if (c
=='\n') {start
= ftell(stream
); c
= getc(stream
);}
else if (c
=='#') while (c
!='\n') c
=getc(stream
);
else if (!isspace(c
)) break;
if (feof(stream
)) { pos(start
); start
= EOF
; }
/* nextline(stream,x): seeks in stream after first newline at or after
char x in stream. seeks to eof if x is in last line.
x is the index of a character in the file (not eof).
returns position in stream
long int nextline(stream
,x
)
while (getc(stream
)!='\n') ;
/* printline(stream): copies stream up to a newline
while ((c
=getc(stream
)) != '\n' && c
!=EOF
) putchar(c
);
/* getline(stream,p): store in *p next chars in stream up to \n
limit of maxstr-1 chars may be stored at p.
while ( (*p
= getc(stream
)) != '\n' && *p
!=EOF
)
/* replace string old at the head of subj by new */
strreplace(subj
, old
, new)
strcpy(buf
, &subj
[strlen(old
)]);