[comp.text] Note on Common TeX and METAFONT

monardo@renoir.Berkeley.EDU (Pat Monardo) (01/21/88)

My C language METAFONT is currently working very nicely.
I plan on enjoying it for a while before submitting it to
the fine scrutiny but it appears to pass the trap test.
As soon as I have a machine readable version of the trap.log,
I will make it pass the test. In the meantine, it now correctly
compiles all of Computer Modern. I dont know about distribution,
but if you would like to beta test it, I may put it on a vax
somewhere for ftp access. Now that METFONT is finished I will also
clean up Common TeX to Version 2.9 very soon.


Regarding a problem with Common TeX:

Newsgroups: comp.text
In article <400@sering.cwi.nl> denise@cwi.nl writes:
>
>We have Common TeX, Version 2.1, and it doesn't seem to work.
>**foo  
>(./foo.tex
>Runaway definition?
>->
>! Forbidden control sequence found while scanning definition of \blort.
><inserted text> 
>                }
><to be read again> 
>                   \bye 
>l.2 \bye
>        
>? x

The problem is that Pascal TeX undex UNIX requires you to do absurb
things to create a loaded TeX. I have never worked with that version
so I dont know why, but it seems that people would do this:

This is TeX (no format preloaded)

*\read-1to\blort^\
Quit (core dumped)

or something like that.

DONT DO THIS!
Simply kill the program and undump it:

This is Common TeX (no format preloaded)

*^\
Quit (core dumped)

and you're ready to go.

	^\pat

chris@mimsy.UUCP (Chris Torek) (01/23/88)

In article <22696@ucbvax.BERKELEY.EDU> monardo@renoir.Berkeley.EDU
(Pat Monardo) writes:
>... Pascal TeX undex UNIX requires you to do absurb things to create
>a loaded TeX. I have never worked with that version so I dont know why,

In case anyone cares, it has to do with keeping things off Berkeley
Pascal's runtime file chain.  Without the \read 0 to \blort, the
preloaded TeX winds up with a circular file chain list and never
goes anywhere.

[For Common TeX,]
>Simply kill the program and undump it:
>
>This is Common TeX (no format preloaded)
[I think there is a `**&plain' missing here]
>*^\
>Quit (core dumped)

This brings up another gripe of mine.  This procedure requires
manual intervention:  Someone must type a control-backslash to
make the undumped TeX.  There is no way to have `make' rebuild
TeX automatically.  My way is a kludge, but it gets the job done.

This is extracted from my ext.c.  The calls to pascal_runtime__main_end
are for Pastel, not Berkeley Pascal; they should simply be deleted
to make it work under the Berkeley compiler.

/*
 * The following is an internal-use-only routine that makes a core
 * dump without any sort of error status.  It is used only when
 * making a production TeX from a virtex, and is triggered by a magic
 * file name requested as \input.
 *
 * This is what is known in computing circles as a hack.
 */
funny_core_dump()
{
	int pid, w;
	union wait status;

	switch (pid = vfork()) {

	case -1:		/* failed */
		perror("vfork");
		pascal_runtime__main_end();
		exit(-1);
		/*NOTREACHED*/

	case 0:			/* child */
		pascal_runtime__main_end();
		signal(SIGQUIT, SIG_DFL);
		kill(getpid(), SIGQUIT);
		write(2, "how did we get here?\n", 21);
		_exit(1);
		/*NOTREACHED*/

	default:		/* parent */
		while ((w = wait(&status)) != pid && w != -1)
			;
		if (status.w_coredump)
			exit(0);
		write(2, "attempt to dump core failed\n", 28);
		pascal_runtime__main_end();
		exit(1);
	}
}

/*
 * Test whether or not the file whose name is in fn
 * can be opened for reading (if amode==READACCESS)
 * or writing (if amode==WRITEACCESS).
 *
 * The pathindex argument is one of the ...FILEPATH constants.
 * If the filename given in nameoffile does not begin with '/', we try 
 * prepending all the ':'-separated areanames in the appropriate path to the
 * filename until access can be made, if it ever can.
 *
 * The realfn array will contain the name that yielded an
 * access success.
 *
 * N.B.:  we test for read access with "access", write access with "creat".
 */
int
testaccess(amode, pathindex, fn, realfn)
	int amode, pathindex;
	char *fn;
	register char *realfn;
{
	register char *p, *q, *s;
	register struct pathinfo *pi;
	int f;

	if (pathindex == INPUTFILEPATH && *fn == 'H' &&
	    strncmp(fn, "HackyInputFileNameForCoreDump.tex", 33) == 0)
		funny_core_dump();

	... [remainder deleted]

The Makefile then reads, in part:

	...
TEXDIR=	/usr/local/lib/tex

TEXINPUTS=	${TEXDIR}/macros
TEXFONTS=	${TEXDIR}/fonts
TEXFORMATS=	${TEXDIR}/macros
TEXPOOL=	${TEXDIR}

LATEXINPUTS=	${TEXDIR}/latex
LATEXFONTS=	${TEXDIR}/latex
LATEXFORMATS=	${TEXDIR}/latex
	...

plain.fmt: initex ${TEXINPUTS}/plain.tex ${TEXINPUTS}/hyphen.tex
	echo ' plain \dump' | \
	TEXINPUTS=":${TEXINPUTS}" TEXFONTS=":${TEXFONTS}" \
	TEXFORMATS=":${TEXFORMATS}" TEXPOOL=":${TEXPOOL}" ./initex

lplain.fmt: initex ${LATEXINPUTS}/lplain.tex ${LATEXFONTS}/lfonts.tex
lplain.fmt: ${TEXINPUTS}/hyphen.tex
	echo ' lplain \dump' | \
	TEXINPUTS=":${LATEXINPUTS}:${TEXINPUTS}" \
	TEXFONTS=":${LATEXFONTS}:${TEXFONTS}" \
	TEXFORMATS=":${LATEXFORMATS}:${TEXFORMATS}" \
	TEXPOOL=":${TEXPOOL}" ./initex

tex: virtex plain.fmt
	echo ' &plain \input HackyInputFileNameForCoreDump.tex' | \
	TEXINPUTS=":${TEXINPUTS}" TEXFONTS=":${TEXFONTS}" \
	TEXFORMATS=":${TEXFORMATS}" TEXPOOL=":${TEXPOOL}" ./virtex
	@echo ''
	undump tex virtex core
	rm -f core

latex: virtex lplain.fmt
	echo ' &lplain \input HackyInputFileNameForCoreDump.tex' | \
	TEXINPUTS=":${LATEXINPUTS}:${TEXINPUTS}" \
	TEXFONTS=":${LATEXFONTS}:${TEXFONTS}" \
	TEXFORMATS=":${LATEXFORMATS}:${TEXFORMATS}" \
	TEXPOOL=":${TEXPOOL}" ./virtex
	@echo ''
	undump latex virtex core
	rm -f core
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

kuo@skatter.UUCP (Dr. Peter Kuo) (01/31/88)

In article <22696@ucbvax.BERKELEY.EDU>, monardo@renoir.Berkeley.EDU (Pat Monardo) writes:
> My C language METAFONT is currently working very nicely.
> I plan on enjoying it for a while before submitting it to
> the fine scrutiny but it appears to pass the trap test.
> As soon as I have a machine readable version of the trap.log,
> I will make it pass the test. In the meantine, it now correctly
> compiles all of Computer Modern. I dont know about distribution,
> but if you would like to beta test it, I may put it on a vax
> somewhere for ftp access. Now that METFONT is finished I will also
> clean up Common TeX to Version 2.9 very soon.
> 
> [... deleted ...]
>
> 	^\pat


Pat, how about some of us poor folks with no FTP access??? Is there an easy
way for me to get a copy of your Common TeX (exe and source) as well? I have
seen a number of other questions similar to mine on TeX-hack... much thanks
in advance!

Peter/
-------------------------------------------------------------------------------
Peter Kuo                   | Bitnet (VMS)  : KUO@SASK
Accelerator Laboratory      |
(a.k.a. The Beam Warehouse) | uucp   (Unix) : !alberta\
Univ. of Saskatchewan       |                 !ihnp4  -- !sask!skatter!kuo
Saskatoon, Saskatchewan     |                 !utcsri /
CANADA  S7N 0W0             |
(Earth)                     | Ma Bell       : (306) 966-8528

Disclaimer: I don't know what I am saying, I'm only a physicist.
            Don't quote me on anything! I speak only for myself.

Opus: "Why, fer cryin' out loud..research physicists need Porsches, TOO!!"

						 -- Bloom County