diff options
26 files changed, 541 insertions, 451 deletions
diff --git a/Build/source/texk/web2c/luatexdir/NEWS b/Build/source/texk/web2c/luatexdir/NEWS index d7fa484fde4..c96a8f3ea9f 100644 --- a/Build/source/texk/web2c/luatexdir/NEWS +++ b/Build/source/texk/web2c/luatexdir/NEWS @@ -2,6 +2,14 @@ This file is in the public domain. ============================================================== +Luatex Release 0.89.4 was released 2016031100 +============================================================== + +Intermediary release. Several bugs fixed. + + + +============================================================== Luatex Release 0.89.2 was released 2016022700 ============================================================== @@ -2667,7 +2675,7 @@ Other news: we probably introduced new problems as well). * Most (all?) files now have a corrected Copyright header, - and link in $Id: NEWS 5808 2016-02-27 07:12:11Z luigi $ and $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/NEWS $ into the object file. + and link in $Id: NEWS 5840 2016-03-11 10:30:17Z luigi $ and $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/NEWS $ into the object file. * Some unnecessary files were removed from the distribution. diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w index 6843cef5cd0..daf20e65b7e 100644 --- a/Build/source/texk/web2c/luatexdir/font/luafont.w +++ b/Build/source/texk/web2c/luatexdir/font/luafont.w @@ -495,10 +495,9 @@ int font_to_lua(lua_State * L, int f) return 1; } -#define count_hash_items(L,name_index,n) \ +#define count_hash_items(L,name,n) \ n = 0; \ - lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); \ - lua_rawget(L, -2); \ + lua_key_rawgeti(name); \ if (lua_type(L, -1) == LUA_TTABLE) { \ lua_pushnil(L); \ while (lua_next(L, -2) != 0) { \ @@ -985,8 +984,7 @@ static void store_math_kerns(lua_State * L, int index, charinfo * co, int id) { int l, k; scaled ht, krn; - lua_rawgeti(L, LUA_REGISTRYINDEX, index); - lua_rawget(L, -2); + lua_key_direct_rawgeti(index); if (lua_istable(L, -1) && ((k = (int) lua_rawlen(L, -1)) > 0)) { for (l = 0; l < k; l++) { lua_rawgeti(L, -1, (l + 1)); @@ -1122,8 +1120,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_charinfo_remainder(co, k); } - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(extensible)); - lua_rawget(L, -2); + lua_key_rawgeti(extensible); if (lua_istable(L, -1)) { int top, bot, mid, rep; top = lua_numeric_field_by_index(L, lua_key_index(top), 0); @@ -1140,8 +1137,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int } lua_pop(L, 1); - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(horiz_variants)); - lua_rawget(L, -2); + lua_key_rawgeti(horiz_variants); if (lua_istable(L, -1)) { int glyph, startconnect, endconnect, advance, extender; extinfo *h; @@ -1166,8 +1162,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int } lua_pop(L, 1); - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(vert_variants)); - lua_rawget(L, -2); + lua_key_rawgeti(vert_variants); if (lua_istable(L, -1)) { int glyph, startconnect, endconnect, advance, extender; extinfo *h; @@ -1204,10 +1199,9 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(mathkern)); - lua_rawget(L, -2); + lua_key_rawgeti(mathkern); if (lua_istable(L, -1)) { - store_math_kerns(L,lua_key_index(top_left), co, top_left_kern); + store_math_kerns(L,lua_key_index(top_left), co, top_left_kern); store_math_kerns(L,lua_key_index(top_right), co, top_right_kern); store_math_kerns(L,lua_key_index(bottom_right), co, bottom_right_kern); store_math_kerns(L,lua_key_index(bottom_left), co, bottom_left_kern); @@ -1215,7 +1209,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int lua_pop(L, 1); } /* end of |has_math| */ - count_hash_items(L, lua_key_index(kerns), nk); + count_hash_items(L, kerns, nk); if (nk > 0) { /* kerns table still on stack */ ckerns = xcalloc((unsigned) (nk + 1), sizeof(kerninfo)); @@ -1258,8 +1252,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int } /* packet commands */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(commands)); - lua_rawget(L, -2); + lua_key_rawgeti(commands); if (lua_istable(L, -1)) { lua_pushnil(L); /* first key */ if (lua_next(L, -2) != 0) { @@ -1270,7 +1263,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int lua_pop(L, 1); /* ligatures */ - count_hash_items(L, lua_key_index(ligatures),nl); + count_hash_items(L, ligatures, nl); if (nl > 0) { /* ligatures table still on stack */ cligs = xcalloc((unsigned) (nl + 1), sizeof(liginfo)); @@ -1421,7 +1414,7 @@ int font_from_lua(lua_State * L, int f) } /* now fetch the base fonts, if needed */ - count_hash_items(L, lua_key_index(fonts), n); + count_hash_items(L, fonts, n); if (n > 0) { /* font table still on stack */ l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int))); @@ -1485,9 +1478,7 @@ int font_from_lua(lua_State * L, int f) read_lua_cidinfo(L, f); /* characters */ - /*lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(characters));lua_rawget(L, -2);*/ lua_key_rawgeti(characters); - /*lua_getfield(L, -1, "characters");*/ if (lua_istable(L, -1)) { /* find the array size values */ int num = 0; /* number of charinfo's to add */ diff --git a/Build/source/texk/web2c/luatexdir/font/tt_table.w b/Build/source/texk/web2c/luatexdir/font/tt_table.w index 8bd2f3b982d..a4164f39d48 100644 --- a/Build/source/texk/web2c/luatexdir/font/tt_table.w +++ b/Build/source/texk/web2c/luatexdir/font/tt_table.w @@ -416,8 +416,7 @@ tt_get_name(sfnt * sfont, char *dest, USHORT destlen, if ((p_id == plat_id) && (e_id == enco_id) && (lang_id == 0xffffu || l_id == lang_id) && (n_id == name_id)) { if (length > destlen - 1) { - fprintf(stderr, - "\n** Notice: Name string too long. Truncating **\n"); + normal_warning("ttf","truncating a very long name"); length = (USHORT) (destlen - 1); } sfnt_seek_set(sfont, (long) (name_offset + string_offset + offset)); diff --git a/Build/source/texk/web2c/luatexdir/font/writecff.w b/Build/source/texk/web2c/luatexdir/font/writecff.w index 5955104845f..2c95ac88e41 100644 --- a/Build/source/texk/web2c/luatexdir/font/writecff.w +++ b/Build/source/texk/web2c/luatexdir/font/writecff.w @@ -3545,8 +3545,7 @@ void writetype1w(PDF pdf, fd_entry * fd) cur_file_name = ff->ff_path; if (!fp) { - fprintf(stderr, "Type1: Could not open Type1 font: %s", cur_file_name); - uexit(1); + formatted_error("cff","could not open Type1 font: %s", cur_file_name); } fclose(fp); @@ -3567,9 +3566,7 @@ void writetype1w(PDF pdf, fd_entry * fd) } fd->ff_found = 1; } else { - fprintf(stderr, "Type1: Could not understand Type1 font: %s", - cur_file_name); - uexit(1); + formatted_error("cff","could not understand Type1 font: %s",cur_file_name); } if (is_subsetted(fd->fm)) { report_stop_file(filetype_subset); diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.w b/Build/source/texk/web2c/luatexdir/font/writetype2.w index d5ce1aca40a..950af999879 100644 --- a/Build/source/texk/web2c/luatexdir/font/writetype2.w +++ b/Build/source/texk/web2c/luatexdir/font/writetype2.w @@ -37,13 +37,11 @@ unsigned long cidtogid_obj = 0; @ low-level helpers @c -#define test_loc(l) \ - if ((f->loc + l) > f->buflen) { \ - fprintf(stderr, "File ended prematurely\n"); \ - uexit(1); \ +#define test_loc(l) \ + if ((f->loc + l) > f->buflen) { \ + normal_error("type 2","the file ended prematurely"); \ } - BYTE get_unsigned_byte(sfnt * f) { test_loc(1); @@ -245,7 +243,7 @@ unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx, fd_entry * fd) /*version = */(void)sfnt_get_ulong(sfont); num_dirs = sfnt_get_ulong(sfont); if (ttc_idx < 0 || ttc_idx > (int) (num_dirs - 1)) { - fprintf(stderr, "Invalid TTC index number %i (0..%i), using index 0 for font %s\n", + formatted_error("type 2","invalid TTC index number %i (0..%i), using index 0 for font %s", ttc_idx,(int) (num_dirs - 1),(fd->fm->ps_name ? fd->fm->ps_name : "")); return 0 ; } @@ -271,7 +269,7 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) char *used_chars = NULL; sfnt *sfont; pdf_obj *fontfile; - int verbose = 0, error = 0; + int error = 0; cidtogidmap = NULL; @@ -285,8 +283,7 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) } if (error < 0) { - fprintf(stderr, "Could not parse the ttf directory.\n"); - uexit(1); + normal_error("type 2","parsing the TTF directory fails"); } if (sfont->type == SFNT_TYPE_TTC && sfnt_find_table_pos(sfont, "CFF ")) { @@ -344,18 +341,11 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) } if (num_glyphs == 1) { - fprintf(stderr, "No glyphs in subset?.\n"); - uexit(1); + normal_error("type 2","there are no glyphs in the subset"); } if (tt_build_tables(sfont, glyphs) < 0) { - fprintf(stderr, "Could not parse the ttf buffer.\n"); - uexit(1); - } - - if (verbose > 1) { - fprintf(stdout, "[%u glyphs (Max CID: %u)]", glyphs->num_glyphs, - last_cid); + normal_error("type 2","the TTF buffer can't be parsed"); } tt_build_finish(glyphs); @@ -364,20 +354,13 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) /* Create font file */ for (i = 0; required_table[i].name; i++) { - if (sfnt_require_table(sfont, - required_table[i].name, - required_table[i].must_exist) < 0) { - fprintf(stderr, "Some required TrueType table does not exist."); - uexit(1); + if (sfnt_require_table(sfont,required_table[i].name, required_table[i].must_exist) < 0) { + normal_error("type 2","some required TrueType table does not exist"); } } fontfile = sfnt_create_FontFile_stream(sfont); - if (verbose > 1) { - fprintf(stdout, "[%ld bytes]", fontfile->length); - } - /* squeeze in the cidgidmap */ if (cidtogidmap != NULL) { cidtogid_obj = (unsigned long) pdf_create_obj(pdf, obj_type_others, 0); diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index 3abe333ec60..dfc3dac6743 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -70,6 +70,7 @@ static const char *const callbacknames[] = { "show_warning_message", "hpack_quality", "vpack_quality", "process_rule", + "insert_local_par", NULL }; diff --git a/Build/source/texk/web2c/luatexdir/lua/llualib.c b/Build/source/texk/web2c/luatexdir/lua/llualib.c index a8760674911..c094c8ed1d1 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llualib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llualib.c @@ -126,8 +126,7 @@ void undump_luac_registers(void) static void bytecode_register_shadow_set(lua_State * L, int k) { /* the stack holds the value to be set */ - lua_pushstring(L, "lua.bytecode_shadow"); /* lua.bytecode_shadow */ - lua_rawget(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(lua_bytecodes_indirect); if (lua_istable(L, -1)) { lua_pushvalue(L, -2); lua_rawseti(L, -2, k); @@ -141,8 +140,7 @@ static int bytecode_register_shadow_get(lua_State * L, int k) { /* the stack holds the value to be set */ int ret = 0; - lua_pushstring(L, "lua.bytecode_shadow"); - lua_rawget(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(lua_bytecodes_indirect); if (lua_istable(L, -1)) { lua_rawgeti(L, -1, k); if (!lua_isnil(L, -1)) @@ -160,9 +158,7 @@ static int writer(lua_State * L, const void *b, size_t size, void *B) bytecode *buf = (bytecode *) B; (void) L; /* for -Wunused */ if ((int) (buf->size + (int) size) > buf->alloc) { - buf->buf = - xrealloc(buf->buf, - (unsigned) (buf->alloc + (int) size + LOAD_BUF_SIZE)); + buf->buf = xrealloc(buf->buf, (unsigned) (buf->alloc + (int) size + LOAD_BUF_SIZE)); buf->alloc = buf->alloc + (int) size + LOAD_BUF_SIZE; } memcpy(buf->buf + buf->size, b, size); @@ -306,8 +302,7 @@ static int get_luaname(lua_State * L) static int lua_functions_get_table(lua_State * L) /* hh */ { - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(lua_functions)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(lua_functions); return 1; } @@ -329,7 +324,7 @@ int luaopen_lua(lua_State * L, char *fname) make_table(L, "bytecode", "tex.bytecode", "getbytecode", "setbytecode"); make_table(L, "name", "tex.name", "getluaname", "setluaname"); lua_newtable(L); - lua_setfield(L, LUA_REGISTRYINDEX, "lua.bytecode_shadow"); + lua_setfield(L, LUA_REGISTRYINDEX, "lua.bytecodes.indirect"); lua_pushstring(L, LUA_VERSION); lua_setfield(L, -2, "version"); if (fname == NULL) { diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c index 6ac8489e9b1..561fef65e66 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c @@ -102,8 +102,7 @@ static lua_token *maybe_istoken(lua_State * L, int ud) lua_token *p = lua_touserdata(L, ud); if (p != NULL) { if (lua_getmetatable(L, ud)) { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_token); if (!lua_rawequal(L, -1, -2)) p = NULL; lua_pop(L, 2); @@ -133,8 +132,7 @@ static void make_new_token(lua_State * L, int cmd, int chr, int cs) fast_get_avail(thetok->token); tok = (cs ? cs_token_flag + cs : token_val(cmd, chr)); set_token_info(thetok->token, tok); - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_token); lua_setmetatable(L, -2); } @@ -143,8 +141,7 @@ static void push_token(lua_State * L, int tok) lua_token *thetok = lua_newuserdata(L, sizeof(lua_token)); thetok->origin = LUA_ORIGIN; thetok->token = tok; - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_token); lua_setmetatable(L, -2); } @@ -220,8 +217,7 @@ inline static int run_put_next(lua_State * L) /* we accept a single nil argument */ return 0; } - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token)); /* n+1 */ - lua_gettable(L, LUA_REGISTRYINDEX); /* n+1 */ + lua_get_metatablelua(luatex_token); m = lua_gettop(L); if (lua_type(L,1) == LUA_TTABLE) { if (n>1) { @@ -540,10 +536,7 @@ static int run_build(lua_State * L) int chr = (int) lua_tointeger(L, 1); int cmd = (int) luaL_optinteger(L, 2, get_cat_code(int_par(cat_code_table_code),chr)); if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) { - fprintf(stdout, - "\n\nluatex error: not a good token.\nCatcode %i can not be returned, so I replaced it by 12 (other)", - (int) cmd); - error(); + formatted_warning("token lib","not a good token, catcode %i can not be returned, so 12 will be used",(int) cmd); cmd = 12; } else if (cmd == 13) { cs = active_to_cs(chr, false); diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index a5d7d7439ee..42f1063264e 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -157,11 +157,6 @@ lua_setmetatable(L,-2); \ } while (0) -#define lua_push_node_metatablelua do { \ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); \ - lua_gettable(L, LUA_REGISTRYINDEX); \ -} while (0) - /* This is a first step towards abstract direct nodes. When we have Lua 5.3 we @@ -257,8 +252,7 @@ static halfword *maybe_isnode(lua_State * L, int i) halfword *p = lua_touserdata(L, i); if (p != NULL) { if (lua_getmetatable(L, i)) { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); if (!lua_rawequal(L, -1, -2)) p = NULL; lua_pop(L, 2); @@ -368,8 +362,7 @@ static int lua_nodelib_prev(lua_State * L) halfword *a; a = (halfword *) lua_newuserdata(L, sizeof(halfword)); *a = p; - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); lua_setmetatable(L, -2); } @@ -397,8 +390,7 @@ void lua_nodelib_push(lua_State * L) } else { a = lua_newuserdata(L, sizeof(halfword)); *a = n; - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); lua_setmetatable(L, -2); } return; @@ -419,8 +411,7 @@ static void lua_nodelib_push_spec(lua_State * L) } else { a = lua_newuserdata(L, sizeof(halfword)); *a = n; - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); lua_setmetatable(L, -2); } return; @@ -432,8 +423,7 @@ void lua_nodelib_push_fast(lua_State * L, halfword n) if (n) { a = lua_newuserdata(L, sizeof(halfword)); *a = n; - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); lua_setmetatable(L, -2); } else { lua_pushnil(L); @@ -469,8 +459,7 @@ static int lua_nodelib_getid(lua_State * L) return 1; } /* [given-node] [mt-given-node] */ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); /* [given-node] [mt-given-node] [mt-node] */ if (!lua_rawequal(L, -1, -2)) { lua_pushnil(L); @@ -513,7 +502,7 @@ static int lua_nodelib_getsubtype(lua_State * L) if ( (p == NULL) || (! lua_getmetatable(L,1)) ) { lua_pushnil(L); } else { - lua_push_node_metatablelua; + lua_get_metatablelua(luatex_node); if ( (!lua_rawequal(L, -1, -2)) || (! nodetype_has_subtype(*p))) { lua_pushnil(L); } else { @@ -565,7 +554,7 @@ static int lua_nodelib_getfont(lua_State * L) if ( (p == NULL) || (! lua_getmetatable(L,1)) ) { lua_pushnil(L); } else { - lua_push_node_metatablelua; + lua_get_metatablelua(luatex_node); if ( (!lua_rawequal(L, -1, -2)) || (type(*p) != glyph_node) ) { lua_pushnil(L); } else { @@ -844,8 +833,7 @@ static int lua_nodelib_getnext(lua_State * L) lua_pushnil(L); } else { /* [given-node] [mt-given-node]*/ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); /* [given-node] [mt-given-node] [mt-node]*/ if (!lua_rawequal(L, -1, -2)) { lua_pushnil(L); @@ -899,8 +887,7 @@ static int lua_nodelib_getprev(lua_State * L) if ( (p == NULL) || (! lua_getmetatable(L,1)) ) { lua_pushnil(L); } else { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); if (!lua_rawequal(L, -1, -2)) { lua_pushnil(L); } else { @@ -918,8 +905,7 @@ static int lua_nodelib_getboth(lua_State * L) lua_pushnil(L); lua_pushnil(L); } else { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); if (!lua_rawequal(L, -1, -2)) { lua_pushnil(L); lua_pushnil(L); @@ -1916,8 +1902,7 @@ static int get_node_field_id(lua_State * L, int n, int node) fields = whatsit_node_data[subtype(node)].fields; } if (lua_key_eq(s, list)) { - /* head and list are equivalent; we don't catch extra virtual fields */ - s = luaS_head_ptr; + s = lua_key(head); } if (fields != NULL) { for (j = 0; fields[j] != NULL; j++) { @@ -3091,6 +3076,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, x_displace(n)); } else if (lua_key_eq(s, yoffset)) { lua_pushinteger(L, y_displace(n)); + } else if (lua_key_eq(s, xadvance)) { + lua_pushinteger(L, x_advance(n)); } else if (lua_key_eq(s, width)) { lua_pushinteger(L, char_width(font(n),character(n))); } else if (lua_key_eq(s, height)) { @@ -3535,8 +3522,7 @@ static int lua_nodelib_getfield(lua_State * L) return 1; } /* [given-node] [mt-given-node]*/ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); /* [given-node] [mt-given-node] [mt-node]*/ if (!lua_rawequal(L, -1, -2)) { lua_pushnil(L) ; @@ -3833,6 +3819,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, x_displace(n)); } else if (lua_key_eq(s, yoffset)) { lua_pushinteger(L, y_displace(n)); + } else if (lua_key_eq(s, xadvance)) { + lua_pushinteger(L, x_advance(n)); } else if (lua_key_eq(s, width)) { lua_pushinteger(L, char_width(font(n),character(n))); } else if (lua_key_eq(s, height)) { @@ -4781,7 +4769,7 @@ static int lua_nodelib_direct_tonode(lua_State * L) if (n != null) { a = (halfword *) lua_newuserdata(L, sizeof(halfword)); *a=n; - lua_push_node_metatablelua; + lua_get_metatablelua(luatex_node); lua_setmetatable(L,-2); } /* else assume node and return argument */ return 1; @@ -5096,6 +5084,8 @@ static int lua_nodelib_fast_setfield(lua_State * L) x_displace(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, yoffset)) { y_displace(n) = (halfword) lua_tointeger(L, 3); + } else if (lua_key_eq(s, xadvance)) { + x_advance(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, width)) { /* not yet */ } else if (lua_key_eq(s, height)) { @@ -5527,8 +5517,7 @@ static int lua_nodelib_setfield(lua_State * L) return 0; } /* [given-node] [mt-given-node]*/ - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(luatex_node); /* [given-node] [mt-given-node] [mt-node]*/ if ( (!lua_rawequal(L, -1, -2)) ) { return 0; @@ -5956,6 +5945,8 @@ static int lua_nodelib_direct_setfield(lua_State * L) x_displace(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, yoffset)) { y_displace(n) = (halfword) lua_tointeger(L, 3); + } else if (lua_key_eq(s, xadvance)) { + x_advance(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, width)) { /* not yet */ } else if (lua_key_eq(s, height)) { @@ -6522,101 +6513,12 @@ static int lua_nodelib_direct_is_node(lua_State * L) return 1; } -/* node.fast.* - - static const struct luaL_Reg fast_nodelib_f[] = { - {"getid", lua_nodelib_fast_getid}, - {"getsubtype", lua_nodelib_fast_getsubtype}, - {"getfont", lua_nodelib_fast_getfont}, - {"getchar", lua_nodelib_fast_getcharacter}, - {"getnext", lua_nodelib_fast_getnext}, - {"getprev", lua_nodelib_fast_getprev}, - {"getfield", lua_nodelib_fast_getfield}, - {"setfield", lua_nodelib_fast_setfield}, - {NULL, NULL} - }; - -*/ - -/* if really needed we can provide this: - -static int lua_nodelib_attributes_to_table(lua_State * L) -{ halfword n; - register halfword attribute; - if (lua_type(L,1) == LUA_TNUMBER) { - n = lua_tointeger(L,1); - } else { - n = *((halfword *) lua_touserdata(L, 1)); - } - if ((n == null) || (! nodetype_has_attributes(type(n)))) { - lua_pushnil(L); - } else { - attribute = node_attr(n); - if (attribute == null || (attribute == cache_disabled)) { - lua_pushnil(L); - } else { - if (! lua_istable(L,2)) { - lua_newtable(L); - } - while (attribute != null) { - lua_pushinteger(L,(int)attribute_id(attribute)); - lua_pushinteger(L,(int)attribute_value(attribute)); - lua_rawset(L,-3); - attribute = vlink(attribute) ; - } - } - } - return 1 ; -} - -*/ - -/* There is no gain here but let's keep it around: - -static int lua_nodelib_attributes_to_properties(lua_State * L) -{ halfword n; - register halfword attribute; - if (lua_type(L,1) == LUA_TNUMBER) { - n = lua_tointeger(L,1); - } else { - n = *((halfword *) lua_touserdata(L, 1)); - } - if (n == null) { - lua_pushnil(L); - return 1; - } - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); - while (n != null) { - lua_rawseti(L, -1, luaS_index(attributes)); - lua_newtable(L); - if (! nodetype_has_attributes(type(n))) { - lua_pushnil(L); - } else { - attribute = node_attr(n); - if (attribute == null || (attribute == cache_disabled)) { - lua_pushnil(L); - } else { - while (attribute != null) { - lua_pushinteger(L,(int)attribute_id(attribute)); - lua_pushinteger(L,(int)attribute_value(attribute)); - lua_rawset(L,-3); - attribute = vlink(attribute) ; - } - } - } - lua_rawset(L,-3); - n = vlink(n); - } - return 1 ; -} - + /* + Beware, enabling and disabling can result in an inconsistent properties table + but it might make sense sometimes. Of course by default we have disabled this + mechanism. And, one can always sweep the table empty. */ -/* Beware, enabling and disabling can result in an inconsistent properties table -but it might make sense sometimes. Of course by default we have disabled this -mechanism. And, one can always sweep the table empty. */ - static int lua_nodelib_properties_set_mode(lua_State * L) /* hh */ { /* <boolean> */ if (lua_isboolean(L,1)) { @@ -6632,8 +6534,7 @@ static int lua_nodelib_properties_set_mode(lua_State * L) /* hh */ static int lua_nodelib_properties_flush_table(lua_State * L) /* hh */ { /* <node|direct> <number> */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); lua_pushnil(L); /* initializes lua_next */ while (lua_next(L,-2) != 0) { lua_pushvalue(L,-2); @@ -6652,8 +6553,7 @@ static int lua_nodelib_get_property(lua_State * L) /* hh */ if (n == null) { lua_pushnil(L); } else { - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); lua_rawgeti(L,-1,n); } return 1; @@ -6665,8 +6565,7 @@ static int lua_nodelib_direct_get_property(lua_State * L) /* hh */ if (n == null) { lua_pushnil(L); } else { - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); lua_rawgeti(L,-1,n); } return 1; @@ -6678,8 +6577,7 @@ static int lua_nodelib_set_property(lua_State * L) /* hh */ halfword n = *((halfword *) lua_touserdata(L, 1)); if (n != null) { lua_settop(L,2); - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); /* <node> <value> <propertytable> */ lua_replace(L,-3); /* <propertytable> <value> */ @@ -6694,8 +6592,7 @@ static int lua_nodelib_direct_set_property(lua_State * L) /* hh */ halfword n = lua_tointeger(L, 1); if (n != null) { lua_settop(L,2); - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); /* <node> <value> <propertytable> */ lua_replace(L,1); /* <propertytable> <value> */ @@ -6706,15 +6603,13 @@ static int lua_nodelib_direct_set_property(lua_State * L) /* hh */ static int lua_nodelib_direct_properties_get_table(lua_State * L) /* hh */ { /* <node|direct> */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties); return 1; } static int lua_nodelib_properties_get_table(lua_State * L) /* hh */ { /* <node|direct> */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties_indirect)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(node_properties_indirect); return 1; } @@ -7006,19 +6901,11 @@ int luaopen_node(lua_State * L) /* node.* */ luaL_register(L, NULL, nodelib_m); luaL_register(L, "node", nodelib_f); - /* node.fast (experimental code) - lua_pushstring(L,"fast"); - lua_newtable(L); - luaL_register(L, NULL, fast_nodelib_f); - lua_rawset(L,-3); - */ /* node.direct */ lua_pushstring(L,"direct"); lua_newtable(L); luaL_register(L, NULL, direct_nodelib_f); lua_rawset(L,-3); - /* initialization of keywords */ - /*initialize_luaS_indexes(L);*/ return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c index 210bc41a7cc..29bfba6baf3 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -506,44 +506,20 @@ static int l_registerannot(lua_State * L) return 0; } -static int l_get_pdf_value(lua_State * L, int key) -{ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(pdf_data)); - lua_gettable(L, LUA_REGISTRYINDEX); - /* [table] */ - lua_rawgeti(L, LUA_REGISTRYINDEX, key); - /* [table] [key] */ - lua_rawget(L,-2); +#define l_get_pdf_value(key) \ + lua_get_metatablelua(pdf_data); \ + lua_key_rawgeti(key); \ return 1; -} -static int l_get_pageresources(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(pageresources)); -} -static int l_get_pageattributes(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(pageattributes)); -} -static int l_get_pagesattributes(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(pagesattributes)); -} -static int l_get_catalog(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(catalog)); -} -static int l_get_info(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(info)); -} -static int l_get_names(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(names)); -} -static int l_get_trailer(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(trailer)); -} -static int l_get_xformresources(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(xformresources)); -} -static int l_get_xformattributes(lua_State * L) { - return l_get_pdf_value(L,lua_key_index(xformattributes)); -} +static int l_get_pageresources (lua_State * L) { l_get_pdf_value(pageresources); } +static int l_get_pageattributes (lua_State * L) { l_get_pdf_value(pageattributes); } +static int l_get_pagesattributes(lua_State * L) { l_get_pdf_value(pagesattributes); } +static int l_get_catalog (lua_State * L) { l_get_pdf_value(catalog); } +static int l_get_info (lua_State * L) { l_get_pdf_value(info); } +static int l_get_names (lua_State * L) { l_get_pdf_value(names); } +static int l_get_trailer (lua_State * L) { l_get_pdf_value(trailer); } +static int l_get_xformresources (lua_State * L) { l_get_pdf_value(xformresources); } +static int l_get_xformattributes(lua_State * L) { l_get_pdf_value(xformattributes); } # define valid_pdf_key ( \ lua_key_eq(s,catalog) || \ @@ -571,8 +547,7 @@ static int getpdf(lua_State * L) lua_pushinteger(L, static_pdf->posstruct->pos.v); return 1; } else if (valid_pdf_key) { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(pdf_data)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(pdf_data); /* [pdf table] [key] [pdf.data table] */ lua_replace(L, -3); /* [pdf.data table] [key] */ @@ -583,49 +558,24 @@ static int getpdf(lua_State * L) return 0; } -static int l_set_pdf_value(lua_State * L, int key) -{ - if (lua_type(L,-1) == LUA_TSTRING) { - /* [value] */ - lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(pdf_data)); - lua_gettable(L, LUA_REGISTRYINDEX); - /* [value] [table] */ - lua_rawgeti(L, LUA_REGISTRYINDEX, key); - /* [value] [table] [key] */ - lua_pushvalue(L, -3); - /* [table] [key] [value] */ - lua_rawset(L,-3); - } +#define l_set_pdf_value(key) \ + if (lua_type(L,-1) == LUA_TSTRING) { \ + lua_get_metatablelua(pdf_data); \ + lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(key)); \ + lua_pushvalue(L, -3); \ + lua_rawset(L,-3); \ + } \ return 0; -} -static int l_set_pageresources(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(pageresources)); -} -static int l_set_pageattributes(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(pageattributes)); -} -static int l_set_pagesattributes(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(pagesattributes)); -} -static int l_set_catalog(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(catalog)); -} -static int l_set_info(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(info)); -} -static int l_set_names(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(names)); -} -static int l_set_trailer(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(trailer)); -} -static int l_set_xformresources(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(xformresources)); -} -static int l_set_xformattributes(lua_State * L) { - return l_set_pdf_value(L,lua_key_index(xformattributes)); -} +static int l_set_pageresources (lua_State * L) { l_set_pdf_value(pageresources); } +static int l_set_pageattributes (lua_State * L) { l_set_pdf_value(pageattributes); } +static int l_set_pagesattributes(lua_State * L) { l_set_pdf_value(pagesattributes); } +static int l_set_catalog (lua_State * L) { l_set_pdf_value(catalog); } +static int l_set_info (lua_State * L) { l_set_pdf_value(info); } +static int l_set_names (lua_State * L) { l_set_pdf_value(names); } +static int l_set_trailer (lua_State * L) { l_set_pdf_value(trailer); } +static int l_set_xformresources (lua_State * L) { l_set_pdf_value(xformresources); } +static int l_set_xformattributes(lua_State * L) { l_set_pdf_value(xformattributes); } static int setpdf(lua_State * L) { @@ -637,8 +587,7 @@ static int setpdf(lua_State * L) if (lua_type(L, -2) == LUA_TSTRING) { s = lua_tostring(L, -1); if (valid_pdf_key) { - lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(pdf_data)); - lua_gettable(L, LUA_REGISTRYINDEX); + lua_get_metatablelua(pdf_data); /* [pdf table] [key] [value] [pdf.data table] */ lua_replace(L, -4); /* [pdf.data table] [key] [value] */ diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index 03a97288a86..b4bd9a3a63c 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -2326,52 +2326,47 @@ static int tex_enableprimitives(lua_State * L) return 0; } -#define get_int_par(A,B,C) do { \ - lua_pushstring(L,(A)); \ - lua_gettable(L,-2); \ +#define get_int_par(A,B) do { \ + lua_key_rawgeti(A); \ if (lua_type(L, -1) == LUA_TNUMBER) { \ - B = (int) lua_tointeger(L, -1); \ + A = (int) lua_tointeger(L, -1); \ } else { \ - B = (C); \ + A = (B); \ } \ lua_pop(L,1); \ } while (0) - -#define get_intx_par(A,B,C,D,E) do { \ - lua_pushstring(L,(A)); \ - lua_gettable(L,-2); \ +#define get_intx_par(A,B,C,D) do { \ + lua_key_rawgeti(A); \ if (lua_type(L, -1) == LUA_TNUMBER) { \ - B = (int) lua_tointeger(L, -1); \ - D = null; \ + A = (int) lua_tointeger(L, -1); \ + C = null; \ } else if (lua_type(L, -1) == LUA_TTABLE){ \ - B = 0; \ - D = nodelib_topenalties(L, lua_gettop(L)); \ + A = 0; \ + C = nodelib_topenalties(L, lua_gettop(L)); \ } else { \ - B = (C); \ - D = (E); \ + A = (B); \ + C = (D); \ } \ lua_pop(L,1); \ } while (0) -#define get_dimen_par(A,B,C) do { \ - lua_pushstring(L,(A)); \ - lua_gettable(L,-2); \ +#define get_dimen_par(A,B) do { \ + lua_key_rawgeti(A); \ if (lua_type(L, -1) == LUA_TNUMBER) { \ - B = (int) lua_tointeger(L, -1); \ + A = (int) lua_tointeger(L, -1); \ } else { \ - B = (C); \ + A = (B); \ } \ lua_pop(L,1); \ } while (0) -#define get_glue_par(A,B,C) do { \ - lua_pushstring(L,(A)); \ - lua_gettable(L,-2); \ +#define get_glue_par(A,B) do { \ + lua_key_rawgeti(A); \ if (lua_type(L, -1) != LUA_TNIL) { \ - B = *check_isnode(L, -1); \ + A = *check_isnode(L, -1); \ } else { \ - B = (C); \ + A = (B); \ } \ lua_pop(L,1); \ } while (0) @@ -2486,15 +2481,13 @@ static int tex_run_linebreak(lua_State * L) lua_checkstack(L, 3); lua_newtable(L); } - lua_pushstring(L, "pardir"); - lua_gettable(L, -2); + lua_key_rawgeti(pardir); if (lua_type(L, -1) == LUA_TSTRING) { paragraph_dir = nodelib_getdir(L, -1, 1); } lua_pop(L, 1); - lua_pushstring(L, "parshape"); - lua_gettable(L, -2); + lua_key_rawgeti(parshape); if (lua_type(L, -1) == LUA_TTABLE) { parshape = nodelib_toparshape(L, lua_gettop(L)); } else { @@ -2502,79 +2495,69 @@ static int tex_run_linebreak(lua_State * L) } lua_pop(L, 1); - get_int_par("pretolerance", - pretolerance, int_par(pretolerance_code)); - get_int_par("tracingparagraphs", - tracingparagraphs, int_par(tracing_paragraphs_code)); - get_int_par("tolerance", - tolerance, int_par(tolerance_code)); - get_int_par("looseness", - looseness, int_par(looseness_code)); - get_int_par("adjustspacing", - adjustspacing, int_par(adjust_spacing_code)); - get_int_par("adjdemerits", - adjdemerits, int_par(adj_demerits_code)); - get_int_par("protrudechars", - protrudechars, int_par(protrude_chars_code)); - get_int_par("linepenalty", - linepenalty, int_par(line_penalty_code)); - get_int_par("lastlinefit", - lastlinefit, int_par(last_line_fit_code)); - get_int_par("doublehyphendemerits", - doublehyphendemerits, int_par(double_hyphen_demerits_code)); - get_int_par("finalhyphendemerits", - finalhyphendemerits, int_par(final_hyphen_demerits_code)); - get_int_par("hangafter", - hangafter, int_par(hang_after_code)); - get_intx_par("interlinepenalty", - interlinepenalty,int_par(inter_line_penalty_code), interlinepenalties, equiv(inter_line_penalties_loc)); - get_intx_par("clubpenalty", - clubpenalty, int_par(club_penalty_code), clubpenalties, equiv(club_penalties_loc)); - get_intx_par("widowpenalty", - widowpenalty, int_par(widow_penalty_code), widowpenalties, equiv(widow_penalties_loc)); - get_int_par("brokenpenalty", - brokenpenalty, int_par(broken_penalty_code)); - get_dimen_par("emergencystretch", - emergencystretch, dimen_par(emergency_stretch_code)); - get_dimen_par("hangindent", - hangindent, dimen_par(hang_indent_code)); - get_dimen_par("hsize", - hsize, dimen_par(hsize_code)); - get_glue_par("leftskip", - leftskip, glue_par(left_skip_code)); - get_glue_par("rightskip", - rightskip, glue_par(right_skip_code)); - + get_int_par (pretolerance, int_par(pretolerance_code)); + get_int_par (tracingparagraphs, int_par(tracing_paragraphs_code)); + get_int_par (tolerance, int_par(tolerance_code)); + get_int_par (looseness, int_par(looseness_code)); + get_int_par (adjustspacing, int_par(adjust_spacing_code)); + get_int_par (adjdemerits, int_par(adj_demerits_code)); + get_int_par (protrudechars, int_par(protrude_chars_code)); + get_int_par (linepenalty, int_par(line_penalty_code)); + get_int_par (lastlinefit, int_par(last_line_fit_code)); + get_int_par (doublehyphendemerits, int_par(double_hyphen_demerits_code)); + get_int_par (finalhyphendemerits, int_par(final_hyphen_demerits_code)); + get_int_par (hangafter, int_par(hang_after_code)); + get_intx_par (interlinepenalty,int_par(inter_line_penalty_code), interlinepenalties, equiv(inter_line_penalties_loc)); + get_intx_par (clubpenalty, int_par(club_penalty_code), clubpenalties, equiv(club_penalties_loc)); + get_intx_par (widowpenalty, int_par(widow_penalty_code), widowpenalties, equiv(widow_penalties_loc)); + get_int_par (brokenpenalty, int_par(broken_penalty_code)); + get_dimen_par(emergencystretch, dimen_par(emergency_stretch_code)); + get_dimen_par(hangindent, dimen_par(hang_indent_code)); + get_dimen_par(hsize, dimen_par(hsize_code)); + get_glue_par (leftskip, glue_par(left_skip_code)); + get_glue_par (rightskip, glue_par(right_skip_code)); ext_do_line_break(paragraph_dir, - pretolerance, tracingparagraphs, tolerance, - emergencystretch, looseness, + pretolerance, + tracingparagraphs, + tolerance, + emergencystretch, + looseness, adjustspacing, parshape, - adjdemerits, protrudechars, - linepenalty, lastlinefit, - doublehyphendemerits, finalhyphendemerits, - hangindent, hsize, hangafter, leftskip, rightskip, + adjdemerits, + protrudechars, + linepenalty, + lastlinefit, + doublehyphendemerits, + finalhyphendemerits, + hangindent, + hsize, + hangafter, + leftskip, + rightskip, interlinepenalties, - interlinepenalty, clubpenalty, + interlinepenalty, + clubpenalty, clubpenalties, widowpenalties, - widowpenalty, brokenpenalty, + widowpenalty, + brokenpenalty, final_par_glue); /* return the generated list, and its prevdepth */ get_linebreak_info (&fewest_demerits, &actual_looseness) ; lua_nodelib_push_fast(L, vlink(cur_list.head_field)); lua_newtable(L); - lua_pushstring(L, "demerits"); + lua_push_key(demerits); lua_pushinteger(L, fewest_demerits); lua_settable(L, -3); - lua_pushstring(L, "looseness"); + lua_push_key(looseness); lua_pushinteger(L, actual_looseness); lua_settable(L, -3); - lua_pushstring(L, "prevdepth"); + lua_push_key(prevdepth); lua_pushinteger(L, cur_list.prev_depth_field); lua_settable(L, -3); - lua_pushstring(L, "prevgraf"); + lua_push_key(prevgraf); lua_pushinteger(L, cur_list.pg_field); lua_settable(L, -3); @@ -2586,6 +2569,13 @@ static int tex_run_linebreak(lua_State * L) return 2; } +static int tex_reset_paragraph(lua_State * L) +{ + (void) L; + normal_paragraph(); + return 0; +} + static int tex_shipout(lua_State * L) { int boxnum = get_box_id(L, 1, true); @@ -2932,6 +2922,7 @@ static const struct luaL_Reg texlib[] = { { "setmath", tex_setmathparm }, { "getmath", tex_getmathparm }, { "linebreak", tex_run_linebreak }, + { "resetparagraph", tex_reset_paragraph }, /* tex random generators */ { "init_rand", tex_init_rand }, { "uniform_rand",tex_unif_rand }, diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w index 75559f9a403..d7bc05024f4 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luainit.w +++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w @@ -764,6 +764,7 @@ int node_table_id; @ @c int l_pack_type_index [PACK_TYPE_SIZE] ; int l_group_code_index [GROUP_CODE_SIZE]; +int l_local_par_index [LOCAL_PAR_SIZE]; int l_math_style_name_index [MATH_STYLE_NAME_SIZE]; int l_dir_par_index [DIR_PAR_SIZE]; int l_dir_text_index [DIR_TEXT_SIZE]; @@ -931,6 +932,7 @@ void lua_initialize(int ac, char **av) /* here start the key definitions */ set_l_pack_type_index; set_l_group_code_index; + set_l_local_par_index; set_l_math_style_name_index; set_l_dir_par_index; set_l_dir_text_index; diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h index 5154a5d303d..163d5577410 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -163,8 +163,7 @@ extern unsigned char show_luahashchars ; extern void unhide_lua_table(lua_State * lua, const char *name, int r); extern int hide_lua_table(lua_State * lua, const char *name); -extern void unhide_lua_value(lua_State * lua, const char *name, - const char *item, int r); +extern void unhide_lua_value(lua_State * lua, const char *name, const char *item, int r); extern int hide_lua_value(lua_State * lua, const char *name, const char *item); typedef struct command_item_ { @@ -269,9 +268,10 @@ extern int luatwrite(lua_State * L); #define lua_key_eq(a,b) (a==luaS_##b##_ptr) -#define luaS_index(a) luaS_##a##_index #define lua_key_index(a) luaS_##a##_index #define lua_key(a) luaS_##a##_ptr +#define lua_key_plus(a) luaS_p##a##_ptr +#define lua_key_minus(a) luaS_m##a##_ptr #define use_lua_key(a) \ extern int luaS_##a##_index ; \ extern const char * luaS_##a##_ptr @@ -280,10 +280,28 @@ extern int luatwrite(lua_State * L); lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index);\ lua_rawget(L, -2) +#define lua_key_direct_rawgeti(i) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, i);\ + lua_rawget(L, -2) + #define lua_key_rawgeti_n(a,n) \ lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index);\ lua_rawget(L, -1+n) +#define lua_key_direct_rawget_n(i,n) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, i);\ + lua_rawget(L, -1+n) + +#define lua_push_key(a) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index); + +#define lua_get_metatablelua_l(L,a) do { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index); \ + lua_gettable(L, LUA_REGISTRYINDEX); \ +} while (0) + +#define lua_get_metatablelua(a) lua_get_metatablelua_l(L,a) + /* Unfortunately floor is already redefined as #define floor ((integer)floor((double)(a))) @@ -306,6 +324,7 @@ preassign these at startup time. */ #define PACK_TYPE_SIZE 4 #define GROUP_CODE_SIZE 23 +#define LOCAL_PAR_SIZE 5 #define MATH_STYLE_NAME_SIZE 8 #define APPEND_LIST_SIZE 5 #define DIR_PAR_SIZE 8 @@ -313,12 +332,14 @@ preassign these at startup time. */ extern int l_pack_type_index [PACK_TYPE_SIZE]; extern int l_group_code_index [GROUP_CODE_SIZE]; +extern int l_local_par_index [LOCAL_PAR_SIZE]; extern int l_math_style_name_index [MATH_STYLE_NAME_SIZE]; extern int l_dir_par_index [DIR_PAR_SIZE]; extern int l_dir_text_index [DIR_TEXT_SIZE]; #define lua_push_pack_type(L,pack_type) lua_rawgeti(L, LUA_REGISTRYINDEX, l_pack_type_index[pack_type] ); #define lua_push_group_code(L,group_code) lua_rawgeti(L, LUA_REGISTRYINDEX, l_group_code_index[group_code]); +#define lua_push_local_par_mode(L,par_mode) lua_rawgeti(L, LUA_REGISTRYINDEX, l_local_par_index[par_mode]); #define lua_push_math_style_name(L,style_name) lua_rawgeti(L, LUA_REGISTRYINDEX, l_math_style_name_index[style_name]); #define lua_push_dir_par(L,dir) lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_par_index[dir+dir_swap]) #define lua_push_dir_text(L,dir) lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index[dir+dir_swap]) @@ -357,6 +378,13 @@ l_group_code_index[20] = lua_key_index(preamble);\ l_group_code_index[21] = lua_key_index(align_set);\ l_group_code_index[22] = lua_key_index(fin_row) +#define set_l_local_par_index \ +l_local_par_index[0] = lua_key_index(new_graf);\ +l_local_par_index[1] = lua_key_index(local_box);\ +l_local_par_index[2] = lua_key_index(hmode_par);\ +l_local_par_index[3] = lua_key_index(penalty);\ +l_local_par_index[4] = lua_key_index(math); + #define set_l_math_style_name_index \ l_math_style_name_index[0] = lua_key_index(display);\ l_math_style_name_index[1] = lua_key_index(crampeddisplay);\ @@ -447,9 +475,11 @@ make_lua_key(action_id);\ make_lua_key(action_type);\ make_lua_key(active);\ make_lua_key(additional);\ +make_lua_key(adjdemerits);\ make_lua_key(adjust);\ make_lua_key(adjust_head);\ make_lua_key(adjusted_hbox);\ +make_lua_key(adjustspacing);\ make_lua_key(advance);\ make_lua_key(after_display);\ make_lua_key(after_output);\ @@ -480,6 +510,7 @@ make_lua_key(box_right);\ make_lua_key(box_right_width);\ make_lua_key(broken_ins);\ make_lua_key(broken_ptr);\ +make_lua_key(brokenpenalty);\ make_lua_key(cache);\ make_lua_key(cal_expand_ratio);\ make_lua_key(catalog);\ @@ -488,6 +519,7 @@ make_lua_key(characters);\ make_lua_key(checksum);\ make_lua_key(cidinfo);\ make_lua_key(class);\ +make_lua_key(clubpenalty);\ make_lua_key(colordepth);\ make_lua_key(colorspace);\ make_lua_key(command);\ @@ -509,6 +541,7 @@ make_lua_key(data);\ make_lua_key(degree);\ make_lua_key(delim);\ make_lua_key(delimptr);\ +make_lua_key(demerits);\ make_lua_key(denom);\ make_lua_key(depth);\ make_lua_key(designsize);\ @@ -521,9 +554,11 @@ make_lua_key(direction);\ make_lua_key(dirs);\ make_lua_key(disc);\ make_lua_key(display);\ +make_lua_key(doublehyphendemerits);\ make_lua_key(down);\ make_lua_key(dvi_ptr);\ make_lua_key(embedding);\ +make_lua_key(emergencystretch);\ make_lua_key(empty_string);\ make_lua_key(encodingbytes);\ make_lua_key(encodingname);\ @@ -546,6 +581,7 @@ make_lua_key(filename);\ make_lua_key(filepath);\ make_lua_key(fill);\ make_lua_key(fin_row);\ +make_lua_key(finalhyphendemerits);\ make_lua_key(font);\ make_lua_key(fonts);\ make_lua_key(format);\ @@ -557,12 +593,15 @@ make_lua_key(glue_set);\ make_lua_key(glue_sign);\ make_lua_key(glyph);\ make_lua_key(h);\ +make_lua_key(hangafter);\ +make_lua_key(hangindent);\ make_lua_key(hbox);\ make_lua_key(head);\ make_lua_key(height);\ make_lua_key(hmode_par);\ make_lua_key(hold_head);\ make_lua_key(horiz_variants);\ +make_lua_key(hsize);\ make_lua_key(hyphenchar);\ make_lua_key(id);\ make_lua_key(image);\ @@ -571,6 +610,7 @@ make_lua_key(immediate);\ make_lua_key(index);\ make_lua_key(info);\ make_lua_key(insert);\ +make_lua_key(interlinepenalty);\ make_lua_key(italic);\ make_lua_key(keepopen);\ make_lua_key(kern);\ @@ -579,18 +619,23 @@ make_lua_key(lang);\ make_lua_key(large_char);\ make_lua_key(large_fam);\ make_lua_key(last_ins_ptr);\ +make_lua_key(lastlinefit);\ make_lua_key(leader);\ make_lua_key(least_page_cost);\ make_lua_key(left);\ make_lua_key(left_boundary);\ make_lua_key(left_protruding);\ +make_lua_key(leftskip);\ make_lua_key(level);\ make_lua_key(ligatures);\ +make_lua_key(linepenalty);\ make_lua_key(link_attr);\ make_lua_key(list);\ make_lua_key(local_box);\ make_lua_key(log);\ +make_lua_key(looseness);\ make_lua_key(lua);\ +make_lua_key(lua_bytecodes_indirect);\ make_lua_key(lua_functions);\ make_lua_key(luatex);\ make_lua_key(luatex_node);\ @@ -651,6 +696,8 @@ make_lua_key(pagebox);\ make_lua_key(pageresources);\ make_lua_key(pagesattributes);\ make_lua_key(parameters);\ +make_lua_key(pardir);\ +make_lua_key(parshape);\ make_lua_key(pdf_data);\ make_lua_key(pdftex);\ make_lua_key(pdf_destination);\ @@ -667,9 +714,11 @@ make_lua_key(pre_adjust_head);\ make_lua_key(pre_align);\ make_lua_key(pre_box);\ make_lua_key(preamble);\ +make_lua_key(pretolerance);\ make_lua_key(prev);\ make_lua_key(prevdepth);\ make_lua_key(prevgraf);\ +make_lua_key(protrudechars);\ make_lua_key(psname);\ make_lua_key(ptr);\ make_lua_key(push);\ @@ -686,6 +735,7 @@ make_lua_key(resources);\ make_lua_key(right);\ make_lua_key(right_boundary);\ make_lua_key(right_protruding);\ +make_lua_key(rightskip);\ make_lua_key(rotation);\ make_lua_key(rule);\ make_lua_key(scale);\ @@ -734,6 +784,7 @@ make_lua_key(tex);\ make_lua_key(text);\ make_lua_key(thread_attr);\ make_lua_key(thread_id);\ +make_lua_key(tolerance);\ make_lua_key(tok);\ make_lua_key(token);\ make_lua_key(top);\ @@ -741,6 +792,7 @@ make_lua_key(top_accent);\ make_lua_key(top_left);\ make_lua_key(top_right);\ make_lua_key(tounicode);\ +make_lua_key(tracingparagraphs);\ make_lua_key(trailer);\ make_lua_key(transform);\ make_lua_key(trim);\ @@ -760,9 +812,11 @@ make_lua_key(vert_variants);\ make_lua_key(vmode_par);\ make_lua_key(visiblefilename);\ make_lua_key(vtop);\ +make_lua_key(widowpenalty);\ make_lua_key(width);\ make_lua_key(writable);\ make_lua_key(x_height);\ +make_lua_key(xadvance);\ make_lua_key(xformresources);\ make_lua_key(xformattributes);\ make_lua_key(xoffset);\ @@ -786,9 +840,11 @@ init_lua_key(action_id);\ init_lua_key(action_type);\ init_lua_key(active);\ init_lua_key(additional);\ +init_lua_key(adjdemerits);\ init_lua_key(adjust);\ init_lua_key(adjust_head);\ init_lua_key(adjusted_hbox);\ +init_lua_key(adjustspacing);\ init_lua_key(advance);\ init_lua_key(after_display);\ init_lua_key(after_output);\ @@ -819,6 +875,7 @@ init_lua_key(box_right);\ init_lua_key(box_right_width);\ init_lua_key(broken_ins);\ init_lua_key(broken_ptr);\ +init_lua_key(brokenpenalty);\ init_lua_key(cache);\ init_lua_key(cal_expand_ratio);\ init_lua_key(catalog);\ @@ -827,6 +884,7 @@ init_lua_key(characters);\ init_lua_key(checksum);\ init_lua_key(cidinfo);\ init_lua_key(class);\ +init_lua_key(clubpenalty);\ init_lua_key(colordepth);\ init_lua_key(colorspace);\ init_lua_key(command);\ @@ -848,6 +906,7 @@ init_lua_key(data);\ init_lua_key(degree);\ init_lua_key(delim);\ init_lua_key(delimptr);\ +init_lua_key(demerits);\ init_lua_key(denom);\ init_lua_key(depth);\ init_lua_key(designsize);\ @@ -860,9 +919,11 @@ init_lua_key(direction);\ init_lua_key(dirs);\ init_lua_key(disc);\ init_lua_key(display);\ +init_lua_key(doublehyphendemerits);\ init_lua_key(down);\ init_lua_key(dvi_ptr);\ init_lua_key(embedding);\ +init_lua_key(emergencystretch);\ init_lua_key(encodingbytes);\ init_lua_key(encodingname);\ init_lua_key(end);\ @@ -884,6 +945,7 @@ init_lua_key(filename);\ init_lua_key(filepath);\ init_lua_key(fill);\ init_lua_key(fin_row);\ +init_lua_key(finalhyphendemerits);\ init_lua_key(font);\ init_lua_key(fonts);\ init_lua_key(format);\ @@ -895,12 +957,15 @@ init_lua_key(glue_set);\ init_lua_key(glue_sign);\ init_lua_key(glyph);\ init_lua_key(h);\ +init_lua_key(hangafter);\ +init_lua_key(hangindent);\ init_lua_key(hbox);\ init_lua_key(head);\ init_lua_key(height);\ init_lua_key(hmode_par);\ init_lua_key(hold_head);\ init_lua_key(horiz_variants);\ +init_lua_key(hsize);\ init_lua_key(hyphenchar);\ init_lua_key(id);\ init_lua_key(image);\ @@ -909,6 +974,7 @@ init_lua_key(immediate);\ init_lua_key(index);\ init_lua_key(info);\ init_lua_key(insert);\ +init_lua_key(interlinepenalty);\ init_lua_key(italic);\ init_lua_key(keepopen);\ init_lua_key(kern);\ @@ -917,18 +983,25 @@ init_lua_key(lang);\ init_lua_key(large_char);\ init_lua_key(large_fam);\ init_lua_key(last_ins_ptr);\ +init_lua_key(lastlinefit);\ +init_lua_key(leftskip);\ init_lua_key(leader);\ init_lua_key(least_page_cost);\ init_lua_key(left);\ init_lua_key(left_boundary);\ init_lua_key(left_protruding);\ +init_lua_key(leftskip);\ init_lua_key(level);\ init_lua_key(ligatures);\ +init_lua_key(leftskip);\ +init_lua_key(linepenalty);\ init_lua_key(link_attr);\ init_lua_key(list);\ init_lua_key(local_box);\ init_lua_key(log);\ +init_lua_key(looseness);\ init_lua_key(lua);\ +init_lua_key(lua_bytecodes_indirect);\ init_lua_key(lua_functions);\ init_lua_key(luatex);\ init_lua_key(luatex_node);\ @@ -979,6 +1052,8 @@ init_lua_key(pagebox);\ init_lua_key(pageresources);\ init_lua_key(pagesattributes);\ init_lua_key(parameters);\ +init_lua_key(pardir);\ +init_lua_key(parshape);\ init_lua_key(pdftex);\ init_lua_key(pdf_destination);\ init_lua_key(pdf_literal);\ @@ -994,9 +1069,11 @@ init_lua_key(pre_adjust_head);\ init_lua_key(pre_align);\ init_lua_key(pre_box);\ init_lua_key(preamble);\ +init_lua_key(pretolerance);\ init_lua_key(prev);\ init_lua_key(prevdepth);\ init_lua_key(prevgraf);\ +init_lua_key(protrudechars);\ init_lua_key(psname);\ init_lua_key(ptr);\ init_lua_key(push);\ @@ -1013,6 +1090,7 @@ init_lua_key(resources);\ init_lua_key(right);\ init_lua_key(right_boundary);\ init_lua_key(right_protruding);\ +init_lua_key(rightskip);\ init_lua_key(rotation);\ init_lua_key(rule);\ init_lua_key(scale);\ @@ -1060,6 +1138,7 @@ init_lua_key(tex);\ init_lua_key(text);\ init_lua_key(thread_attr);\ init_lua_key(thread_id);\ +init_lua_key(tolerance);\ init_lua_key(tok);\ init_lua_key(token);\ init_lua_key(top);\ @@ -1067,6 +1146,7 @@ init_lua_key(top_accent);\ init_lua_key(top_left);\ init_lua_key(top_right);\ init_lua_key(tounicode);\ +init_lua_key(tracingparagraphs);\ init_lua_key(trailer);\ init_lua_key(transform);\ init_lua_key(trim);\ @@ -1086,9 +1166,11 @@ init_lua_key(vert_variants);\ init_lua_key(vmode_par);\ init_lua_key(visiblefilename);\ init_lua_key(vtop);\ +init_lua_key(widowpenalty);\ init_lua_key(width);\ init_lua_key(writable);\ init_lua_key(x_height);\ +init_lua_key(xadvance);\ init_lua_key(xformresources);\ init_lua_key(xformattributes);\ init_lua_key(xoffset);\ @@ -1099,6 +1181,7 @@ init_lua_key(yoffset);\ init_lua_key(yres);\ init_lua_key(ysize);\ init_lua_key_alias(empty_string,"");\ +init_lua_key_alias(lua_bytecodes_indirect,"lua.bytecodes.indirect");\ init_lua_key_alias(lua_functions,"lua.functions");\ init_lua_key_alias(luatex_node, "luatex.node");\ init_lua_key_alias(mLTL,"-LTL");\ @@ -1168,9 +1251,11 @@ use_lua_key(action_id); use_lua_key(action_type); use_lua_key(active); use_lua_key(additional); +use_lua_key(adjdemerits); use_lua_key(adjust); use_lua_key(adjust_head); use_lua_key(adjusted_hbox); +use_lua_key(adjustspacing); use_lua_key(advance); use_lua_key(after_display); use_lua_key(after_output); @@ -1201,6 +1286,7 @@ use_lua_key(box_right); use_lua_key(box_right_width); use_lua_key(broken_ins); use_lua_key(broken_ptr); +use_lua_key(brokenpenalty); use_lua_key(cache); use_lua_key(cal_expand_ratio); use_lua_key(catalog); @@ -1209,6 +1295,7 @@ use_lua_key(characters); use_lua_key(checksum); use_lua_key(cidinfo); use_lua_key(class); +use_lua_key(clubpenalty); use_lua_key(colordepth); use_lua_key(colorspace); use_lua_key(command); @@ -1230,6 +1317,7 @@ use_lua_key(data); use_lua_key(degree); use_lua_key(delim); use_lua_key(delimptr); +use_lua_key(demerits); use_lua_key(denom); use_lua_key(depth); use_lua_key(designsize); @@ -1242,9 +1330,11 @@ use_lua_key(direction); use_lua_key(dirs); use_lua_key(disc); use_lua_key(display); +use_lua_key(doublehyphendemerits); use_lua_key(down); use_lua_key(dvi_ptr); use_lua_key(embedding); +use_lua_key(emergencystretch); use_lua_key(empty_string); use_lua_key(encodingbytes); use_lua_key(encodingname); @@ -1267,6 +1357,7 @@ use_lua_key(filename); use_lua_key(filepath); use_lua_key(fill); use_lua_key(fin_row); +use_lua_key(finalhyphendemerits); use_lua_key(font); use_lua_key(fonts); use_lua_key(format); @@ -1278,12 +1369,15 @@ use_lua_key(glue_set); use_lua_key(glue_sign); use_lua_key(glyph); use_lua_key(h); +use_lua_key(hangafter); +use_lua_key(hangindent); use_lua_key(hbox); use_lua_key(head); use_lua_key(height); use_lua_key(hmode_par); use_lua_key(hold_head); use_lua_key(horiz_variants); +use_lua_key(hsize); use_lua_key(hyphenchar); use_lua_key(id); use_lua_key(image); @@ -1292,6 +1386,7 @@ use_lua_key(immediate); use_lua_key(index); use_lua_key(info); use_lua_key(insert); +use_lua_key(interlinepenalty); use_lua_key(italic); use_lua_key(keepopen); use_lua_key(kern); @@ -1300,18 +1395,23 @@ use_lua_key(lang); use_lua_key(large_char); use_lua_key(large_fam); use_lua_key(last_ins_ptr); +use_lua_key(lastlinefit); use_lua_key(leader); use_lua_key(least_page_cost); use_lua_key(left); use_lua_key(left_boundary); use_lua_key(left_protruding); +use_lua_key(leftskip); use_lua_key(level); use_lua_key(ligatures); +use_lua_key(linepenalty); use_lua_key(link_attr); use_lua_key(list); use_lua_key(local_box); use_lua_key(log); +use_lua_key(looseness); use_lua_key(lua); +use_lua_key(lua_bytecodes_indirect); use_lua_key(lua_functions); use_lua_key(luatex); use_lua_key(luatex_node); @@ -1372,10 +1472,12 @@ use_lua_key(pageattributes); use_lua_key(pageresources); use_lua_key(pagesattributes); use_lua_key(parameters); +use_lua_key(pardir); +use_lua_key(parshape); use_lua_key(pdf_data); use_lua_key(pdftex); -use_lua_key(pdf_destination);\ -use_lua_key(pdf_literal);\ +use_lua_key(pdf_destination); +use_lua_key(pdf_literal); use_lua_key(pen_broken); use_lua_key(pen_inter); use_lua_key(penalty); @@ -1388,9 +1490,11 @@ use_lua_key(pre_adjust_head); use_lua_key(pre_align); use_lua_key(pre_box); use_lua_key(preamble); +use_lua_key(pretolerance); use_lua_key(prev); use_lua_key(prevdepth); use_lua_key(prevgraf); +use_lua_key(protrudechars); use_lua_key(psname); use_lua_key(ptr); use_lua_key(push); @@ -1407,6 +1511,7 @@ use_lua_key(resources); use_lua_key(right); use_lua_key(right_boundary); use_lua_key(right_protruding); +use_lua_key(rightskip); use_lua_key(rotation); use_lua_key(rule); use_lua_key(scale); @@ -1455,6 +1560,7 @@ use_lua_key(tex); use_lua_key(text); use_lua_key(thread_attr); use_lua_key(thread_id); +use_lua_key(tolerance); use_lua_key(tok); use_lua_key(token); use_lua_key(top); @@ -1462,6 +1568,7 @@ use_lua_key(top_accent); use_lua_key(top_left); use_lua_key(top_right); use_lua_key(tounicode); +use_lua_key(tracingparagraphs); use_lua_key(trailer); use_lua_key(transform); use_lua_key(trim); @@ -1481,9 +1588,11 @@ use_lua_key(vert_variants); use_lua_key(vmode_par); use_lua_key(visiblefilename); use_lua_key(vtop); +use_lua_key(widowpenalty); use_lua_key(width); use_lua_key(writable); use_lua_key(x_height); +use_lua_key(xadvance); use_lua_key(xformresources); use_lua_key(xformattributes); use_lua_key(xoffset); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c index afbf08520d4..d2cf7bea15c 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c @@ -1928,6 +1928,16 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf) dump_intfield(L, "glyphcnt", 0); } + if (sf->names != NULL) { + /* + this is not the best way to determine it but for now it will do; otherwise + we need to mess with the ff library + */ + lua_pushstring(L, "truetype"); + lua_pushboolean(L, 1); + lua_rawset(L, -3); + } + dump_intfield(L, "glyphmax", sf->glyphmax - 1); dump_intfield(L, "glyphmin", sf->glyphmin); dump_intfield(L, "units_per_em", sf->units_per_em); diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index 68f7db16da9..d61666e34d6 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -29,9 +29,9 @@ #define TeX int luatex_version = 89; /* \.{\\luatexversion} */ -int luatex_revision = '3'; /* \.{\\luatexrevision} */ -int luatex_date_info = 2016022900; /* the compile date is now hardwired */ -const char *luatex_version_string = "beta-0.89.3"; +int luatex_revision = '4'; /* \.{\\luatexrevision} */ +int luatex_date_info = 2016031100; /* the compile date is now hardwired */ +const char *luatex_version_string = "beta-0.89.4"; const char *engine_name = my_name; /* the name of this engine */ #include <kpathsea/c-ctype.h> diff --git a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h index e2010282075..b1d3449fc44 100644 --- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h +++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h @@ -64,6 +64,7 @@ typedef enum { show_warning_message_callback, hpack_quality_callback, vpack_quality_callback, process_rule_callback, + insert_local_par_callback, total_callbacks } callback_callback_types; diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w index 2bd15f3cedf..65295c6145b 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w +++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w @@ -23,6 +23,13 @@ #include "ptexlib.h" @ @c +#define kern_width(q) width(q) + ex_kern(q) + +/* + ext_xn_over_d(width(q), 1000000+ex_kern(q), 1000000); +*/ + +@ @c pos_info_structure pos_info; /* to be accessed from Lua */ static backend_struct *backend = NULL; @@ -117,14 +124,19 @@ static scaled simple_advance_width(halfword p) switch (type(q)) { case glyph_node: w += glyph_width(q); +/* experimental */ +w += x_advance(q); break; case hlist_node: case vlist_node: case rule_node: case margin_kern_node: - case kern_node: w += width(q); break; + case kern_node: + /* officially we should check the subtype */ + w += kern_width(q); + break; case disc_node: /* hh: the frontend should append already */ if (vlink(no_break(q)) != null) @@ -158,9 +170,12 @@ static halfword calculate_width_to_enddir(halfword p, real cur_glue, scaled cur_ break; case rule_node: case margin_kern_node: - case kern_node: w += width(q); break; + case kern_node: + /* officially we should check the subtype */ + w += kern_width(q); + break; case math_node: /* begin mathskip code */ if (glue_ptr(q) == zero_glue) { @@ -327,7 +342,6 @@ void hlist_out(PDF pdf, halfword this_box, int rule_callback_id) if (synctex) synctexhlist(this_box); - while (p != null) { if (is_char_node(p)) { do { @@ -337,10 +351,13 @@ void hlist_out(PDF pdf, halfword this_box, int rule_callback_id) synch_pos_with_cur(pdf->posstruct, refpos, tmpcur); } ci = output_one_char(pdf, p); - if (textdir_parallel(localpos.dir, dir_TLT)) + if (textdir_parallel(localpos.dir, dir_TLT)) { cur.h += ci.wd; - else +/* experimental */ +cur.h += x_advance(p); + } else { cur.h += ci.ht + ci.dp; + } synch_pos_with_cur(pdf->posstruct, refpos, cur); p = vlink(p); } while (is_char_node(p)); @@ -556,7 +573,8 @@ void hlist_out(PDF pdf, halfword this_box, int rule_callback_id) case kern_node: if (synctex) synctexkern(p, this_box); - cur.h += width(p); + /* officially we should check the subtype */ + cur.h += kern_width(p); break; case rule_node: if (rule_dir(p) < 0) diff --git a/Build/source/texk/web2c/luatexdir/tex/directions.h b/Build/source/texk/web2c/luatexdir/tex/directions.h index e4cea9014dd..8fe126bdb19 100644 --- a/Build/source/texk/web2c/luatexdir/tex/directions.h +++ b/Build/source/texk/web2c/luatexdir/tex/directions.h @@ -39,6 +39,7 @@ extern const char *dir_strings[8]; extern int dir_swap; +/* # define RETURN_DIR_VALUES(a) \ if (s==luaS_##a##_ptr) { \ return (dir_##a); \ @@ -48,9 +49,17 @@ extern int dir_swap; else if (s==luaS_m##a##_ptr) \ return ((dir_##a)-4); \ } +*/ -# define BOX_DIR_VALUE(a) \ - ((s==luaS_p##a##_ptr) : (dir_##a) ? ((s==luaS_m##a##_ptr) : ((dir_##a)-4) ? luaS_pTLT)) +# define RETURN_DIR_VALUES(a) \ + if (s==lua_key(a)) { \ + return (dir_##a); \ + } else if (!absolute_only) { \ + if (s==lua_key_plus(a)) \ + return (dir_##a); \ + else if (s==lua_key_minus(a)) \ + return ((dir_##a)-4); \ + } # define is_mirrored(a) 0 diff --git a/Build/source/texk/web2c/luatexdir/tex/directions.w b/Build/source/texk/web2c/luatexdir/tex/directions.w index b010eb4a9cc..7af25187999 100644 --- a/Build/source/texk/web2c/luatexdir/tex/directions.w +++ b/Build/source/texk/web2c/luatexdir/tex/directions.w @@ -154,6 +154,8 @@ scaled pack_width(int curdir, int pdir, halfword p, boolean isglyph) } else { wd = glyph_depth(p) + glyph_height(p); } +/* experimental */ +wd += x_advance(p); } else { /* hlist, vlist, image, form, rule */ if (textdir_parallel(pdir, curdir)) wd = width(p); @@ -164,8 +166,7 @@ scaled pack_width(int curdir, int pdir, halfword p, boolean isglyph) } @ @c -scaled_whd pack_width_height_depth(int curdir, int pdir, halfword p, - boolean isglyph) +scaled_whd pack_width_height_depth(int curdir, int pdir, halfword p, boolean isglyph) { scaled_whd whd = { 0, 0, 0 }; whd.wd = pack_width(curdir, pdir, p, isglyph); diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w index b2909606d48..29146424fe4 100644 --- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w +++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w @@ -1286,7 +1286,7 @@ static void ext_try_break(int pi, } shortfall += (left_pw(l1) + right_pw(o)); } - if ((shortfall != 0) && (adjust_spacing == 2)) { + if (shortfall != 0) { margin_kern_stretch = 0; margin_kern_shrink = 0; if (protrude_chars > 1) { @@ -1302,14 +1302,12 @@ static void ext_try_break(int pi, } flush_node(cp); } - if ((shortfall > 0) - && ((total_font_stretch + margin_kern_stretch) > 0)) { + if ((shortfall > 0) && ((total_font_stretch + margin_kern_stretch) > 0)) { if ((total_font_stretch + margin_kern_stretch) > shortfall) shortfall = ((total_font_stretch + margin_kern_stretch) / (max_stretch_ratio / cur_font_step)) / 2; else shortfall -= (total_font_stretch + margin_kern_stretch); - } else if ((shortfall < 0) - && ((total_font_shrink + margin_kern_shrink) > 0)) { + } else if ((shortfall < 0) && ((total_font_shrink + margin_kern_shrink) > 0)) { if ((total_font_shrink + margin_kern_shrink) > -shortfall) shortfall = -((total_font_shrink + margin_kern_shrink) / (max_shrink_ratio / cur_font_step)) / 2; else @@ -1620,6 +1618,9 @@ void ext_do_line_break(int paragraph_dir, minimal_demerits[loose_fit] = awful_bad; minimal_demerits[very_loose_fit] = awful_bad; + fewest_demerits = 0; + actual_looseness = 0; + /* We compute the values of |easy_line| and the other local variables relating to line length when the |line_break| procedure is initializing itself. */ if (par_shape_ptr == null) { @@ -1866,8 +1867,9 @@ void ext_do_line_break(int paragraph_dir, if (prev_p != temp_head && ( is_char_node(prev_p) || precedes_break(prev_p) - || ((type(prev_p) == kern_node) && (subtype(prev_p) != explicit_kern && - subtype(prev_p) != italic_kern )) + || ( (type(prev_p) == kern_node) && ( + subtype(prev_p) == font_kern || subtype(prev_p) == accent_kern) + ) )) { ext_try_break(0, unhyphenated_node, line_break_dir, adjust_spacing, par_shape_ptr, adj_demerits, diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w index f36283b58bb..12a4bbab583 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w @@ -1518,7 +1518,7 @@ void new_graf(boolean indented) mode = hmode; space_factor = 1000; /* LOCAL: Add local paragraph node */ - tail_append(make_local_par_node()); + tail_append(make_local_par_node(0)); if (indented) { p = new_null_box(); box_dir(p) = par_direction; @@ -1888,7 +1888,7 @@ void build_local_box(void) eq_define(local_right_box_base, box_ref_cmd, p); if (abs(mode) == hmode) { /* LOCAL: Add local paragraph node */ - tail_append(make_local_par_node()); + tail_append(make_local_par_node(1)); } eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits + 1); } @@ -2851,7 +2851,7 @@ void fixup_directions(void) } if (temp_no_whatsits != 0) { /* LOCAL: Add local paragraph node */ - tail_append(make_local_par_node()); + tail_append(make_local_par_node(2)); } } } @@ -2961,7 +2961,7 @@ void assign_internal_value(int a, halfword p, int val) ((p == (int_base + local_inter_line_penalty_code)) || (p == (int_base + local_broken_penalty_code)))) { /* LOCAL: Add local paragraph node */ - tail_append(make_local_par_node()); + tail_append(make_local_par_node(3)); eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits + 1); diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w index 1a8e332136d..220e8722386 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mlist.w +++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w @@ -1590,9 +1590,12 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle) return; } alink(p) = null ; - nodelist_to_lua(L, p); /* arg 1 */ - lua_pushstring(L, math_style_names[mstyle]); /* arg 2 */ - lua_pushboolean(L, penalties); /* arg 3 */ + nodelist_to_lua(L, p); + /* + lua_pushstring(L, math_style_names[mstyle]); + */ + lua_push_math_style_name(L,mstyle); + lua_pushboolean(L, penalties); if (lua_pcall(L, 3, 1, 0) != 0) { /* 3 args, 1 result */ char errmsg[256]; /* temp hack ... we will have a formatted error */ snprintf(errmsg, 255, "error: %s\n", lua_tostring(L, -1)); diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.w b/Build/source/texk/web2c/luatexdir/tex/packaging.w index 7541339dc36..8c692ae7975 100644 --- a/Build/source/texk/web2c/luatexdir/tex/packaging.w +++ b/Build/source/texk/web2c/luatexdir/tex/packaging.w @@ -341,6 +341,16 @@ void set_prev_char_p(halfword p) prev_char_p = p; } +/* + the kern stretch / shrink code was (or had become) rather weird ... the width field + is set, and then used in a second calculation, repeatedly, so why is that ... maybe some + some weird left-over ... anyway, the values are so small that in practice they are not + significant at all when the backend sees them because a few hundred sp positive or + negative are just noise there (so adjustlevel 3 has hardly any consequence for the + result but is more efficient) +*/ + + @ @c scaled char_stretch(halfword p) { @@ -350,7 +360,7 @@ scaled char_stretch(halfword p) int c = character(p); int ef = get_ef_code(f, c); if (ef > 0) { - scaled dw = calc_char_width(f, c, m) - char_width(f, c); + scaled dw = calc_char_width(f, c, m) - char_width(f, c) - x_advance(p); if (dw > 0) { return round_xn_over_d(dw, ef, 1000); } @@ -368,7 +378,7 @@ scaled char_shrink(halfword p) int c = character(p); int ef = get_ef_code(f, c); if (ef > 0) { - scaled dw = char_width(f, c) - calc_char_width(f, c, -m); + scaled dw = char_width(f, c) + x_advance(p) - calc_char_width(f, c, -m); if (dw > 0) { return round_xn_over_d(dw, ef, 1000); } @@ -378,6 +388,7 @@ scaled char_shrink(halfword p) } @ @c +/* scaled kern_stretch(halfword p) { halfword l, r; @@ -386,23 +397,69 @@ scaled kern_stretch(halfword p) if ((prev_char_p == null) || (vlink(prev_char_p) != p) || (vlink(p) == null)) return 0; l = prev_char_p; - /* we need a left char */ + // we need a left char if (!is_char_node(l)) return 0; r = vlink(p); - /* and a right char */ + // and a right char if (!is_char_node(r)) return 0; - /* and a reason to kern */ + // and a reason to kern if ((font(l) != font(r)) || (font_max_stretch(font(l)) == 0)) return 0; m = font_max_stretch(font(l)); - d = get_kern(font(l), character(l), character(r)); + d = get_kern(font(l), character(l), character(r)); // real kern, so what is width(p) then; the messed up one d = round_xn_over_d(d, 1000 + m, 1000); return round_xn_over_d(d - width(p), get_ef_code(font(l), character(l)), 1000); } +*/ + +scaled kern_stretch(halfword p) +{ + int m; + scaled d, e, x; + scaled w = width(p) ; + halfword l; + halfword r; + if (w == 0) { + /* why bother about zero kerns */ + return 0; + } + l = prev_char_p ; + if ((l == null) || (vlink(l) != p)) { + /* we only care about kerns following a char*/ + return 0; + } + r = vlink(p); + if (r == null) { + /* we only care about kerns between a char and something else */ + } + if (!(is_char_node(l) && is_char_node(r))) { + /* we want two chars (but but don't care about the fonts) */ + return 0; + } + /* we use the old logic, kind of, but average the ef as we might depend on proper overlap */ + m = (font_max_shrink(font(l)) + font_max_shrink(font(r)))/2; + if (m == 0) { + /* nothing to kern */ + return 0; + } + d = round_xn_over_d(w, 1000 + m, 1000); + /* we use the old logic, kind of, but average the ef as we might depend on proper overlap */ + e = (get_ef_code(font(l), character(l)) + get_ef_code(font(r), character(r)))/2 ; + if (e == 1000) { + x = d - w; + } else { + x = round_xn_over_d(d - w, e, 1000); + } + /* + printf("STRETCH w=%i s=%i x=%i\n",w,e+m,x); + */ + return x; +} @ @c +/* scaled kern_shrink(halfword p) { halfword l, r; @@ -411,21 +468,65 @@ scaled kern_shrink(halfword p) if ((prev_char_p == null) || (vlink(prev_char_p) != p) || (vlink(p) == null)) return 0; l = prev_char_p; - /* we need a left char */ + // we need a left char if (!is_char_node(l)) return 0; r = vlink(p); - /* and a right char */ + // and a right char if (!is_char_node(r)) return 0; - /* and a reason to kern */ + // and a reason to kern if ((font(l) != font(r)) || (font_max_shrink(font(l)) == 0)) return 0; m = font_max_stretch(font(l)); - d = get_kern(font(l), character(l), character(r)); + d = get_kern(font(l), character(l), character(r)); // real kern, so what is width(p) then; the messed up one d = round_xn_over_d(d, 1000 - m, 1000); return round_xn_over_d(width(p) - d, get_ef_code(font(l), character(l)), 1000); } +*/ + +scaled kern_shrink(halfword p) +{ + int m; + scaled d, e, x; + scaled w = width(p) ; + halfword l; + halfword r; + if (w == 0) { + /* why bother about zero kerns */ + return 0; + } + l = prev_char_p ; + if ((l == null) || (vlink(l) != p)) { + /* we only care about kerns following a char*/ + return 0; + } + r = vlink(p); + if (r == null) { + /* we only care about kerns between a char and something else */ + } + if (!(is_char_node(l) && is_char_node(r))) { + /* we want two chars (but but don't care about the fonts) */ + return 0; + } + /* we use the old logic, kind of, but average the ef as we might depend on proper overlap */ + m = (font_max_shrink(font(l)) + font_max_shrink(font(r)))/2; + if (m == 0) { + /* nothing to kern */ + return 0; + } + d = round_xn_over_d(w, 1000 - m, 1000); + e = (get_ef_code(font(l), character(l)) + get_ef_code(font(r), character(r)))/2 ; + if (e == 1000) { + x = w - d ; + } else { + x = round_xn_over_d(w - d, e, 1000); + } + /* + printf("SHRINK w=%i s=%i x=%i\n",w,e+m,x); + */ + return x; +} @ @c void do_subst_font(halfword p, int ex_ratio) @@ -513,6 +614,8 @@ halfword new_margin_kern(scaled w, halfword p, int side) expansion is being used. @c +int font_expand_ratio = 0; /* current expansion ratio, needed for recursive call */ + halfword hpack(halfword p, scaled w, int m, int pack_direction) { halfword r; /* the box node that will be returned */ @@ -530,8 +633,11 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) halfword pack_interrupt[8]; scaled font_stretch = 0; scaled font_shrink = 0; - int font_expand_ratio = 0; /* current expansion ratio */ - scaled k = 0; + int adjust_spacing = int_par(adjust_spacing_code); + +/* + int font_expand_ratio = 0; +*/ last_badness = 0; r = new_node(hlist_node, min_quarterword); /* the box node that will be returned */ if (pack_direction == -1) { @@ -555,6 +661,9 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) if (m == cal_expand_ratio) { prev_char_p = null; /* why not always */ } + if (adjust_spacing > 2) { + adjust_spacing = 0; + } total_stretch[normal] = 0; total_shrink[normal] = 0; total_stretch[sfi] = 0; @@ -664,20 +773,27 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) } break; case kern_node: - if (subtype(p) == normal) { + x += width(p); + if (subtype(p) == font_kern && adjust_spacing) { + /* so only when 1 or 2 */ if (m == cal_expand_ratio) { font_stretch = font_stretch + kern_stretch(p); font_shrink = font_shrink + kern_shrink(p); } else if (m == subst_ex_font) { - if (font_expand_ratio > 0) + /* this is the finalizer */ + int k = 0; + if (font_expand_ratio > 0) { k = kern_stretch(p); - else if (font_expand_ratio < 0) + } else if (font_expand_ratio < 0) { k = kern_shrink(p); - if (k != 0) - width(p) = get_kern(font(prev_char_p), character(prev_char_p), character(vlink(p))); + } + ex_kern(p) = k; + x += k; + /* + if (x!=0) printf("SET %i %i %i\n",font_expand_ratio,k,x); + */ } } - x += width(p); break; case disc_node: if (m == subst_ex_font) @@ -985,10 +1101,13 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) q = list_ptr(r); list_ptr(r) = null; flush_node(r); + /* this nested call uses the more or less global font_expand_ratio */ r = hpack(q, w, subst_ex_font, hpack_dir); } while (dir_ptr1 != null) pop_dir_node(dir_ptr1); + /* here we reset the font_expan_ratio */ + font_expand_ratio = 0; return r; } @@ -1119,9 +1238,11 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult, } break; case margin_kern_node: - case kern_node: siz.wd += width(p); break; + case kern_node: + siz.wd += width(p) + ex_kern(p); + break; case disc_node: xx = natural_sizes(no_break(p), null, g_mult, g_sign, g_order, hpack_dir); siz.wd += xx.wd; diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w index 81cfd9cf733..f501d403597 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.w +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w @@ -2138,8 +2138,8 @@ static void resume_after_display(void) push_nest(); mode = hmode; space_factor = 1000; - tail_append(make_local_par_node()); /* this needs to be intercepted in - the display math start ! */ + tail_append(make_local_par_node(4)); /* this needs to be intercepted in + the display math start ! */ get_x_token(); if (cur_cmd != spacer_cmd) back_input(); diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h index aad7bfa026d..cbf983d9736 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h @@ -252,6 +252,7 @@ typedef enum { # define x_displace(a) vinfo((a)+4) # define y_displace(a) vlink((a)+4) # define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */ +# define x_advance(a) vlink((a)+5) # define is_char_node(a) (a!=null && type(a)==glyph_node) @@ -944,7 +945,7 @@ extern int lua_properties_use_metatable ; #define local_left_box equiv(local_left_box_base) #define local_right_box equiv(local_right_box_base) -extern halfword make_local_par_node(void); +extern halfword make_local_par_node(int mode); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w index de718139923..698fb76e82d 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w @@ -473,8 +473,7 @@ important, don't keep resolving the registry index. if (lua_properties_enabled) { \ lua_properties_level = lua_properties_level + 1 ; \ if (lua_properties_level == 1) { \ - lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \ - lua_gettable(Luas, LUA_REGISTRYINDEX); \ + lua_get_metatablelua_l(Luas,node_properties); \ } \ } \ } while(0) @@ -497,8 +496,7 @@ important, don't keep resolving the registry index. #define lua_properties_reset(target) do { \ if (lua_properties_enabled) { \ if (lua_properties_level == 0) { \ - lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \ - lua_gettable(Luas, LUA_REGISTRYINDEX); \ + lua_get_metatablelua_l(Luas,node_properties); \ lua_pushnil(Luas); \ lua_rawseti(Luas,-2,target); \ lua_pop(Luas,1); \ @@ -549,8 +547,7 @@ important, don't keep resolving the registry index. #define lua_properties_copy(target,source) do { \ if (lua_properties_enabled) { \ if (lua_properties_level == 0) { \ - lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \ - lua_gettable(Luas, LUA_REGISTRYINDEX); \ + lua_get_metatablelua_l(Luas,node_properties); \ lua_rawgeti(Luas,-1,source); \ if (lua_type(Luas,-1)==LUA_TTABLE) { \ if (lua_properties_use_metatable) { \ @@ -3708,8 +3705,9 @@ the \.{WEB} macro definitions above, so that format changes will leave @c -halfword make_local_par_node(void) +halfword make_local_par_node(int mode) { + int callback_id; halfword q; halfword p = new_node(local_par_node,0); local_pen_inter(p) = local_inter_line_penalty; @@ -3725,5 +3723,26 @@ halfword make_local_par_node(void) local_box_right_width(p) = width(local_right_box); } local_par_dir(p) = par_direction; + /* callback with node passed */ + callback_id = callback_defined(insert_local_par_callback); + if (callback_id > 0) { + int sfix = lua_gettop(Luas); + if (!get_callback(Luas, callback_id)) { + lua_settop(Luas, sfix); + return p; + } + nodelist_to_lua(Luas, p); + lua_push_local_par_mode(Luas,mode) + if (lua_pcall(Luas, 2, 0, 0) != 0) { /* 2 arg, 0 result */ + char errmsg[256]; /* temp hack ... we will have a formatted error */ + snprintf(errmsg, 255, "error: %s\n", lua_tostring(Luas, -1)); + errmsg[255]='\0'; + lua_settop(Luas, sfix); + normal_error("insert_local_par",errmsg); /* to be done */ + return p; + } + lua_settop(Luas, sfix); + } + /* done */ return p; } |