-#ifdef _WINDOWS
- #define NOCOMM
- #define NOSOUND
- #define NODRIVERS
- #define STRICT
- #pragma warning(disable:4115) // kill rpcasync.h complaint
- #include <windows.h>
- #define MYLIBAPI __declspec(dllexport)
-#endif
+/* Copyright 2014 Clerk Ma
-#include "texwin.h"
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-#pragma warning(disable:4131) // old style declarator
-#pragma warning(disable:4135) // conversion between different integral types
-#pragma warning(disable:4127) // conditional expression is constant
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
-#include <setjmp.h>
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA. */
#define EXTERN extern
#include "texd.h"
-#pragma warning(disable:4244) /* 96/Jan/10 */
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
/* sec 0994 */
void build_page (void)
{
- halfword p;
- halfword q, r;
+ pointer p;
+ pointer q, r;
integer b, c;
integer pi;
-/* unsigned char n; */
- unsigned int n; /* 95/Jan/7 */
+/* unsigned char n; */
+ unsigned int n;
scaled delta, h, w;
if ((link(contrib_head) == 0) || output_active)
do
{
-lab22:
+continu:
p = link(contrib_head);
if (last_glue != max_halfword)
link(q) = p;
link(contrib_head) = q;
- goto lab22;
+ goto continu;
}
else
{
page_total = page_total + page_depth + height(p);
page_depth = depth(p);
- goto lab80;
+ goto contribute;
}
break;
case whatsit_node:
- goto lab80;
+ goto contribute;
break;
case glue_node:
if (page_contents < box_there)
- goto lab31;
+ goto done1;
else if (precedes_break(page_tail))
pi = 0;
else
- goto lab90;
+ goto update_heights;
break;
case kern_node:
if (page_contents < box_there)
- goto lab31;
+ goto done1;
else if (link(p) == 0)
return;
else if (type(link(p)) == glue_node)
pi = 0;
else
- goto lab90;
+ goto update_heights;
break;
case penalty_node:
if (page_contents < box_there)
- goto lab31;
+ goto done1;
else
pi = penalty(p);
break;
case mark_node:
- goto lab80;
+ goto contribute;
break;
case ins_node:
else
{
if (count(n) <= 0)
- w = max_dimen; /* 2^30 - 1 */
+ w = max_dimen;
else
{
w = page_goal - page_total - page_depth;
begin_diagnostic();
print_nl("% split");
print_int(n);
- print_string(" to");
+ prints(" to");
print_scaled(w);
print_char(',');
print_scaled(best_height_plus_depth);
- print_string(" p=");
+ prints(" p=");
if (q == 0)
print_int(eject_penalty);
end_diagnostic(false);
}
-#endif /* STAT */
+#endif
if (count(n) != 1000)
best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * count(n);
insert_penalties = insert_penalties + penalty(q);
}
}
- goto lab80;
+ goto contribute;
}
break;
default:
{
confusion("page");
- return; // abort_flag set
+ return;
}
break;
}
else
b = badness(page_goal - page_total, page_so_far[2]);
else if (page_total - page_goal > page_shrink)
- b = awful_bad; /* 2^30 - 1 */
+ b = awful_bad;
else
b = badness(page_total - page_goal, page_shrink);
- if (b < awful_bad) /* 2^30 - 1 */
+ if (b < awful_bad)
if (pi <= eject_penalty)
c = pi;
else if (b < inf_bad)
c = b;
if (insert_penalties >= 10000)
- c = awful_bad; /* 2^30 - 1 */
+ c = awful_bad;
#ifdef STAT
if (tracing_pages > 0)
{
begin_diagnostic();
print_nl("%");
- print_string(" t=");
+ prints(" t=");
print_totals();
- print_string(" g=");
+ prints(" g=");
print_scaled(page_goal);
- print_string(" b=");
+ prints(" b=");
- if (b == awful_bad) /* 2^30 - 1 */
+ if (b == awful_bad)
print_char('*');
else
print_int(b);
- print_string(" p=");
+ prints(" p=");
print_int(pi);
- print_string(" c=");
+ prints(" c=");
- if (c == awful_bad) /* 2^30 - 1 */
+ if (c == awful_bad)
print_char('*');
else
print_int(c);
end_diagnostic(false);
}
-#endif /* STAT */
+#endif
if (c <= least_page_cost)
{
}
}
- if ((c == awful_bad) || (pi <= eject_penalty)) /* 2^30 - 1 */
+ if ((c == awful_bad) || (pi <= eject_penalty))
{
fire_up(p);
if (output_active)
return;
- goto lab30;
+ goto done;
}
}
if ((type(p) < glue_node) || (type(p) > kern_node))
- goto lab80;
-lab90:
+ goto contribute;
+
+update_heights:
if (type(p) == kern_node)
q = p;
else
page_total = page_total + page_depth + width(q);
page_depth = 0;
-lab80:
+
+contribute:
if (page_depth > page_max_depth)
{
page_total = page_total + page_depth - page_max_depth;
page_tail = p;
link(contrib_head) = link(p);
link(p) = 0;
- goto lab30;
-lab31:
+ goto done;
+
+done1:
link(contrib_head) = link(p);
link(p) = 0;
flush_node_list(p);
-lab30:;
+done:;
}
while (!(link(contrib_head) == 0));
/* sec 1043 */
void app_space (void)
{
- halfword q;
+ pointer q;
if ((space_factor >= 2000) && (xspace_skip != zero_glue))
q = new_param_glue(xspace_skip_code);
link(tail) = q;
tail = q;
}
-/* called from tex8.c only */
/* sec 1047 */
void insert_dollar_sign (void)
{
{
print_err("You can't use `");
print_cmd_chr(cur_cmd, cur_chr);
- print_string("' in ");
+ prints("' in ");
print_mode(mode);
}
/* sec 1050 */
error();
}
/* sec 1051 */
-bool privileged (void)
+boolean privileged (void)
{
if (mode > 0)
return true;
}
}
/* sec 1054 */
-bool its_all_over (void)
+boolean its_all_over (void)
{
- if (privileged ())
+ if (privileged())
{
- if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
+ if ((page_head == page_tail) && (head == tail) && (dead_cycles == 0))
{
return true;
}
s = cur_chr;
- switch(s)
+ switch (s)
{
case fil_code:
cur_val = fil_glue;
s = cur_chr;
- scan_dimen(s == mu_glue, false, false);
+ scan_dimen((s == mu_glue), false, false);
tail_append(new_kern(cur_val));
subtype(tail) = s;
}
/* sec 1064 */
void off_save (void)
{
- halfword p;
+ pointer p;
if (cur_group == bottom_level)
{
break;
}
- print_string(" inserted");
+ prints(" inserted");
ins_list(link(temp_head));
help5("I've inserted something that you may have forgotten.",
"(See the <inserted text> above.)",
error();
}
}
-/* only called from tex8.c */
/* sec 1069 */
void extra_right_brace (void)
{
print_err("Extra }, or forgotten ");
- switch(cur_group)
+ switch (cur_group)
{
case semi_simple_group:
print_esc("endgroup");
/* sec 1075 */
void box_end_(integer box_context)
{
- halfword p;
+ pointer p;
if (box_context < box_flag)
{
{
get_x_token();
}
- while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+ while (!((cur_cmd != spacer) && (cur_cmd != relax)));
- if (((cur_cmd == hskip) && (abs(mode)!= vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
+ if (((cur_cmd == hskip) && (abs(mode) != vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
{
append_glue();
subtype(tail) = box_context - (leader_flag - a_leaders);
else
ship_out(cur_box);
}
-/* called only from tex8.c */
/* sec 1079 */
void begin_box_(integer box_context)
{
- halfword p, q;
+ pointer p, q;
quarterword m;
halfword k;
eight_bits n;
- switch(cur_chr)
+ switch (cur_chr)
{
case box_code:
{
}
else
{
- if (!(tail >= hi_mem_min))
+ if (!is_char_node(tail))
if ((type(tail) == hlist_node) || (type(tail) == vlist_node))
{
q = head;
{
p = q;
- if (!(q >= hi_mem_min))
+ if (!is_char_node(q))
if (type(q) == disc_node)
{
for (m = 1; m <= replace_count(q); m++)
p = link(p);
if (p == tail)
- goto lab30;
+ goto done;
}
q = link(p);
shift_amount(cur_box) = 0;
tail = p;
link(p) = 0;
-lab30:
- ;
+done:;
}
}
}
if (every_hbox != 0)
begin_token_list(every_hbox, every_vbox_text);
}
+
return;
}
break;
back_error();
}
}
-/****************************************************************************/
-void package_ (small_number);
-/****************************************************************************/
/* sec 1091 */
small_number norm_min_ (integer h)
{
return h;
}
/* sec 1091 */
-void new_graf_(bool indented)
+void new_graf_(boolean indented)
{
prev_graf = 0;
space_factor = 1000;
set_cur_lang();
clang = cur_lang;
- prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
+ prev_graf = (norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
if (indented)
{
if (nest_ptr == 1)
build_page();
}
-/* procedure indent_in_hmode; l.21058 */
/* sec 1093 */
void indent_in_hmode (void)
{
- halfword p, q;
+ pointer p, q;
if (cur_chr > 0)
{
tail_append(p);
}
}
-/* only called from tex8.c */
/* sec 1095 */
void head_for_vmode (void)
{
{
print_err("You can't use `");
print_esc("hrule");
- print_string("' here except with leaders");
+ prints("' here except with leaders");
help2("To put a horizontal rule in an hbox or an alignment,",
"you should use \\leaders or \\hrulefill (see The TeXbook).");
error();
back_input();
cur_tok = par_token;
back_input();
- cur_input.index_field = inserted;
+ index = inserted;
}
}
/* sec 1096 */
error_count = 0;
}
}
-/* only called form tex8.c */
/* sec 1099 */
void begin_insert_or_adjust (void)
{
/* sec 1101 */
void make_mark (void)
{
- halfword p;
+ pointer p;
p = scan_toks(false, true);
p = get_node(small_node_size);
if (mode == vmode)
build_page();
}
-/* only called from tex8.c */
/* sec 1105 */
void delete_last (void)
{
- halfword p, q;
+ pointer p, q;
quarterword m;
if ((mode == vmode) && (tail == head))
}
else
{
- if (!(tail >= hi_mem_min))
+ if (!is_char_node(tail))
if (type(tail) == cur_chr)
{
q = head;
{
p = q;
- if (!(q >= hi_mem_min))
+ if (!is_char_node(q))
if (type(q) == disc_node)
{
for (m = 1; m <= replace_count(q); m++)
}
}
}
-/* only called from tex8.c */
-/* procedure unpackage; l.21256 */
/* sec 1110 */
void unpackage (void)
{
- halfword p;
+ pointer p;
char c;
c = cur_chr;
/* sec 1113 */
void append_italic_correction (void)
{
- halfword p;
+ pointer p;
internal_font_number f;
if (tail != head)
{
- if ((tail >= hi_mem_min))
+ if (is_char_node(tail))
p = tail;
else if (type(tail) == ligature_node)
p = tail + 1;
space_factor = 1000;
}
}
-/* only called form tex8.c */
/* sec 1119 */
void build_discretionary (void)
{
- halfword p, q;
+ pointer p, q;
integer n;
unsave();
while (p != 0)
{
- if (!(p >= hi_mem_min))
+ if (!is_char_node(p))
if (type(p) > rule_node)
if (type(p) != kern_node)
if (type(p) != ligature_node)
end_diagnostic(true);
flush_node_list(p);
link(q) = 0;
- goto lab30;
+ goto done;
}
q = p;
incr(n);
}
-lab30:
+done:
p = link(head);
pop_nest();
mode = -hmode;
space_factor = 1000;
}
-/* called only from tex8.c */
/* sec 1123 */
void make_accent (void)
{
real s, t;
- halfword p, q, r;
+ pointer p, q, r;
internal_font_number f;
scaled a, h, x, w, delta;
- ffourquarters i;
+ four_quarters i;
scan_char_num();
f = cur_font;
shift_amount(p) = x - h;
}
- delta = round((w - a) / ((double) 2.0)+ h * t - x * s);
+ delta = round((w - a) / ((double) 2.0) + h * t - x * s);
r = new_kern(delta);
subtype(r) = acc_kern;
link(tail) = r;
"an alignment. Proceed, and I'll ignore this case.");
error();
}
-/* only called from tex8.c */
/* sec 1129 */
void omit_error (void)
{
else
off_save();
}
-/* only called form tex8.c */
/* sec 1135 */
void cs_error (void)
{
scaled w;
scaled l;
scaled s;
- halfword p;
- halfword q;
+ pointer p;
+ pointer q;
internal_font_number f;
integer n;
scaled v;
if (head == tail)
{
pop_nest();
- w = -max_dimen; /* - (2^30 - 1) */
+ w = -max_dimen;
}
else
{
line_break(display_widow_penalty);
v = shift_amount(just_box) + 2 * quad(cur_font);
- w = -max_dimen; /* - (2^30 - 1) */
+ w = -max_dimen;
p = list_ptr(just_box);
while (p != 0)
{
-lab21:
- if ((p >= hi_mem_min))
+reswitch:
+ if (is_char_node(p))
{
f = font(p);
d = char_width(f, char_info(f, character(p)));
- goto lab40;
+ goto found;
}
switch (type(p))
case rule_node:
{
d = width(p);
- goto lab40;
+ goto found;
}
break;
mem[lig_trick] = mem[lig_char(p)];
link(lig_trick) = link(p);
p = lig_trick;
- goto lab21;
+ goto reswitch;
}
break;
if (glue_sign(just_box) == stretching)
{
if ((glue_order(just_box) == stretch_order(q)) && (stretch(q) != 0))
- v = max_dimen; /* - (2^30 - 1) */
+ v = max_dimen;
}
else if (glue_sign(just_box) == shrinking)
{
if ((glue_order(just_box) == shrink_order(q)) && (shrink(q) != 0))
- v = max_dimen; /* - (2^30 - 1) */
+ v = max_dimen;
}
if (subtype(p) >= a_leaders)
- goto lab40;
+ goto found;
}
break;
break;
}
- if (v < max_dimen) /* - (2^30 - 1) */
+ if (v < max_dimen)
v = v + d;
- goto lab45;
-lab40:
- if (v < max_dimen) /* - (2^30 - 1) */
+ goto not_found;
+
+found:
+ if (v < max_dimen)
{
v = v + d;
w = v;
}
else
{
- w = max_dimen; /* - (2^30 - 1) */
- goto lab30;
+ w = max_dimen;
+ goto done;
}
-lab45:
+
+not_found:
p = link(p);
}
-lab30:;
+done:;
}
if (par_shape_ptr == 0)
}
}
/* sec 1151 */
-void scan_math_(halfword p)
+void scan_math_(pointer p)
{
integer c;
-lab20:
+restart:
do
{
get_x_token();
}
- while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+ while (!((cur_cmd != spacer) && (cur_cmd != relax)));
-lab21:
+reswitch:
switch (cur_cmd)
{
case letter:
back_input();
}
- goto lab20;
+ goto restart;
}
}
break;
scan_char_num();
cur_chr = cur_val;
cur_cmd = char_given;
- goto lab21;
+ goto reswitch;
}
break;
/* sec 1155 */
void set_math_char_(integer c)
{
- halfword p;
+ pointer p;
if (c >= 32768L)
{
error();
}
/* sec 1160 */
-void scan_delimiter_(halfword p, bool r)
+void scan_delimiter_(pointer p, boolean r)
{
if (r)
{
{
print_err("Please use ");
print_esc("mathaccent");
- print_string(" for accents in math mode");
+ prints(" for accents in math mode");
help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
"(Accents are not the same in formulas as they are in text.)");
error();
/* sec 1184 */
halfword fin_mlist_(halfword p)
{
- halfword q;
+ pointer q;
if (incompleat_noad != 0)
{
if (type(q) != left_noad)
{
confusion("right");
- return 0; // abort_flag set
+ return 0;
}
info(numerator(incompleat_noad)) = link(q);
link(tail) = p;
q = link(head);
}
+
pop_nest();
return q;
/* sec 1174 */
void build_choices (void)
{
- halfword p;
+ pointer p;
unsave();
p = fin_mlist(0);
void sub_sup (void)
{
/* small_number t; */
- int t; /* 95/Jan/7 */
- halfword p;
+ int t;
+ pointer p;
t = 0;
p = 0;
error();
}
}
+
scan_math(p);
}
-/* used to continue here with math_fraction etc in tex7.c */
-/*****************************************************************************/
-/* moved down here to avoid pragma optimize questions 96/Sep/12 */
/* sec 1086 */
void package_(small_number c)
{
scaled h;
- halfword p;
+ pointer p;
scaled d;
d = box_max_depth;
height(cur_box) = h;
}
}
+
pop_nest();
box_end(saved(0));
-}
-//#pragma optimize ("", on) /* 96/Sep/12 */
\ No newline at end of file
+}
\ No newline at end of file