-#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:4996)
-#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 */
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
-/* math_fraction etc used to be in tex7.c */
/* sec 1181 */
void math_fraction (void)
{
scan_delimiter(right_delimiter(incompleat_noad), false);
}
- switch(c % delimited_code)
+ switch (c % delimited_code)
{
case above_code:
scan_dimen(false, false, false);
thickness(incompleat_noad) = cur_val;
break;
+
case over_code:
thickness(incompleat_noad) = default_code;
break;
+
case atop_code:
thickness(incompleat_noad) = 0;
break;
void math_left_right (void)
{
small_number t;
- halfword p;
+ pointer p;
t = cur_chr;
/* sec 1194 */
void after_math (void)
{
- bool l;
- bool danger;
+ boolean l;
+ boolean danger;
integer m;
- halfword p;
- halfword a;
- halfword b;
+ pointer p;
+ pointer a;
+ pointer b;
scaled w;
scaled z;
scaled e;
scaled d;
scaled s;
small_number g1, g2;
- halfword r;
- halfword t;
+ pointer r;
+ pointer t;
danger = false;
- if ((font_params[fam_fnt(2 + text_size)] < 22) ||
- (font_params[fam_fnt(2 + script_size)] < 22) ||
- (font_params[fam_fnt(2 + script_script_size)] < 22))
+ if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
+ (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
+ (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
{
print_err("Math formula deleted: Insufficient symbol fonts");
help3("Sorry, but I can't typeset math unless \\textfont 2",
flush_math();
danger = true;
}
- else if ((font_params[fam_fnt(3 + text_size)] < 13) ||
- (font_params[fam_fnt(3 + script_size)] < 13) ||
- (font_params[fam_fnt(3 + script_script_size)] < 13))
+ else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
+ (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
+ (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
{
print_err("Math formula deleted: Insufficient extension fonts");
help3("Sorry, but I can't typeset math unless \\textfont 3",
back_error();
}
}
+
cur_mlist = p;
cur_style = text_style;
mlist_penalties = false;
unsave();
decr(save_ptr);
- if (save_stack[save_ptr + 0].cint == 1)
+ if (saved(0) == 1)
l = true;
danger = false;
- if ((font_params[fam_fnt(2 + text_size)] < 22) ||
- (font_params[fam_fnt(2 + script_size)] < 22) ||
- (font_params[fam_fnt(2 + script_script_size)] < 22))
+ if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
+ (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
+ (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
{
print_err("Math formula deleted: Insufficient symbol fonts");
help3("Sorry, but I can't typeset math unless \\textfont 2",
flush_math();
danger = true;
}
- else if ((font_params[fam_fnt(3 + text_size)] < 13) ||
- (font_params[fam_fnt(3 + script_size)] < 13) ||
- (font_params[fam_fnt(3 + script_script_size)] < 13))
+ else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
+ (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
+ (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
{
print_err("Math formula deleted: Insufficient extension fonts");
help3("Sorry, but I can't typeset math unless \\textfont 3",
back_error();
}
}
+
cur_mlist = p;
cur_style = display_style;
mlist_penalties = false;
if (w + q > z)
{
- if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) || (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
+ if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) ||
+ (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
{
free_node(b, box_node_size);
b = hpack(p, z - q, 0);
if (t != adjust_head)
{
- mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH;
+ link(tail) = link(adjust_head);
tail = t;
}
{
get_token();
}
- while (!(cur_tok != 2592));
+ while (!(cur_tok != space_token));
if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
{
/* sec 1236 */
void do_register_command_ (small_number a)
{
- halfword l, q, r, s;
+ pointer l, q, r, s;
char p;
q = cur_cmd;
p = cur_chr;
scan_eight_bit_int();
- switch(p)
+ switch (p)
{
case int_val:
l = cur_val + count_base;
break;
+
case dimen_val:
l = cur_val + scaled_base;
break;
+
case glue_val:
l = cur_val + skip_base;
break;
+
case mu_val:
l = cur_val + mu_skip_base;
break;
}
}
-lab40:;
+lab40:
if (q == tex_register)
scan_optional_equals();
else
eq_define(l, glue_ref, cur_val);
}
}
-/* called only from itex.c */
/* sec 1243 */
void alter_aux (void)
{
nest[nest_ptr] = cur_list;
p = nest_ptr;
- while(abs(nest[p].mode_field) != vmode)
+ while (abs(nest[p].mode_field) != vmode)
decr(p);
scan_optional_equals();
/* sec 1257 */
void new_font_(small_number a)
{
- halfword u;
+ pointer u;
scaled s;
internal_font_number f;
str_number t;
else
{
old_setting = selector;
- selector = 21;
+ selector = new_string;
print_string("FONT");
print(u - active_base);
selector = old_setting;
help2("I can only handle fonts at positive sizes that are",
"less than 2048pt, so I've changed what you said to 10pt.");
error();
- s = 10 * 65536L; /* 10pt */
+ s = 10 * 65536L;
}
}
else if (scan_keyword("scaled"))
flushable_string = str_ptr - 1;
- if (trace_flag) /* debugging stuff only 98/Oct/5 */
+ if (trace_flag)
{
int i, k1, k2, l1, l2;
char *sch = log_line;
show_line(log_line, 0);
}
-/* paragraph 1260 for f <- fontbase+1 to font_ptr do */
- for (f = 1; f < font_ptr; f++)
+ for (f = font_base + 1; f < font_ptr; f++)
{
if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
{
{
if (s == font_size[f])
{
- if (ignore_frozen == 0 || f > frozenfontptr)
+ if (ignore_frozen == 0 || f > frozen_font_ptr)
{
if (trace_flag)
{
}
else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
{
- if (ignore_frozen == 0 || f > frozenfontptr)
- { /* 99/Mar/26 */
+ if (ignore_frozen == 0 || f > frozen_font_ptr)
+ {
if (trace_flag)
{
sprintf(log_line, "SKIPPING %ld ", s);
scan_file_name();
pack_file_name(cur_name, cur_area, cur_ext);
-/* *** some changes in following in 3.14159 *** */
-/* if current extension is *not* empty, try to open using name as is */
-/* string 335 is "" the empty string */
if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n]= 1;
-/* we get here if extension is "", or file with extension failed to open */
-/* if current extension is not `tex,' and `tex' is not irrelevant, try it */
-/* string 785 is .tex */
- else if ((cur_ext != 785) && (name_length + 5 < PATHMAX) &&
-/* *** some changes in above file name handling *** */
- (!extensionirrelevantp(name_of_file, name_length, "tex")))
+ read_open[n] = 1;
+ else if ((cur_ext != 785) && (name_length + 5 < PATH_MAX))
+ {
+ strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);
+ name_length = name_length + 4;
+
+ if (a_open_in(read_file[n], TEXINPUTPATH))
+ read_open[n] = just_open;
+ else
{
- name_of_file[name_length + 1] = '.'; /* .tex */
- name_of_file[name_length + 2] = 't';
- name_of_file[name_length + 3] = 'e';
- name_of_file[name_length + 4] = 'x';
- name_of_file[name_length + 5] = ' ';
- name_length = name_length + 4;
-
- if (a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n] = just_open;
- else
- {
- name_length = name_length - 4; /* remove ".tex" again */
- name_of_file[name_length + 1] = ' ';
+ name_length = name_length - 4;
+ name_of_file[name_length + 1] = ' ';
- if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n]= 1;
- else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n]= 1;
- }
+ if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
+ read_open[n] = 1;
}
+ }
}
}
/* sec 1279 */
/* sec 1288 */
void shift_case (void)
{
- halfword b;
- halfword p;
+ pointer b;
+ pointer p;
halfword t;
eight_bits c;
{
t = info(p);
- if (t < cs_token_flag + single_base) /* 4095 + 257 = cs_tokenflag + single_base */
+ if (t < cs_token_flag + single_base)
{
c = t % 256;
p = link(p);
}
+
begin_token_list(link(def_ref), 3);
free_avail(def_ref);
}
/* sec 1293 */
void show_whatever (void)
{
- halfword p;
+ pointer p;
- switch(cur_chr)
+ switch (cur_chr)
{
case show_lists:
{
show_activities();
}
break;
+
case show_box_code:
{
scan_eight_bit_int();
show_box(box(cur_val));
}
break;
+
case show_code:
{
get_token();
goto lab50;
}
break;
+
default:
{
p = the_toks();
"And type `I\\tracingonline=1\\show...' to show boxes and",
"lists on your terminal as well as in the transcript file.");
}
+
error();
}
/* sec 1349 */
void new_whatsit_(small_number s, small_number w)
{
- halfword p;
+ pointer p;
p = get_node(w);
type(p) = whatsit_node;
else if (cur_val > 15)
cur_val = 16;
}
+
write_stream(tail) = cur_val;
}
/* sec 1348 */
void do_extension (void)
{
-/* integer i, j, k; */
integer k;
-/* halfword p, q, r; */
- halfword p;
+ pointer p;
switch(cur_chr)
{
open_ext(tail) = cur_ext;
}
break;
+
case write_node:
{
k = cur_cs;
write_tokens(tail) = def_ref;
}
break;
+
case close_node:
{
new_write_whatsit(write_node_size);
write_tokens(tail) = 0;
}
break;
+
case special_node:
{
new_whatsit(special_node, write_node_size);
write_tokens(tail) = def_ref;
}
break;
+
case immediate_code:
{
get_x_token();
back_input();
}
break;
+
case set_language_code:
if (abs(mode) != hmode)
{
what_rhm(tail) = norm_min(right_hyphen_min);
}
break;
+
default:
{
confusion("ext1");
case simple_group:
unsave();
break;
+
case bottom_level:
{
print_err("Too many }'s");
error();
}
break;
+
case semi_simple_group:
case math_shift_group:
case math_left_group:
extra_right_brace();
break;
+
case hbox_group:
package(0);
break;
+
case adjust_hbox_group:
{
adjust_tail = adjust_head;
package(0);
}
break;
+
case vbox_group:
{
end_graf();
package(0);
}
break;
+
case vtop_group:
{
end_graf();
package(vtop_code);
}
break;
+
case insert_group:
{
end_graf();
f = floating_penalty;
unsave();
decr(save_ptr);
- p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L); /* 2^30 - 1 */
+ p = vpackage(link(head), 0, 1, 1073741823L); /* 2^30 - 1 */
pop_nest();
- if (save_stack[save_ptr + 0].cint < 255)
+ if (saved(0) < 255)
{
- tail_append(get_node(5));
+ tail_append(get_node(ins_node_size));
type(tail) = ins_node;
- subtype(tail) = save_stack[save_ptr + 0].cint;
+ subtype(tail) = saved(0);
height(tail) = height(p) + depth(p);
ins_ptr(tail) = list_ptr(p);
split_top_ptr(tail) = q;
}
else
{
- tail_append(get_node(2));
+ tail_append(get_node(small_node_size));
type(tail) = adjust_node;
subtype(tail) = 0;
adjust_ptr(tail) = list_ptr(p);
help2("Your sneaky output routine has problematic {'s and/or }'s.",
"I can't handle that very well; good luck.");
error();
+
do
{
get_token();
}
while (!(cur_input.loc_field == 0));
}
+
end_token_list();
end_graf();
unsave();
build_page();
}
break;
+
case disc_group:
build_discretionary();
break;
+
case align_group:
{
back_input();
ins_error();
}
break;
+
case no_align_group:
{
end_graf();
align_peek();
}
break;
+
case vcenter_group:
{
end_graf();
unsave();
save_ptr = save_ptr - 2;
- p = vpackage(link(head), save_stack[save_ptr + 1].cint, save_stack[save_ptr + 0].cint, 1073741823L); /* 2^30 - 1 */
+ p = vpackage(link(head), saved(1), saved(0), 1073741823L); /* 2^30 - 1 */
pop_nest();
tail_append(new_noad());
type(tail) = vcenter_noad;
info(nucleus(tail)) = p;
}
break;
+
case math_choice_group:
build_choices();
break;
+
case math_group:
{
unsave();
decr(save_ptr);
- math_type(save_stack[save_ptr + 0].cint) = sub_mlist;
+ math_type(saved(0)) = sub_mlist;
p = fin_mlist(0);
- info(save_stack[save_ptr + 0].cint) = p;
+ info(saved(0)) = p;
+
if (p != 0)
if (link(p) == 0)
if (type(p) == ord_noad)
if (math_type(subscr(p)) == 0)
if (math_type(supscr(p)) == 0)
{
- mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh;
+ mem[saved(0)].hh = mem[nucleus(p)].hh;
free_node(p, noad_size);
}
}
else if (type(p) == accent_noad)
- if (save_stack[save_ptr + 0].cint == nucleus(tail))
+ if (saved(0) == nucleus(tail))
if (type(tail) == ord_noad)
{
q = head;
case hmode + char_given:
goto lab70;
break;
+
case hmode + char_num:
{
scan_char_num();
goto lab70;
}
break;
+
case hmode + no_boundary:
{
get_x_token();
goto lab21;
}
break;
+
case hmode + spacer:
if (space_factor == 1000)
goto lab120;
else
app_space();
break;
+
case hmode + ex_space:
case mmode + ex_space:
goto lab120;
break;
+
case any_mode(relax):
case vmode + spacer:
case mmode + spacer:
case mmode + no_boundary:
;
break;
+
case any_mode(ignore_spaces):
{
do
goto lab21;
}
break;
+
case vmode + stop:
if (its_all_over())
return;
break;
+
case vmode + vmove:
case hmode + hmove:
case mmode + hmove:
case any_mode(mac_param):
report_illegal_case();
break;
+
case non_math(sup_mark):
case non_math(sub_mark):
case non_math(math_char_num):
case mmode + hrule:
insert_dollar_sign();
break;
+
case vmode + hrule:
case hmode + vrule:
case mmode + vrule:
space_factor = 1000;
}
break;
+
case vmode + vskip:
case hmode + hskip:
case mmode + hskip:
case mmode + mskip:
append_glue();
break;
+
case any_mode(kern):
case mmode + mkern:
append_kern();
break;
+
case non_math(left_brace):
new_save_level(simple_group);
break;
+
case any_mode(begin_group):
new_save_level(semi_simple_group);
break;
+
case any_mode(end_group):
if (cur_group == semi_simple_group)
unsave();
else
off_save();
break;
+
case any_mode(right_brace):
handle_right_brace();
break;
+
case vmode + hmove:
case hmode + vmove:
case mmode + vmove:
scan_box(- (integer) cur_val);
}
break;
+
case any_mode(leader_ship):
scan_box(leader_flag - a_leaders + cur_chr);
break;
+
case any_mode(make_box):
begin_box(0);
break;
+
case vmode + start_par:
new_graf(cur_chr > 0);
break;
+
case vmode + letter:
case vmode + other_char:
case vmode + char_num:
new_graf(true);
}
break;
+
case hmode + start_par:
case mmode + start_par:
indent_in_hmode();
break;
+
case vmode + par_end:
{
normal_paragraph();
build_page();
}
break;
+
case hmode + par_end:
{
if (align_state < 0)
build_page();
}
break;
+
case hmode + stop:
case hmode + vskip:
case hmode + hrule:
case hmode + halign:
head_for_vmode();
break;
+
case any_mode(insert):
case hmode + vadjust:
case mmode + vadjust:
begin_insert_or_adjust();
break;
+
case any_mode(mark):
make_mark();
break;
+
case any_mode(break_penalty):
append_penalty();
break;
+
case any_mode(remove_item):
delete_last();
break;
+
case vmode + un_vbox:
case hmode + un_hbox:
case mmode + un_hbox:
unpackage();
break;
+
case hmode + ital_corr:
append_italic_correction();
break;
+
case mmode + ital_corr:
tail_append(new_kern(0));
break;
+
case hmode + discretionary:
case mmode + discretionary:
append_discretionary();
break;
+
case hmode + accent:
make_accent();
break;
+
case any_mode(car_ret):
case any_mode(tab_mark):
align_error();
break;
+
case any_mode(no_align):
noalign_error();
break;
+
case any_mode(omit):
omit_error();
break;
+
case vmode + halign:
case hmode + valign:
init_align();
break;
+
case mmode + halign:
if (privileged ())
if (cur_group == math_shift_group)
else
off_save();
break;
+
case vmode + endv:
case hmode + endv:
do_endv();
break;
+
case any_mode(end_cs_name):
cs_error();
break;
+
case hmode + math_shift:
init_math();
break;
+
case mmode + eq_no:
if (privileged ())
if (cur_group == math_shift_group)
else
off_save();
break;
+
case mmode + left_brace:
{
tail_append(new_noad());
scan_math(nucleus(tail));
}
break;
+
case mmode + letter:
case mmode + other_char:
case mmode + char_given:
set_math_char(math_code(cur_chr));
break;
+
case mmode + char_num:
{
scan_char_num();
set_math_char(math_code(cur_chr));
}
break;
+
case mmode + math_char_num:
{
scan_fifteen_bit_int();
set_math_char(cur_val);
}
break;
+
case mmode + math_given:
set_math_char(cur_chr);
break;
+
case mmode + delim_num:
{
scan_twenty_seven_bit_int();
set_math_char(cur_val / 4096);
}
break;
+
case mmode + math_comp:
{
tail_append(new_noad());
scan_math(nucleus(tail));
}
break;
+
case mmode + limit_switch:
math_limit_switch();
break;
+
case mmode + radical:
math_radical();
break;
+
case mmode + accent:
case mmode + math_accent:
math_ac();
break;
+
case mmode + vcenter:
{
scan_spec(vcenter_group, false);
begin_token_list(every_vbox, every_vbox_text);
}
break;
+
case mmode + math_style:
tail_append(new_style(cur_chr));
break;
+
case mmode + non_script:
{
tail_append(new_glue(0));
subtype(tail) = cond_math_glue;
}
break;
+
case mmode + math_choice:
append_choices();
break;
+
case mmode + sub_mark:
case mmode + sup_mark:
sub_sup();
break;
+
case mmode + above:
math_fraction();
break;
+
case mmode + left_right:
math_left_right();
break;
+
case mmode + math_shift:
if (cur_group == math_shift_group)
after_math();
else
off_save();
break;
+
case any_mode(toks_register):
case any_mode(assign_toks):
case any_mode(assign_int):
case any_mode(set_interaction):
prefixed_command();
break;
+
case any_mode(after_assignment):
{
get_token();
after_token = cur_tok;
}
break;
+
case any_mode(after_group):
{
get_token();
save_for_after(cur_tok);
}
break;
+
case any_mode(in_stream):
open_or_close_in();
break;
+
case any_mode(message):
issue_message();
break;
+
case any_mode(case_shift):
shift_case();
break;
+
case any_mode(xray):
show_whatever();
break;
+
case any_mode(extension):
do_extension();
break;
if (mode > 0)
if (language != clang)
fix_language();
- {
- lig_stack = avail;
- if (lig_stack == 0)
- lig_stack = get_avail();
- else
- {
- avail = mem[lig_stack].hh.v.RH;
- mem[lig_stack].hh.v.RH = 0;
-#ifdef STAT
- incr(dyn_used);
-#endif /* STAT */
- }
- }
+ fast_get_avail(lig_stack);
font(lig_stack) = main_f;
cur_l = cur_chr;
character(lig_stack) = cur_l;
lab101:
adjust_space_factor();
- {
- lig_stack = avail;
-
- if (lig_stack == 0)
- lig_stack = get_avail();
- else
- {
- avail = mem[lig_stack].hh.v.RH;
- mem[lig_stack].hh.v.RH = 0;
-#ifdef STAT
- incr(dyn_used);
-#endif /* STAT */
- }
- }
+ fast_get_avail(lig_stack);
font(lig_stack) = main_f;
cur_r = cur_chr;
character(lig_stack) = cur_r;