diff options
Diffstat (limited to 'source/luametatex/source/tex/texconditional.c')
-rw-r--r-- | source/luametatex/source/tex/texconditional.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/source/luametatex/source/tex/texconditional.c b/source/luametatex/source/tex/texconditional.c index 925e9fac9..9cbdeed2b 100644 --- a/source/luametatex/source/tex/texconditional.c +++ b/source/luametatex/source/tex/texconditional.c @@ -41,13 +41,17 @@ condition_state_info lmt_condition_state = { .cond_ptr = null, - .if_limit = 0, .cur_if = 0, + .cur_unless = 0, + .if_step = 0, + .if_unless = 0, + .if_limit = 0, .if_line = 0, .skip_line = 0, .chk_num = 0, .chk_dim = 0, .if_nesting = 0, + .padding = 0, }; /*tex @@ -89,9 +93,8 @@ static void tex_aux_pass_text(void) } case or_else_code: case or_unless_code: - do { - tex_get_next(); - } while (cur_cmd == spacer_cmd); + tex_get_next_non_spacer(); + /*tex So we skip the token after |\orelse| or |\orunless| without testing it! */ break; default: ++level; @@ -143,9 +146,7 @@ static int tex_aux_pass_text_x(int tracing_ifs, int tracing_commands) } else if (tracing_ifs) { tex_show_cmd_chr(cur_cmd, cur_chr); } - do { - tex_get_next(); - } while (cur_cmd == spacer_cmd); + tex_get_next_non_spacer(); if (lmt_condition_state.if_limit == if_code) { if (cur_cmd == if_test_cmd && cur_chr >= first_real_if_test_code) { goto OKAY; @@ -218,6 +219,11 @@ static void tex_aux_if_warning(void) } } +/*tex + We can consider a dedicated condition stack so that we can copy faster. Or we can just emulate + an if node in |lmt_condition_state|. +*/ + static void tex_aux_push_condition_stack(int code, int unless) { halfword p = tex_get_node(if_node_size); @@ -591,13 +597,13 @@ void tex_conditional_if(halfword code, int unless) result = odd(tex_scan_int(0, NULL)); goto RESULT; case if_vmode_code: - result = abs(cur_list.mode) == vmode; + result = is_v_mode(cur_list.mode); goto RESULT; case if_hmode_code: - result = abs(cur_list.mode) == hmode; + result = is_h_mode(cur_list.mode); goto RESULT; case if_mmode_code: - result = abs(cur_list.mode) == mmode; + result = is_m_mode(cur_list.mode); goto RESULT; case if_inner_code: result = cur_list.mode < nomode; @@ -1216,7 +1222,6 @@ void tex_conditional_if(halfword code, int unless) } else { /*tex Wait for |\fi|. */ //lmt_condition_state.if_step = code; - lmt_condition_state.if_limit = fi_code; } } @@ -1234,9 +1239,7 @@ void tex_conditional_fi_or_else(void) tex_show_cmd_chr(if_test_cmd, cur_chr); } if (cur_chr == or_else_code || cur_chr == or_unless_code) { - do { - tex_get_next(); - } while (cur_cmd == spacer_cmd); + tex_get_next_non_spacer(); } else if (cur_chr > lmt_condition_state.if_limit) { if (lmt_condition_state.if_limit == if_code) { /*tex |