/* first process pipe input */
if(piped_in)
{
if (iflag != 1)
{
/* need to buffer; can't seek in pipes */
/* make a temporary and volatile file in /tmp */
strcpy(scratch_file,TEMPFILE);
mktemp(scratch_file);
if ((scr=fopen(scratch_file,"w")) == (FILE *)NULL)
{
fprintf(stderr,
"texmatch: Cannot open scratch file [%s]\n",scratch_file);
exit(-1);
}
scrbuf(stdin,scr);
fclose(scr);
scr=fopen(scratch_file,"r");
unlink(scratch_file);
Match(scr);
fseek(scr,0,0);
Expand(scr,buf);
fclose(scr);
}
else
Match(stdin);
}
/* then process input line for arguments and assume they are input files */
xargc = argc;
xargv = argv;
for (xargc--,xargv++; xargc; xargc--,xargv++)
{
cptr = *xargv;
if( *cptr=='-' ) continue; /* this is a flag */
if((temp=fopen(cptr,"r")) != (FILE *)NULL)
{
fprintf(stderr,"%s:\n",cptr);
Match(temp);
fprintf(stderr,"\n");
if (iflag != 1)
{
fseek(temp,0,0);
Expand(temp,buf);
}
fclose(temp);
}
else
fprintf(stderr,"texmatch: Cannot open %s\n",cptr);
}