summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/tex
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-02-03 21:33:11 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-02-03 21:33:11 +0000
commit85a5ab00705446693e236ee78a0be10f53e86377 (patch)
treedcc942a92ffb98bbb2731f58fa069a46a18f9dcb /Build/source/texk/web2c/luatexdir/tex
parentb14c66510e21d60854c376a6d8cdfb3c48f5e2b8 (diff)
luatexdir: sync with the upstream (1.0.3)
git-svn-id: svn://tug.org/texlive/trunk@43128 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/tex')
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/buildpage.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/commands.w1
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/dumpdata.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/equivalents.h25
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/linebreak.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/linebreak.w24
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.w48
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/packaging.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/packaging.w67
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/scanning.w53
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.w66
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.w208
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.w2
14 files changed, 311 insertions, 217 deletions
diff --git a/Build/source/texk/web2c/luatexdir/tex/buildpage.w b/Build/source/texk/web2c/luatexdir/tex/buildpage.w
index c45d9cb7d7e..cba07cbf6f6 100644
--- a/Build/source/texk/web2c/luatexdir/tex/buildpage.w
+++ b/Build/source/texk/web2c/luatexdir/tex/buildpage.w
@@ -289,6 +289,7 @@ void build_page(void)
int pi = 0; /* penalty to be added to the badness */
int n; /* insertion box number */
scaled delta, h, w; /* sizes used for insertion calculations */
+ int id, sk, i;
if ((vlink(contrib_head) == null) || output_active)
return;
do {
@@ -406,8 +407,11 @@ void build_page(void)
freeze_page_specs(inserts_only);
n = subtype(p);
r = page_ins_head;
- while (n >= subtype(vlink(r)))
+ i = 1 ;
+ while (n >= subtype(vlink(r))) {
r = vlink(r);
+ i = i + 1 ;
+ }
if (subtype(r) != n) {
/* Create a page insertion node with |subtype(r)=qi(n)|, and
include the glue correction for box |n| in the
@@ -417,7 +421,12 @@ void build_page(void)
encountered for a new page. A user who changes the contents of \.{\\box}~|n|
after that first \.{\\insert}~|n| had better be either extremely careful
or extremely lucky, or both. */
-
+id = callback_defined(build_page_insert_callback);
+if (id != 0) {
+ run_callback(id, "dd->d",n,i,&sk);
+} else {
+ sk = n;
+}
q = new_node(inserting_node, n);
try_couple_nodes(q, vlink(r));
couple_nodes(r, q);
@@ -428,18 +437,17 @@ void build_page(void)
else
height(r) = height(box(n)) + depth(box(n));
best_ins_ptr(r) = null;
- q = skip(n);
+ /* q = skip(n); */
+q = skip(sk);
if (count(n) == 1000)
h = height(r);
else
h = x_over_n(height(r), 1000) * count(n);
page_goal = page_goal - h - width(q);
if (stretch_order(q) > 1)
- page_so_far[1 + stretch_order(q)] =
- page_so_far[1 + stretch_order(q)] + stretch(q);
+ page_so_far[1 + stretch_order(q)] = page_so_far[1 + stretch_order(q)] + stretch(q);
else
- page_so_far[2 + stretch_order(q)] =
- page_so_far[2 + stretch_order(q)] + stretch(q);
+ page_so_far[2 + stretch_order(q)] = page_so_far[2 + stretch_order(q)] + stretch(q);
page_shrink = page_shrink + shrink(q);
if ((shrink_order(q) != normal) && (shrink(q) != 0)) {
print_err("Infinite glue shrinkage inserted from \\skip");
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w
index b89dadffd1f..04eba945b1c 100644
--- a/Build/source/texk/web2c/luatexdir/tex/commands.w
+++ b/Build/source/texk/web2c/luatexdir/tex/commands.w
@@ -51,6 +51,7 @@ void initialize_commands(void)
primitive_tex("medmuskip", assign_mu_glue_cmd, glue_base + med_mu_skip_code, glue_base + thin_mu_skip_code);
primitive_tex("thickmuskip", assign_mu_glue_cmd, glue_base + thick_mu_skip_code, glue_base + thin_mu_skip_code);
primitive_luatex("mathsurroundskip", assign_glue_cmd, glue_base + math_skip_code, glue_base);
+ primitive_luatex("mathsurroundmode", assign_int_cmd, int_base + math_skip_mode_code, int_base);
primitive_tex("output", assign_toks_cmd, output_routine_loc, local_base);
primitive_tex("everypar", assign_toks_cmd, every_par_loc, local_base);
primitive_tex("everymath", assign_toks_cmd, every_math_loc, local_base);
diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
index c7bb4c2e87d..dd0cf3b5aba 100644
--- a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
+++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
@@ -23,7 +23,7 @@
/* we start with 907: the sum of the values of the bytes of "don knuth" */
-#define FORMAT_ID (907+20)
+#define FORMAT_ID (907+24)
#if ((FORMAT_ID>=0) && (FORMAT_ID<=256))
#error Wrong value for FORMAT_ID.
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
index 27a4f96401b..d12ae5b29f5 100644
--- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -285,16 +285,23 @@ the |number_regs| \.{\\dimen} registers.
# define shape_mode_code 94
# define first_valid_language_code 95
# define hyphenation_bounds_code 96
+# define math_skip_mode_code 97
-# define math_option_code 97
+# define math_option_code (math_skip_mode_code+1)
-# define mathoption_int_base (int_base+98) /* one reserve */
-# define mathoption_int_last (int_base+106)
+# define mathoption_int_base_code (math_option_code+1) /* one reserve */
+# define mathoption_int_last_code (mathoption_int_base_code+8)
-# define backend_int_base (int_base+107)
-# define backend_int_last (int_base+131)
+# define backend_int_base_code (mathoption_int_last_code+1)
+# define backend_int_last_code (backend_int_base_code+32) /* we need some 25 but take some slack */
-# define tex_int_pars (132) /* total number of integer parameters */
+# define tex_int_pars (backend_int_last_code+1) /* total number of integer parameters */
+
+# define mathoption_int_base (int_base+mathoption_int_base_code)
+# define mathoption_int_last (int_base+mathoption_int_last_code)
+
+# define backend_int_base (int_base+backend_int_base_code)
+# define backend_int_last (int_base+backend_int_last_code)
# define page_direction_code (tex_int_pars)
# define body_direction_code (tex_int_pars+1)
@@ -552,6 +559,7 @@ extern halfword last_cs_name;
#define space_skip_par glue_par(space_skip_code)
#define xspace_skip_par glue_par(xspace_skip_code)
#define math_skip_par glue_par(math_skip_code)
+#define math_skip_mode int_par(math_skip_mode_code)
#define pre_display_size_par dimen_par(pre_display_size_code)
#define display_width_par dimen_par(display_width_code)
@@ -786,4 +794,9 @@ extern halfword last_cs_name;
#define end_template_token (cs_token_flag+frozen_end_template)
#define end_write_token (cs_token_flag+end_write)
+/* for now here */
+
+#define xspace_skip_subtype (xspace_skip_code + 1)
+#define space_skip_subtype (space_skip_code + 1)
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.h b/Build/source/texk/web2c/luatexdir/tex/linebreak.h
index 99560ebed2e..1f49278314b 100644
--- a/Build/source/texk/web2c/luatexdir/tex/linebreak.h
+++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.h
@@ -87,7 +87,7 @@ extern halfword find_protchar_right(halfword l, halfword r);
|| ((type((a)) == disc_node) && empty_disc(a)) \
|| ((type((a)) == kern_node) && ((width((a)) == 0) || (subtype((a)) == normal))) \
|| ((type((a)) == rule_node) && zero_dimensions(a)) \
- || ((type((a)) == math_node) && (surround((a)) == 0)) \
+ || ((type((a)) == math_node) && (surround((a)) == 0 || (glue_is_zero((a))))) \
|| (type((a)) == dir_node) \
|| ((type((a)) == hlist_node) && (list_ptr((a)) == null) && zero_dimensions(a)) \
|| (type((a)) == local_par_node) \
diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
index 1c8a1e20f69..ad003097105 100644
--- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w
+++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
@@ -348,11 +348,11 @@ static boolean check_expand_pars(internal_font_number f)
l = pop_node(); /* don't visit this node again */
run = false;
}
-if ((vlink(l) != null) && (type(l) == boundary_node) && (subtype(l) == protrusion_boundary) &&
- ((boundary_value(l) == 1) || (boundary_value(l) == 3))) {
- /* skip next node */
- l = vlink(l);
-}
+ if ((vlink(l) != null) && (type(l) == boundary_node) && (subtype(l) == protrusion_boundary) &&
+ ((boundary_value(l) == 1) || (boundary_value(l) == 3))) {
+ /* skip next node */
+ l = vlink(l);
+ }
if (vlink(l) != null) {
l = vlink(l);
} else if (hlist_stack_level == 0) {
@@ -393,11 +393,11 @@ if ((vlink(l) != null) && (type(l) == boundary_node) && (subtype(l) == protrusio
l = pop_node();
}
if ((r != l) && (r != null)) {
-if ((alink(r) != null) && (type(r) == boundary_node) && (subtype(r) == protrusion_boundary) &&
- ((boundary_value(r) == 2) || (boundary_value(r) == 3))) {
- /* skip next node */
- r = alink(r);
-}
+ if ((alink(r) != null) && (type(r) == boundary_node) && (subtype(r) == protrusion_boundary) &&
+ ((boundary_value(r) == 2) || (boundary_value(r) == 3))) {
+ /* skip next node */
+ r = alink(r);
+ }
if (alink(r) != null) {
r = alink(r);
} else { /* this is the input: \.{\\leavevmode\\penalty-10000\\penalty-10000} (bug \#268) */
@@ -898,7 +898,7 @@ static void compute_break_width(int break_type, int line_break_dir, int adjust_s
switch (type(s)) {
case math_node:
/* begin mathskip code */
- if (glue_is_zero(math_skip_par)) {
+ if (glue_is_zero(s)) {
break_width[1] -= surround(s);
break;
} else {
@@ -1840,7 +1840,7 @@ void ext_do_line_break(int paragraph_dir,
case math_node:
auto_breaking = (subtype(cur_p) == after);
/* begin mathskip code */
- if (glue_is_zero(math_skip_par)) {
+ if (glue_is_zero(cur_p) || ignore_math_skip(cur_p)) {
kern_break();
break;
} else {
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w
index 909128e93c6..32fd32d4c0e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w
@@ -66,13 +66,12 @@ already apply that shift.
@ @c
#define nDEBUG
-#define reset_attributes(p,newatt) do { \
+#define reset_attributes(p,newatt) do { \
delete_attribute_ref(node_attr(p)); \
- node_attr(p) = newatt; \
- if (newatt!=null) { \
- assert(type(newatt)==attribute_list_node); \
- add_node_attr_ref(node_attr(p)); \
- } \
+ node_attr(p) = newatt; \
+ if (newatt!=null) { \
+ add_node_attr_ref(node_attr(p)); \
+ } \
} while (0)
#define DEFINE_MATH_PARAMETERS(A,B,C,D) do { \
@@ -88,11 +87,11 @@ already apply that shift.
} \
} while (0)
-#define DEFINE_DMATH_PARAMETERS(A,B,C,D) do { \
- if (B==text_size) { \
- def_math_param(A, display_style,(C),D); \
- def_math_param(A, cramped_display_style,(C),D); \
- } \
+#define DEFINE_DMATH_PARAMETERS(A,B,C,D) do { \
+ if (B==text_size) { \
+ def_math_param(A, display_style,(C),D); \
+ def_math_param(A, cramped_display_style,(C),D); \
+ } \
} while (0)
#define font_MATH_par(a,b) \
@@ -2662,7 +2661,6 @@ static scaled make_op(pointer q, int cur_style)
math_character(nucleus(q)) = c;
}
delta = char_italic(cur_f, cur_c);
-printf("delta %i\n",delta);
x = clean_box(nucleus(q), cur_style, cur_style);
if (delta != 0) {
if (do_new_math(cur_f)) {
@@ -3784,16 +3782,13 @@ static pointer math_spacing_glue(int l_type, int r_type, int mstyle, scaled mmu)
confusion("mathspacing");
}
if (x != 0) {
- pointer y;
if (x <= thick_mu_skip_code) {
/* trap thin/med/thick settings cf. old TeX */
- y = math_glue(glue_par(x), mmu);
- z = new_glue(y);
+ z = math_glue(glue_par(x), mmu); /* allocates a glue */
/* store a symbolic subtype */
subtype(z) = (quarterword) (x + 1);
} else {
- y = math_glue(x, mmu);
- z = new_glue(y);
+ z = math_glue(x, mmu); /* allocates a glue */
}
}
return z;
@@ -4046,14 +4041,18 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
math_glue_to_glue(q, cur_mu);
} else if ((cur_size != text_size) && (subtype(q) == cond_math_glue)) {
p = vlink(q);
- if (p != null)
- if ((type(p) == glue_node) || (type(p) == kern_node)) {
- couple_nodes(q,vlink(p));
- vlink(p) = null;
+ if (p != null)
+ if ((type(p) == glue_node) || (type(p) == kern_node)) {
+ if (vlink(p) != null) {
+ couple_nodes(q,vlink(p));
+ vlink(p) = null;
+ } else {
+ vlink(q) = null;
+ }
flush_node_list(p);
- }
+ }
}
- goto DONE_WITH_NODE;
+ goto DONE_WITH_NODE;
break;
case kern_node:
math_kern(q, cur_mu);
@@ -4242,8 +4241,9 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
A low-level |free_node| is easier than attempting to nullify such dependant
fields for all possible node and noad types.
*/
- if (nodetype_has_attributes(type(r)))
+ if (nodetype_has_attributes(type(r))) {
delete_attribute_ref(node_attr(r));
+ }
reset_node_properties(r);
free_node(r, get_node_size(type(r), subtype(r)));
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.h b/Build/source/texk/web2c/luatexdir/tex/packaging.h
index 21845d5d0aa..6a0802e4676 100644
--- a/Build/source/texk/web2c/luatexdir/tex/packaging.h
+++ b/Build/source/texk/web2c/luatexdir/tex/packaging.h
@@ -147,4 +147,9 @@ latter two are used denote \.{\\vbox} and \.{\\hbox}, respectively.
extern void begin_box(int box_context);
+#define math_skip_boundary(n) \
+(n && type(n) == glue_node && (subtype(n) == space_skip_subtype || subtype(n) == xspace_skip_subtype))
+
+extern int ignore_math_skip(halfword p) ;
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.w b/Build/source/texk/web2c/luatexdir/tex/packaging.w
index ba0a5d764ac..f094a0d9665 100644
--- a/Build/source/texk/web2c/luatexdir/tex/packaging.w
+++ b/Build/source/texk/web2c/luatexdir/tex/packaging.w
@@ -191,12 +191,10 @@ others are \.{\\vcenter}, \.{\\valign}, and \.{\\halign}).
void scan_full_spec(group_code c, int spec_direction, int just_pack)
{
- int s;
- int i;
- int v;
- int spec_code;
+ int s, i, v, spec_code;
boolean done = false ;
halfword attr_list;
+ boolean attr_done = false ;
if (attr_list_cache == cache_disabled)
update_attribute_cache();
attr_list = attr_list_cache;
@@ -227,9 +225,9 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack)
scan_optional_equals();
scan_int();
v = cur_val;
- if ((attr_list != null) && (attr_list == attr_list_cache)) {
+ if (! attr_done) {
attr_list = copy_attribute_list(attr_list_cache);
- add_node_attr_ref(attr_list); /* will be used once */
+ attr_done = true;
}
attr_list = do_set_attribute(attr_list, i, v);
goto CONTINUE;
@@ -239,9 +237,6 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack)
spec_direction = cur_val;
goto CONTINUE;
}
- if (attr_list == attr_list_cache) {
- add_node_attr_ref(attr_list);
- }
if (scan_keyword("to")) {
spec_code = exactly;
} else if (scan_keyword("spread")) {
@@ -256,9 +251,9 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack)
QUICK:
spec_code = additional;
cur_val = 0;
- add_node_attr_ref(attr_list);
done = true;
FOUND:
+ add_node_attr_ref(attr_list);
set_saved_record(0, saved_boxcontext, 0, s);
set_saved_record(1, saved_boxspec, spec_code, cur_val);
/* DIR: Adjust |text_dir_ptr| for |scan_spec| */
@@ -281,6 +276,7 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack)
eq_word_define(int_base + text_direction_code, spec_direction);
}
+
@ To figure out the glue setting, |hpack| and |vpack| determine how much
stretchability and shrinkability are present, considering all four orders of
infinity. The highest order of infinity that has a nonzero coefficient is then
@@ -605,6 +601,35 @@ expansion is being used.
@c
int font_expand_ratio = 0; /* current expansion ratio, needed for recursive call */
+int ignore_math_skip(halfword p)
+{
+ if (math_skip_mode == 6) {
+ if (subtype(p) == after) {
+ if (math_skip_boundary(vlink(p))) {
+ return 0;
+ }
+ } else {
+ if (math_skip_boundary(alink(p))) {
+ return 0;
+ }
+ }
+ } else if (math_skip_mode == 7) {
+ if (subtype(p) == after) {
+ if (! math_skip_boundary(vlink(p))) {
+ return 0;
+ }
+ } else {
+ if (! math_skip_boundary(alink(p))) {
+ return 0;
+ }
+ }
+ } else {
+ return 0;
+ }
+ reset_glue_to_zero(p);
+ return 1;
+}
+
halfword hpack(halfword p, scaled w, int m, int pack_direction)
{
halfword r; /* the box node that will be returned */
@@ -744,6 +769,15 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
d = depth(p);
break;
/* */
+ case math_node:
+ /* begin mathskip code */
+ if (glue_is_zero(p) || ignore_math_skip(p)) {
+ x += surround(p);
+ break;
+ } else {
+ /* fall through */
+ }
+ /* end mathskip code */
case glue_node:
/* Incorporate glue into the horizontal totals */
x += width(p);
@@ -802,15 +836,6 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
hpack_dir = dir_dir(dir_ptr1);
}
break;
- case math_node:
- /* begin mathskip code */
- if (glue_is_zero(p)) {
- x += surround(p);
- break;
- } else {
- /* fall through: mathskip */
- }
- /* end mathskip code */
case margin_kern_node:
if (m == cal_expand_ratio) {
int f = font(margin_char(p));
@@ -1187,11 +1212,11 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult,
/* */
case math_node:
/* begin mathskip code */
- if (glue_is_zero(p)) {
+ if (glue_is_zero(p) || ignore_math_skip(p)) {
siz.wd += surround(p);
break;
} else {
- /* fall through: mathskip */
+ /* fall through */
}
/* end mathskip code */
case glue_node:
diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.w b/Build/source/texk/web2c/luatexdir/tex/scanning.w
index 658f149adaf..7bed4d29016 100644
--- a/Build/source/texk/web2c/luatexdir/tex/scanning.w
+++ b/Build/source/texk/web2c/luatexdir/tex/scanning.w
@@ -140,9 +140,8 @@ we use scaled points so that the value doesn't actually change. And when a
@c
static void downgrade_cur_val(boolean delete_glue)
{
- halfword m;
if (cur_val_level == glue_val_level) {
- m = cur_val;
+ halfword m = cur_val;
cur_val = width(m);
if (delete_glue)
flush_node(m);
@@ -152,19 +151,34 @@ static void downgrade_cur_val(boolean delete_glue)
decr(cur_val_level);
}
+/*
void negate_cur_val(boolean delete_glue)
{
- halfword m;
if (cur_val_level >= glue_val_level) {
- m = cur_val;
+ halfword m = cur_val;
cur_val = new_spec(m);
if (delete_glue)
flush_node(m);
- /* Negate all three glue components of |cur_val| */
negate(width(cur_val));
negate(stretch(cur_val));
negate(shrink(cur_val));
+ } else {
+ negate(cur_val);
+ }
+}
+*/
+void negate_cur_val(boolean modify_glue)
+{
+ if (cur_val_level >= glue_val_level) {
+ if (modify_glue) {
+ /* we modify in-place */
+ } else {
+ cur_val = new_spec(cur_val);
+ }
+ negate(width(cur_val));
+ negate(stretch(cur_val));
+ negate(shrink(cur_val));
} else {
negate(cur_val);
}
@@ -296,7 +310,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
save_cur_chr = cur_chr;
cur_chr = chr;
/* Fetch an item in the current node, if appropriate */
- /* Here is where \.{\\lastpenalty}, \.{\\lastkern}, and \.{\\lastskip} are
+ /* Here is where \.{\\lastpenalty}, \.{\\lastkern}, and \.{\\ } are
implemented. The reference count for \.{\\lastskip} will be updated later.
We also handle \.{\\inputlineno} and \.{\\badness} here, because they are
@@ -325,13 +339,16 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
}
/* This code for reducing |cur_val_level| and\slash or negating the
result is similar to the one for all the other cases of
- |scan_something_internal|, with the difference that |scan_expr| has
- already increased the reference count of a glue specification.
+ |scan_something_internal|; we free a glue_spec when needed.
*/
while (cur_val_level > level) {
downgrade_cur_val(true);
}
if (negative) {
+ /*
+ we get a new glue spec node with negated values and the old
+ intermediate is deleted
+ */
negate_cur_val(true);
}
return succeeded;
@@ -475,7 +492,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
}
} else {
if (cur_chr == glue_val_level)
- cur_val = zero_glue;
+ cur_val = zero_glue; /* a pointer */
else
cur_val = 0;
if (cur_chr == last_node_type_code) {
@@ -500,7 +517,8 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
break;
case lastskip_code:
if (type(cur_list.tail_field) == glue_node)
- cur_val = new_glue(cur_list.tail_field);
+ // cur_val = new_spec(cur_list.tail_field);
+ cur_val = cur_list.tail_field;
if (subtype(cur_list.tail_field) == mu_glue)
cur_val_level = mu_val_level;
break;
@@ -519,7 +537,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
break;
case lastskip_code:
if (last_glue != max_halfword)
- cur_val = last_glue; /* maybe new_glue */
+ cur_val = last_glue;
break;
case last_node_type_code:
cur_val = last_node_type;
@@ -543,9 +561,10 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
If |negative| is |true|, |cur_val_level| is known to be |<=mu_val|.
*/
if (negative) {
+ /* we create a new (negated) glue spec and keep the old one */
negate_cur_val(false);
} else if ((cur_val_level >= glue_val_level) && (cur_val_level <= mu_val_level)) {
- cur_val = new_glue(cur_val);
+ cur_val = new_spec(cur_val);
}
}
return succeeded;
@@ -660,8 +679,7 @@ void scan_something_internal(int level, boolean negative)
get_token();
if (cur_cmd != math_style_cmd) {
print_err("Missing math style, treated as \\displaystyle");
- help1
- ("A style should have been here; I inserted `\\displaystyle'.");
+ help1("A style should have been here; I inserted `\\displaystyle'.");
cur_val = display_style;
back_error();
} else {
@@ -841,9 +859,10 @@ void scan_something_internal(int level, boolean negative)
If |negative| is |true|, |cur_val_level| is known to be |<=mu_val|.
*/
if (negative) {
+ /* we create a new (negated) glue spec and keep the old one */
negate_cur_val(false);
} else if ((cur_val_level >= glue_val_level) && (cur_val_level <= mu_val_level)) {
- cur_val = new_glue(cur_val);
+ cur_val = new_spec(cur_val);
}
}
}
@@ -2485,8 +2504,8 @@ static void scan_expr(void)
t = f;
if ((l >= glue_val_level) && (o != expr_none)) {
/* do we really need to copy here ? */
- t = new_spec(f);
- flush_node(f);
+// t = new_spec(f);
+// flush_node(f);
normalize_glue(t);
} else {
t = f;
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w
index b378c662619..16911bc4a6c 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w
@@ -1778,6 +1778,7 @@ void math_fraction(void)
halfword c; /* the type of generalized fraction we are scanning */
pointer q;
halfword options = 0;
+ halfword temp_value;
c = cur_chr;
if (incompleat_noad_par != null) {
const char *hlp[] = {
@@ -1795,7 +1796,8 @@ void math_fraction(void)
tex_error("Ambiguous; you need another { and }", hlp);
} else {
incompleat_noad_par = new_node(fraction_noad, 0);
- numerator(incompleat_noad_par) = new_node(sub_mlist_node, 0);
+ temp_value = new_node(sub_mlist_node, 0);
+ numerator(incompleat_noad_par) = temp_value;
math_list(numerator(incompleat_noad_par)) = vlink(head);
vlink(head) = null;
tail = head;
@@ -2430,9 +2432,34 @@ void after_math(void)
}
tail_append(new_math(math_surround_par, before));
/* begin mathskip code */
- if (! glue_is_zero(math_skip_par)) {
- copy_glue_values(tail,math_skip_par);
- surround(tail) = 0;
+ switch (math_skip_mode) {
+ case 0 :
+ /* obey mathsurround when zero glue */
+ if (! glue_is_zero(math_skip_par)) {
+ copy_glue_values(tail,math_skip_par);
+ surround(tail) = 0;
+ }
+ break ;
+ case 1 :
+ /* always left */
+ case 3 :
+ /* always both */
+ case 6 :
+ /* only when skip */
+ copy_glue_values(tail,math_skip_par);
+ surround(tail) = 0;
+ break ;
+ case 2 :
+ /* only right */
+ surround(tail) = 0;
+ break ;
+ case 4 :
+ /* ignore, obey marthsurround */
+ break ;
+ case 5:
+ /* all spacing disabled */
+ surround(tail) = 0;
+ break ;
}
/* end mathskip code */
if (dir_math_save) {
@@ -2449,9 +2476,34 @@ void after_math(void)
dir_math_save = false;
tail_append(new_math(math_surround_par, after));
/* begin mathskip code */
- if (! glue_is_zero(math_skip_par)) {
- copy_glue_values(tail,math_skip_par);
- surround(tail) = 0;
+ switch (math_skip_mode) {
+ case 0 :
+ /* obey mathsurround when zero glue */
+ if (! glue_is_zero(math_skip_par)) {
+ copy_glue_values(tail,math_skip_par);
+ surround(tail) = 0;
+ }
+ break ;
+ case 2 :
+ /* always right */
+ case 3 :
+ /* always both */
+ case 6 :
+ /* only when skip */
+ copy_glue_values(tail,math_skip_par);
+ surround(tail) = 0;
+ break ;
+ case 1 :
+ /* only left */
+ surround(tail) = 0;
+ break ;
+ case 4 :
+ /* ignore, obey marthsurround */
+ break ;
+ case 5:
+ /* all spacing disabled */
+ surround(tail) = 0;
+ break ;
}
/* end mathskip code */
space_factor_par = 1000;
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
index 943a347554d..dda0925609e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -376,7 +376,7 @@ typedef enum {
math_text_char_node,
delim_node, /* shield fields */
margin_kern_node,
- glyph_node,
+ glyph_node, /* this and below have attributes */
align_record_node,
pseudo_file_node,
pseudo_line_node,
@@ -947,6 +947,7 @@ typedef enum {
# define ss_glue fill_glue+glue_spec_size
# define fil_neg_glue ss_glue+glue_spec_size
# define page_ins_head fil_neg_glue+glue_spec_size
+
# define contrib_head page_ins_head+temp_node_size
# define page_head contrib_head+temp_node_size
# define temp_head page_head+temp_node_size
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
index 3a368c82336..17be906c8e6 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
@@ -1080,21 +1080,30 @@ void copy_node_wrapup_pdf(halfword p, halfword r)
halfword copy_node(const halfword p)
{
halfword r; /* current node being fabricated for new list */
- halfword w ; /* whatsit subtype */
+ halfword w; /* whatsit subtype */
+ halfword t; /* type of node */
register halfword s; /* a helper variable for copying into variable mem */
register int i;
if (copy_error(p)) {
r = new_node(temp_node, 0);
return r;
}
- i = get_node_size(type(p), subtype(p));
+ t = type(p);
+ i = get_node_size(t,subtype(p));
r = get_node(i);
(void) memcpy((void *) (varmem + r), (void *) (varmem + p), (sizeof(memory_word) * (unsigned) i));
+ /* possible speedup: */
+ /*
+ if t == glue_spec) {
+ return r;
+ }
+ */
+
if (synctex_par) {
/* handle synctex extension */
- switch (type(p)) {
+ switch (t) {
case math_node:
synctex_tag_math(r) = cur_input.synctex_tag_field;
synctex_line_math(r) = line;
@@ -1105,14 +1114,14 @@ halfword copy_node(const halfword p)
break;
}
}
- if (nodetype_has_attributes(type(p))) {
+ if (nodetype_has_attributes(t)) {
add_node_attr_ref(node_attr(p));
alink(r) = null;
lua_properties_copy(r,p);
}
vlink(r) = null;
- switch (type(p)) {
+ switch (t) {
case glyph_node:
copy_sub_list(lig_ptr(r),lig_ptr(p)) ;
break;
@@ -1791,17 +1800,43 @@ static void free_node_chain(halfword q, int s)
free_chain[s] = q;
}
-@ @c
+@ At the start of the node memory area we reserve some special nodes,
+for instance frequently used glue specifications. We could as well just
+use new_glue here but for the moment we stick to the traditional approach.
+
+@c
+#define initialize_glue(n,wi,st,sh,sto,sho) \
+ vlink(n) = null; \
+ type(n) = glue_spec_node; \
+ width(n) = wi; \
+ stretch(n) = st; \
+ shrink(n) = sh; \
+ stretch_order(n) = sto; \
+ shrink_order(n) = sho;
+
+#define initialize_whatever(n,t) \
+ vinfo(n) = 0; \
+ type(n) = t; \
+ vlink(n) = null; \
+ alink(n) = null;
+
+#define initialize_point(n) \
+ type(n) = glyph_node; \
+ subtype(n) = 0; \
+ vlink(n) = null; \
+ vinfo(n + 1) = null; \
+ alink(n) = null; \
+ font(n) = 0; \
+ character(n) = '.'; \
+ vinfo(n + 3) = 0; \
+ vlink(n + 3) = 0; \
+ vinfo(n + 4) = 0; \
+ vlink(n + 4) = 0;
+
void init_node_mem(int t)
{
my_prealloc = var_mem_stat_max;
- /* message ?
-
- assert(whatsit_node_data[user_defined_node].id == user_defined_node);
- assert(node_data[passive_node].id == passive_node);
- */
-
varmem = (memory_word *) realloc((void *) varmem, sizeof(memory_word) * (unsigned) t);
if (varmem == NULL) {
overflow("node memory size", (unsigned) var_mem_max);
@@ -1819,112 +1854,32 @@ void init_node_mem(int t)
vlink(rover) = rover;
node_size(rover) = (t - rover);
var_used = 0;
+
/* initialize static glue specs */
- width(zero_glue) = 0;
- type(zero_glue) = glue_spec_node;
- vlink(zero_glue) = null;
- stretch(zero_glue) = 0;
- stretch_order(zero_glue) = normal;
- shrink(zero_glue) = 0;
- shrink_order(zero_glue) = normal;
- width(sfi_glue) = 0;
- type(sfi_glue) = glue_spec_node;
- vlink(sfi_glue) = null;
- stretch(sfi_glue) = 0;
- stretch_order(sfi_glue) = sfi;
- shrink(sfi_glue) = 0;
- shrink_order(sfi_glue) = normal;
- width(fil_glue) = 0;
- type(fil_glue) = glue_spec_node;
- vlink(fil_glue) = null;
- stretch(fil_glue) = unity;
- stretch_order(fil_glue) = fil;
- shrink(fil_glue) = 0;
- shrink_order(fil_glue) = normal;
- width(fill_glue) = 0;
- type(fill_glue) = glue_spec_node;
- vlink(fill_glue) = null;
- stretch(fill_glue) = unity;
- stretch_order(fill_glue) = fill;
- shrink(fill_glue) = 0;
- shrink_order(fill_glue) = normal;
- width(ss_glue) = 0;
- type(ss_glue) = glue_spec_node;
- vlink(ss_glue) = null;
- stretch(ss_glue) = unity;
- stretch_order(ss_glue) = fil;
- shrink(ss_glue) = unity;
- shrink_order(ss_glue) = fil;
- width(fil_neg_glue) = 0;
- type(fil_neg_glue) = glue_spec_node;
- vlink(fil_neg_glue) = null;
- stretch(fil_neg_glue) = -unity;
- stretch_order(fil_neg_glue) = fil;
- shrink(fil_neg_glue) = 0;
- shrink_order(fil_neg_glue) = normal;
+
+ initialize_glue(zero_glue,0,0,0,0,0);
+ initialize_glue(sfi_glue,0,0,0,sfi,0);
+ initialize_glue(fil_glue,0,unity,0,fil,0);
+ initialize_glue(fill_glue,0,unity,0,fill,0);
+ initialize_glue(ss_glue,0,unity,unity,fil,fil);
+ initialize_glue(fil_neg_glue,0,-unity,0,fil,0);
+
/* initialize node list heads */
- vinfo(page_ins_head) = 0;
- type(page_ins_head) = temp_node;
- vlink(page_ins_head) = null;
- alink(page_ins_head) = null;
- vinfo(contrib_head) = 0;
- type(contrib_head) = temp_node;
- vlink(contrib_head) = null;
- alink(contrib_head) = null;
- vinfo(page_head) = 0;
- type(page_head) = temp_node;
- vlink(page_head) = null;
- alink(page_head) = null;
- vinfo(temp_head) = 0;
- type(temp_head) = temp_node;
- vlink(temp_head) = null;
- alink(temp_head) = null;
- vinfo(hold_head) = 0;
- type(hold_head) = temp_node;
- vlink(hold_head) = null;
- alink(hold_head) = null;
- vinfo(adjust_head) = 0;
- type(adjust_head) = temp_node;
- vlink(adjust_head) = null;
- alink(adjust_head) = null;
- vinfo(pre_adjust_head) = 0;
- type(pre_adjust_head) = temp_node;
- vlink(pre_adjust_head) = null;
- alink(pre_adjust_head) = null;
- vinfo(active) = 0;
- type(active) = unhyphenated_node;
- vlink(active) = null;
- alink(active) = null;
- vinfo(align_head) = 0;
- type(align_head) = temp_node;
- vlink(align_head) = null;
- alink(align_head) = null;
- vinfo(end_span) = 0;
- type(end_span) = span_node;
- vlink(end_span) = null;
- alink(end_span) = null;
- type(begin_point) = glyph_node;
- subtype(begin_point) = 0;
- vlink(begin_point) = null;
- vinfo(begin_point + 1) = null;
- alink(begin_point) = null;
- font(begin_point) = 0;
- character(begin_point) = '.';
- vinfo(begin_point + 3) = 0;
- vlink(begin_point + 3) = 0;
- vinfo(begin_point + 4) = 0;
- vlink(begin_point + 4) = 0;
- type(end_point) = glyph_node;
- subtype(end_point) = 0;
- vlink(end_point) = null;
- vinfo(end_point + 1) = null;
- alink(end_point) = null;
- font(end_point) = 0;
- character(end_point) = '.';
- vinfo(end_point + 3) = 0;
- vlink(end_point + 3) = 0;
- vinfo(end_point + 4) = 0;
- vlink(end_point + 4) = 0;
+
+ initialize_whatever(page_ins_head,temp_node);
+ initialize_whatever(contrib_head,temp_node);
+ initialize_whatever(page_head,temp_node);
+ initialize_whatever(temp_head,temp_node);
+ initialize_whatever(hold_head,temp_node);
+ initialize_whatever(adjust_head,temp_node);
+ initialize_whatever(pre_adjust_head,temp_node);
+ initialize_whatever(align_head,temp_node);
+
+ initialize_whatever(active,unhyphenated_node);
+ initialize_whatever(end_span,span_node);
+
+ initialize_point(begin_point);
+ initialize_point(end_point);
}
@ @c
@@ -3609,9 +3564,24 @@ The reference count in the copy is |null|, because there is assumed
to be exactly one reference to the new specification.
@c
-halfword new_spec(halfword p)
-{
- return copy_node(p == null ? zero_glue : p);
+halfword new_spec(halfword q) /* safeguard for copying a glue node */
+{
+ if (q == null) {
+ return copy_node(zero_glue);
+ } else if (type(q) == glue_spec_node) {
+ return copy_node(q);
+ } else if (type(q) == glue_node) {
+ halfword p = copy_node(zero_glue);
+ width(p) = width(q);
+ stretch(p) = stretch(q);
+ shrink(p) = shrink(q);
+ stretch_order(p) = stretch_order(q);
+ shrink_order(p) = shrink_order(q);
+ return p;
+ } else {
+ /* alternatively we can issue a warning */
+ return copy_node(zero_glue);
+ }
}
@ And here's a function that creates a glue node for a given parameter
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w
index 7b781fc082b..196ecf8c399 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w
@@ -2325,6 +2325,7 @@ static int do_variable_pdf(halfword c)
else if (scan_keyword("gentounicode")) { do_variable_backend_int(c_pdf_gen_tounicode); }
else if (scan_keyword("pkfixeddpi")) { do_variable_backend_int(c_pdf_pk_fixed_dpi); }
else if (scan_keyword("suppressoptionalinfo")) { do_variable_backend_int(c_pdf_suppress_optional_info); }
+ else if (scan_keyword("omitcidset")) { do_variable_backend_int(c_pdf_omit_cidset); }
else if (scan_keyword("horigin")) { do_variable_backend_dimen(d_pdf_h_origin); }
else if (scan_keyword("vorigin")) { do_variable_backend_dimen(d_pdf_v_origin); }
@@ -2702,7 +2703,6 @@ void conv_toks(void)
pop_selector;
break;
case normal_deviate_code:
- scan_int();
push_selector;
print_int(norm_rand());
pop_selector;