diff options
Diffstat (limited to 'source/luametatex/source/tex')
-rw-r--r-- | source/luametatex/source/tex/texmlist.c | 4 | ||||
-rw-r--r-- | source/luametatex/source/tex/texscanning.c | 68 | ||||
-rw-r--r-- | source/luametatex/source/tex/textoken.h | 1 |
3 files changed, 46 insertions, 27 deletions
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 */ |