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 - metrics - download
Index: T d

⟦7a321f889⟧ TextFile

    Length: 3361 (0xd21)
    Types: TextFile
    Names: »detex1.c«

Derivation

└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
    └─⟦c319c2751⟧ »unix3.0/TeX3.0.tar.Z« 
        └─⟦036c765ac⟧ 
            └─⟦this⟧ »TeX3.0/TeXcontrib/kamal/detex1.c« 
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89
    └─⟦this⟧ »./tex82/TeXcontrib/kamal/detex1.c« 
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
    └─⟦63303ae94⟧ »unix3.14/TeX3.14.tar.Z« 
        └─⟦c58930e5c⟧ 
            └─⟦this⟧ »TeX3.14/TeXcontrib/kamal/detex1.c« 

TextFile

/* COPYRIGHT (C) 1987 Kamal Al-Yahya */
/* detex: strips TeX's and LaTeX's commands */

char *documentation[] = {
" SYNTAX",
"        detex [-i] file1 [file2 .....]",
"     or detex [-i]  < file1 [file2 ....]",
"",
"See the manual page for more details.",
"",
"        Flag:",
"             -i:     ignores TeX's and LaTeX's \input and \include commands",
"             -w:     matching is not checked",
"",
};

/* Author: Kamal Al-Yahya, Stanford University,		11/1/83 */
/* Last modified:					1/25/87 */

int	doclength = { sizeof documentation/sizeof documentation[0] };

#include        "setups.h"

#ifdef tops20
#define TEMPFILE "texXXXXXX"
#else
#define TEMPFILE "/tmp/texXXXXXX"
#endif

#ifdef MSC
#else
struct sgttyb ttystat;
#endif

extern char *mktemp();
char scratch_file[MAXWORD];

int wflag;
int xargc;
char **xargv;

main(argc,argv)
int argc; 
char *argv[];
{
char *buf;
FILE *temp,*scr;
register char *cptr;
int piped_in;
int iflag,i;

if (((buf = (char *)malloc(MAXLEN*sizeof(char))) == (char *)NULL))
	{
    	fprintf(stderr,"detex: Cannot malloc() internal buffer space\n\
Need an array of %d characters\n",MAXLEN);
	exit(-1);
	}

/* If no arguments, and not in a pipeline, self document */
#ifdef MSC	/* MS-DOS cannot distinguish piped input from no input */
piped_in = (argc == 1);
#else
piped_in = ioctl ((fileno (stdin)), TIOCGETP, &ttystat);
#endif

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

/* 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,
			"detex: 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\n");
	DeTeX(buf,stdout);
	fclose(scr);
	}

/* 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)
		{
		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");
		DeTeX(buf,stdout);
		fclose(temp);
		}
	else
		fprintf(stderr,"detex: Cannot open %s\n",cptr);
	}

}