diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2019-10-13 17:09:41 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2019-10-13 17:09:41 +0000 |
commit | 378030dd89abc0f2b0d9902dd343d1f2108a202f (patch) | |
tree | 65db6ed6a3bd3124cbb14b3634c3aae2401e5cd2 /Build/source/texk/web2c/luatexdir/lua | |
parent | df16ddc90a200f2c3a5f5724c8ad376a3258c298 (diff) |
sync with upstream luatex rev. 7197
git-svn-id: svn://tug.org/texlive/trunk@52360 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/lnodelib.c | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/ltexlib.c | 99 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luainit.c | 32 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luanode.c | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luatex-api.h | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luatoken.c | 4 |
7 files changed, 129 insertions, 23 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index f0297ae8f51..163906eedf5 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -56,7 +56,7 @@ static const char *const callbacknames[] = { "pre_output_filter", "buildpage_filter", "hpack_filter", "vpack_filter", - "glyph_not_found", + "glyph_not_found", "glyph_info", "hyphenate", "ligaturing", "kerning", diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index dd794827646..d5ab00a5541 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -7581,6 +7581,7 @@ static int lua_nodelib_direct_uses_font(lua_State * L) halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); + return 1; } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); @@ -7598,6 +7599,7 @@ static int lua_nodelib_uses_font(lua_State * L) halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); + return 1; } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index 9dc9350b5c6..5187bc89c01 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -2066,7 +2066,7 @@ static int tex_setmathparm(lua_State * L) } i = luaL_checkoption(L, (n - 2), NULL, math_param_names); j = luaL_checkoption(L, (n - 1), NULL, math_style_names); - if (i<0 && i>=math_param_last) { + if (i < 0 || j < 0) { /* invalid spec, just ignore it */ } else if (i>=math_param_first_mu_glue) { p = lua_touserdata(L, n); @@ -2084,20 +2084,24 @@ static int tex_setmathparm(lua_State * L) static int tex_getmathparm(lua_State * L) { - if ((lua_gettop(L) == 2)) { + if (lua_gettop(L) == 2) { int i = luaL_checkoption(L, 1, NULL, math_param_names); int j = luaL_checkoption(L, 2, NULL, math_style_names); - scaled k = get_math_param(i, j); - if (i<0 && i>=math_param_last) { + if (i < 0 || j < 0) { lua_pushnil(L); - } else if (i>=math_param_first_mu_glue) { - if (k <= thick_mu_skip_code) { - k = glue_par(k); - } - lua_nodelib_push_fast(L, k); } else { - lua_pushinteger(L, k); + scaled k = get_math_param(i, j); + if (i >= math_param_first_mu_glue) { + if (k <= thick_mu_skip_code) { + k = glue_par(k); + } + lua_nodelib_push_fast(L, k); + } else { + lua_pushinteger(L, k); + } } + } else { + lua_pushnil(L); } return 1; } @@ -3483,8 +3487,8 @@ static int runtoks(lua_State * L) if (lua_type(L,1) == LUA_TFUNCTION) { int old_mode = mode; int ref; - pointer r = get_avail(); - pointer t = get_avail(); + halfword r = get_avail(); + halfword t = get_avail(); token_info(r) = token_val(extension_cmd,end_local_code); lua_pushvalue(L, 1); ref = luaL_ref(L,LUA_REGISTRYINDEX); @@ -3502,16 +3506,31 @@ static int runtoks(lua_State * L) mode = old_mode; luaL_unref(L,LUA_REGISTRYINDEX,ref); } else { - int k = get_item_index(L, lua_gettop(L), toks_base); - halfword t = toks(k); + halfword t; + int k = get_item_index(L, 1, toks_base); check_index_range(k, "gettoks"); - if (t != null) { + t = toks(k); + if (! t) { + /* nothing to do */ + } else if ((scanner_status != defining) || (lua_toboolean(L,2))) { + int grouped = lua_toboolean(L,3); int old_mode = mode; - pointer r = get_avail(); - token_info(r) = token_val(extension_cmd,end_local_code); - begin_token_list(r,inserted); - /* new_save_level(semi_simple_group); */ + if (grouped) { + halfword r = get_avail(); + token_info(r) = token_val(right_brace_cmd,0); + begin_token_list(r,inserted); + } + { + halfword r = get_avail(); + token_info(r) = token_val(extension_cmd,end_local_code); + begin_token_list(r,inserted); + } begin_token_list(t,local_text); + if (grouped) { + halfword r = get_avail(); + token_info(r) = token_val(left_brace_cmd,0); + begin_token_list(r,inserted); + } if (luacstrings > 0) { lua_string_start(); } @@ -3522,11 +3541,51 @@ static int runtoks(lua_State * L) local_control(); mode = old_mode; /* unsave(); */ + } else { + halfword q; + halfword p = temp_token_head; + halfword r = token_link(t); + set_token_link(p, null); + while (r) { + fast_store_new_token(token_info(r)); + r = token_link(r); + } + ins_list(token_link(temp_token_head)); } } return 0; } +static int quittoks(lua_State * L) +{ + (void) L; + if (tracing_nesting_par > 2) { + local_control_message("quitting token scanner"); + } + end_local_control(); + return 0; +} + +/*tex Negative values are internal and inline. */ + +static int tex_getmodevalues(lua_State * L) +{ + lua_newtable(L); + lua_pushinteger(L,0); + lua_push_string_by_name(L,unset); /* 0 */ + lua_rawset(L, -3); + lua_pushinteger(L,vmode); + lua_push_string_by_name(L,vertical); /* 1 */ + lua_rawset(L, -3); + lua_pushinteger(L,hmode); + lua_push_string_by_name(L,horizontal); /* 127 */ + lua_rawset(L, -3); + lua_pushinteger(L,mmode); + lua_push_string_by_name(L,math); /* 253 */ + lua_rawset(L, -3); + return 1; +} + /* till here */ void init_tex_table(lua_State * L) @@ -3650,7 +3709,9 @@ static const struct luaL_Reg texlib[] = { { "get_synctex_line", lua_get_synctex_line }, /* test */ { "runtoks", runtoks }, + { "quittoks", quittoks }, { "forcehmode", forcehmode }, + { "getmodevalues", tex_getmodevalues }, /* sentinel */ { NULL, NULL } }; diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.c b/Build/source/texk/web2c/luatexdir/lua/luainit.c index 7abf8c8ee5e..7570910b0ef 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luainit.c +++ b/Build/source/texk/web2c/luatexdir/lua/luainit.c @@ -24,6 +24,7 @@ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. #include "ptexlib.h" #include <kpathsea/c-stat.h> +#include <kpathsea/cnf.h> #include "lua/luatex-api.h" @@ -66,6 +67,7 @@ const_string LUATEX_IHELP[] = { "", " The following regular options are understood: ", "", + " --cnf-line =STRING parse STRING as a configuration file line", " --credits display credits and exit", " --debug-format enable format debugging", " --draftmode switch on draft mode (generates no output PDF)", @@ -183,6 +185,16 @@ static void prepare_cmdline(lua_State * L, char **av, int ac, int zero_offset) int kpse_init = -1; +/*tex + +Array and count of values given with --cnf-line. + +*/ +static string *user_cnf_lines = NULL; +static unsigned user_cnf_nlines = 0; + + + string input_name = NULL; static string user_progname = NULL; @@ -234,6 +246,7 @@ static struct option long_options[] = { {"interaction", 1, 0, 0}, {"halt-on-error", 0, &haltonerrorp, 1}, {"kpathsea-debug", 1, 0, 0}, + {"cnf-line", 1,0 ,0}, {"progname", 1, 0, 0}, {"version", 0, 0, 0}, {"credits", 0, 0, 0}, @@ -359,6 +372,16 @@ static void parse_options(int ac, char **av) show_luahashchars = 1; } else if (ARGUMENT_IS("kpathsea-debug")) { kpathsea_debug |= atoi(optarg); + } else if (ARGUMENT_IS ("cnf-line")) { + if (user_cnf_lines == NULL) { + user_cnf_nlines = 1; + user_cnf_lines = xmalloc (sizeof (const_string)); + } else { + user_cnf_nlines++; + user_cnf_lines = xrealloc (user_cnf_lines, + user_cnf_nlines * sizeof (const_string)); + } + user_cnf_lines[user_cnf_nlines-1] = xstrdup (optarg); } else if (ARGUMENT_IS("progname")) { user_progname = optarg; } else if (ARGUMENT_IS("jobname")) { @@ -998,6 +1021,15 @@ void lua_initialize(int ac, char **av) putenv(LC_NUMERIC_C); /*tex this is sometimes needed */ putenv(engine_luatex); + /*tex add user's cnf values*/ + if (user_cnf_lines) { + unsigned i; + for (i = 0; i < user_cnf_nlines; i++) { + /* debug printf ("ucnf%d: %s\n", i, user_cnf_lines[i]); */ + kpathsea_cnf_line_env_progname (kpse_def, user_cnf_lines[i]); + free (user_cnf_lines[i]); + } + } luainterpreter(); /*tex init internalized strings */ set_init_keys; diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.c b/Build/source/texk/web2c/luatexdir/lua/luanode.c index 3182b609773..a0c97e37dc8 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luanode.c +++ b/Build/source/texk/web2c/luatexdir/lua/luanode.c @@ -140,13 +140,18 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); return ret; } - lua_settop(Luas, s_top); + /*tex This should prevent a stack overflow (see r6689), */ + /*tex but as side effect it discards the ouput */ + /*tex of the linebreak_filter, see [Dev-luatex] linebreak_filter */ + /*tex lua_settop(Luas, s_top);*/ p = lua_touserdata(Luas, -1); if (p != NULL) { a = nodelist_from_lua(Luas,-1); try_couple_nodes(*new_head,a); ret = 1; } + /*tex re-inserted this line */ + lua_settop(Luas, s_top); return ret; } diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h index d54bd84663f..9525cecd26d 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -799,6 +799,7 @@ make_lua_key(hlist);\ make_lua_key(hmode_par);\ make_lua_key(hmove);\ make_lua_key(hold_head);\ +make_lua_key(horizontal);\ make_lua_key(horiz_variants);\ make_lua_key(hrule);\ make_lua_key(hsize);\ @@ -1215,6 +1216,7 @@ make_lua_key(variable);\ make_lua_key(vbox);\ make_lua_key(vcenter);\ make_lua_key(version);\ +make_lua_key(vertical);\ make_lua_key(vert_italic);\ make_lua_key(vert_variants);\ make_lua_key(visiblefilename);\ @@ -1502,6 +1504,7 @@ init_lua_key(hlist);\ init_lua_key(hmode_par);\ init_lua_key(hmove);\ init_lua_key(hold_head);\ +init_lua_key(horizontal);\ init_lua_key(horiz_variants);\ init_lua_key(hrule);\ init_lua_key(hsize);\ @@ -1905,6 +1908,7 @@ init_lua_key(variable);\ init_lua_key(vbox);\ init_lua_key(vcenter);\ init_lua_key(version);\ +init_lua_key(vertical);\ init_lua_key(vert_italic);\ init_lua_key(vert_variants);\ init_lua_key(visiblefilename);\ @@ -2256,6 +2260,7 @@ use_lua_key(hlist); use_lua_key(hmode_par); use_lua_key(hmove); use_lua_key(hold_head); +use_lua_key(horizontal); use_lua_key(horiz_variants); use_lua_key(hrule); use_lua_key(hsize); @@ -2672,6 +2677,7 @@ use_lua_key(variable); use_lua_key(vbox); use_lua_key(vcenter); use_lua_key(version); +use_lua_key(vertical); use_lua_key(vert_italic); use_lua_key(vert_variants); use_lua_key(visiblefilename); diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.c b/Build/source/texk/web2c/luatexdir/lua/luatoken.c index fb197b68f7b..874fbc99a5d 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatoken.c +++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.c @@ -140,6 +140,7 @@ command_item command_names[] = { { assign_box_dir_cmd, NULL, 0}, { assign_direction_cmd, NULL, 0}, { assign_dir_cmd, NULL, 0}, + { combine_toks_cmd, NULL, 0}, { advance_cmd, NULL, 0}, { multiply_cmd, NULL, 0}, { divide_cmd, NULL, 0}, @@ -169,7 +170,6 @@ command_item command_names[] = { { variable_cmd, NULL, 0}, { feedback_cmd, NULL, 0}, { the_cmd, NULL, 0}, - { combine_toks_cmd, NULL, 0}, { top_bot_mark_cmd, NULL, 0}, { call_cmd, NULL, 0}, { long_call_cmd, NULL, 0}, @@ -306,6 +306,7 @@ void l_set_token_data(void) init_token_key(command_names, assign_box_dir_cmd, assign_box_dir); init_token_key(command_names, assign_direction_cmd, assign_direction); init_token_key(command_names, assign_dir_cmd, assign_dir); + init_token_key(command_names, combine_toks_cmd, combinetoks); init_token_key(command_names, advance_cmd, advance); init_token_key(command_names, multiply_cmd, multiply); init_token_key(command_names, divide_cmd, divide); @@ -334,7 +335,6 @@ void l_set_token_data(void) init_token_key(command_names, variable_cmd, variable); init_token_key(command_names, feedback_cmd, feedback); init_token_key(command_names, the_cmd, the); - init_token_key(command_names, combine_toks_cmd, combinetoks); init_token_key(command_names, top_bot_mark_cmd, top_bot_mark); init_token_key(command_names, call_cmd, call); init_token_key(command_names, long_call_cmd, long_call); |