LaTeX for Xenix (3 of 14)

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


---- Cut Here and unpack ----
#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file arith.c continued
#
CurArch=3
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 arith.c"
sed 's/^X//' << 'SHAR_EOF' >> arith.c
X	scal	x;
X	val		n;
X{
X	bool	negative;
X	scal	quotient;
X
X	negative = FALSE;
X	if (n == 0) {
X		arith_error = TRUE;
X		remainder = x;
X		return 0;
X	}
X	if (n < 0) {
X		negate(x);
X		negate(n);
X		negative = TRUE;
X	}
X	if (x >= 0) {
X		quotient = x / n;
X		remainder = x % n;
X	} else {
X		quotient = -(-x / n);
X		remainder = -(-x % n);
X	}
X	if (negative)
X		negate(remainder);
X	return quotient;
X}
X
Xscal
Xxn_over_d (x, n, d)
X	scal	x;
X	val		n;
X	val		d;
X{
X	val		t;
X	val		u;
X	val		v;
X	bool	positive;
X
X	if (x >= 0)
X		positive = TRUE;
X	else {
X		negate(x);
X		positive = FALSE;
X	}
X	t = (x % 0100000) * n;
X	u = (x / 0100000) * n + (t / 0100000);
X	v = (u % d) * 0100000 + (t % 0100000);
X	if (u / d >= 0100000)
X		arith_error = TRUE;
X	else u = 0100000 * (u / d) + (v / d);
X	if (positive) {
X		remainder = v % d;
X		return u;
X	} else {
X		remainder = - (v % d);
X		return -u;
X	}
X}
X
Xhword
Xbadness (t, s)
X	scal	t;
X	scal	s;
X{
X	val		r;
X
X	if (t == 0)
X		return 0;
X	else if (s <= 0)
X		return INF_BAD;
X	else {
X		if (t <= 7230584)
X			r = (t * 297) / s;
X		else if (s >= 1663497)
X			r = t / (s / 297);
X		else r = t;
X		if (r > 1290)
X			return INF_BAD;
X		else return ((r * r * r + 0400000) / 01000000);
X	}
X}
SHAR_EOF
echo "File arith.c is complete"
chmod 0444 arith.c || echo "restore of arith.c fails"
set `wc -c arith.c`;Sum=$1
if test "$Sum" != "2301"
then echo original size 2301, current size $Sum;fi
echo "x - extracting arith.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > arith.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 *		arith.h
X */
X
X#define	UNITY			0200000
X#define	TWO				0400000
X
Xval		half();
Xscal	round_decimals();
Xint		print_scaled();
X
Xglobal	bool	arith_error;
Xglobal	scal	remainder;
X
Xscal	nx_plus_y();
Xscal	x_over_n();
Xscal	xn_over_d();
X
X#define	INF_BAD			10000 
X
Xhword	badness();
SHAR_EOF
chmod 0444 arith.h || echo "restore of arith.h fails"
set `wc -c arith.h`;Sum=$1
if test "$Sum" != "485"
then echo original size 485, current size $Sum;fi
echo "x - extracting box.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > box.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 *		box.c
X */
X
X#include "tex.h"
X#include "texext.h"
X#include "arith.h"
X#include "heap.h"
X#include "char.h"
X#include "str.h"
X#include "eq.h"
X#include "hash.h"
X#include "tfm.h"
X#include "print.h"
X#include "math.h"
X#include "box.h"
X#include "token.h"
X#include "tokenlists.h"
X
Xval		depth_threshold;
Xval		breadth_max;
Xfnt		font_in_short_display;
X
Xptr
Xnew_null_box ()
X{
X	ptr		p;
X
X	p = get_node(BOX_NODE_SIZE);
X	type(p) = HLIST_NODE;
X	subtype(p) = MIN_QUARTERWORD;
X	width(p) = 0;
X	depth(p) = 0;
X	height(p) = 0;
X	shift_amount(p) = 0;
X	list_ptr(p) = NULL;
X	glue_sign(p) = NORMAL;
X	glue_order(p) = NORMAL;
X	glue_set(p) = 0.0;
X
X	return p;
X}
X
Xptr
Xnew_rule ()
X{
X	ptr		 p;
X
X	p = get_node(RULE_NODE_SIZE);
X	type(p) = RULE_NODE;
X	subtype(p) = 0;
X	width(p) = NULL_FLAG;
X	depth(p) = NULL_FLAG;
X	height(p) = NULL_FLAG;
X
X	return p;
X}
X
Xptr
Xnew_ligature (f, c, q)
X	qword	f;
X	qword	c;
X	ptr		q;
X{
X	ptr	 	p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = LIGATURE_NODE;
X	subtype(p) = 0;
X	font(lig_char(p)) = f;
X	character(lig_char(p)) = c;
X	lig_ptr(p) = q;
X
X	return p;
X}
X
Xptr
Xnew_disc ()
X{
X	ptr		p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = DISC_NODE;
X	replace_count(p) = 0;
X	pre_break(p) = NULL;
X	post_break(p) = NULL;
X
X	return p;
X}
X
Xptr
Xnew_math (w, s)
X	scal	w;
X	int		s;
X{
X	ptr		p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = MATH_NODE;
X	subtype(p) = s;
X	width(p) = w;
X
X	return p;
X}
X
Xptr
Xnew_spec (p)
X	ptr		p;
X{
X	ptr		q;
X
X	q = get_node(GLUE_SPEC_SIZE);
X	mem[q] = mem[p];
X	glue_ref_count(q) = NULL;
X	width(q) = width(p);
X	stretch(q) = stretch(p);
X	shrink(q) = shrink(p);
X
X	return q;
X}
X
Xptr
Xnew_param_glue (n)
X	int		n;
X{
X	ptr		p;
X	ptr		q;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = GLUE_NODE;
X	subtype(p) = n + 1;
X	leader_ptr(p) = NULL;
X	q = glue_par(n);
X	glue_ptr(p) = q;
X	incr(glue_ref_count(q));
X
X	return p;
X}
X
Xptr
Xnew_glue (q)
X	ptr		q;
X{
X	ptr		p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = GLUE_NODE;
X	subtype(p) = NORMAL;
X	leader_ptr(p) = NULL;
X	glue_ptr(p) = q;
X	incr(glue_ref_count(q));
X
X	return p;
X}
X
Xptr
Xnew_skip_param (n)
X	int		n;
X{
X	ptr		p;
X
X	temp_ptr = new_spec(glue_par(n));
X	p = new_glue(temp_ptr);
X	glue_ref_count(temp_ptr) = NULL;
X	subtype(p) = n + 1;
X
X	return p;
X}
X
Xptr
Xnew_kern (w)
X	scal	w;
X{
X	ptr		p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = KERN_NODE;
X	subtype(p) = NORMAL;
X	width(p) = w;
X
X	return p;
X}
X
Xptr
Xnew_penalty (m)
X	val		m;
X{
X	ptr		p;
X
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = PENALTY_NODE;
X	subtype(p) = 0;
X	penalty(p) = m;
X
X	return p;
X}
X
Xprint_font_and_char (p)
X	ptr		p;
X{
X	if (p > mem_end)
X		print_esc("CLOBBERED.");
X	else {
X		if (font(p) < FONT_BASE || font(p) > FONT_MAX)
X			print_char('*');
X		else {
X			print_esc("");
X			print_str(font_id_text(font(p)));
X			print_char(' ');
X			print_ASCII(qo(character(p)));
X		}
X	}
X}
X
Xprint_mark (p)
X	ptr		p;
X{
X	print_char('{');
X	if (p < 0 || p > tok_end)
X		print_esc("CLOBBERED.");
X	else show_token_list(token_link(p), NULL, (val) MAX_PRINT_LINE - 10);
X	print_char('}');
X}
X
Xprint_rule_dimen (d)
X	scal	d;
X{
X	if (is_running(d))
X		print_char('*');
X	else print_scaled(d);
X}
X
Xprint_glue (d, o, s)
X	scal	d;
X	qword	o;
X	char*	s;
X{
X	print_scaled(d);
X	if (o < NORMAL || o > FILLL)
X		print("foul");
X	else if (o > NORMAL) {
X		print("fil");
X		while  (o >  FIL) {
X			print_char('l');
X			decr(o);
X		}
X	} else if (s)
X		print(s);
X}
X
Xprint_spec (p, s)
X	ptr		p;
X	char*	s;
X{
X	if (p < MEM_MIN || p >= hi_mem_min)
X		print_char('*');
X	else {
X		print_scaled(width(p));
X		if (s) print(s);
X		if (stretch(p) != 0) {
X			print(" plus ");
X			print_glue(stretch(p), stretch_order(p), s);
X		}
X		if (shrink(p) != 0) {
X			print(" minus ");
X			print_glue(shrink(p), shrink_order(p), s);
X		}
X	}
X}
X
Xshort_display (p)
X	ptr		p;
X{
X	int		n;
X
X	for (p; p > NULL; p = link(p)) {
X		if (is_char_node(p) && p <= mem_end) {
X			if (font(p) != font_in_short_display) {
X				if (font(p) < FONT_BASE || font(p) > FONT_MAX) 
X					print_char('*');
X				else {
X					print_esc("");
X					print_str(font_id_text(font(p)));
X				}
X				print_char(' ');
X				font_in_short_display = font(p);
X			}
X			print_ASCII(qo(character(p)));
X		} else {
X			switch (type(p))
X			{
X			case HLIST_NODE:
X			case VLIST_NODE: 
X			case INS_NODE:
X			case WHATSIT_NODE:
X			case MARK_NODE:
X			case ADJUST_NODE:
X			case UNSET_NODE:
X				print("[]");
X				break;
X
X			case RULE_NODE:
X				print_char('|');
X				break;
X
X			case GLUE_NODE:
X				if (glue_ptr(p) != zero_glue)
X					print_char(' ');
X				break;
X
X			case MATH_NODE:
X				print_char('$');
X				break;
X
X			case LIGATURE_NODE:
X				short_display(lig_ptr(p));
X				break;
X
X			case DISC_NODE:
X				short_display(pre_break(p));
X				short_display(post_break(p));
X				n = replace_count(p);
X				while (n > 0) {
X					if (link(p) != NULL)
X						p = link(p);
X					decr(n);
X				}
X				break;
X
X			default:
X				break;
X			}
X		}
X	}
X}
X
Xshow_box (p)
X	ptr		p;
X{
X	depth_threshold = show_box_depth;
X	breadth_max = show_box_breadth;
X	if (breadth_max <= 0)
X		breadth_max = 5;
X	if (pool_ptr + depth_threshold >= POOL_SIZE)
X		depth_threshold = POOL_SIZE - pool_ptr - 1;
X	show_node_list(p);
X	print_ln();
X}
X
Xshow_box1 (p)
X	ptr		p;
X{
X	if (type(p) == HLIST_NODE)
X		print_esc("h");
X	else if (type(p) == VLIST_NODE)
X		print_esc("v");
X	else print_esc("unset");
X	print("box(");
X	print_scaled(height(p));
X	print_char('+')	;
X	print_scaled(depth(p));
X	print(")x")	;
X	print_scaled(width(p));
X	if (type(p) == UNSET_NODE) {
X		if (span_count(p) != MIN_QUARTERWORD) {
X			print(" (");
X			print_int(qo(span_count(p))+1);
X			print(" columns)");
X		}
X		if (glue_stretch(p) != 0) {
X			print(", stretch ");
X			print_glue(glue_stretch(p), glue_order(p), "");
X		}
X		if (glue_shrink(p) != 0) {
X			print(", shrink ");
X			print_glue(glue_shrink(p), glue_sign(p), "");
X		}
X	} else {
X		show_glue_set(p);
X		if (shift_amount(p) != 0) {
X			print(", shifted ");
X			print_scaled(shift_amount(p));
X		}
X	}
X	node_list_display(list_ptr(p));
X}
X
Xshow_glue_set (p)
X	ptr		p;
X{
X	if (glue_set(p) != 0 && glue_sign(p) != NORMAL) {
X		print(", glue set ");
X		if (glue_sign(p) == SHRINKING)
X			print("- ");
X		if (abs(glue_set(p)) > 20000.0) {
X			if (glue_set(p) > 0)
X				print_char('>');
X			else print("< -");
X			print_glue(20000 * UNITY, glue_order(p), "");
X		} else
X			print_glue(round(glue_set(p) * UNITY), glue_order(p), "");
X	}
X}
X
Xshow_rule (p)
X	ptr		p;
X{
X	print_esc("rule(");
X	print_rule_dimen(height(p));
X	print_char('+');
X	print_rule_dimen(depth(p));
X	print(")x");
X	print_rule_dimen(width(p));
X}
X
Xshow_insertion (p)
X	ptr		p;
X{
X	print_esc("insert");
X	print_int(qo(subtype(p)));
X	print(", natural size ");
X	print_scaled(height(p));
X	print("; split(");
X	print_spec(split_top_ptr(p), "");
X	print_char(',');
X	print_scaled(depth(p));
X	print("); float cost ");
X	print_val(float_cost(p));
X	node_list_display(ins_ptr(p));
X}
X
Xshow_leaders (p)
X	ptr		p;
X{
X	print_esc("");
X	if (subtype(p) == C_LEADERS)
X		print_char('c');
X	else if (subtype(p) == X_LEADERS)
X		print_char('x');
X	print("leaders ");
X	print_spec(glue_ptr(p), "");
X	node_list_display(leader_ptr(p));
X}
X
Xshow_glue (p)
X	ptr		p;
X{
X	if (subtype(p) >= A_LEADERS)
X		show_leaders(p);
X	else {
X		print_esc("glue");
X		if (subtype(p) != NORMAL) {
X			print_char('(');
X			if (subtype(p) < COND_MATH_GLUE)
X				print_skip_param(subtype(p) - 1);
X			else if (subtype(p) == COND_MATH_GLUE)
X				print_esc("nonscript");
X			else print_esc("mskip");
X			print_char(')');
X		}
X		if (subtype(p) != COND_MATH_GLUE) {
X			print_char(' ');
X			if (subtype(p) < COND_MATH_GLUE)
X				print_spec(glue_ptr(p), "");
X			else print_spec(glue_ptr(p), "mu");
X		}
X	}
X}
X
Xshow_kern (p)
X	ptr		p;
X{
X	if (subtype(p) != MU_GLUE) {
X		print_esc("kern");
X		if (subtype(p) != NORMAL)
X			print_char(' ');
X		print_scaled(width(p));
X		if (subtype(p) == ACC_KERN)
X			print(" (for accent)");}
X	else {
X		print_esc("mkern");
X		print_scaled(width(p));
X		print("mu");
X	}
X}
X
Xshow_math (p)
X	ptr		p;
X{
X	print_esc("math");
X	if (subtype(p) == BEFORE)
X		print("on");
X	else print("off");
X	if (width(p) != 0) {
X		print(", surrounded ");
X		print_scaled(width(p));
X	}
X}
X	
Xshow_ligature (p)
X	ptr		p;
X{
X	print_font_and_char(lig_char(p));
X	print(" (ligature ");
X	font_in_short_display = font(lig_char(p));
X	short_display(lig_ptr(p));
X	print_char(')');
X}
X
Xshow_discretionary (p)
X	ptr		p;
X{
X	print_esc("discretionary");
X	if (replace_count(p) > 0) {
X		print(" replacing ");
X		print_int(replace_count(p));
X	}
X	node_list_display(pre_break(p));
X	append_char('|');
X	show_node_list(post_break(p));
X	flush_char();
X}
X
Xshow_penalty (p)
X	ptr		p;
X{
X	print_esc("penalty ");
X	print_val(penalty(p));
X}
X
Xshow_mark (p)
X	ptr		p;
X{
X	print_esc("mark");
X	print_mark(mark_ptr(p));
X}
X
Xshow_adjust (p)
X	ptr		p;
X{
X	print_esc("vadjust");
X	node_list_display(adjust_ptr(p));
X}
X
Xshow_node_list (p)
X	ptr 	p;
X{
X	int		n;
X
X	if (cur_length() > depth_threshold) {
X		if (p > NULL)
X			print(" []");
X		return;
X	}
X	n = 0;
X	while (p > NULL) {
X		print_ln();
X		print_current_string();
X		if (p > mem_end) {
X			print("Bad link, display aborted.");
X			return;
X		}
X		incr(n);
X		if (n > breadth_max) {
X			print("etc.");
X			return;
X		}
X		if (is_char_node(p))
X			print_font_and_char(p);
X		else {
X			switch (type(p))
X			{
X			case HLIST_NODE:
X			case VLIST_NODE:
X			case UNSET_NODE:
X				show_box1(p);
X				break;
X
X			case RULE_NODE:
X				show_rule(p);
X				break;
X			
X			case INS_NODE:
X				show_insertion(p);
X				break;
X			
X			case WHATSIT_NODE:
X				show_whatsit(p);
X				break;
X			
X			case GLUE_NODE:
X				show_glue(p);
X				break;
X			
X			case KERN_NODE:
X				show_kern(p);
X				break;
X			
X			case MATH_NODE:
X				show_math(p);
X				break;
X			
X			case LIGATURE_NODE:
X				show_ligature(p);
X				break;
X
X			case PENALTY_NODE:
X				show_penalty(p);
X				break;
X		
X			case DISC_NODE:
X				show_discretionary(p);
X				break;
X			
X			case MARK_NODE:
X				show_mark(p);
X				break;
X			
X			case ADJUST_NODE:
X				show_adjust(p);
X				break;
X			
X			case STYLE_NODE:
X				print_style(subtype(p));
X				break;
X			
X			case CHOICE_NODE:
X				show_choice_node(p);
X				break;
X
X			case INNER_NOAD:
X			case ORD_NOAD:
X			case OP_NOAD:
X			case BIN_NOAD:
X			case REL_NOAD:
X			case OPEN_NOAD:
X			case CLOSE_NOAD:
X			case PUNCT_NOAD:
X			case RADICAL_NOAD:
X			case OVER_NOAD:
X			case UNDER_NOAD:
X			case VCENTER_NOAD:
X			case ACCENT_NOAD:
X			case LEFT_NOAD:
X			case RIGHT_NOAD:
X				show_normal_noad(p);
X				break;
X			
X			case FRACTION_NOAD:
X				show_fraction_noad(p);
X				break;
X
X			default:
X				print("Unknown node type!");
X				break;
X			}
X		}
X		p = link(p);
X	}
X}
X
Xshow_info ()
X{
X	show_node_list(info(temp_ptr));
X}
X
Xdelete_glue_ref (p)
X	ptr		p;
X{
X	if (glue_ref_count(p) == NULL)
X		free_node(p, GLUE_SPEC_SIZE);
X	else decr(glue_ref_count(p));
X}
X
Xflush_node_list (p)
X	ptr		p;
X{
X	ptr		q;
X
X	while (p != NULL) {
X		q = link(p);
X		if (is_char_node(p)) {
X			free_avail(p);
X		} else {
X			switch (type(p))
X			{
X			case HLIST_NODE:
X			case VLIST_NODE:
X			case UNSET_NODE:
X				flush_node_list(list_ptr(p));
X				free_node(p, BOX_NODE_SIZE);
X				goto done;
X				break;
X					
X			case RULE_NODE:
X				free_node(p, RULE_NODE_SIZE);
X				goto done;
X				break;
X
X			case INS_NODE:
X				flush_node_list(ins_ptr(p));
X				delete_glue_ref(split_top_ptr(p));
X				free_node(p, INS_NODE_SIZE);
X				goto done;
X				break;
X
X			case WHATSIT_NODE:
X				free_whatsit(p);
X				goto done;
X				break;
X			
X			case GLUE_NODE:
X				fast_delete_glue_ref(glue_ptr(p));
X				if (leader_ptr(p) != NULL)
X					flush_node_list(leader_ptr(p));
X				break;
X
X			case KERN_NODE:
X			case MATH_NODE:
X			case PENALTY_NODE:
X				break;
X
X			case LIGATURE_NODE:
X				flush_node_list(lig_ptr(p));
X				break;
X
X			case MARK_NODE:
X				delete_token_ref(mark_ptr(p));
X				break;
X			
X			case DISC_NODE:
X				flush_node_list(pre_break(p));
X				flush_node_list(post_break(p));
X				break;
X
X			case ADJUST_NODE:
X				flush_node_list(adjust_ptr(p));
X				break;
X
X			case STYLE_NODE:
X				free_node(p, STYLE_NODE_SIZE);
X				goto done;
X				break;
X
X			case CHOICE_NODE:
X				flush_node_list(display_mlist(p));
X				flush_node_list(text_mlist(p));
X				flush_node_list(script_mlist(p));
X				flush_node_list(script_script_mlist(p));
X				free_node(p, STYLE_NODE);
X				goto done;
X				break;
X
X			case ORD_NOAD:
X			case OP_NOAD:
X			case BIN_NOAD:
X			case REL_NOAD:
X			case OPEN_NOAD:
X			case CLOSE_NOAD:
X			case PUNCT_NOAD:
X			case INNER_NOAD:
X			case RADICAL_NOAD:
X			case OVER_NOAD:
X			case UNDER_NOAD:
X			case VCENTER_NOAD:
X			case ACCENT_NOAD:
X				if (math_type(nucleus(p)) >= SUB_BOX)
X					flush_node_list(info(nucleus(p)));
X				if (math_type(supscr(p)) >= SUB_BOX)
X					flush_node_list(info(supscr(p)));
X				if (math_type(subscr(p)) >= SUB_BOX)
X					flush_node_list(info(subscr(p)));
X				if (type(p) == RADICAL_NOAD)
X					free_node(p, RADICAL_NOAD_SIZE);
X				else if (type(p) == ACCENT_NOAD)
X					free_node(p, ACCENT_NOAD_SIZE);
X				else free_node(p, NOAD_SIZE);
X				goto done;
X				break;
X			
X			case LEFT_NOAD:
X			case RIGHT_NOAD:
X				free_node(p, NOAD_SIZE);
X				goto done;
X				break;
X			
X			case FRACTION_NOAD:
X				flush_node_list(info(numerator(p)));
X				flush_node_list(info(denominator(p)));
X				free_node(p, FRACTION_NOAD_SIZE);
X				goto done;
X				break;
X
X			default:
X				confusion("flushing");
X				break;
X			}
X			free_node(p, SMALL_NODE_SIZE);
X			done:;	
X		}
X		p = q;
X	}
X}
X
Xptr
Xcopy_node_list (p)
X	ptr		p;
X{
X	ptr		h;
X	ptr		q;
X	ptr		r;
X	int		words;
X
X	h = get_avail();
X	q = h;
X	while (p != NULL) {
X		words = 1;
X		if (is_char_node(p))
X			r = get_avail();
X		else {
X			switch (type(p))
X			{
X			case HLIST_NODE:
X			case VLIST_NODE:
X			case UNSET_NODE:
X				r = get_node(BOX_NODE_SIZE);
X				mem[r + 6] = mem[p + 6];
X				mem[r + 5] = mem[p + 5];
X				list_ptr(r) = copy_node_list(list_ptr(p));
X				words = 5;
X				break;
X			
X			case RULE_NODE:
X				r = get_node(RULE_NODE_SIZE);
X				words = RULE_NODE_SIZE;
X				break;
X
X			case INS_NODE:
X				r = get_node(INS_NODE_SIZE);
X				mem[r + 4] = mem[p + 4];
X				add_glue_ref(split_top_ptr(p));
X				ins_ptr(r) = copy_node_list(ins_ptr(p));
X				words = INS_NODE_SIZE - 1;
X				break;
X
X			case WHATSIT_NODE:
X				r = copy_whatsit(p);
X				break;
X			
X			case GLUE_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				add_glue_ref(glue_ptr(p));
X				glue_ptr(r) = glue_ptr(p);
X				leader_ptr(r) = copy_node_list(leader_ptr(p));
X				break;
X			
X			case KERN_NODE:
X			case MATH_NODE:
X			case PENALTY_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				words = SMALL_NODE_SIZE;
X				break;
X			
X			case LIGATURE_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				mem[lig_char(r)] = mem[lig_char(p)];
X				lig_ptr(r) = copy_node_list(lig_ptr(p));
X				break;
X				
X			case DISC_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				pre_break(r) = copy_node_list(pre_break(p));
X				post_break(r) = copy_node_list(post_break(p));
X				break;
X
X			case MARK_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				add_token_ref(mark_ptr(p));
X				words = SMALL_NODE_SIZE;
X				break;
X
X			case ADJUST_NODE:
X				r = get_node(SMALL_NODE_SIZE);
X				adjust_ptr(r) = copy_node_list(adjust_ptr(p));
X				break;
X			
X			default:
X				confusion("copying");
X				break;
X			}
X		}
X		while (words > 0) {
X			decr(words);
X			mem[r + words] = mem[p + words];
X		}
X		link(q) = r;
X		q = r;
X		p = link(p);
X	}
X	link(q) = NULL;
X	q = link(h);
X	free_avail(h);
X	return q;
X}
SHAR_EOF
chmod 0444 box.c || echo "restore of box.c fails"
set `wc -c box.c`;Sum=$1
if test "$Sum" != "15162"
then echo original size 15162, current size $Sum;fi
echo "x - extracting box.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > box.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 *		box.h
X */
X
X#define	type(M)				mem[M].hh.hh2.b0
X#define	subtype(M)			mem[M].hh.hh2.b1
X
X#define	font				type
X#define	character			subtype
X#define	is_char_node(M)		(M >= hi_mem_min)
X
Xptr	new_null_box();
X
X#define	HLIST_NODE			0
X#define	VLIST_NODE			1
X
X#define	BOX_NODE_SIZE		7
X#define	WIDTH_OFFSET		1
X#define	DEPTH_OFFSET		2
X#define	HEIGHT_OFFSET		3
X#define	SHIFT_OFFSET		4
X#define	LIST_OFFSET			5
X#define	GLUE_OFFSET			6
X#define	width(B)			mem[B + WIDTH_OFFSET].sc
X#define	depth(B)			mem[B + DEPTH_OFFSET].sc
X#define	height(B)			mem[B + HEIGHT_OFFSET].sc
X#define	shift_amount(B)		mem[B + SHIFT_OFFSET].sc
X#define	list_ptr(B)			link(B + LIST_OFFSET)
X#define	glue_order(B)		subtype(B + LIST_OFFSET)
X#define	glue_sign(B)		type(B + LIST_OFFSET)
X#define	glue_set(B)			mem[B + GLUE_OFFSET].gr
X
X#define	NORMAL				0
X#define	STRETCHING			1
X#define	SHRINKING			2
X	
Xptr new_rule();
X
X#define	RULE_NODE			2
X#define	RULE_NODE_SIZE		4
X#define	NULL_FLAG			-010000000000
X#define	is_running(R)		(R == NULL_FLAG)
X
X#define	INS_NODE			3
X#define	INS_NODE_SIZE		5
X#define	float_cost(I)		mem[I + 1].i
X#define	ins_ptr(I)			info(I + 4)
X#define	split_top_ptr(I)	link(I + 4)
X	
X#define	MARK_NODE			4
X#define	SMALL_NODE_SIZE		2
X#define	mark_ptr(M)			link(M + 1)
X	
X#define	ADJUST_NODE			5
X#define	adjust_ptr			mark_ptr
X
Xptr new_ligature();
X
X#define	LIGATURE_NODE		6
X#define	lig_char(L)			L + 1
X#define	lig_ptr(L)			link(lig_char(L))
X
Xptr	new_disc();
X
X#define	DISC_NODE			7
X#define	replace_count		subtype
X#define	pre_break			llink
X#define	post_break			rlink
X
X#define	WHATSIT_NODE		8
X
Xptr	new_math();
X
X#define	MATH_NODE			9
X#define	BEFORE				0
X#define	AFTER				1
X
X#define	precedes_break(M)	(type(M) < MATH_NODE)
X#define	non_discardable(M)	(type(M) < MATH_NODE)
X
Xptr	new_spec();
Xptr new_param_glue();
Xptr new_glue();
Xptr new_skip_param();
X
X#define	GLUE_NODE			10
X#define	COND_MATH_GLUE		98
X#define	MU_GLUE				99
X#define	A_LEADERS			100
X#define	C_LEADERS			101
X#define	X_LEADERS			102
X#define	glue_ptr			llink
X#define	leader_ptr			rlink
X
X#define	GLUE_SPEC_SIZE		4
X#define	glue_ref_count(G)	link(G)
X#define	stretch(G)			mem[G + 2].sc
X#define	shrink(G)			mem[G + 3].sc
X#define	stretch_order		type
X#define	shrink_order		subtype
X#define	FIL					1
X#define	FILL				2
X#define	FILLL				3
X
Xptr new_kern();
X
X#define	KERN_NODE			11
X#define	EXPLICIT			1
X#define	ACC_KERN			2
X
Xptr	new_penalty();
X
X#define	PENALTY_NODE		12
X#define	INF_PENALTY			10000L
X#define	EJECT_PENALTY		-INF_PENALTY
X#define	penalty(P)			mem[P + 1].i
X
X#define	UNSET_NODE			13
X#define	span_count			subtype
X#define	glue_stretch(U)		mem[U + GLUE_OFFSET].sc
X#define	glue_shrink			shift_amount
X
Xint	print_short_display();
Xint	print_font_and_char();
Xint	print_mark();
Xint	print_rule_dimen();
Xint	print_glue();
Xint	print_spec(); 
X
X#define	node_list_display(N) \
X	{append_char('.'); show_node_list(N); flush_char();}
X
Xglobal	int		font_in_short_display;
Xglobal	val		depth_threshold;
Xglobal	val		breadth_max;
Xglobal	int		words;
X
Xint	show_node_list();
Xint	show_box();
Xint	show_info();
Xint	short_display();
X
Xptr	copy_node_list();
Xint	flush_node_list();
X
Xint	delete_glue_ref();
X#define	fast_delete_glue_ref(G)	\
X	{if (glue_ref_count(G) == NULL) \
X		free_node(G, GLUE_SPEC_SIZE); \
X	else decr(glue_ref_count(G));}
X#define	add_glue_ref(G) \
X	incr(glue_ref_count(G))
SHAR_EOF
chmod 0444 box.h || echo "restore of box.h fails"
set `wc -c box.h`;Sum=$1
if test "$Sum" != "3489"
then echo original size 3489, current size $Sum;fi
echo "x - extracting boxlists.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > boxlists.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 *		boxlists.c
X */
X
X#include "tex.h"
X#include "cmds.h"
X#include "heap.h"
X#include "eq.h"
X#include "eqstack.h"
X#include "def.h"
X#include "box.h"
X#include "tokenstack.h"
X#include "token.h"
X#include "scan.h"
X#include "tokenlists.h"
X#include "evalstack.h"
X#include "tfm.h"
X#include "pack.h"
X#include "page.h"
X#include "math.h"
X#include "io.h"
X#include "print.h"
X#include "error.h"
X#include "boxlists.h"
X
Xptr		cur_box;
X
Xappend_glue ()
X{
X	hword	s;
X	
X	s = cur_chr;
X	switch (s) 
X	{
X	case FIL_CODE:
X		cur_val = fil_glue;
X		break;
X
X	case FILL_CODE:
X		cur_val = fill_glue;
X		break;
X
X	case SS_CODE:
X		cur_val = ss_glue;
X		break;
X
X	case FIL_NEG_CODE:
X		cur_val = fil_neg_glue;
X		break;
X
X	case SKIP_CODE:
X		scan_glue(GLUE_VAL);
X		break;
X
X	case MSKIP_CODE:
X		scan_glue(MU_VAL);
X		break;
X
X	default:
X		break;
X	}
X	tail_append(new_glue((ptr) cur_val));
X	if (s >= SKIP_CODE) {
X		decr(glue_ref_count((ptr) cur_val));
X		if (s > SKIP_CODE)
X			subtype(tail) = MU_GLUE;
X	}
X}
X
Xappend_kern ()
X{
X	qword	s;
X	
X	s = cur_chr;
X	scan_dimen(s == MU_GLUE, FALSE, FALSE);
X	tail_append(new_kern(cur_val));
X	subtype(tail) = s;
X}
X
Xhandle_right_brace ()
X{
X	scal	d;
X	val		f;
X	ptr		p;
X	ptr		q;
X	
X	switch (cur_group)
X	{
X	case SIMPLE_GROUP:
X		unsave();
X		break;
X	
X	case BOTTOM_LEVEL:
X		print_err("Too many }'s");
X		help_close_group();
X		error();
X		break;
X	
X	case SEMI_SIMPLE_GROUP:
X	case MATH_SHIFT_GROUP:
X	case MATH_LEFT_GROUP:
X		extra_right_brace();
X		break;
X
X	case HBOX_GROUP:
X		package(0);
X		break;
X	
X	case ADJUSTED_HBOX_GROUP:
X		adjust_tail = adjust_head;
X		package(0);
X		break;
X	
X	case VBOX_GROUP:
X		end_graf();
X		package(0);
X		break;
X	
X	case VTOP_GROUP:
X		end_graf();
X		package(VTOP_CODE);
X		break;
X
X	case INSERT_GROUP:
X		end_graf();
X		q = split_top_skip;
X		add_glue_ref(q);
X		d = split_max_depth;
X		f = floating_penalty;
X		unsave();
X		decr(save_ptr);
X		p = vpack(link(head), NATURAL);
X		pop_nest();
X		if (saved(0) < 255) {
X			tail_append(get_node(INS_NODE_SIZE));
X			type(tail) = INS_NODE;
X			subtype(tail) = qi(saved(0));
X			height(tail) = height(p) + depth(p);
X			ins_ptr(tail) = list_ptr(p);
X			split_top_ptr(tail) = q;
X			depth(tail) = d;
X			float_cost(tail) = f;
X		} else {
X			tail_append(get_node(SMALL_NODE_SIZE));
X			type(tail) = ADJUST_NODE;
X			subtype(tail) = 0;
X			adjust_ptr(tail) = list_ptr(p);
X			delete_glue_ref(q);
X		}
X		free_node(p, BOX_NODE_SIZE);
X		if (nest_ptr == 0) 
X			build_page();
X		break;
X	
X	case OUTPUT_GROUP:
X		if (loc != NULL)  {
X			print_err("Unbalanced output routine");
X			help_output_balance();
X			error();
X			do get_token();
X			while (loc != NULL);
X		}
X		end_token_list();
X		end_graf();
X		unsave();
X		output_active = FALSE;
X		insert_penalties = 0;
X		if (box(255) != NULL) {
X			print_err("Output routine didn't use all of ");
X			print_esc("box255");
X			help_output();
X			box_error(255);
X		}
X		if (tail != head) {
X			link(page_tail) = link(head);
X			page_tail = tail;
X		}
X		if (link(page_head) != NULL) {
X			if (link(contrib_head) == NULL)
X				contrib_tail = page_tail;
X			link(page_tail) = link(contrib_head);
X			link(contrib_head) = link(page_head);
X			link(page_head) = NULL;
X			page_tail = page_head;
X		}
X		pop_nest();
X		build_page();
X		break;
X	
X	case DISC_GROUP:
X		build_discretionary();
X		break;
X	
X	case ALIGN_GROUP:
X		back_input();
X		cur_tok = CS_TOKEN_FLAG + FROZEN_CR;
X		print_err("Missing ");
X		print_esc("cr");
X		print(" inserted");
X		help_align_cr();
X		ins_error(); 
X		break;
X
X	case NO_ALIGN_GROUP:
X		end_graf();
X		unsave();
X		align_peek();
X		break;
X	
X	case VCENTER_GROUP:
X		end_graf();
X		unsave();
X		save_ptr -= 2;
X		p = vpackage(link(head), saved(1), (int) saved(0), MAX_DIMEN);
X		pop_nest();
X		tail_append(new_noad());
X		type(tail) = VCENTER_NOAD;
X		math_type(nucleus(tail)) = SUB_BOX;
X		info(nucleus(tail)) = p;
X		break;
X	
X	case MATH_CHOICE_GROUP:
X		build_choices();
X		break;
X
X	case MATH_GROUP:
X		unsave();
X		decr(save_ptr);
X		math_type(saved(0)) = SUB_MLIST;
X		p = fin_mlist(NULL);
X		info(saved(0)) = p;
X		if (p != NULL) {
X			if (link(p) == NULL) {
X				if (type(p) == ORD_NOAD) {
X					if (math_type(subscr(p)) == EMPTY &&
X						math_type(supscr(p)) == EMPTY) {
X						mem[saved(0)].hh = mem[nucleus(p)].hh;
X						free_node(p, NOAD_SIZE);
X					}
X				} else if (type(p) == ACCENT_NOAD &&
X					saved(0) == nucleus(tail) &&
X					type(tail) == ORD_NOAD) {
X					q = head;
X					while (link(q) != tail)
X						q = link(q);
X					link(q) = p;
X					free_node(tail, NOAD_SIZE);
X					tail = p;
X				}
X			}
X		}
X		break;
X	
X	default:
X		confusion("rightbrace");
X		break;
X	}
X}
X
Xextra_right_brace ()
X{
X	print_err("Extra }, or forgotten ");
X	switch (cur_group) 
X	{
X	case SEMI_SIMPLE_GROUP:
X		print_esc("endgroup");
X		break;
X
X	case MATH_SHIFT_GROUP:
X		print_char('$');
X		break;
X
X	case MATH_LEFT_GROUP:
X		print_esc("right");
X		break;
X	}
X	help_group_close();
X	error();
X	incr(align_state);
X}
X
Xpackage (c)
X	int		c;
X{
X	scal	d;
X	scal	h;
X	ptr		p;
X
X	d = box_max_depth;
X	unsave();
X	save_ptr -= 3;
X	if (mode == -HMODE)
X		cur_box = hpack(link(head), saved(2), (int) saved(1));
X	else {
X		cur_box = vpackage(link(head), saved(2), (int) saved(1), d);
X		if (c == VTOP_CODE) {
X			h = 0;
X			p = list_ptr(cur_box);
X			if (p != NULL && type(p) <= RULE_NODE)
X				h = height(p);
X			depth(cur_box) += height(cur_box) - h;
X			height(cur_box) = h;
X		}
X	}
X	pop_nest();
X	box_end();
X}
X
Xbox_end ()
X{
X	ptr		p;
X
X	if (saved(0) < BOX_FLAG) {
X		if (cur_box != NULL) {
X			shift_amount(cur_box) = saved(0);
X			if (abs(mode) == VMODE) {
X				append_to_vlist(cur_box);
X				if (adjust_tail != NULL) {
X					if (adjust_head != adjust_tail) {
X						link(tail) = link(adjust_head);
X						tail = adjust_tail;
X					}
X					adjust_tail = NULL;
X				}
X				if (mode > 0) 
X					build_page();
X			} else {
X				if (abs(mode) == HMODE)
X					space_factor = 1000;
X				else {
X					p = new_noad();
X					math_type(nucleus(p)) = SUB_BOX;
X					info(nucleus(p)) = cur_box;
X					cur_box = p;
X				}
X				link(tail) = cur_box;
X				tail = cur_box;
X			}
X		}
X	} else if (saved(0) < SHIP_OUT_FLAG)
X		if (saved(0) < BOX_FLAG + 256)
X			eq_define((ptr)(BOX_BASE-BOX_FLAG+saved(0)), BOX_REF, cur_box);
X		else
X			geq_define((ptr)(BOX_BASE-BOX_FLAG-256+saved(0)), BOX_REF, cur_box);
X	else if (cur_box != NULL) {
X		if (saved(0) > SHIP_OUT_FLAG) {
X			get_nbrx_token();
X			if (cur_cmd == HSKIP && abs(mode) != VMODE ||
X				cur_cmd == VSKIP && abs(mode) == VMODE ||
X				cur_cmd == MSKIP && abs(mode) == MMODE) {
X				append_glue();
X				leader_ptr(tail) = cur_box;
X				subtype(tail) = saved(0) - (LEADER_FLAG - A_LEADERS);
X			} else {
X				print_err("Leaders not followed by proper glue");
X				help_leaders();
X				back_error();
X				flush_node_list(cur_box);
X			}
X		} else
X			ship_out(cur_box);
X	}
X}
X
Xbegin_box ()
X{
X	int		k;
X	int		m;
X	int		n;
X	ptr		p;
X	ptr		q;
X
X	switch (cur_chr)
X	{
X	case BOX_CODE:
X		scan_eight_bit_int();
X		cur_box = box(cur_val);
X		box(cur_val) = NULL;
X		break;
X	
X	case COPY_CODE:
X		scan_eight_bit_int();
X		cur_box = copy_node_list(box(cur_val));
X		break;
X	
X	case LAST_BOX_CODE:
X		cur_box = NULL;
X		if (abs(mode) == MMODE) {
X			you_cant();
X			help_lastbox_m();
X			error();
X		} else if (mode == VMODE && head == tail) {
X			you_cant();
X			help_lastbox_v();
X			error();
X		} else if (!is_char_node(tail) &&
X			(type(tail) == HLIST_NODE || type(tail) == VLIST_NODE)) {
X			q = head;
X			do	{
X				p = q;
X				if (!is_char_node(q) && type(q) == DISC_NODE) {
X					for (m = 1; m <= replace_count(q); incr(m)) 
X						p = link(p);
X					if (p == tail)
X						break;
X				}
X				q = link(p);
X			} while (q != tail);
X			cur_box = tail;
X			shift_amount(cur_box) = 0;
X			tail = p;
X			link(p) = NULL;
X		}
X		break;
X
X	case VSPLIT_CODE:
X		scan_eight_bit_int();
X		n = cur_val;
X		if (!scan_keyword("to")) {
X			print_err("Missing `to' inserted");
X			help_vsplit();
X			error();
X		}
X		scan_normal_dimen();
X		cur_box = vsplit(n, cur_val);
X		break;
X	
X	default:
X		k = cur_chr - VTOP_CODE;
X		incr(save_ptr);
X		scan_spec();
X		if (k == HMODE) {
X			if (saved(-3) < BOX_FLAG && abs(mode) == VMODE)
X				new_save_level(ADJUSTED_HBOX_GROUP);
X			else new_save_level(HBOX_GROUP);
X		} else {
X			if (k == VMODE)
X				new_save_level(VBOX_GROUP);
X			else {
X				new_save_level(VTOP_GROUP);
X				k = VMODE;
X			}
X			normal_paragraph();
X		}
X		push_nest();
X		mode = -k;
X		if (k == VMODE) {
X			prev_depth = IGNORE_DEPTH;
X			if (every_vbox != NULL)
X				begin_token_list(every_vbox, EVERY_VBOX_TEXT);
X		} else {
X			space_factor = 1000;
X			if (every_hbox != NULL) 
X				begin_token_list(every_hbox, EVERY_HBOX_TEXT);
X		}
X		return;
X		break;
X	}
X	box_end();
X}
X
Xscan_spec ()
X{
X	if (scan_keyword("to"))
X		saved(0) = EXACTLY;
X	else if (scan_keyword("spread")) 
X		saved(0) = ADDITIONAL;
X	else {
X		saved(0) = ADDITIONAL;
X		saved(1) = 0;
X		goto found;
X	}
X	scan_normal_dimen();
X	saved(1) = cur_val;
X
Xfound:
X	save_ptr += 2;
X	scan_left_brace();
X}
X
Xscan_box ()
X{
X	get_nbrx_token();
X	if (cur_cmd == MAKE_BOX)
X		begin_box();
X	else if (saved(0) >= LEADER_FLAG &&
X			(cur_cmd == HRULE || cur_cmd == VRULE)) {
X			cur_box = scan_rule_spec();
X			box_end();
X	} else {
X		print_err("A <box> was supposed to be here");
X		help_box();
X		back_error();
X	}
X}
X
Xnormal_paragraph ()
X{
X	if (looseness != 0)
X		eq_word_define((ptr) INT_BASE + LOOSENESS_CODE, 0L);
X	if (hang_indent != 0)
X		eq_word_define((ptr) DIMEN_BASE + HANG_INDENT_CODE, 0L);
X	if (hang_after != 1)
X		eq_word_define((ptr) INT_BASE + HANG_AFTER_CODE, 1L);
X	if (par_shape_ptr != NULL)
X		eq_define(PAR_SHAPE_LOC, SHAPE_REF, NULL);
X}
X
Xnew_graf (indented)
X	bool	indented;
X{
X	prev_graf = 0;
X	if (mode == VMODE || head != tail)
X		tail_append(new_param_glue(PAR_SKIP_CODE));
X	push_nest();
X	mode = HMODE;
X	space_factor = 1000;
X	if (indented) {
X		tail = new_null_box();
X		link(head) = tail;
X		width(tail) = par_indent;
X	}
X	if (every_par != NULL)
X		begin_token_list(every_par, EVERY_PAR_TEXT);
X	if (nest_ptr == 1) 
X		build_page();
X}
X
Xindent_in_hmode ()
X{
X	ptr		p;
X	ptr		q;
X
X	if (cur_chr > 0) {
X		p = new_null_box();
X		width(p) = par_indent;
X		if (abs(mode) == HMODE)
X			space_factor = 1000;
X		else {
X			q = new_noad();
X			math_type(nucleus(q)) = SUB_BOX;
X			info(nucleus(q)) = p;
X			p = q;
X		}
X		tail_append(p);
X	}
X}
X
Xhead_for_vmode ()
X{
X	if (mode < 0) {
X		if (cur_cmd != HRULE)
X			off_save();
X		else {
X			print_err("You can't use `");
X			print_esc("hrule");
X			print("' here except with leaders");
X			help_head_for_vmode();
X			error();
X		}
X	} else {
X		back_input();
X		cur_tok = par_token;
X		back_input();
X		token_type = INSERTED;
X	}
X}
X	
Xend_graf ()
X{
X	if (mode == HMODE) {
X		if (head == tail)
X			pop_nest();
X		else
X			line_break(widow_penalty);
X		normal_paragraph();
X		error_count = 0;
X	}
X}
X
Xappend_to_vlist (b)
X	ptr		b;
X{
X	scal	d;
X	ptr		p;
X
X	if (prev_depth > IGNORE_DEPTH) {
X		d = width(baseline_skip) - prev_depth - height(b);
X		if (d < line_skip_limit)
X			p = new_param_glue(LINE_SKIP_CODE);
X		else {
X			p = new_skip_param(BASELINE_SKIP_CODE);
X			width(temp_ptr) = d;
X		}
X		link(tail) = p;
X		tail = p;
X	}
X	link(tail) = b;
X	tail = b;
X	prev_depth = depth(b);
X}
X
Xbegin_insert_or_adjust ()
X{
X	if (cur_cmd == VADJUST)
X		cur_val = 255;
X	else {
X		scan_eight_bit_int();
X		if (cur_val == 255) {
X			print_err("You can't ");
X			print_esc("insert");
X			print_int(255);
X			help_insert_255();
X			error();
X			cur_val = 0;
X		}
X	}
X	saved(0) = cur_val;
X	incr(save_ptr);
X	new_save_level(INSERT_GROUP);
X	scan_left_brace();
X	normal_paragraph();
X	push_nest();
X	mode = -VMODE;
X	prev_depth = IGNORE_DEPTH;
X}
X
Xmake_mark ()
X{
X	ptr		p;
X
X	scan_toks(FALSE, TRUE);
X	p = get_node(SMALL_NODE_SIZE);
X	type(p) = MARK_NODE;
X	subtype(p) = 0;
X	mark_ptr(p) = def_ref;
X	link(tail) = p;
X	tail = p;
X}
X
Xappend_penalty ()
X{
X	scan_int();
X	tail_append(new_penalty(cur_val));
X	if (mode == VMODE) 
X		build_page();
X}
X
Xdelete_last ()
X{
X	qword	m;
X	ptr		p;
X	ptr		q;
X
X	if (mode == VMODE && tail == head) {
X		if (cur_chr != GLUE_NODE || last_glue != MAX_HALFWORD) {
X			you_cant();
X			help_delete_last();
X			if (cur_chr == KERN_NODE)
X				help_line[1] = "Try `I\\kern-\\lastkern' instead.";
X			else if (cur_chr != GLUE_NODE)
X				help_line[1] = "Perhaps you can make the output routine do it.";
X			error();
X		}
X	} else if (!is_char_node(tail) && type(tail) == cur_chr) {
X		q = head;
X		do	{
X			p = q;
X			if (!is_char_node(q) && type(q) == DISC_NODE) {
X				for (m = 1; m <= replace_count(q); incr(m))
X					p = link(p);
X				if (p == tail)
X					return;
X			}
X			q = link(p);
X		} while (q != tail);
X		link(p) = NULL;
X		flush_node_list(tail);
X		tail = p;
X	}
X}
X
Xunpackage ()
X{	
X	int		c;
X	ptr		p;
X	
X	c = cur_chr;
X	scan_eight_bit_int();
X	p = box(cur_val);
X	if (p == NULL) return;
X	if (abs(mode) == MMODE ||
X		abs(mode) == VMODE && type(p) != VLIST_NODE ||
X		abs(mode) == HMODE && type(p) != HLIST_NODE) {
X		print_err("Incompatible list can't be unboxed");
X		help_pandora();
X		error();
X		return;
X	}
X	if (c == COPY_CODE)
X		link(tail) = copy_node_list(list_ptr(p));
X	else {
X		link(tail) = list_ptr(p);
X		box(cur_val) = NULL;
X		free_node(p, BOX_NODE_SIZE);
X	}
X	while (link(tail) != NULL)
X		tail = link(tail);
X}
X
Xappend_italic_correction ()
X{
X	ptr		p;
X	fnt		f;
X
X 	if (tail != head) {
X		if (is_char_node(tail))
X			p = tail;
X		else if (type(tail) == LIGATURE_NODE)
X			p = lig_char(tail);
X		else return;
X	}
X	f = font(p);
X	tail_append(new_kern(char_italic(f, char_info(f, character(p)))));
X	subtype(tail) = EXPLICIT;
X}
X
Xappend_discretionary ()
X{
X	int		c;
X
X	tail_append(new_disc());
X	if (cur_chr == 1) {
X		c = hyphen_char[cur_font];
X		if (c >= 0 && c < 256)
X			pre_break(tail) = new_character(cur_font, c);
X	} else {
X		incr(save_ptr);
X		saved(-1) = 0;
X		scan_left_brace();
X		new_save_level(DISC_GROUP);
X		push_nest();
X		mode = -HMODE;
X		space_factor = 1000;
X	}
X}
X
Xbuild_discretionary ()
X{
X	int		n;
X	ptr		p;
X	ptr		q;
X
X	unsave();
X	q = head;
X	p = link(q);
X	n = 0;
X	while (p != NULL) {
X		if (!is_char_node(p) && type(p) > RULE_NODE &&
X			type(p) != KERN_NODE && type(p) != LIGATURE_NODE) {
X			print_err("Improper discretionary list");
X			help_discretionary();
X			error();
X			begin_diagnostic();
X			print_nl("The following discretionary sublist has been deleted:");
X			show_box(p);
X			end_diagnostic(TRUE);
X			flush_node_list(p);
X			link(q) = NULL;
X			break;
X		}
X		q = p;
X		p = link(q);
X		incr(n);
X	}
X	p = link(head);
X	pop_nest();
X	switch ((int) saved(-1))
X	{
X	case 0:
X		pre_break(tail) = p;
X		break;
X
X	case 1:
X		post_break(tail) = p;
X		break;
X
X	case 2:
X		if (n > 0 && abs(mode) == MMODE) {
X			print_err("Illegal math ");
X			print_esc("discretionary");
X			help_math_disc();
X			flush_node_list(p);
X			n = 0;
X			error();
X		} else
X			link(tail) = p;
X		if (n <= MAX_QUARTERWORD)
X			replace_count(tail) = n;
X		else {
X			print_err("Discretionary list is too long");
X			help_disc();
X			error();
X		}
X		if (n > 0) tail = q;
X		decr(save_ptr);
X		return;
X	}
X	incr(saved(-1));
X	scan_left_brace();
X	new_save_level(DISC_GROUP);
X	push_nest();
X	mode = -HMODE;
X	space_factor = 1000;
X}
X
Xmake_accent ()
X{
X	scal	a;
X	fnt		f;
X	scal	h;
X	fourq	i;
X	ptr		p;
X	ptr		q;
X	ptr		r;
X	float	s;
X	float	t;
X	scal	w;
X	scal	x;
X	scal	delta;
X
X	scan_char_num();
X	f = cur_font;
X	p = new_character(f, cur_val);
X	if (p != NULL) {
X		x = x_height(f);
X		s = (float) slant(f) / 65536.0;
X		a = char_width(f, char_info(f, character(p)));
X		do_assignments();
X		q = NULL;
X		f = cur_font;
X		if (cur_cmd == LETTER ||
X			cur_cmd == OTHER_CHAR ||
X			cur_cmd ==  CHAR_GIVEN) 
X			q = new_character(f, cur_chr);
X		else if (cur_cmd ==  CHAR_NUM) {
X			scan_char_num();
X			q = new_character(f, cur_val);
X		} else back_input();
X		if (q != NULL) {
X			t = (float) slant(f) / 65536.0;
X			i = char_info(f, character(q));
X			w = char_width(f, i); 
X			h = char_height(f, height_depth(i));
X			if (h != x) {
X				p = hpack(p, NATURAL);
X				shift_amount(p) = x - h;
X			}
X			delta = round((float) (w - a) / 2.0 + h * t - x * s);
X			r = new_kern(delta);
X			subtype(r) = ACC_KERN;
X			link(tail) = r;
X			link(r) = p;
X			tail = new_kern(-a - delta);
X			subtype(tail) = ACC_KERN;
X			link(p) = tail; p = q;
X		}
X		link(tail) = p;
X		tail = p;
X		space_factor = 1000;
X	}
X}
X
Xalign_error ()
X{
X	if (abs(align_state) > 2) {
X		print_err("Misplaced ");
X		print_cmd_chr(cur_cmd, cur_chr);
X		if (cur_tok == TAB_TOKEN + '&') 
X			help_tab();
X		else help_align_error();
X		error();
X	} else {
X		back_input();
X		if (align_state < 0) {
X			print_err("Missing { inserted");
X			incr(align_state);
X			cur_tok = LEFT_BRACE_TOKEN + '{';
X		} else {
X			print_err("Missing } inserted");
X			decr(align_state);
X			cur_tok = RIGHT_BRACE_TOKEN + '}';
X		}
X		help_fix_alignment();
X		ins_error();
X	}
X}
X
Xno_align_error ()
X{
X	print_err("Misplaced ");
X	print_esc("noalign");
X	help_noalign();
X	error();
X}
X
Xomit_error ()
X{
X	print_err("Misplaced ");
X	print_esc("omit");
X	help_omit();
X	error();
X}
X
Xdo_endv ()
X{
X	if (cur_group == ALIGN_GROUP) {
X		end_graf();
X		if (fin_col())
X			fin_row();
X	} else off_save();
X}
X
Xcs_error ()
X{
X	print_err("Extra ");
X	print_esc("endcsname");
X	help_csname();
X	error();
X}
X
X/*
X *	Help text
X */
X
X
Xhelp_head_for_vmode ()
X{
X	help2("To put a horizontal rule in an hbox or an alignment,",
X	"you should use \\leaders or \\hrulefill (see The TeXbook).");
X}
X
X
Xhelp_close_group ()
X{
X	help2("You've closed more groups than you opened.",
X	"Such booboos are generally harmless, so keep going.");
X}
X
X
Xhelp_output_balance ()
X{
X	help2("Your sneaky output routine has fewer real {'s than }'s.",
X	"I can't handle that very well; good luck.");
X}
X
X
Xhelp_output ()
X{
X	help3("Your \\output commands should empty \\box255,",
X	"e.g., by saying `\\shipout\\box255'.",
X	"Proceed; I'll discard its present contents.");
X}
X
X
Xhelp_group_close ()
X{
X	help5("I've deleted a group-closing symbol because it seems to be",
X	"spurious, as in `$x}$'. But perhaps the } is legitimate and",
X	"you forgot something else, as in `\\hbox{$x}'. In such cases",
X	"the way to recover is to insert both the forgotten and the",
X	"deleted material, e.g., by typing `I$}'.");
X}
X
X
Xhelp_leaders ()
X{
X	help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
X	"I found the <box or rule>, but there's no suitable",
X	"<hskip or vskip>, so I'm ignoring these leaders.");
X}
X
X
Xhelp_lastbox_m ()
X{
X	help1("Sorry; this \\lastbox will be void.");
X}
X
X
Xhelp_lastbox_v ()
X{
X	help2("Sorry...I usually can't take things from the current page.",
X	"This \\lastbox will therefore be void.");
X}
X
X
Xhelp_vsplit ()
X{
X	help2("I'm working on `\\vsplit<box number> to <dimen>';",
X	"will look for the <dimen> next.");
X}
X
X
Xhelp_box ()
X{
X	help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
X	"something like that. So you might find something missing in",
X	"your output. But keep trying; you can fix this later.");
X}
X
X
Xhelp_insert_255 ()
X{
X	help1("I'm changing to \\insert0; box 255 is special.");
X}
X
X
Xhelp_space_fac ()
X{
X	help1("I allow only values in the range 1..65536 here.");
X}
X
X
Xhelp_delete_last ()
X{
X	help2("Sorry...I usually can't take things from the current page.",
X	"Try `I\\vskip-\\lastskip' instead.");
X}
X
X
Xhelp_pandora ()
X{
X	help3("Sorry, Pandora. (You sneaky devil.)",
X	"I refuse to unbox an \\hbox in vertical mode or vice versa.",
X	"And I can't open any boxes in math mode.");
X}
X
X
Xhelp_math_disc ()
X{
X	help2("Sorry: The third part of a discretionary break must be",
X	"empty, in math formulas. I had to delete your third part.");
X}
X
X
Xhelp_discretionary ()
X{
X	help1("Discretionary lists must contain only boxes and kerns.");
X}
X
X
Xhelp_disc ()
X{
X	help2("Wow---I never thought anybody would tweak me here.",
X	"You can't seriously need such a huge discretionary list?");
X}
X
X
Xhelp_missing_the ()
X{
X	help3("Please dont say \\count or \\dimen or \\skip in the midst of",
X	"a paragraph or formula. I'm going to assume that you",
X	"meant to say `\\the\\count' or `\\the\\dimen' or `\\the\\skip',");
X}
X
X
Xhelp_tab ()
X{
X	help6("I can't figure out why you would want to use a tab mark",
X	"here. If you want an ampersand, the remedy is",
X	"simple: Just type `I\\&' now. But if some right brace",
X	"up above has ended a previous alignment prematurely,",
X	"you're probably due for more error messages, and you",
X	"might try typing `S' now just to see what is salvageable.");
SHAR_EOF
echo "End of part 3"
echo "File boxlists.c is continued in part 4"
echo "4" > s2_seq_.tmp
exit 0



More information about the Comp.unix.xenix mailing list