/* first process pipe input */
if(piped_in)
{
/* 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);
if (wflag != 1)
{
fprintf(stderr,"Checking matching...\n");
Match(scr);
fseek(scr,0,0);
}
/* either expand or buffer */
if (iflag != 1)
{ Expand(scr,buf); fclose(scr); }
else
{ tmpbuf(scr,buf); fclose(scr); }
if (wflag != 1)
fprintf(stderr,"Checking matching done\n");
Eqn(buf,out_file);
fclose(scr);
}
/* next process in=inputfiles */
if(getpar_("in","s",string))
{
sscanf(string,"%s",filename);
if((temp=fopen(filename,"r")) != NULL)
{
if (wflag != 1)
{
fprintf(stderr,"Checking matching...\n");
fprintf(stderr,"%s:\n",filename);
Match(temp);
fprintf(stderr,"\n");
fseek(temp,0,0);
}
/* either expand or buffer */
if (iflag != 1)
{ Expand(temp,buf); fclose(temp); }
else
{ tmpbuf(temp,buf); fclose(temp); }
if (wflag != 1)
fprintf(stderr,"Checking matching done\n\n");
Eqn(buf,out_file);
fclose(temp);
}
else
fprintf(stderr,"texeqn: Cannot open %s\n",filename);
}
/* then process input line for arguments and assume they are input files */
for (xargc--,xargv++; xargc; xargc--,xargv++)
{
cptr = *xargv;
if( *cptr=='-' ) continue; /* this is a flag */
while (*cptr)
{
if (*cptr == '=') break; /* this is for getpar */
cptr++;
}
if (*cptr) continue;
cptr = *xargv;
if((temp=fopen(cptr,"r")) != (FILE *)NULL)
{
if (wflag != 1)
{
fprintf(stderr,"Checking matching...\n");
fprintf(stderr,"%s:\n",cptr);
Match(temp);
fprintf(stderr,"\n");
fseek(temp,0,0);
}
/* either expand or buffer */
if (iflag != 1)
{ Expand(temp,buf); fclose(temp); }
else
{ tmpbuf(temp,buf); fclose(temp); }
if (wflag != 1)
fprintf(stderr,"Checking matching done\n\n");
Eqn(buf,out_file);
fclose(temp);
}
else
fprintf(stderr,"texeqn: Cannot open %s\n",cptr);
}