summaryrefslogtreecommitdiff
path: root/source/luametatex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2023-01-05 20:22:55 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2023-01-05 20:22:55 +0100
commit659b8f28e591006b6d0669c05d809d6ccf60cec0 (patch)
tree287a360fe83cfb90ccf7507c46022771fc11da4e /source/luametatex
parent705b807c950a697d3c8be592c452a6fb3e561c7e (diff)
downloadcontext-659b8f28e591006b6d0669c05d809d6ccf60cec0.tar.gz
2023-01-05 17:46:00
Diffstat (limited to 'source/luametatex')
-rw-r--r--source/luametatex/source/luarest/lmtbasexxlib.c2
-rw-r--r--source/luametatex/source/tex/texmaincontrol.c17
-rw-r--r--source/luametatex/source/tex/texmath.c64
3 files changed, 32 insertions, 51 deletions
diff --git a/source/luametatex/source/luarest/lmtbasexxlib.c b/source/luametatex/source/luarest/lmtbasexxlib.c
index fca7fcef8..9a723060e 100644
--- a/source/luametatex/source/luarest/lmtbasexxlib.c
+++ b/source/luametatex/source/luarest/lmtbasexxlib.c
@@ -14,7 +14,7 @@
First I had a mix of own code and LHF code (base64 and base85) but in the end I decided to reuse
some of pplibs code. Performance is ok, although we can speed up the base16 coders. When needed,
- we can have a few more bur normally pure \LUA\ is quite ok for our purpose.
+ we can have a few more but normally pure \LUA\ is quite ok for our purpose.
*/
diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c
index a5f3b5334..8b9250444 100644
--- a/source/luametatex/source/tex/texmaincontrol.c
+++ b/source/luametatex/source/tex/texmaincontrol.c
@@ -3487,8 +3487,8 @@ static int tex_aux_valid_arithmic(int cmd, int *index, int *level, int *varcmd,
*original = eq_value(*index);
return 1;
case register_cmd:
- *index = tex_aux_get_register_index(*level);
*level = cur_chr;
+ *index = tex_aux_get_register_index(cur_chr);
*original = eq_value(*index);
return 1;
case integer_cmd:
@@ -3603,30 +3603,30 @@ static void tex_aux_arithmic_register(int a, int code)
halfword original = 0;
if (tex_aux_valid_arithmic(cmd, &index, &level, &varcmd, &simple, &original)) {
halfword value = null;
- lmt_scanner_state.arithmic_error = 0;
+ // lmt_scanner_state.arithmic_error = 0;
switch (code) {
case advance_code:
tex_scan_optional_keyword("by");
case advance_by_code:
{
- value = tex_aux_get_register_value(level, 0);
+ halfword amount = tex_aux_get_register_value(level, 0);
switch (level) {
case int_val_level:
case attr_val_level:
case dimen_val_level:
- if (value) {
- value += original;
+ if (amount) {
+ value = original + amount;
break;
} else {
return;
}
case glue_val_level:
case mu_val_level:
- if (tex_glue_is_zero(value)) {
+ if (tex_glue_is_zero(amount)) {
return;
} else {
/* Compute the sum of two glue specs */
- halfword newvalue = tex_new_glue_spec_node(value);
+ halfword newvalue = tex_new_glue_spec_node(amount);
tex_flush_node(value);
glue_amount(newvalue) += glue_amount(original);
if (glue_stretch(newvalue) == 0) {
@@ -3667,9 +3667,11 @@ static void tex_aux_arithmic_register(int a, int code)
case multiply_by_code:
{
halfword amount = tex_scan_int(0, NULL);
+ halfword value = 0;
if (amount == 1) {
return;
} else {
+ lmt_scanner_state.arithmic_error = 0;
switch (level) {
case int_val_level:
case attr_val_level:
@@ -3710,6 +3712,7 @@ static void tex_aux_arithmic_register(int a, int code)
if (amount == 1) {
return;
} else {
+ lmt_scanner_state.arithmic_error = 0;
switch (level) {
case int_val_level:
case attr_val_level:
diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c
index 134399c53..d2c0ff413 100644
--- a/source/luametatex/source/tex/texmath.c
+++ b/source/luametatex/source/tex/texmath.c
@@ -1233,7 +1233,7 @@ static void tex_aux_push_math(quarterword group, int style)
update_tex_math_right_class(unset_noad_class);
}
-static void tex_aux_enter_ordinary_math(int style)
+static void tex_aux_enter_inline_math(int style)
{
tex_aux_push_math(math_shift_group, style);
update_tex_family(0, unused_math_family);
@@ -1264,16 +1264,16 @@ void tex_run_math_initialize(void)
tex_aux_enter_display_math(math_shift_cmd);
} else {
tex_back_input(cur_tok);
- tex_aux_enter_ordinary_math(text_style);
+ tex_aux_enter_inline_math(text_style);
}
break;
case math_shift_cs_cmd:
if (cur_chr == begin_math_mode_code) {
- tex_aux_enter_ordinary_math(tex_scan_math_style_identifier(0, 0));
+ tex_aux_enter_inline_math(tex_scan_math_style_identifier(0, 0));
} else if (cur_chr == begin_display_math_code && cur_list.mode > nomode) {
tex_aux_enter_display_math(begin_display_math_code);
} else if (cur_chr == begin_inline_math_code) {
- tex_aux_enter_ordinary_math(text_style);
+ tex_aux_enter_inline_math(text_style);
} else {
tex_you_cant_error("math shift 1");
}
@@ -1298,7 +1298,7 @@ void tex_run_math_equation_number(void) {
if (cur_group == math_shift_group) {
tex_set_saved_record(saved_equation_number_item_location, equation_number_location_save_type, 0, cur_chr);
lmt_save_state.save_stack_data.ptr += saved_equation_number_n_of_items;
- tex_aux_enter_ordinary_math(text_style);
+ tex_aux_enter_inline_math(text_style);
} else {
tex_off_save();
}
@@ -4285,49 +4285,26 @@ static void tex_aux_resume_after_display(void)
*/
-inline static void tex_aux_inject_display_skip_before(quarterword param, quarterword subtype)
+static void tex_aux_inject_display_skip(quarterword param, quarterword subtype)
{
if (param > 0) {
switch (display_skip_mode_par) {
case display_skip_default :
case display_skip_always :
- tex_tail_append(tex_new_param_glue_node(param, subtype));
break;
case display_skip_non_zero:
- if (! tex_glue_is_zero(glue_parameter(param))) {
- tex_tail_append(tex_new_param_glue_node(param, subtype));
- }
- break;
- case display_skip_ignore:
- break;
- default:
- /*tex > 3 reserved for future use */
- tex_tail_append(tex_new_param_glue_node(param, subtype));
- break;
- }
- }
-}
-
-inline static void tex_aux_inject_display_skip_after(quarterword param, quarterword subtype)
-{
- if (param > 0) {
- switch (display_skip_mode_par) {
- case display_skip_default :
- case display_skip_always :
- tex_tail_append(tex_new_param_glue_node(param, subtype));
- break;
- case display_skip_non_zero:
- if (! tex_glue_is_zero(glue_parameter(param))) {
- tex_tail_append(tex_new_param_glue_node(param, subtype));
+ if (tex_glue_is_zero(glue_parameter(param))) {
+ return;
+ } else {
+ break;
}
- break;
case display_skip_ignore:
- break;
+ return;
default:
/*tex > 3 reserved for future use */
- tex_tail_append(tex_new_param_glue_node(param, subtype));
break;
}
+ tex_tail_append(tex_new_param_glue_node(param, subtype));
}
}
@@ -4478,7 +4455,7 @@ static void tex_aux_finish_displayed_math(int atleft, halfword eqnumber, halfwor
tex_append_to_vlist(eqnumber, lua_key_index(equation_number), NULL);
tex_tail_append(tex_new_penalty_node(infinite_penalty, equation_number_penalty_subtype));
} else {
- tex_aux_inject_display_skip_before(glue_above, subtype_above);
+ tex_aux_inject_display_skip(glue_above, subtype_above);
}
if (number_width != 0) {
scaled shift = line_width - equation_width - number_width - displacement;
@@ -4542,7 +4519,7 @@ static void tex_aux_finish_displayed_math(int atleft, halfword eqnumber, halfwor
box_shift_amount(equation_box) = indent + displacement;
}
/*tex check for prev: */
- tex_append_to_vlist(equation_box, lua_key_index(equation), NULL);
+ tex_append_to_vlist(equation_box, lua_key_index(equation), NULL); /* eqbox has the formula */
if (eqnumber && number_width == 0 && ! atleft) {
tex_tail_append(tex_new_penalty_node(infinite_penalty, equation_number_penalty_subtype));
/* if (math_direction_par == dir_lefttoright) { */
@@ -4575,7 +4552,7 @@ static void tex_aux_finish_displayed_math(int atleft, halfword eqnumber, halfwor
cur_list.tail = pre_migrate_tail;
}
tex_tail_append(tex_new_penalty_node(post_display_penalty_par, after_display_penalty_subtype));
- tex_aux_inject_display_skip_after(glue_below, subtype_below);
+ tex_aux_inject_display_skip(glue_below, subtype_below);
tex_aux_resume_after_display();
}
@@ -4591,7 +4568,8 @@ static void tex_aux_finish_displayed_math(int atleft, halfword eqnumber, halfwor
*/
-void tex_run_math_shift(void) {
+void tex_run_math_shift(void)
+{
if (cur_group == math_shift_group) {
/*tex box containing equation number */
halfword eqnumber = null;
@@ -4613,7 +4591,7 @@ void tex_run_math_shift(void) {
break;
}
}
- if (cur_list.mode == -mode) {
+ if (cur_list.mode == -mode) { // todo: symbolic
/*tex end of equation number */
AGAIN:
switch (cur_cmd) {
@@ -4641,7 +4619,7 @@ void tex_run_math_shift(void) {
tex_confusion("after math");
}
}
- if (mode < 0) {
+ if (mode < 0) { // mode == inline_mmode
/*tex
The |unsave| is done after everything else here; hence an appearance of |\mathsurround|
@@ -4780,13 +4758,13 @@ void tex_finish_display_alignment(halfword head, halfword tail, halfword prevdep
}
tex_pop_nest();
tex_tail_append(tex_new_penalty_node(pre_display_penalty_par, before_display_penalty_subtype));
- tex_aux_inject_display_skip_before(above_display_skip_code, above_display_skip_glue);
+ tex_aux_inject_display_skip(above_display_skip_code, above_display_skip_glue);
node_next(cur_list.tail) = head;
if (head && tail) {
cur_list.tail = tail;
}
tex_tail_append(tex_new_penalty_node(post_display_penalty_par, after_display_penalty_subtype));
- tex_aux_inject_display_skip_after(below_display_skip_code, below_display_skip_glue);
+ tex_aux_inject_display_skip(below_display_skip_code, below_display_skip_glue);
cur_list.prev_depth = prevdepth;
tex_aux_resume_after_display();
}