summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/luametatex/source/luametatex.h2
-rw-r--r--source/luametatex/source/tex/texequivalents.c76
-rw-r--r--source/luametatex/source/tex/texequivalents.h4
-rw-r--r--source/luametatex/source/tex/texmaincontrol.c341
-rw-r--r--source/luametatex/source/tex/texmaincontrol.h2
-rw-r--r--source/luametatex/source/tex/texmath.c109
-rw-r--r--source/luametatex/source/tex/texpackaging.c29
-rw-r--r--source/luametatex/source/tex/texpackaging.h36
-rw-r--r--source/luametatex/source/tex/textypes.h3
9 files changed, 277 insertions, 325 deletions
diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h
index c92599fbc..b46922a11 100644
--- a/source/luametatex/source/luametatex.h
+++ b/source/luametatex/source/luametatex.h
@@ -89,7 +89,7 @@
# define luametatex_version 210
# define luametatex_revision 04
# define luametatex_version_string "2.10.04"
-# define luametatex_development_id 20221221
+# define luametatex_development_id 20221222
# define luametatex_name_camelcase "LuaMetaTeX"
# define luametatex_name_lowercase "luametatex"
diff --git a/source/luametatex/source/tex/texequivalents.c b/source/luametatex/source/tex/texequivalents.c
index d91663dd3..827f68a77 100644
--- a/source/luametatex/source/tex/texequivalents.c
+++ b/source/luametatex/source/tex/texequivalents.c
@@ -507,6 +507,12 @@ static int tex_aux_save_value(int id)
return i ? saved_value(i) : 0;
}
+static int tex_aux_save_level(int id)
+{
+ int i = tex_aux_found_save_type(id);
+ return i ? saved_level(i) : 0;
+}
+
static int tex_aux_saved_box_spec(halfword *packing, halfword *amount)
{
int i = tex_aux_found_save_type(box_spec_save_type);
@@ -675,43 +681,47 @@ void tex_show_save_groups(void)
tex_confusion("show groups");
break;
}
- /*tex Show the box context */
- {
- int i = tex_aux_save_value(saved_full_spec_item_context);;
- if (i) {
- if (i < box_flag) {
- /* this is pretty horrible and likely wrong */
- singleword cmd = (abs(lmt_nest_state.nest[pointer].mode) == vmode) ? hmove_cmd : vmove_cmd;
- tex_print_cmd_chr(cmd, (i > 0) ? move_forward_code : move_backward_code);
- tex_print_dimension(abs(i), pt_unit);
- } else if (i <= max_global_box_flag) {
- if (i >= global_box_flag) {
- tex_print_str_esc("global");
- i -= (global_box_flag - box_flag);
+ /*tex
+ Show the box context. In traditional \TEX\ the shift is encoded in the context which is
+ why it had such a large offset for the other context value. That somewhat dirty trick
+ was has stepwise been removed.
+ */
+ switch (tex_aux_save_value(saved_full_spec_item_context)) {
+ case direct_box_flag:
+ {
+ scaled shift = tex_aux_save_value(saved_full_spec_item_shift);
+ if (shift != null_flag) {
+ /*tex We passed the safeguard. */
+ singleword cmd = (abs(lmt_nest_state.nest[pointer].mode) == vmode) ? hmove_cmd : vmove_cmd;
+ tex_print_cmd_chr(cmd, (shift > 0) ? move_forward_code : move_backward_code);
+ tex_print_dimension(abs(shift), pt_unit);
}
+ }
+ break;
+ case global_box_flag:
+ tex_print_str_esc("global");
+ case box_flag:
+ {
tex_print_str_esc("setbox");
- tex_print_int(i - box_flag);
+ tex_print_int(tex_aux_save_level(saved_full_spec_item_context));
tex_print_char('=');
- } else {
- switch (i) {
- case a_leaders_flag:
- tex_print_cmd_chr(leader_cmd, a_leaders);
- break;
- case c_leaders_flag:
- tex_print_cmd_chr(leader_cmd, c_leaders);
- break;
- case x_leaders_flag:
- tex_print_cmd_chr(leader_cmd, x_leaders);
- break;
- case g_leaders_flag:
- tex_print_cmd_chr(leader_cmd, g_leaders);
- break;
- case u_leaders_flag:
- tex_print_cmd_chr(leader_cmd, u_leaders);
- break;
- }
}
- }
+ break;
+ case a_leaders_flag:
+ tex_print_cmd_chr(leader_cmd, a_leaders);
+ break;
+ case c_leaders_flag:
+ tex_print_cmd_chr(leader_cmd, c_leaders);
+ break;
+ case x_leaders_flag:
+ tex_print_cmd_chr(leader_cmd, x_leaders);
+ break;
+ case g_leaders_flag:
+ tex_print_cmd_chr(leader_cmd, g_leaders);
+ break;
+ case u_leaders_flag:
+ tex_print_cmd_chr(leader_cmd, u_leaders);
+ break;
}
FOUND1:
{
diff --git a/source/luametatex/source/tex/texequivalents.h b/source/luametatex/source/tex/texequivalents.h
index 511463c6a..82e500fb3 100644
--- a/source/luametatex/source/tex/texequivalents.h
+++ b/source/luametatex/source/tex/texequivalents.h
@@ -1788,8 +1788,8 @@ extern halfword tex_explicit_disc_penalty (halfword mode);
# define update_tex_tab_skip_local(v) tex_eq_define(internal_glue_location(tab_skip_code), internal_glue_reference_cmd, v);
# define update_tex_tab_skip_global(v) tex_geq_define(internal_glue_location(tab_skip_code), internal_glue_reference_cmd, v);
-# define update_tex_box_local(n,v) tex_eq_define(register_box_location(n) - box_flag, register_box_reference_cmd, v);
-# define update_tex_box_global(n,v) tex_geq_define(register_box_location(n) - global_box_flag, register_box_reference_cmd, v);
+# define update_tex_box_local(n,v) tex_eq_define(register_box_location(n), register_box_reference_cmd, v);
+# define update_tex_box_global(n,v) tex_geq_define(register_box_location(n), register_box_reference_cmd, v);
# define update_tex_insert_mode(a,v) tex_word_define(a, internal_int_location(insert_mode_code), v)
diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c
index aa160968e..62b6d1e1e 100644
--- a/source/luametatex/source/tex/texmaincontrol.c
+++ b/source/luametatex/source/tex/texmaincontrol.c
@@ -662,7 +662,7 @@ static void tex_aux_run_end_group(void) {
*/
-static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
+static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift, halfword slot)
{
/*tex Get the next non-blank non-relax... and optionally skip an equal sign */
while (1) {
@@ -680,7 +680,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
switch (cur_cmd) {
case make_box_cmd:
{
- tex_begin_box(boxcontext, shift);
+ tex_begin_box(boxcontext, shift, slot);
return;
}
case vcenter_cmd:
@@ -705,7 +705,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
case vlist_node:
case rule_node:
case glyph_node:
- tex_box_end(boxcontext, boxnode, shift, unset_noad_class);
+ tex_box_end(boxcontext, boxnode, shift, unset_noad_class, slot);
return;
}
}
@@ -720,7 +720,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
halfword v = tex_scan_lua_value(cur_chr);
switch (v) {
case no_val_level:
- tex_box_end(boxcontext, null, shift, unset_noad_class);
+ tex_box_end(boxcontext, null, shift, unset_noad_class, slot);
return;
case list_val_level:
if (box_leaders_flag(boxcontext)) {
@@ -729,14 +729,14 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
case vlist_node:
case rule_node:
// case glyph_node:
- tex_box_end(boxcontext, cur_val, shift, unset_noad_class);
+ tex_box_end(boxcontext, cur_val, shift, unset_noad_class, slot);
return;
}
} else {
switch (node_type(cur_val)) {
case hlist_node:
case vlist_node:
- tex_box_end(boxcontext, cur_val, shift, unset_noad_class);
+ tex_box_end(boxcontext, cur_val, shift, unset_noad_class, slot);
return;
}
}
@@ -749,7 +749,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
{
if (box_leaders_flag(boxcontext)) {
halfword rulenode = tex_aux_scan_rule_spec(cur_cmd == hrule_cmd ? h_rule_type : (cur_cmd == vrule_cmd ? v_rule_type : m_rule_type), cur_chr);
- tex_box_end(boxcontext, rulenode, shift, unset_noad_class);
+ tex_box_end(boxcontext, rulenode, shift, unset_noad_class, slot);
return;
} else {
break;
@@ -762,7 +762,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
halfword boxnode = null;
tex_aux_run_text_char_number();
boxnode = tex_pop_tail();
- tex_box_end(boxcontext, boxnode, shift, unset_noad_class);
+ tex_box_end(boxcontext, boxnode, shift, unset_noad_class, slot);
return;
} else {
break;
@@ -776,8 +776,8 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
"that. So you might find something missing in your output. But keep trying; you\n"
"can fix this later."
);
- if (boxcontext == lua_scan_flag) {
- tex_box_end(boxcontext, null, shift, unset_noad_class);
+ if (boxcontext == lua_scan_flag) { /* hm */
+ tex_box_end(boxcontext, null, shift, unset_noad_class, slot);
}
}
@@ -791,7 +791,7 @@ static void tex_aux_scan_box(int boxcontext, int optional_equal, scaled shift)
static void tex_aux_run_move(void) {
int code = cur_chr;
halfword val = tex_scan_dimen(0, 0, 0, 0, NULL);
- tex_aux_scan_box(0, 0, code == move_forward_code ? val : - val);
+ tex_aux_scan_box(direct_box_flag, 0, code == move_forward_code ? val : - val, -1);
}
/*tex
@@ -903,13 +903,13 @@ static int leader_flags[] = {
};
static void tex_aux_run_leader(void) {
- tex_aux_scan_box(leader_flags[cur_chr], 0, null_flag);
+ tex_aux_scan_box(leader_flags[cur_chr], 0, null_flag, -1);
}
static void tex_aux_run_legacy(void) {
switch (cur_chr) {
case shipout_code:
- tex_aux_scan_box(shipout_flag, 0, null_flag);
+ tex_aux_scan_box(shipout_flag, 0, null_flag, -1);
break;
default:
/* cant_happen */
@@ -922,7 +922,7 @@ static void tex_aux_run_local_box(void) {
}
static void tex_aux_run_make_box(void) {
- tex_begin_box(0, null_flag);
+ tex_begin_box(direct_box_flag, null_flag, -1);
}
/*tex
@@ -1465,7 +1465,7 @@ static void tex_aux_invalid_catcode_table_error(void) {
tex_handle_error(
normal_error_type,
"Invalid \\catcode table",
- "All \\catcode table ids must be between 0 and " LMT_TOSTRING(max_n_of_catcode_tables-1)
+ "All \\catcode table ids must be between 0 and " LMT_TOSTRING(max_n_of_catcode_tables - 1)
);
}
@@ -1890,7 +1890,7 @@ halfword tex_local_scan_box(void)
int old_mode = cur_list.mode;
int old_level = lmt_main_control_state.local_level;
cur_list.mode = -hmode;
- tex_aux_scan_box(lua_scan_flag, 0, null_flag);
+ tex_aux_scan_box(lua_scan_flag, 0, null_flag, -1);
if (lmt_main_control_state.local_level == old_level) {
/*tex |\directlua{print(token.scan_list())}\hbox{!}| (n n) */
if (tracing_nesting_par > 2) {
@@ -2726,125 +2726,122 @@ static void tex_aux_wrapup_leader_box(halfword boxcontext, halfword boxnode)
}
}
-void tex_box_end(int boxcontext, halfword boxnode, scaled shift, halfword mainclass)
+void tex_box_end(int boxcontext, halfword boxnode, scaled shift, halfword mainclass, halfword slot)
{
cur_box = boxnode;
- if (boxcontext < box_flag) {
- /*tex
-
- Append box |boxnode| to the current list, shifted by |boxcontext|. The global variable
- |adjust_tail| will be non-null if and only if the current box might include adjustments
- that should be appended to the current vertical list.
-
- Having shift in the box context is kind of strange but as long as we stay below maxdimen
- it works.
+ switch (boxcontext) {
+ case direct_box_flag:
+ /*tex
- We now pass the shift directly, so no boxcontext trick here.
+ Append box |boxnode| to the current list, shifted by |boxcontext|. The global variable
+ |adjust_tail| will be non-null if and only if the current box might include adjustments
+ that should be appended to the current vertical list.
- */
+ Having shift in the box context is kind of strange but as long as we stay below maxdimen
+ it works. We now pass the shift directly, so no boxcontext trick here.
- if (boxnode) {
- // box_shift_amount(boxnode) = boxcontext;
- if (shift != null_flag) {
- box_shift_amount(boxnode) = shift;
- }
- switch (cur_mode) {
- case vmode:
- if (lmt_packaging_state.pre_adjust_tail) {
- if (pre_adjust_head != lmt_packaging_state.pre_adjust_tail) {
- tex_inject_adjust_list(pre_adjust_head, 1, boxnode, NULL);
+ */
+ if (boxnode) {
+ if (shift != null_flag) {
+ box_shift_amount(boxnode) = shift;
+ }
+ switch (cur_mode) {
+ case vmode:
+ if (lmt_packaging_state.pre_adjust_tail) {
+ if (pre_adjust_head != lmt_packaging_state.pre_adjust_tail) {
+ tex_inject_adjust_list(pre_adjust_head, 1, boxnode, NULL);
+ }
+ lmt_packaging_state.pre_adjust_tail = null;
}
- lmt_packaging_state.pre_adjust_tail = null;
- }
- if (lmt_packaging_state.pre_migrate_tail) {
- if (pre_migrate_head != lmt_packaging_state.pre_migrate_tail) {
- tex_append_list(pre_migrate_head, lmt_packaging_state.pre_migrate_tail);
+ if (lmt_packaging_state.pre_migrate_tail) {
+ if (pre_migrate_head != lmt_packaging_state.pre_migrate_tail) {
+ tex_append_list(pre_migrate_head, lmt_packaging_state.pre_migrate_tail);
+ }
+ lmt_packaging_state.pre_migrate_tail = null;
}
- lmt_packaging_state.pre_migrate_tail = null;
- }
- tex_append_to_vlist(boxnode, lua_key_index(box), NULL);
- if (lmt_packaging_state.post_migrate_tail) {
- if (post_migrate_head != lmt_packaging_state.post_migrate_tail) {
- tex_append_list(post_migrate_head, lmt_packaging_state.post_migrate_tail);
+ tex_append_to_vlist(boxnode, lua_key_index(box), NULL);
+ if (lmt_packaging_state.post_migrate_tail) {
+ if (post_migrate_head != lmt_packaging_state.post_migrate_tail) {
+ tex_append_list(post_migrate_head, lmt_packaging_state.post_migrate_tail);
+ }
+ lmt_packaging_state.post_migrate_tail = null;
}
- lmt_packaging_state.post_migrate_tail = null;
- }
- if (lmt_packaging_state.post_adjust_tail) {
- if (post_adjust_head != lmt_packaging_state.post_adjust_tail) {
- tex_inject_adjust_list(post_adjust_head, 1, null, NULL);
+ if (lmt_packaging_state.post_adjust_tail) {
+ if (post_adjust_head != lmt_packaging_state.post_adjust_tail) {
+ tex_inject_adjust_list(post_adjust_head, 1, null, NULL);
+ }
+ lmt_packaging_state.post_adjust_tail = null;
}
- lmt_packaging_state.post_adjust_tail = null;
- }
- if (cur_list.mode > nomode) {
- if (! lmt_page_builder_state.output_active) {
- lmt_page_filter_callback(box_page_context, 0);
+ if (cur_list.mode > nomode) {
+ if (! lmt_page_builder_state.output_active) {
+ lmt_page_filter_callback(box_page_context, 0);
+ }
+ tex_build_page();
}
- tex_build_page();
- }
- break;
- case hmode:
- cur_list.space_factor = default_space_factor;
- tex_couple_nodes(cur_list.tail, boxnode);
- cur_list.tail = boxnode;
- break;
- /* case mmode: */
- default:
- boxnode = tex_new_sub_box(boxnode);
- tex_couple_nodes(cur_list.tail, boxnode);
- cur_list.tail = boxnode;
- if (mainclass != unset_noad_class) {
- set_noad_classes(boxnode, mainclass);
- }
- break;
+ break;
+ case hmode:
+ cur_list.space_factor = default_space_factor;
+ tex_couple_nodes(cur_list.tail, boxnode);
+ cur_list.tail = boxnode;
+ break;
+ /* case mmode: */
+ default:
+ boxnode = tex_new_sub_box(boxnode);
+ tex_couple_nodes(cur_list.tail, boxnode);
+ cur_list.tail = boxnode;
+ if (mainclass != unset_noad_class) {
+ set_noad_classes(boxnode, mainclass);
+ }
+ break;
+ }
+ } else {
+ /* just scanning */
}
- } else {
- /* just scanning */
- }
- } else if (boxcontext < global_box_flag) {
- /*tex Store |box| in a local box register */
- update_tex_box_local(boxcontext, boxnode);
- } else if (boxcontext <= max_global_box_flag) {
- /*tex Store |box| in a global box register */
- update_tex_box_global(boxcontext, boxnode);
- } else {
- switch (boxcontext) {
- case shipout_flag:
- /*tex This normally can't happen as some backend code needs to kick in. */
- if (boxnode) {
- /*tex We just show the box ... */
- tex_begin_diagnostic();
- tex_show_node_list(boxnode, max_integer, max_integer);
- tex_end_diagnostic();
- /*tex ... and wipe it when it's a register ... */
- if (box_register(boxnode)) {
- tex_flush_node_list(boxnode);
- box_register(boxnode) = null;
- }
- /*tex ... so there is at least an indication that we flushed. */
+ break;
+ case box_flag:
+ /*tex Store |box| in a local box register */
+ update_tex_box_local(slot, boxnode);
+ break;
+ case global_box_flag:
+ /*tex Store |box| in a global box register */
+ update_tex_box_global(slot, boxnode);
+ break;
+ case shipout_flag:
+ /*tex This normally can't happen as some backend code needs to kick in. */
+ if (boxnode) {
+ /*tex We just show the box ... */
+ tex_begin_diagnostic();
+ tex_show_node_list(boxnode, max_integer, max_integer);
+ tex_end_diagnostic();
+ /*tex ... and wipe it when it's a register ... */
+ if (box_register(boxnode)) {
+ tex_flush_node_list(boxnode);
+ box_register(boxnode) = null;
}
- break;
- case left_box_flag:
- case right_box_flag:
- case middle_box_flag:
- /*tex Actualy, this cannot happen ... will go away. */
- tex_aux_finish_local_box();
- break;
- case lua_scan_flag:
- /*tex We are done with scanning so let's return to the caller. */
- tex_aux_wrapup_local_scan_box();
- cur_box = boxnode;
- break;
- case a_leaders_flag:
- case c_leaders_flag:
- case x_leaders_flag:
- case g_leaders_flag:
- case u_leaders_flag:
- tex_aux_wrapup_leader_box(boxcontext, boxnode);
- break;
- default:
- /* fatal error */
- break;
- }
+ /*tex ... so there is at least an indication that we flushed. */
+ }
+ break;
+ case left_box_flag:
+ case right_box_flag:
+ case middle_box_flag:
+ /*tex Actualy, this cannot happen ... will go away. */
+ tex_aux_finish_local_box();
+ break;
+ case lua_scan_flag:
+ /*tex We are done with scanning so let's return to the caller. */
+ tex_aux_wrapup_local_scan_box();
+ cur_box = boxnode;
+ break;
+ case a_leaders_flag:
+ case c_leaders_flag:
+ case x_leaders_flag:
+ case g_leaders_flag:
+ case u_leaders_flag:
+ tex_aux_wrapup_leader_box(boxcontext, boxnode);
+ break;
+ default:
+ /* fatal error */
+ break;
}
}
@@ -2858,76 +2855,6 @@ void tex_box_end(int boxcontext, halfword boxnode, scaled shift, halfword maincl
*/
-// void tex_begin_paragraph(int doindent, int context)
-// {
-// halfword q;
-// int indented = doindent;
-// int isvmode = cur_list.mode == vmode;
-// if (isvmode || cur_list.head != cur_list.tail) {
-// /*tex
-// Actually we could remove the callback and hook it into the |\everybeforepar| but that one
-// started out as a |tex.expandmacro| itself and we don't want the callback overhead every
-// time, so now we have both. However, in the end I decided to do this one {\em before} the
-// parskip is injected.
-// */
-// if (every_before_par_par) {
-// tex_begin_inserted_list(tex_get_available_token(token_val(end_local_cmd, 0)));
-// tex_begin_token_list(every_before_par_par, every_before_par_text);
-// if (tracing_nesting_par > 2) {
-// tex_local_control_message("entering local control via \\everybeforepar");
-// }
-// tex_local_control(1);
-// }
-// // if (type(cur_list.tail) == glue_node && subtype(cur_list.tail) == par_skip_glue) {
-// // /* ignore */
-// // } else {
-// tex_tail_append(tex_new_param_glue_node(par_skip_code, par_skip_glue));
-// // }
-// }
-// lmt_begin_paragraph_callback(isvmode, &indented, context);
-// /*tex We'd better not messed up things in the callback! */
-// cur_list.prev_graf = 0;
-// tex_push_nest();
-// cur_list.mode = hmode;
-// cur_list.space_factor = default_space_factor;
-// /*tex Add local paragraph node */
-// tex_tail_append(tex_new_par_node(vmode_par_par_subtype));
-// // if (end_of_par_par) {
-// // update_tex_end_of_par(null); /* option */
-// // }
-// q = cur_list.tail;
-// /*tex We will move this to after the dir nodes have been dealt with. */
-// tex_aux_insert_parindent(indented);
-// /*tex Dir nodes end up before the indent box. */
-// {
-// halfword dir_rover = lmt_dir_state.text_dir_ptr;
-// while (dir_rover) {
-// if ((node_next(dir_rover)) || (dir_direction(dir_rover) != par_direction_par)) {
-// halfword dir_graf_tmp = tex_new_dir(normal_dir_subtype, dir_direction(dir_rover));
-// tex_try_couple_nodes(dir_graf_tmp, node_next(q));
-// tex_couple_nodes(q, dir_graf_tmp);
-// }
-// dir_rover = node_next(dir_rover);
-// }
-// }
-// /*tex We might need to go to the last injected dir and/or indent node. */
-// while (node_next(q)) {
-// q = node_next(q);
-// }
-// cur_list.tail = q;
-// /*tex The |\everypar| tokens are injected after dir nodes have been added. */
-// if (every_par_par) {
-// tex_begin_token_list(every_par_par, every_par_text);
-// }
-// if (lmt_nest_state.nest_data.ptr == 1) {
-// if (! lmt_page_builder_state.output_active) {
-// lmt_page_filter_callback(begin_paragraph_page_context, 0);
-// }
-// /*tex put |par_skip| glue on current page */
-// tex_build_page();
-// }
-// }
-
void tex_tail_prepend(halfword n)
{
tex_couple_nodes(node_prev(cur_list.tail), n);
@@ -3048,7 +2975,7 @@ static void tex_aux_run_kern(void)
{
halfword code = cur_chr;
switch (code) {
- /* not yet enabled and maybe it never wil be */
+ /* not yet enabled and maybe it never will be */
case h_kern_code:
if (cur_mode == vmode) {
tex_back_input(token_val(kern_cmd, normal_kern_code));
@@ -4227,9 +4154,9 @@ static void tex_aux_set_box_property(void)
static void tex_aux_set_box(int a)
{
- halfword n = tex_scan_box_register_number() + (is_global(a) ? global_box_flag : box_flag);
+ halfword slot = tex_scan_box_register_number();
if (lmt_error_state.set_box_allowed) {
- tex_aux_scan_box(n, 1, null_flag);
+ tex_aux_scan_box(is_global(a) ? global_box_flag : box_flag, 1, null_flag, slot);
} else {
tex_handle_error(
normal_error_type,
@@ -5492,32 +5419,22 @@ static int tex_aux_set_some_item(halfword a)
static void tex_aux_set_constant_register(halfword cmd, halfword cs, halfword flags)
{
+ halfword v = null;
switch(cmd) {
case integer_cmd:
- {
- halfword v = tex_scan_int(1, NULL);
- tex_define(flags, cs, integer_cmd, v);
- }
+ v = tex_scan_int(1, NULL);
break;
case dimension_cmd:
- {
- scaled v = tex_scan_dimen(0, 0, 0, 1, NULL);
- tex_define(flags, cs, dimension_cmd, v);
- }
+ v = tex_scan_dimen(0, 0, 0, 1, NULL);
break;
case gluespec_cmd:
- {
- halfword v = tex_scan_glue(glue_val_level, 1);
- tex_define(flags, cs, gluespec_cmd, v);
- }
+ v = tex_scan_glue(glue_val_level, 1);
break;
case mugluespec_cmd:
- {
- halfword v = tex_scan_glue(mu_val_level, 1);
- tex_define(flags, cs, mugluespec_cmd, v);
- }
+ v = tex_scan_glue(mu_val_level, 1);
break;
}
+ tex_define(flags, cs, cmd, v);
}
void tex_run_prefixed_command(void)
diff --git a/source/luametatex/source/tex/texmaincontrol.h b/source/luametatex/source/tex/texmaincontrol.h
index b71aaedac..5b72a3d43 100644
--- a/source/luametatex/source/tex/texmaincontrol.h
+++ b/source/luametatex/source/tex/texmaincontrol.h
@@ -52,7 +52,7 @@ extern void tex_you_cant_error (const char *helpinfo);
extern void tex_off_save (void);
extern halfword tex_local_scan_box (void);
-extern void tex_box_end (int boxcontext, halfword boxnode, scaled shift, halfword mainclass);
+extern void tex_box_end (int boxcontext, halfword boxnode, scaled shift, halfword mainclass, halfword slot);
extern void tex_get_r_token (void);
diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c
index ffc73cd12..ec30de1ca 100644
--- a/source/luametatex/source/tex/texmath.c
+++ b/source/luametatex/source/tex/texmath.c
@@ -2458,53 +2458,70 @@ halfword tex_math_make_disc(halfword d)
void tex_run_math_modifier(void)
{
halfword tail = cur_list.tail;
- if (cur_list.head != tail && node_type(tail) == simple_noad) { // maybe all
- switch (cur_chr) {
- case adapt_to_left_modifier_code:
- noad_options(tail) = unset_option(noad_options(tail), noad_option_adapt_to_right_size);
- noad_options(tail) |= noad_option_adapt_to_left_size;
- break;
- case adapt_to_right_modifier_code:
- noad_options(tail) = unset_option(noad_options(tail), noad_option_adapt_to_left_size);
- noad_options(tail) |= noad_option_adapt_to_right_size;
- break;
- /* todo: actually this one can also be used for other types */
- case axis_modifier_code:
- noad_options(tail) |= noad_option_axis;
- break;
- case no_axis_modifier_code:
- noad_options(tail) |= noad_option_no_axis;
- break;
- case phantom_modifier_code:
- noad_options(tail) |= noad_option_phantom;
- break;
- case void_modifier_code:
- noad_options(tail) |= noad_option_void;
- break;
- case source_modifier_code:
- if (tex_scan_keyword("nucleus")) {
- noad_options(tail) |= noad_option_source_on_nucleus;
+ if (cur_list.head != tail) {
+ switch (node_type(tail)) {
+ case simple_noad:
+ switch (cur_chr) {
+ case adapt_to_left_modifier_code:
+ noad_options(tail) = unset_option(noad_options(tail), noad_option_adapt_to_right_size);
+ noad_options(tail) |= noad_option_adapt_to_left_size;
+ break;
+ case adapt_to_right_modifier_code:
+ noad_options(tail) = unset_option(noad_options(tail), noad_option_adapt_to_left_size);
+ noad_options(tail) |= noad_option_adapt_to_right_size;
+ break;
+ /* todo: actually this one can also be used for other types */
+ case axis_modifier_code:
+ noad_options(tail) |= noad_option_axis;
+ break;
+ case no_axis_modifier_code:
+ noad_options(tail) |= noad_option_no_axis;
+ break;
+ case phantom_modifier_code:
+ noad_options(tail) |= noad_option_phantom;
+ break;
+ case void_modifier_code:
+ noad_options(tail) |= noad_option_void;
+ break;
+ case source_modifier_code:
+ if (tex_scan_keyword("nucleus")) {
+ noad_options(tail) |= noad_option_source_on_nucleus;
+ }
+ noad_source(tail) = tex_scan_int(0, NULL);
+ break;
+ case openup_height_modifier_code:
+ noad_options(tail) |= noad_option_openup_height;
+ noad_height(tail) = tex_scan_dimen(0, 0, 0, 0, NULL);
+ break;
+ case openup_depth_modifier_code:
+ noad_options(tail) |= noad_option_openup_depth;
+ noad_depth(tail) = tex_scan_dimen(0, 0, 0, 0, NULL);
+ break;
+ case display_limits_modifier_code:
+ noad_options(tail) = unset_option(noad_options(tail), noad_option_limits | noad_option_no_limits);
+ break;
+ case limits_modifier_code:
+ noad_options(tail) = unset_option(noad_options(tail), noad_option_no_limits);
+ noad_options(tail) |= noad_option_limits;
+ break;
+ case no_limits_modifier_code:
+ noad_options(tail) = unset_option(noad_options(tail), noad_option_limits);
+ noad_options(tail) |= noad_option_no_limits;
+ break;
+ }
+ default:
+ switch (node_type(tail)) {
+ case accent_noad:
+ switch (cur_chr) {
+ case source_modifier_code:
+ if (tex_scan_keyword("nucleus")) {
+ noad_options(tail) |= noad_option_source_on_nucleus;
+ }
+ noad_source(tail) = tex_scan_int(0, NULL);
+ break;
+ }
+
}
- noad_source(tail) = tex_scan_int(0, NULL);
- break;
- case openup_height_modifier_code:
- noad_options(tail) |= noad_option_openup_height;
- noad_height(tail) = tex_scan_dimen(0, 0, 0, 0, NULL);
- break;
- case openup_depth_modifier_code:
- noad_options(tail) |= noad_option_openup_depth;
- noad_depth(tail) = tex_scan_dimen(0, 0, 0, 0, NULL);
- break;
- case display_limits_modifier_code:
- noad_options(tail) = unset_option(noad_options(tail), noad_option_limits | noad_option_no_limits);
- break;
- case limits_modifier_code:
- noad_options(tail) = unset_option(noad_options(tail), noad_option_no_limits);
- noad_options(tail) |= noad_option_limits;
- break;
- case no_limits_modifier_code:
- noad_options(tail) = unset_option(noad_options(tail), noad_option_limits);
- noad_options(tail) |= noad_option_no_limits;
break;
}
}
diff --git a/source/luametatex/source/tex/texpackaging.c b/source/luametatex/source/tex/texpackaging.c
index 9b7ff31bf..49a18497c 100644
--- a/source/luametatex/source/tex/texpackaging.c
+++ b/source/luametatex/source/tex/texpackaging.c
@@ -65,7 +65,7 @@
*/
-static void tex_aux_scan_full_spec(quarterword c, quarterword spec_direction, int just_pack, scaled shift)
+static void tex_aux_scan_full_spec(halfword context, quarterword c, quarterword spec_direction, int just_pack, scaled shift, halfword slot)
{
quarterword spec_code = packing_additional;
int spec_amount = 0;
@@ -85,7 +85,6 @@ static void tex_aux_scan_full_spec(quarterword c, quarterword spec_direction, in
halfword state = 0;
halfword retain = 0;
halfword mainclass = unset_noad_class;
- int context = saved_value(saved_full_spec_item_context);
int brace = 0;
while (1) {
/*tex Maybe |migrate <int>| makes sense here. */
@@ -300,7 +299,7 @@ static void tex_aux_scan_full_spec(quarterword c, quarterword spec_direction, in
/*tex Now we're referenced. We need to preserve this over the group. */
add_attribute_reference(attrlist);
/* */
- tex_set_saved_record(saved_full_spec_item_context, box_context_save_type, 0, context);
+ tex_set_saved_record(saved_full_spec_item_context, box_context_save_type, slot, context); /* slot fits in a quarterword */
/*tex Traditionally these two are packed into one record: */
tex_set_saved_record(saved_full_spec_item_packaging, box_spec_save_type, spec_code, spec_amount);
/*tex Adjust |text_dir_ptr| for |scan_spec|: */
@@ -2320,7 +2319,7 @@ halfword tex_filtered_vpack(halfword p, scaled h, int m, scaled maxdepth, int gr
void tex_run_vcenter(void)
{
- tex_aux_scan_full_spec(vcenter_group, direction_l2r, 0, 0);
+ tex_aux_scan_full_spec(direct_box_flag, vcenter_group, direction_l2r, 0, 0, -1);
tex_normal_paragraph(vcenter_par_context);
tex_push_nest();
cur_list.mode = -vmode;
@@ -2398,13 +2397,14 @@ static scaled tex_aux_first_height(halfword boxnode)
void tex_package(singleword nature)
{
- halfword context, spec, dirptr, attrlist, justpack, orientation, anchor, geometry, source, target, axis, mainclass, state, retain;
+ halfword slot, context, spec, dirptr, attrlist, justpack, orientation, anchor, geometry, source, target, axis, mainclass, state, retain;
scaled shift;
int grp = cur_group;
scaled maxdepth = box_max_depth_par;
halfword boxnode = null; /*tex Aka |cur_box|. */
tex_unsave();
lmt_save_state.save_stack_data.ptr -= saved_full_spec_n_of_items;
+ slot = saved_level(saved_full_spec_item_context);
context = saved_value(saved_full_spec_item_context);
spec = saved_value(saved_full_spec_item_packaging);
dirptr = saved_value(saved_full_spec_item_direction);
@@ -2536,7 +2536,7 @@ void tex_package(singleword nature)
box_axis(boxnode) = (singleword) axis;
box_package_state(boxnode) |= (singleword) state;
tex_pop_nest();
- tex_box_end(context, boxnode, shift, mainclass);
+ tex_box_end(context, boxnode, shift, mainclass, slot);
}
void tex_run_unpackage(void)
@@ -2786,7 +2786,7 @@ void tex_run_unpackage(void)
*/
-inline static halfword tex_aux_depth_correction(halfword b, const line_break_properties *properties)
+static halfword tex_aux_depth_correction(halfword b, const line_break_properties *properties)
{
/*tex The deficiency of space between baselines: */
halfword p;
@@ -3227,7 +3227,7 @@ halfword tex_vsplit(halfword n, scaled h, int m)
*/
-void tex_begin_box(int boxcontext, scaled shift)
+void tex_begin_box(int boxcontext, scaled shift, halfword slot)
{
halfword code = cur_chr;
halfword boxnode = null; /*tex Aka |cur_box|. */
@@ -3392,7 +3392,6 @@ void tex_begin_box(int boxcontext, scaled shift)
break;
}
mode = code - vtop_code;
- tex_set_saved_record(saved_full_spec_item_context, box_context_save_type, 0, boxcontext);
switch (abs(cur_list.mode)) {
case vmode:
spec_direction = dir_lefttoright;
@@ -3405,16 +3404,16 @@ void tex_begin_box(int boxcontext, scaled shift)
break;
}
if (mode == hmode) {
- if ((boxcontext < box_flag) && (abs(cur_list.mode) == vmode)) {
- tex_aux_scan_full_spec(adjusted_hbox_group, spec_direction, just_pack, shift);
+ if ((boxcontext == direct_box_flag) && (abs(cur_list.mode) == vmode)) {
+ tex_aux_scan_full_spec(boxcontext, adjusted_hbox_group, spec_direction, just_pack, shift, slot);
} else {
- tex_aux_scan_full_spec(hbox_group, spec_direction, just_pack, shift);
+ tex_aux_scan_full_spec(boxcontext, hbox_group, spec_direction, just_pack, shift, slot);
}
} else {
if (mode == vmode) {
- tex_aux_scan_full_spec(vbox_group, spec_direction, just_pack, shift);
+ tex_aux_scan_full_spec(boxcontext, vbox_group, spec_direction, just_pack, shift, slot);
} else {
- tex_aux_scan_full_spec((code == dbox_code || code == dpack_code) ? dbox_group : vtop_group, spec_direction, just_pack, shift);
+ tex_aux_scan_full_spec(boxcontext, (code == dbox_code || code == dpack_code) ? dbox_group : vtop_group, spec_direction, just_pack, shift, slot);
mode = vmode;
}
tex_normal_paragraph(vmode_par_context);
@@ -3437,5 +3436,5 @@ void tex_begin_box(int boxcontext, scaled shift)
}
}
/*tex In simple cases, we use the box immediately. */
- tex_box_end(boxcontext, boxnode, shift, unset_noad_class);
+ tex_box_end(boxcontext, boxnode, shift, unset_noad_class, slot);
}
diff --git a/source/luametatex/source/tex/texpackaging.h b/source/luametatex/source/tex/texpackaging.h
index 5fd4bf9e4..0e3c0a471 100644
--- a/source/luametatex/source/tex/texpackaging.h
+++ b/source/luametatex/source/tex/texpackaging.h
@@ -179,29 +179,37 @@ extern void tex_run_vcenter (void);
|box_code|, |copy_code|, |last_box_code|, |vsplit_code|, |vtop_code|, |vtop_code + vmode|, and
|vtop_code + hmode|, where the latter two are used denote |\vbox| and |\hbox|, respectively.
+ Originally the shift was encoded in the box context in case of a move. In fact even the local
+ and global register assignments were in that property but this is no longer the case. This
+ actually makes implementing a |\boxspecdef| cleaner (a discarded experiment). The intermediate
+ cleasned up flags can be found in the history.
+
*/
# define biggest_reg 65535 /*tex This could be in |textypes.h|. */
typedef enum box_flags {
- box_flag = 010000000000, /*tex context code for |\setbox0| (< maxdimen) */
- global_box_flag = 010000000000 + biggest_reg, /*tex context code for |\global\setbox0| */
- max_global_box_flag = 010000000000 + 2 * biggest_reg,
- left_box_flag = 010000000000 + 2 * biggest_reg + 1, /*tex context code for |\localleftbox| (not used) */
- right_box_flag = 010000000000 + 2 * biggest_reg + 2, /*tex context code for |\localrightbox| (not used) */
- middle_box_flag = 010000000000 + 2 * biggest_reg + 3, /*tex context code for |\localrightbox| (not used) */
- shipout_flag = 010000000000 + 2 * biggest_reg + 4, /*tex context code for |\shipout| */
- lua_scan_flag = 010000000000 + 2 * biggest_reg + 5, /*tex context code for |scan_list| */
- a_leaders_flag = 010000000000 + 2 * biggest_reg + 6, /*tex context code for |\leaders| */
- c_leaders_flag = 010000000000 + 2 * biggest_reg + 7, /*tex context code for |\cleaders| */
- x_leaders_flag = 010000000000 + 2 * biggest_reg + 8, /*tex context code for |\xleaders| */
- g_leaders_flag = 010000000000 + 2 * biggest_reg + 9, /*tex context code for |\gleaders| */
- u_leaders_flag = 010000000000 + 2 * biggest_reg + 10, /*tex context code for |\uleaders| */
+ direct_box_flag = 0x00,
+ /* moved_box_flag = 0x01, */
+ /* vcenter_box_flag = 0x02, */
+ box_flag = 0x02, /*tex context code for |\setbox0| */
+ global_box_flag = 0x03, /*tex context code for |\global\setbox0| */
+ left_box_flag = 0x04, /*tex context code for |\localleftbox| */
+ right_box_flag = 0x05, /*tex context code for |\localrightbox| */
+ middle_box_flag = 0x06, /*tex context code for |\localrightbox| */
+ shipout_flag = 0x07, /*tex context code for |\shipout| */
+ lua_scan_flag = 0x08, /*tex context code for |scan_list| */
+ a_leaders_flag = 0x09, /*tex context code for |\leaders| */
+ c_leaders_flag = 0x0A, /*tex context code for |\cleaders| */
+ x_leaders_flag = 0x0B, /*tex context code for |\xleaders| */
+ g_leaders_flag = 0x0C, /*tex context code for |\gleaders| */
+ u_leaders_flag = 0x0D, /*tex context code for |\uleaders| */
+
} box_flags;
# define box_leaders_flag(f) (f >= a_leaders_flag && f <= u_leaders_flag)
-extern void tex_begin_box (int boxcontext, scaled shift);
+extern void tex_begin_box (int boxcontext, scaled shift, halfword slot);
extern int tex_ignore_math_skip (halfword p);
# endif
diff --git a/source/luametatex/source/tex/textypes.h b/source/luametatex/source/tex/textypes.h
index 0fa80dd99..12a0aadf9 100644
--- a/source/luametatex/source/tex/textypes.h
+++ b/source/luametatex/source/tex/textypes.h
@@ -170,7 +170,8 @@ extern halfword tex_badness(
# define semi_tight_criterium 12 /* same as |decent_criterium| */
# define default_rule 26214 /*tex 0.4pt */
-# define ignore_depth -65536000 /*tex The magic dimension value to mean \quote {ignore me}. */
+# define ignore_depth -65536000 /*tex The magic dimension value to mean \quote {ignore me}: -1000pt */
+# define ignore_depth_zero_baselineskip -131072000 /*tex Idem but keep zero skip: -2000pt */
# define min_quarterword 0 /*tex The smallest allowable value in a |quarterword|. */
# define max_quarterword 65535 /*tex The largest allowable value in a |quarterword|. */