DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T t

⟦d2c0c0a96⟧ TextFile

    Length: 2656 (0xa60)
    Types: TextFile
    Names: »texexpand1.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/textools/texexpand1.c« 

TextFile

/* texexpand: to expand TeX and LaTeX \input and include files
 * to compile:   cc texexpand.c -o texexpand 
 */

char *documentation[] = {
" SYNTAX",
"        texexpand [-w] file1 [file2 .....]",
"     or texexpand [-w] < file1 [file2 ....]",
"",
"        Flags:",
"              -w    maching is not checked",
"",
"See the manual page for more details.",
"",
};

/* 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 character in a document */

struct sgttyb ttystat;
extern char *strcpy(), *mktemp();
char scratch_file[100];

int wflag;
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,w;

/* 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 'w':
					wflag=1;
					break;
				default:
			     		fprintf(stderr,
					"unknown flag -%c\n",*cptr);
					break;
				}
			}
		}
	}

/* first process pipe input */
if(piped_in)
	{
	if (wflag != 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);
		fprintf(stderr,"Checking matching...\n");
		TeXMatch(scr);
		fseek(scr,0,0);
		TeXExpand(scr,big,MAXLEN);
		fprintf(stderr,"Checking matching done\n\n");
		fclose(scr);
		}
	else
		TeXExpand(stdin,big,MAXLEN);

	fprintf(stdout,"%s\n",big);
	}

/* 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((temp=fopen(cptr,"r")) != NULL)
		{
		if (wflag != 1)
			{
			fprintf(stderr,"Checking matching...\n");
			fprintf(stderr,"%s:\n",cptr);
			TeXMatch(temp);
			fprintf(stderr,"\n");
			fseek(temp,0,0);
			}
		TeXExpand(temp,big,MAXLEN);
		if (wflag != 1)
			fprintf(stderr,"Checking matching done\n\n");
		fprintf(stdout,"%s",big);
		fclose(temp);
		}
	else
		fprintf(stderr,"texexpand: Cannot open %s\n",cptr);
	}

}