summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2023-02-14 18:21:35 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2023-02-14 18:21:35 +0100
commitcd404631d7079a9af603d173eb015f026731aa01 (patch)
tree588c6c8e860bb26955999dfc8be67eb78cc7ff7f /source
parentd643b65f7ab840157f538914b07f8d3cddf94bec (diff)
downloadcontext-cd404631d7079a9af603d173eb015f026731aa01.tar.gz
2023-02-14 17:44:00
Diffstat (limited to 'source')
-rw-r--r--source/luametatex/source/lua/lmtnodelib.c8
-rw-r--r--source/luametatex/source/lua/lmttokenlib.c5
-rw-r--r--source/luametatex/source/luametatex.h7
-rw-r--r--source/luametatex/source/tex/texmlist.c4
-rw-r--r--source/luametatex/source/tex/texscanning.c68
-rw-r--r--source/luametatex/source/tex/textoken.h1
6 files changed, 62 insertions, 31 deletions
diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c
index 6a07e3454..72b9918e4 100644
--- a/source/luametatex/source/lua/lmtnodelib.c
+++ b/source/luametatex/source/lua/lmtnodelib.c
@@ -5321,15 +5321,19 @@ static int nodelib_direct_patchattributes(lua_State *L)
return 0;
}
+/* firstnode attributeid [nodetype] */
+
static int nodelib_direct_findattribute(lua_State *L) /* returns attr value and node */
{
halfword c = nodelib_valid_direct_from_index(L, 1);
if (c) {
halfword i = lmt_tohalfword(L, 2);
+ halfword t = lmt_optinteger(L, 3, -1);
while (c) {
- if (tex_nodetype_has_attributes(node_type(c))) {
+ if ((t < 0 || node_type(c) == t) && tex_nodetype_has_attributes(node_type(c))) {
halfword p = node_attr(c);
if (p) {
+ /* we could skip if the previous value is the same and didn't match */
p = node_next(p);
while (p) {
if (attribute_index(p) == i) {
@@ -5757,6 +5761,8 @@ static int nodelib_direct_traversechar(lua_State *L)
}
}
+/* maybe a variant that checks for an attribute */
+
static int nodelib_direct_aux_next_glyph(lua_State *L)
{
halfword t;
diff --git a/source/luametatex/source/lua/lmttokenlib.c b/source/luametatex/source/lua/lmttokenlib.c
index dcd17b53e..5259a1478 100644
--- a/source/luametatex/source/lua/lmttokenlib.c
+++ b/source/luametatex/source/lua/lmttokenlib.c
@@ -3797,6 +3797,7 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_integer_code:
{
+ /* expects valid integer, no double */
*value = lua_type(L, -1) == LUA_TNUMBER ? lmt_tohalfword(L, -1) : 0;
if (*value < - max_integer) {
*value = max_integer;
@@ -3807,6 +3808,7 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_cardinal_code:
{
+ /* expects valid integer, no double */
lua_Unsigned u = lua_type(L, -1) == LUA_TNUMBER ? (lua_Unsigned) lua_tointeger(L, -1) : 0;
if (u > max_cardinal) {
u = max_cardinal;
@@ -3820,7 +3822,8 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_dimension_code:
{
- *value = lua_type(L, -1) == LUA_TNUMBER ? lmt_tohalfword(L, -1) : 0;
+ /* accepts double and rounds it */
+ *value = lua_type(L, -1) == LUA_TNUMBER ? lmt_roundnumber(L, -1) : 0;
if (*value < - max_dimen) {
*value = max_dimen;
} else if (*value > max_dimen) {
diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h
index c26810396..19175a487 100644
--- a/source/luametatex/source/luametatex.h
+++ b/source/luametatex/source/luametatex.h
@@ -76,12 +76,15 @@
2.09.35 : near the end of 2021 (so close to the 2.10 release date)
2.09.55 : in July 2022 (the official release of the new math engine)
2.10.00 : a few days before the ctx 2022 meeting (starting September 19)
- 2.10.01 : mid October 2022
+ 2.10.01 : mid October 2022 (some more upgrades of the math engine)
+ 2.10.05 : late January 2023
At some point the \CONTEXT\ group will be responsible for guaranteeing that the official version
is what comes with \CONTEXT\ and that long term support and stabilty is guaranteed and that no
feature creep or messing up happens. We'll see.
+ Hans Hagen
+
*/
# include "tex/textypes.h"
@@ -89,7 +92,7 @@
# define luametatex_version 210
# define luametatex_revision 06
# define luametatex_version_string "2.10.06"
-# define luametatex_development_id 20230126
+# define luametatex_development_id 20230209
# define luametatex_name_camelcase "LuaMetaTeX"
# define luametatex_name_lowercase "luametatex"
diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c
index d7c37e47a..8409f8df3 100644
--- a/source/luametatex/source/tex/texmlist.c
+++ b/source/luametatex/source/tex/texmlist.c
@@ -6361,7 +6361,7 @@ static void tex_mlist_to_hlist_preroll_radicals(mliststate *state)
} else if (radical_height(current) < 0) {
box_height(body) += radical_height(current);
if (box_height(body) < 0) {
- box_height(body) += 0;
+ box_height(body) = 0;
}
} else if (radical_height(current)) {
box_height(body) = radical_height(current);
@@ -6371,7 +6371,7 @@ static void tex_mlist_to_hlist_preroll_radicals(mliststate *state)
} else if (radical_depth(current) < 0) {
box_depth(body) += radical_depth(current);
if (box_depth(body) < 0) {
- box_depth(body) += 0;
+ box_depth(body) = 0;
}
} else if (radical_depth(current)) {
box_depth(body) = radical_depth(current);
diff --git a/source/luametatex/source/tex/texscanning.c b/source/luametatex/source/tex/texscanning.c
index 08d5cdaa0..23fc29d1c 100644
--- a/source/luametatex/source/tex/texscanning.c
+++ b/source/luametatex/source/tex/texscanning.c
@@ -3550,7 +3550,7 @@ static void tex_aux_too_many_parameters_error(void)
{
tex_handle_error(
normal_error_type,
- "You already have nine parameters",
+ "You already have 15 parameters",
"I'm going to ignore the # sign you just used, as well the token that followed it.\n"
/*tex That last bit was added in the TeX 2021 buglet fix round. */
);
@@ -3607,7 +3607,9 @@ static void tex_aux_illegal_parameter_in_body_error(void)
\stoptyping
*/
-inline static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfword *hash_brace)
+/* There is no real gain and we get a 1K larger binary: */ /* inline */
+
+static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfword *hash_brace)
{
halfword h = *p;
while (1) {
@@ -3633,9 +3635,9 @@ inline static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfwo
*p = tex_store_new_token(*p, cur_tok);
*p = tex_store_new_token(*p, end_match_token);
set_token_preamble(h, 1);
- set_token_parameters(h, *counter - zero_token);
+ set_token_parameters(h, *counter);
return 1;
- } else if (*counter == F_token_l) {
+ } else if (*counter == 0xF) {
tex_aux_too_many_parameters_error();
} else {
switch (cur_tok) {
@@ -3688,17 +3690,21 @@ inline static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfwo
cur_tok = par_command_match_token;
break;
default:
- ++*counter;
- if (cur_tok != *counter) {
- if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
- *counter += gap_match_count;
+ if (cur_tok >= one_token && cur_tok <= nine_token) {
+ ++*counter;
+ if ((cur_tok - other_token - '0') == *counter) {
+ cur_tok += match_token - other_token ;
+ break;
+ }
+ } else if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
+ ++*counter;
+ if ((cur_tok - letter_token - 'A' - gap_match_count) == *counter) {
cur_tok += match_token - letter_token;
break;
- } else {
- tex_aux_parameters_order_error();
}
}
- cur_tok += match_token - other_token;
+ tex_aux_parameters_order_error();
+ cur_tok = match_token; /* zero */
break;
}
}
@@ -3710,7 +3716,7 @@ inline static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfwo
if (h != *p) {
*p = tex_store_new_token(*p, end_match_token);
set_token_preamble(h, 1);
- set_token_parameters(h, *counter - zero_token);
+ set_token_parameters(h, *counter);
}
if (cur_cmd == right_brace_cmd) {
++lmt_input_state.align_state;
@@ -3724,7 +3730,7 @@ inline static int tex_aux_valid_macro_preamble(halfword *p, int *counter, halfwo
halfword tex_scan_macro_normal(void)
{
halfword hash_brace = 0;
- halfword counter = zero_token;
+ halfword counter = 0;
halfword result = get_reference_token();
halfword p = result;
lmt_input_state.scanner_status = scanner_is_defining;
@@ -3748,16 +3754,22 @@ halfword tex_scan_macro_normal(void)
tex_get_token();
if (cur_cmd == parameter_cmd) {
/*tex Keep the |#|. */
- } else if (cur_tok <= zero_token || cur_tok > counter) {
- if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
- cur_tok = token_val(parameter_reference_cmd, cur_chr - '0' - gap_match_count);
+ } else {
+ halfword n;
+ if (cur_tok >= one_token && cur_tok <= nine_token) {
+ n = cur_chr - '0';
+ } else if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
+ n = cur_chr - '0' - gap_match_count;
+ } else {
+ n = counter + 1;
+ }
+ if (n <= counter) {
+ cur_tok = token_val(parameter_reference_cmd, n);
} else {
tex_aux_illegal_parameter_in_body_error();
cur_tok = s;
}
- } else {
- cur_tok = token_val(parameter_reference_cmd, cur_chr - '0');
- }
+ }
} else if (cur_cmd == prefix_cmd && cur_chr == enforced_code && (! overload_mode_par || lmt_main_state.run_state != production_state)) { /* todo cur_tok == let_aliased_token */
cur_tok = token_val(prefix_cmd, always_code);
}
@@ -3777,7 +3789,7 @@ halfword tex_scan_macro_normal(void)
halfword tex_scan_macro_expand(void)
{
halfword hash_brace = 0;
- halfword counter = zero_token;
+ halfword counter = 0;
halfword result = get_reference_token();
halfword p = result;
lmt_input_state.scanner_status = scanner_is_defining;
@@ -3830,15 +3842,21 @@ halfword tex_scan_macro_expand(void)
tex_get_x_token();
if (cur_cmd == parameter_cmd) {
/*tex Keep the |#|. */
- } else if (cur_tok <= zero_token || cur_tok > counter) {
- if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
- cur_tok = token_val(parameter_reference_cmd, cur_chr - '0' - gap_match_count);
+ } else {
+ halfword n;
+ if (cur_tok >= one_token && cur_tok <= nine_token) {
+ n = cur_chr - '0';
+ } else if (cur_tok >= A_token_l && cur_tok <= F_token_l) {
+ n = cur_chr - '0' - gap_match_count;
+ } else {
+ n = counter + 1;
+ }
+ if (n <= counter) {
+ cur_tok = token_val(parameter_reference_cmd, n);
} else {
tex_aux_illegal_parameter_in_body_error();
cur_tok = s;
}
- } else {
- cur_tok = token_val(parameter_reference_cmd, cur_chr - '0');
}
goto APPENDTOKEN;
}
diff --git a/source/luametatex/source/tex/textoken.h b/source/luametatex/source/tex/textoken.h
index 345c04c23..20885ee66 100644
--- a/source/luametatex/source/tex/textoken.h
+++ b/source/luametatex/source/tex/textoken.h
@@ -213,6 +213,7 @@ extern token_state_info lmt_token_state;
# define left_parent_token (other_token + '(')
# define right_parent_token (other_token + ')')
# define zero_token (other_token + '0') /*tex zero, the smallest digit */
+# define one_token (other_token + '1')
# define five_token (other_token + '5')
# define seven_token (other_token + '7')
# define nine_token (other_token + '9') /*tex zero, the smallest digit */