#define EXTERN extern
-#include "texd.h"
+#include "yandytex.h"
/* sec 0715 */
-halfword rebox_(halfword b, scaled w)
+pointer rebox (pointer b, scaled w)
{
- halfword p;
+ pointer p;
internal_font_number f;
scaled v;
p = list_ptr(b);
- if (((p >= hi_mem_min)) && (link(p) == 0))
+ if ((is_char_node(p)) && (link(p) == 0))
{
f = font(p);
v = char_width(f, char_info(f, character(p)));
return b;
}
}
-/* This is to be the start of tex5.c */
/* sec 0716 */
-halfword math_glue_(halfword g, scaled m)
+pointer math_glue (pointer g, scaled m)
{
- halfword p;
+ pointer p;
integer n;
scaled f;
}
p = get_node(glue_spec_size);
- width(p) = mult_and_add(n, width(g), xn_over_d(width(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
+ width(p) = mu_mult(width(g));
stretch_order(p) = stretch_order(g);
if (stretch_order(p) == normal)
- stretch(p) = mult_and_add(n, stretch(g), xn_over_d(stretch(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
+ stretch(p) = mu_mult(stretch(g));
else
stretch(p) = stretch(g);
shrink_order(p) = shrink_order(g);
if (shrink_order(p) == normal)
- shrink(p) = mult_and_add(n, shrink(g), xn_over_d(shrink(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
+ shrink(p) = mu_mult(shrink(g));
else
shrink(p) = shrink(g);
return p;
}
/* sec 0717 */
-void math_kern_ (halfword p, scaled m)
+void math_kern (pointer p, scaled m)
{
integer n;
scaled f;
f = f + 65536L;
}
- width(p) = mult_and_add(n, width(p), xn_over_d(width(p), f, 65536L), 1073741823L); /* 2^30 - 1 */
+ width(p) = mu_mult(width(p));
subtype(p) = explicit;
}
}
incompleat_noad = 0;
}
/* sec 0720 */
-halfword clean_box_(halfword p, small_number s)
+pointer clean_box (pointer p, small_number s)
{
- halfword q;
+ pointer q;
small_number save_style;
- halfword x;
- halfword r;
+ pointer x;
+ pointer r;
- switch(math_type(p))
+ switch (math_type(p))
{
case math_char:
{
case sub_box:
{
q = info(p);
- goto lab40;
+ goto found;
}
break;
default:
{
q = new_null_box();
- goto lab40;
+ goto found;
}
break;
}
cur_mu = x_over_n(math_quad(cur_size), 18);
}
-lab40:
- if ((q >= hi_mem_min) || (q == 0))
+
+found:
+ if (is_char_node(q) || (q == 0))
x = hpack(q, 0, 1);
else if ((link(q) == 0) && (type(q) <= vlist_node) && (shift_amount(q) == 0))
x = q;
q = list_ptr(x);
- if ((q >= hi_mem_min))
+ if (is_char_node(q))
{
r = link(q);
if (r != 0)
if (link(r) == 0)
- if (!(r >= hi_mem_min))
+ if (!is_char_node(r))
if (type(r) == kern_node)
{
free_node(r, small_node_size);
return x;
}
/* sec 0722 */
-void fetch_(halfword a)
+void fetch_(pointer a)
{
cur_c = character(a);
cur_f = fam_fnt(fam(a) + cur_size);
print_size(cur_size);
print_char(' ');
print_int(fam(a));
- print_string(" is undefined (character ");
+ prints(" is undefined (character ");
print(cur_c);
print_char(')');
help4("Somewhere in the math formula just ended, you used the",
else
cur_i = null_character;
- if (!((cur_i.b0 > 0)))
+ if (!char_exists(cur_i))
{
char_warning(cur_f, cur_c);
math_type(a) = 0;
}
}
/* sec 0734 */
-void make_over_(halfword q)
+void make_over (pointer q)
{
info(nucleus(q)) = overbar(clean_box(nucleus(q), 2 * (cur_style / 2) + 1),
3 * default_rule_thickness, default_rule_thickness);
math_type(nucleus(q)) = sub_box;
}
/* sec 0735 */
-void make_under_(halfword q)
+void make_under (pointer q)
{
- halfword p, x, y;
+ pointer p, x, y;
scaled delta;
x = clean_box(nucleus(q), cur_style);
p = new_kern(3 * default_rule_thickness);
link(x) = p;
link(p) = fraction_rule(default_rule_thickness);
- y = vpackage(x, 0, 1, 1073741823L); /* 2^30 - 1 */
+ y = vpackage(x, 0, 1, max_dimen);
delta = height(y) + depth(y) + default_rule_thickness;
height(y) = height(x);
depth(y) = delta - height(y);
math_type(nucleus(q)) = sub_box;
}
/* sec 0736 */
-void make_vcenter_(halfword q)
+void make_vcenter (pointer q)
{
- halfword v;
+ pointer v;
scaled delta;
v = info(nucleus(q));
if (type(v) != vlist_node)
{
confusion("vcenter");
- return; // abort_flag set
+ return;
}
delta = height(v) + depth(v);
depth(v) = delta - height(v);
}
/* sec 0737 */
-void make_radical_(halfword q)
+void make_radical (pointer q)
{
- halfword x, y;
+ pointer x, y;
scaled delta, clr;
x = clean_box(nucleus(q), 2 * (cur_style / 2) + 1);
math_type(nucleus(q)) = sub_box;
}
/* sec 0738 */
-void make_math_accent_(halfword q)
+void make_math_accent (pointer q)
{
- halfword p, x, y;
+ pointer p, x, y;
integer a;
quarterword c;
internal_font_number f;
fetch(accent_chr(q));
- if ((cur_i.b0 > 0))
+ if (char_exists(cur_i))
{
i = cur_i;
c = cur_c;
if (op_byte(cur_i) >= kern_flag)
if (skip_byte(cur_i) <= stop_flag)
s = char_kern(cur_f, cur_i);
- goto lab31;
+
+ goto done1;
}
if (skip_byte(cur_i) >= stop_flag)
- goto lab31;
+ goto done1;
a = a + skip_byte(cur_i) + 1;
cur_i = font_info[a].qqqq;
}
}
}
-lab31:;
+
+done1:
x = clean_box(nucleus(q), cramped_style(cur_style));
w = width(x);
h = height(x);
while (true)
{
if (char_tag(i) != list_tag)
- goto lab30;
+ goto done;
y = rem_byte(i);
i = char_info(f, y);
- if (!(i.b0 > 0))
- goto lab30;
+ if (!char_exists(i))
+ goto done;
if (char_width(f, i) > w)
- goto lab30;
+ goto done;
c = y;
}
-lab30:;
+
+done:
if (h < x_height(f))
delta = h;
else
{
flush_node_list(x);
x = new_noad();
- mem[nucleus(x)]= mem[nucleus(q)];
- mem[supscr(x)]= mem[supscr(q)];
- mem[subscr(x)]= mem[subscr(q)];
+ mem[nucleus(x)] = mem[nucleus(q)];
+ mem[supscr(x)] = mem[supscr(q)];
+ mem[subscr(x)] = mem[subscr(q)];
mem[supscr(q)].hh = empty_field;
mem[subscr(q)].hh = empty_field;
math_type(nucleus(q)) = sub_mlist;
y = char_box(f, c);
shift_amount(y) = s + half(w - width(y));
width(y) = 0;
- p = new_kern(- (integer) delta);
+ p = new_kern(-(integer) delta);
link(p) = x;
link(y) = p;
- y = vpackage(y, 0, 1, 1073741823L); /* 2^30 - 1 */
+ y = vpackage(y, 0, 1, max_dimen);
width(y) = width(x);
if (height(y) < h)
}
}
/* sec 0743 */
-void make_fraction_(halfword q)
+void make_fraction (pointer q)
{
- halfword p, v, x, y, z;
+ pointer p, v, x, y, z;
scaled delta, delta1, delta2, shift_up, shift_down, clr;
- if (thickness(q) == default_code) /* 2^30 */
+ if (thickness(q) == default_code)
thickness(q) = default_rule_thickness;
x = clean_box(numerator(q), num_style(cur_style));
delta = half(thickness(q));
delta1 = clr - ((shift_up - depth(x)) - (axis_height(cur_size) + delta));
- delta2 = clr -((axis_height(cur_size) - delta) - (height(z) - shift_down));
+ delta2 = clr - ((axis_height(cur_size) - delta) - (height(z) - shift_down));
if (delta1 > 0)
shift_up = shift_up + delta1;
link(v) = z;
new_hlist(q) = hpack(x, 0, 1);
}
-/***************************************************************************/
-scaled make_op_ (halfword);
-/***************************************************************************/
/* sec 0752 */
-void make_ord_(halfword q)
+void make_ord (pointer q)
{
integer a;
- halfword p, r;
+ pointer p, r;
-lab20:
+restart:
if (math_type(subscr(q)) == 0)
if (math_type(supscr(q)) == 0)
if (math_type(nucleus(q)) == math_char)
}
else
{
- {
- if (interrupt != 0)
- {
- pause_for_instructions();
- }
- }
+ check_interrupt();
switch (op_byte(cur_i))
{
return;
math_type(nucleus(q)) = math_char;
- goto lab20;
+ goto restart;
}
if (skip_byte(cur_i) >= stop_flag)
}
}
}
-/***************************************************************************/
-void make_scripts_ (halfword, scaled);
-/***************************************************************************/
/* sec 0762 */
-small_number make_left_right_(halfword q, small_number style, scaled max_d, scaled max_h)
+small_number make_left_right (pointer q, small_number style, scaled max_d, scaled max_h)
{
scaled delta, delta1, delta2;
delta = delta2;
new_hlist(q) = var_delimiter(delimiter(q), cur_size, delta);
+
return type(q) - (left_noad - open_noad);
}
/* sec 0726 */
void mlist_to_hlist (void)
{
- halfword mlist;
+ pointer mlist;
boolean penalties;
small_number style;
small_number save_style;
- halfword q;
- halfword r;
-/* small_number r_type; */
- int r_type; /* 95/Jan/7 */
-/* small_number t; */
- int t; /* 95/Jan/7 */
- halfword p, x, y, z;
+ pointer q;
+ pointer r;
+ /* small_number r_type; */
+ int r_type;
+ /* small_number t; */
+ int t;
+ pointer p, x, y, z;
integer pen;
small_number s;
scaled max_h, max_d;
while (q != 0)
{
-lab21:
+reswitch:
delta = 0;
switch (type(q))
case left_noad:
{
type(q) = ord_noad;
- goto lab21;
+ goto reswitch;
}
break;
default:
- ;
+ do_nothing();
break;
}
break;
type(r) = ord_noad;
if (type(q) == right_noad)
- goto lab80;
+ goto done_with_noad;
}
break;
case left_noad:
- goto lab80;
+ goto done_with_noad;
break;
case fraction_noad:
{
make_fraction(q);
- goto lab82;
+ goto check_dimensions;
}
break;
delta = make_op(q);
if (subtype(q) == limits)
- goto lab82;
+ goto check_dimensions;
}
break;
case open_noad:
case inner_noad:
- ;
+ do_nothing();
break;
case radical_noad:
cur_mu = x_over_n(math_quad(cur_size), 18);
}
- goto lab81;
+ goto done_with_node;
}
break;
switch (cur_style / 2)
{
case 0:
- {
- p = display_mlist(q);
- display_mlist(q) = 0;
- }
+ choose_mlist(display_mlist);
break;
case 1:
- {
- p = text_mlist(q);
- text_mlist(q) = 0;
- }
+ choose_mlist(text_mlist);
break;
case 2:
- {
- p = script_mlist(q);
- script_mlist(q) = 0;
- }
+ choose_mlist(script_mlist);
break;
case 3:
- {
- p = script_script_mlist(q);
- script_script_mlist(q) = 0;
- }
+ choose_mlist(script_script_mlist);
break;
}
link(p) = z;
}
- goto lab81;
+
+ goto done_with_node;
}
break;
case whatsit_node:
case penalty_node:
case disc_node:
- goto lab81;
+ goto done_with_node;
break;
case rule_node:
if (depth(q) > max_d)
max_d = depth(q);
- goto lab81;
+ goto done_with_node;
}
break;
flush_node_list(p);
}
}
- goto lab81;
+
+ goto done_with_node;
}
break;
case kern_node:
{
math_kern(q, cur_mu);
- goto lab81;
+ goto done_with_node;
}
break;
default:
{
confusion("mlist1");
- return; // abort_flag set
+ return;
}
break;
}
{
fetch(nucleus(q));
- if ((cur_i.b0 > 0))
+ if (char_exists(cur_i))
{
delta = char_italic(cur_f, cur_i);
p = new_character(cur_f, cur_c);
default:
{
confusion("mlist2");
- return; // abort_flag set
+ return;
}
break;
}
new_hlist(q) = p;
if ((math_type(subscr(q)) == 0) && (math_type(supscr(q)) == 0))
- goto lab82;
+ goto check_dimensions;
make_scripts(q, delta);
-lab82:
+
+check_dimensions:
z = hpack(new_hlist(q), 0, 1);
if (height(z) > max_h)
max_d = depth(z);
free_node(z, box_node_size);
-lab80:
+
+done_with_noad:
r = q;
r_type = type(r);
-lab81:
+
+done_with_node:
q = link(q);
}
case vcenter_noad:
case over_noad:
case under_noad:
- ;
+ do_nothing();
break;
case radical_noad:
cur_mu = x_over_n(math_quad(cur_size), 18);
}
- goto lab83;
+ goto delete_q;
}
break;
p = q;
q = link(q);
link(p) = 0;
- goto lab30;
+ goto done;
}
break;
default:
{
confusion("mlist3");
- return; // abort_flag set
+ return;
}
break;
}
default:
{
confusion("mlist4");
- return; // abort_flag set
+ return;
}
break;
}
}
r_type = t;
-lab83:
+
+delete_q:
r = q;
q = link(q);
free_node(r, s);
-lab30:;
+done:;
}
}
/* sec 0772 */
void push_alignment (void)
{
- halfword p;
+ pointer p;
p = get_node(align_stack_node_size);
link(p) = align_ptr;
/* sec 0772 */
void pop_alignment (void)
{
- halfword p;
+ pointer p;
free_avail(cur_head);
p = align_ptr;
/* sec 0782 */
void get_preamble_token (void)
{
-lab20:
+restart:
get_token();
while ((cur_chr == span_code) && (cur_cmd == tab_mark))
if (cur_cmd == endv)
{
fatal_error("(interwoven alignment preambles are not allowed)");
- return; // abort_flag set
+ return;
}
if ((cur_cmd == assign_glue) && (cur_chr == glue_base + tab_skip_code))
else
eq_define(glue_base + tab_skip_code, glue_ref, cur_val);
- goto lab20;
+ goto restart;
}
}
/* sec 0774 */
void init_align (void)
{
- halfword save_cs_ptr;
- halfword p;
+ pointer save_cs_ptr;
+ pointer p;
save_cs_ptr = cur_cs;
push_alignment();
align_state = -1000000L;
- if ((mode == mmode) && ((tail != cur_list.head_field) || (incompleat_noad != 0)))
+ if ((mode == mmode) && ((tail != head) || (incompleat_noad != 0)))
{
print_err("Improper ");
print_esc("halign");
- print_string(" inside $$'s");
+ prints(" inside $$'s");
help3("Displays can use special alignments (like \\eqalignno)",
"only if nothing but the alignment itself is between $$'s.",
"So I've deleted the formulas that preceded this alignment.");
cur_align = link(cur_align);
if (cur_cmd == car_ret)
- goto lab30;
+ goto done;
p = hold_head;
link(p) = 0;
get_preamble_token();
if (cur_cmd == mac_param)
- goto lab31;
+ goto done1;
if ((cur_cmd <= car_ret) && (cur_cmd >= tab_mark) && (align_state == -1000000L))
if ((p == hold_head) && (cur_loop == 0) && (cur_cmd == tab_mark))
"\\halign or \\valign is being set up. In this case you had",
"none, so I've put one in; maybe that will work.");
back_error();
- goto lab31;
+ goto done1;
}
else if ((cur_cmd != spacer) || (p != hold_head))
{
}
}
-lab31:
+done1:
link(cur_align) = new_null_box();
cur_align = link(cur_align);
info(cur_align) = end_span;
- width(cur_align) = null_flag; /* - 2^30 */
+ width(cur_align) = null_flag;
u_part(cur_align) = link(hold_head);
p = hold_head;
link(p) = 0;
while (true)
{
-lab22:
+continu:
get_preamble_token();
if ((cur_cmd <= car_ret) && (cur_cmd >= tab_mark) && (align_state == -1000000L))
- goto lab32;
+ goto done2;
if (cur_cmd == mac_param)
{
"\\halign or \\valign is being set up. In this case you had",
"more than one, so I'm ignoring all but the first.");
error();
- goto lab22;
+ goto continu;
}
link(p) = get_avail();
info(p) = cur_tok;
}
-lab32:
+done2:
link(p) = get_avail();
p = link(p);
info(p) = end_template_token;
v_part(cur_align) = link(hold_head);
}
-lab30:
+done:
scanner_status = 0;
new_save_level(align_group);
if (every_cr != 0)
begin_token_list(every_cr, every_cr_text);
+
align_peek();
}
/* sec 0787 */
-void init_span_ (halfword p)
+void init_span (pointer p)
{
push_nest();
space_factor = 1000;
else
{
- cur_list.aux_field.cint = ignore_depth;
+ prev_depth = ignore_depth;
normal_paragraph();
}
if (mode == -hmode)
space_factor = 0;
else
- cur_list.aux_field.cint = 0;
+ prev_depth = 0;
tail_append(new_glue(glue_ptr(preamble)));
subtype(tail) = tab_skip_code + 1;
/* sec 0799 */
void fin_row (void)
{
- halfword p;
+ pointer p;
if (mode == -hmode)
{
}
else
{
- p = vpackage(link(head), 0, 1, 1073741823L); /* 2^30 - 1 */
+ p = vpackage(link(head), 0, 1, max_dimen);
pop_nest();
link(tail) = p;
tail = p;
/* sec 0800 */
void fin_align (void)
{
- halfword p, q, r, s, u, v;
+ pointer p, q, r, s, u, v;
scaled t, w;
scaled o;
halfword n;
if (cur_group != align_group)
{
confusion("align1");
- return; // abort_flag set
+ return;
}
unsave();
if (cur_group != align_group)
{
confusion("align0");
- return; // abort_flag set
+ return;
}
unsave();
flush_list(v_part(q));
p = link(link(q));
- if (width(q) == null_flag) /* - 2^30 */
+ if (width(q) == null_flag)
{
width(q) = 0;
r = link(q);
}
while (!(q == 0));
- p = vpackage(preamble, saved(1), saved(0), 1073741823L); /* 2^30 - 1 */
+ p = vpackage(preamble, saved(1), saved(0), max_dimen);
q = link(preamble);
do
while (q != 0)
{
- if (!(q >= hi_mem_min))
+ if (!is_char_node(q))
if (type(q) == unset_node)
{
if (mode == -vmode)
r = link(link(r));
s = link(link(s));
}
- while(!(r == 0));
+ while (!(r == 0));
}
else if (type(q) == rule_node)
{
- if ((width(q) == -1073741824L)) /* 2^30 */
+ if (is_running(width(q)))
width(q) = width(p);
- if ((height(q) == -1073741824L)) /* 2^30 */
+ if (is_running(height(q)))
height(q) = height(p);
- if ((depth(q) == -1073741824L)) /* 2^30 */
+ if (is_running(depth(q)))
depth(q) = depth(p);
if (o != 0)
tail_append(new_penalty(post_display_penalty));
tail_append(new_param_glue(below_display_skip_code));
- cur_list.aux_field.cint = aux_save.cint;
+ prev_depth = aux_save.cint;
resume_after_display();
}
else
tail = q;
if (mode == vmode)
- {
build_page();
- }
}
}
-/* used to be align_peek, zfintieshrink, etc in old tex5.c */
-/************************************************************************/
-/* moved down here to avoid questions about pragma optimize */
-/* #pragma optimize("g", off) */
-/* for MC VS compiler */
-/* Moved down here 96/Oct/12 in response to problem with texerror.tex */
-/* pragma optimize("a", off) not strong enough - this may slow things */
/* sec 0791 */
boolean fin_col (void)
{
- halfword p;
- halfword q, r;
- halfword s;
- halfword u;
+ pointer p;
+ pointer q, r;
+ pointer s;
+ pointer u;
scaled w;
glue_ord o;
halfword n;
if (cur_align == 0)
{
confusion("endv");
- return 0; // abort_flag set
+ return 0;
}
q = link(cur_align);
if (q == 0)
{
confusion("endv");
- return 0; // abort_flag set
+ return 0;
}
if (align_state < 500000L)
{
fatal_error("(interwoven alignment preambles are not allowed)");
- return 0; // abort_flag set
+ return 0;
}
p = link(q);
if ((p == 0) && (extra_info(cur_align) < cr_code))
if (cur_loop != 0)
{
-/* potential problem here if new_null_box causes memory reallocation ??? */
-/* compiler optimization does not refresh `mem' loaded in registers ? */
link(q) = new_null_box();
p = link(q);
info(p) = end_span;
if (extra_info(cur_align) != span_code)
{
unsave();
-
new_save_level(align_group);
{
if (n > max_quarterword)
{
- confusion("256 spans"); /* 256 spans --- message wrong now, but ... */
- return 0; // abort_flag set
+ confusion("256 spans");
+ return 0;
}
q = cur_span;
return false;
}
/* sec 0749 */
-scaled make_op_(halfword q)
+scaled make_op (pointer q)
{
scaled delta;
- halfword p, v, x, y, z;
+ pointer p, v, x, y, z;
quarterword c;
four_quarters i;
scaled shift_up, shift_down;
c = rem_byte(cur_i);
i = char_info(cur_f, c);
- if ((i.b0 > 0))
+ if (char_exists(i))
{
cur_c = c;
cur_i = i;
return delta;
}
/* sec 0756 */
-void make_scripts_(halfword q, scaled delta)
+void make_scripts (pointer q, scaled delta)
{
- halfword p, x, y, z;
+ pointer p, x, y, z;
scaled shift_up, shift_down, clr;
small_number t;
p = new_hlist(q);
- if ((p >= hi_mem_min))
+ if (is_char_node(p))
{
shift_up = 0;
shift_down = 0;
p = new_kern((shift_up - depth(x)) - (height(y) - shift_down));
link(x) = p;
link(p) = y;
- x = vpackage(x, 0, 1, 1073741823L); /* 2^30 - 1 */
+ x = vpackage(x, 0, 1, max_dimen);
shift_amount(x) = shift_down;
}
}