diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2021-12-31 10:38:50 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2021-12-31 10:38:50 +0000 |
commit | cb71b62afd23fc35a04304858ee2d221b8a51dcb (patch) | |
tree | 17511b8aa9976f8420b25c24dc1060b65074257c /Build/source/texk/web2c/luatexdir/tex/maincontrol.c | |
parent | c46a6d281af96d35e0b0efa75a7aafac88677a8a (diff) |
sync luatex with upstream r7476.
git-svn-id: svn://tug.org/texlive/trunk@61453 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/tex/maincontrol.c')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/maincontrol.c | 207 |
1 files changed, 142 insertions, 65 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.c b/Build/source/texk/web2c/luatexdir/tex/maincontrol.c index 9aec6c12ff4..f72659c5064 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.c +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.c @@ -463,8 +463,16 @@ static void run_start_par (void) { } static void run_new_graf (void) { - back_input(); - new_graf(true); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (cur_cmd == valign_cmd && partoken_context_code_par > 0 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + back_input(); + new_graf(true); + } } /*tex @@ -607,6 +615,14 @@ static void run_after_group (void) { save_for_after(cur_tok); } +static void run_par_token (void) { + get_token(); + if (cur_cs > 0) { + par_loc = cur_cs; + par_token = cur_tok; + } +} + static void run_extension (void) { do_extension(0); } @@ -976,6 +992,7 @@ static void init_main_control (void) { any_mode(set_interaction_cmd, prefixed_command); any_mode(after_assignment_cmd,run_after_assignment); any_mode(after_group_cmd,run_after_group); + any_mode(partoken_name_cmd,run_par_token); any_mode(in_stream_cmd,open_or_close_in); any_mode(message_cmd,issue_message); any_mode(case_shift_cmd, shift_case); @@ -1272,7 +1289,7 @@ void report_illegal_case(void) you_cant(); help4( "Sorry, but I'm not programmed to handle this case;", - "I'll just pretend that you didn''t ask for it.", + "I'll just pretend that you didn't ask for it.", "If you're in the wrong mode, you might be able to", "return to the right one by typing `I}' or `I$' or `I\\par'." ); @@ -1459,10 +1476,14 @@ deal with such errors. void handle_right_brace(void) { - halfword p, q; /* for short-term use */ - scaled d; /* holds |split_max_depth| in |insert_group| */ - int f; /* holds |floating_penalty| in |insert_group| */ + halfword p, q; /* for short-term use */ + scaled d; /* holds |split_max_depth| in |insert_group| */ + int f; /* holds |floating_penalty| in |insert_group| */ p = null; + /* + The |partoken_context_code_par| branch is taken from pdftex as-is. We could save some lines + by first testing for hmode and the parameter but in the end it's not cleaner. + */ switch (cur_group) { case simple_group: fixup_directions(); @@ -1502,57 +1523,89 @@ void handle_right_brace(void) package(0); break; case vbox_group: - end_graf(vbox_group); - package(0); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 0 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + end_graf(vbox_group); + package(0); + } break; case vtop_group: - end_graf(vtop_group); - package(vtop_code); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 0 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + end_graf(vtop_group); + package(vtop_code); + } break; case insert_group: - end_graf(insert_group); - q = new_glue(split_top_skip_par); - d = split_max_depth_par; - f = floating_penalty_par; - unsave(); - save_ptr--; - /*tex - Now |saved_value(0)| is the insertion number, or the |vadjust| subtype. - */ - p = vpack(vlink(head), 0, additional, -1); - pop_nest(); - if (saved_type(0) == saved_insert) { - tail_append(new_node(ins_node, saved_value(0))); - height(tail) = height(p) + depth(p); - ins_ptr(tail) = list_ptr(p); - split_top_ptr(tail) = q; - depth(tail) = d; - float_cost(tail) = f; - } else if (saved_type(0) == saved_adjust) { - tail_append(new_node(adjust_node, saved_value(0))); - adjust_ptr(tail) = list_ptr(p); - flush_node(q); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 1 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; } else { - confusion("insert_group"); - } - list_ptr(p) = null; - flush_node(p); - if (nest_ptr == 0) { - checked_page_filter(insert); - build_page(); + end_graf(insert_group); + q = new_glue(split_top_skip_par); + d = split_max_depth_par; + f = floating_penalty_par; + unsave(); + save_ptr--; + /*tex + Now |saved_value(0)| is the insertion number, or the |vadjust| subtype. + */ + p = vpack(vlink(head), 0, additional, -1); + pop_nest(); + if (saved_type(0) == saved_insert) { + tail_append(new_node(ins_node, saved_value(0))); + height(tail) = height(p) + depth(p); + ins_ptr(tail) = list_ptr(p); + split_top_ptr(tail) = q; + depth(tail) = d; + float_cost(tail) = f; + } else if (saved_type(0) == saved_adjust) { + tail_append(new_node(adjust_node, saved_value(0))); + adjust_ptr(tail) = list_ptr(p); + flush_node(q); + } else { + confusion("insert_group"); + } + list_ptr(p) = null; + flush_node(p); + if (nest_ptr == 0) { + checked_page_filter(insert); + build_page(); + } } break; case output_group: - /*tex - this is needed in case the \.{\\output} executes a \.{\\textdir} command. - */ - if (dir_level(text_dir_ptr) == cur_level) { - /*tex Remove from |text_dir_ptr| */ - halfword text_dir_tmp = vlink(text_dir_ptr); - flush_node(text_dir_ptr); - text_dir_ptr = text_dir_tmp; + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 1 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + /*tex + this is needed in case the \.{\\output} executes a \.{\\textdir} command. + */ + if (dir_level(text_dir_ptr) == cur_level) { + /*tex Remove from |text_dir_ptr| */ + halfword text_dir_tmp = vlink(text_dir_ptr); + flush_node(text_dir_ptr); + text_dir_ptr = text_dir_tmp; + } + resume_after_output(); } - resume_after_output(); break; case disc_group: build_discretionary(); @@ -1570,13 +1623,29 @@ void handle_right_brace(void) ins_error(); break; case no_align_group: - end_graf(no_align_group); - unsave(); - align_peek(); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 1 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + end_graf(no_align_group); + unsave(); + align_peek(); + } break; case vcenter_group: - end_graf(vcenter_group); - finish_vcenter(); + /* the |partoken_context_code_par| branch is taken from pdftex as-is: */ + if (partoken_context_code_par > 0 && mode == hmode) { + back_input(); + cur_tok = par_token; + back_input(); + token_type = inserted; + } else { + end_graf(vcenter_group); + finish_vcenter(); + } break; case math_choice_group: build_choices(); @@ -1873,13 +1942,29 @@ displays. */ +static int only_dirs(halfword n) +{ + while (n) { + if (type(n) == local_par_node || type(n) == dir_node) { + n = vlink(n); + } else { + return 0; + } + } + return 1; +} + void end_graf(int line_break_context) { if (mode == hmode) { - if ((head == tail) || (vlink(head) == tail)) { - if (vlink(head) == tail) - flush_node(vlink(head)); - /*tex |null| paragraphs are ignored, all contain a |local_paragraph| node */ + /*tex + We ignore |null| paragraphs, that is those that only have a local par node + and possibly a few dir nodes injected automatically. + */ + if (head == tail) { + pop_nest(); + } else if (only_dirs(vlink(head))) { + flush_node(vlink(head)); pop_nest(); } else { line_break(false, line_break_context); @@ -3968,10 +4053,6 @@ void show_whatever(void) int m; /* upper bound on |fi_or_else| codes */ int l; /* line where that conditional began */ int n; /* level of \.{\\if...\\fi} nesting */ - int saved_selector; /* previous selector. Must be distinct from the global err_old_setting. */ - saved_selector = selector; - if (file_can_be_written(show_stream_par)) - selector = show_stream_par; switch (cur_chr) { case show_lists: begin_diagnostic(); @@ -4066,10 +4147,6 @@ void show_whatever(void) } } COMMON_ENDING: - if (valid_write_file(selector)) { - selector = saved_selector; - return; - } if (interaction < error_stop_mode) { help0(); decr(error_count); |