# to unbundle, sh this file (in an empty directory)
echo delatex.lex 1>&2
sed >delatex.lex <<'//GO.SYSIN DD delatex.lex' 's/^-//'
-/* Make this with:  lex delatex.lex;  cc lex.yy.c -ll -o delatex */
-L [A-Za-z]
-%Start Display Math Normal Tag
-%%
-<Normal>\'	{yyleng--; yymore(); /* ignore apostrophes */}
-<Normal>{L}+\\- {yyleng-=2; yymore(); /* ignore hyphens */}
-<Normal>[a-z]/[^A-Za-z] ; /* ignore single letter "words" */
-<Normal>[A-Z]+	; /* ignore words all in uppercase */
-<Normal>{L}+('{L}*)*{L}	{printf("%s\n",yytext); /* any other letter seq is a word */} 
-<Normal>"%".*	; /* ignore comments */
-<Normal>\\{L}+	; /* ignore other control sequences */
-<Normal>"\\begin{"	BEGIN Tag; /* ignore this and up to next "}" */
-<Normal>"\\bibitem{"	BEGIN Tag;
-<Normal>"\\bibliography{"	BEGIN Tag;
-<Normal>"\\bibstyle{"	BEGIN Tag;
-<Normal>"\\cite{"	BEGIN Tag;
-<Normal>"\\end{"		BEGIN Tag;
-<Normal>"\\include{"	BEGIN Tag;
-<Normal>"\\includeonly{"	BEGIN Tag;
-<Normal>"\\input{"	BEGIN Tag;
-<Normal>"\\label{"	BEGIN Tag;
-<Normal>"\\pageref{"	BEGIN Tag;
-<Normal>"\\ref{"		BEGIN Tag;
-<Tag>[^}]		; /* ignore things up to next "}" */
-<Tag>"}"		BEGIN Normal;
-<Normal>[0-9]+	; /* ignore numbers */
-<Normal>"\\("		BEGIN Math; /* begin latex math mode */
-<Math>"\\)"		BEGIN Normal; /* end latex math mode */
-<Math>.|\\[^)]|\n	; /* ignore anything else in latex math mode */
-<Normal,Display>\$([^$]|\\\$)+\$	;  /* ignore things in math mode */
-<Normal>"\\["		BEGIN Display; /* now in Latex display mode */
-<Normal>"$$"		BEGIN Display; /* now in Display math mode */
-<Display>[^$]|\\[^\]]	; /* ignore most things in display math mode */
-<Display>"\\]"	BEGIN Normal; /* get out of Display math mode */
-<Display>"$$"	BEGIN Normal; /* get out of Display math mode */
-<Normal>\\.	; /* ignore other single character control sequences */
-<Normal>\\\n	; /* more of the same */
-<Normal>\n|.	; /* ignore anything else, a character at a time */
-%%
-main(argc,argv)
-	char **argv;
-{
-	int i;
-	
-	BEGIN Normal; /* Starts yylex off in the right state */
-	if (argc==1) {
-	    yyin = stdin;
-	    yylex();
-	    }
-	else for (i=1; i<argc; i++) {
-	    yyin = fopen(argv[i],"r");
-	    if (yyin==NULL) {
-		fprintf(stderr,"can't open %s\n",argv[i]);
-		exit(1);
-		}
-	    yylex();
-	    }
-	exit(0);
-}
//GO.SYSIN DD delatex.lex
mkdir r2bib
echo r2bib/r2bib.1 1>&2
sed >r2bib/r2bib.1 <<'//GO.SYSIN DD r2bib/r2bib.1' 's/^-//'
-.TH R2BIB 1-local
-.SH NAME
-r2bib \- convert refer input files to bibtex .bib files
-.SH SYNOPSIS
-.B r2bib
-file ...
-.br
-.SH DESCRIPTION
-.B r2bib
-reads the
-.I files
-and produces a
-.B bibtex
-reference list (a .bib file) on the standard output.
-If no files are given, r2bib reads
-standard input.
-.PP
-Since
-.B refer
-files are inherently unstructured (compared to
-.B bibtex )
-.B r2bib
-only does a passable job.  In particular
-.B refer
-doesn't require a keyword, while
-.B bibtex
-does.  The heuristic that
-.B r2bib
-uses for cooking up a keyword, in order of precedence, is:
-.PP
-1. Use the keyword entry (%K) if it's only one word.
-.PP
-2. Use the label entry (%L) if it's only one word.
-.PP
-3. Otherwise just use the string "keyN" where N
-is the count of this bibliographic entry in
-the refer file(s).
-.PP
-To determine the type of reference that the
-.B refer
-entry is,
-.B r2bib
-has to do some ``calculated guessing''.  The heuristic used
-here (again, in order of precedence) is:
-.PP
-1. If it has a journal entry (%J) then it's considered to
-be an @article.
-.PP
-2. If it has a report entry (%R) then it's considered to
-be a @techreport.
-.PP
-3. If it has a issuer entry (%I) then it's considered to
-be a @book.
-.PP
-4. Otherwise it's considered to be a @misc.
-.PP
-Quite often
-.B r2bib
-will misguess and you will need to edit (by hand) the resulting .bib
-file.
-.PP
-Any fields that
-.B r2bib
-doesn't know about it will ignore (and complain about on stderr).
-.SH AUTHOR
-Rusty Wright, Center For Music Experiment, University of California San
-Diego.
-.SH BUGS
//GO.SYSIN DD r2bib/r2bib.1
echo r2bib/r2bib.c 1>&2
sed >r2bib/r2bib.c <<'//GO.SYSIN DD r2bib/r2bib.c' 's/^-//'
-# include <ctype.h>
-# include <stdio.h>
-
-struct rb {
-	char	rb_kl;		/* refer key letter		*/
-	char *	rb_kw;		/* bibtex string		*/
-	char	rb_emit;	/* don't print data if 0	*/
-	char *	rb_data;	/* refer data			*/
-};
-
-struct rb rb[] = {
-	{ 'A',	"author",	1,	NULL	},
-	{ 'B',	"booktitle",	1,	NULL	},
-	{ 'C',	"address",	1,	NULL	},
-	{ 'D',	"year",		1,	NULL	},	/* mismatch */
-	{ 'E',	"editor",	1,	NULL	},
-/*	{ 'H',	"commentary1",	1,	NULL	},*/
-	{ 'I',	"publisher",	1,	NULL	},
-	{ 'J',	"journal",	1,	NULL	},
-	{ 'K',	"note",		1,	NULL	},	/* mismatch */
-	{ 'L',	"label",	0,	NULL	},	/* use as bibtex key */
-	{ 'N',	"number",	1,	NULL	},
-	{ 'O',	"note",		1,	NULL	}, /*hwt mod; was commented out */
-	{ 'P',	"pages",	1,	NULL	},
-	{ 'Q',	"institution",	1,	NULL	},
-	{ 'R',	"report",	0,	NULL	},
-	{ 'S',	"series",	1,	NULL	},
-	{ 'T',	"title",	1,	NULL	},
-	{ 'V',	"volume",	1,	NULL	},
-/*	{ 'X',	"abstract",	1,	NULL	},*/
-	{ 0,	0,		0,	0	}
-};
-
-struct bmap {
-	char	bm_kl;
-	char	*bm_entry;
-};
-
-/*
- * entries are in order of precedence.
- * any entry with a 'J' field must be
- * an article, but anthing with an 'I'
- * field doesn't have to be a book (if
- * an entry has both 'J' and 'I' it is
- * considered to be an article).
- */
-struct bmap	bmap[] = {
-	{ 'J',	"article"	},
-	{ 'R',	"techreport"	},
-	{ 'I',	"book"		},
-	{ 0,	0		}
-};
-
-main(argc, argv)
-	char		**argv;
-{
-	register FILE	*fid;
-	register int	i;
-	int		err;
-
-	err = 0;
-
-	if (argc > 1) {
-		for (i = 1; i < argc; i++) {
-			if ((fid = fopen(argv[i], "r")) == NULL) {
-				fprintf(stderr, "fopen: ");
-				perror(argv[i]);
-				continue;
-			}
-			err += r2bib(argv[i], fid);
-		}
-	}
-	else
-		err += r2bib("stdin", stdin);
-
-	if (err)
-		exit(1);
-
-	exit(0);
-}
-
-r2bib(file, fid)
-	char		*file;
-	FILE		*fid;
-{
-	extern char	*sanz();
-	register char	*cp;
-	struct rb	*lrb;		/* last rb stored into */
-	int		line;
-	char		buf[BUFSIZ];
-	int		err;
-
-	lrb = NULL;
-	err = 0;
-	line = 0;
-
-	while (fgets(buf, sizeof(buf), fid) != NULL) {
-		line++;
-
-		if ((cp = sanz(buf)) == NULL) {
-			if (lrb != NULL) {
-				dumprb();
-				lrb = NULL;
-			}
-			continue;
-		}
-
-		/*
-		 * if the first letter is a % then it's the
-		 * a new record, otherwise it's a continuation
-		 * of the previous one.
-		 */
-		if (cp[0] == '%') {
-			for (lrb = &rb[0]; lrb->rb_kl != 0; lrb++) {
-				if (lrb->rb_kl == cp[1]) {
-					stuffrb(lrb, &cp[2]);
-					break;
-				}
-			}
-			if (lrb->rb_kl == 0) {
-				fprintf(stderr, "r2b: %s: line %d: unknown key letter %c, ignoring\n", file, line, cp[1]);
-				err = 1;
-			}
-		}
-		else {
-			if (lrb == NULL) {
-				fprintf(stderr, "r2b: %s: line %d: bad format, ignoring\n", file, line);
-				err = 1;
-				continue;
-			}
-
-			stuffrb(lrb, &cp[0]);
-		}
-	}
-
-	if (lrb != NULL)
-		dumprb();
-
-	return(err);
-}
-
-dumprb() {
-	register struct rb	*trb;
-	register struct bmap	*bm;
-	static int		key;
-	char			*bibkey;
-	char			*cp;
-	int			first;
-
-	/*
-	 * first, figure out what type of entry this
-	 * is.
-	 */
-	for (bm = &bmap[0]; bm->bm_kl != 0; bm++) {
-		for (trb = &rb[0]; trb->rb_kl != 0; trb++) {
-			if ((trb->rb_kl == bm->bm_kl) && (trb->rb_data != NULL)) {
-				printf("@%s{", bm->bm_entry);
-				goto out;
-			}
-		}
-	}
-out:
-	if (bm->bm_kl == 0)
-		printf("@misc{");
-
-	/*
-	 * in order of precedence; how to determine the
-	 * bibtex key:
-	 *	1. use keyword (%K) if only one word.
-	 *	2. use refer label (%L).
-	 *	3. otherwise just use the string "keyN" where N
-	 *	   is the count of this bibliographic entry in
-	 *	   the refer file.
-	 */
-	key++;
-	for (trb = &rb[0]; trb->rb_kl != 0; trb++) {
-		if ((trb->rb_kl == 'K') && (trb->rb_data != NULL)) {
-			for (cp = trb->rb_data; *cp != NULL; cp++) {
-				if (isspace(*cp))
-					break;
-			}
-
-			/* ran to end of string? */
-			if (*cp == NULL) {
-				printf("%s,\n", trb->rb_data);
-
-				/* if used here then free & zero it */
-				(void) free(trb->rb_data);
-				trb->rb_data = NULL;
-				break;
-			}
-		}
-
-		if ((trb->rb_kl == 'L') && (trb->rb_data != NULL)) {
-			for (cp = trb->rb_data; *cp != NULL; cp++) {
-				if (isspace(*cp))
-					break;
-			}
-
-			/* ran to end of string? */
-			if (*cp == NULL) {
-				printf("%s,\n", trb->rb_data);
-				break;
-			}
-		}
-	}
-
-	/* nothing reasonable to use, punt */
-	if (trb->rb_kl == 0)
-		printf("key%d,\n", key);
-
-	first = 1;
-
-	for (trb = &rb[0]; trb->rb_kl != 0; trb++) {
-		if (trb->rb_data == NULL)
-			continue;
-
-		if (trb->rb_emit != 0) {
-			/*
-			 * clank,
-			 * this is so that things will line up.
-			 */
-			if (strlen(trb->rb_kw) < 6)
-				cp = "\t\t";
-			else
-				cp = "\t";
-
-			if (! first)
-				printf(",\n");
-
-			printf("\t%s =%s\"%s\"", trb->rb_kw, cp, trb->rb_data);
-			first = 0;
-		}
-
-		(void) free(trb->rb_data);
-		trb->rb_data = NULL;
-	}
-
-	printf("\n}\n\n");
-}
-
-stuffrb(lrb, cp)
-	struct rb	*lrb;
-	char		*cp;
-{
-	extern char	*andfix();
-	extern char	*malloc();
-	extern char	*realloc();
-
-	/* empty data field */
-	if ((cp = sanz(cp)) == NULL)
-		return;
-
-	if (lrb->rb_kl == 'A')
-		cp = andfix(cp);
-
-	if (lrb->rb_data == NULL) {
-		if ((lrb->rb_data = malloc(strlen(cp) + 1)) == NULL) {
-			perror("malloc");
-			exit(1);
-		}
-
-		strcpy(lrb->rb_data, cp);
-	}
-	else {
-		char	*conj;
-
-		if (lrb->rb_kl == 'A')
-			conj = " and ";
-		else
-			conj = " ";
-
-		if ((lrb->rb_data = realloc(lrb->rb_data, strlen(lrb->rb_data) + strlen(cp) + strlen(conj) + 1)) == NULL) {
-			perror("realloc");
-			exit(1);
-		}
-
-		strcat(lrb->rb_data, conj);
-		strcat(lrb->rb_data, cp);
-	}
-}
-
-/*
- */
-char *
-andfix(string)
-	register char	*string;
-{
-	register char	*tmp;
-	register char	*cp;
-
-	tmp = string;
-
-	for (cp = string; *cp != NULL; cp++) {
-		if (strncmp(cp, " and ", 5) == 0) {
-			/*
-			 * +2 for the curly braces around "{and}",
-			 * +1 for the null at the end.
-			 */
-			if ((tmp = malloc(strlen(string) + 2 + 1)) == NULL) {
-				perror("malloc");
-				exit(1);
-			}
-
-			strncpy(tmp, string, cp - string);
-			tmp[cp - string] = NULL; /* strncpy doesn't */
-			strcat(tmp, " {and} ");
-			strcat(tmp, cp + 5);
-		}
-	}
-
-	return(tmp);
-}
-
-char *
-sanz(bp)
-	char		*bp;
-{
-	register char	*cp;
-
-	cp = &bp[strlen(bp) - 1];
-
-	/*
-	 * back up over any spaces chars
-	 */
-	while (isspace(*cp) && (cp >= bp))
-		cp--;
-
-	if (cp < bp)
-		return(NULL);	/* empty line */
-
-	*++cp = NULL;
-
-	while (isspace(*bp) && (bp < cp))
-		bp++;
-
-	if (cp == bp)
-		return(NULL);	/* empty line */
-
-	return(bp);
-}
//GO.SYSIN DD r2bib/r2bib.c
echo texoff 1>&2
sed >texoff <<'//GO.SYSIN DD texoff' 's/^-//'
-#!/bin/sh
-p=
-set -- `getopt p $*`
-for i do
-  case $i in
-    -p) p=y; shift;;
-    --) shift; break;;
-    -*) exit;;
-  esac
-done
-if test $# -ne 1
-  then echo 'Only one file at a time' 1>&2
-fi
-
-b=`basename $1 .tex`
-if test -r bib.bib && newer bib.bib $b.bbl
-  then cite $b || exit
-fi
-if newer $b.tex $b.dvi || newer bib.bib $b.dvi
-  then
-    ${LATEX:=latex} $b
-    if grep -s '^LaTeX Warning' $b.log
-      then $LATEX $b || exit
-    fi
-fi
-if test -n "$p"
-  then
-    case $TYPESETTER in
-      202) dvit -T202 $b|d202;;
-      aps) echo 'APS not supported' 1>&2;;
-        *) dvit $b|dcan;;
-    esac
-fi
//GO.SYSIN DD texoff
chmod +x texoff
echo texrm 1>&2
sed >texrm <<'//GO.SYSIN DD texrm' 's/^-//'
-#!/bin/sh
-exec rm -f *.aux *.blg *.bbl *.dvi *.log
//GO.SYSIN DD texrm
chmod +x texrm
mkdir textr
echo textr/GREEK.h 1>&2
sed >textr/GREEK.h <<'//GO.SYSIN DD textr/GREEK.h' 's/^-//'
-/*
-This file contains the list of the upper-case Greek letters.
-In case I overlooked any, it can be added here.
-*/
-char *GREEK_list[] =
-{
-"ALPHA",    "BETA",   "GAMMA",  "DELTA",  "CHI",
-"EPSILON",  "ETA",    "KAPPA",  "LAMDA",  "MU",
-"NU",       "OMEGA",  "PI",     "PHI",    "PSI",
-"RHO",      "SIGMA",  "THETA",  "TAU",    "XI",    "ZETA"
-};
//GO.SYSIN DD textr/GREEK.h
echo textr/README 1>&2
sed >textr/README <<'//GO.SYSIN DD textr/README' 's/^-//'
-Please read this file before you install the program.
-
-Troff-to-TeX translator version .5, October, 16, 1986.
-
-Copyright (C) 1986 Kamal Al-Yahya.
-Copying of this package is permitted without prior permission
-provided it is not done for profit, this copyright notice is kept, and
-any changes made to the package are clearly documented.
-
-I would very much appreciate any comments or suggestions. My e-net
-address is		kamal@hanauma.stanford.edu
-(You might have some problems reaching me directly on this address.)
-
-Please, note that this is a preliminary version. Known bugs are
-documented in the bugs file. There will certainly be unexpected bugs.
-Some bugs will not cause the translated document to be unprintable but
-will give a result different from your what you expect.
-The program may not do a 100% translation the first time. However,
-having it do 90% (or even more) is very much possible unless you have
-one of those papers that give horrible math combinations.
-
-Currently, the program translates most ms macros, most equations, and
-some plain troff commands. man macros are not included yet, so translation
-of manuals (especially the headers and footers) may not be good enough.
-
-
-			INSTALLATION INSTRUCTIONS
-
-In short, type ``make'' and then run it on the document (try the testfile):
-		textr testfile > testfile.tex
-
-In details:
-
-- In the makefile, define the destination of the executable (default is
-  current directory). Also, if the optimizer in your machine is
-  buggy, delete the -O flag.
-- type ``make'' to produce the executable, called ``textr''.
-- The program needs a \lefheader{}, \rightheader{}, and \footer{} macros
-  that we have on our sight but is not included in sep.tex. (The reason is
-  that it is pretty complicated with latex; it involves creating
-  a new pagestyle). You don't have to add these macros to sep.tex, but
-  if the document changes headers and footers, you may want to do it manually
-  in the translated document.
-- move sep.tex to your macros directory.
-
-			USING THE TRANSLATOR
-
-You can run the program either by
-		textr < file  > file.tex
-or
-		textr file  > file.tex
-You are most likely to get messages on the standard error telling
-you about things it encounters and cannot do.
-
-Now you have the translated document. Look at it and see if you
-can spot a major error. Run it through latex. If it runs and produces
-the dvi, then print it. If you get latex error messages modify
-the translated document accordingly and repeat the latex run, and so on.
-I usually get away with one or two iterations.
-
-
//GO.SYSIN DD textr/README
echo textr/README2 1>&2
sed >textr/README2 <<'//GO.SYSIN DD textr/README2' 's/^-//'
-I received many requests for an early version of the troff-to-tex
-translator, much more than I'd anticipated!
-Besides the large number of requests, mail to/from our system is terrible.
-Some of those who tried to reach me, were not able to do so.
-On my part, I was also unable to reply to some people;  mail keeps
-coming back.
-
-I therefore apologize that I cannot fulfill individual requests
-with one exception.
-The exception is that you don't have ftp and my mail to you does
-not bounce back!
-
-I will send it to be put on the distribution tape sooner than I'd planed.
-Since we don't have anonymous ftp on our system, I will also send it
-NOW to the University of Washington so that you can ftp it from there.
-
-PLEASE NOTE:    this is a preliminary release. Unexpected bugs are not
-		impossible (known bugs are documented). Also,
-		there are unrecognized troff commands that will be
-		added in the future if necessary.
-
-Some notes about the translator:
-- I concentrated on math mode and ms macros. They constitute the bulk
-  of the papers written here. I have used it to translate a few documents
-  with no problems. It also has some plain nroff-troff macros, but
-  not many (since people here rarely use them, it was OK).
-- I decided to make the translated document to be in LaTeX not plain TeX
-  since LaTeX is more widely used here.
-- The translator is written in C.
-- documentation is scarce; will add more in the future.
//GO.SYSIN DD textr/README2
echo textr/bugs 1>&2
sed >textr/bugs <<'//GO.SYSIN DD textr/bugs' 's/^-//'
-This is a list of the known bugs. Many of them are not serious
-and LaTeX will process the translated documnet (although it will look
-somewhat different).
-
-- does not do tables
-- only one argument for troff macros is taken
-- IP is treated as LP
-- when some operators (notably over, sub and sup) are renamed (via define),
-  then they are encountered in the text, textr will treat them as
-  ordinary macros and will not apply their rules
-- rpile, lpile and cpile are treated the same as pile
-- rcol, lcol are treated the same as ccol
-- troff commands that are not separated from their argument by a space, are
-  not properly parsed (e.g .sp3i)
-- lineup and mark are ignored. The rules are so different
-- some macro arguments are not recognized
-- .ul is treated like the .cu (i.e continuous underlining)
-- changing line spacing is ignored
-- only math defines are recognized; .de defines are not
-- math size, gsize, fat, and gfont are ignored
-
-Diagnostics:
-- TeX will complain about vague sub and sup nesting like a sub i sub k,
-  but it will run
-- LaTeX will complain about an unnecessary \newline, but will run
//GO.SYSIN DD textr/bugs
echo textr/flip.h 1>&2
sed >textr/flip.h <<'//GO.SYSIN DD textr/flip.h' 's/^-//'
-/*
-This file contains the words that are placed the opposite way
-in troff and TeX. Is there any more?
-*/
-char *flip_list[] =
-{
-"hat",   "under",   "bar",   "vec",   "dot",   "dotdot",   "tilde"
-};
//GO.SYSIN DD textr/flip.h
echo textr/makefile 1>&2
sed >textr/makefile <<'//GO.SYSIN DD textr/makefile' 's/^-//'
-CFLAGS = -O
-B =
-
-clean:
-	rm -f *.o core *junk*
-
-textr: textr.o tr.o subs.o
-	cc $(CFLAGS) textr.o tr.o subs.o -o $Btextr
-# I removed an -lsep from above
-
-textr.o: textr.c setups.h
-	cc $(CFLAGS) -c textr.c
-tr.o: tr.c setups.h
-	cc $(CFLAGS) -c tr.c
-subs.o: subs.c setups.h similar.h GREEK.h flip.h troff_mac.h mathcom.h
-	cc $(CFLAGS) -c subs.c
//GO.SYSIN DD textr/makefile
echo textr/mathcom.h 1>&2
sed >textr/mathcom.h <<'//GO.SYSIN DD textr/mathcom.h' 's/^-//'
-/*
-This file contains a list of the words that have simple
-correspondence in the two languages.
-Do not put here words that require action (like sub).
-If the word is identical in the two languages (except for TeX's backslash),
-put it in similar.h
-*/
-
-struct math_equiv {
-	char *troff_symb, *tex_symb;
-} math[] = {
-/*	troff name		TeX name		*/
-
-	"inf",			"\\infty",
-	"union",		"\\cup",
-	"inter",		"\\cap",
-	"grad",			"\\nabla",
-	"pile",			"\\matrix",
-	"cpile",		"\\matrix",
-	"lpile",		"\\matrix",
-	"rpile",		"\\matrix",
-	"above",		"\\cr",
-	"~",			"\\ ",
-	"^",			"\\,",
-	"half",			"{1\\over 2}",
-	"nothing",		"",
-	"fat",			"",
-	"mark",			"",
-	"lineup",		""
-};
//GO.SYSIN DD textr/mathcom.h
echo textr/sep.tex 1>&2
sed >textr/sep.tex <<'//GO.SYSIN DD textr/sep.tex' 's/^-//'
-% You need these macros since they are refered to by the translator.
-% You can modify them if you want.
-
-\batchmode		% turn off interaction
-\documentstyle[11pt]{article}
-\textheight=9in
-\textwidth=6.4in
-\begin{document}
-\oddsidemargin=-.2in
-\voffset=-.1in
-\newdimen\singlespacing
-\singlespacing=11pt     % single line spacing
-\newfont{\bigbf}{ambx10 scaled\magstep 3}
-
-%  one-line title
-\def\title#1{\vbox{\vskip 1in\centerline{{\bigbf #1}}\vskip .3in}}
-
-\normalbaselineskip=18pt     % 1.5 line spacing
-\baselineskip=\normalbaselineskip
-\def\addspacing#1{\addtolength{\baselineskip}{#1\baselineskip}}
-
-% author
-\def\author#1{ \centerline{\it #1} \vskip .1cm}
-\def\authoraff#1{ \centerline{\rm #1} \vskip .2in}
-% centered section heading
-\def\mhead#1{ \vskip .3in \centerline{\bf #1} \nobreak \medskip}
-% subheading
-\def\shead#1{ \vskip .20in \leftline{\bf #1} \nobreak \smallskip}
-% define ABSTRACT, INTRODUCTION, DISCUSSION, CONCLUSIONS, REFERENCES,
-% and APPENDIX as the first three letters
-\def\ABS{\mhead{ABSTRACT}}
-\def\INT{\mhead{INTRODUCTION}}
-\def\DIS{\mhead{DISCUSSION}}
-\def\CON{\mhead{CONCLUSIONS}}
-\def\ACK{\mhead{ACKNOWLEDGMENTS}}
-\def\REF{\mhead{REFERENCES}}
-\def\APP{\mhead{APPENDIX}}
-
-% reference macro, second ... lines are indented
-\newdimen\dtmp     % temporary dimension variable
-\def\reference#1{ \baselineskip=\singlespacing \dtmp=\hsize
-		\advance\dtmp by-\parindent \parshape 2 0in \hsize \parindent
-		\dtmp \noindent #1 \endgraf \baselineskip=\normalbaselineskip
-		\vskip4pt
-		}
//GO.SYSIN DD textr/sep.tex
echo textr/setups.h 1>&2
sed >textr/setups.h <<'//GO.SYSIN DD textr/setups.h' 's/^-//'
-/* setup file */
-
-#include        <stdio.h>
-#include        <strings.h>
-#include        <ctype.h>
-#include        <sys/ioctl.h>
-#include        <sgtty.h>
-#define	MAXLEN	32000		/* maximum length of document */
-#define	MAXWORD	250		/* maximum word length */
-#define	MAXLINE	500		/* maximum line length */
-#define	MAXDEF	200		/* maximum number of defines */
-struct defines {
-	char *def_macro;
-	char *replace;
-	int legal;
-} define[MAXDEF];
//GO.SYSIN DD textr/setups.h
echo textr/similar.h 1>&2
sed >textr/similar.h <<'//GO.SYSIN DD textr/similar.h' 's/^-//'
-/*
-This file contains a list of math words that are similar in the
-two languages (in fact identical except for TeX's backslah).
-If I overlooked anything out, it can be put here
-Do NOT put here words that are similar but require some action (like over)
-*/
-char *similar_list[] =
-{
-"alpha",   "beta",    "gamma",   "delta",    "chi",   "epsilon",
-"eta",     "kappa",   "lambda",  "mu",       "nu",    "omega",
-"pi",      "phi",     "psi",     "rho",      "sigma", "theta",
-"tau",     "xi",      "zeta",    "approx",   "int",   "sqrt",
-"lim",     "matrix",  "partial", "sin",      "sinh",  "cos",
-"cosh",    "tan",     "tanh",    "cot",      "coth",  "exp",
-"log",     "prod",    "times",    "sum",     "prime"
-};
//GO.SYSIN DD textr/similar.h
echo textr/subs.c 1>&2
sed >textr/subs.c <<'//GO.SYSIN DD textr/subs.c' 's/^-//'
-/* 
-These subroutines do (in general) small things for the translator.
-*/
-
-#include        "setups.h"
-#include        "similar.h"
-#include        "GREEK.h"
-#include        "flip.h"
-#include        "mathcom.h"
-#include        "troff_mac.h"
-
-extern int def_count;
-
-/* compile-time counting of elements */
-int GREEK_count = (sizeof(GREEK_list)/sizeof(GREEK_list[0]));
-int similar_count = (sizeof(similar_list)/sizeof(similar_list[0]));
-int flip_count = (sizeof(flip_list)/sizeof(flip_list[0]));
-int mathcom_count = (sizeof(math)/sizeof(struct math_equiv));
-int macro_count = (sizeof(macro)/sizeof(struct macro_table));
-
-tmpbuf(in,buffer)		/* copy input to buffer */
-/* copy input to buffer, buffer holds only MAXLEN characters */
-FILE *in;
-char *buffer;
-{
-int l=0;
-
-while (l++ < MAXLEN && (*buffer = getc(in)) != EOF)
-	buffer++;
-if (l >= MAXLEN)
-	{
-	fprintf(stderr,"WARNING: document is too large\n");
-	exit(-1);
-	}
-*buffer = NULL;
-}
-
-scrbuf(in,out)			/* copy input to output */
-FILE *in,*out;
-{
-int c;
-while ((c =getc(in)) != EOF)	putc(c,out);
-}
-
-getword(inbuf,w)		/* get an alphanumeric word (dot also) */
-char *inbuf, *w;
-{
-int c,i;
-
-for (i=0; (c = *inbuf++) != NULL
-	&& (isalpha(c) || isdigit(c) || c == '.') && i < MAXWORD; i++)
-		w[i] = c;
-if (i == 0 && c != NULL)
-	w[i++] = c;
-w[i] = NULL;
-return(i);
-}
-
-get_defword(inbuf,w,legal)		/* get the "define" word */
-char *inbuf, *w;			/* delited by space only */
-int *legal;
-{
-int c,i;
-
-*legal = 0;
-for (i=0; (c = *inbuf++) != NULL && c != ' ' && c != '\n'
-		&& c != '\t' && i < MAXWORD; i++)
-	{
-	w[i] = c;
-	if (isalpha(c) == 0)	*legal = 1;	/* illegal TeX macro */ 
-	}
-w[i] = NULL;
-return(i);
-}
-
-getdef(inbuf,ww)		/* get the define substitution */
-char *inbuf, *ww;
-{
-int c,i,len;
-int def_delim;
-char w[MAXWORD];
-
-def_delim = *inbuf++;		/* take first character as delimiter */
-len=1;		i=0;
-while ((c = *inbuf++) != NULL && c != def_delim && i < MAXWORD)
-	{
-	len++;
-	if (c != '\"')		w[i++] = c;
-	}
-w[i] = NULL;
-len++;
-if (c != def_delim)
-{
-fprintf(stderr,"WARNING: missing right delimiter for define, define=%s\n",w);
-len--;
-}
-troff_tex(w,ww,1);		/* now translate the substitution */
-return(len);
-}
-
-get_no_math(inbuf,w)		/* get text surrounded by quotes in math mode */
-char *inbuf, *w;
-{
-int c,i;
-
-for (i=0; (c = *inbuf++) != NULL && c != '\"' && i < MAXWORD; i++)
-		w[i] = c;
-w[i] = NULL;
-return(i);
-}
-
-similar(w)			/* check if w is in the similar list */
-char *w;
-{
-int i;
-
-for (i=0; i < similar_count ; i++)
-	{
-	if (strcmp(similar_list[i],w) == 0)
-		return(1);
-	}
-return(-1);
-}
-
-GREEK(w)			/* check if w is in the GREEK list */
-char *w;
-{
-int i;
-
-for (i=0; i < GREEK_count ; i++)
-	{
-	if (strcmp(GREEK_list[i],w) == 0)
-		return(1);
-	}
-return(-1);
-}
-
-Greek(w,ww)			/* change GREEK to Greek */
-char *w, *ww;
-{
-*ww++ = '\\';		*ww++ = *w;
-while(*w++ != NULL)
-	*ww++ = tolower(*w);
-*ww = NULL;
-}
-
-skip_white(inbuf)		/* skip white space */
-char *inbuf;
-{
-int c,len;
-
-len=0;
-while ((c = *inbuf++) == ' ' || c == '\t' || c == '\n')
-		len++;
-return(len);
-}
-
-skip_line(inbuf)		/* ignore the rest of the line */
-char *inbuf;
-{
-int len;
-
-len=0;
-while (*inbuf++ != '\n')
-	len++;
-return(len+1);
-}
-
-get_arg(inbuf,w,rec,eq)		/* get next word */
-char *inbuf, *w;
-int rec,eq;			/* eq=1 means math mode */
-{
-int c,len,i;
-char ww[MAXWORD];
-
-len=0;
-while ((c = *inbuf) == ' ' || c == '\t')	/* skip spaces and tabs */
-		{inbuf++;	len++;}
-i=0;
-while ((c = *inbuf++) != NULL && c != ' ' && c != '\t' && c != '\n'
-		&& c != '$' && c != '}' && c != '~' && i < MAXWORD)
-		{ww[i++] = c;	len++;}
-ww[i] = NULL;
-if (rec == 1)				/* check if recursion is rquired */
-	troff_tex(ww,w,eq);
-else
-	strcpy(w,ww);
-return(len);
-}
-
-get_sub_arg(inbuf,w)		/* get the argument for sub and sup */
-char *inbuf, *w;
-{
-int c,len,i;
-char ww[MAXWORD], tmp[MAXWORD];
-
-len=0;
-while ((c = *inbuf) == ' ' || c == '\t')
-		{inbuf++;	len++;}
-i=0;
-while ((c = *inbuf++) != NULL && c != ' ' && c != '\t' && c != '\n'
-		&& c != '$' && c != '}' && c != '~' && i < MAXWORD)
-		{ww[i++] = c;	len++;}
-ww[i] = NULL;
-if (strcmp(ww,"roman") == 0  || strcmp(ww,"bold") == 0 || strcmp(w,"italic") == 0)
-	{
-	get_arg(inbuf,tmp,0,0);
-	sprintf(ww,"%s%c%s",ww,c,tmp);
-	len += strlen(tmp)+1;
-	}
-troff_tex(ww,w,1);		/* recursive */
-return(len);
-}
-
-get_line(inbuf,w,rec)		/* get the rest of the line */
-char *inbuf, *w;
-int rec;			/* rec=1 means recursion is required */
-{
-int c,i,len;
-char ww[MAXLINE];
-
-i=0;	len=0;
-while ((c = *inbuf) == ' ' || c == '\t')
-		{inbuf++;	len++;}
-while ((c = *inbuf++) != NULL && c != '\n' && len < MAXLINE)
-		{ww[i++] = c;	len++;}
-ww[i] = NULL;
-if (rec == 1)
-	troff_tex(ww,w,0);
-else
-	strcpy(w,ww);
-return(len);
-}
-
-is_def(w)		/* check if w was defined by the user */
-char *w;
-{
-int i;
-
-for (i=0; i < def_count; i++)
-	{
-	if (strcmp(define[i].def_macro,w) == 0)
-		return(i);
-	}
-return(-1);
-}
-
-is_mathcom(w,ww)	/* check if w has a simple correspondence in TeX */
-char *w,*ww;
-{
-int i;
-
-for (i=0; i < mathcom_count; i++)
-	{
-	if (strcmp(math[i].troff_symb,w) == 0)
-		{
-		strcpy(ww,math[i].tex_symb);
-		return(i);
-		}
-	}
-return(-1);
-}
-
-is_troff_mac(w,ww,arg)	/* check if w is a macro or plain troff command */
-char *w,*ww;
-int *arg;
-{
-int i;
-
-for (i=0; i < macro_count; i++)
-	{
-	if (strcmp(macro[i].troff_mac,w) == 0)
-		{
-		strcpy(ww,macro[i].tex_mac);
-		*arg = macro[i].arg;
-		return(i);
-		}
-	}
-return(-1);
-}
-
-is_flip(w)		/* check if w is in the flip list */
-char *w;
-{
-int i;
-
-for (i=0; i < flip_count; i++)
-	{
-	if (strcmp(flip_list[i],w) == 0)
-		return(i);
-	}
-return(-1);
-}
-
-flip(outbuf,w)			/* do the flipping */
-char *outbuf, *w;
-{
-int len = 0;
-char ww[MAXWORD], tmp[MAXWORD];
-int white;
-
-outbuf--;
-white = 1;
-while (*outbuf == ' ' || *outbuf == '\t' || *outbuf == '\n')
-	{ outbuf--;	white++;}
-while (*outbuf != ' ' && *outbuf != '\t' && *outbuf != '\n' && *outbuf != '{')
-	{ outbuf--;	white++;}
-outbuf++;	white--;
-if (*outbuf == '\\')
-	{
-	outbuf++;
-	getword(outbuf,tmp);
-	sprintf(ww,"\\%s",tmp);
-	outbuf--;
-	}
-else
-	getword(outbuf,ww);
-*outbuf = NULL;
-if (strcmp(w,"under") == 0)
-	{
-	sprintf(outbuf,"\\underline %s",ww);
-	len = strlen(ww) + 11 - white;
-	}
-else if (strcmp(w,"dotdot") == 0)
-	{
-	sprintf(outbuf,"\\ddot %s",ww);
-	len = strlen(ww) + 6 - white;
-	}
-else
-	{
-	sprintf(outbuf,"\\%s %s",w,ww);
-	len = strlen(ww) + strlen(w) + 2 - white;
-	}
-return(len);
-}
-
-flip_twice(outbuf,w,ww)		/* take care of things like x hat under */
-char *outbuf, *w, *ww;
-{
-int len = 0;
-char tmp1[MAXWORD], tmp2[MAXWORD];
-int white;
-
-outbuf--;	white = 1;
-while (*outbuf == ' ' || *outbuf == '\t' || *outbuf == '\n')
-	{outbuf--;	white++;}
-while (*outbuf != ' ' && *outbuf != '\t' && *outbuf != '\n' && *outbuf != '{')
-	{outbuf--;	white++;}
-outbuf++;	white--;
-if (*outbuf == '\\')
-	{
-	outbuf++;
-	getword(outbuf,tmp2);
-	sprintf(tmp1,"\\%s",tmp2);
-	outbuf--;
-	}
-else
-	getword(outbuf,tmp1);
-*outbuf = NULL;
-if (strcmp(w,"under") == 0)
-	{
-	strcat(outbuf,"\\underline{");
-	len = 11;
-	}
-else if (strcmp(w,"dotdot") == 0)
-	{
-	strcat(outbuf,"\\ddot{");
-	len = 6;
-	}
-else
-	{
-	sprintf(outbuf,"\\%s{",w);
-	len = strlen(w) + 2;
-	}
-outbuf += len;
-if (strcmp(ww,"under") == 0)
-	{
-	sprintf(outbuf,"\\underline %s}",tmp1);
-	len += strlen(tmp1) + 12 - white;
-	}
-else if (strcmp(ww,"dotdot") == 0)
-	{
-	sprintf(outbuf,"\\ddot %s}",tmp1);
-	len += strlen(tmp1) + 7 - white;
-	}
-else
-	{
-	sprintf(outbuf,"\\%s %s}",ww,tmp1);
-	len += strlen(tmp1) + strlen(ww) + 3 - white;
-	}
-return(len);
-}
-
-remove_extra_braces(inbuf,w)		/* get rid of unnecessary braces */
-char *inbuf, *w;			/* (that cause problems!) */
-{
-int i,c;
-int left_brace=0, right_brace=0;
-char ww[MAXLINE];
-
-inbuf++;
-for (i=0; (c = *inbuf++) != NULL && i < MAXLINE; i++)
-		{
-		if (c == '{')	left_brace++;
-		if (c == '}')	right_brace++;
-		if (right_brace > left_brace)
-			break;
-		ww[i] = c;
-		}
-ww[i++] = NULL;
-troff_tex(ww,w,1);
-return(i);
-}
-
-get_over_arg(inbuf,ww)		/* get the denominator of over */
-char *inbuf, *ww;
-{
-char w[MAXWORD], tmp[MAXWORD];
-
-inbuf += getword(inbuf,w);		/* read first word */
-inbuf += getword(inbuf,tmp);		/* read second word */
-/* as long as there is a sup or sub read the next two words */
-while (strcmp(tmp,"sub") == 0 || strcmp(tmp,"sup") == 0)
-	{
-	strcat(w,tmp);
-	inbuf += getword(inbuf,tmp);
-	strcat(w,tmp);
-	inbuf += getword(inbuf,tmp);
-	}
-troff_tex(w,ww,1);
-return(strlen(w));
-}
//GO.SYSIN DD textr/subs.c
echo textr/testfile 1>&2
sed >textr/testfile <<'//GO.SYSIN DD textr/testfile' 's/^-//'
-.EQ
-delim $$
-gsize 11
-define dC "delta C"
-define xx 'x sup x'
-define B 'bold B'
-define (( 'left ('
-define )) 'right )'
-define ov 'over'
-.EN
-.ds LH Is $beta$ a real number?
-.ds RH Right Header
-.ds CF SEP-50
-.TL  	
-Testing the troff-to-tex translator
-.AU  		
-Kamal Al-Yahya
-.AI
-Stanford University
-.AB
-This is an abstract. The word ``abstract'' should appear as a heading
-(since I did not use the ``no'' option). In some sites, like ours, it is
-suppressed. The translated document will have it anyway.
-.AE
-.PP
-Now let's test some equations:
-.EQ (1)
-2 left ( 1 ~+~ sqrt{omega sub i+1 + zeta -{x+1} over {THETA +1} y + 1} right )
-~~~=~~~ 1
-.EN
-.EQ
-left [
-matrix {
-   ccol { e sub 1 above . above . above e sub i above . above . above e sub N }
-}
-right ] sub n+1 ~~=~~ y + 1
-.EN
-.EQ
-bold X + roman a ~>=~
-a tilde fwd 20 sum from i to N lim from {x -> k} dC
-.EN
-.EQ
-(( "speed" times "time" = "distance travelled" ))
-.EN
-.EQ
-beta sub i >= zeta dC
-.EN
-.PP
-In-line math like $beta +1$ is surrounded by math delimiters, as
-defined by
-.B delim.
-.I
-This sentence appears in italic.
-.R
-Now back to the regular font.
-.IP
-Tables are not translated (too painful!).
-\" .TS
-\" table commands would go here.
-\" .TE
-This is a footnote.
-.FS
-This text appears in the footnote.
-.FE
-\" this is commented text
-.PP
-Now we start a figure.
-.Is
-.sp 3i
-.Ic 1
-This is the captions of the figure.
-.Ie
-.PP
-Try some floating objects.
-.br
-.KS
-This text should be kept in one page. i.e. a page break is discouraged here.
-.KE
-.br
-Now a floating text.
-.KF
-This text should be kept in one page even if we had to move it around,
-since it is a
-.I floating
-object. This is a boxed
-.BX word.
-.KE
-.br
-These characters are special in TeX, so they need to be escaped
-in the translation % & # _ .
-.PP
-Now some backslash commands: \fBbold \fRroman \f2italic.
-\f1Back to roman.
-.Ac
-Thanks to everyone who helped.
-.Re
-Many books were used as references.
-.Re
-Many manuals were also used.
//GO.SYSIN DD textr/testfile
echo textr/textr.c 1>&2
sed >textr/textr.c <<'//GO.SYSIN DD textr/textr.c' 's/^-//'
-/* textr: troff to tex translator */
-/* Author: Kamal Al-Yahya, Stanford University,		9/4/86 */
-
-char *documentation[] = {
-" SYNTAX",
-"        textr file1 file2 ...",
-"or",
-"        textr < file1 file2 ...",
-"",
-};
-
-int	doclength = { sizeof documentation/sizeof documentation[0] };
-
-#include        "setups.h"
-
-FILE *out_file;
-struct sgttyb ttystat;
-extern char *strcpy(), *mktemp();
-char scratch_file[MAXWORD];
-
-int xargc;
-char **xargv;
-
-main(argc,argv)
-int argc; 
-char *argv[];
-{
-char inbuf[MAXLEN],outbuf[MAXLEN];
-FILE *temp,*scr;
-register char *cptr;
-int piped_in;
-int i;
-
-/* 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);
-	}
-
-out_file = stdout;		/* default output */
-
-/* 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,"/tmp/texXXXXXX");
-	mktemp(scratch_file);
-	scr=fopen(scratch_file,"w");
-	scrbuf(stdin,scr);
-	fclose(scr);
-	scr=fopen(scratch_file,"r");
-	unlink(scratch_file);
-	tmpbuf(scr,inbuf);
-	fclose(scr);
-	troff_tex(inbuf,outbuf,0);
-	fprintf(out_file,"\\input sep\n");
-	fprintf(out_file,"%s",outbuf);
-	fprintf(out_file,"%s","\\end{document}\n");
-	}
-
-/* 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")) != NULL)
-		{
-		tmpbuf(temp,inbuf);
-		fclose(temp);
-		troff_tex(inbuf,outbuf,0);
-		fprintf(out_file,"\\input sep\n");
-		fprintf(out_file,"%s",outbuf);
-		fprintf(out_file,"%s","\\end{document}\n");
-		}
-	else
-		fprintf(stderr,"textr: Cannot open %s\n",cptr);
-	}
-
-}
//GO.SYSIN DD textr/textr.c
echo textr/tr.c 1>&2
sed >textr/tr.c <<'//GO.SYSIN DD textr/tr.c' 's/^-//'
-#include        "setups.h"
-int def_count = 0;
-
-troff_tex(inbuf,outbuf,eq)
-char *inbuf,*outbuf;
-int eq;
-{
-char eqn_no[MAXWORD], w[MAXWORD], ww[MAXLINE];
-char tmp[MAXWORD];
-char *p;
-int len,c,c1,c2,i,j;
-int ref = 0;
-int put_brace = 0;
-int first_word = 1;
-int arg = 0;
-int legal = 0;
-int floating = 0;
-int ds_warned = 0;
-static char DELIM[1];
-float flen;
-extern char *malloc();
-
-strcpy(DELIM,"$");		/* math delimiter */
-*outbuf = NULL;		tmp[0] = NULL;
-while (getword(inbuf,w) > 0)
-	{
-	len=strlen(w);
-	c1 = *--inbuf;
-	c2 = *++inbuf;
-	inbuf += len;
-/* first check if we are in an equation */
-	if (eq == 1)
-		{
-		if (strcmp(w,"delim") == 0)
-			{
-			inbuf += skip_white(inbuf);
-			DELIM[0] = *inbuf;
-			inbuf += 2;
-			inbuf += skip_line(inbuf);
-			}
-		else if (strcmp(w,DELIM) == 0)
-			{
-			eq = 0;
-			strcat(outbuf,"$");
-			outbuf++;
-			}
-		else if (strcmp(w,"left") == 0 || strcmp(w,"right") == 0)
-			{
-			inbuf += skip_white(inbuf);
-			len = getword(inbuf,ww);
-			if (strcmp(ww,"nothing") == 0)
-				inbuf += len;
-			else
-				{
-				sprintf(outbuf,"\\%s",w);
-				outbuf += strlen(w)+1;
-				if (strcmp(ww,"floor") == 0)
-					{
-					inbuf += len;
-					if (strcmp(w,"left") == 0)
-						strcat(outbuf,"\\lfloor");
-					else
-						strcat(outbuf,"\\rfloor");
-					outbuf += 7;
-					}
-				else if (*inbuf == '{' || *inbuf == '}')
-					{
-					strcat(outbuf,"\\");
-					outbuf++;
-					}
-				}
-			}
-		else if (strcmp(w,"size") == 0)
-			inbuf += get_arg(inbuf,ww,0,0);
-		else if (strcmp(w,"gsize") == 0 || strcmp(w,"gfont") == 0)
-			inbuf += skip_line(inbuf);
-		else if (strcmp(w,"ccol") == 0 || strcmp(w,"lcol") == 0 ||
-			 strcmp(w,"rcol") == 0)
-			{
-			inbuf += skip_white(inbuf);
-			if (*inbuf != '{')
-				fprintf(stderr,"expecting left brace after ccol\n");
-			inbuf += remove_extra_braces(inbuf,ww) + 2;
-			strcat(outbuf,ww);
-			outbuf += strlen(ww);
-			}
-		else if (strcmp(w,"bold") == 0 || strcmp(w,"roman") == 0 ||
-			 strcmp(w,"italic") == 0)
-			{
-			inbuf += get_arg(inbuf,ww,0,0);
-			if (strcmp(w,"bold") == 0)
-				sprintf(outbuf,"{\\bf %s}",ww);
-			else if (strcmp(w,"roman") == 0)
-				sprintf(outbuf,"{\\rm %s}",ww);
-			else
-				sprintf(outbuf,"{\\it %s}",ww);
-			outbuf += strlen(ww) + 6;
-			}
-		else if (strcmp(w,"sup") == 0 || strcmp(w,"to") == 0 ||
-			 strcmp(w,"sub") == 0 || strcmp(w,"from") == 0)
-			{
-			while ((c = *--outbuf) == ' ' || c == '\t' || c == '\n') ;
-			*++outbuf = NULL;
-			if (strcmp(w,"sup") == 0 || strcmp(w,"to") == 0)
-				strcat(outbuf,"^");
-			else
-				strcat(outbuf,"_");
-			*++outbuf = NULL;
-			inbuf += skip_white(inbuf);
-			len = get_sub_arg(inbuf,ww);
-			inbuf += len;
-			if (len > 1)
-				{
-				sprintf(outbuf,"{%s}",ww);
-				outbuf += strlen(ww) + 2;
-				len = skip_white(inbuf);
-				inbuf += len;
-				getword(inbuf,ww);
-				if (strcmp(ww,"over") == 0)
-					put_brace = 1;
-				inbuf -= len;
-				}
-			else
-				{
-				strcat(outbuf,ww);
-				outbuf += len;
-				}
-			}
-		else if (strcmp(w,"define") == 0)
-			{
-			for (i=0; *--outbuf != '$' && i < MAXLEN; i++)
-				tmp[i] = *outbuf;
-			tmp[i] = NULL;
-			strcat(tmp,"$$");
-			*--outbuf = NULL;
-			inbuf += skip_white(inbuf);
-			get_defword(inbuf,w,&legal);
-			len=strlen(w);
-			inbuf += len;	
-			inbuf += skip_white(inbuf);
-			inbuf += getdef(inbuf,ww);
-			if (legal == 1)
-				{
-				define[def_count].legal = 1;
-				fprintf(stderr,
-					"illegal TeX macro, %s, replacing it\n",w);
-				p = (char *)malloc((unsigned)(strlen(ww)+1)*
-					sizeof(char));
-				strcpy(p,ww);
-				define[def_count].replace = p;
-				}
-			else
-				{
-				define[def_count].legal = 0;
-				sprintf(outbuf,"\\def\\%s{%s}\n",w,ww);
-				outbuf += len+strlen(ww)+8;
-				}
-			p = (char *)malloc((unsigned)(len+1)*sizeof(char));
-			strcpy(p,w);
-			define[def_count++].def_macro = p;
-			inbuf += skip_white(inbuf);
-			for (j=i+1; j >= 0; j--)
-				*outbuf++ = tmp[j];
-			tmp[0] = NULL;
-			}
-		else if (strcmp(w,"=") == 0)
-			{
-			if (*inbuf == '=')
-				{
-				inbuf++;
-				strcat(outbuf,"\\equiv");
-				outbuf += 6;
-				}
-			else
-				{strcat(outbuf,"=");	outbuf++;}
-			}
-		else if (strcmp(w,"<") == 0 || strcmp(w,">") == 0)
-			{
-			if (*inbuf == '=')
-				{
-				inbuf++;
-				if (strcmp(w,"<") == 0)
-					strcat(outbuf,"\\le");
-				else
-					strcat(outbuf,"\\ge");
-				outbuf += 3;
-				}
-			}
-		else if (strcmp(w,"-") == 0)
-			{
-			if (*inbuf == '>')
-				{
-				inbuf++;
-				strcat(outbuf,"\\to");
-				outbuf += 3;
-				}
-			else
-				{strcat(outbuf,"-");	outbuf++;}
-			}
-		else if (strcmp(w,".EN") == 0)
-			{
-			eq=0;
-			if ((len=strlen(eqn_no)) > 0)
-				{
-				sprintf(outbuf,"\\eqno %s",eqn_no);
-				outbuf += len + 6;
-				}
-			eqn_no[0] = NULL;
-			c1 = *--outbuf;
-			c2 = *--outbuf;
-			if (c1 == '\n' && c2 == '$')
-				*--outbuf = NULL;
-			else
-				{
-				outbuf += 2;
-				strcat(outbuf,"$$");
-				outbuf += 2;
-				}
-			}
-		else if (c2 == '\"')
-			{
-			inbuf -= len-1;
-			len = get_no_math(inbuf,ww);
-			inbuf += len+1;
-			sprintf(outbuf,"\\ \\it\\hbox{%s}",ww);
-			outbuf += len+12;
-			}
-		else if (strcmp(w,"up") == 0 || strcmp(w,"down") == 0
-			 || strcmp(w,"fwd") == 0 || strcmp(w,"back") == 0)
-			{
-			if (strcmp(w,"up") == 0)
-				{
-				strcat(outbuf,"\\raise");
-				outbuf +=6;
-				strcpy(tmp,"ex");
-				}
-			else if (strcmp(w,"down") == 0)
-				{
-				strcat(outbuf,"\\lower");
-				outbuf +=6;
-				strcpy(tmp,"ex");
-				}
-			else if (strcmp(w,"fwd") == 0)
-				{
-				strcat(outbuf,"\\kern");
-				outbuf +=5;
-				strcpy(tmp,"em");
-				}
-			else if (strcmp(w,"back") == 0)
-				{
-				strcat(outbuf,"\\kern-");
-				outbuf +=6;
-				strcpy(tmp,"em");
-				}
-			inbuf += skip_white(inbuf);
-			inbuf += getword(inbuf,ww);
-			len = atoi(ww);		flen = len/100.;
-			ww[0] = NULL;
-			sprintf(outbuf,"%4.2f%s",flen,tmp);
-			outbuf += 6;
-			}
-		else if (strcmp(w,"over") == 0)
-			{
-			if (!first_word)
-				{
-				outbuf--;
-				for (i=0; *outbuf == ' ' || *outbuf == '\t' ||
-						*outbuf =='\n'; i++)
-					outbuf--;
-				if (*outbuf == '}' && put_brace == 0)
-					*outbuf = ' ';
-				else
-					{
-					for ( ; !(*outbuf == ' ' || *outbuf == '\t'
-						|| *outbuf =='\n'); i++)
-						outbuf--;
-					*outbuf-- = '{';
-					if (*outbuf == '\\')	*outbuf = ' ';
-					outbuf++;
-					put_brace = 0;
-					}
-				outbuf += i+1;
-				}
-			strcat(outbuf,"\\over");
-			outbuf += 5;
-			inbuf += skip_white(inbuf);
-			strcat(outbuf," ");	outbuf++;
-			if (*inbuf == '{')
-				inbuf++;
-			else
-				{
-				inbuf += get_over_arg(inbuf,ww);
-				sprintf(outbuf,"%s",ww);
-				outbuf += strlen(ww);
-				if (*inbuf != NULL)
-					{strcat(outbuf,"}"); outbuf++;}
-				}
-			}
-		else if (similar(w) > 0)
-			{
-			sprintf(outbuf,"\\%s",w);
-			outbuf += len+1;
-			}
-		else if (GREEK(w) > 0)
-			{
-			Greek(w,ww);
-			len=strlen(ww);
-			strcat(outbuf,ww);
-			outbuf += len;
-			}
-		else if (is_flip(w) >= 0)
-			{
-			if (!first_word)
-				{
-				len = skip_white(inbuf);
-				inbuf += len;
-				getword(inbuf,ww);
-				if (is_flip(ww) >= 0)
-					{
-					inbuf += strlen(ww);
-					len=flip_twice(outbuf,w,ww);  outbuf +=len;
-					}
-				else
-					{
-					inbuf -= len;
-					len = flip(outbuf,w);	outbuf += len;
-					}
-				}
-			else if (strcmp(w,"under") == 0)
-				{strcat(outbuf,"\\underline");	outbuf +=10;}
-			else if (strcmp(w,"dotdot") == 0)
-				{strcat(outbuf,"\\ddot");	outbuf +=5;}
-			else
-				{sprintf(outbuf,"\\%s",w); outbuf +=strlen(w)+1;}
-			}
-		else if (is_mathcom(w,ww) >=0 )
-			{
-			sprintf(outbuf,"%s",ww);
-			outbuf += strlen(ww);
-			}
-		else if (def_count > 0 && (i=is_def(w)) >= 0)
-			{
-			if (define[i].legal == 1)
-				{
-				sprintf(outbuf,"%s",define[i].replace);
-				outbuf += strlen(define[i].replace);
-				}
-			else
-				{
-				sprintf(outbuf,"\\%s",w);
-				outbuf += len+1;
-				}
-			}
-
-/* if none of the above equation sepcials matched, it is either
-   an an ordinary symbol or an illegal macro */
-
-		else
-			{
-			len = get_arg(inbuf,ww,0,0);
-			sprintf(tmp,"%s%s",w,ww);
-			if (def_count > 0 && (i=is_def(tmp)) >= 0)
-				{
-				inbuf += len;
-				sprintf(outbuf,"%s",define[i].replace);
-				outbuf += strlen(define[i].replace);
-				}
-			else
-				{
-				strcat(outbuf,w);
-				outbuf += strlen(w);
-				}
-			}
-		}
-
-/* check if it is a math delimiter; switch to math mode if so */
-
-	else if (strcmp(w,DELIM) == 0)
-		{
-		eq = 1;
-		strcat(outbuf,"$");
-		outbuf++;
-		}
-
-/* check if it is a non-equation troff command */
-
-	else if ((c2 == '.') && (c1 == '\n' || (first_word)))
-		{
-		if (strcmp(w,".TS") == 0)
-			fprintf(stderr,"I cannot do tables\n");
-		else if (strcmp(w,".B1") == 0)
-			fprintf(stderr,"I cannot do boxed lines\n");
-		else if (strcmp(w,".R") == 0 || strcmp(w,".rm") == 0 ||
-			 strcmp(w,".B") == 0 || strcmp(w,".bf") == 0 ||
-			 strcmp(w,".I") == 0 || strcmp(w,".it") == 0)
-			{
-			if (strcmp(w,".R") == 0 || strcmp(w,".rm") == 0)
-				strcpy(w,"rm");
-			else if (strcmp(w,".B") == 0 || strcmp(w,".bf") == 0)
-				strcpy(w,"bf");
-			else
-				strcpy(w,"it");
-			inbuf += get_arg(inbuf,ww,0,0);
-			if (ww[0] == NULL)
-				{
-				sprintf(outbuf,"\\%s",w);
-				outbuf += 3;
-				}
-			else
-				{
-				sprintf(outbuf,"{\\%s %s}",w,ww);
-				outbuf += strlen(ww) + 6;
-				}
-			}
-		else if (strcmp(w,".AB") == 0)
-			{
-			inbuf += get_arg(inbuf,ww,0,0);
-			if (strcmp(ww,"no") == 0)
-				{
-				strcat(outbuf,"\\bigskip");
-				outbuf += 8;
-				}
-			else
-				{
-				strcat(outbuf,"\\ABS");
-				outbuf += 4;
-				}
-			}
-		else if (strcmp(w,".Re") == 0)
-			{
-			if (ref == 0)
-				{
-				strcat(outbuf,"\\REF\n");
-				outbuf += 5;
-				}
-			ref ++;
-			inbuf += skip_line(inbuf);
-			inbuf += get_line(inbuf,ww,0);
-			sprintf(outbuf,"\\reference{%s}",ww);
-			outbuf += 12 + strlen(ww);
-			}
-		else if (strcmp(w,".Ic") == 0)
-			{
-			inbuf += get_arg(inbuf,ww,0,0);
-			sprintf(outbuf,"\\caption{%s",ww);
-			outbuf += strlen(ww) + 9;
-			}
-		else if (strcmp(w,".ds") == 0)
-			{
-			if (!ds_warned)
-				{
-				fprintf(stderr,"WARNING: header and footer commands I am putting may not work for your site\n");
-				ds_warned = 1;
-				}
-			inbuf += get_arg(inbuf,ww,0,0);
-			if (strcmp(ww,"LH") == 0)
-				{
-				inbuf += get_line(inbuf,ww,1);
-				sprintf(outbuf,"\\lefthead{%s}",ww);
-				outbuf += strlen(ww)+11;
-				}
-			else if (strcmp(ww,"RH") == 0)
-				{
-				inbuf += get_line(inbuf,ww,1);
-				sprintf(outbuf,"\\righthead{%s}",ww);
-				outbuf += strlen(ww)+12;
-				}
-			else if (strcmp(ww,"CF") == 0)
-				{
-				inbuf += get_line(inbuf,ww,0);
-				if (ww[0] != '%')
-					{
-					sprintf(outbuf,"\\footer{%s}",ww);
-					outbuf += strlen(ww)+9;
-					}
-				}
-			else fprintf(stderr,"I do not understand .ds %s\n",ww);
-			}
-		else if (strcmp(w,".KS") == 0)
-			{
-			strcat(outbuf,"{\\nobreak");
-			outbuf += 9;
-			}
-		else if (strcmp(w,".KF") == 0)
-			{
-			floating = 1;
-			strcat(outbuf,"\\begin{figure}");
-			outbuf += 14;
-			}
-		else if (strcmp(w,".KE") == 0)
-			{
-			if (floating)
-				{
-				strcat(outbuf,"\\end{figure}");
-				outbuf += 12;
-				}
-			else
-				{
-				strcat(outbuf,"}");
-				outbuf += 1;
-				}
-			floating = 0;
-			}
-		else if (strcmp(w,".BX") == 0)
-			{
-			inbuf += get_arg(inbuf,ww,1,0);
-			sprintf(outbuf,"\\fbox{%s}",ww);
-			outbuf += strlen(ww) + 7;
-			}
-		else if (strcmp(w,".FS") == 0)
-			{
-			inbuf += skip_line(inbuf);
-			inbuf += get_arg(inbuf,ww,1,0);
-			sprintf(outbuf,"\\footnote{%s",ww);
-			outbuf += strlen(ww) + 10;
-			}
-		else if (strcmp(w,".FE") == 0)
-			{
-			*--outbuf = NULL;
-			strcat(outbuf,"}");
-			outbuf++;
-			}
-		else if (strcmp(w,".sp") == 0)
-			{
-			inbuf += get_arg(inbuf,ww,0,0);
-			if (ww[0] == NULL)
-				{
-				strcat(outbuf,"\\newline");
-				outbuf += 8;
-				}
-			else
-				{
-				if (ww[strlen(ww)-1] == 'i')
-					{
-					sprintf(outbuf,"\\vskip%sn",ww);
-					outbuf += strlen(ww)+7;
-					}
-				else
-					{
-					len = atoi(ww);
-					for (i=0; i < len; i++)
-						{
-						strcat(outbuf,"\\newline");
-						outbuf += 8;
-						}
-					}
-				}
-			}
-		else if (strcmp(w,".ls") == 0)
-			{
-			fprintf(stderr,"I do not change spacing\n");
-			inbuf += skip_line(inbuf);
-			}
-		else if (strcmp(w,".EQ") == 0)
-			{
-			eq=1;
-			put_brace = 0;
-			strcat(outbuf,"$$");
-			outbuf += 2;
-			len=get_arg(inbuf,eqn_no,0,0);
-			if (strcmp(eqn_no,"I") == 0 || strcmp(eqn_no,"L") == 0)
-				{
-				fprintf(stderr,"lineups are ignored\n");
-				inbuf += len;
-				len = get_arg(inbuf,eqn_no,0,0);
-				}
-			if ((strlen(eqn_no)) > 0)
-				inbuf += len;
-			}
-		else if ((i=is_troff_mac(w,ww,&arg)) >= 0)
-			{
-			strcat(outbuf,ww);
-			outbuf += strlen(ww);
-			if (arg == 1) 
-				{
-				inbuf += skip_line(inbuf);
-				inbuf += get_line(inbuf,ww,1);
-				sprintf(outbuf,"{%s}",ww);
-				outbuf += strlen(ww)+2;
-				}
-			}
-		else 
-			{
-			fprintf(stderr,"I cannot translate troff macro %s\n",w);
-			inbuf += skip_line(inbuf);
-			}
-		}
-
-	else if (strcmp(w,"#") == 0 || strcmp(w,"&") == 0 ||
-		 strcmp(w,"_") == 0 || strcmp(w,"%") == 0)
-		{
-		sprintf(outbuf,"\\%s",w);
-		outbuf += 2;
-		}
-
-/* check for backslash commands */
-
-	else if (strcmp(w,"\\") == 0)
-		{
-		if (*inbuf == ' ' || *inbuf == '\t' || *inbuf == '\n')
-			*outbuf++ = *inbuf++;
-		else if (*inbuf == '"')
-			{
-			inbuf ++;
-			inbuf += get_line(inbuf,ww,0);
-			sprintf(outbuf,"%%%s",ww);
-			outbuf += strlen(ww)+1;
-			}
-		else if (*inbuf == '&')
-			inbuf++;
-		else if (*inbuf == '(')
-			{
-			c1 = *++inbuf;
-			c2 = *++inbuf;
-			inbuf++;
-			if (c1 == 'e' && c2 == 'm')
-				{
-				strcat(outbuf,"---");
-				outbuf += 3;
-				}
-			else if (c1 == 'd' && c2 == 'e')
-				{
-				strcat(outbuf,"$^\\circ$");
-				outbuf += 8;
-				}
-			else fprintf(stderr,
-				"I am not prepared to handle \\(%c%c\n",c1,c2);
-			}
-		else if (*inbuf == 's')
-			inbuf +=3;
-		else if (*inbuf == '*')
-			{
-			c1 = *++inbuf;
-			inbuf++;
-			if (c1 == ':')
-				strcat(outbuf,"\\\"");
-			else if (c1 == 'C')
-				strcat(outbuf,"\\v");
-			else if (c1 == ',')
-				strcat(outbuf,"\\c");
-			else
-				sprintf(outbuf,"\\%c",c1);
-			outbuf += 2;
-			c1 = *inbuf++;
-			sprintf(outbuf,"{%c}",c1);
-			outbuf += 3;
-			}
-		else if (*inbuf == 'f')
-			{
-			c1 = *++inbuf;
-			inbuf++;
-			if (c1 == '1' || c1 == 'R')
-				{
-				strcat(outbuf," \\rm ");
-				outbuf += 5;
-				}
-			else if (c1 == '2' || c1 == 'I')
-				{
-				strcat(outbuf," \\it ");
-				outbuf += 5;
-				}
-			else if (c1 == '3' || c1 == 'B')
-				{
-				strcat(outbuf," \\bf ");
-				outbuf += 5;
-				}
-			else fprintf(stderr,
-				"I do not understand \\f%c yet\n",c1);
-			}
-		else fprintf(stderr,"I am not prepared to handle \\%c\n",*inbuf);
-		}
-
-/* if non of the above checks, its a dull word; copy it */
-
-	else
-		{
-		strcat(outbuf,w);
-		outbuf += len;
-		}
-	*outbuf = NULL;  ww[0] = NULL;  tmp[0] = NULL;  first_word = 0;
-	}
-*outbuf = NULL;
-}
//GO.SYSIN DD textr/tr.c
echo textr/troff_mac.h 1>&2
sed >textr/troff_mac.h <<'//GO.SYSIN DD textr/troff_mac.h' 's/^-//'
-/*
-This file contains the list for non-math macros and plain troff macros.
-Do NOT forget to put the dot for the troff macros, and the backslash
-for TeX macros (two backslashes, one for escape).
-The third column in the list is 0 for macros that have no arguments
-and 1 for those that do.
-*/
-struct macro_table {
-	char *troff_mac, *tex_mac;
-	int arg;
-} macro[] = {
-
-/*  troff macro		TeX macro		   argument	*/
-	".PP",		 "\\par",			0,
-	".LP",		 "\\par\\noindent",		0,
-	".IP",		 "\\par\\noindent",		0,
-	".TL",		 "\\title",			1,
-	".AU",		 "\\author",			1,
-	".AI",		 "\\authoraff",			1,
-	".NH",		 "\\section",			1,
-	".MH",		 "\\mhead",			1,
-	".SH",		 "\\shead",			1,
-	".AE",		 "\\newpage",			0,
-	".Ac",		 "\\ACK",		  	0,
-	".RS",		 "\\shiftright",		0,
-	".RE",		 "\\shiftleft",			0,
-	".DS",		 "\\displaybegin",		0,
-	".DE",		 "\\displayend",		0,
-	".TE",		 "",				0,
-	".B2",		 "",				0,
-	".UL",		 "\\undertext",			1,
-	".Is",		 "\\begin{figure}",		0,
-	".Ie",		 "}\\end{figure}",		0,
-	".br",		 "\\newline",			0,
-	".bp",		 "\\newpage",			0,
-	".ce",		 "\\centerline",		1,
-	".ul",		 "\\underline",			1,
-	".cl",		 "\\underline",			1,
-	".nf",		 "\\begin{verbatim}",		0,
-	".fi",		 "\\end{verbatim}",		0
-};
//GO.SYSIN DD textr/troff_mac.h