LaTeX for Xenix (9 of 14)

G Geers glenn at extro.ucc.su.oz.au
Fri Feb 16 10:41:04 AEST 1990


---- Cut Here and unpack ----
#!/bin/sh
# this is part 9 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file hash.c continued
#
CurArch=9
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file hash.c"
sed 's/^X//' << 'SHAR_EOF' >> hash.c
X	ptr		p;
X
X	h = buffer[j];
X	for (k = j + 1; k < j + l; incr(k)) {
X		h = h + h + buffer[k];
X		while (h >= HASH_PRIME)
X			h -= HASH_PRIME;
X	}
X	for (p = h + HASH_BASE; ; p = next(p)) {
X		if (text(p) > 0 && length(text(p)) == l)
X			if (str_eq_buf(text(p), j))
X				return p;
X		if (next(p) == 0) {
X			if (no_new_control_sequence)
X				return UNDEFINED_CONTROL_SEQUENCE;
X			if (text(p) > 0) {
X				do
X					if (hash_is_full)
X						overflow("hash size", HASH_SIZE);
X					else decr(hash_used);
X				while (text(hash_used) != 0);
X				next(p) = hash_used;
X				p = hash_used;
X			}
X			str_room(l);
X			for (k = j; k < j + l; incr(k))
X				append_char(buffer[k]);
X			text(p) = make_string();
X#ifdef STAT
X			incr(cs_count);
X#endif
X			return p;
X		}
X	}
X}
X
Xprint_cs (p)
X	ptr		p;
X{	
X	if (p < HASH_BASE) {
X		if (p >= SINGLE_BASE) {
X			if (p == NULL_CS) {
X				print_esc("csname");
X				print_esc("endcsname");
X			} else {
X				print_esc(""); 
X				print_str(p - SINGLE_BASE); 
X				if (cat_code(p - SINGLE_BASE) == LETTER)
X					print_char(' ');
X			}
X		} else if (p < ACTIVE_BASE)
X			print_esc("IMPOSSIBLE.");
X		else print_str(p - ACTIVE_BASE);
X	} else if (p >= UNDEFINED_CONTROL_SEQUENCE)
X		print_esc("IMPOSSIBLE.");
X	else if (text(p) < 0 || text(p) >= str_ptr)
X		print_esc("NONEXISTENT.");
X	else {
X		print_esc("");
X		slow_print(text(p));
X		print_char(' ');
X	}
X}
X
Xsprint_cs (p)
X	ptr		p;
X{
X	if (p < HASH_BASE) {
X		if (p < SINGLE_BASE)
X			print_str(p - ACTIVE_BASE);
X		else if (p < NULL_CS) {
X			print_esc("");
X			print_str(p - SINGLE_BASE);
X		} else {
X			print_esc("csname");
X			print_esc("endcsname");
X		}
X	} else {
X		print_esc("");
X		slow_print(text(p));
X	}
X}
X
X#ifdef INIT
Xprimitive (s, c, o)
X	char*	s;
X	qword	c;
X	hword	o;
X{
X	int		j;
X	int		k;
X	int		l;
X	str		new_str;
X
X	if (s[1] == NUL)
X		cur_val = s[0] + SINGLE_BASE;
X	else {
X		new_str = make_string_given(s);
X		k = str_start[new_str];
X		l = length(new_str);
X		for (j = 0; j < l; incr(j))
X			buffer[j] = str_pool[k + j];
X		cur_val = id_lookup(0, l);
X		flush_string();
X		text(cur_val) = new_str;
X	}
X	eq_level(cur_val) = LEVEL_ONE;
X	eq_type(cur_val) = c;
X	equiv(cur_val) = o;
X}
X#endif
SHAR_EOF
echo "File hash.c is complete"
chmod 0444 hash.c || echo "restore of hash.c fails"
set `wc -c hash.c`;Sum=$1
if test "$Sum" != "2748"
then echo original size 2748, current size $Sum;fi
echo "x - extracting hash.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > hash.h &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		hash.h
X */
X
X#define	next(H)				hash[H].hh1.lh
X#define	text(H)				hash[H].hh1.rh
X#define	font_id_text(H)		text(FONT_ID_BASE + H)
X
X#define	hash_is_full		(hash_used == HASH_BASE)
X
Xglobal	twoh	hash[];
Xglobal	ptr		hash_used;
Xglobal	bool	no_new_control_sequence;
Xglobal	int		cs_count;
X
Xptr		id_lookup();
Xint		print_cs();
Xint		sprint_cs();
X
X#ifdef	INIT
Xint		primitive();
X#endif
SHAR_EOF
chmod 0444 hash.h || echo "restore of hash.h fails"
set `wc -c hash.h`;Sum=$1
if test "$Sum" != "591"
then echo original size 591, current size $Sum;fi
echo "x - extracting heap.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > heap.c &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		heap.c
X */
X
X#include "tex.h"
X#include "eq.h"
X#include "arith.h"
X#include "box.h"
X#include "evalstack.h"
X#include "par.h"
X#include "page.h"
X#include "print.h"
X#include "error.h"
X#include "heap.h"
X
Xmword	mem[MEM_MAX-MEM_MIN+1];
Xptr		mem_end;
Xptr		lo_mem_max;
Xptr		hi_mem_min;
Xptr		avail;
Xint		dyn_used;
Xptr		rover;
Xint		var_used;
Xint		max_var_used;
Xptr		temp_ptr;
X
Xptr
Xget_avail ()
X{
X	ptr		p;
X
X	p = avail;
X	if (p != NULL)
X		avail = link(avail);
X	else if (mem_end < MEM_MAX) {
X		incr(mem_end);
X		p = mem_end;
X	} else {
X		decr(hi_mem_min);
X		p = hi_mem_min;
X		if (hi_mem_min <= lo_mem_max) {
X			runaway();
X			overflow("main memory size", MEM_MAX - MEM_MIN);
X		}
X	}
X	link(p) = NULL;
X#ifdef STAT
X	incr(dyn_used);
X#endif
X	return p;
X}
X
Xptr
Xget_node (s)
X	int		s;
X{
X	ptr		p;
X	ptr		q;
X	int		r;
X	int		t;
X
Xrestart:
X	p = rover;
X	do {
X		q = p + node_size(p);
X		while (is_empty(q)) {
X			t = rlink(q);
X			if (q == rover)
X				rover = t;
X			llink(t) = llink(q);
X			rlink(llink(q)) = t;
X			q += node_size(q);
X		}
X		r = q - s;
X		if (r > (int) p + 1)  {
X			node_size(p) = r - p;
X			rover = p;
X			goto found;
X		}
X		if (r == p && (rlink(p) != rover || llink(p) != rover)) {
X			rover = rlink(p);
X			t = llink(p);
X			llink(rover) = t;
X			rlink(t) = rover;
X			goto found;
X		}
X		node_size(p) = q - p;
X		p = rlink(p);
X	} while (p != rover);
X	if (s == 010000000000)
X		return MAX_HALFWORD;
X	if (lo_mem_max + 2 < hi_mem_min && 
X		lo_mem_max + 2 <= MEM_BOT + MAX_HALFWORD) {
X		if (lo_mem_max + 1000 < hi_mem_min)
X			t = lo_mem_max + 1000;
X		else t = (lo_mem_max + hi_mem_min + 2) / 2;
X		p = llink(rover);
X		q = lo_mem_max;
X		rlink(p) = q;
X		llink(rover) = q;
X		if (t > MEM_BOT + MAX_HALFWORD)
X			t = MEM_BOT + MAX_HALFWORD;
X		rlink(q) = rover;
X		llink(q) = p;
X		link(q) = EMPTY_FLAG;
X		node_size(q) = t - lo_mem_max;
X		lo_mem_max = t;
X		link(lo_mem_max) = NULL;
X		info(lo_mem_max) = NULL; 
X		rover = q;
X		goto restart;
X	}
X
X	overflow("main memory size", MEM_MAX + 1 - MEM_MIN);
X
Xfound:
X	link(r) = NULL;
X#ifdef STAT
X	var_used += s;
X#endif
X	return r;
X}
X
Xfree_node (p, s)
X	ptr		p;
X	hword	s;
X{
X	ptr		q;
X
X	node_size(p) = s;
X	link(p) = EMPTY_FLAG;
X	q = llink(rover);
X	llink(p) = q;
X	rlink(p) = rover;
X	llink(rover) = p;
X	rlink(q) = p;
X#ifdef STAT
X	var_used -= s;
X#endif
X}
X
Xinit_mem ()
X{
X	int		k;
X	
X#ifdef INIT
X	for (k = MEM_BOT + 1; k <= LO_MEM_STAT_MAX; k++)
X		mem[k].sc = 0;
X	for (k = MEM_BOT; k <= LO_MEM_STAT_MAX; k += GLUE_SPEC_SIZE) {
X		glue_ref_count(k) = NULL + 1;
X		stretch_order(k) = NORMAL;
X		shrink_order(k) = NORMAL;
X	}
X	stretch(fil_glue) = UNITY;
X	stretch_order(fil_glue) = FIL;
X	stretch(fill_glue) = UNITY;
X	stretch_order(fill_glue) = FILL;
X	stretch(ss_glue) = UNITY;
X	stretch_order(ss_glue) = FIL;
X	shrink(ss_glue) = UNITY;
X	shrink_order(ss_glue) = FIL;
X	stretch(fil_neg_glue) = -UNITY;
X	stretch_order(fil_neg_glue) = FIL;
X	
X	rover = LO_MEM_STAT_MAX + 1;
X	link(rover) = EMPTY_FLAG;
X	node_size(rover) = 1000;
X	llink(rover) = rover;
X	rlink(rover) = rover;
X
X	lo_mem_max = rover + 1000;
X	link(lo_mem_max) = NULL;
X	info(lo_mem_max) = NULL;
X	for (k = HI_MEM_STAT_MIN; k <= MEM_TOP; incr(k))
X		mem[k] = mem[lo_mem_max];
X
X	link(end_span) = MAX_QUARTERWORD + 1;
X	info(end_span) = NULL;
X	type(last_active) = HYPHENATED;
X	subtype(last_active) = 0;
X	line_number(last_active) = MAX_HALFWORD;
X	type(page_ins_head) = SPLIT_UP;
X	subtype(page_ins_head) = qi(255);
X	link(page_ins_head) = page_ins_head;
X	type(page_head) = GLUE_NODE;
X	subtype(page_head) = NORMAL;
X
X	avail = NULL;
X	mem_end = MEM_TOP;
X	hi_mem_min = HI_MEM_STAT_MIN;
X	var_used = LO_MEM_STAT_MAX + 1 - MEM_BOT;
X	dyn_used = HI_MEM_STAT_USAGE;
X#endif
X}
X
Xsort_avail()
X{
X	ptr		p;
X	ptr		q;
X	ptr		r;
X	ptr		old_rover;
X
X#ifdef INIT
X	get_node(010000000000);
X	p = rlink(rover);
X	rlink(rover) = MAX_HALFWORD;
X	old_rover = rover;
X	while (p != old_rover) {
X		if (p < rover) {
X			q = p;
X			p = rlink(q);
X			rlink(q) = rover;
X			rover = q;
X		} else {
X			q = rover;
X			while (rlink(q) < p)
X				q = rlink(q);
X			r = rlink(p);
X			rlink(p) = rlink(q);
X			rlink(q) = p;
X			p = r;
X		}
X	}
X	p = rover;
X	while (rlink(p) != MAX_HALFWORD) {
X		llink(rlink(p)) = p;
X		p = rlink(p);
X	}
X	rlink(p) = rover;
X	llink(rover) = p;
X#endif
X}
SHAR_EOF
chmod 0444 heap.c || echo "restore of heap.c fails"
set `wc -c heap.c`;Sum=$1
if test "$Sum" != "4344"
then echo original size 4344, current size $Sum;fi
echo "x - extracting heap.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > heap.h &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		heap.h
X */
X
X#define	qi(M)			(M + MIN_QUARTERWORD)
X#define	qo(M)			(M - MIN_QUARTERWORD)
X#define	hi(M)			(M + MIN_HALFWORD)
X#define	ho(M)			(M - MIN_HALFWORD)
X
X#ifdef NULL
X#undef NULL
X#endif
X#define	NULL			MIN_HALFWORD
X
Xglobal	mword	mem[];
Xglobal	ptr		lo_mem_max;
Xglobal	ptr		hi_mem_min;
X
Xglobal	int		var_used;
Xglobal	int		max_var_used;
Xglobal	int		dyn_used;
X
X#define	link(M)			mem[M].hh.hh1.rh
X#define	info(M)			mem[M].hh.hh1.lh
X
Xglobal	ptr	 	avail;
Xglobal	ptr		mem_end;
X
Xptr get_avail();
X
X
X#ifdef	STAT
X#define	fast_get_avail(M) \
X	{M = avail; \
X	if (M == NULL) M = get_avail(); \
X	else {avail = link(M); link(M) = NULL; incr(dyn_used);}}
X#else
X#define	fast_get_avail(M) \
X	{M = avail; \
X	if (M == NULL) M = get_avail(); \
X	else {avail = link(M); link(M) = NULL;}}
X#endif
X
X
X#ifdef STAT
X#define free_avail(M) \
X	{link(M) = avail; avail = M; decr(dyn_used);}
X#else
X#define free_avail(M) \
X	{link(M) = avail; avail = M;}
X#endif
X
Xint		flush_list();
X
X#define	is_empty(M)			(link(M) == EMPTY_FLAG)
X#define	EMPTY_FLAG			MAX_HALFWORD
X#define	node_size			info
X#define	llink(M)			info(M + 1)
X#define	rlink(M) 			link(M + 1)
X
Xglobal	ptr	rover;
X
Xptr		get_node();
Xint		free_node();
X
Xglobal	ptr	temp_ptr;
X
X#define	zero_glue 		MEM_BOT
X#define	fil_glue 		(zero_glue + GLUE_SPEC_SIZE)
X#define	fill_glue 		(fil_glue + GLUE_SPEC_SIZE)
X#define	ss_glue  		(fill_glue + GLUE_SPEC_SIZE)
X#define	fil_neg_glue 	(ss_glue + GLUE_SPEC_SIZE)
X
X#define	LO_MEM_STAT_MAX	(fil_neg_glue + GLUE_SPEC_SIZE - 1)
X
X#define	page_ins_head 	(MEM_TOP)
X#define	contrib_head  	(MEM_TOP - 1)
X#define	page_head  		(MEM_TOP - 2)
X#define	temp_head  		(MEM_TOP - 3)
X#define	hold_head  		(MEM_TOP - 4)
X#define	adjust_head		(MEM_TOP - 5)
X#define	active  		(MEM_TOP - 7)
X#define	align_head  	(MEM_TOP - 8)
X#define	end_span  		(MEM_TOP - 9)
X#define	lig_trick  		(MEM_TOP - 10)
X#define	garbage  		(MEM_TOP - 10)
X
X#define	HI_MEM_STAT_MIN		(MEM_TOP - 10)
X#define	HI_MEM_STAT_USAGE	11
X
Xbool	init_mem();
X
X#ifdef INIT
Xint		sort_avail();
X#endif
SHAR_EOF
chmod 0444 heap.h || echo "restore of heap.h fails"
set `wc -c heap.h`;Sum=$1
if test "$Sum" != "2203"
then echo original size 2203, current size $Sum;fi
echo "x - extracting hyph.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > hyph.c &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		hyph.c
X */
X
X#include	"tex.h"
X#include	"cmds.h"
X#include	"heap.h"
X#include	"token.h"
X#include	"eq.h"
X#include	"str.h"
X#include	"tfm.h"
X#include	"box.h"
X#include	"scan.h"
X#include	"tokenstack.h"
X#include	"par.h"
X#include	"print.h"
X#include	"error.h"
X#include	"hyph.h"
X
Xptr		ha;
Xptr		hb;
Xhword	hc[66];
Xfnt		hf;
Xint		hn;
Xascii	hu[64];
Xbyte	hyf[65];
Xint		hyf_char;
Xint		hyf_distance[256];
Xqword	hyf_next[256];
Xint		hyf_num[256];
Xint		hyph_count;
Xptr		hyph_list[HYPH_SIZE+1];
Xstr		hyph_word[HYPH_SIZE+1];
Xint		hyphen_passed;
Xint		trie_max;
Xqword	trie_op_ptr;
Xtwoh	trie[TRIE_SIZE+1];
X
Xhyphenate ()
X{
X	ascii	c;
X	int		h;
X	int		i;
X	int		j;
X	str		k;
X	int		l;
X	ptr		q;
X	ptr		r;
X	ptr		s;
X	int		u;
X	qword	v;
X	int		z;
X	ptr		hyf_node;
X	ptr		major_tail;
X	ptr		minor_tail;
X
X	for (j = 0; j <= hn; incr(j))
X		hyf[j] = 0;
X	h = hc[1];
X	for (j = 2; j <= hn; incr(j))
X		h = (h + h + hc[j]) % HYPH_SIZE;
X	loop {
X		k = hyph_word[h];
X		if (k == 0) goto not_found;
X		if (length(k) < hn)	goto not_found;
X		if (length(k) == hn) {
X			j = 1;
X			u = str_start[k];
X			do {
X				if (str_pool[u] < hc[j]) goto not_found;
X				if (str_pool[u] > hc[j]) goto done;
X				incr(u); incr(j);
X			} while (j <= hn);
X			for (s = hyph_list[h]; s != NULL; s = link(s))
X				hyf[info(s)] = 1;
X			goto found;
X		}
X
X	done:
X		if (h > 0)
X			decr(h);
X		else h = HYPH_SIZE;
X	}
X
Xnot_found:
X	hc[0] = 127;
X	hc[hn + 1] = 127;
X	hc[hn + 2] = 256;
X	for (j = 0; j <= hn - 2; incr(j)) {
X		z = hc[j];
X		l = j;
X		while (hc[l] == trie_char(z)) {
X			if (trie_op(z) != MIN_QUARTERWORD) {
X				v = trie_op(z);
X				do {
X					i = l - hyf_distance[v];
X					if (hyf_num[v] > hyf[i])
X						hyf[i] = hyf_num[v];
X					v = hyf_next[v];
X				} while (v != MIN_QUARTERWORD);
X			}
X			incr(l);
X			z = trie_link(z) + hc[l];
X		}
X	}
X
Xfound:
X	hyf[1] = 0;
X	hyf[hn - 2] = 0;
X	hyf[hn - 1] = 0;
X	hyf[hn] = 0;
X
X	for (j = 2; j <= hn - 3; incr(j))
X		if (odd(hyf[j])) goto found1;
X	return;
X
Xfound1:
X	q = link(hb);
X	link(hb) = NULL;
X	s = cur_p;
X	while (link(s) != ha)
X		s = link(s);
X	link(s) = NULL;
X	flush_node_list(ha);
X	j = 0;
X	do {
X		l = j;
X		j = reconstitute(j + 1, hn);
X		if (hyphen_passed != 0) {
X			r = get_node(SMALL_NODE_SIZE);
X			link(s) = r;
X			link(r) = link(hold_head);
X			type(r) = DISC_NODE;
X			major_tail = link(hold_head);
X			if (link(major_tail) != NULL)
X				major_tail = link(major_tail);
X			i = hyphen_passed;
X			minor_tail = NULL;
X			hyf_node = new_character(hf, (ascii) hyf_char);
X			if (hyf_node != NULL) {
X				incr(i);
X				c = hu[i];
X				hu[i] = hyf_char;
X			}
X			do {
X				l = reconstitute(l + 1, i);
X				if (minor_tail == NULL)
X					pre_break(r) = link(hold_head);
X				else link(minor_tail) = link(hold_head);
X				minor_tail = link(hold_head);
X				if (link(minor_tail) != NULL)
X					minor_tail = link(minor_tail);
X			} while (l != i);
X			if (hyf_node != NULL) {
X				hu[i] = c;
X				free_avail(hyf_node);
X				decr(i);
X				l = i;
X			}
X			hyf[i] = 0;
X			minor_tail = NULL;
X			post_break(r) = NULL;
X			while (l < j) {
X				do {
X					l = reconstitute(l + 1, hn);
X					if (minor_tail == NULL)
X						post_break(r) = link(hold_head);
X					else link(minor_tail) = link(hold_head);
X					minor_tail = link(hold_head);
X					if (link(minor_tail) != NULL) {
X						hyf[l] = 0;
X						minor_tail = link(minor_tail);
X					}
X				} while (l < j);
X				while (l > j) {
X					j = reconstitute(j + 1, hn);
X					link(major_tail) = link(hold_head);
X					major_tail = link(hold_head);
X					if (link(major_tail) != NULL) {
X						hyf[j] = 0;
X						major_tail = link(major_tail);
X					}
X				}
X			}
X			i = 0; 
X			s = r;
X			while(link(s) != NULL) {
X				incr(i);
X				s =  link(s);
X			}
X			replace_count(r) = i;
X		} else {
X			link(s) = link(hold_head);
X			s = link(s);
X			if (link(s) != NULL)
X				s = link(s);
X		}
X		if (odd(hyf[j])) {
X			r = new_disc();
X			pre_break(r) = new_character(hf, (ascii) hyf_char);
X			link(s) = r;
X			s = r;
X		}
X	} while (j != hn);
X	link(s) = q;
X}
X	
Xreconstitute (j, n)
X	int		j;
X	int		n;
X{
X	qword	c;
X	qword	d;
X	ptr		p;
X	fourq	q;
X	int		r;
X	ptr		s;
X	scal	w;
X
X	hyphen_passed = 0;
X	s = hold_head;
X	w = 0;
X	c = d = qi(hu[j]);
X	loop {
Xcontin: p = get_avail();
X		font(p) = hf;
X		character(p) = c;
X		link(s) = p;
X		if (j == n) break;
X		q = char_info(hf, d);
X		if (char_tag(q) != LIG_TAG) break;
X		r = lig_kern_start(hf, q);
X		c = qi(hu[j + 1]);
X		loop {
X			q = font_info[r].qqqq;
X			if (next_char(q) == c) {
X				if (odd(hyf[j]) && hyphen_passed == 0)
X					hyphen_passed = j;
X				if (op_bit(q) < KERN_FLAG) {
X					d = rem_byte(q);
X					incr(j);
X					s = p;
X					goto contin;
X				} else {
X					w = char_kern(hf, q);
X					goto done;
X				}
X			} else if (stop_bit(q) < STOP_FLAG)
X				incr(r);
X			else goto done;
X		}
X	}
X
Xdone:
X	if (s != hold_head) {
X		p = new_ligature(hf, d, link(hold_head));
X		link(hold_head) = p;
X	}
X	if (w != 0)
X		link(link(hold_head)) = new_kern(w);
X	return j;
X}
X
Xnew_hyph_exceptions ()
X{
X	int		h;
X	int		j;
X	str		k;
X	int		n;
X	ptr		p;
X	ptr		q;
X	str		s;
X	str		t;
X	int		u;
X	int		v;
X
X	n = 0;
X	p = NULL;
X	scan_left_brace();
X	loop {
X		get_x_token();
X
X	reswitch:
X		switch (cur_cmd)
X		{
X		case LETTER:
X		case OTHER_CHAR:
X		case CHAR_GIVEN:
X			if (cur_chr == '-') {
X				if (n > 1) {
X					q = get_avail();
X					link(q) = p;
X					info(q) = n;
X					p = q;
X				}
X			} else {
X				if (cur_chr > 127 || lc_code(cur_chr) == 0) {
X					print_err("Not a letter");
X					help_hyph_lccode();
X					error();
X				} else if (n < 63) {
X					incr(n);
X					hc[n] = lc_code(cur_chr) - 1;
X				}
X			}
X			break;
X		
X		case CHAR_NUM:
X			scan_char_num();
X			cur_chr = cur_val;
X			cur_cmd = CHAR_GIVEN;
X			goto reswitch;
X			break;
X
X		case SPACER:
X		case RIGHT_BRACE:
X			if (n > 4) {
X				str_room(n);
X				h = 0;
X				for (j = 1; j <= n; incr(j)) {
X					h = (h + h + hc[j]) % HYPH_SIZE;
X					append_char(hc[j]);
X				}
X				s = make_string();
X				loop {
X					if (p == NULL)
X						break;
X					if (info(p) < n - 2)
X						break;
X					q = link(p);
X					free_avail(p);
X					p = q;
X				}
X				if (hyph_count == HYPH_SIZE)
X					overflow("exception dictionary", HYPH_SIZE);
X				incr(hyph_count);
X				while (hyph_word[h] != 0) {
X					k = hyph_word[h];
X					if (length(k) < length(s))
X						goto found;
X					if (length(k) > length(s))
X						goto not_found;
X					u = str_start[k];
X					v = str_start[s];
X					do {
X						if (str_pool[u] < str_pool[v])
X							goto found;
X						if (str_pool[u] > str_pool[v])
X							goto not_found;
X						incr(u); incr(v);
X					} while (u != str_start[k + 1]);
X
X				found:
X					q = hyph_list[h];
X					hyph_list[h] = p;
X					p = q;
X					t = hyph_word[h];
X					hyph_word[h] = s;
X					s = t;
X				
X			not_found:
X					if (h > 0)
X						decr(h);
X					else h = HYPH_SIZE;
X				}
X				hyph_word[h] = s;
X				hyph_list[h] = p;
X			}
X			if (cur_cmd == RIGHT_BRACE)
X				return;
X			n = 0;
X			p = NULL;
X			break;
X
X		default:
X			print_err("Improper ");
X			print_esc("hyphenation");
X			print(" will be flushed");
X			help_hyph();
X			error();
X			break;
X		}
X	}
X}
X
X/*
X *	Help text
X */
X
Xhelp_hyph_lccode ()
X{
X	help2("Letters in \\hyphenation words must have \\lccode > 0",
X	"Proceed; I'll ignore the character I just read.");
X}
X
Xhelp_hyph ()
X{
X	help2("Hyphenation exceptions must contain only letters",
X	"and hyphens. But continue; I'll forgive and forget.");
X}
X
X#ifdef INIT
X
Xqword	trie_op_hash[TRIE_OP_HASH_SIZE+1];	
Xqword	trie_op_ptr;
X
Xint		trie_hash[TRIE_SIZE+1];
Xascii	trie_c[TRIE_SIZE+1];
Xqword	trie_o[TRIE_SIZE+1];
Xint		trie_l[TRIE_SIZE+1];
Xint		trie_r[TRIE_SIZE+1];
Xint		trie_min;
Xint		trie_ptr;
Xbool	trie_taken[TRIE_SIZE+1];
X
Xqword
Xnew_trie_op (d, n, v)
X	int		d;
X	int		n;
X	qword	v;
X{
X	int		h;
X	qword	u;
X
X/*	h = abs((n + 313 * d + 361 * v)) % TRIE_OP_HASH_SIZE; */
X	if ((h=(n+313*d+361*v))<0)
X		h=(-h);		/* patch to overcome a bug in /lib/ccom
X				** on Dual  DHD 3/89
X				*/
X	h %= TRIE_OP_HASH_SIZE;
X	loop {
X		u = trie_op_hash[h];
X		if (u == MIN_QUARTERWORD) {
X			if (trie_op_ptr == MAX_QUARTERWORD)
X				return MIN_QUARTERWORD;
X			incr(trie_op_ptr);
X			hyf_distance[trie_op_ptr] = d;
X			hyf_num[trie_op_ptr] = n;
X			hyf_next[trie_op_ptr] = v;
X			trie_op_hash[h] = trie_op_ptr;
X			return trie_op_ptr;
X		}
X		if (hyf_distance[u] == d && 
X			hyf_num[u] == n &&
X			hyf_next[u] == v)
X				return u;
X		if (h > 0)
X			decr(h);
X		else h = TRIE_OP_HASH_SIZE;
X	}
X}
X		
Xtrie_node (p)
X	int		p;
X{
X	int		h;
X	int		q;
X
X/*	h = abs(trie_c[p] + 
X			1009 * trie_o[p] +
X			2718 * trie_l[p] +
X			3142 * trie_r[p])
X			% TRIE_SIZE; */
X	if ((h = (trie_c[p] + 
X			1009 * trie_o[p] +
X			2718 * trie_l[p] +
X			3142 * trie_r[p])) < 0)
X		h = (-h);
X	h %= TRIE_SIZE;		/*  Similar patch to above  */
X	loop {
X		q = trie_hash[h];
X		if (q == 0) {
X			trie_hash[h] = p; 
X			return p;
X		}
X		if (trie_c[q] == trie_c[p] &&
X			trie_o[q] == trie_o[p] &&
X			trie_l[q] == trie_l[p] && 
X			trie_r[q] == trie_r[p])
X			return q;
X		if (h > 0) 
X			decr(h);
X		else h = TRIE_SIZE;
X	}
X}
X
Xcompress_trie (p)
X	int		p;
X{
X	if (p == 0)
X		return 0;
X	else {
X		trie_l[p] = compress_trie(trie_l[p]);
X		trie_r[p] = compress_trie(trie_r[p]);
X		return (trie_node(p));
X	}
X}
X
Xinit_pattern_memory ()
X{
X	int		h;
X	int		p;
X
X	for (h = 0; h <= TRIE_OP_HASH_SIZE; incr(h))
X		trie_op_hash[h] = MIN_QUARTERWORD;
X	trie_op_ptr = MIN_QUARTERWORD;
X	trie_root = 0;
X	trie_c[0] = 0;
X	trie_ptr = 0;
X	for (p = 0; p <= TRIE_SIZE; incr(p))
X		trie_hash[p] = 0;
X}
X
Xinit_trie_memory ()
X{
X	int		p;
X
X	for (p = 0; p <= trie_ptr; incr(p))
X		trie_ref[p] = 0;
X	trie_max = trie_min = 128;
X	trie_link(0) = 1;
X	trie_taken[0] = FALSE;
X	for (p = 1; p <= 128; p++) {
X		trie_back(p) = p - 1;
X		trie_link(p) = p + 1;
X		trie_taken[p] = FALSE;
X	}
X}
X
Xfirst_fit (p)
X	int		p;
X{
X	ascii	c;
X	int		h;
X	int		q;
X	int		z;
X
X	c = trie_c[p];
X	if (c < trie_min)
X		trie_min = c;
X	z = trie_link(trie_min - 1);
X	loop {
X		if (z < c)
X			goto not_found;
X		h = z - c;
X		if (trie_max < h + 128) {
X			if (TRIE_SIZE <= h + 128)
X				overflow("pattern memory", TRIE_SIZE);
X			do {
X				incr(trie_max); 
X				trie_taken[trie_max] = FALSE;
X				trie_link(trie_max) = trie_max + 1;
X				trie_back(trie_max) = trie_max - 1;
X			} while (trie_max != h + 128);
X		}
X		if (trie_taken[h])
X			goto not_found;
X		for (q = trie_r[p]; q > 0; q = trie_r[q])
X			if (trie_link(h + trie_c[q]) == 0)
X				goto not_found;
X		goto found;
X
X	not_found:
X		z = trie_link(z);
X	}
X
Xfound:
X	trie_taken[h] = TRUE;
X	trie_ref[p] = h;
X	q = p;
X	do {
X		z = h + trie_c[q];
X		trie_back(trie_link(z)) = trie_back(z);
X		trie_link(trie_back(z)) = trie_link(z);
X		trie_link(z) = 0;
X		q = trie_r[q];
X	} while (q != 0);
X}
X
Xtrie_pack (p)
X	int		p;
X{
X	int		q;
X
X	do {	
X		q = trie_l[p];
X		if (q > 0 && trie_ref[q] == 0) {
X			first_fit(q);
X			trie_pack(q);
X		}
X		p = trie_r[p];
X	} while (p != 0);
X}
X
Xtrie_fix (p)
X	int		p;
X{
X	ascii	c;
X	int		q;
X	int		z;
X
X	z = trie_ref[p];
X	while (p != 0) {
X		q = trie_l[p];
X		c = trie_c[p];
X		trie_link(z + c) = trie_ref[q];
X		trie_char(z + c) = c;
X		trie_op(z + c) = trie_o[p];
X		if (q > 0)
X			trie_fix(q);
X		p = trie_r[p];
X	}
X}
X
Xnew_patterns ()
X{
X	ascii	c;
X	twoh	h;
X	int		k;
X	int		l;
X	int		p;
X	int		q;
X	int		r;
X	int		s;
X	qword	v;
X	bool	digit_sensed;
X	bool	first_child;
X
X	scan_left_brace();
X	init_pattern_memory();
X	k = 0;
X	hyf[0] = 0;
X	digit_sensed = FALSE;
X	loop {
X		get_x_token();
X		switch (cur_cmd)
X		{
X		case LETTER:
X		case OTHER_CHAR:
X			if (digit_sensed || cur_chr < '0' || cur_chr > '9') {
X				if (cur_chr == '.')
X					cur_chr = 128;
X				else {
X					cur_chr = lc_code(cur_chr);
X					if (cur_chr == 0) {
X						print_err("Nonletter");
X						help1("(See Appendix H.)");
X						error();
X						cur_chr = 128;
X					}
X				}
X				if (k < 63) {
X					incr(k);
X					hc[k] = cur_chr - 1;
X					hyf[k] = 0;
X					digit_sensed = FALSE;
X				}
X			} else {
X				hyf[k] = cur_chr - '0';
X				if (k < 63)
X					digit_sensed = TRUE;
X			}
X			break;
X
X		case SPACER:
X		case RIGHT_BRACE:
X			if (k > 0) {
X				if (hc[1] == 127)
X					hyf[0] = 0;
X				if (hc[k] == 127)
X					hyf[k] = 0;
X				l = k;
X				v = MIN_QUARTERWORD;
X				loop {
X					if (hyf[l] != 0)
X						v = new_trie_op(k - l, hyf[l], v);
X					if (l > 0)
X						decr(l);
X					else break;
X				}
X				q = 0; 
X				while (l < k) {
X					incr(l);
X					c = hc[l];
X					p = trie_l[q];
X					first_child = TRUE;
X					while (p > 0 && c > trie_c[p]) {
X						q = p;
X						p = trie_r[q];
X						first_child = FALSE;
X					}
X					if (p == 0 || c < trie_c[p]) {
X						if (trie_ptr == TRIE_SIZE)
X							overflow("pattern memory", TRIE_SIZE);
X						incr(trie_ptr);
X						trie_r[trie_ptr] = p;
X						p = trie_ptr;
X						trie_l[p] = 0;
X						if (first_child)
X							trie_l[q] = p;
X						else trie_r[q] = p;
X						trie_c[p] = c;
X						trie_o[p] = MIN_QUARTERWORD;
X					}
X					q = p;
X				}
X				if (trie_o[q] != MIN_QUARTERWORD) {
X					print_err("Duplicate pattern");
X					help1("(See Appendix H.)");
X					error();
X				}
X				trie_o[q] = v;
X			}
X			if (cur_cmd == RIGHT_BRACE)
X				goto done;
X			k = 0;
X			hyf[0] = 0;
X			digit_sensed = FALSE;
X			break;
X
X		default:
X			print_err("Bad ");
X			print_esc("patterns");
X			help1("(See Appendix H.)");
X			error();
X			break;
X		}
X	}
X
Xdone:
X	trie_root = compress_trie(trie_root);
X	init_trie_memory();
X	if (trie_root != 0) {
X		first_fit(trie_root);
X		trie_pack(trie_root);
X	}
X	r = 0;
X	while (trie_taken[r])
X		incr(r);
X	trie_ref[0] = r;
X	trie_fix(trie_root);
X	r = 0;
X	h.hh2.rh = 0;
X	h.hh2.b0 = 0;
X	h.hh2.b1 = 0;
X	do {
X		s = trie_link(r);
X		trie[r] = h;
X		r = s;
X	} while (r <= trie_max);
X}
X#endif
X
Xinit_hyph ()
X{
X#ifdef INIT
X	int		k;
X	int		z;
X
X	trie_op_ptr = MIN_QUARTERWORD;
X	trie_link(0) = 0;
X	trie_char(0) = 0;
X	trie_op(0) = 0;
X	for (k = 1; k <= 127; k++)
X		trie[k] = trie[0];
X	trie_max = 127;
X	for (z = 0; z <= HYPH_SIZE; z++) {
X		hyph_word[z] = 0;
X		hyph_list[z] = NULL;
X	}
X	hyph_count = 0;
X#endif
X}
SHAR_EOF
chmod 0444 hyph.c || echo "restore of hyph.c fails"
set `wc -c hyph.c`;Sum=$1
if test "$Sum" != "13684"
then echo original size 13684, current size $Sum;fi
echo "x - extracting hyph.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > hyph.h &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		hyph.h
X */
X
Xglobal	ptr		ha;
Xglobal	ptr		hb;
Xglobal	hword	hc[];
Xglobal	int		hn;
Xglobal	fnt		hf;
Xglobal	ascii	hu[];
Xglobal	int		hyf_char;
X
Xint		hyphenate();
X
Xglobal	byte	hyf[];
Xglobal	int		hyphen_passed;
X
Xint		reconstitute();
X
X#define	trie_link(T)		trie[T].hh2.rh
X#define	trie_char(T)		trie[T].hh2.b1
X#define	trie_op(T)			trie[T].hh2.b0
X
Xglobal	twoh	trie[];
Xglobal	qword	trie_op_ptr;
Xglobal	int		trie_max;
X
Xglobal	int		hyf_distance[];
Xglobal	int		hyf_num[];
Xglobal	qword	hyf_next[];
X
Xint		new_hyph_exceptions();
X
Xglobal	str		hyph_word[];
Xglobal	ptr		hyph_list[];
Xglobal	int		hyph_count;
X
X#ifdef INIT
X
Xglobal	qword	trie_op_hash[];
Xglobal	int		trie_min;
X
Xqword	new_trie_op();
X
X#define	trie_root		trie_l[0]
X
Xglobal	int		trie_ptr;
Xglobal	ascii	trie_c[];
Xglobal	qword	trie_o[];
Xglobal	int		trie_l[];
Xglobal	int		trie_r[];
X
Xglobal	int		trie_hash[];
X
Xint		trie_node();
Xint		compress_trie();
X
Xint		init_pattern_memory();
X
X#define	trie_ref			trie_hash
X#define	trie_back(T)		trie[T].hh1.lh
X
Xglobal	bool	trie_taken[];
X
Xint		init_trie_memory();
X
Xint		first_fit();
Xint		trie_pack();
Xint		trie_fix();
X
Xint		new_patterns();
X
X#endif
SHAR_EOF
chmod 0444 hyph.h || echo "restore of hyph.h fails"
set `wc -c hyph.h`;Sum=$1
if test "$Sum" != "1335"
then echo original size 1335, current size $Sum;fi
echo "x - extracting io.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > io.c &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		io.c
X */
X
X#include "tex.h"
X#include "char.h"
X#include "str.h"
X#include "tokenstack.h"
X#include "print.h"
X#include "file.h"
X#include "io.h"
X
Xint		last;
Xascii	buffer[BUF_SIZE];
Xint		first;
Xint		max_buf_stack;
X
XFILE *
Xa_open_in ()
X{
X	if (test_access(READ_ACCESS, INPUT_FILE_PATH))
X		return (fopen(name_of_file, "r"));
X	return NULL;
X}
X
XFILE *
Xa_open_out ()
X{
X	if (test_access(WRITE_ACCESS, NO_FILE_PATH))
X		return (fopen(name_of_file, "w"));
X	return NULL;
X}
X
XFILE *
Xb_open_in ()
X{
X	if (test_access(READ_ACCESS, FONT_FILE_PATH))
X		return (fopen(name_of_file, "r"));
X	return NULL;
X}
X
XFILE *
Xb_open_out ()
X{
X	if (test_access(WRITE_ACCESS, NO_FILE_PATH))
X		return (fopen(name_of_file, "w"));
X	return NULL;
X}
X
XFILE *
Xw_open_in ()
X{
X	if (test_access(READ_ACCESS, FORMAT_FILE_PATH))
X		return (fopen(name_of_file, "r"));
X	return NULL;
X}
X
XFILE *
Xw_open_out ()
X{
X	if (test_access(WRITE_ACCESS, NO_FILE_PATH))
X		return (fopen(name_of_file, "w"));
X	return NULL;
X}
X
Xbool 
Xinput_ln (f, bypass_eoln)
X	alpha_file	f;
X	bool		bypass_eoln;
X{
X	int			c;
X
X	last = first;
X	loop {
X		c = getc(f);
X		if (c == EOLN)
X			break;
X		if (c == EOF) {
X			if (last == first)
X				return FALSE;
X			else
X				break;
X		}
X		if (last > max_buf_stack) {
X			max_buf_stack = last + 1;
X			if (max_buf_stack == BUF_SIZE - 1)
X				overflow("buffer size", BUF_SIZE);
X		}
X		buffer[last] = xord[c];
X		incr(last);
X	}
X	loop {
X		if (last == first)
X			break;	
X		else if (buffer[last - 1] != ' ')
X			break;
X		else decr(last);
X	}
X	return TRUE;
X}
X
Xterm_input ()
X{
X	int		k;
X
X	update_terminal();
X	if (!input_ln(term_in, FALSE)) 
X		fatal_error("! End of file on the terminal");
X	term_offset = 0;
X	decr(selector);
X	if (last != first)
X		for (k = first; k < last; incr(k))
X			print_char(buffer[k]);
X	print_ln();
X	incr(selector);
X}
X
Xbool
Xinit_terminal ()
X{
X	loop {
X		fputs("**", stdout);
X		update_terminal();
X		if (!input_ln(term_in, FALSE)) {
X			puts("\n! End of file on the terminal...why?");
X			return FALSE;
X		}
X		loc = first;
X		while (loc < last && buffer[loc] == ' ')
X			incr(loc);
X		if (loc < last)
X			return TRUE;
X		puts("Please type the name of your input file.");
X	}
X}
SHAR_EOF
chmod 0444 io.c || echo "restore of io.c fails"
set `wc -c io.c`;Sum=$1
if test "$Sum" != "2327"
then echo original size 2327, current size $Sum;fi
echo "x - extracting io.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > io.h &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X */
X
X
X/*
X *		io.h
X */
X
Xglobal	int		last;
Xglobal	ascii	buffer[];
Xglobal	int		first;
Xglobal	int		max_buf_stack;
X
XFILE	*a_open_in();
XFILE	*a_open_out();
X
XFILE	*b_open_in();
XFILE	*b_open_out();
X
XFILE	*w_open_in();
XFILE	*w_open_out();
X
X#define	a_close(FD)				(fclose(FD))
X#define	b_close(FD)				(fclose(FD))
X#define	w_close(FD)				(fclose(FD))
X
X#define	prompt_input(S)			{print(S); term_input();}
X
Xbool 	init_terminal();
Xint		term_input();
Xbool	input_ln();
X
X#define	term_in					stdin
X#define	term_out				stdout
X#define	t_open_in()
X#define	t_open_out()
X#define	update_terminal()		fflush(stdout)
X#define	clear_terminal()
SHAR_EOF
chmod 0444 io.h || echo "restore of io.h fails"
set `wc -c io.h`;Sum=$1
if test "$Sum" != "686"
then echo original size 686, current size $Sum;fi
echo "x - extracting math.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > math.c &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		math.c
X */
X
X#include "tex.h"
X#include "heap.h"
X#include "eq.h"
X#include "scan.h"
X#include "evalstack.h"
X#include "arith.h"
X#include "str.h"
X#include "box.h"
X#include "tfm.h"
X#include "print.h"
X#include "pack.h"
X#include "math.h"
X
Xtwoh	empty_field;
X
Xptr
Xnew_style (s)
X	int		s;
X{
X	ptr		p;
X
X	p = get_node(STYLE_NODE_SIZE);
X	type(p) = STYLE_NODE;
X	subtype(p) = s;
X	width(p)= 0;
X	depth(p) = 0;
X
X	return p;
X}
X
Xptr
Xnew_choice ()
X{
X	ptr		p;
X
X	p = get_node(STYLE_NODE_SIZE);
X	type(p) = CHOICE_NODE;
X	subtype(p) = 0;
X	display_mlist(p) = NULL;
X	text_mlist(p) = NULL;
X	script_mlist(p) = NULL;
X	script_script_mlist(p) = NULL;
X
X	return p;
X}
X
Xptr
Xnew_noad ()
X{
X	ptr		p;
X
X	p = get_node(NOAD_SIZE);
X	type(p) = ORD_NOAD;
X	subtype(p) = NORMAL;
X	mem[nucleus(p)].hh = empty_field;
X	mem[subscr(p)].hh = empty_field;
X	mem[supscr(p)].hh = empty_field;
X
X	return p;
X}
X
Xprint_fam_and_char (p)
X	ptr		p;
X{
X	print_esc("fam");
X	print_int(fam(p));
X	print_char(' ');
X	print_ASCII(qo(character(p)));
X}
X
Xprint_delimiter (p)
X	ptr		p;
X{
X	val		a;
X
X	a = small_fam(p) * 256 + qo(small_char(p));
X	a = a * 0x1000 + large_fam(p) * 256 + qo(large_char(p));
X	if (a < 0)
X		print_val(a);
X	else print_hex(a);
X}
X
Xprint_subsidiary_data (p, c)
X	ptr		p;
X	ascii	c;
X{
X	if (cur_length() >= depth_threshold) {
X		if (math_type(p) != EMPTY)
X			print(" []");
X		return;
X	}
X	append_char(c);
X	temp_ptr = p;
X	switch (math_type(p))
X	{
X	case MATH_CHAR:
X		print_ln();
X		print_current_string();
X		print_fam_and_char(p);
X		break;
X	
X	case SUB_BOX:
X		show_info();
X		break;
X	
X	case SUB_MLIST:
X		if (info(p) == NULL) {
X			print_ln();
X			print_current_string();
X			print("{}");
X		} else show_info();
X		break;
X	}
X	flush_char();
X}
X
Xprint_style (c)
X	int	  c;
X{
X	switch (c / 2) 
X	{
X	case 0:
X		print_esc("displaystyle");
X		break;
X
X	case 1:
X		print_esc("textstyle");
X		break;
X
X	case 2:
X		print_esc("scriptstyle");
X		break;
X
X	case 3:
X		print_esc("scriptscriptstyle");
X		break;
X
X	default:
X		print("Unknown style!");
X		break;
X	}
X}
X
Xprint_size (s)
X	int		s;
X{
X	if (s == 0)
X		print_esc("textfont");
X	else if (s == SCRIPT_SIZE)
X		print_esc("scriptfont");
X	else print_esc("scriptscriptfont");
X}
X
Xshow_normal_noad (p)
X	ptr		p;
X{
X	switch (type(p)) 
X	{
X	case ORD_NOAD:
X		print_esc("mathord");
X		break;
X
X	case OP_NOAD:
X		print_esc("mathop");
X		break;
X
X	case BIN_NOAD:
X		print_esc("mathbin");
X		break;
X
X	case REL_NOAD:
X		print_esc("mathrel");
X		break;
X
X	case OPEN_NOAD:
X		print_esc("mathopen");
X		break;
X
X	case CLOSE_NOAD:	
X		print_esc("mathclose");
X		break;
X
X	case PUNCT_NOAD:
X		print_esc("mathpunct");
X		break;
X
X	case INNER_NOAD:
X		print_esc("mathinner");
X		break;
X
X	case OVER_NOAD:
X		print_esc("overline");
X		break;
X
X	case UNDER_NOAD:
X		print_esc("underline");
X		break;
X
X	case VCENTER_NOAD:
X		print_esc("vcenter");
X		break;
X
X	case RADICAL_NOAD:
X		print_esc("radical");
X		print_delimiter(left_delimiter(p));
X		break;
X
X	case ACCENT_NOAD:
X		print_esc("accent");
X		print_fam_and_char(accent_chr(p));
X		break;
X
X	case LEFT_NOAD:
X		print_esc("left");
X		print_delimiter(nucleus(p));
X		break;
X
X	case RIGHT_NOAD:
X		print_esc("right");
X		print_delimiter(nucleus(p));
X		break;
X
X	}
X	if (subtype(p) != NORMAL)
X		if (subtype(p) == LIMITS)
X			print_esc("limits");
X		else print_esc("nolimits");
X	if (type(p) < LEFT_NOAD)
X		print_subsidiary_data(nucleus(p), '.');
X	print_subsidiary_data(supscr(p), '^');
X	print_subsidiary_data(subscr(p), '_');
X}
X
Xshow_fraction_noad (p)
X	ptr		p;
X{
X	print_esc("fraction, thickness ");
X	if (thickness(p) == DEFAULT_CODE)
X		print("= default");
X	else print_scaled(thickness(p));
X	if (small_fam(left_delimiter(p)) != 0 ||
X		small_char(left_delimiter(p)) != MIN_QUARTERWORD ||
X		large_fam(left_delimiter(p)) != 0 ||
X		large_char(left_delimiter(p)) != MIN_QUARTERWORD) {
X		print(", left-delimiter ");
X		print_delimiter(left_delimiter(p));
X	}
X	if (small_fam(right_delimiter(p)) != 0 ||
X		small_char(right_delimiter(p)) != MIN_QUARTERWORD ||
X		large_fam(right_delimiter(p)) != 0 ||
X		large_char(right_delimiter(p)) != MIN_QUARTERWORD) {
X		print(", right-delimiter ");
X		print_delimiter(right_delimiter(p));
X	}
X	print_subsidiary_data(numerator(p), '\\');
X	print_subsidiary_data(denominator(p), '/');
X}
X
Xshow_choice_node (p)
X	ptr 	p;
X{
X	print_esc("mathchoice");
X	append_char('D');
X	show_node_list(display_mlist(p));
X	flush_char();
X	append_char('T');
X	show_node_list(text_mlist(p));
X	flush_char();
X	append_char('S');
X	show_node_list(script_mlist(p));
X	flush_char();
X	append_char('s');
X	show_node_list(script_script_mlist(p));
X	flush_char();
X}
X
Xptr
Xfraction_rule (t)
X	scal	t;
X{
X	ptr		p;
X
X	p = new_rule();
X	height(p) = t;
X	depth(p) = 0;
X
X	return p;
X}
X
Xptr
Xoverbar (b, k, t)
X	ptr		b;
X	scal	k;
X	scal	t;
X{
X	ptr		p;
X	ptr		q;
X
X	p = new_kern(k);
X	link(p) = b;
X	q = fraction_rule(t);
X	link(q) = p;
X	p = new_kern(t);
X	link(p) = q;
X	return (vpack(p, NATURAL));
X}
X
Xptr
Xvar_delimiter (d, s, v)
X	ptr		d;
X	int		s;
X	scal	v;
X{
X	ptr		b;
X	qword	c;
X	fnt		f;
X	fnt		g;
X	int		m;
X	int		n;
X	fourq	q;
X	fourq	r;
X	scal	u;
X	scal	w;
X	qword	x;
X	qword	y;
X	int		z;
X	byte	hd;
X	bool	large_attempt;
X
X	f = NULL_FONT;
X	w = 0;
X	large_attempt = FALSE;
X	z = small_fam(d);
X	x = small_char(d);
X	loop {
X		if (z != 0 || x != MIN_QUARTERWORD) {
X			z = z + s + 16;
X			do {
X				z = z - 16;
X				g = fam_fnt(z);
X				if (g != NULL_FONT) {
X					y = x;
X			contin:
X					if (qo(y) >= font_bc[g] && qo(y) <= font_ec[g]) {
X						q = char_info(g, y);
X						if (char_exists(q)) {
X							if (char_tag(q) == EXT_TAG)  {
X								f = g;
X								c = y;
X								goto found;
X							}
X							hd = height_depth(q);
X							u = char_height(g, hd) + char_depth(g, hd);
X							if (u > w) {
X								f = g;
X								c = y;
X								w = u;
X								if (u >= v)
X									goto found;
X							}
X							if (char_tag(q) == LIST_TAG) {
X								y = rem_byte(q);
X								goto contin;
X							}
X						}
X					}
X				}
X			} while (z >= 16);
X		}
X		if (large_attempt)
X			goto found;
X		large_attempt = TRUE;
X		z = large_fam(d);
X		x = large_char(d);
X	}
X
Xfound:
X	if (f != NULL_FONT) {
X		if (char_tag(q) == EXT_TAG) {
X			b = new_null_box();
X			type(b) = VLIST_NODE;
X			r = font_info[exten_base[f] + rem_byte(q)].qqqq;
X			c = ext_rep(r);
X			u = height_plus_depth(f, c);
X			w = 0;
X			q = char_info(f, c);
X			width(b) = char_width(f, q) + char_italic(f, q);
X			c = ext_bot(r); 
X			if (c != MIN_QUARTERWORD)
X				w += height_plus_depth(f, c);
X			c = ext_mid(r);
X			if (c != MIN_QUARTERWORD)
X				w += height_plus_depth(f, c);
X			c = ext_top(r);
X			if (c != MIN_QUARTERWORD)
X				w += height_plus_depth(f, c);
X			n = 0;
X			if (u > 0) {
X				while (w < v) {
X					w = w + u;
X					incr(n);
X					if (ext_mid(r) != MIN_QUARTERWORD)
X						w = w + u;
X				}
X			}
X			c = ext_bot(r);
X			if (c != MIN_QUARTERWORD)
X				stack_into_box(b, f, c);
X			c = ext_rep(r);
X			for (m = 1; m <= n; incr(m)) 
X				stack_into_box(b, f, c);
X			c = ext_mid(r);
X			if (c != MIN_QUARTERWORD) {
X				stack_into_box(b, f, c);
X				c = ext_rep(r);
X				for (m = 1; m <= n; incr(m))
X					stack_into_box(b, f, c);
X			}
X			c = ext_top(r);
X			if (c != MIN_QUARTERWORD)
X				stack_into_box(b, f, c);
X			depth(b) = w - height(b);
X		} else
X			b = char_box(f, c);
X	} else {
X		b = new_null_box();
X		width(b) = null_delimiter_space;
X	}
X	shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
X	return b;
X}
X
Xptr
Xchar_box (f, c)
X	fnt		f;
X	qword	c;
X{
X	ptr		b;
X	ptr		p;
X	fourq	q;
X	byte	hd;
X
X	q = char_info(f, c);
X	hd = height_depth(q);
X	b = new_null_box();
X	width(b) = char_width(f, q) + char_italic(f, q);
X	height(b) = char_height(f, hd);
X	depth(b) = char_depth(f, hd);
X	p = get_avail();
X	character(p) = c;
X	font(p) = f;
X	list_ptr(b) = p;
X	
X	return b;
X}
X
Xstack_into_box (b, f, c)
X	ptr		b;
X	fnt		f;
X	qword	c;
X{
X	ptr		p;
X
X	p = char_box(f, c);
X	link(p) = list_ptr(b);
X	list_ptr(b) = p;
X	height(b) = height(p);
X}
X
Xscal
Xheight_plus_depth (f, c)
X	fnt		f;
X	qword	c;
X{
X	fourq	q;
X	byte	hd;
X
X	q = char_info(f, c);
X	hd = height_depth(q);
X	return (char_height(f, hd) + char_depth(f, hd));
X}
X
Xptr
Xrebox (b, w)
X	ptr		b;
X	scal	w;
X{
X	fnt		f;
X	ptr		p;
X	scal	v;
X
X	if (width(b) != w && list_ptr(b) != NULL) {
X		if (type(b) == VLIST_NODE)
X			b = hpack(b, NATURAL);
X		p = list_ptr(b);
X		if (is_char_node(p) && link(p) == NULL) {
X			f = font(p);
X			v = char_width(f, char_info(f, character(p)));
X			if (v != width(b)) 
X				link(p) = new_kern(width(b) - v);
X		}
X		free_node(b, BOX_NODE_SIZE);
X		b = new_glue(ss_glue);
X		link(b) = p;
X		while (link(p) != NULL)
X			p = link(p);
X		link(p) = new_glue(ss_glue); 
X		return (hpack(b, w, EXACTLY));
X	} else {
X		width(b) = w;
X		return b;
X	}
X}
X
X#define	mu_mult(x) \
X	nx_plus_y(n, x, xn_over_d(x, f, 0200000L))
X
Xptr
Xmath_glue (g, m)
X	ptr		g;
X	scal	m;
X{
X	scal	f;
X	val		n;
X	ptr		p;
X
X	n = x_over_n(m, 0200000L);
X	f = remainder;
X	p = get_node(GLUE_SPEC_SIZE);
X	width(p) = mu_mult(width(g));
X	stretch_order(p) = stretch_order(g);
X	if (stretch_order(p) == NORMAL)
X		stretch(p) = mu_mult(stretch(g));
X	else stretch(p) = stretch(g);
X	shrink_order(p) = shrink_order(g);
X	if (shrink_order(p) == NORMAL)
X		shrink(p) = mu_mult(shrink(g));
X	else shrink(p) = shrink(g);
X
X	return p;
X}
X
Xmath_kern (p, m)
X	ptr		p;
X	scal	m;
X{
X	scal	f;
X	val		n;
X
X	if (subtype(p) == MU_GLUE) {
X		n = x_over_n(m, 0200000L);
X		f = remainder;
X		width(p) = mu_mult(width(p));
X		subtype(p) = NORMAL;
X	}
X}
X
Xflush_math ()
X{
X	flush_node_list(link(head));
X	flush_node_list(incompleat_noad);
X	link(head) = NULL;
X	tail = head;
X	incompleat_noad = NULL;
X}
SHAR_EOF
chmod 0444 math.c || echo "restore of math.c fails"
set `wc -c math.c`;Sum=$1
if test "$Sum" != "9504"
then echo original size 9504, current size $Sum;fi
echo "x - extracting math.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > math.h &&
X
X/*
X *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
X *    Copying of this file is granted according to the provisions 
X *    specified in the file COPYING which must accompany this file.
X */
X
X
X/*
X *		math.h
X */
X
Xptr	new_style();
X
X#define	STYLE_NODE				(UNSET_NODE + 1)
X#define	STYLE_NODE_SIZE			3
X#define	DISPLAY_STYLE			0
X#define	TEXT_STYLE				2
X#define	SCRIPT_STYLE			4
X#define	SCRIPT_SCRIPT_STYLE		6
X#define	CRAMPED					1
X
Xptr	new_choice();
X
X#define	CHOICE_NODE				(UNSET_NODE + 2)
X#define	display_mlist(C)		info(C + 1)
X#define	text_mlist(C)			link(C + 1)
X#define	script_mlist(C)			info(C + 2)
X#define	script_script_mlist(C)	link(C + 2)
X
Xptr	new_noad();
X
X#define	NOAD_SIZE			4
X#define	nucleus(N)			(N + 1)
X#define	supscr(N)			(N + 2)
X#define	subscr(N)			(N + 3)
X#define	fam					font
X#define	math_type			link
X
X#define	ORD_NOAD			(UNSET_NODE + 3)
X#define	OP_NOAD				(ORD_NOAD + 1)
X#define	BIN_NOAD			(ORD_NOAD + 2)
X#define	REL_NOAD			(ORD_NOAD + 3)
X#define	OPEN_NOAD			(ORD_NOAD + 4)
X#define	CLOSE_NOAD			(ORD_NOAD + 5)
X#define	PUNCT_NOAD			(ORD_NOAD + 6)
X#define	INNER_NOAD			(ORD_NOAD + 7)
X
X#define	MATH_CHAR			1
X#define	SUB_BOX				2
X#define	SUB_MLIST			3
X#define	MATH_TEXT_CHAR		4
X
X#define	LIMITS				1
X#define	NO_LIMITS			2
X
X#define	left_delimiter(D)	(D + 4)
X#define	right_delimiter(D)	(D + 5)
X
X#define	small_fam(D)		mem[D].qqqq.b0
X#define	small_char(D)		mem[D].qqqq.b1
X#define	large_fam(D)		mem[D].qqqq.b2
X#define	large_char(D)		mem[D].qqqq.b3
X
X#define	RADICAL_NOAD		(INNER_NOAD + 1)
X#define	RADICAL_NOAD_SIZE	5
X#define	FRACTION_NOAD		(RADICAL_NOAD + 1)
X#define	FRACTION_NOAD_SIZE	6
X#define	DEFAULT_CODE		010000000000
X#define	thickness			width
X#define	numerator			supscr
X#define	denominator			subscr
X
X#define	null_delimiter		null_character
X
Xglobal	twoh	empty_field;
X
X#define	UNDER_NOAD			(FRACTION_NOAD + 1)
X#define	OVER_NOAD			(UNDER_NOAD + 1)
X#define	ACCENT_NOAD			(OVER_NOAD + 1)
X#define	ACCENT_NOAD_SIZE	5
X#define	accent_chr(A)		(A + 4)
X#define	VCENTER_NOAD		(ACCENT_NOAD + 1)
X#define	LEFT_NOAD			(VCENTER_NOAD + 1)
X#define	RIGHT_NOAD			(LEFT_NOAD + 1)
X#define	delimiter			nucleus	
X
X#define	scripts_allowed(N)	(type(N) >= ORD_NOAD && type(N) < LEFT_NOAD)
X
Xint		print_fam_and_char();
Xint		print_delimiter();
Xint		print_subsidiary_data();
Xint		print_style();
Xint		print_size();
X
X#define	TEXT_SIZE			0
X#define	SCRIPT_SIZE			16
X#define	SCRIPT_SCRIPT_SIZE	32
X
Xint		show_normal_noad();
Xint		show_fraction_noad();
X
X#define	mathsy(F, P) \
X	font_info[param_base[fam_fnt(2 + F)] + P].sc
X
X#define	math_x_height(F)	mathsy(F, 5)
X#define	math_quad(F)		mathsy(F, 6)
X#define	num1(F)				mathsy(F, 8)
X#define	num2(F)				mathsy(F, 9)
X#define	num3(F)				mathsy(F, 10)
X#define	denom1(F)			mathsy(F, 11)
X#define	denom2(F)			mathsy(F, 12)
X#define	sup1(F)				mathsy(F, 13)
X#define	sup2(F)				mathsy(F, 14)
X#define	sup3(F)				mathsy(F, 15)
X#define	sub1(F)				mathsy(F, 16)
X#define	sub2(F)				mathsy(F, 17)
X#define	sup_drop(F)			mathsy(F, 18)
X#define	sub_drop(F)			mathsy(F, 19)
X#define	delim1(F)			mathsy(F, 20)
X#define	delim2(F)			mathsy(F, 21)
X#define	axis_height(F)		mathsy(F, 22)
X
X#define	TOTAL_MATHSY_PARAMS	22
X
X#define	mathex(P) \
X	font_info[param_base[fam_fnt(3 + cur_size)] + P].sc
X
X#define	default_rule_thickness	mathex(8)
X#define	big_op_spacing1			mathex(9)
X#define	big_op_spacing2			mathex(10)
X#define	big_op_spacing3			mathex(11)
X#define	big_op_spacing4			mathex(12)
SHAR_EOF
echo "End of part 9"
echo "File math.h is continued in part 10"
echo "10" > s2_seq_.tmp
exit 0



More information about the Comp.unix.xenix mailing list