From d39c2f56a0bdf0ee397e6871bb20b5c75c0ea8cb Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sun, 23 Jan 2022 21:24:49 +0000 Subject: luatex : sync with the upstream git-svn-id: svn://tug.org/texlive/trunk@61717 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/web2c/luatexdir/luatex_svnversion.h | 2 +- Build/source/texk/web2c/luatexdir/tex/commands.c | 1 + Build/source/texk/web2c/luatexdir/tex/dumpdata.c | 2 +- .../source/texk/web2c/luatexdir/tex/equivalents.h | 4 +- Build/source/texk/web2c/luatexdir/tex/texmath.c | 87 +++++++++++++++++++++- Build/source/texk/web2c/luatexdir/tex/texnodes.c | 41 +--------- 6 files changed, 90 insertions(+), 47 deletions(-) diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h index 941c15d7514..ed3bab1f03e 100644 --- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h +++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h @@ -1 +1 @@ -#define luatex_svn_revision 7483 +#define luatex_svn_revision 7484 diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.c b/Build/source/texk/web2c/luatexdir/tex/commands.c index 899e84c3bb7..9cf5efeeec5 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.c +++ b/Build/source/texk/web2c/luatexdir/tex/commands.c @@ -799,6 +799,7 @@ void initialize_etex_commands(void) primitive_luatex("mathnolimitsmode", assign_int_cmd, int_base + math_nolimits_mode_code, int_base); primitive_luatex("mathitalicsmode", assign_int_cmd, int_base + math_italics_mode_code, int_base); primitive_luatex("mathrulesmode", assign_int_cmd, int_base + math_rules_mode_code, int_base); + primitive_luatex("matheqdirmode", assign_int_cmd, int_base + math_eq_dir_mode_code, int_base); primitive_luatex("mathrulesfam", assign_int_cmd, int_base + math_rules_fam_code, int_base); primitive_luatex("synctex", assign_int_cmd, int_base + synctex_code, int_base); diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.c b/Build/source/texk/web2c/luatexdir/tex/dumpdata.c index 0457def2965..fb435c2ca1e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/dumpdata.c +++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.c @@ -32,7 +32,7 @@ with LuaTeX; if not, see . */ -#define FORMAT_ID (907+57) +#define FORMAT_ID (907+58) #if ((FORMAT_ID>=0) && (FORMAT_ID<=256)) #error Wrong value for FORMAT_ID. #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h index ce9ad1f2aaa..8df33be5237 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h @@ -313,8 +313,9 @@ the |number_regs| \.{\\dimen} registers. # define discretionary_ligature_mode_code 120 # define partoken_context_code 121 # define show_stream_code 122 +# define math_eq_dir_mode_code 123 -# define math_option_code 123 +# define math_option_code 124 # define mathoption_int_base_code (math_option_code+1) /* one reserve */ # define mathoption_int_last_code (mathoption_int_base_code+8) @@ -816,6 +817,7 @@ extern halfword last_cs_name; #define fixup_boxes_par int_par(fixup_boxes_code) #define glyph_dimensions_par int_par(glyph_dimensions_code) #define math_defaults_mode_par int_par(math_defaults_mode_code) +#define math_eq_dir_mode_par int_par(math_eq_dir_mode_code) #define discretionary_ligature_mode_par int_par(discretionary_ligature_mode_code) #define partoken_context_code_par int_par(partoken_context_code) diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.c b/Build/source/texk/web2c/luatexdir/tex/texmath.c index ebfb50a804a..01a0657ac83 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.c +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.c @@ -241,10 +241,35 @@ static void unsave_math_fam_data(int gl) static sa_tree math_param_head = NULL; +// void def_math_param(int param_id, int style_id, scaled value, int lvl) +// { +// int n = param_id + (256 * style_id); +// sa_tree_item sa_value = { 0 }; +// sa_value.int_value = (int) value; +// set_sa_item(math_param_head, n, sa_value, lvl); +// if (tracing_assigns_par > 1) { +// begin_diagnostic(); +// tprint("{assigning"); +// print_char(' '); +// print_cmd_chr(set_math_param_cmd, param_id); +// print_cmd_chr(math_style_cmd, style_id); +// print_char('='); +// print_int(value); +// print_char('}'); +// end_diagnostic(false); +// } +// } + void def_math_param(int param_id, int style_id, scaled value, int lvl) { int n = param_id + (256 * style_id); sa_tree_item sa_value = { 0 }; + if (param_id >= math_param_ord_ord_spacing && param_id <= math_param_inner_inner_spacing) { + sa_tree_item ti = get_sa_item(math_param_head, n); + if (ti.int_value > thick_mu_skip_code && valid_node(ti.int_value)) { + free_node(ti.int_value, glue_spec_size); + } + } sa_value.int_value = (int) value; set_sa_item(math_param_head, n, sa_value, lvl); if (tracing_assigns_par > 1) { @@ -266,6 +291,36 @@ scaled get_math_param(int param_id, int style_id) return (scaled) get_sa_item(math_param_head, n).int_value; } +// static void unsave_math_param_data(int gl) +// { +// sa_stack_item st; +// if (math_param_head->stack == NULL) +// return; +// while (math_param_head->stack_ptr > 0 && +// abs(math_param_head->stack[math_param_head->stack_ptr].level) +// >= (int) gl) { +// st = math_param_head->stack[math_param_head->stack_ptr]; +// if (st.level > 0) { +// rawset_sa_item(math_param_head, st.code, st.value); +// /*tex Do a trace message, if requested. */ +// if (tracing_restores_par > 1) { +// int param_id = st.code % 256; +// int style_id = st.code / 256; +// begin_diagnostic(); +// tprint("{restoring"); +// print_char(' '); +// print_cmd_chr(set_math_param_cmd, param_id); +// print_cmd_chr(math_style_cmd, style_id); +// print_char('='); +// print_int(get_math_param(param_id, style_id)); +// print_char('}'); +// end_diagnostic(false); +// } +// } +// (math_param_head->stack_ptr)--; +// } +// } + static void unsave_math_param_data(int gl) { sa_stack_item st; @@ -276,11 +331,17 @@ static void unsave_math_param_data(int gl) >= (int) gl) { st = math_param_head->stack[math_param_head->stack_ptr]; if (st.level > 0) { + int param_id = st.code % 256; + int style_id = st.code / 256; + if (param_id >= math_param_ord_ord_spacing && param_id <= math_param_inner_inner_spacing) { + sa_tree_item ti = get_sa_item(math_param_head, st.code); + if (ti.int_value > thick_mu_skip_code && valid_node(ti.int_value)) { + free_node(ti.int_value, glue_spec_size); + } + } rawset_sa_item(math_param_head, st.code, st.value); /*tex Do a trace message, if requested. */ if (tracing_restores_par > 1) { - int param_id = st.code % 256; - int style_id = st.code / 256; begin_diagnostic(); tprint("{restoring"); print_char(' '); @@ -2437,13 +2498,31 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) d = 0; } tail_append(new_penalty(pre_display_penalty_par,after_display_penalty)); - if ((d + line_s <= pre_display_size_par) || l) { + + /* tex + By default the short skip detection is not adapted to r2l typesetting and that + hasn't been the case since the start of the project. Changing it could break + hacks that users came up with but when you set \.{\\matheqdirmode} to a positive + value direction will be taken into account. + */ + if (math_eq_dir_mode_par<=0) { /* old behavior */ + if ((d + line_s <= pre_display_size_par) || l) { /*tex not enough clearance */ g1 = above_display_skip_code; g2 = below_display_skip_code; - } else { + } else { + g1 = above_display_short_skip_code; + g2 = below_display_short_skip_code; + } + } else { + if ((d + line_s <= pre_display_size_par) || ((! dir_math_save && l) || (dir_math_save && ! l))) { + /*tex not enough clearance */ + g1 = above_display_skip_code; + g2 = below_display_skip_code; + } else { g1 = above_display_short_skip_code; g2 = below_display_short_skip_code; + } } /*tex diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.c b/Build/source/texk/web2c/luatexdir/tex/texnodes.c index 4e645fda976..3b4152364c1 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.c +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.c @@ -33,13 +33,10 @@ LuaTeX; if not, see . */ #define MAX_CHAIN_SIZE 13 /* why not a bit larger */ -#define CHECK_NODE_USAGE 1 /* this triggers checking */ memory_word *volatile varmem = NULL; -#ifdef CHECK_NODE_USAGE - char *varmem_sizes = NULL; -#endif +char *varmem_sizes = NULL; halfword var_mem_max = 0; halfword rover = 0; @@ -1436,13 +1433,9 @@ int lua_properties_use_metatable = 0 ; int valid_node(halfword p) { if (p > my_prealloc && p < var_mem_max) { -#ifdef CHECK_NODE_USAGE if (varmem_sizes[p] > 0) { return 1; } -#else - return 1; -#endif } return 0; } @@ -1476,8 +1469,6 @@ static int test_count = 1; } \ } -#ifdef CHECK_NODE_USAGE - static void check_static_node_mem(void) { dotest(zero_glue, width(zero_glue), 0); @@ -1587,12 +1578,9 @@ static void node_mem_dump(halfword p) } } -#endif - static int free_error(halfword p) { if (p > my_prealloc && p < var_mem_max) { -#ifdef CHECK_NODE_USAGE int i; if (varmem_sizes[p] == 0) { check_static_node_mem(); @@ -1610,7 +1598,6 @@ static int free_error(halfword p) node_mem_dump(p); return 1; } -#endif } else { formatted_error("nodes", "attempt to free an impossible node %d", (int) p); return 1; @@ -1621,7 +1608,6 @@ static int free_error(halfword p) static int copy_error(halfword p) { if (p >= 0 && p < var_mem_max) { -#ifdef CHECK_NODE_USAGE if (p > my_prealloc && varmem_sizes[p] == 0) { if (type(p) == glyph_node) { formatted_warning("nodes", "attempt to copy free glyph (%c) node %d, ignored", (int) character(p), (int) p); @@ -1630,7 +1616,6 @@ static int copy_error(halfword p) } return 1; } -#endif } else { formatted_error("nodes", "attempt to copy an impossible node %d", (int) p); return 1; @@ -2727,9 +2712,7 @@ halfword get_node(int s) r = free_chain[s]; if (r != null) { free_chain[s] = vlink(r); -#ifdef CHECK_NODE_USAGE varmem_sizes[r] = (char) s; -#endif vlink(r) = null; /*tex Maintain usage statistics. */ var_used += s; @@ -2749,9 +2732,7 @@ void free_node(halfword p, int s) formatted_error("nodes", "node number %d of type %d should not be freed", (int) p, type(p)); return; } -#ifdef CHECK_NODE_USAGE varmem_sizes[p] = 0; -#endif if (s < MAX_CHAIN_SIZE) { vlink(p) = free_chain[s]; free_chain[s] = p; @@ -2772,16 +2753,12 @@ static void free_node_chain(halfword q, int s) { register halfword p = q; while (vlink(p) != null) { -#ifdef CHECK_NODE_USAGE varmem_sizes[p] = 0; -#endif var_used -= s; p = vlink(p); } var_used -= s; -#ifdef CHECK_NODE_USAGE varmem_sizes[p] = 0; -#endif vlink(p) = free_chain[s]; free_chain[s] = q; } @@ -2831,13 +2808,11 @@ void init_node_mem(int t) overflow("node memory size", (unsigned) var_mem_max); } memset((void *) (varmem), 0, (unsigned) t * sizeof(memory_word)); -#ifdef CHECK_NODE_USAGE varmem_sizes = (char *) realloc(varmem_sizes, sizeof(char) * (unsigned) t); if (varmem_sizes == NULL) { overflow("node memory size", (unsigned) var_mem_max); } memset((void *) varmem_sizes, 0, sizeof(char) * (unsigned) t); -#endif var_mem_max = t; rover = var_mem_stat_max + 1; vlink(rover) = rover; @@ -2876,9 +2851,7 @@ void dump_node_mem(void) dump_int(var_mem_max); dump_int(rover); dump_things(varmem[0], var_mem_max); -#ifdef CHECK_NODE_USAGE dump_things(varmem_sizes[0], var_mem_max); -#endif dump_things(free_chain[0], MAX_CHAIN_SIZE); dump_int(var_used); dump_int(my_prealloc); @@ -2898,11 +2871,9 @@ void undump_node_mem(void) var_mem_max = (x < 100000 ? 100000 : x); varmem = xmallocarray(memory_word, (unsigned) var_mem_max); undump_things(varmem[0], x); -#ifdef CHECK_NODE_USAGE varmem_sizes = xmallocarray(char, (unsigned) var_mem_max); memset((void *) varmem_sizes, 0, (unsigned) var_mem_max * sizeof(char)); undump_things(varmem_sizes[0], x); -#endif undump_things(free_chain[0], MAX_CHAIN_SIZE); undump_int(var_used); undump_int(my_prealloc); @@ -2941,9 +2912,7 @@ halfword slow_get_node(int s) vlink(rover) += s; } if (vlink(rover) < var_mem_max) { -#ifdef CHECK_NODE_USAGE varmem_sizes[r] = (char) (s > 127 ? 127 : s); -#endif vlink(r) = null; /*tex Maintain usage statistics. */ var_used += s; @@ -2984,13 +2953,11 @@ halfword slow_get_node(int s) overflow("node memory size", (unsigned) var_mem_max); } memset((void *) (varmem + var_mem_max), 0, (unsigned) x * sizeof(memory_word)); -#ifdef CHECK_NODE_USAGE varmem_sizes = (char *) realloc(varmem_sizes, sizeof(char) * (unsigned) (var_mem_max + x)); if (varmem_sizes == NULL) { overflow("node memory size", (unsigned) var_mem_max); } memset((void *) (varmem_sizes + var_mem_max), 0, (unsigned) (x) * sizeof(char)); -#endif /*tex Todo: is it perhaps possible to merge the new memory with an existing rover? */ vlink(var_mem_max) = rover; node_size(var_mem_max) = x; @@ -3011,7 +2978,6 @@ halfword slow_get_node(int s) char *sprint_node_mem_usage(void) { char *s; -#ifdef CHECK_NODE_USAGE char *ss; int i; int b = 0; @@ -3043,16 +3009,12 @@ char *sprint_node_mem_usage(void) b = 1; } } -#else - s = strdup(""); -#endif return s; } halfword list_node_mem_usage(void) { halfword q = null; -#ifdef CHECK_NODE_USAGE halfword p = null; halfword i, j; char *saved_varmem_sizes = xmallocarray(char, (unsigned) var_mem_max); @@ -3069,7 +3031,6 @@ halfword list_node_mem_usage(void) } } free(saved_varmem_sizes); -#endif return q; } -- cgit v1.2.3