|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T t ┃
Length: 3152 (0xc50) Types: TextFile Names: »texmatch2.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/textools/texmatch2.c«
/* * texmatch: checks matching parantheses, braces, brackets, and dollar signs * in TeX documents. * * to compile: cc texmatch.c -lsep -o texmatch */ char *documentation[] = { " SYNTAX", " texmatch [-i] [parameters] [inputfiles]", "", " flags:", " -i ignores TeX's and LaTeX's \input and \include commands", "", " parameters:", " in=filename filename is the input file", " (Default: in=stdin)", "" }; /* Author: Kamal Al-Yahya, Stanford University, 11/1/83 */ /* Modified: 6/30/86 */ int doclength = { sizeof documentation/sizeof documentation[0] }; #include <stdio.h> #include <sys/ioctl.h> #include <sgtty.h> #define MAXLEN 100000 /* maximum characters in a document */ char string[100],filename[100]; struct sgttyb ttystat; extern char *strcpy(), *mktemp(); char scratch_file[100]; int wflag=0; /* for consistency with other programs */ int xargc; char **xargv; main(argc,argv) int argc; char *argv[]; { char big[MAXLEN]; FILE *temp,*scr; register char *cptr; int piped_in; int i,iflag; /* If no arguments, and not in a pipeline, self document */ piped_in = ioctl ((fileno (stdin)), TIOCGETP, &ttystat); if (argc == 1 && !piped_in) { for( i=0; i<doclength; i++) printf("%s\n",documentation[i]); exit (0); } /* process option flags */ xargc = argc; xargv = argv; for (xargc--,xargv++; xargc; xargc--,xargv++) { cptr = *xargv; if( *cptr=='-' ) { while( *(++cptr)) { switch( *cptr ) { case 'i': iflag=1; break; default: fprintf(stderr, "unknown flag -%c\n",*cptr); break; } } } } /* first process pipe input */ xargc = argc; xargv = argv; if(piped_in) { if (iflag != 1) { /* need to buffer; can's seek in pipes */ /* make a temporary and volatile file in /tmp */ strcpy(scratch_file,"/tmp/texXXXXXX"); mktemp(scratch_file); scr=fopen(scratch_file,"w"); scrbuf(stdin,scr); fclose(scr); scr=fopen(scratch_file,"r"); unlink(scratch_file); TeXMatch(scr); fseek(scr,0,0); TeXExpand(scr,big,MAXLEN); fclose(scr); } else TeXMatch(stdin); } /* next process in=inputfiles */ if(getpar_("in","s",string)) { sscanf(string,"%s",filename); if((temp=fopen(filename,"r")) != NULL) { fprintf(stderr,"%s:\n",cptr); TeXMatch(temp); fprintf(stderr,"\n"); if (iflag != 1) { fseek(temp,0,0); TeXExpand(temp,big,MAXLEN); } fclose(temp); } else fprintf(stderr,"texmatch: 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")) != NULL) { fprintf(stderr,"%s:\n",cptr); TeXMatch(temp); fprintf(stderr,"\n"); if (iflag != 1) { fseek(temp,0,0); TeXExpand(temp,big,MAXLEN); } fclose(temp); } else fprintf(stderr,"texmatch: Cannot open %s\n",cptr); } }