summaryrefslogtreecommitdiff
path: root/source/luametatex/source/tex
diff options
context:
space:
mode:
Diffstat (limited to 'source/luametatex/source/tex')
-rw-r--r--source/luametatex/source/tex/texalign.c12
-rw-r--r--source/luametatex/source/tex/texcommands.c2
-rw-r--r--source/luametatex/source/tex/texdumpdata.h2
-rw-r--r--source/luametatex/source/tex/texmainbody.c7
-rw-r--r--source/luametatex/source/tex/texnesting.c2
-rw-r--r--source/luametatex/source/tex/texpackaging.c241
-rw-r--r--source/luametatex/source/tex/texpackaging.h15
-rw-r--r--source/luametatex/source/tex/textoken.c10
8 files changed, 175 insertions, 116 deletions
diff --git a/source/luametatex/source/tex/texalign.c b/source/luametatex/source/tex/texalign.c
index f35bb50b5..46d3153cf 100644
--- a/source/luametatex/source/tex/texalign.c
+++ b/source/luametatex/source/tex/texalign.c
@@ -287,7 +287,6 @@ static alignment_state_info lmt_alignment_state = {
static void tex_aux_wipe_row_state(void)
{
- delete_attribute_reference(lmt_alignment_state.row_state.attrlist);
lmt_alignment_state.row_state.attrlist = null;
lmt_alignment_state.row_state.orientation = 0;
lmt_alignment_state.row_state.xoffset = 0;
@@ -619,7 +618,7 @@ static void tex_aux_scan_align_spec(quarterword c)
if (! attrlist) {
/* this alse sets the reference when not yet set */
attrlist = tex_current_attribute_list();
- }
+ }
/*tex Now we're referenced. We need to preserve this over the group. */
add_attribute_reference(attrlist);
tex_set_saved_record(saved_align_specification, box_spec_save_type, mode, amount);
@@ -693,6 +692,8 @@ static void tex_aux_run_no_align(void)
if (eq_value(register_attribute_location(i)) != v) {
if (lmt_alignment_state.row_state.attrlist) {
lmt_alignment_state.row_state.attrlist = tex_patch_attribute_list(lmt_alignment_state.row_state.attrlist, i, v);
+ } else if (lmt_alignment_state.attr_list) {
+ lmt_alignment_state.row_state.attrlist = tex_copy_attribute_list_set(lmt_alignment_state.attr_list, i, v);
} else {
lmt_alignment_state.row_state.attrlist = tex_copy_attribute_list_set(tex_current_attribute_list(), i, v);
}
@@ -802,11 +803,6 @@ static void tex_aux_run_no_align(void)
}
DONE:
lmt_alignment_state.row_state_set = done;
- if (! lmt_alignment_state.row_state.attrlist) {
- /* this alse sets the reference when not yet set */
- lmt_alignment_state.row_state.attrlist = tex_current_attribute_list();
- }
- add_attribute_reference(lmt_alignment_state.row_state.attrlist);
/* */
if (! brace) {
tex_scan_left_brace();
@@ -2051,6 +2047,8 @@ void tex_cleanup_alignments(void)
tex_put_available_token(lmt_alignment_state.omit_template);
lmt_alignment_state.hold_token_head = null;
lmt_alignment_state.omit_template = null;
+ delete_attribute_reference(lmt_alignment_state.attr_list);
+ lmt_alignment_state.attr_list = null;
}
/*tex
diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c
index 615db76c9..5c8328d52 100644
--- a/source/luametatex/source/tex/texcommands.c
+++ b/source/luametatex/source/tex/texcommands.c
@@ -879,7 +879,9 @@ void tex_initialize_commands(void)
tex_primitive(tex_command, "box", make_box_cmd, box_code, 0);
tex_primitive(tex_command, "copy", make_box_cmd, copy_code, 0);
tex_primitive(tex_command, "lastbox", make_box_cmd, last_box_code, 0);
+ tex_primitive(luatex_command, "tsplit", make_box_cmd, tsplit_code, 0);
tex_primitive(tex_command, "vsplit", make_box_cmd, vsplit_code, 0);
+ tex_primitive(luatex_command, "dsplit", make_box_cmd, dsplit_code, 0);
tex_primitive(luatex_command, "tpack", make_box_cmd, tpack_code, 0);
tex_primitive(luatex_command, "vpack", make_box_cmd, vpack_code, 0);
tex_primitive(luatex_command, "hpack", make_box_cmd, hpack_code, 0);
diff --git a/source/luametatex/source/tex/texdumpdata.h b/source/luametatex/source/tex/texdumpdata.h
index 31d422784..a386ca3ba 100644
--- a/source/luametatex/source/tex/texdumpdata.h
+++ b/source/luametatex/source/tex/texdumpdata.h
@@ -55,7 +55,7 @@
*/
-# define luametatex_format_fingerprint 681
+# define luametatex_format_fingerprint 682
/* These end up in the string pool. */
diff --git a/source/luametatex/source/tex/texmainbody.c b/source/luametatex/source/tex/texmainbody.c
index 57b7d34be..4dd9c37a0 100644
--- a/source/luametatex/source/tex/texmainbody.c
+++ b/source/luametatex/source/tex/texmainbody.c
@@ -374,6 +374,13 @@ void tex_main_body(void)
}
}
+ /*tex
+ We assume that |ignore_depth_criterium_par| is unchanged. If needed we can always do
+ this:
+ */
+
+ /* cur_list.prev_depth = ignore_depth_criterium_par; */
+
/*tex Ready to go, so come to life. */
lmt_error_state.history = spotless;
diff --git a/source/luametatex/source/tex/texnesting.c b/source/luametatex/source/tex/texnesting.c
index f29bfe0a2..4ec68b28b 100644
--- a/source/luametatex/source/tex/texnesting.c
+++ b/source/luametatex/source/tex/texnesting.c
@@ -247,7 +247,7 @@ void tex_initialize_nesting(void)
cur_list.delim = null;
cur_list.prev_graf = 0;
cur_list.mode_line = 0;
- cur_list.prev_depth = ignore_depth_criterium_par;
+ cur_list.prev_depth = ignore_depth; /*tex |ignore_depth_criterium_par| is not yet available! */
cur_list.space_factor = 1000;
cur_list.incomplete_noad = null;
cur_list.direction_stack = null;
diff --git a/source/luametatex/source/tex/texpackaging.c b/source/luametatex/source/tex/texpackaging.c
index 3cea2b7b8..6ad1f5718 100644
--- a/source/luametatex/source/tex/texpackaging.c
+++ b/source/luametatex/source/tex/texpackaging.c
@@ -2312,6 +2312,52 @@ halfword tex_filtered_vpack(halfword p, scaled h, int m, scaled maxdepth, int gr
return q;
}
+static scaled tex_aux_first_height(halfword boxnode)
+{
+ halfword list = box_list(boxnode);
+ if (list) {
+ switch (node_type(list)) {
+ case hlist_node:
+ case vlist_node:
+ return box_height(list);
+ case rule_node:
+ return rule_height(list);
+ }
+ }
+ return 0;
+}
+
+static void tex_aux_set_vnature(halfword boxnode, int nature)
+{
+ switch (nature) {
+ case vtop_code:
+ case tsplit_code:
+ {
+ /*tex
+
+ Read just the height and depth of |boxnode| (|boxnode|), for |\vtop|. The height of
+ a |\vtop| box is inherited from the first item on its list, if that item is an
+ |hlist_node|, |vlist_node|, or |rule_node|; otherwise the |\vtop| height is zero.
+
+ */
+ scaled height = tex_aux_first_height(boxnode);
+ box_depth(boxnode) = box_total(boxnode) - height;
+ box_height(boxnode) = height;
+ box_package_state(boxnode) = vtop_package_state;
+ }
+ break;
+ case vbox_code:
+ case vsplit_code:
+ box_package_state(boxnode) = vbox_package_state;
+ break;
+ case dbox_code:
+ case dsplit_code:
+ box_package_state(boxnode) = dbox_package_state;
+ break;
+ }
+}
+
+
/*tex
Here we always start out in l2r mode and without shift. After all we need to be compatible with
how it was before.
@@ -2358,21 +2404,6 @@ void tex_finish_vcenter_group(void)
}
}
-static scaled tex_aux_first_height(halfword boxnode)
-{
- halfword list = box_list(boxnode);
- if (list) {
- switch (node_type(list)) {
- case hlist_node:
- case vlist_node:
- return box_height(list);
- case rule_node:
- return rule_height(list);
- }
- }
- return 0;
-}
-
void tex_package(singleword nature)
{
halfword slot, context, spec, dirptr, attrlist, justpack, orientation, anchor, geometry, source, target, axis, mainclass, state, retain;
@@ -2409,29 +2440,7 @@ void tex_package(singleword nature)
} else {
boxnode = tex_filtered_vpack(node_next(cur_list.head), spec, saved_level(saved_full_spec_item_packaging),
maxdepth, grp, saved_level(saved_full_spec_item_direction), justpack, attrlist, state, retain);
- switch (nature) {
- case vtop_code:
- {
- /*tex
-
- Read just the height and depth of |boxnode| (|boxnode|), for |\vtop|. The height of
- a |\vtop| box is inherited from the first item on its list, if that item is an
- |hlist_node|, |vlist_node|, or |rule_node|; otherwise the |\vtop| height is zero.
-
- */
- scaled height = tex_aux_first_height(boxnode);
- box_depth(boxnode) = box_total(boxnode) - height;
- box_height(boxnode) = height;
- box_package_state(boxnode) = vtop_package_state;
- }
- break;
- case vbox_code:
- box_package_state(boxnode) = vbox_package_state;
- break;
- case dbox_code:
- box_package_state(boxnode) = dbox_package_state;
- break;
- }
+ tex_aux_set_vnature(boxnode, nature);
}
if (dirptr) {
/*tex Adjust back |text_dir_ptr| for |scan_spec| */
@@ -2679,7 +2688,9 @@ void tex_run_unpackage(void)
cur_list.tail = tex_tail_of_node_list(tail);
break;
}
+ case tsplit_code:
case vsplit_code:
+ case dsplit_code:
{
tex_try_couple_nodes(tail, lmt_packaging_state.split_discards_head);
lmt_packaging_state.split_discards_head = null;
@@ -3264,7 +3275,9 @@ void tex_begin_box(int boxcontext, scaled shift, halfword slot)
}
}
break;
+ case tsplit_code:
case vsplit_code:
+ case dsplit_code:
{
/*tex
Split off part of a vertical box, make |boxnode| point to it. Here we deal with
@@ -3274,24 +3287,47 @@ void tex_begin_box(int boxcontext, scaled shift, halfword slot)
halfword mode = packing_exactly ;
halfword index = tex_scan_box_register_number();
halfword size = 0;
- switch (tex_scan_character("utUT", 0, 1, 0)) {
- case 'u': case 'U':
- if (tex_scan_mandate_keyword("upto", 1)) {
- mode = packing_additional;
- size = tex_scan_dimen(0, 0, 0, 0, NULL);
- }
- break;
- case 't': case 'T':
- if (tex_scan_mandate_keyword("to", 1)) {
- mode = packing_exactly ;
- size = tex_scan_dimen(0, 0, 0, 0, NULL);
- }
- break;
- default:
- tex_aux_show_keyword_error("upto|to");
- break;
+ halfword attrlist = null;
+ while (1) {
+ switch (tex_scan_character("adtuvADTUV", 0, 1, 0)) {
+ case 0:
+ goto DONE;
+ case 'a': case 'A':
+ if (tex_scan_mandate_keyword("attr", 1)) {
+ halfword i = tex_scan_attribute_register_number();
+ halfword v = tex_scan_int(1, NULL);
+ if (eq_value(register_attribute_location(i)) != v) {
+ if (attrlist) {
+ attrlist = tex_patch_attribute_list(attrlist, i, v);
+ } else {
+ attrlist = tex_copy_attribute_list_set(tex_current_attribute_list(), i, v);
+ }
+ }
+ }
+ break;
+ case 't': case 'T':
+ if (tex_scan_mandate_keyword("to", 1)) {
+ mode = packing_exactly ;
+ size = tex_scan_dimen(0, 0, 0, 0, NULL);
+ }
+ break;
+ case 'u': case 'U':
+ if (tex_scan_mandate_keyword("upto", 1)) {
+ mode = packing_additional;
+ size = tex_scan_dimen(0, 0, 0, 0, NULL);
+ }
+ break;
+ default:
+ tex_aux_show_keyword_error("attr|upto|to|vbox|vtop|dbox");
+ goto DONE;
+ }
}
+ DONE:
boxnode = tex_vsplit(index, size, mode);
+ tex_aux_set_vnature(boxnode, code);
+ if (attrlist) {
+ tex_attach_attribute_list_attribute(boxnode, attrlist);
+ }
}
break;
case insert_box_code:
@@ -3337,65 +3373,74 @@ void tex_begin_box(int boxcontext, scaled shift, halfword slot)
box. The juggling with codes and addition or subtraction was somewhat messy.
*/
- /* case tpack_code: */
- /* case vpack_code: */
- /* case hpack_code: */
- /* case dpack_code: */
- /* case vtop_code: */
- /* case vbox_code: */
- /* case hbox_code: */
- /* case dbox_code: */
default:
{
- int just_pack = 0;
- quarterword spec_direction = direction_unknown;
- /*tex 0 or |vmode| or |hmode| */
- halfword mode; /* todo */
+ quarterword direction;
+ int justpack = 0;
+ int group = vbox_group;
+ int mode = vmode;
+ int adjusted = 0;
+ switch (abs(cur_list.mode)) {
+ case vmode:
+ direction = dir_lefttoright;
+ if (boxcontext == direct_box_flag) {
+ adjusted = 1;
+ }
+ break;
+ case hmode:
+ direction = (singleword) text_direction_par;
+ break;
+ case mmode:
+ direction = (singleword) math_direction_par;
+ break;
+ default:
+ direction = direction_unknown;
+ break;
+ }
switch (code) {
case tpack_code:
- code = vtop_code;
- just_pack = 1;
+ // mode = vmode;
+ justpack = 1;
+ group = vtop_group;
break;
case vpack_code:
- code = vtop_code + vmode;
- just_pack = 1;
+ // mode = vmode;
+ justpack = 1;
+ // group = vbox_group;
break;
case hpack_code:
- code = vtop_code + hmode;
- just_pack = 1;
+ mode = hmode;
+ justpack = 1;
+ group = adjusted ? adjusted_hbox_group : hbox_group;
break;
case dpack_code:
- code = dbox_code + hmode;
- just_pack = 1;
+ // mode = vmode;
+ justpack = 1;
+ group = dbox_group;
break;
- }
- mode = code - vtop_code;
- switch (abs(cur_list.mode)) {
- case vmode:
- spec_direction = dir_lefttoright;
+ case vtop_code:
+ // mode = vmode;
+ // justpack = 0;
+ group = vtop_group;
break;
- case hmode:
- spec_direction = (singleword) text_direction_par;
+ case vbox_code:
+ // mode = vmode;
+ // justpack = 0;
+ // group = vbox_group;
break;
- case mmode:
- spec_direction = (singleword) math_direction_par;
+ case hbox_code:
+ mode = hmode;
+ // justpack = 0;
+ group = adjusted ? adjusted_hbox_group : hbox_group;
+ break;
+ case dbox_code:
+ // mode = vmode;
+ // justpack = 0;
+ group = dbox_group;
break;
}
- if (mode == hmode) {
- 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(boxcontext, hbox_group, spec_direction, just_pack, shift, slot);
- }
- } else {
- if (mode == vmode) {
- tex_aux_scan_full_spec(boxcontext, vbox_group, spec_direction, just_pack, shift, slot);
- } else {
- 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);
- }
+ tex_aux_scan_full_spec(boxcontext, group, direction, justpack, shift, slot);
+ tex_normal_paragraph(vmode_par_context);
tex_push_nest();
update_tex_internal_dir_state(0);
cur_list.mode = - mode;
diff --git a/source/luametatex/source/tex/texpackaging.h b/source/luametatex/source/tex/texpackaging.h
index 8cef36619..dea884d0f 100644
--- a/source/luametatex/source/tex/texpackaging.h
+++ b/source/luametatex/source/tex/texpackaging.h
@@ -23,15 +23,18 @@ typedef enum box_codes {
copy_code, /*tex |chr_code| for |\copy| */
unpack_code,
last_box_code, /*tex |chr_code| for |\lastbox| */
+ tsplit_code,
vsplit_code, /*tex |chr_code| for |\vsplit| */
- tpack_code,
- vpack_code,
- hpack_code,
+ dsplit_code,
+ /* hsplit_code, */
+ tpack_code,
+ vpack_code, /*tex |chr_code| for |\vpack| */
dpack_code,
- vtop_code, /*tex |chr_code| for |\vtop| */
- vbox_code,
- hbox_code,
+ hpack_code,
+ vtop_code,
+ vbox_code, /*tex |chr_code| for |\vbox| */
dbox_code,
+ hbox_code,
insert_box_code,
insert_copy_code,
local_left_box_box_code,
diff --git a/source/luametatex/source/tex/textoken.c b/source/luametatex/source/tex/textoken.c
index 7a30b97eb..79e2e5e64 100644
--- a/source/luametatex/source/tex/textoken.c
+++ b/source/luametatex/source/tex/textoken.c
@@ -480,15 +480,19 @@ void tex_print_meaning(halfword code)
tex_print_cs(cur_cs);
return;
} else {
- if (cur_chr && get_token_reference(cur_chr) == max_token_reference) {
- tex_print_str("constant ");
- }
+ int constant = (cur_chr && get_token_reference(cur_chr) == max_token_reference);
switch (code) {
case meaning_code:
case meaning_full_code:
+ if (constant) {
+ tex_print_str("constant ");
+ }
tex_print_str("macro");
goto FOLLOWUP;
case meaning_asis_code:
+ if (constant) {
+ tex_print_str_esc("constant ");
+ }
// tex_print_format("%e%C %S ", def_cmd, def_code, cur_cs);
tex_print_cmd_chr(def_cmd, def_code);
tex_print_char(' ');