diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-09 23:43:20 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-09 23:43:20 +0000 |
commit | aa5d0e8bf3515c424ba0594a2d4e06ae31da7796 (patch) | |
tree | e56fd10d89732547ddb207c1998a1ded4360382e /Build/source/texk/web2c/luatexdir/tex/texnodes.w | |
parent | d33684eeca435784c95c62c7981dd02f7818b263 (diff) |
Imported Luatex 1.06.3 (Lua 5.2.4)
git-svn-id: svn://tug.org/texlive/trunk@46269 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/tex/texnodes.w')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/tex/texnodes.w | 187 |
1 files changed, 157 insertions, 30 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w index 7967006ec35..d0008b08fc8 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w @@ -656,11 +656,14 @@ static int test_count = 1; #define check_action_ref(a) { dorangetest(p,a,var_mem_max); } #define check_attribute_ref(a) { dorangetest(p,a,var_mem_max); } -#define check_token_ref(a) { \ + +/* hm, we can just pass p then */ + +#define check_token_ref(p) { \ if (type(p) == whatsit_node) { \ - formatted_error("nodes","fuzzy token cleanup in whatsit node with id %i and subtype %i",type(p),subtype(p)); \ + formatted_error("nodes","fuzzy token cleanup in whatsit node with type %s and subtype %i",node_data[type(p)].name,subtype(p)); \ } else { \ - formatted_error("nodes","fuzzy token cleanup in node with id %i",type(p)); \ + formatted_error("nodes","fuzzy token cleanup in node with type %s",node_data[type(p)].name); \ } \ } @@ -828,6 +831,67 @@ static int copy_error(halfword p) } @ @c +static halfword synctex_anyway_mode = 0; /* 2 also glyphs */ +static halfword synctex_line_field = 0; +static halfword synctex_no_files = 0; + +void synctex_set_mode(int m) +{ + synctex_anyway_mode = m; +}; + +int synctex_get_mode(void) +{ + return synctex_anyway_mode; +}; + +void synctex_set_no_files(int f) +{ + synctex_no_files = f; +}; + +int synctex_get_no_files(void) +{ + return (int) synctex_no_files ; +}; + +void synctex_set_tag(int t) +{ + cur_input.synctex_tag_field = t; +}; + +int synctex_get_tag(void) +{ + return (int) cur_input.synctex_tag_field; +}; + + +int synctex_get_line(void) +{ + return (int) synctex_line_field; +}; + +static int forced_tag = 0; +static int forced_line = 0; + +void synctex_force_tag(int t) +{ + forced_tag = t; +}; + +void synctex_force_line(int t) +{ + forced_line = t; +}; + +void synctex_set_line(int l) +{ + synctex_line_field = l; +}; + +@ @c +/* if_stack is called a lot so maybe optimize */ + halfword new_node(int i, int j) { int s = get_node_size(i, j); @@ -892,13 +956,54 @@ halfword new_node(int i, int j) default: break; } - if (synctex_par) { - /* handle synctex extension */ + if (synctex_anyway_mode) { switch (i) { - case math_node: - synctex_tag_math(n) = cur_input.synctex_tag_field; - synctex_line_math(n) = line; + /* 1 = all but glyphs */ + /* 2 = also glyphs */ + /* 3 = glyphs and glue */ + /* 4 = only glyphs */ + case glyph_node: + if (synctex_anyway_mode > 1) { + synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + break; + case glue_node: + if (synctex_anyway_mode < 4) { + synctex_tag_glue(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_glue(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + break; + case kern_node: + if (synctex_anyway_mode < 3) { + synctex_tag_kern(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_kern(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + break; + case hlist_node: + case vlist_node: + case unset_node: /* useless */ + if (synctex_anyway_mode < 3) { + synctex_tag_box(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_box(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + break; + case rule_node: + if (synctex_anyway_mode < 3) { + synctex_tag_rule(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_rule(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } break; + case math_node: /* noads probably make more sense */ + if (synctex_anyway_mode < 3) { + synctex_tag_math(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_math(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + break; + } + } else if (synctex_par) { + /* handle synctex extension */ + switch (i) { case glue_node: synctex_tag_glue(n) = cur_input.synctex_tag_field; synctex_line_glue(n) = line; @@ -919,6 +1024,10 @@ halfword new_node(int i, int j) synctex_tag_rule(n) = cur_input.synctex_tag_field; synctex_line_rule(n) = line; break; + case math_node: + synctex_tag_math(n) = cur_input.synctex_tag_field; + synctex_line_math(n) = line; + break; } } /* take care of attributes */ @@ -935,6 +1044,10 @@ halfword raw_glyph_node(void) { register halfword n = get_node(glyph_node_size); (void) memset((void *) (varmem + n + 1), 0, (sizeof(memory_word) * (glyph_node_size - 1))); + if (synctex_anyway_mode > 1) { + synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } type(n) = glyph_node; subtype(n) = 0; return n; @@ -944,6 +1057,10 @@ halfword new_glyph_node(void) { register halfword n = get_node(glyph_node_size); (void) memset((void *) (varmem + n + 1), 0, (sizeof(memory_word) * (glyph_node_size - 1))); + if (synctex_anyway_mode > 1) { + synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } type(n) = glyph_node; subtype(n) = 0; build_attribute_list(n); @@ -1102,7 +1219,16 @@ halfword copy_node(const halfword p) } */ - if (synctex_par) { + if (synctex_anyway_mode) { + /* + if (t == glyph_node) { + if (synctex_anyway_mode > 1) { + synctex_tag_glyph(r) = forced_tag ? forced_tag : cur_input.synctex_tag_field; + synctex_line_glyph(r) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line; + } + } + */ + } else if (synctex_par) { /* handle synctex extension */ switch (t) { case math_node: @@ -1520,7 +1646,7 @@ static void check_node_wrapup_core(halfword p) switch (subtype(p)) { /* frontend code */ case special_node: - check_token_ref(write_tokens(p)); + check_token_ref(p); break; case user_defined_node: switch (user_node_type(p)) { @@ -1528,7 +1654,7 @@ static void check_node_wrapup_core(halfword p) check_attribute_ref(user_node_value(p)); break; case 't': - check_token_ref(user_node_value(p)); + check_token_ref(p); break; case 'n': dorangetest(p, user_node_value(p), var_mem_max); @@ -1558,39 +1684,39 @@ void check_node_wrapup_pdf(halfword p) switch (subtype(p)) { case pdf_literal_node: if (pdf_literal_type(p) == normal) - check_token_ref(pdf_literal_data(p)); + check_token_ref(p); break; case pdf_colorstack_node: if (pdf_colorstack_cmd(p) <= colorstack_data) - check_token_ref(pdf_colorstack_data(p)); + check_token_ref(p); break; case pdf_setmatrix_node: - check_token_ref(pdf_setmatrix_data(p)); + check_token_ref(p); break; case late_lua_node: if (late_lua_name(p) > 0) - check_token_ref(late_lua_name(p)); + check_token_ref(p); if (late_lua_type(p) == normal) - check_token_ref(late_lua_data(p)); + check_token_ref(p); break; case pdf_annot_node: - check_token_ref(pdf_annot_data(p)); + check_token_ref(p); break; case pdf_start_link_node: if (pdf_link_attr(p) != null) - check_token_ref(pdf_link_attr(p)); + check_token_ref(p); check_action_ref(pdf_link_action(p)); break; case pdf_dest_node: if (pdf_dest_named_id(p) > 0) - check_token_ref(pdf_dest_id(p)); + check_token_ref(p); break; case pdf_thread_node: case pdf_start_thread_node: if (pdf_thread_named_id(p) > 0) - check_token_ref(pdf_thread_id(p)); + check_token_ref(p); if (pdf_thread_attr(p) != null) - check_token_ref(pdf_thread_attr(p)); + check_token_ref(p); break; case pdf_save_node: case pdf_restore_node: @@ -1718,18 +1844,19 @@ void check_node(halfword p) } @ @c -void fix_node_list(halfword head) +halfword fix_node_list(halfword head) { - halfword p, q; + halfword next, tail; if (head == null) - return; - p = head; - q = vlink(p); - while (q != null) { - alink(q) = p; - p = q; - q = vlink(p); + return null; + tail = head; + next = vlink(head); + while (next != null) { + alink(next) = tail; + tail = next; + next = vlink(tail); } + return tail; } @ @c |