LaTeX for Xenix

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


---- Cut Here and unpack ----
#!/bin/sh
# this is part 10 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file math.h continued
#
CurArch=10
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 math.h"
sed 's/^X//' << 'SHAR_EOF' >> math.h
X#define	big_op_spacing5			mathex(13)
X
X#define	TOTAL_MATHEX_PARAMS	13
X
X#define	cramped_style(S)	2 * (S / 2) + CRAMPED
X#define	sub_style(S)		2 * (S / 4) + SCRIPT_STYLE + CRAMPED
X#define	sup_style(S)		2 * (S / 4) + SCRIPT_STYLE + (S % 2)
X#define	num_style(S)		S + 2 - 2 * (S / 6)
X#define	denom_style(S)		2 * (S / 2) + CRAMPED + 2 - 2 * (S / 6)
X
X#define change_size_and_mu() \
X	{if (cur_style < SCRIPT_STYLE) \
X		cur_size = TEXT_SIZE; \
X	else cur_size = 16 * ((cur_style - TEXT_STYLE) / 2); \
X	cur_mu = x_over_n(math_quad(cur_size), 18L);}
X
Xptr		fraction_rule();
Xptr		overbar();
Xptr		var_delimiter();
Xint		stack_into_box();
Xscal	height_plus_depth();
Xptr		char_box();
Xptr		rebox();
Xptr		math_glue();
Xint		math_kern();
Xint		flush_math();
SHAR_EOF
echo "File math.h is complete"
chmod 0444 math.h || echo "restore of math.h fails"
set `wc -c math.h`;Sum=$1
if test "$Sum" != "4115"
then echo original size 4115, current size $Sum;fi
echo "x - extracting mathlists.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > mathlists.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 *		mathlists.c
X */
X
X#include "tex.h"
X#include "cmds.h"
X#include "heap.h"
X#include "arith.h"
X#include "eq.h"
X#include "eqstack.h"
X#include "evalstack.h"
X#include "token.h"
X#include "tokenstack.h"
X#include "scan.h"
X#include "tfm.h"
X#include "box.h"
X#include "pack.h"
X#include "math.h"
X#include "mlist-hlist.h"
X#include "par.h"
X#include "page.h"
X#include "print.h"
X#include "error.h"
X#include "mathlists.h"
X
Xpush_math (c)
X	group	c;
X{
X	push_nest();
X	mode = -MMODE;
X	incompleat_noad = NULL;
X	new_save_level(c);
X}
X
Xinit_math ()
X{
X	scal	d;
X	fnt		f;
X	scal	l;
X	int		n;
X	ptr		p;
X	ptr		q;
X	scal	s;
X	scal	v;
X	scal	w;
X
X	get_token();
X	if (cur_cmd == MATH_SHIFT && mode > 0) {
X		if (head == tail) {
X			pop_nest();
X			w = -MAX_DIMEN;
X		} else {
X			line_break(display_widow_penalty);
X			v = shift_amount(just_box) + 2 * quad(cur_font);
X			w = -MAX_DIMEN;
X			p = list_ptr(just_box);
X			while (p != NULL) {
X		reswitch:
X				if (is_char_node(p)) {
X					f = font(p);
X					d = char_width(f, char_info(f, character(p)));
X					goto found;
X				}
X				switch (type(p))
X				{
X				case HLIST_NODE:
X				case VLIST_NODE:
X				case RULE_NODE:
X					d = width(p);
X					goto found;
X					break;
X				
X				case LIGATURE_NODE:
X					make_char_from_lig();
X					goto reswitch;
X					break;
X				
X				case KERN_NODE:
X				case MATH_NODE:
X					d = width(p);
X					break;
X
X				case GLUE_NODE:
X					q = glue_ptr(p);
X					d = width(q);
X					if (glue_sign(just_box) == STRETCHING) {
X						if (glue_order(just_box) == stretch_order(q) &&
X							stretch(q) != 0)
X							v = MAX_DIMEN;
X					} else if (glue_sign(just_box) == SHRINKING)  {
X						if (glue_order(just_box) == shrink_order(q) &&
X							shrink(q) != 0) 
X							v = MAX_DIMEN;
X					}
X					if (subtype(p) >= A_LEADERS)	
X						goto found;
X					break;
X
X				case WHATSIT_NODE: 
X					d = 0;
X					break;
X
X				default:
X					d = 0;
X					break;
X				}
X				if (v < MAX_DIMEN)
X					v += d;
X				goto not_found;
X			
X			found:
X				if (v < MAX_DIMEN) {
X					v += d;
X					w = v;
X				} else {
X					w = MAX_DIMEN;
X					break;
X				}
X
X			not_found:
X				p = link(p);
X			}
X		}
X		if (par_shape_ptr == NULL) {
X			if (hang_indent != 0 &&
X				(hang_after >= 0 &&
X				prev_graf + 2 > hang_after ||
X				prev_graf + 1 < -hang_after)) {
X				l = hsize - abs(hang_indent);
X				s = (hang_indent > 0) ? hang_indent : 0;
X			} else {
X				l = hsize;
X				s = 0;
X			}
X		} else {
X			n = info(par_shape_ptr);
X			if (prev_graf + 2 >= n)
X				p = par_shape_ptr + 2 * n;
X			else p = par_shape_ptr + 2 * (prev_graf + 2);
X			s = mem[p - 1].sc;
X			l = mem[p].sc;
X		}
X		push_math(MATH_SHIFT_GROUP);
X		mode = MMODE;
X		eq_word_define(INT_BASE + CUR_FAM_CODE, -1L);
X		eq_word_define(DIMEN_BASE + PRE_DISPLAY_SIZE_CODE, w);
X		eq_word_define(DIMEN_BASE + DISPLAY_WIDTH_CODE, l);
X		eq_word_define(DIMEN_BASE + DISPLAY_INDENT_CODE, s);
X		if (every_display != NULL)
X			begin_token_list(every_display, EVERY_DISPLAY_TEXT);
X		if (nest_ptr == 1)
X			build_page();
X	} else {
X		back_input(); 
X		push_math(MATH_SHIFT_GROUP);
X		eq_word_define(INT_BASE + CUR_FAM_CODE, -1L);
X		if (every_math != NULL)
X			begin_token_list(every_math, EVERY_MATH_TEXT);
X	}
X}
X
Xstart_eq_no ()
X{
X	saved(0) = cur_chr;
X	incr(save_ptr);
X	push_math(MATH_SHIFT_GROUP);
X	eq_word_define(INT_BASE + CUR_FAM_CODE, -1L);
X	if (every_math != NULL)
X		begin_token_list(every_math, EVERY_MATH_TEXT);
X}
X
X#define	fam_in_range()	 (cur_fam >= 0 && cur_fam < 16)
X
Xscan_math (p)
X	ptr		p;
X{
X	int		c;
X
Xrestart:
X	get_nbrx_token();
X
Xreswitch:
X	switch (cur_cmd)
X	{
X	case LETTER:
X	case OTHER_CHAR:
X	case CHAR_GIVEN:
X		if (cur_chr >= 128)
X			c = cur_chr;
X		else {
X			c = ho(math_code(cur_chr));
X			if (c == 0100000) {
X				cur_cs = cur_chr + ACTIVE_BASE;
X				cur_cmd = eq_type(cur_cs);
X				cur_chr = equiv(cur_cs);
X				x_token();
X				back_input();
X				goto restart;
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 MATH_CHAR_NUM:
X		scan_fifteen_bit_int();
X		c = cur_val;
X		break;
X
X	case MATH_GIVEN:
X		c = cur_chr;
X		break;
X		
X	case DELIM_NUM:
X		scan_twenty_seven_bit_int();
X		c = cur_val / 010000;
X		break;
X
X	default:
X		back_input();
X		scan_left_brace();
X		saved(0) = p;
X		incr(save_ptr);
X		push_math(MATH_GROUP);
X		return;
X		break;
X	}
X	math_type(p) = MATH_CHAR;
X	character(p) = c % 256;
X	if (c >= VAR_CODE && fam_in_range())
X		fam(p) = cur_fam;
X	else fam(p) = (c / 256) % 16;
X}
X
Xset_math_char (c)
X	val		c;
X{
X	ptr		p;
X
X	if (c >= 0100000) {
X		cur_cs = cur_chr + ACTIVE_BASE;
X		cur_cmd = eq_type(cur_cs);
X		cur_chr = equiv(cur_cs);
X		x_token();
X		back_input();
X	} else {
X		p = new_noad();
X		math_type(nucleus(p)) = MATH_CHAR;
X		character(nucleus(p)) = c % 256;
X		fam(nucleus(p)) = (c / 256) % 16;
X		if (c >= VAR_CODE) {
X			if (fam_in_range())
X				fam(nucleus(p)) = cur_fam;
X			type(p) = ORD_NOAD;
X		} else type(p) = ORD_NOAD + (c / 010000);
X		link(tail) = p;
X		tail = p;
X	}
X}
X
Xmath_limit_switch ()
X{
X	if (head != tail && type(tail) == OP_NOAD) {
X		subtype(tail) = cur_chr;
X		return;
X	}
X	print_err("Limit controls must follow a math operator");
X	help_limits();
X	error();
X}
X
Xscan_delimiter (p, r)
X	ptr		p;
X	bool	r;
X{
X	if (r)
X		scan_twenty_seven_bit_int();
X	else {
X		get_nbrx_token();
X		switch (cur_cmd) 
X		{
X		case LETTER:
X		case OTHER_CHAR:
X			cur_val = del_code(cur_chr);
X			break;
X
X		case DELIM_NUM:
X			scan_twenty_seven_bit_int();
X			break;
X
X		default:
X			cur_val = -1;
X			break;
X		}
X	}
X	if (cur_val < 0) {
X		print_err("Missing delimiter (. inserted)");
X		help_delimiter();
X		back_error();
X		cur_val = 0;
X	}
X	small_fam(p) = (cur_val / 04000000) % 16;
X	small_char(p) = qi((cur_val / 010000) % 256);
X	large_fam(p) = (cur_val / 256) % 16;
X	large_char(p) = qi(cur_val % 256);
X}
X
Xmath_radical ()
X{
X	tail_append(get_node(RADICAL_NOAD_SIZE));
X	type(tail) = RADICAL_NOAD;
X	subtype(tail) = NORMAL;
X	mem[nucleus(tail)].hh = empty_field;
X	mem[supscr(tail)].hh = empty_field;
X	mem[subscr(tail)].hh = empty_field;
X	scan_delimiter(left_delimiter(tail), TRUE);
X	scan_math(nucleus(tail));
X}
X
Xmath_ac ()
X{
X	if (cur_cmd == ACCENT) {
X		print_err("Please use ");
X		print_esc("mathaccent");
X		print(" for accents in math mode");
X		help_math_accent();
X		error();
X	}
X	tail_append(get_node(ACCENT_NOAD_SIZE));
X	type(tail) = ACCENT_NOAD;
X	subtype(tail) = NORMAL;
X	mem[nucleus(tail)].hh = empty_field;
X	mem[subscr(tail)].hh = empty_field;
X	mem[supscr(tail)].hh = empty_field;
X	math_type(accent_chr(tail)) = MATH_CHAR;
X	scan_fifteen_bit_int();
X	character(accent_chr(tail)) = qi(cur_val % 256);
X	if (cur_val >= VAR_CODE && fam_in_range())
X		fam(accent_chr(tail)) = cur_fam;
X	else fam(accent_chr(tail)) = (cur_val / 256) % 16;
X	scan_math(nucleus(tail));
X}
X
Xappend_choices ()
X{
X	tail_append(new_choice());
X	incr(save_ptr);
X	saved(-1) = 0;
X	scan_left_brace();
X	push_math(MATH_CHOICE_GROUP);
X}
X
Xbuild_choices ()
X{
X	ptr		p;
X
X	unsave();
X	p = fin_mlist(NULL);
X	switch ((int) saved(-1))
X	{
X	case 0:
X		display_mlist(tail) = p;
X		break;
X
X	case 1:
X		text_mlist(tail) = p;
X		break;
X
X	case 2:
X		script_mlist(tail) = p;
X		break;
X
X	case 3:
X		script_script_mlist(tail) = p;
X		decr(save_ptr);
X		return;
X	}
X	incr(saved(-1));
X	scan_left_brace();
X	push_math(MATH_CHOICE_GROUP);
X}
X
Xsub_sup ()
X{
X	ptr		p = NULL;
X	short	t = EMPTY;
X
X	if (tail != head && scripts_allowed(tail)) {
X		p = supscr(tail) + cur_cmd - SUP_MARK;
X		t = math_type(p);
X	}
X	if (p == NULL || t != EMPTY) {
X		tail_append(new_noad());
X		p = supscr(tail) + cur_cmd - SUP_MARK;
X		if (t != EMPTY) {
X			if (cur_cmd == SUP_MARK) {
X				print_err("Double superscript");
X				help_double_sup();
X			} else {
X				print_err("Double subscript");
X				help_double_sub();
X			}
X			error();
X		}
X	}
X	scan_math(p);
X}
X
Xmath_fraction ()
X{
X	int		c;
X
X	c = cur_chr;
X	if (incompleat_noad != NULL) {
X		if (c >= DELIMITED_CODE) {
X			scan_delimiter(garbage, FALSE);
X			scan_delimiter(garbage, FALSE);
X		}
X		if (c % DELIMITED_CODE == ABOVE_CODE)
X			scan_normal_dimen();
X		print_err("Ambiguous; you need another { and }");
X		help_fraction();
X		error();
X	} else {
X		incompleat_noad = get_node(FRACTION_NOAD_SIZE);
X		type(incompleat_noad) = FRACTION_NOAD;
X		subtype(incompleat_noad) = NORMAL;
X		math_type(numerator(incompleat_noad)) = SUB_MLIST;
X		info(numerator(incompleat_noad)) = link(head);
X		mem[denominator(incompleat_noad)].hh = empty_field;
X		mem[left_delimiter(incompleat_noad)].qqqq = null_delimiter;
X		mem[right_delimiter(incompleat_noad)].qqqq = null_delimiter;
X		link(head) = NULL;
X		tail = head;
X		if (c >= DELIMITED_CODE) {
X			scan_delimiter(left_delimiter(incompleat_noad), FALSE);
X			scan_delimiter(right_delimiter(incompleat_noad), FALSE);
X		}
X		switch (c % DELIMITED_CODE)
X		{
X		case ABOVE_CODE:
X			scan_normal_dimen();
X			thickness(incompleat_noad) = cur_val;
X			break;
X
X		case OVER_CODE:
X			thickness(incompleat_noad) = DEFAULT_CODE;
X			break;
X
X		case ATOP_CODE:
X			thickness(incompleat_noad) = 0;
X			break;
X		}
X	}
X}
X
Xptr
Xfin_mlist (p)
X	ptr		p;
X{
X	ptr		q;
X
X	if (incompleat_noad != NULL) {
X		math_type(denominator(incompleat_noad)) = SUB_MLIST;
X		info(denominator(incompleat_noad)) = link(head);
X		if (p == NULL)
X			q = incompleat_noad;
X		else {
X			q = info(numerator(incompleat_noad));
X			if (type(q) != LEFT_NOAD)
X				confusion("right");
X			info(numerator(incompleat_noad)) = link(q);
X			link(q) = incompleat_noad;
X			link(incompleat_noad) = p;
X		}
X	} else {
X		link(tail) = p;
X		q = link(head);
X	}
X	pop_nest();
X	return q;
X}
X
Xmath_left_right ()
X{
X	ptr		p;
X	int		t;
X
X	t = cur_chr;
X	if (t == RIGHT_NOAD && cur_group != MATH_LEFT_GROUP) {
X		if (cur_group == MATH_SHIFT_GROUP) {
X			scan_delimiter(garbage, FALSE);
X			print_err("Extra ");
X			print_esc("right");
X			help_xtra_right();
X			error();
X		} else
X			off_save();
X	} else {
X		p = new_noad();
X		type(p) = t;
X		scan_delimiter(delimiter(p), FALSE);
X		if (t == LEFT_NOAD) {
X			push_math(MATH_LEFT_GROUP);
X			link(head) = p;
X			tail = p;
X		} else {
X			p = fin_mlist(p);
X			unsave();
X			tail_append(new_noad());
X			type(tail) = INNER_NOAD;
X			math_type(nucleus(tail)) = SUB_MLIST;
X			info(nucleus(tail)) = p;
X		}
X	}
X}
X
Xafter_math ()
X{
X	ptr		a;
X	ptr		b;
X	scal	d;
X	scal	e;
X	bool	l;
X	int		m;
X	ptr		p;
X	scal	q;
X	ptr		r;
X	scal	s;
X	scal	t;
X	scal	w;
X	scal	z;
X	int		g1;
X	int		g2;
X	bool	danger;
X
X	danger = FALSE;
X	if (font_params[fam_fnt(2 + TEXT_SIZE)] < TOTAL_MATHSY_PARAMS ||
X		font_params[fam_fnt(2 + SCRIPT_SIZE)] < TOTAL_MATHSY_PARAMS ||
X		font_params[fam_fnt(2 + SCRIPT_SCRIPT_SIZE)] < TOTAL_MATHSY_PARAMS) {
X		print_err("Math formula deleted: Insufficient symbol fonts");
X		help_math_sy();
X		error();
X		flush_math();
X		danger = TRUE;
X	} else if (font_params[fam_fnt(3 + TEXT_SIZE)] < TOTAL_MATHEX_PARAMS ||
X		font_params[fam_fnt(3 + SCRIPT_SIZE)] < TOTAL_MATHEX_PARAMS ||
X		font_params[fam_fnt(3 + SCRIPT_SCRIPT_SIZE)] < TOTAL_MATHEX_PARAMS) {
X		print_err("Math formula deleted: Insufficient extension fonts");
X		help_math_ex();
X		error();
X		flush_math();
X		danger = TRUE;
X	}
X	m = mode;
X	l = FALSE;
X	p = fin_mlist(NULL);
X	if (mode == -m) {
X		cur_mlist = p;
X		cur_style = TEXT_STYLE;
X		mlist_penalties = FALSE;
X		mlist_to_hlist();
X		a = hpack(link(temp_head), NATURAL);
X		unsave();
X		decr(save_ptr);
X		if (saved(0) == 1)
X			l = TRUE;
X		if (danger)
X			flush_math();
X		m = mode;
X		p = fin_mlist(NULL);
X	} else
X		a = NULL;
X	if (m < 0) {
X		tail_append(new_math(math_surround, BEFORE));
X		cur_mlist = p;
X		cur_style = TEXT_STYLE;
X		mlist_penalties = (mode > 0);
X		mlist_to_hlist();
X		link(tail) = link(temp_head);
X		while (link(tail) != NULL)
X			tail = link(tail);
X		tail_append(new_math(math_surround, AFTER));
X		space_factor = 1000;
X		unsave();
X	} else {
X		get_x_token();
X		if (cur_cmd != MATH_SHIFT) {
X			print_err("Display math should end with $$");
X			help_doldol();
X			back_error();
X		}
X		cur_mlist = p;
X		cur_style = DISPLAY_STYLE;
X		mlist_penalties = FALSE;
X		mlist_to_hlist();
X		p = link(temp_head);
X		adjust_tail = adjust_head;
X		b = hpack(p, NATURAL);
X		t = adjust_tail;
X		adjust_tail = NULL;
X		w = width(b);
X		z = display_width;
X		s = display_indent;
X		if (a == NULL || danger)
X			e = q = 0;
X		else {
X			e = width(a);
X			q = e + math_quad(TEXT_SIZE);
X		}
X		if (w + q > z) {
X			if (e != 0 &&
X				(w - total_shrink[NORMAL] + q <= z ||
X				total_shrink[FIL] != 0 ||
X				total_shrink[FILL] != 0 ||
X				total_shrink[FILLL] != 0)) {
X				free_node(b, BOX_NODE_SIZE);
X				b = hpack(p, z - q, EXACTLY);
X			} else {
X				e = 0;
X				if (w > z) {
X					free_node(b, BOX_NODE_SIZE);
X					b = hpack(p, z, EXACTLY);
X				}
X			}
X			w = width(b);
X		}
X		d = half(z - w);
X		if (e > 0 && d < 2 * e) {
X			d = half(z - w - e);
X			if (p != NULL && type(p) == GLUE_NODE)
X				d = 0;
X		}
X		tail_append(new_penalty(pre_display_penalty));
X		if (d + s <= pre_display_size || l) {
X			g1 = ABOVE_DISPLAY_SKIP_CODE;
X			g2 = BELOW_DISPLAY_SKIP_CODE;
X		} else {
X			g1 = ABOVE_DISPLAY_SHORT_SKIP_CODE;
X			g2 = BELOW_DISPLAY_SHORT_SKIP_CODE;
X		}
X		if (l && e == 0) {
X			shift_amount(a) = s;
X			append_to_vlist(a);
X			tail_append(new_penalty(INF_PENALTY));
X		} else
X			tail_append(new_param_glue(g1));
X		if (e != 0) {
X			r = new_kern(z - w - e - d);
X			if (l) {
X				link(a) = r;
X				link(r) = b;
X				b = a;
X				d = 0;
X			} else {
X				link(b) = r;
X				link(r) = a;
X			}
X			b = hpack(b, NATURAL);
X		}
X		shift_amount(b) = s + d;
X		append_to_vlist(b);
X		if (t != adjust_head) {
X			link(tail) = link(adjust_head);
X			tail = t;
X		}
X		if (a != NULL && e == 0 && !l) {
X			tail_append(new_penalty(INF_PENALTY));
X			shift_amount(a) = s + z - width(a);
X			append_to_vlist(a);
X			tail_append(new_penalty(post_display_penalty));
X		} else {
X			tail_append(new_penalty(post_display_penalty));
X			tail_append(new_param_glue(g2));
X		}
X		resume_after_display();
X	}
X}
X
Xresume_after_display ()
X{
X	if (cur_group != MATH_SHIFT_GROUP)
X		confusion("display");
X	unsave();
X	prev_graf += 3;
X	push_nest();
X	mode = HMODE;
X	space_factor = 1000;
X	scan_optional_space();
X	if (nest_ptr == 1) 
X		build_page();
X}
X
X/*
X *	Help text
X */
X
Xhelp_math_accent ()
X{
X	help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
X	"(Accents are not the same in formulas as they are in text.)" );
X}
X
Xhelp_math_sy ()
X{
X	help3("Sorry, but I can't typeset math unless \\textfont 2",
X	"and \\scriptfont 2 and \\scriptscriptfont 2 have all",
X	"the \\fontdimen values needed in math symbol fonts." );
X}
X
Xhelp_math_ex ()
X{
X	help3("Sorry, but I can't typeset math unless \\textfont 3",
X	"and \\scriptfont 3 and \\scriptscriptfont 3 have all",
X	"the \\fontdimen values needed in math extension fonts." );
X}
X
Xhelp_limits ()
X{
X	help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
X}
X
Xhelp_delimiter ()
X{
X	help6("I was expecting to see something like `(' or `\\{' or",
X	"`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
X	"should probably delete the `{' by typing `1' now, so that",
X	"braces don't get unbalanced. Otherwise just proceed.",
X	"Acceptable delimiters are characters whose \\delcode is",
X	"nonnegative, or you can use `\\delimiter <delimiter code>'.");
X}
X
Xhelp_fraction ()
X{
X	help3("I'm ignoring this fraction specification, since I don't",
X	"know whether a construction like `x \\over y \\over z'",
X	"means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
X}
X
Xhelp_xtra_right ()
X{
X	help1("I'm ignoring a \\right that had no matching \\left.");
X}
X
Xhelp_doldol ()
X{
X	help2("The `$' that I just saw supposedly matches a previous `$$'.",
X	"So I shall assume that you typed `$$' both times.");
X}
X
Xhelp_double_sub ()
X{
X	help1("I treat `x_1_2' essentially like `x_1{}_2'.");
X}
X
Xhelp_double_sup ()
X{
X	help1("I treat `x^1^2' essentially like `x^1{}^2'.");
X}
SHAR_EOF
chmod 0444 mathlists.c || echo "restore of mathlists.c fails"
set `wc -c mathlists.c`;Sum=$1
if test "$Sum" != "15642"
then echo original size 15642, current size $Sum;fi
echo "x - extracting mathlists.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > mathlists.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 *		mathlist.h
X */
X
X#define	ABOVE_CODE		0
X#define	OVER_CODE		1
X#define	ATOP_CODE		2
X#define	DELIMITED_CODE	3
X
Xint		init_math();
Xint		start_eq_no();
Xint		scan_math();
Xint		set_math_char();
Xint		math_limit_switch();
Xint		scan_delimiter();
Xint		math_radical();
Xint		math_ac();
Xint		append_choices();
Xint		build_choices();
Xint		sub_sup();
Xint		math_fraction();
Xptr		fin_mlist();
Xint		math_left_right();
Xint		after_math();
Xint		resume_after_display();
SHAR_EOF
chmod 0444 mathlists.h || echo "restore of mathlists.h fails"
set `wc -c mathlists.h`;Sum=$1
if test "$Sum" != "663"
then echo original size 663, current size $Sum;fi
echo "x - extracting mklog (Text)"
sed 's/^X//' << 'SHAR_EOF' > mklog &&
Xcc -O -DINIT -DBIG -c align.c
Xcc -O -DINIT -DBIG -c arith.c
Xcc -O -DINIT -DBIG -c box.c
Xcc -O -DINIT -DBIG -c boxlists.c
Xcc -O -DINIT -DBIG -c char.c
Xcc -O -DINIT -DBIG -c cmds.c
Xcc -O -DINIT -DBIG -c cond.c
Xcc -O -DINIT -DBIG -c def.c
Xcc -O -DINIT -DBIG -c dvi.c
Xcc -O -DINIT -DBIG -c eq.c
Xcc -O -DINIT -DBIG -c eqstack.c
Xcc -O -DINIT -DBIG -c error.c
Xcc -O -DINIT -DBIG -c eval.c
Xcc -O -DINIT -DBIG -c evalstack.c
Xcc -O -DINIT -DBIG -c expand.c
Xcc -O -DINIT -DBIG -c file.c
Xcc -O -DINIT -DBIG -c fmt.c
Xcc -O -DINIT -DBIG -c hash.c
Xcc -O -DINIT -DBIG -c heap.c
Xcc -O -DINIT -DBIG -c hyph.c
Xcc -O -DINIT -DBIG -c io.c
Xcc -O -DINIT -DBIG -c math.c
Xcc -O -DINIT -DBIG -c mathlists.c
Xcc -O -DINIT -DBIG -c mlist-hlist.c
Xcc -O -DINIT -DBIG -c pack.c
Xcc -O -DINIT -DBIG -c page.c
Xcc -O -DINIT -DBIG -c par.c
Xcc -O -DINIT -DBIG -c print.c
Xcc -O -DINIT -DBIG -c scan.c
Xcc -O -DINIT -DBIG -c str.c
Xcc -O -DINIT -DBIG -c tex.c
Xcc -O -DINIT -DBIG -c texext.c
Xcc -O -DINIT -DBIG -c tfm.c
Xcc -O -DINIT -DBIG -c token.c
Xcc -O -DINIT -DBIG -c tokenlists.c
Xcc -O -DINIT -DBIG -c tokenstack.c
Xcc -O -DINIT -DBIG align.o  arith.o  box.o  boxlists.o  char.o  cmds.o  cond.o  def.o  dvi.o  eq.o  eqstack.o  error.o  eval.o  evalstack.o  expand.o  file.o  fmt.o  hash.o  heap.o  hyph.o  io.o  math.o  mathlists.o  mlist-hlist.o  pack.o  page.o  par.o  print.o  scan.o  str.o  tex.o  texext.o  tfm.o  token.o  tokenlists.o  tokenstack.o  -o initex
Xtext	data	bss	dec	hex
X210944	45056	1107196	1363196	14ccfc
Xcc -O -DBIG -c cmds.c
Xcc -O -DBIG -c def.c
Xcc -O -DBIG -c eq.c
Xcc -O -DBIG -c fmt.c
Xcc -O -DBIG -c hash.c
Xcc -O -DBIG -c heap.c
Xcc -O -DBIG -c hyph.c
Xcc -O -DBIG -c tex.c
Xcc -O -DBIG -c token.c
Xcc -O -DBIG align.o  arith.o  box.o  boxlists.o  char.o  cmds.o  cond.o  def.o  dvi.o  eq.o  eqstack.o  error.o  eval.o  evalstack.o  expand.o  file.o  fmt.o  hash.o  heap.o  hyph.o  io.o  math.o  mathlists.o  mlist-hlist.o  pack.o  page.o  par.o  print.o  scan.o  str.o  tex.o  texext.o  tfm.o  token.o  tokenlists.o  tokenstack.o  -o virtex
Xtext	data	bss	dec	hex
X192512	40960	1834492	2067964	1f8dfc
SHAR_EOF
chmod 0444 mklog || echo "restore of mklog fails"
set `wc -c mklog`;Sum=$1
if test "$Sum" != "2080"
then echo original size 2080, current size $Sum;fi
echo "x - extracting mlist-hlist.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > mlist-hlist.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 *		mlist-hlist.c
X */
X
X#include "tex.h"
X#include "heap.h"
X#include "arith.h"
X#include "scan.h"
X#include "eq.h"
X#include "box.h"
X#include "math.h"
X#include "pack.h"
X#include "tfm.h"
X#include "print.h"
X#include "error.h"
X#include "str.h"
X#include "mlist-hlist.h"
X
Xqword	cur_c;
Xfnt		cur_f;
Xfourq	cur_i;
Xscal	cur_mu;
Xint		cur_size;
Xint		cur_style;
Xptr		cur_mlist;
Xbool	mlist_penalties;
X
Xptr
Xclean_box (p, s)
X	ptr		p;
X	int		s;
X{
X	ptr		q;
X	ptr		r;
X	ptr		x;
X	int		save_style;
X
X	switch (math_type(p))
X	{
X	case MATH_CHAR:
X		cur_mlist = new_noad();
X		mem[nucleus(cur_mlist)] = mem[p];
X		break;
X
X	case SUB_BOX:
X		q = info(p);
X		goto found; 
X		break;	
X	
X	case SUB_MLIST:
X		cur_mlist = info(p);
X		break;
X	
X	default:
X		q = new_null_box();
X		goto found;
X		break;
X	}
X	save_style = cur_style;
X	cur_style = s;
X	mlist_penalties = FALSE;
X	mlist_to_hlist();
X	q = link(temp_head);
X	cur_style = save_style;
X	change_size_and_mu();
X
Xfound:
X	if (is_char_node(q) || q == NULL)
X		x = hpack(q, NATURAL);	
X	else if (link(q) == NULL &&
X			type(q) <= VLIST_NODE &&
X			shift_amount(q) == 0)
X			x = q;
X	else x = hpack(q, NATURAL);
X	q = list_ptr(x);
X	if (is_char_node(q)) {
X		r = link(q);
X		if (r != NULL &&
X			link(r) == NULL &&	
X			!is_char_node(r) &&
X			type(r) == KERN_NODE) {
X			free_node(r, SMALL_NODE_SIZE);
X			link(q) = NULL;
X		}
X	}
X	return x;
X}
X
Xfetch (a)
X	ptr		a;
X{
X	cur_c = character(a);
X	cur_f = fam_fnt(fam(a) + cur_size);
X	if (cur_f == NULL_FONT) {
X		print_err("");
X		print_size(cur_size);
X		print_char(' ');
X		print_int(fam(a));
X		print(" is undefined (character ");
X		print_ASCII(qo(cur_c));
X		print_char(')');
X		help_undefd_mathchar();
X		error();
X		cur_i = null_character;
X		math_type(a) = EMPTY;
X	} else {
X		if (qo(cur_c) >= font_bc[cur_f] &&
X			qo(cur_c) <= font_ec[cur_f])
X			cur_i = char_info(cur_f, cur_c);
X		else cur_i = null_character;
X		if (!char_exists(cur_i)) {
X			char_warning(cur_f, qo(cur_c));
X			math_type(a) = EMPTY;
X		}
X	}
X}
X
Xchar	math_spacing[] = 
X		"0234000122*4000133**3**344*0400400*000000234000111*1111112341011";
X
X#define	choose_mlist(L) \
X	{p = L(q); L(q) = NULL;}
X
Xmlist_to_hlist ()
X{
X	ptr		p;
X	ptr		q;
X	ptr		r;
X	int		s;
X	int		t;
X	ptr		x;
X	ptr		y;
X	ptr		z;
X	val		pen;
X	scal	delta;
X	scal	max_d;
X	scal	max_h;
X	ptr		mlist;
X	int		style;
X	int		r_type;
X	bool	penalties;
X	int		save_style;
X
X	mlist = cur_mlist;
X	penalties = mlist_penalties;
X	style = cur_style;
X	q = mlist;
X	r = NULL;
X	r_type = OP_NOAD;
X	max_h = 0;
X	max_d = 0;
X	change_size_and_mu();
X
X	while (q != NULL)
X	{
Xreswitch:
X		delta = 0;
X		switch (type(q))
X		{
X		case BIN_NOAD:	
X			switch (r_type)
X			{
X			case BIN_NOAD:
X			case OP_NOAD:
X			case REL_NOAD:
X			case OPEN_NOAD:
X			case PUNCT_NOAD:
X			case LEFT_NOAD:
X				type(q) = ORD_NOAD;
X				goto reswitch;
X				break;
X
X			default:
X				break;
X			}
X			break;
X
X		case REL_NOAD:
X		case CLOSE_NOAD:
X		case PUNCT_NOAD:
X		case RIGHT_NOAD:
X			if (r_type == BIN_NOAD)
X				type(r) = ORD_NOAD;
X			if (type(q) == RIGHT_NOAD)
X				goto done_with_noad;
X			break;
X
X		case LEFT_NOAD:
X			goto done_with_noad;
X			break;
X
X		case FRACTION_NOAD:
X			make_fraction(q);
X			goto check_dimensions;
X			break;
X		
X		case OP_NOAD:
X			delta = make_op(q);
X			if (subtype(q) == LIMITS)
X				goto check_dimensions;
X			break;
X
X		case ORD_NOAD:
X			make_ord(q);
X			break;
X
X		case OPEN_NOAD:
X		case INNER_NOAD:
X			break;
X		
X		case RADICAL_NOAD:
X			make_radical(q);
X			break;
X		
X		case OVER_NOAD:
X			make_over(q);
X			break;
X
X		case UNDER_NOAD:
X			make_under(q);
X			break;
X	
X		case ACCENT_NOAD:
X			make_math_accent(q);
X			break;
X		
X		case VCENTER_NOAD:
X			make_vcenter(q);
X			break;
X		
X		case STYLE_NODE:
X			cur_style = subtype(q);
X			change_size_and_mu();
X			goto done_with_node;
X			break;
X		
X		case CHOICE_NODE:
X			switch (cur_style / 2)
X			{
X			case 0:
X				choose_mlist(display_mlist);
X				break;
X
X			case 1:
X				choose_mlist(text_mlist);
X				break;
X
X			case 2:
X				choose_mlist(script_mlist);
X				break;
X
X			case 3:
X				choose_mlist(script_script_mlist);
X				break;
X			}
X			flush_node_list(display_mlist(q));
X			flush_node_list(text_mlist(q));
X			flush_node_list(script_mlist(q));
X			flush_node_list(script_script_mlist(q));
X			type(q) = STYLE_NODE;
X			subtype(q) = cur_style;
X			width(q) = 0;
X			depth(q) = 0;
X			if (p != NULL) {
X				z = link(q);
X				link(q) = p;
X				while (link(p) != NULL)
X					p = link(p);
X				link(p) = z;
X			}
X			goto done_with_node;
X			break;
X
X		case INS_NODE:
X		case MARK_NODE:
X		case ADJUST_NODE:
X		case WHATSIT_NODE:
X		case PENALTY_NODE:
X		case DISC_NODE:
X			goto done_with_node;
X			break;
X		
X		case RULE_NODE:
X			if (height(q) > max_h)
X				max_h = height(q);
X			if (depth(q) > max_d)
X				max_d = depth(q);
X			goto done_with_node;
X			break;
X
X		case GLUE_NODE:
X			if (subtype(q) == MU_GLUE) {
X				x = glue_ptr(q);
X				y = math_glue(x, cur_mu);
X				delete_glue_ref(x);
X				glue_ptr(q) = y;
X				subtype(q) = NORMAL;
X			} else if (cur_size != TEXT_SIZE &&
X				subtype(q) == COND_MATH_GLUE) {
X				p = link(q);
X				if (p != NULL &&
X					(type(p) == GLUE_NODE ||
X					type(p) == KERN_NODE)) {
X					link(q) = link(p);
X					link(p) = NULL;
X					flush_node_list(p);
X				}
X			}
X			goto done_with_node;
X			break;
X		
X		case KERN_NODE:
X			math_kern(q, cur_mu);
X			goto done_with_node;
X			break;
X		
X		default:
X			confusion("mlist1");
X		}
X
X		switch (math_type(nucleus(q)))
X		{
X		case MATH_CHAR:
X		case MATH_TEXT_CHAR:
X			fetch(nucleus(q));
X			if (char_exists(cur_i)) {
X				delta = char_italic(cur_f, cur_i);
X				p = new_character(cur_f, qo(cur_c));
X				if (math_type(nucleus(q)) == MATH_TEXT_CHAR &&
X					space(cur_f) != 0)
X					delta = 0;
X				if (math_type(subscr(q)) == EMPTY && delta != 0) {
X					link(p) = new_kern(delta);
X					delta = 0;
X				}
X			} else
X				p = NULL;
X			break;
X		
X		case EMPTY:
X			p = NULL;
X			break;
X
X		case SUB_BOX:
X			p = info(nucleus(q));
X			break;
X
X		case SUB_MLIST:
X			cur_mlist = info(nucleus(q));
X			save_style = cur_style;
X			mlist_penalties = FALSE;
X			mlist_to_hlist();
X			cur_style = save_style;
X			change_size_and_mu();
X			p = hpack(link(temp_head), NATURAL); 
X			break;
X
X		default:
X			confusion("mlist2");
X		}
X		new_hlist(q) = p;
X		if (math_type(subscr(q)) == EMPTY && 
X			math_type(supscr(q)) == EMPTY)
X			goto check_dimensions;
X		make_scripts(q, delta);
X		
Xcheck_dimensions:
X		z = hpack((ptr)new_hlist(q), NATURAL);
X		if (height(z) > max_h)
X			max_h = height(z);
X		if (depth(z) > max_d)
X			max_d = depth(z);
X		free_node(z, BOX_NODE_SIZE);
X
Xdone_with_noad:
X		r = q;
X		r_type = type(r);
X
Xdone_with_node:
X		q = link(q);
X	} 
X
X	if (r_type == BIN_NOAD)
X		type(r) = ORD_NOAD;
X	p = temp_head;
X	link(p) = NULL;
X	q = mlist;
X	r_type = 0;
X	cur_style = style;
X	change_size_and_mu();
X
X	while (q != NULL) {
X		t = ORD_NOAD;
X		s = NOAD_SIZE;
X		pen = INF_PENALTY;
X		switch (type(q))
X		{
X		case OP_NOAD:
X		case OPEN_NOAD:
X		case CLOSE_NOAD:
X		case PUNCT_NOAD:
X		case INNER_NOAD:
X			t = type(q);
X			break;
X		
X		case BIN_NOAD:
X			t = BIN_NOAD;
X			pen = bin_op_penalty;
X			break;
X		
X		case REL_NOAD:
X			t = REL_NOAD;
X			pen = rel_penalty;
X			break; 
X		
X		case ORD_NOAD:
X		case VCENTER_NOAD:
X		case OVER_NOAD:
X		case UNDER_NOAD:
X			break;
X
X		case RADICAL_NOAD:
X			s = RADICAL_NOAD_SIZE;
X			break;
X
X		case ACCENT_NOAD:
X			s = ACCENT_NOAD_SIZE;
X			break;
X
X		case FRACTION_NOAD:
X			t = INNER_NOAD;
X			s = FRACTION_NOAD_SIZE;
X			break;
X
X		case LEFT_NOAD:
X		case RIGHT_NOAD:
X			t = make_left_right(q, style, max_d, max_h);
X			break;
X		
X		case STYLE_NODE:
X			cur_style = subtype(q);
X			s = STYLE_NODE_SIZE;
X			change_size_and_mu();
X			goto delete_q;
X			break;
X
X		case WHATSIT_NODE:
X		case PENALTY_NODE:
X		case RULE_NODE:
X		case DISC_NODE:
X		case ADJUST_NODE:
X		case INS_NODE:
X		case MARK_NODE:
X		case GLUE_NODE:
X		case KERN_NODE:
X			link(p) = q;
X			p = q;
X			q = link(q);
X			link(p) = NULL;
X			continue;
X		
X		default:
X			confusion("mlist3");
X		}
X
X		if (r_type > 0) {
X			switch (math_spacing[r_type * 8 + t + magic_offset]) 
X			{
X			case '0':
X				x = 0;
X				break;
X
X			case '1':
X				if (cur_style < SCRIPT_STYLE)
X					x = THIN_MU_SKIP_CODE;
X				else x = 0;
X				break;
X
X			case '2':
X				x = THIN_MU_SKIP_CODE;
X				break;
X
X			case '3':
X				if (cur_style < SCRIPT_STYLE)
X					x = MED_MU_SKIP_CODE;
X				else x = 0;
X				break;
X
X			case '4':
X				if (cur_style < SCRIPT_STYLE)
X					x = THICK_MU_SKIP_CODE;
X				else x = 0;
X				break;
X
X			default:
X				confusion("mlist4");
X				break;
X			}
X			if (x != 0) {
X				y = math_glue(glue_par(x), cur_mu);
X				z = new_glue(y);
X				glue_ref_count(y) = NULL;
X				link(p) = z;
X				p = z;
X				subtype(z) = x + 1;
X			}
X		}
X		if (new_hlist(q) != NULL) {
X			link(p) = new_hlist(q);
X			do p = link(p);
X			while (link(p) != NULL);
X		}
X		if (penalties && link(q) != NULL && pen < INF_PENALTY) {
X			r_type = type(link(q));
X			if (r_type != PENALTY_NODE && r_type != REL_NOAD) {
X				z = new_penalty(pen);
X				link(p) = z;
X				p = z;
X			}
X		}
X		r_type = t;
X
Xdelete_q:
X		r = q;
X		q = link(q);
X		free_node(r, s);
X	}
X}
X
Xmake_over (q)
X	ptr	q;
X{
X	info(nucleus(q)) =
X		overbar(clean_box(nucleus(q), cramped_style(cur_style)),
X				3 * default_rule_thickness, default_rule_thickness);
X	math_type(nucleus(q)) = SUB_BOX;
X}
X
Xmake_under (q)
X	ptr 	q;
X{
X	ptr		p;
X	ptr		x;
X	ptr		y;
X	scal	delta;
X
X	x = clean_box(nucleus(q), cur_style);
X	p = new_kern(3 * default_rule_thickness);
X	link(x) = p;
X	link(p) = fraction_rule(default_rule_thickness);
X	y = vpack(x, NATURAL);
X	delta = height(y) + depth(y) + default_rule_thickness;
X	height(y) = height(x);
X	depth(y) = delta - height(y);
X	info(nucleus(q)) = y;
X	math_type(nucleus(q)) = SUB_BOX;
X}
X
Xmake_vcenter (q)
X	ptr		q;
X{
X	ptr		v;
X	scal	delta;
X
X	v = info(nucleus(q));
X	if (type(v) != VLIST_NODE)
X		confusion("vcenter");
X	delta = height(v) + depth(v);
X	height(v) = axis_height(cur_size) + half(delta);
X	depth(v) = delta - height(v);
X}
X
Xmake_radical (q)
X	ptr		q;
X{
X	ptr		x;
X	ptr		y;
X	scal	clr;
X	scal	delta;
X
X	x = clean_box(nucleus(q), cramped_style(cur_style));
X	if (cur_style < TEXT_STYLE)
X		clr = default_rule_thickness + (abs(math_x_height(cur_size)) / 4);
X	else {
X		clr = default_rule_thickness;
X		clr += (abs(clr) / 4);
X	}
X	y = var_delimiter(left_delimiter(q), cur_size,
X						height(x) + depth(x) + clr + default_rule_thickness);
X	delta = depth(y) - (height(x) + depth(x) + clr);
X	if (delta > 0) clr += half(delta);
X	shift_amount(y) = -(height(x) + clr);
X	link(y)  = overbar(x, clr, height(y));
X	info(nucleus(q)) = hpack(y, NATURAL);
X	math_type(nucleus(q)) = SUB_BOX;
X}
X
Xmake_math_accent (q)
X	ptr		q;
X{
X	int		a;
X	qword	c;
X	fnt		f;
X	scal	h;
X	fourq	i;
X	ptr		p;
X	scal	s;
X	scal	w;
X	ptr		x;
X	ptr		y;
X	scal	delta;
X
X	fetch(accent_chr(q)); 
X	if (char_exists(cur_i)) {
X		i = cur_i;
X		c = cur_c;
X		f = cur_f;
X		s = 0;
X		if (math_type(nucleus(q)) == MATH_CHAR) {
X			fetch(nucleus(q));
X			if (char_tag(cur_i) == LIG_TAG) {
X				a = lig_kern_start(cur_f, cur_i);
X				do	{
X					cur_i = font_info[a].qqqq;
X					if (qo(next_char(cur_i)) == skew_char[cur_f]) {
X						if (op_bit(cur_i) >= KERN_FLAG)
X							s = char_kern(cur_f, cur_i);
X						break;
X					}
X					incr(a);
X				} while (stop_bit(cur_i) < STOP_FLAG);
X			}
X		}
X		x = clean_box(nucleus(q), cramped_style(cur_style));
X		w = width(x);
X		h = height(x);
X		loop {
X			if (char_tag(i) != LIST_TAG)
X				break;
X			y = rem_byte(i);
X			i = char_info(f, y);
X			if (char_width(f, i) > w)
X				break;
X			c = y;
X		}
X		delta = (h < x_height(f) ? h : x_height(f));
X		if ((math_type(supscr(q)) != EMPTY ||
X			math_type(subscr(q)) != EMPTY) &&
X			math_type(nucleus(q)) == MATH_CHAR) {
X				flush_node_list(x);
X				x = new_noad(); 
X				mem[nucleus(x)] = mem[nucleus(q)];
X				mem[supscr(x)] = mem[supscr(q)];
X				mem[subscr(x)] = mem[subscr(q)];
X				mem[supscr(q)].hh = empty_field;
X				mem[subscr(q)].hh = empty_field;
X				math_type(nucleus(q)) = SUB_MLIST;
X				info(nucleus(q)) = x;
X				x = clean_box(nucleus(q), cur_style);
X				delta = delta + height(x) - h;
X				h = height(x);
X		}
X		y = char_box(f, c);
X		shift_amount(y) = s + half(w - width(y));
X		width(y) = 0;
X		p = new_kern(-delta);
X		link(p) = x;
X		link(y) = p;
X		y = vpack(y, NATURAL);
X		width(y) = width(x);
X		if (height(y) < h) {
X			p = new_kern(h - height(y));
X			link(p) = list_ptr(y);
X			list_ptr(y) = p;
X			height(y) = h;
X		}
X		info(nucleus(q)) = y;
X		math_type(nucleus(q)) = SUB_BOX;
X	}
X}
X
Xmake_fraction (q)
X	ptr		q;
X{
X	ptr		p;
X	ptr		v;
X	ptr		x;
X	ptr		y;
X	ptr		z;
X	scal	clr;
X	scal	delta;
X	scal	delta1;
X	scal	delta2;
X	scal	shift_up;
X	scal	shift_down;
X
X	if (thickness(q) == DEFAULT_CODE)
X		thickness(q) = default_rule_thickness;
X	x = clean_box(numerator(q), num_style(cur_style));
X	z = clean_box(denominator(q), denom_style(cur_style));
X	if (width(x) < width(z))
X		x = rebox(x, width(z));
X	else z = rebox(z, width(x));
X	if (cur_style < TEXT_STYLE) {
X		shift_up = num1(cur_size);
X		shift_down = denom1(cur_size);
X	} else {
X		shift_down = denom2(cur_size);
X		if (thickness(q) != 0)
X			shift_up = num2(cur_size);
X		else shift_up = num3(cur_size);
X	}
X	if (thickness(q) == 0) {
X		if (cur_style < TEXT_STYLE)
X			clr = 7 * default_rule_thickness;
X		else clr = 3 * default_rule_thickness;
X		delta = half(clr - ((shift_up - depth(x)) - (height(z) - shift_down)));
X		if (delta > 0) {
X			shift_up += delta;
X			shift_down += delta;
X		}
X	} else {
X		if (cur_style < TEXT_STYLE)
X			clr = 3 * thickness(q);
X		else clr = thickness(q);
X		delta = half(thickness(q));
X		delta1 = clr -
X			((shift_up - depth(x)) - (axis_height(cur_size) + delta));
X		delta2 = clr - 
X			((axis_height(cur_size) - delta) - (height(z) - shift_down));
X		if (delta1 > 0) shift_up += delta1;
X		if (delta2 > 0) shift_down += delta2;
X	}
X	v = new_null_box();
X	type(v) = VLIST_NODE;
X	height(v) = shift_up + height(x);
X	depth(v) = depth(z) + shift_down;
X	width(v) = width(x);
X	if (thickness(q) == 0) {
X		p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
X		link(p) = z;
X	} else {
X		y = fraction_rule(thickness(q));
X		p = new_kern((axis_height(cur_size)-delta) - (height(z)-shift_down));
X		link(y) = p;
X		link(p) = z;
X		p = new_kern((shift_up - depth(x)) - (axis_height(cur_size) + delta));
X		link(p)  = y;
X	}
X	link(x) = p;
X	list_ptr(v) = x;
X	if (cur_style < TEXT_STYLE)
X		delta = delim1(cur_size);
X	else delta = delim2(cur_size);
X	x = var_delimiter(left_delimiter(q), cur_size, delta);
X	link(x) = v;
X	z = var_delimiter(right_delimiter(q), cur_size, delta);
X	link(v) = z;
X	new_hlist(q) = hpack(x, NATURAL);
X}
X
Xscal
Xmake_op (q)
X	ptr		q;
X{
X	ptr		p;
X	ptr		v;
X	ptr		x;
X	ptr		y;
X	ptr		z;
X	scal	delta;
X	scal	shift_up;
X	scal	shift_down;
X
X	if (subtype(q) == NORMAL && cur_style < TEXT_STYLE)
X		subtype(q) = LIMITS;
X	if (math_type(nucleus(q)) == MATH_CHAR) {
X		fetch(nucleus(q));
X		if (cur_style < TEXT_STYLE && char_tag(cur_i) == LIST_TAG) {
X			cur_c = rem_byte(cur_i);
X			character(nucleus(q)) = cur_c;
X			cur_i = char_info(cur_f, cur_c);
X		}
X		delta = char_italic(cur_f, cur_i);
X		x = clean_box(nucleus(q), cur_style);
X		if (math_type(subscr(q)) != EMPTY && subtype(q) != LIMITS)
X			width(x) -= delta;
X		shift_amount(x) = half(height(x) - depth(x)) - axis_height(cur_size);
X		math_type(nucleus(q)) = SUB_BOX;
X		info(nucleus(q)) = x;
X	} else delta = 0;
X	if (subtype(q) == LIMITS) {
X		x = clean_box(supscr(q), sup_style(cur_style));
X		y = clean_box(nucleus(q), cur_style);
X		z = clean_box(subscr(q), sub_style(cur_style));
X		v = new_null_box();
X		type(v) = VLIST_NODE;
X		width(v) = width(y);
X		if (width(x) > width(v))
X			width(v) = width(x);
X		if (width(z) > width(v))
X			width(v) = width(z);
X		x = rebox(x, width(v));
X		y = rebox(y, width(v));
X		z = rebox(z, width(v));
X		shift_amount(x) = half(delta);
X		shift_amount(z) = -shift_amount(x);
X		height(v) = height(y);
X		depth(v) = depth(y);
X		if (math_type(supscr(q)) == EMPTY) {
X			free_node(x, BOX_NODE_SIZE);
X			list_ptr(v) = y;
X		} else {
X			shift_up = big_op_spacing3 - depth(x);
X			if (shift_up < big_op_spacing1)
X				shift_up = big_op_spacing1;
X			p = new_kern(shift_up);
X			link(p) = y;
X			link(x) = p;
X			p = new_kern(big_op_spacing5);
X			link(p) = x;
X			list_ptr(v) = p;
X			height(v) += big_op_spacing5 + height(x) + depth(x) + shift_up;
X		}
X		if (math_type(subscr(q)) == EMPTY)
X			free_node(z, BOX_NODE_SIZE);
X		else {
X			shift_down = big_op_spacing4 - height(z);
X			if (shift_down < big_op_spacing2)
X				shift_down = big_op_spacing2;
X			p = new_kern(shift_down);
X			link(y) = p;
X			link(p) = z;
X			p = new_kern(big_op_spacing5);
X			link(z) = p;
X			depth(v) += big_op_spacing5 + height(z) + depth(z) + shift_down;
X		}
X		new_hlist(q) = v;
X	}
X	return delta;
X}
X
Xmake_ord (q)
X	ptr		q;
X{
X	int		a;
X	ptr		p;
X
Xrestart:
X	if (math_type(subscr(q)) == EMPTY &&
X		math_type(supscr(q)) == EMPTY &&
X		math_type(nucleus(q)) == MATH_CHAR) {
X		p = link(q);
X		if (p != NULL &&
X			type(p) >= ORD_NOAD &&
X			type(p) <= PUNCT_NOAD &&
X			math_type(nucleus(p)) == MATH_CHAR &&
X			fam(nucleus(p)) == fam(nucleus(q))) {
X			math_type(nucleus(q)) = MATH_TEXT_CHAR;
X			fetch(nucleus(q));
X			if (char_tag(cur_i) == LIG_TAG) {
X				a = lig_kern_start(cur_f, cur_i);
X				cur_c = character(nucleus(p));
X				do	{
X					cur_i = font_info[a].qqqq;
X					if (next_char(cur_i) == cur_c) {
X						if (op_bit(cur_i) >= KERN_FLAG) {
X							p = new_kern(char_kern(cur_f, cur_i));
X							link(p) = link(q);
X							link(q) = p;
X							return;
X						} else {
X							link(q) = link(p);
X							math_type(nucleus(q)) = MATH_CHAR;
X							character(nucleus(q)) = rem_byte(cur_i);
X							mem[subscr(q)] = mem[subscr(p)];
X							mem[supscr(q)] = mem[supscr(p)];
X							free_node(p, NOAD_SIZE);
X							goto restart;
X						}
X					}
X					incr(a);
X				} while (stop_bit(cur_i) < STOP_FLAG);
X			}
X		}
X	}
X}
X
Xmake_scripts (q, delta)
X	ptr		q;
X	scal	delta;
X{
X	ptr		p;
X	int		t;
X	ptr		x;
X	ptr		y;
X	ptr		z;
X	scal	clr;
X	scal	shift_up;
X	scal	shift_down;
X
X	p = new_hlist(q);
X	if (is_char_node(p)) {
X		shift_up = 0;
X		shift_down = 0;
X	} else {
X		z = hpack(p, NATURAL);
X		if (cur_style < SCRIPT_STYLE)	
X			t = SCRIPT_SIZE;
X		else t = SCRIPT_SCRIPT_SIZE;
X		shift_up = height(z) - sup_drop(t);
X		shift_down = depth(z) + sub_drop(t);
X		free_node(z, BOX_NODE_SIZE);
X	}
X	if (math_type(supscr(q)) == EMPTY) {
X		x = clean_box(subscr(q), sub_style(cur_style));
X		width(x) += script_space;
X		if (shift_down < sub1(cur_size))
X			shift_down = sub1(cur_size);
X		clr = height(x) - (abs(math_x_height(cur_size) * 4) / 5);
X		if (shift_down < clr)
X			shift_down = clr;
X		shift_amount(x) = shift_down;
X	} else {
X		x = clean_box(supscr(q), sup_style(cur_style));
X		width(x) += script_space;
X		if (odd(cur_style))
X			clr = sup3(cur_size);
X		else if (cur_style < TEXT_STYLE)
X			clr = sup1(cur_size);
X		else clr = sup2(cur_size);
X		if (shift_up < clr)
X			shift_up = clr;
X		clr = depth(x) + (abs(math_x_height(cur_size)) / 4);
X		if (shift_up < clr)
X			shift_up = clr;
X		if (math_type(subscr(q)) == EMPTY) 
X			shift_amount(x) = -shift_up;
X		else {
X			y = clean_box(subscr(q), sub_style(cur_style));
X			width(y) += script_space;
X			if (shift_down < sub2(cur_size))
X				shift_down = sub2(cur_size);
X			clr = 4 * default_rule_thickness -
X						((shift_up - depth(x)) - (height(y) - shift_down));
X			if (clr > 0) {
X				shift_down += clr;
X				clr = (abs(math_x_height(cur_size) * 4) / 5) -
X						(shift_up - depth(x));
X				if (clr > 0) {
X					shift_up += clr;
X					shift_down -= clr;
X				}
X			}
X			shift_amount(x) = delta;
X			p = new_kern((shift_up - depth(x)) - (height(y) - shift_down));
X			link(x) = p;
X			link(p) = y;
X			x = vpack(x, NATURAL);
X			shift_amount(x) = shift_down;
X		}
X	}
X	if (new_hlist(q) == NULL)
X		new_hlist(q) = x;
X	else {
X		p = new_hlist(q);
X		while (link(p) != NULL)
X			p = link(p);
X		link(p) = x;
X	}
X}
X
Xmake_left_right (q, style, max_d, max_h)
X	ptr		q;
X	int		style;
X	scal	max_d;
X	scal	max_h;
X{
X	scal	delta;
X	scal	delta1;
X	scal	delta2;
X
X	if (style  < SCRIPT_STYLE)
X		cur_size = TEXT_SIZE;
X	else cur_size = 16 * ((style - TEXT_STYLE) / 2);
X	delta2 = max_d + axis_height(cur_size);
X	delta1 = max_h + max_d - delta2;
X	if (delta2 > delta1)
X		delta1 = delta2;
X	delta = (delta1 / 500) * delimiter_factor;
X	delta2 = delta1 + delta1 - delimiter_shortfall;
X	if (delta < delta2)
X		delta = delta2;
X	new_hlist(q) = var_delimiter(delimiter(q), cur_size, delta);
X	return (type(q) - (LEFT_NOAD - OPEN_NOAD));
X}
X
Xint		magic_offset = - 9 * ORD_NOAD;
X
X/*
X *	Help text
X */
X
Xhelp_undefd_mathchar ()
X{
X	help4("Somewhere in the math formula just ended, you used the",
X	"stated character from an undefined font family. For example,",
X	"plain TeX doesn't allow \\it or \\sl in subscripts. Proceed,",
X	"and I'll try to forget that I needed that character.");
X}
SHAR_EOF
chmod 0444 mlist-hlist.c || echo "restore of mlist-hlist.c fails"
set `wc -c mlist-hlist.c`;Sum=$1
if test "$Sum" != "20509"
then echo original size 20509, current size $Sum;fi
echo "x - extracting mlist-hlist.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > mlist-hlist.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 *		mlist-hl.h
X */
X
Xglobal	qword	cur_c;
Xglobal	fnt		cur_f;
Xglobal	fourq	cur_i;
Xglobal	ptr		cur_mlist;
Xglobal	scal	cur_mu;
Xglobal	int		cur_size;
Xglobal	int		cur_style;
Xglobal	bool	mlist_penalties;
X
Xptr		clean_box();
Xint		fetch();
X
X#define	new_hlist(N)			mem[nucleus(N)].i
X
Xint		mlist_to_hlist();
X
Xint		make_over();
Xint		make_under();
Xint		make_vcenter();
Xint		make_radical();
Xint		make_math_accent();
Xint		make_fraction();
Xscal	make_op();
Xint		make_ord();
Xint		make_scripts();
Xint		make_left_right();
X
Xglobal	int	magic_offset;
SHAR_EOF
chmod 0444 mlist-hlist.h || echo "restore of mlist-hlist.h fails"
set `wc -c mlist-hlist.h`;Sum=$1
if test "$Sum" != "742"
then echo original size 742, current size $Sum;fi
echo "x - extracting pack.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > pack.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 *		pack.c
X */
X
X#include "tex.h"
X#include "heap.h"
X#include "arith.h"
X#include "scan.h"
X#include "tokenstack.h"
X#include "eq.h"
X#include "eqstack.h"
X#include "evalstack.h"
X#include "box.h"
X#include "tfm.h"
X#include "dvi.h"
X#include "print.h"
X#include "error.h"
X#include "pack.h"
X
Xptr		adjust_tail;
Xval		pack_begin_line;
Xscal	total_shrink[4];
Xscal	total_stretch[4];
X
X#define	clr_dimens() \
X	{d = x = 0; \
X	total_stretch[FILLL] = 0; \
X	total_stretch[FILL] = 0; \
X	total_stretch[FIL] = 0; \
SHAR_EOF
echo "End of part 10"
echo "File pack.c is continued in part 11"
echo "11" > s2_seq_.tmp
exit 0



More information about the Comp.unix.xenix mailing list