From: kazama@square.ntt.jp (Kazuhiro Kazama)
Newsgroups: fj.comp.texhax
Subject: texfix 1.1 (Re: including EPSF figure into Tex File)
Date: 13 Apr 92 15:01:29 GMT
	<278936@nttlab.ntt.JP> <KURI.92Apr3140053@news3.pontneuf.tis.co.jp>
	<TAKEBA.92Apr6122902@rondo.otsl.oki.co.jp> <283353@nttlab.ntt.JP>
Distribution: fj
Organization: NTT Software Laboratories, Tokyo, Japan.
In-reply-to: kazama@square.ntt.jp's message of 7 Apr 1992 23:40:09 JST

$@Iw4V!w#N#T#T%=%U%H8&$G$9!#(J

In article <283353@nttlab.ntt.JP> kazama@square.ntt.jp (Kazuhiro Kazama) writes:
 > $@!!$H$$$&$o$1$G!"(Jdvi2ps-j$@MQ$N(JC$@8@8l$G=q$$$?%W%m%0%i%`$rEj9F$7$^$9!#(J
 > dvi2ps-j$@$N%f!<%6$O$3$l$G%P%0$r$&$^$/2sHr$G$-$k$+$I$&$+$r;n$7$F$_$F$/$@(J
 > $@$5$$!#$3$l$GLdBj$r2sHr$G$-$k$+$I(J$@$&$+CN$j$?$$$N$G!"$<$R7k2L$r%a!<%k$^$?(J
 > $@$O%K%e!<%9$G65$($F2<$5$$!#(J

$@!!:#$^$GJs9p$OGO>l!w:eBg$5$s(J(xfig)$@$H$($H$&!wIY;NDL$5$s(J(new idraw beta
version)$@$N#27o$"$j$^$7$?!#$&$^$/F0$$$F$$$k$=$&$G$9!#$&$^$/F0$+(J$@$J$$?M$O(J
$@$<$R65$($F2<$5$$!#(J

$@!t(J $@#27o$7$+$J$$$H$$$&$3$H$O!"<B:]$K:$$C$F$$$k?M$O$"$^$j$$$J$+$C$?$N$+$J!)(J

$@!!0JA0$N%P!<%8%g%s$O(Jstrstr()$@$r;H$C$F$$$^$9$,!"$3$N4X?t$,$J$$%^%7%s$,$"(J
$@$j$^$9$N$G!"$=$&$$$&>l9g$O:#(J$@EY$O(J"-DSTRSTR"$@$N%*%W%7%g%s$rIU$1$l$P%3%s%Q(J
$@%$%k$G$-$k$h$&$K$7$^$7$?!#:#EY$N%P!<%8%g%s$OE73$$5$s$N%"%I(J$@%P%$%9$K=>$C(J
$@$F2~NI$7$?$N$G!"0l3d$[$IB.$/$J$C$F$$$^$9!#(J

$@!t(J $@$H$$$$$D$D$b!"E73$$5$s$NBg7y$$$J(Jgets()$@$r$^(J$@$@;H$C$F$$$k(J:-P

$@!!$"$H$-$A$s$H3NG'$7$?$o$1$G$O$"$j$^$;$s$,!"(J-DSTRSTR$@$G%3%s%Q%$%k$7$?J}(J
$@$,$^$?0l3d$[$I(J$@B.$$$_$?$$$G$9(J(Sun OS 4.1.2)$@!#$J$<$@$m$&!)!)!)$3$N4X?t$O(J
$@;d$,:n$C$?$N$G(JBSD$@HG$H$O0c$&$s$@$1$I!"$b$7$+$7(J$@$F4V0c$C$F$$$?$j$7$F!#%P(J
$@%0$,$"$l$P;XE&$7$F$/$@$5$$!#(J

$@!!;H$$J}$O!"A0$HF1$8$G(J
	   dvi2ps foo.dvi | texfix | lpr
$@$_$?$$$K!"I8=`F~NO$+$iFI$s$GI8=`=PNO$K=P$7$^$9!#(JJDVI2KPS$@$rDj5A$9(J
$@$k$H(Jjdvi2kps$@$G$b;H$($k$+$b(J$@$7$l$^$;$s$,!"$^$@L$3NG'$G$9!#(J
--- cut here --- cut here --- cut here --- cut here --- cut here --
/*
 *	texfix.c
 *
 *	version 1.1 (April 8, 1992)
 *	written by Kazuhiro Kazama (kazama@square.ntt.jp)
 *
 *	This original program is retexps made by takeba@otsl.oki.co.jp.
 */
#include	<stdio.h>
#include	<string.h>
#include	<signal.h>
char	*mktemp();

#ifdef	STRSTR
char	*strstr();
#endif

#define	PAGECOM	"%%Page:"
#define	BSP	"@beginspecial"
#define	ESP	"@endspecial"
#ifdef JDVI2KPS
#define	BOP	"@bop"
#define	EOP	"@eop"
#else
#define	BOP	"BP"
#define	EOP	"EP"
#endif

char	line[BUFSIZ];
char	tmpstr[] = "/tmp/tfXXXXXX";
char	*tmpfn;
int	cleanup();

main()
{
    if ((tmpfn = mktemp(tmpstr)) == NULL) {
        perror("mktemp failed.");
        exit(1);
    }
    signal(SIGHUP, cleanup);
    signal(SIGINT, cleanup);
    signal(SIGQUIT, cleanup);
    signal(SIGPIPE, cleanup);
    signal(SIGTERM, cleanup);
    while (gets(line) != NULL)
	if (strncmp(line, PAGECOM, sizeof(PAGECOM) - 1) == 0) {
	    puts(line);
	    if (pageout())
		break;
	} else
	    puts(line);
    unlink(tmpfn);
    exit(0);
}

pageout()
{
    char	*p;
    int	c;
    FILE	*tmpfp;

    while (gets(line) != NULL)
	if (strcmp(line, BOP) == 0) {
	    puts(line);
	    if ((tmpfp = fopen(tmpfn, "w")) == NULL) {
		perror("fopen failed.");
		exit(1);
	    }
	} else if (strcmp(line, EOP) == 0) {
	    fclose(tmpfp);
	    if ((tmpfp = fopen(tmpfn, "r")) == NULL) {
		perror("fopen failed.");
		exit(1);
	    }
	    while ((c = getc(tmpfp)) != EOF)
		putchar(c);
	    fclose(tmpfp);
	    puts(line);
	    return 0;
	} else if ((p = strstr(line, BSP)) != NULL && strcmp(p, BSP) == 0) {
	    puts(line);
	    if (specialout())
		return 1;
	} else {
	    fputs(line, tmpfp);
	    putc('\n', tmpfp);
	}
    return 1;
}

specialout()
{
    char	*p;
    int	inspecial = 1;

    while (gets(line) != NULL)
	if ((p = strstr(line, BSP)) != NULL && strcmp(p, BSP) == 0) {
	    puts(line);
	    inspecial++;
	} else if (strcmp(line, ESP) == 0) {
	    puts(line);
	    if (--inspecial == 0)
		return 0;
	} else
	    puts(line);
    return 1;
}

cleanup()
{
    unlink(tmpfn);
    exit(0);
}

#ifdef	STRSTR
char	*strstr(s1, s2)
register char	*s1, *s2;
{
    register int	l1, l2;
    register char	c2;

    if ((c2 = *s2) != '\0')
	for (l1 = strlen(s1), l2 = strlen(++s2); l1 > l2; l1--)
	    if (*s1++ == c2 && strncmp(s1, s2, l2) == 0)
		return --s1;
    return NULL;
}
#endif
--- cut here --- cut here --- cut here --- cut here --- cut here --
--
	$@Iw4V0lMN(J (kazama@square.ntt.jp)
	NTT$@%=%U%H%&%'%"8&5f=j(J $@%=%U%H%&%'%"4pAC5;=Q8&5fIt(J
	$@J,;67?%=%U%H%&%'%"8&5f%0%k!<%W(J