diff options
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/tex')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/commands.h | 3 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/commands.w | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/linebreak.w | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/mainbody.w | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/printing.w | 11 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/scanning.h | 3 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/scanning.w | 31 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texfileio.w | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texnodes.h | 13 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texnodes.w | 431 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/textoken.h | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/textoken.w | 62 |
12 files changed, 396 insertions, 181 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h index ee0407b0eb7..690823b7856 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.h +++ b/Build/source/texk/web2c/luatexdir/tex/commands.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -/* $Id: commands.h 4634 2013-04-21 14:45:45Z hhenkel $ */ +/* $Id: commands.h 4877 2014-03-14 01:26:05Z luigi $ */ #ifndef COMMANDS_H # define COMMANDS_H @@ -263,6 +263,7 @@ typedef enum { font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */ font_id_code, /* command code for \.{\\fontid} */ uchar_code, /* command code for \.{\\Uchar} */ + lua_function_code, /* command code for \.{\\luafunction} */ } convert_codes; typedef enum { diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w index 75fdefda898..51d2112c1d5 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.w +++ b/Build/source/texk/web2c/luatexdir/tex/commands.w @@ -21,8 +21,8 @@ @ @c static const char _svn_version[] = - "$Id: commands.w 4634 2013-04-21 14:45:45Z hhenkel $" - "$URL: https://foundry.supelec.fr/svn/luatex/branches/ex-glyph/source/texk/web2c/luatexdir/tex/commands.w $"; + "$Id: commands.w 4878 2014-03-14 10:48:03Z taco $" + "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/commands.w $"; #include "ptexlib.h" @@ -490,6 +490,7 @@ void initialize_commands(void) 0); primitive_pdftex("pdfnormaldeviate", convert_cmd, normal_deviate_code, 0); primitive_core("directlua", convert_cmd, lua_code, 0); + primitive_luatex("luafunction", convert_cmd, lua_function_code, 0); primitive_luatex("luaescapestring", convert_cmd, lua_escape_string_code, 0); primitive_luatex("mathstyle", convert_cmd, math_style_code, 0); primitive_pdftex("expanded", convert_cmd, expanded_code, 0); diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w index fd486c3367e..646676bcfa2 100644 --- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w +++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w @@ -19,7 +19,7 @@ @ @c static const char _svn_version[] = - "$Id: linebreak.w 4777 2014-02-10 10:09:39Z luigi $" + "$Id: linebreak.w 4775 2014-02-07 12:36:34Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/linebreak.w $"; #include "ptexlib.h" diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.w b/Build/source/texk/web2c/luatexdir/tex/mainbody.w index 8f0e3c47f4c..9aada03cf30 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.w +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.w @@ -23,7 +23,7 @@ @ @c static const char _svn_version[] = - "$Id: mainbody.w 4722 2014-01-03 09:32:35Z taco $" + "$Id: mainbody.w 4877 2014-03-14 01:26:05Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/mainbody.w $"; #include "ptexlib.h" @@ -443,7 +443,7 @@ void main_body(void) if (pdf_draftmode_option != 0) pdf_draftmode = static_pdf->draftmode = pdf_draftmode_value; pdf_init_map_file((char *) pdftex_map); - if (end_line_char_inactive()) + if (end_line_char_inactive) decr(ilimit); else buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code); diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.w b/Build/source/texk/web2c/luatexdir/tex/printing.w index 77d55a736b1..53bd0c79a8a 100644 --- a/Build/source/texk/web2c/luatexdir/tex/printing.w +++ b/Build/source/texk/web2c/luatexdir/tex/printing.w @@ -19,7 +19,7 @@ @ @c static const char _svn_version[] = - "$Id: printing.w 4722 2014-01-03 09:32:35Z taco $" + "$Id: printing.w 4857 2014-03-07 00:01:41Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/printing.w $"; #include "ptexlib.h" @@ -477,6 +477,15 @@ void print_banner(const char *v, int ver) if (format_ident > 0) print(format_ident); print_ln(); + if (show_luahashchars){ + wterm(' '); +#ifdef LuajitTeX + fprintf(term_out,"Number of bits used by the hash function (luajittex): %d",LUAJITTEX_HASHCHARS); +#else + fprintf(term_out,"Number of bits used by the hash function (luatex): %d",LUATEX_HASHCHARS); +#endif + print_ln(); + } if (shellenabledp) { wterm(' '); if (restrictedshell) diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.h b/Build/source/texk/web2c/luatexdir/tex/scanning.h index 8c263404173..ca7804ea749 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.h +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -/* $Id: scanning.h 4085 2011-02-10 09:21:57Z taco $ */ +/* $Id: scanning.h 4877 2014-03-14 01:26:05Z luigi $ */ #ifndef SCANNING_H # define SCANNING_H @@ -57,7 +57,6 @@ extern void scan_limited_int(int max, const char *name); extern void scan_fifteen_bit_int(void); extern void scan_fifty_one_bit_int(void); -extern void scan_string_argument(void); extern void scan_four_bit_int_or_18(void); # define octal_token (other_token+'\'') /* apostrophe, indicates an octal constant */ diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.w b/Build/source/texk/web2c/luatexdir/tex/scanning.w index 6e1a423d173..f3cc9b29bb5 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.w +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.w @@ -19,8 +19,8 @@ @ @c static const char _svn_version[] = - "$Id: scanning.w 4562 2013-01-21 02:58:59Z khaled $" - "$URL: https://foundry.supelec.fr/svn/luatex/branches/ex-glyph/source/texk/web2c/luatexdir/tex/scanning.w $"; + "$Id: scanning.w 4877 2014-03-14 01:26:05Z luigi $" + "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/scanning.w $"; #include "ptexlib.h" @@ -939,33 +939,6 @@ void scan_four_bit_int_or_18(void) } -@ @c -void scan_string_argument(void) -{ - int s; - scan_left_brace(); - get_x_token(); - while ((cur_cmd != right_brace_cmd)) { - if ((cur_cmd == letter_cmd) || (cur_cmd == other_char_cmd)) { - str_room(1); - append_char(cur_chr); - } else if (cur_cmd == spacer_cmd) { - str_room(1); - append_char(' '); - } else { - tprint("Bad token appearing in string argument"); - } - get_x_token(); - } - s = make_string(); - /* todo: this was just conserving the string pool: */ -#if 0 - if (str_eq_str("mi",s)) s="mi"; - if (str_eq_str("mo",s)) s="mo"; - if (str_eq_str("mn",s)) s="mn"; -#endif - cur_val = s; -} @ An integer number can be preceded by any number of spaces and `\.+' or diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.w b/Build/source/texk/web2c/luatexdir/tex/texfileio.w index 769dd3bd1c8..3a7ab5578c0 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texfileio.w +++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.w @@ -19,7 +19,7 @@ @ @c static const char _svn_version[] = - "$Id: texfileio.w 4722 2014-01-03 09:32:35Z taco $" + "$Id: texfileio.w 4877 2014-03-14 01:26:05Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/texfileio.w $"; #include "ptexlib.h" @@ -973,7 +973,7 @@ void start_input(void) ; } firm_up_the_line(); - if (end_line_char_inactive()) + if (end_line_char_inactive) decr(ilimit); else buffer[ilimit] = (packed_ASCII_code) end_line_char; diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h index bfc3a424091..d1015373909 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h @@ -1,5 +1,5 @@ /* texnodes.h - + Copyright 2006-2008 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -/* $Id: texnodes.h 4634 2013-04-21 14:45:45Z hhenkel $ */ +/* $Id: texnodes.h 4847 2014-03-05 18:13:17Z luigi $ */ #include <stdarg.h> @@ -146,7 +146,7 @@ typedef enum { # define synctex_tag_glue(a) vinfo((a)+3) # define synctex_line_glue(a) vlink((a)+3) -/* disc nodes could eventually be smaller, because the indirect +/* disc nodes could eventually be smaller, because the indirect pointers are not really needed (8 instead of 10). */ @@ -691,7 +691,7 @@ extern void print_short_node_contents(halfword n); extern void show_node_list(int i); extern pointer actual_box_width(pointer r, scaled base_width); -/* TH: these two defines still need checking. The node ordering in luatex is not +/* TH: these two defines still need checking. The node ordering in luatex is not quite the same as in tex82 */ # define precedes_break(a) (type((a))<math_node && \ @@ -785,4 +785,9 @@ extern halfword new_skip_param(int n); extern halfword new_kern(scaled w); extern halfword new_penalty(int m); +extern int lua_properties_enabled ; +extern int lua_properties_level ; +extern int lua_properties_use_metatable ; + #endif + diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w index c087343b90c..73b39d08757 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w @@ -19,7 +19,7 @@ @ @c static const char _svn_version[] = - "$Id: texnodes.w 4754 2014-01-23 10:01:21Z taco $" + "$Id: texnodes.w 4847 2014-03-05 18:13:17Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/texnodes.w $"; #include "ptexlib.h" @@ -334,6 +334,173 @@ node_info whatsit_node_data[] = { #define last_whatsit_node user_defined_node +/* hh: experiment */ + +/* + +When we copy a node list, there are several possibilities: we do the same as a new node, +we copy the entry to the table in properties (a reference), we do a deep copy of a table +in the properties, we create a new table and give it the original one as a metatable. +After some experiments (that also included timing) with these scenarios I decided that a +deep copy made no sense, nor did nilling. In the end both the shallow copy and the metatable +variant were both ok, although the second ons is slower. The most important aspect to keep +in mind is that references to other nodes in properties no longer can be valid for that +copy. We could use two tables (one unique and one shared) or metatables but that only +complicates matters. + +When defining a new node, we could already allocate a table but it is rather easy to do +that at the lua end e.g. using a metatable __index method. That way it is under macro +package control. + +When deleting a node, we could keep the slot (e.g. setting it to false) but it could make +memory consumption raise unneeded when we have temporary large node lists and after that +only small lists. + +So, in the end this is what we ended up with. For the record, I also experimented with the +following: + +- copy attributes to the properties so that we hav efast access at the lua end: in the end + the overhead is not compensated by speed and convenience, in fact, attributes are not + that slow when it comes to accessing them +- a bitset in the node but again the gain compared to attributes is neglectable and it also + demands a pretty string agreement over what bit represents what, and this is unlikely to + succeed in the tex community (I could use it for font handling, which is cross package, + but decided that it doesn't pay off + +In case one wonders why properties make sense then, well, it is not so much speed that we +gain, but more convenience: storing all kind of (temporary) data in attributes is no fun and +this mechanism makes sure that properties are cleaned up when a node is freed. Also, the +advantage of a more or less global properties table is that we stay at the lua end. An +alternative is to store a reference in the node itself but that is complicated by the fact +that the register has some limitations (no numeric keys) and we also don't want to mess with +it too much. + +*/ + +int lua_properties_level = 0 ; /* can be private */ +int lua_properties_enabled = 0 ; +int lua_properties_use_metatable = 0 ; + +/* We keep track of nesting so that we don't oveflow the stack, and, what is more important, +don't keep resolving the registry index. */ + +#define lua_properties_push do { \ + 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); \ + } \ + } \ +} while(0) + +#define lua_properties_pop do { \ + if (lua_properties_enabled) { \ + if (lua_properties_level == 1) \ + lua_pop(Luas,1); \ + lua_properties_level = lua_properties_level - 1 ; \ + } \ +} while(0) + +/* No setting is needed: */ + +#define lua_properties_set(target) do { \ +} while(0) + +/* Resetting boils down to nilling. */ + +#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_pushnil(Luas); \ + lua_rawseti(Luas,-2,target); \ + lua_pop(Luas,1); \ + } else { \ + lua_pushnil(Luas); \ + lua_rawseti(Luas,-2,target); \ + } \ + } \ +} while(0) + +/* For a moment I considered supporting all kind of data types but in practice +that makes no sense. So we stick to a cheap shallow copy with as option a +metatable. Btw, a deep copy would look like this: + +static void copy_lua_table(lua_State* L, int index) { + lua_newtable(L); + lua_pushnil(L); + while(lua_next(L, index-1) != 0) { + lua_pushvalue(L, -2); + lua_insert(L, -2); + if (lua_type(L,-1)==LUA_TTABLE) + copy_lua_table(L,-1); + lua_settable(L, -4); + } + lua_pop(L,1); +} + +#define lua_properties_copy(target, source) do { \ + if (lua_properties_enabled) { \ + lua_pushnumber(Luas,source); \ + lua_rawget(Luas,-2); \ + if (lua_type(Luas,-1)==LUA_TTABLE) { \ + copy_lua_table(Luas,-1); \ + lua_pushnumber(Luas,target); \ + lua_insert(Luas,-2); \ + lua_rawset(Luas,-3); \ + } else { \ + lua_pop(Luas,1); \ + } \ + } \ +} while(0) + +*/ + +/* isn't there a faster way to metatable? */ + +#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_rawgeti(Luas,-1,source); \ + if (lua_type(Luas,-1)==LUA_TTABLE) { \ + if (lua_properties_use_metatable) { \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setfield(Luas,-2,"__index"); \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setmetatable(Luas,-2); \ + } \ + lua_rawseti(Luas,-2,target); \ + } else { \ + lua_pop(Luas,1); \ + } \ + lua_pop(Luas,1); \ + } else { \ + lua_rawgeti(Luas,-1,source); \ + if (lua_type(Luas,-1)==LUA_TTABLE) { \ + if (lua_properties_use_metatable) { \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setfield(Luas,-2,"__index"); \ + lua_newtable(Luas); \ + lua_insert(Luas,-2); \ + lua_setmetatable(Luas,-2); \ + } \ + lua_rawseti(Luas,-2,target); \ + } else { \ + lua_pop(Luas,1); \ + } \ + } \ + } \ +} while(0) + +/* Here end the property handlers. */ + @ @c halfword new_node(int i, int j) { @@ -408,7 +575,6 @@ halfword new_node(int i, int j) synctex_line_glue(n) = line; break; case kern_node: - /* synctex ignores implicit kerns */ if (j != 0) { synctex_tag_kern(n) = cur_input.synctex_tag_field; synctex_line_kern(n) = line; @@ -428,6 +594,7 @@ halfword new_node(int i, int j) /* take care of attributes */ if (nodetype_has_attributes(i)) { build_attribute_list(n); + /* lua_properties_set */ } type(n) = (quarterword) i; subtype(n) = (quarterword) j; @@ -458,20 +625,23 @@ halfword new_glyph_node(void) type(n) = glyph_node; subtype(n) = 0; build_attribute_list(n); + /* lua_properties_set */ return n; } @ makes a duplicate of the node list that starts at |p| and returns a - pointer to the new list + pointer to the new list @c halfword do_copy_node_list(halfword p, halfword end) { halfword q = null; /* previous position in new list */ halfword h = null; /* head of the list */ + register halfword s ; copy_error_seen = 0; + lua_properties_push; /* saves stack and time */ while (p != end) { - register halfword s = copy_node(p); + s = copy_node(p); if (h == null) { h = s; } else { @@ -480,6 +650,7 @@ halfword do_copy_node_list(halfword p, halfword end) q = s; p = vlink(p); } + lua_properties_pop; /* saves stack and time */ return h; } @@ -488,7 +659,50 @@ halfword copy_node_list(halfword p) return do_copy_node_list(p, null); } -@ make a dupe of a single node +/* There is no gain in using a temp var: + + #define copy_sub_list(target,source) do { \ + l = source; \ + if (l != null) { \ + s = copy_node_list(l); \ + target = s; \ + } else { \ + target = null; \ + } \ + } while (0) + + #define copy_sub_node(target,source) do { \ + l = source; \ + if (l != null) { \ + s = copy_node(l); \ + target = s ; \ + } else { \ + target = null; \ + } \ + } while (0) + + So we use: +*/ + +#define copy_sub_list(target,source) do { \ + if (source != null) { \ + s = do_copy_node_list(source, null); \ + target = s; \ + } else { \ + target = null; \ + } \ + } while (0) + +#define copy_sub_node(target,source) do { \ + if (source != null) { \ + s = copy_node(source); \ + target = s ; \ + } else { \ + target = null; \ + } \ +} while (0) + +@ make a dupe of a single node @c halfword copy_node(const halfword p) { @@ -506,7 +720,7 @@ halfword copy_node(const halfword p) (sizeof(memory_word) * (unsigned) i)); /* handle synctex extension */ - switch (type(p)) { + switch (type(p)) { case math_node: synctex_tag_math(r) = cur_input.synctex_tag_field; synctex_line_math(r) = line; @@ -516,38 +730,25 @@ halfword copy_node(const halfword p) synctex_line_kern(r) = line; break; } - if (nodetype_has_attributes(type(p))) { add_node_attr_ref(node_attr(p)); - alink(r) = null; /* needs checking */ + alink(r) = null; + lua_properties_copy(r,p); } vlink(r) = null; - switch (type(p)) { case glyph_node: - s = copy_node_list(lig_ptr(p)); - lig_ptr(r) = s; + copy_sub_list(lig_ptr(r),lig_ptr(p)) ; break; case glue_node: add_glue_ref(glue_ptr(p)); - s = copy_node_list(leader_ptr(p)); - leader_ptr(r) = s; + copy_sub_list(leader_ptr(r),leader_ptr(p)) ; break; case hlist_node: case vlist_node: case unset_node: - s = copy_node_list(list_ptr(p)); - list_ptr(r) = s; - break; - case ins_node: - add_glue_ref(split_top_ptr(p)); - s = copy_node_list(ins_ptr(p)); - ins_ptr(r) = s; - break; - case margin_kern_node: - s = copy_node(margin_char(p)); - margin_char(r) = s; + copy_sub_list(list_ptr(r),list_ptr(p)) ; break; case disc_node: pre_break(r) = pre_break_head(r); @@ -578,63 +779,51 @@ halfword copy_node(const halfword p) assert(tlink_no_break(r) == null); } break; + case ins_node: + add_glue_ref(split_top_ptr(p)); + copy_sub_list(ins_ptr(r),ins_ptr(p)) ; + break; + case margin_kern_node: + copy_sub_node(margin_char(r),margin_char(p)); + break; case mark_node: add_token_ref(mark_ptr(p)); break; case adjust_node: - s = copy_node_list(adjust_ptr(p)); - adjust_ptr(r) = s; + copy_sub_list(adjust_ptr(r),adjust_ptr(p)); break; - case choice_node: - s = copy_node_list(display_mlist(p)); - display_mlist(r) = s; - s = copy_node_list(text_mlist(p)); - text_mlist(r) = s; - s = copy_node_list(script_mlist(p)); - script_mlist(r) = s; - s = copy_node_list(script_script_mlist(p)); - script_script_mlist(r) = s; + copy_sub_list(display_mlist(r),display_mlist(p)) ; + copy_sub_list(text_mlist(r),text_mlist(p)) ; + copy_sub_list(script_mlist(r),script_mlist(p)) ; + copy_sub_list(script_script_mlist(r),script_script_mlist(p)) ; break; case simple_noad: case radical_noad: case accent_noad: - s = copy_node_list(nucleus(p)); - nucleus(r) = s; - s = copy_node_list(subscr(p)); - subscr(r) = s; - s = copy_node_list(supscr(p)); - supscr(r) = s; + copy_sub_list(nucleus(r),nucleus(p)) ; + copy_sub_list(subscr(r),subscr(p)) ; + copy_sub_list(supscr(r),supscr(p)) ; if (type(p) == accent_noad) { - s = copy_node_list(accent_chr(p)); - accent_chr(r) = s; - s = copy_node_list(bot_accent_chr(p)); - bot_accent_chr(r) = s; + copy_sub_list(accent_chr(r),accent_chr(p)) ; + copy_sub_list(bot_accent_chr(r),bot_accent_chr(p)) ; } else if (type(p) == radical_noad) { - s = copy_node(left_delimiter(p)); - left_delimiter(r) = s; - s = copy_node_list(degree(p)); - degree(r) = s; + copy_sub_node(left_delimiter(r),left_delimiter(p)) ; + copy_sub_list(degree(r),degree(p)) ; } break; case fence_noad: - s = copy_node(delimiter(p)); - delimiter(r) = s; + copy_sub_node(delimiter(r),delimiter(p)) ; break; case sub_box_node: case sub_mlist_node: - s = copy_node_list(math_list(p)); - math_list(r) = s; + copy_sub_list(math_list(r),math_list(p)) ; break; case fraction_noad: - s = copy_node_list(numerator(p)); - numerator(r) = s; - s = copy_node_list(denominator(p)); - denominator(r) = s; - s = copy_node(left_delimiter(p)); - left_delimiter(r) = s; - s = copy_node(right_delimiter(p)); - right_delimiter(r) = s; + copy_sub_list(numerator(r),numerator(p)) ; + copy_sub_list(denominator(r),denominator(p)) ; + copy_sub_node(left_delimiter(r),left_delimiter(p)) ; + copy_sub_node(right_delimiter(r),right_delimiter(p)) ; break; case glue_spec_node: glue_ref_count(r) = null; @@ -880,6 +1069,33 @@ int copy_error(halfword p) return 0; } +/* No gain in a helper: + + #define free_sub_list(source) do { \ + l = source; \ + if (l != null) \ + flush_node_list(l); \ + } while (0) + + #define free_sub_node(source) do { \ + l = source; \ + if (l != null) \ + flush_node(l); \ + } while (0) + + So: + +*/ + +#define free_sub_list(source) do { \ + if (source != null) \ + flush_node_list(source); \ +} while (0) + +#define free_sub_node(source) do { \ + if (source != null) \ + flush_node(source); \ +} while (0) @ @c void flush_node(halfword p) @@ -897,11 +1113,29 @@ void flush_node(halfword p) switch (type(p)) { case glyph_node: - flush_node_list(lig_ptr(p)); + free_sub_list(lig_ptr(p)); break; case glue_node: delete_glue_ref(glue_ptr(p)); - flush_node_list(leader_ptr(p)); + free_sub_list(leader_ptr(p)); + break; + case hlist_node: + case vlist_node: + case unset_node: + free_sub_list(list_ptr(p)); + break; + case disc_node: + free_sub_list(vlink(pre_break(p))); + free_sub_list(vlink(post_break(p))); + free_sub_list(vlink(no_break(p))); +// why not: free_sub_list(pre_break(p)); +// why not: free_sub_list(post_break(p)); +// why not: free_sub_list(no_break(p)); + break; + case rule_node: + case kern_node: + case math_node: + case penalty_node: break; case glue_spec_node: /* this allows free-ing of lua-allocated glue specs */ @@ -914,20 +1148,6 @@ void flush_node(halfword p) } return ; break ; - case attribute_node: - case attribute_list_node: - case temp_node: - case rule_node: - case kern_node: - case math_node: - case penalty_node: - break; - - case hlist_node: - case vlist_node: - case unset_node: - flush_node_list(list_ptr(p)); - break; case whatsit_node: switch (subtype(p)) { @@ -1039,38 +1259,33 @@ void flush_node(halfword p) case mark_node: delete_token_ref(mark_ptr(p)); break; - case disc_node: - flush_node_list(vlink(pre_break(p))); - flush_node_list(vlink(post_break(p))); - flush_node_list(vlink(no_break(p))); - break; case adjust_node: flush_node_list(adjust_ptr(p)); break; case style_node: /* nothing to do */ break; case choice_node: - flush_node_list(display_mlist(p)); - flush_node_list(text_mlist(p)); - flush_node_list(script_mlist(p)); - flush_node_list(script_script_mlist(p)); + free_sub_list(display_mlist(p)); + free_sub_list(text_mlist(p)); + free_sub_list(script_mlist(p)); + free_sub_list(script_script_mlist(p)); break; case simple_noad: case radical_noad: case accent_noad: - flush_node_list(nucleus(p)); - flush_node_list(subscr(p)); - flush_node_list(supscr(p)); + free_sub_list(nucleus(p)); + free_sub_list(subscr(p)); + free_sub_list(supscr(p)); if (type(p) == accent_noad) { - flush_node_list(accent_chr(p)); - flush_node_list(bot_accent_chr(p)); + free_sub_list(accent_chr(p)); + free_sub_list(bot_accent_chr(p)); } else if (type(p) == radical_noad) { - flush_node(left_delimiter(p)); - flush_node_list(degree(p)); + free_sub_node(left_delimiter(p)); + free_sub_list(degree(p)); } break; case fence_noad: - flush_node(delimiter(p)); + free_sub_list(delimiter(p)); break; case delim_node: /* nothing to do */ case math_char_node: @@ -1078,16 +1293,16 @@ void flush_node(halfword p) break; case sub_box_node: case sub_mlist_node: - flush_node_list(math_list(p)); + free_sub_list(math_list(p)); break; case fraction_noad: - flush_node_list(numerator(p)); - flush_node_list(denominator(p)); - flush_node(left_delimiter(p)); - flush_node(right_delimiter(p)); + free_sub_list(numerator(p)); + free_sub_list(denominator(p)); + free_sub_node(left_delimiter(p)); + free_sub_node(right_delimiter(p)); break; case pseudo_file_node: - flush_node_list(pseudo_lines(p)); + free_sub_list(pseudo_lines(p)); break; case pseudo_line_node: case shape_node: @@ -1107,14 +1322,19 @@ void flush_node(halfword p) case inserting_node: case split_up_node: case expr_node: + case attribute_node: + case attribute_list_node: + case temp_node: break; default: fprintf(stdout, "flush_node: type is %d\n", type(p)); return; } - if (nodetype_has_attributes(type(p))) + if (nodetype_has_attributes(type(p))) { delete_attribute_ref(node_attr(p)); + lua_properties_reset(p); + } free_node(p, get_node_size(type(p), subtype(p))); return; } @@ -1128,12 +1348,13 @@ void flush_node_list(halfword pp) return; if (free_error(p)) return; - + lua_properties_push; /* saves stack and time */ while (p != null) { register halfword q = vlink(p); flush_node(p); p = q; } + lua_properties_pop; /* saves stack and time */ } @ @c @@ -1423,7 +1644,7 @@ halfword get_node(int s) { register halfword r; #if 0 - check_static_node_mem(); + check_static_node_mem(); #endif assert(s < MAX_CHAIN_SIZE); @@ -2566,9 +2787,9 @@ static void show_whatsit_node(int p) clobbered or chosen at random. -@ |str_room| need not be checked; see |show_box| +@ |str_room| need not be checked; see |show_box| -@ Recursive calls on |show_node_list| therefore use the following pattern: +@ Recursive calls on |show_node_list| therefore use the following pattern: @c #define node_list_display(A) do { \ append_char('.'); \ diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h index c557012e7a2..f757612fc5d 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.h +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -/* $Id: textoken.h 4634 2013-04-21 14:45:45Z hhenkel $ */ +/* $Id: textoken.h 4877 2014-03-14 01:26:05Z luigi $ */ #ifndef TEXTOKEN_H # define TEXTOKEN_H @@ -139,9 +139,9 @@ extern int get_char_cat_code(int); |get_next| if it wants to suppress expansion. */ -# define no_expand_flag special_char - -extern boolean end_line_char_inactive(void); +# define no_expand_flag special_char +# define end_line_char int_par(end_line_char_code) +# define end_line_char_inactive ((end_line_char < 0) || (end_line_char > 127)) extern halfword par_loc; extern halfword par_token; diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w index b12f54fa006..48f6e43d48b 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.w +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w @@ -19,7 +19,7 @@ @ @c static const char _svn_version[] = - "$Id: textoken.w 4786 2014-02-10 13:17:44Z taco $" + "$Id: textoken.w 4877 2014-03-14 01:26:05Z luigi $" "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/tex/textoken.w $"; #include "ptexlib.h" @@ -28,7 +28,6 @@ static const char _svn_version[] = #define pausing int_par(pausing_code) #define cat_code_table int_par(cat_code_table_code) #define tracing_nesting int_par(tracing_nesting_code) -#define end_line_char int_par(end_line_char_code) #define suppress_outer_error int_par(suppress_outer_error_code) #define every_eof equiv(every_eof_loc) @@ -1238,14 +1237,6 @@ static boolean check_expanded_code(int *kk) return false; } -@ todo: this is a function because it is still used from the converted pascal. - once that is gone, it can be a \#define again - -@c -boolean end_line_char_inactive(void) -{ - return ((end_line_char < 0) || (end_line_char > 127)); -} @ All of the easy branches of |get_next| have now been taken care of. There is one more branch. @@ -1327,7 +1318,7 @@ static next_line_retval next_line(void) } return next_line_restart; } - if (inhibit_eol || end_line_char_inactive()) + if (inhibit_eol || end_line_char_inactive) ilimit--; else buffer[ilimit] = (packed_ASCII_code) end_line_char; @@ -1346,7 +1337,7 @@ static next_line_retval next_line(void) if (selector < log_only) open_log_file(); if (interaction > nonstop_mode) { - if (end_line_char_inactive()) + if (end_line_char_inactive) ilimit++; if (ilimit == istart) { /* previous line was empty */ tprint_nl("(Please type a command or say `\\end')"); @@ -1355,7 +1346,7 @@ static next_line_retval next_line(void) first = istart; prompt_input("*"); /* input on-line into |buffer| */ ilimit = last; - if (end_line_char_inactive()) + if (end_line_char_inactive) ilimit--; else buffer[ilimit] = (packed_ASCII_code) end_line_char; @@ -1718,29 +1709,30 @@ static boolean print_convert_string(halfword c, int i) } @ @c -int scan_lua_state(void) +int scan_lua_state(void) /* hh-ls: optional name or number (not optional name optional number) */ { - int sn = 0; - if (scan_keyword("name")) { - scan_pdf_ext_toks(); - sn = def_ref; - } /* Parse optional lua state integer, or an instance name to be stored in |sn| */ /* Get the next non-blank non-relax non-call token */ + int sn = 0; do { get_x_token(); } while ((cur_cmd == spacer_cmd) || (cur_cmd == relax_cmd)); - back_input(); /* have to push it back, whatever it is */ if (cur_cmd != left_brace_cmd) { - scan_register_num(); - if (get_lua_name(cur_val)) - sn = (cur_val - 65536); + if (scan_keyword("name")) { + (void) scan_toks(false, true); + sn = def_ref; + } else { + scan_register_num(); + if (get_lua_name(cur_val)) + sn = (cur_val - 65536); + } } return sn; } + @ The procedure |conv_toks| uses |str_toks| to insert the token list for |convert| functions into the scanner; `\.{\\outer}' control sequences are allowed to follow `\.{\\string}' and `\.{\\meaning}'. @@ -1840,7 +1832,7 @@ void conv_toks(void) save_warning_index = warning_index; save_def_ref = def_ref; u = save_cur_string(); - scan_pdf_ext_toks(); + scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ s = tokens_to_string(def_ref); delete_token_ref(def_ref); def_ref = save_def_ref; @@ -1870,7 +1862,7 @@ void conv_toks(void) save_scanner_status = scanner_status; save_def_ref = def_ref; save_warning_index = warning_index; - scan_pdf_ext_toks(); + scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ bool = in_lua_escape; in_lua_escape = true; escstr.s = (unsigned char *) tokenlist_to_cstring(def_ref, false, &l); @@ -1893,7 +1885,7 @@ void conv_toks(void) save_warning_index = warning_index; save_def_ref = def_ref; u = save_cur_string(); - scan_pdf_ext_toks(); + scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ warning_index = save_warning_index; scanner_status = save_scanner_status; ins_list(token_link(def_ref)); @@ -1907,7 +1899,7 @@ void conv_toks(void) save_def_ref = def_ref; save_warning_index = warning_index; sn = scan_lua_state(); - scan_pdf_ext_toks(); + scan_toks(false, true); /*hh-ls was scan_pdf_ext_toks();*/ s = def_ref; warning_index = save_warning_index; def_ref = save_def_ref; @@ -1920,6 +1912,19 @@ void conv_toks(void) lua_string_start(); return; break; + case lua_function_code: + scan_int(); + if (cur_val <= 0) { + pdf_error("luafunction", "invalid number"); + } else { + u = save_cur_string(); + luacstrings = 0; + luafunctioncall(cur_val); + restore_cur_string(u); + if (luacstrings > 0) + lua_string_start(); + } + break; case pdf_insert_ht_code: scan_register_num(); break; @@ -2021,6 +2026,7 @@ void conv_toks(void) case pdf_creation_date_code: case lua_escape_string_code: case lua_code: + case lua_function_code: case expanded_code: break; default: @@ -2157,7 +2163,7 @@ void read_toks(int n, halfword r, halfword j) } ilimit = last; - if (end_line_char_inactive()) + if (end_line_char_inactive) decr(ilimit); else buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code); |