6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
11 #pragma warning(disable:4131) // old style declarator
12 #pragma warning(disable:4135) // conversion between different integral types
13 #pragma warning(disable:4127) // conditional expression is constant
21 #pragma warning(disable:4244) /* 96/Jan/10 */
23 /* rebox_ used to be in tex4.c */
25 halfword rebox_(halfword b, scaled w)
28 internal_font_number f;
31 if ((width(b) != w) && (list_ptr(b) != 0))
33 if (type(b) == vlist_node)
38 if (((p >= hi_mem_min)) && (link(p) == 0))
41 v = char_width(f, char_info(f, character(p)));
44 link(p) = new_kern(width(b) - v);
47 free_node(b, box_node_size);
48 b = new_glue(ss_glue);
54 link(p) = new_glue(ss_glue);
55 return hpack(b, w, exactly);
63 /* This is to be the start of tex5.c */
65 halfword math_glue_(halfword g, scaled m)
71 n = x_over_n(m, 65536L);
80 p = get_node(glue_spec_size);
81 width(p) = mult_and_add(n, width(g), xn_over_d(width(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
82 stretch_order(p) = stretch_order(g);
84 if (stretch_order(p) == normal)
85 stretch(p) = mult_and_add(n, stretch(g), xn_over_d(stretch(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
87 stretch(p) = stretch(g);
89 shrink_order(p) = shrink_order(g);
91 if (shrink_order(p) == normal)
92 shrink(p) = mult_and_add(n, shrink(g), xn_over_d(shrink(g), f, 65536L), 1073741823L); /* 2^30 - 1 */
94 shrink(p) = shrink(g);
99 void math_kern_ (halfword p, scaled m)
104 if (subtype(p) == mu_glue)
106 n = x_over_n(m, 65536L);
115 width(p) = mult_and_add(n, width(p), xn_over_d(width(p), f, 65536L), 1073741823L); /* 2^30 - 1 */
116 subtype(p) = explicit;
120 void flush_math (void)
122 flush_node_list(link(head));
123 flush_node_list(incompleat_noad);
129 halfword clean_box_(halfword p, small_number s)
132 small_number save_style;
140 cur_mlist = new_noad();
141 mem[nucleus(cur_mlist)] = mem[p];
164 save_style = cur_style;
166 mlist_penalties = false;
169 cur_style = save_style;
172 if (cur_style < script_style)
173 cur_size = text_size;
175 cur_size = 16 * ((cur_style - text_style) / 2);
177 cur_mu = x_over_n(math_quad(cur_size), 18);
180 if ((q >= hi_mem_min) || (q == 0))
182 else if ((link(q) == 0) && (type(q) <= vlist_node) && (shift_amount(q) == 0))
189 if ((q >= hi_mem_min))
195 if (!(r >= hi_mem_min))
196 if (type(r) == kern_node)
198 free_node(r, small_node_size);
206 void fetch_(halfword a)
208 cur_c = character(a);
209 cur_f = fam_fnt(fam(a) + cur_size);
211 if (cur_f == null_font)
214 print_size(cur_size);
217 print_string(" is undefined (character ");
220 help4("Somewhere in the math formula just ended, you used the",
221 "stated character from an undefined font family. For example,",
222 "plain TeX doesn't allow \\it or \\sl in subscripts. Proceed,",
223 "and I'll try to forget that I needed that character.");
225 cur_i = null_character;
230 if ((cur_c >= font_bc[cur_f]) && (cur_c <= font_ec[cur_f]))
231 cur_i = char_info(cur_f, cur_c);
233 cur_i = null_character;
235 if (!((cur_i.b0 > 0)))
237 char_warning(cur_f, cur_c);
243 void make_over_(halfword q)
245 info(nucleus(q)) = overbar(clean_box(nucleus(q), 2 * (cur_style / 2) + 1),
246 3 * default_rule_thickness, default_rule_thickness);
247 math_type(nucleus(q)) = sub_box;
250 void make_under_(halfword q)
255 x = clean_box(nucleus(q), cur_style);
256 p = new_kern(3 * default_rule_thickness);
258 link(p) = fraction_rule(default_rule_thickness);
259 y = vpackage(x, 0, 1, 1073741823L); /* 2^30 - 1 */
260 delta = height(y) + depth(y) + default_rule_thickness;
261 height(y) = height(x);
262 depth(y) = delta - height(y);
263 info(nucleus(q)) = y;
264 math_type(nucleus(q)) = sub_box;
267 void make_vcenter_(halfword q)
272 v = info(nucleus(q));
274 if (type(v) != vlist_node)
276 confusion("vcenter");
277 return; // abort_flag set
279 delta = height(v) + depth(v);
280 height(v) = axis_height(cur_size) + half(delta);
281 depth(v) = delta - height(v);
284 void make_radical_(halfword q)
289 x = clean_box(nucleus(q), 2 * (cur_style / 2) + 1);
291 if (cur_style < text_style)
292 clr = default_rule_thickness + (abs(math_x_height(cur_size)) / 4);
295 clr = default_rule_thickness;
296 clr = clr + (abs(clr) / 4);
299 y = var_delimiter(left_delimiter(q), cur_size, height(x) + depth(x) + clr + default_rule_thickness);
300 delta = depth(y) -(height(x) + depth(x) + clr);
303 clr = clr + half(delta);
305 shift_amount(y) = - (integer) (height(x) + clr);
306 link(y) = overbar(x, clr, height(y));
307 info(nucleus(q)) = hpack(y, 0, 1);
308 math_type(nucleus(q)) = sub_box;
311 void make_math_accent_(halfword q)
316 internal_font_number f;
323 fetch(accent_chr(q));
332 if (math_type(nucleus(q)) == math_char)
336 if (char_tag(cur_i) == lig_tag)
338 a = lig_kern_start(cur_f, cur_i);
339 cur_i = font_info[a].qqqq;
341 if (skip_byte(cur_i) > stop_flag)
343 a = lig_kern_restart(cur_f, cur_i);
344 cur_i = font_info[a].qqqq;
349 if (next_char(cur_i) == skew_char[cur_f])
351 if (op_byte(cur_i) >= kern_flag)
352 if (skip_byte(cur_i) <= stop_flag)
353 s = char_kern(cur_f, cur_i);
357 if (skip_byte(cur_i) >= stop_flag)
360 a = a + skip_byte(cur_i) + 1;
361 cur_i = font_info[a].qqqq;
366 x = clean_box(nucleus(q), cramped_style(cur_style));
372 if (char_tag(i) != list_tag)
381 if (char_width(f, i) > w)
392 if ((math_type(supscr(q)) != 0) || (math_type(subscr(q)) != 0))
393 if (math_type(nucleus(q)) == math_char)
397 mem[nucleus(x)]= mem[nucleus(q)];
398 mem[supscr(x)]= mem[supscr(q)];
399 mem[subscr(x)]= mem[subscr(q)];
400 mem[supscr(q)].hh = empty_field;
401 mem[subscr(q)].hh = empty_field;
402 math_type(nucleus(q)) = sub_mlist;
403 info(nucleus(q)) = x;
404 x = clean_box(nucleus(q), cur_style);
405 delta = delta + height(x) - h;
410 shift_amount(y) = s + half(w - width(y));
412 p = new_kern(- (integer) delta);
415 y = vpackage(y, 0, 1, 1073741823L); /* 2^30 - 1 */
420 p = new_kern(h - height(y));
421 link(p) = list_ptr(y);
426 info(nucleus(q)) = y;
427 math_type(nucleus(q)) = sub_box;
431 void make_fraction_(halfword q)
433 halfword p, v, x, y, z;
434 scaled delta, delta1, delta2, shift_up, shift_down, clr;
436 if (thickness(q) == default_code) /* 2^30 */
437 thickness(q) = default_rule_thickness;
439 x = clean_box(numerator(q), num_style(cur_style));
440 z = clean_box(denominator(q), denom_style(cur_style));
442 if (width(x) < width(z))
443 x = rebox(x, width(z));
445 z = rebox(z, width(x));
447 if (cur_style < text_style)
449 shift_up = num1(cur_size);
450 shift_down = denom1(cur_size);
454 shift_down = denom2(cur_size);
456 if (thickness(q) != 0)
457 shift_up = num2(cur_size);
459 shift_up = num3(cur_size);
462 if (thickness(q) == 0)
464 if (cur_style < text_style)
465 clr = 7 * default_rule_thickness;
467 clr = 3 * default_rule_thickness;
469 delta = half(clr - ((shift_up - depth(x)) - (height(z) - shift_down)));
473 shift_up = shift_up + delta;
474 shift_down = shift_down + delta;
479 if (cur_style < text_style)
480 clr = 3 * thickness(q);
484 delta = half(thickness(q));
485 delta1 = clr - ((shift_up - depth(x)) - (axis_height(cur_size) + delta));
486 delta2 = clr -((axis_height(cur_size) - delta) - (height(z) - shift_down));
489 shift_up = shift_up + delta1;
492 shift_down = shift_down + delta2;
496 type(v) = vlist_node;
497 height(v) = shift_up + height(x);
498 depth(v) = depth(z) + shift_down;
501 if (thickness(q) == 0)
503 p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
508 y = fraction_rule(thickness(q));
509 p = new_kern((axis_height(cur_size) - delta) - (height(z) - shift_down));
512 p = new_kern((shift_up - depth(x)) - (axis_height(cur_size) + delta));
519 if (cur_style < text_style)
520 delta = delim1(cur_size);
522 delta = delim2(cur_size);
524 x = var_delimiter(left_delimiter(q), cur_size, delta);
526 z = var_delimiter(right_delimiter(q), cur_size, delta);
528 new_hlist(q) = hpack(x, 0, 1);
530 /***************************************************************************/
531 /* moved to end to avoid questions about pragma optimize 96/Sep/12 */
532 scaled make_op_ (halfword);
533 /***************************************************************************/
535 void make_ord_(halfword q)
541 if (math_type(subscr(q)) == 0)
542 if (math_type(supscr(q)) == 0)
543 if (math_type(nucleus(q)) == math_char)
548 if ((type(p) >= ord_noad) && (type(p) <= punct_noad))
549 if (math_type(nucleus(p)) == math_char)
550 if (fam(nucleus(p)) == fam(nucleus(q)))
552 math_type(nucleus(q)) = math_text_char;
555 if (char_tag(cur_i) == lig_tag)
557 a = lig_kern_start(cur_f, cur_i);
558 cur_c = character(nucleus(p));
559 cur_i = font_info[a].qqqq;
561 if (skip_byte(cur_i) > stop_flag)
563 a = lig_kern_restart(cur_f, cur_i);
564 cur_i = font_info[a].qqqq;
569 if (next_char(cur_i) == cur_c)
570 if (skip_byte(cur_i) <= stop_flag)
571 if (op_byte(cur_i) >= kern_flag)
573 p = new_kern(char_kern(cur_f, cur_i));
583 pause_for_instructions();
587 switch (op_byte(cur_i))
591 character(nucleus(q)) = rem_byte(cur_i);
595 character(nucleus(p)) = rem_byte(cur_i);
602 character(nucleus(r)) = rem_byte(cur_i);
603 fam(nucleus(r)) = fam(nucleus(q));
607 if (op_byte(cur_i) < 11)
608 math_type(nucleus(r)) = math_char;
610 math_type(nucleus(r)) = math_text_char;
617 character(nucleus(q)) = rem_byte(cur_i);
618 mem[subscr(q)] = mem[subscr(p)];
619 mem[supscr(q)] = mem[supscr(p)];
620 free_node(p, noad_size);
625 if (op_byte(cur_i) > 3)
628 math_type(nucleus(q)) = math_char;
632 if (skip_byte(cur_i) >= stop_flag)
635 a = a + skip_byte(cur_i) + 1;
636 cur_i = font_info[a].qqqq;
642 /***************************************************************************/
643 /* moved to end to avoid questions about pragma optimize 96/Sep/12 */
644 void make_scripts_ (halfword, scaled);
645 /***************************************************************************/
647 small_number make_left_right_(halfword q, small_number style, scaled max_d, scaled max_h)
649 scaled delta, delta1, delta2;
651 if (style < script_style)
652 cur_size = text_size;
654 cur_size = 16 * ((style - text_style) / 2);
656 delta2 = max_d + axis_height(cur_size);
657 delta1 = max_h + max_d - delta2;
662 delta = (delta1 / 500) * delimiter_factor;
663 delta2 = delta1 + delta1 - delimiter_shortfall;
668 new_hlist(q) = var_delimiter(delimiter(q), cur_size, delta);
669 return type(q) - (left_noad - open_noad);
672 void mlist_to_hlist (void)
677 small_number save_style;
680 /* small_number r_type; */
681 int r_type; /* 95/Jan/7 */
682 /* small_number t; */
683 int t; /* 95/Jan/7 */
691 penalties = mlist_penalties;
700 if (cur_style < script_style)
701 cur_size = text_size;
703 cur_size = 16 * ((cur_style - text_style) / 2);
705 cur_mu = x_over_n(math_quad(cur_size), 18);
741 if (r_type == bin_noad)
744 if (type(q) == right_noad)
764 if (subtype(q) == limits)
800 cur_style = subtype(q);
803 if (cur_style < script_style)
804 cur_size = text_size;
806 cur_size = 16 * ((cur_style - text_style) / 2);
808 cur_mu = x_over_n(math_quad(cur_size), 18);
817 switch (cur_style / 2)
821 p = display_mlist(q);
822 display_mlist(q) = 0;
842 p = script_script_mlist(q);
843 script_script_mlist(q) = 0;
848 flush_node_list(display_mlist(q));
849 flush_node_list(text_mlist(q));
850 flush_node_list(script_mlist(q));
851 flush_node_list(script_script_mlist(q));
852 type(q) = style_node;
853 subtype(q) = cur_style;
882 if (height(q) > max_h)
885 if (depth(q) > max_d)
894 if (subtype(q) == mu_glue)
897 y = math_glue(x, cur_mu);
902 else if ((cur_size != text_size) && (subtype(q) == cond_math_glue))
907 if ((type(q) == glue_node) || (type(p) == kern_node))
920 math_kern(q, cur_mu);
928 return; // abort_flag set
933 switch (math_type(nucleus(q)))
942 delta = char_italic(cur_f, cur_i);
943 p = new_character(cur_f, cur_c);
945 if ((math_type(nucleus(q)) == math_text_char) && (space(cur_f) != 0))
948 if ((math_type(subscr(q)) == 0) && (delta != 0))
950 link(p) = new_kern(delta);
964 p = info(nucleus(q));
969 cur_mlist = info(nucleus(q));
970 save_style = cur_style;
971 mlist_penalties = false;
973 cur_style = save_style;
976 if (cur_style < script_style)
977 cur_size = text_size;
979 cur_size = 16 * ((cur_style - text_style) / 2);
981 cur_mu = x_over_n(math_quad(cur_size), 18);
984 p = hpack(link(temp_head), 0, 1);
991 return; // abort_flag set
998 if ((math_type(subscr(q)) == 0) && (math_type(supscr(q)) == 0))
1001 make_scripts(q, delta);
1003 z = hpack(new_hlist(q), 0, 1);
1005 if (height(z) > max_h)
1008 if (depth(z) > max_d)
1011 free_node(z, box_node_size);
1019 if (r_type == bin_noad)
1029 if (cur_style < script_style)
1030 cur_size = text_size;
1032 cur_size = 16 *((cur_style - text_style) / 2);
1034 cur_mu = x_over_n(math_quad(cur_size), 18);
1056 pen = bin_op_penalty;
1075 s = radical_noad_size;
1079 s = accent_noad_size;
1085 s = fraction_noad_size;
1091 t = make_left_right(q, style, max_d, max_h);
1096 cur_style = subtype(q);
1097 s = style_node_size;
1100 if (cur_style < script_style)
1101 cur_size = text_size;
1103 cur_size = 16 *((cur_style - text_style) / 2);
1105 cur_mu = x_over_n(math_quad(cur_size), 18);
1132 confusion("mlist3");
1133 return; // abort_flag set
1140 switch (str_pool[r_type * 8 + t + magic_offset])
1147 if (cur_style < script_style)
1148 x = thin_mu_skip_code;
1154 x = thin_mu_skip_code;
1158 if (cur_style < script_style)
1159 x = med_mu_skip_code;
1165 if (cur_style < script_style)
1166 x = thick_mu_skip_code;
1173 confusion("mlist4");
1174 return; // abort_flag set
1181 y = math_glue(glue_par(x), cur_mu);
1183 glue_ref_count(y) = 0;
1190 if (new_hlist(q) != 0)
1192 link(p) = new_hlist(q);
1198 while (!(link(p) == 0));
1203 if (pen < inf_penalty)
1205 r_type = type(link(q));
1207 if (r_type != penalty_node)
1208 if (r_type != rel_noad)
1210 z = new_penalty(pen);
1225 void push_alignment (void)
1229 p = get_node(align_stack_node_size);
1230 link(p) = align_ptr;
1231 info(p) = cur_align;
1232 llink(p) = preamble;
1233 rlink(p) = cur_span;
1234 mem[p + 2].cint = cur_loop;
1235 mem[p + 3].cint = align_state;
1236 info(p + 4) = cur_head;
1237 link(p + 4) = cur_tail;
1239 cur_head = get_avail();
1242 void pop_alignment (void)
1246 free_avail(cur_head);
1248 cur_tail = link(p + 4);
1249 cur_head = info(p + 4);
1250 align_state = mem[p + 3].cint;
1251 cur_loop = mem[p + 2].cint;
1252 cur_span = rlink(p);
1253 preamble = llink(p);
1254 cur_align = info(p);
1255 align_ptr = link(p);
1256 free_node(p, align_stack_node_size);
1259 void get_preamble_token (void)
1264 while ((cur_chr == span_code) && (cur_cmd == tab_mark))
1268 if (cur_cmd > max_command)
1275 if (cur_cmd == endv)
1277 fatal_error("(interwoven alignment preambles are not allowed)");
1278 return; // abort_flag set
1281 if ((cur_cmd == assign_glue) && (cur_chr == glue_base + tab_skip_code))
1283 scan_optional_equals();
1284 scan_glue(glue_val);
1286 if (global_defs > 0)
1287 geq_define(glue_base + tab_skip_code, glue_ref, cur_val);
1289 eq_define(glue_base + tab_skip_code, glue_ref, cur_val);
1295 void init_align (void)
1297 halfword save_cs_ptr;
1300 save_cs_ptr = cur_cs;
1302 align_state = -1000000L;
1304 if ((mode == mmode) && ((tail != cur_list.head_field) || (incompleat_noad != 0)))
1306 print_err("Improper ");
1307 print_esc("halign");
1308 print_string(" inside $$'s");
1309 help3("Displays can use special alignments (like \\eqalignno)",
1310 "only if nothing but the alignment itself is between $$'s.",
1311 "So I've deleted the formulas that preceded this alignment.");
1321 prev_depth = nest[nest_ptr - 2].aux_field.cint;
1324 mode = - (integer) mode;
1326 scan_spec(align_group, false);
1328 cur_align = align_head;
1330 scanner_status = aligning;
1331 warning_index = save_cs_ptr;
1332 align_state = -1000000L;
1336 link(cur_align) = new_param_glue(tab_skip_code);
1337 cur_align = link(cur_align);
1339 if (cur_cmd == car_ret)
1347 get_preamble_token();
1349 if (cur_cmd == mac_param)
1352 if ((cur_cmd <= car_ret) && (cur_cmd >= tab_mark) && (align_state == -1000000L))
1353 if ((p == hold_head) && (cur_loop == 0) && (cur_cmd == tab_mark))
1354 cur_loop = cur_align;
1357 print_err("Missing # inserted in alignment preamble");
1358 help3("There should be exactly one # between &'s, when an",
1359 "\\halign or \\valign is being set up. In this case you had",
1360 "none, so I've put one in; maybe that will work.");
1364 else if ((cur_cmd != spacer) || (p != hold_head))
1366 link(p) = get_avail();
1373 link(cur_align) = new_null_box();
1374 cur_align = link(cur_align);
1375 info(cur_align) = end_span;
1376 width(cur_align) = null_flag; /* - 2^30 */
1377 u_part(cur_align) = link(hold_head);
1384 get_preamble_token();
1386 if ((cur_cmd <= car_ret) && (cur_cmd >= tab_mark) && (align_state == -1000000L))
1389 if (cur_cmd == mac_param)
1391 print_err("Only one # is allowed per tab");
1392 help3("There should be exactly one # between &'s, when an",
1393 "\\halign or \\valign is being set up. In this case you had",
1394 "more than one, so I'm ignoring all but the first.");
1399 link(p) = get_avail();
1405 link(p) = get_avail();
1407 info(p) = end_template_token;
1408 v_part(cur_align) = link(hold_head);
1413 new_save_level(align_group);
1416 begin_token_list(every_cr, every_cr_text);
1420 void init_span_ (halfword p)
1425 space_factor = 1000;
1428 cur_list.aux_field.cint = ignore_depth;
1435 void init_row (void)
1439 mode = (-hmode - vmode) - mode;
1444 cur_list.aux_field.cint = 0;
1446 tail_append(new_glue(glue_ptr(preamble)));
1447 subtype(tail) = tab_skip_code + 1;
1448 cur_align = link(preamble);
1449 cur_tail = cur_head;
1450 init_span(cur_align);
1453 void init_col (void)
1455 extra_info(cur_align) = cur_cmd;
1457 if (cur_cmd == omit)
1462 begin_token_list(u_part(cur_align), u_template);
1465 /* fin_col() moved to end to hide in pragma (g, "off") */
1466 /* may need to move more ? everything calling new_null_box() ? */
1474 p = hpack(link(head), 0, 1);
1478 if (cur_head != cur_tail)
1480 link(tail) = link(cur_head);
1486 p = vpackage(link(head), 0, 1, 1073741823L); /* 2^30 - 1 */
1490 space_factor = 1000;
1493 type(p) = unset_node;
1494 glue_stretch(p) = 0;
1497 begin_token_list(every_cr, every_cr_text);
1502 void fin_align (void)
1504 halfword p, q, r, s, u, v;
1509 memory_word aux_save;
1511 if (cur_group != align_group)
1513 confusion("align1");
1514 return; // abort_flag set
1519 if (cur_group != align_group)
1521 confusion("align0");
1522 return; // abort_flag set
1527 if (nest[nest_ptr - 1].mode_field == mmode)
1536 flush_list(u_part(q));
1537 flush_list(v_part(q));
1540 if (width(q) == null_flag) /* - 2^30 */
1548 add_glue_ref(zero_glue);
1550 glue_ptr(c) = zero_glue;
1554 if (info(q) != end_span)
1556 t = width(q) + width(glue_ptr(link(q)));
1560 n = min_quarterword + 1;
1564 width(r) = width(r) - t;
1570 n = link(info(s)) + 1;
1582 if (width(r) > width(info(s)))
1583 width(info(s)) = width(r);
1585 free_node(r, span_node_size);
1590 while (!(r == end_span));
1593 type(q) = unset_node;
1594 span_count(q) = min_quarterword;
1597 glue_order(q) = normal;
1598 glue_sign(q) = normal;
1599 glue_stretch(q) = 0;
1605 save_ptr = save_ptr - 2;
1606 pack_begin_line = - (integer) mode_line;
1610 rule_save = overfull_rule;
1612 p = hpack(preamble, saved(1), saved(0));
1613 overfull_rule = rule_save;
1621 height(q) = width(q);
1627 p = vpackage(preamble, saved(1), saved(0), 1073741823L); /* 2^30 - 1 */
1632 width(q) = height(q);
1639 pack_begin_line = 0;
1645 if (!(q >= hi_mem_min))
1646 if (type(q) == unset_node)
1650 type(q) = hlist_node;
1651 width(q) = width(p);
1655 type(q) = vlist_node;
1656 height(q) = height(p);
1659 glue_order(q) = glue_order(p);
1660 glue_sign(q) = glue_sign(p);
1661 glue_set(q) = glue_set(p);
1662 shift_amount(q) = o;
1663 r = link(list_ptr(q));
1664 s = link(list_ptr(p));
1673 while (n > min_quarterword)
1678 link(u) = new_glue(v);
1680 subtype(u) = tab_skip_code + 1;
1683 if (glue_sign(p) == stretching)
1685 if (stretch_order(v) == glue_order(p))
1686 t = t + round(glue_set(p) * stretch(v));
1688 else if (glue_sign(p) == shrinking)
1690 if (shrink_order(v) == glue_order(p))
1691 t = t - round(glue_set(p) * shrink(v));
1695 link(u) = new_null_box();
1700 width(u) = width(s);
1703 type(u) = vlist_node;
1704 height(u) = width(s);
1711 height(r) = height(q);
1712 depth(r) = depth(q);
1716 glue_sign(r) = normal;
1717 glue_order(r) = normal;
1720 else if (t > width(r))
1722 glue_sign(r) = stretching;
1724 if (glue_stretch(r) == 0)
1727 glue_set(r) = (t - width(r)) / ((double) glue_stretch(r));
1731 glue_order(r) = glue_sign(r);
1732 glue_sign(r) = shrinking;
1734 if (glue_shrink(r) == 0)
1736 else if ((glue_order(r) == normal) && (width(r) - t > glue_shrink(r)))
1739 glue_set(r) = (width(r) - t)/ ((double) glue_shrink(r));
1743 type(r) = hlist_node;
1747 width(r) = width(q);
1751 glue_sign(r) = normal;
1752 glue_order(r) = normal;
1755 else if (t > height(r))
1757 glue_sign(r) = stretching;
1759 if (glue_stretch(r) == 0)
1762 glue_set(r) = (t - height(r)) / ((double) glue_stretch(r));
1766 glue_order(r) = glue_sign(r);
1767 glue_sign(r) = shrinking;
1769 if (glue_shrink(r) == 0)
1771 else if ((glue_order(r) == normal) && (height(r) - t > glue_shrink(r)))
1774 glue_set(r) = (height(r) - t) / ((double) glue_shrink(r));
1778 type(r) = vlist_node;
1781 shift_amount(r) = 0;
1786 link(r) = link(hold_head);
1795 else if (type(q) == rule_node)
1797 if ((width(q) == -1073741824L)) /* 2^30 */
1798 width(q) = width(p);
1800 if ((height(q) == -1073741824L)) /* 2^30 */
1801 height(q) = height(p);
1803 if ((depth(q) == -1073741824L)) /* 2^30 */
1804 depth(q) = depth(p);
1811 shift_amount(q) = o;
1822 aux_save = cur_list.aux_field;
1831 if (cur_cmd != math_shift)
1833 print_err("Missing $$ inserted");
1834 help2("Displays can use special alignments (like \\eqalignno)",
1835 "only if nothing but the alignment itself is between $$'s.");
1842 if (cur_cmd != math_shift)
1844 print_err("Display math should end with $$");
1845 help2("The `$' that I just saw supposedly matches a previous `$$'.",
1846 "So I shall assume that you typed `$$' both times.");
1852 tail_append(new_penalty(pre_display_penalty));
1853 tail_append(new_param_glue(above_display_skip_code));
1859 tail_append(new_penalty(post_display_penalty));
1860 tail_append(new_param_glue(below_display_skip_code));
1861 cur_list.aux_field.cint = aux_save.cint;
1862 resume_after_display();
1866 cur_list.aux_field = aux_save;
1878 /* used to be align_peek, zfintieshrink, etc in old tex5.c */
1879 /************************************************************************/
1880 /* moved down here to avoid questions about pragma optimize */
1881 /* #pragma optimize("g", off) */
1882 /* for MC VS compiler */
1883 /* Moved down here 96/Oct/12 in response to problem with texerror.tex */
1884 /* pragma optimize("a", off) not strong enough - this may slow things */
1899 return 0; // abort_flag set
1902 q = link(cur_align);
1907 return 0; // abort_flag set
1910 if (align_state < 500000L)
1912 fatal_error("(interwoven alignment preambles are not allowed)");
1913 return 0; // abort_flag set
1918 if ((p == 0) && (extra_info(cur_align) < cr_code))
1921 /* potential problem here if new_null_box causes memory reallocation ??? */
1922 /* compiler optimization does not refresh `mem' loaded in registers ? */
1923 link(q) = new_null_box();
1926 width(p) = null_flag;
1927 cur_loop = link(cur_loop);
1929 r = u_part(cur_loop);
1933 link(q) = get_avail();
1940 u_part(p) = link(hold_head);
1942 r = v_part(cur_loop);
1946 link(q) = get_avail();
1953 v_part(p) = link(hold_head);
1954 cur_loop = link(cur_loop);
1955 link(p) = new_glue(glue_ptr(cur_loop));
1959 print_err("Extra alignment tab has been changed to ");
1961 help3("You have given more \\span or & marks than there were",
1962 "in the preamble to the \\halign or \\valign now in progress.",
1963 "So I'll assume that you meant to type \\cr instead.");
1964 extra_info(cur_align) = cr_code;
1968 if (extra_info(cur_align) != span_code)
1972 new_save_level(align_group);
1977 adjust_tail = cur_tail;
1978 u = hpack(link(head), 0, 1);
1980 cur_tail = adjust_tail;
1985 u = vpackage(link(head), 0, 1, 0);
1989 n = min_quarterword;
1991 if (cur_span != cur_align)
2000 while (!(q == cur_align));
2002 if (n > max_quarterword)
2004 confusion("256 spans"); /* 256 spans --- message wrong now, but ... */
2005 return 0; // abort_flag set
2010 while (link(info(q)) < n)
2013 if (link(info(q)) > n)
2015 s = get_node(span_node_size);
2021 else if (width(info(q)) < w)
2024 else if (w > width(cur_align))
2025 width(cur_align) = w;
2027 type(u) = unset_node;
2030 if (total_stretch[filll] != 0)
2032 else if (total_stretch[fill] != 0)
2034 else if (total_stretch[fil] != 0)
2040 glue_stretch(u) = total_stretch[o];
2042 if (total_shrink[filll] != 0)
2044 else if (total_shrink[fill] != 0)
2046 else if (total_shrink[fil] != 0)
2052 glue_shrink(u) = total_shrink[o];
2058 tail_append(new_glue(glue_ptr(link(cur_align))));
2059 subtype(tail) = tab_skip_code + 1;
2061 if (extra_info(cur_align) >= cr_code)
2069 align_state = 1000000L;
2075 while (!(cur_cmd != spacer));
2082 /* #pragma optimize ("g", on) */ /* for MC VS compiler */
2083 /* #pragma optimize ("g",) */ /* 94/Jan/25 */
2084 /* #pragma optimize ("", on) */ /* 96/Sep/12 */
2085 /* #pragma optimize("g", off) */ /* for MC VS compiler */
2087 scaled make_op_(halfword q)
2090 halfword p, v, x, y, z;
2093 scaled shift_up, shift_down;
2095 if ((subtype(q) == normal) && (cur_style < text_style))
2096 subtype(q) = limits;
2098 if (math_type(nucleus(q)) == math_char)
2102 if ((cur_style < text_style) && (char_tag(cur_i) == list_tag))
2104 c = rem_byte(cur_i);
2105 i = char_info(cur_f, c);
2111 character(nucleus(q)) = c;
2115 delta = char_italic(cur_f, cur_i);
2116 x = clean_box(nucleus(q), cur_style);
2118 if ((math_type(subscr(q)) != 0) && (subtype(q) != limits))
2119 width(x) = width(x) - delta;
2121 shift_amount(x) = half(height(x) - depth(x)) - axis_height(cur_size);
2122 math_type(nucleus(q)) = sub_box;
2123 info(nucleus(q)) = x;
2128 if (subtype(q) == limits)
2130 x = clean_box(supscr(q), sup_style(cur_style));
2131 y = clean_box(nucleus(q), cur_style);
2132 z = clean_box(subscr(q), sub_style(cur_style));
2134 type(v) = vlist_node;
2135 width(v) = width(y);
2137 if (width(x) > width(v))
2138 width(v) = width(x);
2140 if (width(z) > width(v))
2141 width(v) = width(z);
2143 x = rebox(x, width(v));
2144 y = rebox(y, width(v));
2145 z = rebox(z, width(v));
2146 shift_amount(x) = half(delta);
2147 shift_amount(z) = - (integer) shift_amount(x);
2148 height(v) = height(y);
2149 depth(v) = depth(y);
2151 if (math_type(supscr(q)) == 0)
2153 free_node(x, box_node_size);
2158 shift_up = big_op_spacing3 - depth(x);
2160 if (shift_up < big_op_spacing1)
2161 shift_up = big_op_spacing1;
2163 p = new_kern(shift_up);
2166 p = new_kern(big_op_spacing5);
2169 height(v) = height(v) + big_op_spacing5 + height(x) + depth(x) + shift_up;
2172 if (math_type(subscr(q)) == 0)
2173 free_node(z, box_node_size);
2176 shift_down = big_op_spacing4 - height(z);
2178 if (shift_down < big_op_spacing2)
2179 shift_down = big_op_spacing2;
2181 p = new_kern(shift_down);
2184 p = new_kern(big_op_spacing5);
2186 depth(v) = depth(v) + big_op_spacing5 + height(z) + depth(z) + shift_down;
2194 /* #pragma optimize ("g", on) */ /* for MC VS compiler */
2195 /* #pragma optimize ("g",) */ /* 94/Jan/25 */
2196 /* #pragma optimize ("", on) */ /* 96/Sep/12 */
2197 /* #pragma optimize ("g", off) */
2199 void make_scripts_(halfword q, scaled delta)
2201 halfword p, x, y, z;
2202 scaled shift_up, shift_down, clr;
2207 if ((p >= hi_mem_min))
2216 if (cur_style < script_style)
2219 t = script_script_size;
2221 shift_up = height(z) - sup_drop(t);
2222 shift_down = depth(z) + sub_drop(t);
2223 free_node(z, box_node_size);
2226 if (math_type(supscr(q)) == 0)
2228 x = clean_box(subscr(q), sub_style(cur_style));
2229 width(x) = width(x) + script_space;
2231 if (shift_down < sub1(cur_size))
2232 shift_down = sub1(cur_size);
2234 clr = height(x) -(abs(math_x_height(cur_size) * 4) / 5);
2236 if (shift_down < clr)
2239 shift_amount(x) = shift_down;
2244 x = clean_box(supscr(q), sup_style(cur_style));
2245 width(x) = width(x) + script_space;
2248 clr = sup3(cur_size);
2249 else if (cur_style < text_style)
2250 clr = sup1(cur_size);
2252 clr = sup2(cur_size);
2257 clr = depth(x) +(abs(math_x_height(cur_size)) / 4);
2263 if (math_type(subscr(q)) == 0)
2264 shift_amount(x) = - (integer) shift_up;
2267 y = clean_box(subscr(q), sub_style(cur_style));
2268 width(y) = width(y) + script_space;
2270 if (shift_down < sub2(cur_size))
2271 shift_down = sub2(cur_size);
2273 clr = 4 * default_rule_thickness - ((shift_up - depth(x)) - (height(y) - shift_down));
2277 shift_down = shift_down + clr;
2279 clr = (abs(math_x_height(cur_size) * 4) / 5) - (shift_up - depth(x));
2283 shift_up = shift_up + clr;
2284 shift_down = shift_down - clr;
2288 shift_amount(x) = delta;
2289 p = new_kern((shift_up - depth(x)) - (height(y) - shift_down));
2292 x = vpackage(x, 0, 1, 1073741823L); /* 2^30 - 1 */
2293 shift_amount(x) = shift_down;
2297 if (new_hlist(q) == 0)
2303 while (link(p) != 0)
2309 /* #pragma optimize ("g", on) */ /* 96/Sep/12 */
2310 /* #pragma optimize ("g") */ /* 94/Jan/25 */
2311 /* #pragma optimize ("", on) */ /* 96/Sep/12 */