summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-11-14 00:48:08 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-11-14 00:48:08 +0000
commit64322869cd45fa0029198b6ef544363a0cf49eb6 (patch)
treefaa34b755a1bd7b9b5ca4a66d204deebf841d119 /Build/source/texk/web2c
parent6d37525a79984eea934633c34944113831e3fecb (diff)
web2c/luatexdir: Sync with the upstream trunk.
git-svn-id: svn://tug.org/texlive/trunk@38844 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r--Build/source/texk/web2c/luatexdir/dvi/dvigen.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/dvi/dvigen.w153
-rw-r--r--Build/source/texk/web2c/luatexdir/font/dofont.w9
-rw-r--r--Build/source/texk/web2c/luatexdir/font/luafont.w328
-rw-r--r--Build/source/texk/web2c/luatexdir/font/luatexfont.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/font/texfont.h31
-rw-r--r--Build/source/texk/web2c/luatexdir/font/texfont.w250
-rw-r--r--Build/source/texk/web2c/luatexdir/font/tfmofm.w34
-rw-r--r--Build/source/texk/web2c/luatexdir/font/tt_glyf.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/font/vfovf.w93
-rw-r--r--Build/source/texk/web2c/luatexdir/font/vfpacket.w12
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writeenc.w1
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writet1.w18
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writetype2.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/image/epdf.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/image/pdftoepdf.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writeimg.w56
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/hyphen.w42
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.w27
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c157
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lfontlib.c34
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/limglib.c101
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lkpselib.c47
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llanglib.c33
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llualib.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c62
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnodelib.c908
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c553
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lstatslib.c36
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexiolib.c44
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c1418
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltokenlib.c34
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luagen.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luagen.w35
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w209
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luajitstuff.w139
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luanode.w112
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luastuff.w34
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h196
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatoken.w21
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/fontviewbase.c3
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macenc.c14
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c18
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c13
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil.c1
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c336
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex.c8
-rw-r--r--Build/source/texk/web2c/luatexdir/luatexcallbackids.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfaction.h64
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfaction.w59
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfannot.w4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w18
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfdest.w26
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.h17
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w217
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w376
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfimage.w4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflink.w29
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdflistout.w641
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w6
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfobj.w30
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w25
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w7
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfrule.w69
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w5
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w12
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w79
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h55
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.w18
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfthread.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h8
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.h8
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.w24
-rw-r--r--Build/source/texk/web2c/luatexdir/ptexlib.h43
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/align.w38
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/buildpage.w12
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/commands.h451
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/commands.w1122
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/conditional.w15
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/directions.h358
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/directions.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/dumpdata.w4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/equivalents.h534
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/errors.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/errors.w171
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/expand.w13
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/extensions.h124
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/extensions.w1088
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/inputstack.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/linebreak.h55
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/linebreak.w242
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mainbody.w29
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/maincontrol.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/maincontrol.w192
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.h5
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.w2748
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/packaging.h6
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/packaging.w299
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/postlinebreak.w157
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/primitive.h15
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/primitive.w56
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/printing.h77
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/printing.w27
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/scanning.w84
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.w564
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.h657
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.w1899
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.h20
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.w940
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/utils.w12
114 files changed, 10605 insertions, 8998 deletions
diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.h b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h
index 001e1744ddf..49552f1d9c2 100644
--- a/Build/source/texk/web2c/luatexdir/dvi/dvigen.h
+++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h
@@ -172,8 +172,6 @@ this is essentially the depth of |push| commands in the \.{DVI} output.
extern scaledpos dvi;
-extern void expand_macros_in_tokenlist(halfword p);
-extern void write_out(halfword p);
extern void dvi_special(PDF pdf, halfword p);
extern void ensure_dvi_header_written(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.w b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w
index 53d3b9b0e89..ce38db7c4c2 100644
--- a/Build/source/texk/web2c/luatexdir/dvi/dvigen.w
+++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.w
@@ -35,9 +35,10 @@
@c
#undef write_dvi
+/* todo: move macros to api */
+
#define mode cur_list.mode_field /* current mode */
-#define pdf_output int_par(pdf_output_code)
#define mag int_par(mag_code)
#define tracing_output int_par(tracing_output_code)
#define tracing_stats int_par(tracing_stats_code)
@@ -1053,13 +1054,19 @@ that a \.{DVI}-reading program will push onto its coordinate stack.
@c
void dvi_place_rule(PDF pdf, halfword q, scaledpos size)
{
- (void) q;
synch_dvi_with_pos(pdf->posstruct->pos);
- if (textdir_is_L(pdf->posstruct->dir)) {
- dvi_out(set_rule); /* movement optimization for |dir_*L*| */
- dvi.h += size.h;
- } else
- dvi_out(put_rule);
+ if ((subtype(q) == box_rule) || (subtype(q) == image_rule) || (subtype(q) == empty_rule)) {
+ /* place nothing, only take space */
+ if (textdir_is_L(pdf->posstruct->dir))
+ dvi.h += size.h;
+ } else {
+ /* normal_rule or >= 100 being a leader rule */
+ if (textdir_is_L(pdf->posstruct->dir)) {
+ dvi_out(set_rule); /* movement optimization for |dir_*L*| */
+ dvi.h += size.h;
+ } else
+ dvi_out(put_rule);
+ }
dvi_four(size.v);
dvi_four(size.h);
}
@@ -1108,136 +1115,6 @@ void dvi_special(PDF pdf, halfword p)
cur_length = 0; /* erase the string */
}
-@ The final line of this routine is slightly subtle; at least, the author
-didn't think about it until getting burnt! There is a used-up token list
-@^Knuth, Donald Ervin@>
-on the stack, namely the one that contained |end_write_token|. (We
-insert this artificial `\.{\\endwrite}' to prevent runaways, as explained
-above.) If it were not removed, and if there were numerous writes on a
-single page, the stack would overflow.
-
-@c
-/* TODO: keep track of this value */
-#define end_write_token cs_token_flag+end_write
-
-void expand_macros_in_tokenlist(halfword p)
-{
- int old_mode; /* saved |mode| */
- pointer q, r; /* temporary variables for list manipulation */
- q = get_avail();
- token_info(q) = right_brace_token + '}';
- r = get_avail();
- token_link(q) = r;
- token_info(r) = end_write_token;
- begin_token_list(q, inserted);
- begin_token_list(write_tokens(p), write_text);
- q = get_avail();
- token_info(q) = left_brace_token + '{';
- begin_token_list(q, inserted);
- /* now we're ready to scan
- `\.\{$\langle\,$token list$\,\rangle$\.{\} \\endwrite}' */
- old_mode = mode;
- mode = 0;
- /* disable \.{\\prevdepth}, \.{\\spacefactor}, \.{\\lastskip}, \.{\\prevgraf} */
- cur_cs = write_loc;
- q = scan_toks(false, true); /* expand macros, etc. */
- get_token();
- if (cur_tok != end_write_token) {
- /* Recover from an unbalanced write command */
- const char *hlp[] = {
- "On this page there's a \\write with fewer real {'s than }'s.",
- "I can't handle that very well; good luck.", NULL
- };
- tex_error("Unbalanced write command", hlp);
- do {
- get_token();
- } while (cur_tok != end_write_token);
- }
- mode = old_mode;
- end_token_list(); /* conserve stack space */
-}
-
-void write_out(halfword p)
-{
- int old_setting; /* holds print |selector| */
- int j; /* write stream number */
- boolean clobbered; /* system string is ok? */
- int ret; /* return value from |runsystem| */
- char *s, *ss; /* line to be written, as a C string */
- int callback_id;
- int lua_retval;
- expand_macros_in_tokenlist(p);
- old_setting = selector;
- j = write_stream(p);
- if (j == 18) {
- selector = new_string;
- } else if (write_open[j]) {
- selector = j;
- } else { /* write to the terminal if file isn't open */
- if ((j == 17) && (selector == term_and_log))
- selector = log_only;
- tprint_nl("");
- }
- s = tokenlist_to_cstring(def_ref, false, NULL);
- if (selector < no_print) { /* selector is a file */
- /* fix up the output buffer using callbacks */
- callback_id = callback_defined(process_output_buffer_callback);
- if (callback_id > 0) {
- lua_retval = run_callback(callback_id, "S->S", s, &ss);
- if ((lua_retval == true) && (ss != NULL))
- { xfree(s); s = ss; }
- }
- }
- tprint(s);
- xfree(s);
- print_ln();
- flush_list(def_ref);
- if (j == 18) {
- cur_string[cur_length] = '\0'; /* Convert newline to null. */
- if (tracing_online <= 0)
- selector = log_only; /* Show what we're doing in the log file. */
- else
- selector = term_and_log; /* Show what we're doing. */
- /* If the log file isn't open yet, we can only send output to the terminal.
- Calling |open_log_file| from here seems to result in bad data in the log.
- */
- if (!log_opened_global)
- selector = term_only;
- tprint_nl("runsystem(");
- tprint((char *) cur_string);
- tprint(")...");
- if (shellenabledp) {
- clobbered = false;
- if (strlen((char *) cur_string) != cur_length)
- clobbered = true;
- /* minimal checking: NUL not allowed in argument string of |system|() */
- if (clobbered) {
- tprint("clobbered");
- } else {
- /* We have the command. See if we're allowed to execute it,
- and report in the log. We don't check the actual exit status of
- the command, or do anything with the output. */
- ret = runsystem((char *) cur_string);
- if (ret == -1)
- tprint("quotation error in system command");
- else if (ret == 0)
- tprint("disabled (restricted)");
- else if (ret == 1)
- tprint("executed");
- else if (ret == 2)
- tprint("executed safely (allowed)");
- }
- } else {
- tprint("disabled"); /* |shellenabledp| false */
- }
- print_char('.');
- tprint_nl("");
- print_ln();
- cur_length = 0; /* erase the string */
- }
- selector = old_setting;
-}
-
@ Here's an example of how these conventions are used. Whenever it is time to
ship out a box of stuff, we shall use the macro |ensure_dvi_open|.
@@ -1247,7 +1124,7 @@ void ensure_dvi_header_written(PDF pdf)
unsigned l;
unsigned s; /* index into |str_pool| */
int old_setting; /* saved |selector| setting */
- assert(pdf->o_mode == OMODE_DVI);
+ assert(output_mode_used == OMODE_DVI);
assert(pdf->o_state == ST_FILE_OPEN);
if (half_buf == 0) {
diff --git a/Build/source/texk/web2c/luatexdir/font/dofont.w b/Build/source/texk/web2c/luatexdir/font/dofont.w
index a7fd7122fca..28693ac1fc1 100644
--- a/Build/source/texk/web2c/luatexdir/font/dofont.w
+++ b/Build/source/texk/web2c/luatexdir/font/dofont.w
@@ -23,7 +23,7 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
-@ a bit more interfacing is needed for proper error reporting
+@ a bit more interfacing is needed for proper error reporting
@c
static char *font_error_message(pointer u, char *nom, scaled s)
@@ -50,7 +50,7 @@ static int do_define_font(int f, const char *cnom, scaled s, int natural_dir)
boolean res; /* was the callback successful? */
int callback_id;
char *cnam;
- int r;
+ int r, t;
res = 0;
callback_id = callback_defined(define_font_callback);
@@ -61,11 +61,12 @@ static int do_define_font(int f, const char *cnom, scaled s, int natural_dir)
if (callback_id > 0) { /* success */
luaL_checkstack(Luas, 1, "out of stack space");
lua_rawgeti(Luas, LUA_REGISTRYINDEX, callback_id);
- if (lua_istable(Luas, -1)) {
+ t = lua_type(Luas, -1);
+ if (t == LUA_TTABLE) {
res = font_from_lua(Luas, f);
destroy_saved_callback(callback_id);
/* |lua_pop(Luas, 1);| *//* done by |font_from_lua| */
- } else if (lua_isnumber(Luas, -1)) {
+ } else if (t == LUA_TNUMBER) {
r=(int)lua_tonumber(Luas, -1);
destroy_saved_callback(callback_id);
delete_font(f);
diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w
index ce6f35c5f07..e72cbc615ed 100644
--- a/Build/source/texk/web2c/luatexdir/font/luafont.w
+++ b/Build/source/texk/web2c/luatexdir/font/luafont.w
@@ -103,22 +103,17 @@ const char *MATH_param_names[] = {
/* here for now, may be useful elsewhere */
-int ff_checkoption (lua_State *L, int narg, const char *def,
- const char *const lst[]);
-
-int ff_checkoption (lua_State *L, int narg, const char *def,
- const char *const lst[]) {
- const char *name = (def) ? luaL_optstring(L, narg, def) :
- luaL_checkstring(L, narg);
- int i;
- for (i=0; lst[i]; i++)
+int ff_checkoption (lua_State *L, int narg, const char *def, const char *const lst[]);
+
+int ff_checkoption (lua_State *L, int narg, const char *def, const char *const lst[]) {
+ const char *name = (def) ? luaL_optstring(L, narg, def) : luaL_checkstring(L, narg);
+ int i;
+ for (i=0; lst[i]; i++)
if (strcmp(lst[i], name) == 0)
- return i;
- return -1;
+ return i;
+ return -1;
}
-
-
static void dump_intfield(lua_State * L, const char *n, int c)
{
lua_pushstring(L, n);
@@ -146,12 +141,11 @@ static void dump_math_kerns(lua_State * L, charinfo * co, int l, int id)
dump_intfield(L, "height", co->bottom_left_math_kern_array[(2*i)]);
dump_intfield(L, "kern", co->bottom_left_math_kern_array[(2*i)+1]);
}
- /* *INDENT-ON* */
+ /* INDENT-ON */
lua_rawseti(L, -2, (i + 1));
}
}
-
static void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * co)
{
liginfo *l;
@@ -178,6 +172,12 @@ static void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * c
lua_rawset(L, -3);
}
+ if (get_charinfo_vert_italic(co) != 0) {
+ lua_pushstring(L, "vert_italic");
+ lua_pushnumber(L, get_charinfo_vert_italic(co));
+ lua_rawset(L, -3);
+ }
+
if (get_charinfo_top_accent(co) !=0) {
lua_pushstring(L, "top_accent");
lua_pushnumber(L, get_charinfo_top_accent(co));
@@ -188,7 +188,7 @@ static void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * c
lua_pushstring(L, "bot_accent") ;
lua_pushnumber(L, get_charinfo_bot_accent(co));
lua_rawset(L, -3);
- }
+ }
if (get_charinfo_ef(co) != 0) {
lua_pushstring(L, "expansion_factor");
@@ -468,6 +468,8 @@ int font_to_lua(lua_State * L, int f)
lua_setfield(L, -2, "direction");
lua_pushnumber(L, font_encodingbytes(f));
lua_setfield(L, -2, "encodingbytes");
+ lua_pushboolean(L, font_oldmath(f));
+ lua_setfield(L, -2, "oldmath");
lua_pushnumber(L, font_tounicode(f));
lua_setfield(L, -2, "tounicode");
@@ -587,60 +589,19 @@ static void append_float(eight_bits ** cpp, float a)
*cpp = cp;
}
-//#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5)
-
-
-/* static int n_numeric_field(lua_State * L, int name_index, int dflt) */
-/* { */
-/* register int i = dflt; */
-/* lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /\* fetch the stringptr *\/ */
-/* lua_rawget(L, -2); */
-/* if (lua_type(L, -1) == LUA_TNUMBER) { */
-/* i = lua_roundnumber(L, -1); */
-/* } */
-/* lua_pop(L, 1); */
-/* return i; */
-/* } */
-
-
-
-
-/* static int enum_field(lua_State * L, const char *name, int dflt, */
-/* const char **values) */
-/* { */
-/* int k; */
-/* const char *s; */
-/* int i = dflt; */
-/* lua_pushstring(L, name); */
-/* lua_rawget(L, -2); */
-/* if (lua_isnumber(L, -1)) { */
-/* i=(int)lua_tonumber(L, -1); */
-/* } else if (lua_isstring(L, -1)) { */
-/* s = lua_tostring(L, -1); */
-/* k = 0; */
-/* while (values[k] != NULL) { */
-/* if (strcmp(values[k], s) == 0) { */
-/* i = k; */
-/* break; */
-/* } */
-/* k++; */
-/* } */
-/* } */
-/* lua_pop(L, 1); */
-/* return i; */
-/* } */
-
-static int n_enum_field(lua_State * L, int name_index, int dflt,
- const char **values)
+/*#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5)*/
+
+static int n_enum_field(lua_State * L, int name_index, int dflt, const char **values)
{
- int k;
+ int k, t;
const char *s;
int i = dflt;
lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */
lua_rawget(L, -2);
- if (lua_isnumber(L, -1)) {
+ t = lua_type(L,-1);
+ if (t == LUA_TNUMBER) {
i=(int)lua_tonumber(L, -1);
- } else if (lua_isstring(L, -1)) {
+ } else if (t == LUA_TSTRING) {
s = lua_tostring(L, -1);
k = 0;
while (values[k] != NULL) {
@@ -655,20 +616,6 @@ static int n_enum_field(lua_State * L, int name_index, int dflt,
return i;
}
-
-
-/* static int boolean_field(lua_State * L, const char *name, int dflt) */
-/* { */
-/* int i = dflt; */
-/* lua_pushstring(L, name); */
-/* lua_rawget(L, -2); */
-/* if (lua_isboolean(L, -1)) { */
-/* i = lua_toboolean(L, -1); */
-/* } */
-/* lua_pop(L, 1); */
-/* return i; */
-/* } */
-
static int n_boolean_field(lua_State * L, int name_index, int dflt)
{
int i = dflt;
@@ -681,13 +628,12 @@ static int n_boolean_field(lua_State * L, int name_index, int dflt)
return i;
}
-
static char *n_string_field_copy(lua_State * L, int name_index, const char *dflt)
{
char *i;
lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */
lua_rawget(L, -2);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
i = xstrdup(lua_tostring(L, -1));
} else if (dflt == NULL) {
i = NULL;
@@ -700,10 +646,11 @@ static char *n_string_field_copy(lua_State * L, int name_index, const char *dflt
static const char *n_string_field(lua_State * L, int name_index)
{
- lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */
+ lua_rawgeti(L, LUA_REGISTRYINDEX, name_index); /* fetch the stringptr */
lua_rawget(L, -2);
return lua_tostring(L,-1);
}
+
/*static void init_font_string_pointers(lua_State * L){}*/
static int count_char_packet_bytes(lua_State * L)
@@ -715,7 +662,7 @@ static int count_char_packet_bytes(lua_State * L)
lua_rawgeti(L, -1, i);
if (lua_istable(L, -1)) {
lua_rawgeti(L, -1, 1);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
const char *s = lua_tostring(L, -1);
if (lua_key_eq(s, font)) {
l += 5;
@@ -743,7 +690,7 @@ static int count_char_packet_bytes(lua_State * L)
} else if (lua_key_eq(s, special) || lua_key_eq(s, lua)) {
size_t len;
lua_rawgeti(L, -2, 2);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
(void) lua_tolstring(L, -1, &len);
lua_pop(L, 1);
if (len > 0) {
@@ -751,13 +698,16 @@ static int count_char_packet_bytes(lua_State * L)
}
} else {
lua_pop(L, 1);
- fprintf(stdout, "invalid packet special!\n");
+ normal_error("vf command","invalid packet special");
+ /* fprintf(stdout, "invalid packet special!\n"); */
}
} else {
- fprintf(stdout, "unknown packet command %s!\n", s);
+ normal_error("vf command","unknown packet command");
+ /* fprintf(stdout, "unknown packet command %s!\n", s); */
}
} else {
- fprintf(stdout, "no packet command!\n");
+ normal_error("vf command","no packet command");
+ /* fprintf(stdout, "no packet command!\n"); */
}
lua_pop(L, 1); /* command name */
}
@@ -775,8 +725,7 @@ static scaled sp_to_dvi(halfword sp, halfword atsize)
}
@ @c
-static void
-read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
+static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, internal_font_number f, int atsize)
{
int i, n, m;
size_t l;
@@ -799,7 +748,7 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
if (lua_istable(L, -1)) {
/* fetch the command code */
lua_rawgeti(L, -1, 1);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
s = lua_tostring(L, -1);
cmd = 0;
if (lua_key_eq(s, font)) {
@@ -815,7 +764,11 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
cmd = packet_nop_code;
lua_rawgeti(L, -2, 2);
n = (int) luaL_checkinteger(L, -1);
- ff = (n > max_f ? l_fonts[1] : l_fonts[n]);
+ if (n ==0) {
+ ff = f;
+ } else {
+ ff = (n > max_f ? l_fonts[1] : l_fonts[n]);
+ }
lua_rawgeti(L, -3, 3);
n = (int) luaL_checkinteger(L, -1);
lua_pop(L, 2);
@@ -856,7 +809,11 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
append_packet(cmd);
lua_rawgeti(L, -2, 2);
n = (int) luaL_checkinteger(L, -1);
- ff = (n > max_f ? l_fonts[1] : l_fonts[n]);
+ if (n == 0) {
+ ff = n;
+ } else {
+ ff = (n > max_f ? l_fonts[1] : l_fonts[n]);
+ }
do_store_four(ff);
lua_pop(L, 1);
break;
@@ -932,12 +889,14 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
lua_pop(L, 1);
break;
default:
- fprintf(stdout, "Unknown char packet code %s\n", s);
+ normal_error("vf command","invalid packet code");
+ /* fprintf(stdout, "Unknown char packet code %s\n", s); */
}
}
lua_pop(L, 1); /* command code */
} else {
- fprintf(stdout, "Found a `commands' item that is not a table\n");
+ normal_error("vf command","commands has to be a tbale");
+ /* fprintf(stdout, "Found a `commands' item that is not a table\n"); */
}
lua_pop(L, 1); /* command table */
}
@@ -951,7 +910,7 @@ static void read_lua_cidinfo(lua_State * L, int f)
{
int i;
char *s;
- //lua_getfield(L, -1, "cidinfo");
+ /*lua_getfield(L, -1, "cidinfo");*/
lua_key_rawgeti(cidinfo);
if (lua_istable(L, -1)) {
i = lua_numeric_field_by_index(L,lua_key_index(version), 0);
@@ -970,9 +929,9 @@ static void read_lua_cidinfo(lua_State * L, int f)
@ @c
static void read_lua_parameters(lua_State * L, int f)
{
- int i, n;
+ int i, n, t;
const char *s;
- //lua_getfield(L, -1, "parameters");
+ /*lua_getfield(L, -1, "parameters");*/
lua_key_rawgeti(parameters);
if (lua_istable(L, -1)) {
/* the number of parameters is the max(IntegerKeys(L)),7) */
@@ -999,15 +958,24 @@ static void read_lua_parameters(lua_State * L, int f)
}
lua_pushnil(L); /* first key */
while (lua_next(L, -2) != 0) {
- if (lua_isnumber(L, -2)) {
+ t = lua_type(L,-2);
+ if (t == LUA_TNUMBER) {
i = (int) lua_tointeger(L, -2);
if (i >= 8) {
- n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0);
+ if (lua_type(L,-1) == LUA_TNUMBER) {
+ n = lua_roundnumber(L, -1);
+ } else {
+ n = 0;
+ }
set_font_param(f, i, n);
}
- } else if (lua_isstring(L, -2)) {
+ } else if (t == LUA_TSTRING) {
s = lua_tostring(L, -2);
- n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0);
+ if (lua_type(L,-1) == LUA_TNUMBER) {
+ n = lua_roundnumber(L, -1);
+ } else {
+ n = 0;
+ }
if (lua_key_eq(s, slant)) {
set_font_param(f, slant_code, n);
} else if (lua_key_eq(s, space)) {
@@ -1034,15 +1002,16 @@ static void read_lua_parameters(lua_State * L, int f)
@ @c
static void read_lua_math_parameters(lua_State * L, int f)
{
- int i = 0, n = 0;
- //lua_getfield(L, -1, "MathConstants");
+ int i = 0, n = 0, t;
+ /*lua_getfield(L, -1, "MathConstants");*/
lua_key_rawgeti(MathConstants);
if (lua_istable(L, -1)) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
- if (lua_isnumber(L, -2)) {
+ t = lua_type(L,-2);
+ if (t == LUA_TNUMBER) {
i=(int)lua_tonumber(L, -2);
- } else if (lua_isstring(L, -2)) {
+ } else if (t == LUA_TSTRING) {
i = ff_checkoption(L, -2, NULL, MATH_param_names);
}
n=(int)lua_tonumber(L, -1);
@@ -1051,6 +1020,9 @@ static void read_lua_math_parameters(lua_State * L, int f)
}
lua_pop(L, 1); /* pop value */
}
+ set_font_oldmath(f,false);
+ } else {
+ set_font_oldmath(f,true);
}
lua_pop(L, 1);
}
@@ -1061,15 +1033,16 @@ static void read_lua_math_parameters(lua_State * L, int f)
static void store_math_kerns(lua_State * L, int index, charinfo * co, int id)
{
- int l, k;
+ int l, k;
scaled ht, krn;
- lua_rawgeti(L, LUA_REGISTRYINDEX, index);lua_rawget(L, -2);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, index);
+ lua_rawget(L, -2);
if (lua_istable(L, -1) && ((k = (int) lua_rawlen(L, -1)) > 0)) {
for (l = 0; l < k; l++) {
lua_rawgeti(L, -1, (l + 1));
if (lua_istable(L, -1)) {
- ht = (scaled) lua_numeric_field_by_index(L, lua_key_index(height), MIN_INF);
- krn = (scaled) lua_numeric_field_by_index(L, lua_key_index(kern), MIN_INF);
+ ht = (scaled) lua_numeric_field_by_index(L, lua_key_index(height), MIN_INF);
+ krn = (scaled) lua_numeric_field_by_index(L, lua_key_index(kern), MIN_INF);
if (krn > MIN_INF && ht > MIN_INF)
add_charinfo_math_kern(co, id, ht, krn);
}
@@ -1084,7 +1057,7 @@ static void
font_char_from_lua(lua_State * L, internal_font_number f, int i,
int *l_fonts, boolean has_math)
{
- int k, r, t;
+ int k, r, t, lt;
charinfo *co;
kerninfo *ckerns;
liginfo *cligs;
@@ -1105,6 +1078,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
set_charinfo_depth(co, j);
j = lua_numeric_field_by_index(L, lua_key_index(italic), 0);
set_charinfo_italic(co, j);
+ j = lua_numeric_field_by_index(L, lua_key_index(vert_italic), 0);
+ set_charinfo_vert_italic(co, j);
j = lua_numeric_field_by_index(L, lua_key_index(index), 0);
set_charinfo_index(co, j);
j = lua_numeric_field_by_index(L, lua_key_index(expansion_factor), 0);
@@ -1121,14 +1096,14 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
else
set_charinfo_name(co, NULL);
/* n_string_field leaves a value on stack*/
- lua_pop(L,1);
+ lua_pop(L,1);
s = n_string_field(L, lua_key_index(tounicode));
if (s != NULL)
set_charinfo_tounicode(co, xstrdup(s));
else
set_charinfo_tounicode(co, NULL);
- /* n_string_field leaves a value on stack*/
- lua_pop(L,1);
+ /* n_string_field leaves a value on stack*/
+ lua_pop(L,1);
if (has_math) {
j = lua_numeric_field_by_index(L, lua_key_index(top_accent), INT_MIN);
set_charinfo_top_accent(co, j);
@@ -1174,8 +1149,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
startconnect = lua_numeric_field_by_index(L, lua_key_index(start), 0);
endconnect = lua_numeric_field_by_index(L, lua_key_index(end), 0);
advance = lua_numeric_field_by_index(L, lua_key_index(advance), 0);
- h = new_variant(glyph, startconnect, endconnect,
- advance, extender);
+ h = new_variant(glyph, startconnect, endconnect, advance, extender);
add_charinfo_hor_variant(co, h);
lua_pop(L, 1);
} else {
@@ -1201,8 +1175,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
startconnect = lua_numeric_field_by_index(L, lua_key_index(start), 0);
endconnect = lua_numeric_field_by_index(L, lua_key_index(end), 0);
advance = lua_numeric_field_by_index(L, lua_key_index(advance), 0);
- h = new_variant(glyph, startconnect, endconnect,
- advance, extender);
+ h = new_variant(glyph, startconnect, endconnect, advance, extender);
add_charinfo_vert_variant(co, h);
lua_pop(L, 1);
} else {
@@ -1243,18 +1216,17 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
k = non_boundarychar;
- if (lua_isnumber(L, -2)) {
+ lt = lua_type(L,-2);
+ if (lt == LUA_TNUMBER) {
k=(int)lua_tonumber(L, -2); /* adjacent char */
if (k < 0)
k = non_boundarychar;
- } else if (lua_isstring(L, -2)) {
+ } else if (lt == LUA_TSTRING) {
s = lua_tostring(L, -2);
if (lua_key_eq(s, right_boundary)) {
k = right_boundarychar;
if (!has_right_boundary(f))
- set_right_boundary(f,
- get_charinfo(f,
- right_boundarychar));
+ set_right_boundary(f, get_charinfo(f, right_boundarychar));
}
}
j = lua_roundnumber(L, -1); /* movement */
@@ -1288,7 +1260,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
lua_pushnil(L); /* first key */
if (lua_next(L, -2) != 0) {
lua_pop(L, 2);
- read_char_packets(L, (int *) l_fonts, co, atsize);
+ read_char_packets(L, (int *) l_fonts, co, f, atsize);
}
}
lua_pop(L, 1);
@@ -1305,19 +1277,18 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
k = non_boundarychar;
- if (lua_isnumber(L, -2)) {
+ lt = lua_type(L,-2);
+ if (lt == LUA_TNUMBER) {
k=(int)lua_tonumber(L, -2); /* adjacent char */
if (k < 0) {
k = non_boundarychar;
}
- } else if (lua_isstring(L, -2)) {
+ } else if (lt == LUA_TSTRING) {
s = lua_tostring(L, -2);
if (lua_key_eq(s, right_boundary)) {
k = right_boundarychar;
if (!has_right_boundary(f))
- set_right_boundary(f,
- get_charinfo(f,
- right_boundarychar));
+ set_right_boundary(f, get_charinfo(f, right_boundarychar));
}
}
r = -1;
@@ -1325,9 +1296,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
r = lua_numeric_field_by_index(L, lua_key_index(char), -1); /* ligature */
}
if (r != -1 && k != non_boundarychar) {
- t = n_enum_field(L, lua_key_index(type), 0, ligature_type_strings);
- set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k,
- r);
+ t = n_enum_field(L, lua_key_index(type), 0, ligature_type_strings);
+ set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, r);
ctr++;
} else {
luatex_warn
@@ -1358,7 +1328,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
@c
int font_from_lua(lua_State * L, int f)
{
- int i, n, r, t;
+ int i, n, r, t, lt;
int s_top; /* lua stack top */
int bc; /* first char index */
int ec; /* last char index */
@@ -1378,13 +1348,13 @@ int font_from_lua(lua_State * L, int f)
else if (lua_key_eq(ss, renew))
save_ref = 0;
/* n_string_field leaves a value on stack*/
- lua_pop(L,1);
+ lua_pop(L,1);
/* the table is at stack index -1 */
/*if (luaS_width_index == 0)
init_font_string_pointers(L);
*/
-
+
s = n_string_field_copy(L,lua_key_index(area), "");
set_font_area(f, s);
s = n_string_field_copy(L, lua_key_index(filename), NULL);
@@ -1415,6 +1385,8 @@ int font_from_lua(lua_State * L, int f)
set_font_natural_dir(f, i);
i = lua_numeric_field_by_index(L,lua_key_index(encodingbytes), 0);
set_font_encodingbytes(f, (char) i);
+ i = n_boolean_field(L,lua_key_index(oldmath), 0);
+ set_font_oldmath(f, i);
i = lua_numeric_field_by_index(L,lua_key_index(tounicode), 0);
set_font_tounicode(f, (char) i);
@@ -1451,9 +1423,7 @@ int font_from_lua(lua_State * L, int f)
set_font_format(f, i);
i = n_enum_field(L, lua_key_index(embedding), unknown_embedding, font_embedding_strings);
set_font_embedding(f, i);
- if (font_encodingbytes(f) == 0 &&
- (font_format(f) == opentype_format
- || font_format(f) == truetype_format)) {
+ if (font_encodingbytes(f) == 0 && (font_format(f) == opentype_format || font_format(f) == truetype_format)) {
set_font_encodingbytes(f, 2);
}
@@ -1467,9 +1437,12 @@ int font_from_lua(lua_State * L, int f)
for (i = 1; i <= n; i++) {
lua_rawgeti(L, -1, i);
if (lua_istable(L, -1)) {
- lua_key_rawgeti(id);
+ lua_key_rawgeti(id);
if (lua_isnumber(L, -1)) {
l_fonts[i]=(int)lua_tonumber(L, -1);
+ if (l_fonts[i] == 0) {
+ l_fonts[i] = (int) f;
+ }
lua_pop(L, 2); /* pop id and entry */
continue;
}
@@ -1477,23 +1450,13 @@ int font_from_lua(lua_State * L, int f)
};
ss = NULL;
if (lua_istable(L, -1)) {
- /* lua_getfield(L, -1, "name"); */
- /* if (lua_isstring(L, -1)) { */
- /* ss = lua_tostring(L, -1); */
- /* } */
- /* lua_pop(L, 1); /\* pop name *\/ */
- ss = n_string_field(L, lua_key_index(name));
+ ss = n_string_field(L, lua_key_index(name));
/* string is anchored */
lua_pop(L,1);
}
if (ss != NULL) {
- /* lua_getfield(L, -1, "size"); */
- /* t = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : -1000); */
- /* lua_pop(L, 1); */
- t = lua_numeric_field_by_index(L, lua_key_index(size), -1000);
- /* TODO: the stack is messed up, otherwise this
- * explicit resizing would not be needed
- */
+ t = lua_numeric_field_by_index(L, lua_key_index(size), -1000);
+ /* TODO: the stack is messed up, otherwise this explicit resizing would not be needed */
s_top = lua_gettop(L);
if (strcmp(font_name(f), ss) == 0)
l_fonts[i] = f;
@@ -1522,11 +1485,17 @@ int font_from_lua(lua_State * L, int f)
read_lua_parameters(L, f);
if (!no_math) {
read_lua_math_parameters(L, f);
+ if (n_boolean_field(L, lua_key_index(oldmath), 0)) {
+ set_font_oldmath(f,true);
+ }
+
+ } else {
+ set_font_oldmath(f,true);
}
read_lua_cidinfo(L, f);
/* characters */
- //lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(characters));lua_rawget(L, -2);
+ /*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)) {
@@ -1561,12 +1530,13 @@ int font_from_lua(lua_State * L, int f)
set_font_ec(f, ec);
lua_pushnil(L); /* first key */
while (lua_next(L, -2) != 0) {
- if (lua_isnumber(L, -2)) {
+ lt = lua_type(L,-2);
+ if (lt == LUA_TNUMBER) {
i=(int)lua_tonumber(L, -2);
if (i >= 0) {
font_char_from_lua(L, f, i, l_fonts, !no_math);
}
- } else if (lua_isstring(L, -2)) {
+ } else if (lt == LUA_TSTRING) {
const char *ss1 = lua_tostring(L, -2);
if (lua_key_eq(ss1, left_boundary)) {
font_char_from_lua(L, f, left_boundarychar, l_fonts,
@@ -1589,9 +1559,9 @@ int font_from_lua(lua_State * L, int f)
if (fstep > 100)
fstep = 100;
if (fstep != 0) {
- int fshrink = lua_numeric_field_by_index(L, lua_key_index(shrink), 0);
- int fstretch =lua_numeric_field_by_index(L, lua_key_index(stretch), 0);
- int fexpand = n_boolean_field(L, lua_key_index(auto_expand), 0);
+ int fshrink = lua_numeric_field_by_index(L, lua_key_index(shrink), 0);
+ int fstretch =lua_numeric_field_by_index(L, lua_key_index(stretch), 0);
+ int fexpand = n_boolean_field(L, lua_key_index(auto_expand), 0);
if (fshrink < 0)
fshrink = 0;
if (fshrink > 500)
@@ -1610,9 +1580,9 @@ int font_from_lua(lua_State * L, int f)
}
}
- } else { /* jikes, no characters */
- luatex_warn("lua-loaded font [%d] (%s) has no characters!", f,
- font_name(f));
+ } else {
+ /* jikes, no characters */
+ luatex_warn("lua-loaded font [%d] (%s) has no characters!", f, font_name(f));
}
if (save_ref > 0) {
@@ -1622,9 +1592,9 @@ int font_from_lua(lua_State * L, int f)
lua_pop(L, 1);
set_font_cache_id(f, save_ref);
}
- } else { /* jikes, no characters */
- luatex_warn("lua-loaded font [%d] (%s) has no character table!", f,
- font_name(f));
+ } else {
+ /* jikes, no characters */
+ luatex_warn("lua-loaded font [%d] (%s) has no character table!", f, font_name(f));
}
if (l_fonts != NULL)
@@ -1632,8 +1602,6 @@ int font_from_lua(lua_State * L, int f)
return true;
}
-
-
@* Ligaturing.
@c
@@ -1734,9 +1702,10 @@ static int try_ligature(halfword * frst, halfword fwd)
font(newgl) = font(cur);
character(newgl) = lig_replacement(lig);
set_is_ligature(newgl);
-
- /* below might not be correct in contrived border case.
- but we use it only for debugging, so ... */
+ /*
+ below might not be correct in contrived border case.
+ but we use it only for debugging, so ...
+ */
if (character(cur) < 0) {
set_is_leftboundary(newgl);
}
@@ -1755,9 +1724,11 @@ static int try_ligature(halfword * frst, halfword fwd)
node_attr(newgl) = node_attr(cur);
}
- /* TODO/FIXME if this ligature is consists of another ligature
- we should add it's |lig_ptr| to the new glyphs |lig_ptr| (and
- cleanup the no longer needed node) LOW PRIORITY */
+ /*
+ TODO/FIXME if this ligature is consists of another ligature
+ we should add it's |lig_ptr| to the new glyphs |lig_ptr| (and
+ cleanup the no longer needed node) LOW PRIORITY
+ */
/* left side */
if (keep_left) {
halfword new_first = copy_node(cur);
@@ -1828,7 +1799,7 @@ static halfword handle_lig_nest(halfword root, halfword cur)
static halfword handle_lig_word(halfword cur)
{
halfword right = null;
- if (type(cur) == whatsit_node && subtype(cur) == cancel_boundary_node) {
+ if (type(cur) == boundary_node) {
halfword prev = alink(cur);
halfword fwd = vlink(cur);
/* no need to uncouple |cur|, it is freed */
@@ -1920,8 +1891,7 @@ static halfword handle_lig_word(halfword cur)
}
/* we are finished with the |pre_break| */
handle_lig_nest(pre_break(fwd), vlink_pre_break(fwd));
- } else if (type(fwd) == whatsit_node
- && subtype(fwd) == cancel_boundary_node) {
+ } else if (type(fwd) == boundary_node) {
halfword next = vlink(fwd);
try_couple_nodes(cur, next);
flush_node(fwd);
@@ -2019,7 +1989,7 @@ static halfword handle_lig_word(halfword cur)
\.{{a-}{b}{AB} {-}{}{}} 'c'
*/
/* is it tail necessary ? */
- halfword last1 = vlink(next), tail ;
+ halfword last1 = vlink(next), tail ;
uncouple_node(next);
try_couple_nodes(fwd, last1);
/* \.{{a-}{b}{AB} {-}{c}{}} */
@@ -2092,9 +2062,7 @@ halfword handle_ligaturing(halfword head, halfword tail)
cur = vlink(prev);
while (cur != null) {
- if (type(cur) == glyph_node ||
- (type(cur) == whatsit_node
- && subtype(cur) == cancel_boundary_node)) {
+ if (type(cur) == glyph_node || (type(cur) == boundary_node)) {
cur = handle_lig_word(cur);
}
prev = cur;
@@ -2154,8 +2122,7 @@ static void add_kern_after(halfword left, halfword right, halfword aft)
}
-static void
-do_handle_kerning(halfword root, halfword init_left, halfword init_right)
+static void do_handle_kerning(halfword root, halfword init_left, halfword init_right)
{
halfword cur = vlink(root);
halfword left = null;
@@ -2249,8 +2216,7 @@ halfword handle_kerning(halfword head, halfword tail)
@* ligaturing and kerning : lua-interface.
@c
-static halfword
-run_lua_ligkern_callback(halfword head, halfword tail, int callback_id)
+static halfword run_lua_ligkern_callback(halfword head, halfword tail, int callback_id)
{
lua_State *L = Luas;
int i;
diff --git a/Build/source/texk/web2c/luatexdir/font/luatexfont.h b/Build/source/texk/web2c/luatexdir/font/luatexfont.h
index d296780063d..bd84a61672c 100644
--- a/Build/source/texk/web2c/luatexdir/font/luatexfont.h
+++ b/Build/source/texk/web2c/luatexdir/font/luatexfont.h
@@ -203,9 +203,7 @@ int readchar(boolean, chardesc *);
extern char notdef[];
/* vfovf.c */
-internal_font_number letter_space_font(internal_font_number f,
- int e, boolean nolig);
-internal_font_number auto_expand_font(internal_font_number f, int e);
+internal_font_number letter_space_font(internal_font_number f, int e, boolean nolig);
void pdf_check_vf(internal_font_number f);
internal_font_number copy_font_info(internal_font_number f);
diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.h b/Build/source/texk/web2c/luatexdir/font/texfont.h
index 10deb9f51a2..682d1d892ad 100644
--- a/Build/source/texk/web2c/luatexdir/font/texfont.h
+++ b/Build/source/texk/web2c/luatexdir/font/texfont.h
@@ -75,6 +75,7 @@ typedef struct charinfo {
scaled height; /* height */
scaled depth; /* depth */
scaled italic; /* italic correction */
+ scaled vert_italic; /* italic correction */
scaled top_accent; /* top accent alignment */
scaled bot_accent; /* bot accent alignment */
int ef; /* font expansion factor */
@@ -112,8 +113,6 @@ extern extinfo *new_variant(int glyph, int startconnect, int endconnect,
extern scaled_whd get_charinfo_whd(internal_font_number f, int c);
-
-
typedef struct texfont {
int _font_size;
int _font_dsize;
@@ -135,6 +134,7 @@ typedef struct texfont {
char _font_touched; /* internal information */
int _font_cache_id; /* internal information */
char _font_encodingbytes; /* 1 or 2 bytes */
+ boolean _font_oldmath; /* default to false when MathConstants seen */
int _font_slant; /* a slant in ppt */
int _font_extend; /* an extension in ppt, or 1000 */
@@ -198,7 +198,6 @@ extern const char *font_type_strings[];
extern const char *font_format_strings[];
extern const char *font_embedding_strings[];
-
# define font_checksum(a) font_tables[a]->_font_checksum
# define set_font_checksum(a,b) font_checksum(a) = b
@@ -292,6 +291,9 @@ boolean cmp_font_area(int, str_number);
# define font_encodingbytes(a) font_tables[a]->_font_encodingbytes
# define set_font_encodingbytes(a,b) font_encodingbytes(a) = b
+# define font_oldmath(a) font_tables[a]->_font_oldmath
+# define set_font_oldmath(a,b) font_oldmath(a) = b
+
# define font_slant(a) font_tables[a]->_font_slant
# define set_font_slant(a,b) font_slant(a) = b
@@ -334,7 +336,6 @@ boolean cmp_font_area(int, str_number);
# define pdf_font_attr(a) font_tables[a]->_pdf_font_attr
# define set_pdf_font_attr(a,b) pdf_font_attr(a) = b
-
# define left_boundarychar -1
# define right_boundarychar -2
# define non_boundarychar -3
@@ -418,6 +419,7 @@ extern void set_charinfo_width(charinfo * ci, scaled val);
extern void set_charinfo_height(charinfo * ci, scaled val);
extern void set_charinfo_depth(charinfo * ci, scaled val);
extern void set_charinfo_italic(charinfo * ci, scaled val);
+extern void set_charinfo_vert_italic(charinfo * ci, scaled val);
extern void set_charinfo_top_accent(charinfo * ci, scaled val);
extern void set_charinfo_bot_accent(charinfo * ci, scaled val);
extern void set_charinfo_tag(charinfo * ci, scaled val);
@@ -447,6 +449,7 @@ extern scaled get_charinfo_width(charinfo * ci);
extern scaled get_charinfo_height(charinfo * ci);
extern scaled get_charinfo_depth(charinfo * ci);
extern scaled get_charinfo_italic(charinfo * ci);
+extern scaled get_charinfo_vert_italic(charinfo * ci);
extern scaled get_charinfo_top_accent(charinfo * ci);
extern scaled get_charinfo_bot_accent(charinfo * ci);
extern char get_charinfo_tag(charinfo * ci);
@@ -517,6 +520,7 @@ extern scaled calc_char_width(internal_font_number f, int c, int ex);
extern scaled char_width(internal_font_number f, int c);
extern scaled char_depth(internal_font_number f, int c);
extern scaled char_italic(internal_font_number f, int c);
+extern scaled char_vert_italic(internal_font_number f, int c);
extern scaled char_top_accent(internal_font_number f, int c);
extern scaled char_bot_accent(internal_font_number f, int c);
@@ -606,6 +610,7 @@ extern int vf_packet_bytes(charinfo * co);
extern charinfo *copy_charinfo(charinfo * ci);
/* this function is in vfovf.c for the moment */
+
extern int make_vf_table(lua_State * L, const char *name, scaled s);
/* some bits of the old interface, used by e.g. writet3.c */
@@ -617,4 +622,22 @@ extern int make_vf_table(lua_State * L, const char *name, scaled s);
# define get_charheight(f,c) (char_exists(f,c) ? char_height(f,c) : 0)
# define get_chardepth(f,c) (char_exists(f,c) ? char_depth(f,c) : 0)
+/* moved from pdffont.h */
+
+extern int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */
+
+extern internal_font_number tfm_lookup(char *s, scaled fs);
+
+extern int fix_expand_value(internal_font_number f, int e);
+
+extern void set_expand_params(internal_font_number f, boolean auto_expand,
+ int stretch_limit, int shrink_limit,
+ int font_step);
+
+extern void read_expand_font(void);
+extern void new_letterspaced_font(small_number a);
+extern void make_font_copy(small_number a);
+
+extern void glyph_to_unicode(void);
+
#endif /* TEXFONT_H */
diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.w b/Build/source/texk/web2c/luatexdir/font/texfont.w
index 3ce43c161ac..7cfb52215bc 100644
--- a/Build/source/texk/web2c/luatexdir/font/texfont.w
+++ b/Build/source/texk/web2c/luatexdir/font/texfont.w
@@ -28,7 +28,7 @@ incompatible with TeX after |fetch()| has detected an error condition.
\item{} Knuth also had a |font_glue()| optimization. I've removed that
because it was a bit of dirty programming and it also was
-problematic |if 0 != null|.
+problematic |if 0 != null|.
@c
@@ -550,6 +550,11 @@ void set_charinfo_italic(charinfo * ci, scaled val)
ci->italic = val;
}
+void set_charinfo_vert_italic(charinfo * ci, scaled val)
+{
+ ci->vert_italic = val;
+}
+
void set_charinfo_top_accent(charinfo * ci, scaled val)
{
ci->top_accent = val;
@@ -834,7 +839,7 @@ void set_charinfo_extensible(charinfo * ci, int top, int bot, int mid, int rep)
}
}
-@ Note that many more simple things like this are implemented as macros
+@ Note that many more simple things like this are implemented as macros
in the header file.
@c
@@ -858,6 +863,11 @@ scaled get_charinfo_italic(charinfo * ci)
return ci->italic;
}
+scaled get_charinfo_vert_italic(charinfo * ci)
+{
+ return ci->vert_italic;
+}
+
scaled get_charinfo_top_accent(charinfo * ci)
{
return ci->top_accent;
@@ -956,8 +966,7 @@ scaled calc_char_width(internal_font_number f, int c, int ex)
{
charinfo *ci = char_info(f, c);
scaled w = get_charinfo_width(ci);
- //printf("ex=%d\n",ex);
- if (ex != 0)
+ if (ex != 0)
w = round_xn_over_d(w, 1000 + ex, 1000);
return w;
}
@@ -965,21 +974,29 @@ scaled calc_char_width(internal_font_number f, int c, int ex)
scaled char_depth(internal_font_number f, int c)
{
charinfo *ci = char_info(f, c);
- scaled w = get_charinfo_depth(ci);
- return w;
+ scaled d = get_charinfo_depth(ci);
+ return d;
}
scaled char_height(internal_font_number f, int c)
{
charinfo *ci = char_info(f, c);
- scaled w = get_charinfo_height(ci);
- return w;
+ scaled h = get_charinfo_height(ci);
+ return h;
}
scaled char_italic(internal_font_number f, int c)
{
charinfo *ci = char_info(f, c);
- return get_charinfo_italic(ci);
+ scaled i = get_charinfo_italic(ci);
+ return i;
+}
+
+scaled char_vert_italic(internal_font_number f, int c)
+{
+ charinfo *ci = char_info(f, c);
+ scaled i = get_charinfo_vert_italic(ci);
+ return i;
}
scaled char_top_accent(internal_font_number f, int c)
@@ -1249,6 +1266,22 @@ boolean cmp_font_area(int id, str_number t)
return 1;
}
+@ Here come some subroutines to deal with expanded fonts for HZ-algorithm.
+return 1 == identical
+@c
+static boolean cmp_font_name(int id, char *tt)
+{
+ char *tid;
+ if (!is_valid_font(id))
+ return 0;
+ tid = font_name(id);
+ if (tt == NULL && tid == NULL)
+ return 1;
+ if (tt == NULL || tid == NULL || strcmp(tid, tt) != 0)
+ return 0;
+ return 1;
+}
+
@ @c
int test_no_ligatures(internal_font_number f)
{
@@ -1463,6 +1496,7 @@ static void dump_charinfo(int f, int c)
dump_int(get_charinfo_height(co));
dump_int(get_charinfo_depth(co));
dump_int(get_charinfo_italic(co));
+ dump_int(get_charinfo_vert_italic(co));
dump_int(get_charinfo_top_accent(co));
dump_int(get_charinfo_bot_accent(co));
dump_int(get_charinfo_tag(co));
@@ -1527,6 +1561,7 @@ static void dump_font_entry(texfont * f)
dump_int(f->_font_touched);
dump_int(f->_font_cache_id);
dump_int(f->_font_encodingbytes);
+ dump_int(f->_font_oldmath);
dump_int(f->_font_slant);
dump_int(f->_font_extend);
dump_int(f->font_max_shrink);
@@ -1610,6 +1645,8 @@ static int undump_charinfo(int f)
undump_int(x);
set_charinfo_italic(co, x);
undump_int(x);
+ set_charinfo_vert_italic(co, x);
+ undump_int(x);
set_charinfo_top_accent(co, x);
undump_int(x);
set_charinfo_bot_accent(co, x);
@@ -1699,6 +1736,7 @@ static void undump_font_entry(texfont * f)
undump_int(x); f->_font_touched = (char)x;
undump_int(x); f->_font_cache_id = x;
undump_int(x); f->_font_encodingbytes = (char)x;
+ undump_int(x); f->_font_oldmath = x;
undump_int(x); f->_font_slant = x;
undump_int(x); f->_font_extend = x;
undump_int(x); f->font_max_shrink = x;
@@ -1776,3 +1814,197 @@ void undump_font(int f)
i = undump_charinfo(f);
}
}
+
+/* moved from pdffont.w */
+
+@ @c
+#define font_id_text(A) cs_text(font_id_base+(A)) /* a frozen font identifier's name */
+
+int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */
+
+@ @c
+internal_font_number tfm_lookup(char *s, scaled fs)
+{ /* looks up for a TFM with name |s| loaded at |fs| size; if found then flushes |s| */
+ internal_font_number k;
+ if (fs != 0) {
+ for (k = 1; k <= max_font_id(); k++) {
+ if (cmp_font_name(k, s) && font_size(k) == fs) {
+ return k;
+ }
+ }
+ } else {
+ for (k = 1; k <= max_font_id(); k++) {
+ if (cmp_font_name(k, s)) {
+ return k;
+ }
+ }
+ }
+ return null_font;
+}
+
+@ @c
+int fix_expand_value(internal_font_number f, int e)
+{ /* return the multiple of |font_step(f)| that is nearest to |e| */
+ int step;
+ int max_expand;
+ boolean neg;
+ if (e == 0)
+ return 0;
+ if (e < 0) {
+ e = -e;
+ neg = true;
+ max_expand = font_max_shrink(f);
+ } else {
+ neg = false;
+ max_expand = font_max_stretch(f);
+ }
+ if (e > max_expand) {
+ e = max_expand;
+ } else {
+ step = font_step(f);
+ if (e % step > 0)
+ e = step * round_xn_over_d(e, 1, step);
+ }
+ if (neg)
+ e = -e;
+ return e;
+}
+
+@ @c
+void set_expand_params(internal_font_number f, boolean auto_expand,
+ int stretch_limit, int shrink_limit, int font_step)
+{ /* expand a font with given parameters */
+ set_font_step(f, font_step);
+ set_font_auto_expand(f, auto_expand);
+ set_font_max_shrink(f, shrink_limit);
+ set_font_max_stretch(f, stretch_limit);
+}
+
+@ @c
+void read_expand_font(void)
+{ /* read font expansion spec and load expanded font */
+ int shrink_limit, stretch_limit, font_step;
+ internal_font_number f;
+ boolean auto_expand;
+ /* read font expansion parameters */
+ scan_font_ident();
+ f = cur_val;
+ if (f == null_font)
+ normal_error("font expansion", "invalid font identifier");
+ /*if (pdf_font_blink(f) != null_font)*/
+ /* normal_error("font expansion",*/
+ /* "\\fontexpand cannot be used this way (the base font has been expanded)");*/
+ scan_optional_equals();
+ scan_int();
+ stretch_limit = fix_int(cur_val, 0, 1000);
+ scan_int();
+ shrink_limit = fix_int(cur_val, 0, 500);
+ scan_int();
+ font_step = fix_int(cur_val, 0, 100);
+ if (font_step == 0)
+ normal_error("font expansion", "invalid step");
+ stretch_limit = stretch_limit - stretch_limit % font_step;
+ if (stretch_limit < 0)
+ stretch_limit = 0;
+ shrink_limit = shrink_limit - shrink_limit % font_step;
+ if (shrink_limit < 0)
+ shrink_limit = 0;
+ if ((stretch_limit == 0) && (shrink_limit == 0))
+ normal_error("font expansion", "invalid limit(s)");
+ auto_expand = false;
+ if (scan_keyword("autoexpand")) {
+ auto_expand = true;
+ /* Scan an optional space */
+ get_x_token();
+ if (cur_cmd != spacer_cmd)
+ back_input();
+ }
+
+ if (font_step(f) != 0) {
+ /* this font has been expanded, ensure the expansion parameters are identical */
+ if (font_step(f) != font_step)
+ normal_error("font expansion","font has been expanded with different expansion step");
+
+ if (((font_max_stretch(f) == 0) && (stretch_limit != 0)) ||
+ ((font_max_stretch(f) > 0)
+ && (font_max_stretch(f) != stretch_limit)))
+ normal_error("font expansion","font has been expanded with different stretch limit");
+
+ if (((font_max_shrink(f) == 0) && (shrink_limit != 0)) ||
+ ((font_max_shrink(f) > 0)
+ && (font_max_shrink(f) != shrink_limit)))
+ normal_error("font expansion","font has been expanded with different shrink limit");
+
+ if (font_auto_expand(f) != auto_expand)
+ normal_error("font expansion","font has been expanded with different auto expansion value");
+ } else {
+ if (font_used(f))
+ normal_warning("font expansion", "font should be expanded before its first use", true, true);
+ set_expand_params(f, auto_expand, stretch_limit, shrink_limit,
+ font_step);
+ }
+}
+
+@ @c
+void new_letterspaced_font(small_number a)
+{ /* letter-space a font by creating a virtual font */
+ pointer u; /* user's font identifier */
+ str_number t; /* name for the frozen font identifier */
+ internal_font_number f, k;
+ boolean nolig = false;
+ get_r_token();
+ u = cur_cs;
+ if (u >= hash_base)
+ t = cs_text(u);
+ else
+ t = maketexstring("FONT");
+ define(u, set_font_cmd, null_font);
+ scan_optional_equals();
+ scan_font_ident();
+ k = cur_val;
+ scan_int();
+ if (scan_keyword("nolig"))
+ nolig=true;
+ f = letter_space_font(k, fix_int(cur_val, -1000, 1000), nolig);
+ equiv(u) = f;
+ eqtb[font_id_base + f] = eqtb[u];
+ font_id_text(f) = t;
+}
+
+@ @c
+void make_font_copy(small_number a)
+{ /* make a font copy for further use with font expansion */
+ pointer u; /* user's font identifier */
+ str_number t; /* name for the frozen font identifier */
+ internal_font_number f, k;
+ get_r_token();
+ u = cur_cs;
+ if (u >= hash_base)
+ t = cs_text(u);
+ else
+ t = maketexstring("FONT");
+ define(u, set_font_cmd, null_font);
+ scan_optional_equals();
+ scan_font_ident();
+ k = cur_val;
+ f = copy_font_info(k);
+ equiv(u) = f;
+ eqtb[font_id_base + f] = eqtb[u];
+ font_id_text(f) = t;
+}
+
+@ @c
+void glyph_to_unicode(void)
+{
+ str_number s1, s2;
+ scan_pdf_ext_toks();
+ s1 = tokens_to_string(def_ref);
+ delete_token_ref(def_ref);
+ scan_pdf_ext_toks();
+ s2 = tokens_to_string(def_ref);
+ delete_token_ref(def_ref);
+ def_tounicode(s1, s2);
+ flush_str(s2);
+ flush_str(s1);
+}
+
diff --git a/Build/source/texk/web2c/luatexdir/font/tfmofm.w b/Build/source/texk/web2c/luatexdir/font/tfmofm.w
index 41542689c7f..6eeccdda214 100644
--- a/Build/source/texk/web2c/luatexdir/font/tfmofm.w
+++ b/Build/source/texk/web2c/luatexdir/font/tfmofm.w
@@ -22,7 +22,7 @@
#include "ptexlib.h"
-@ Here are some macros that help process ligatures and kerns
+@ Here are some macros that help process ligatures and kerns
@c
#define lig_kern_start(f,c) char_remainder(f,c)
#define stop_flag 128 /* value indicating `\.{STOP}' in a lig/kern program */
@@ -48,7 +48,7 @@ $\Omega$ is capable of reading not only \.{TFM} files, but also
\.{OFM} files, which can describe fonts with up to 65536 characters
and with huge lig/kern tables. These fonts will often be virtual
fonts built up from real fonts with 256 characters, but $\Omega$
-is not aware of this.
+is not aware of this.
The documentation below describes \.{TFM} files, with slight additions
to show where \.{OFM} files differ.
@@ -73,7 +73,7 @@ $$\vbox{\halign{\hfil#&$\null=\null$#\hfil\cr
They are all nonnegative and less than $2^{15}$. We must have |bc-1<=ec<=255|,
and
$$\hbox{|lf=6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$
-Note that a \.{TFM} font may contain as many as 256 characters
+Note that a \.{TFM} font may contain as many as 256 characters
(if |bc=0| and |ec=255|), and as few as 0 characters (if |bc=ec+1|).
Incidentally, when two or more 8-bit bytes are combined to form an integer of
@@ -89,7 +89,7 @@ the first two bytes be 0 to differentiate \.{TFM} and \.{OFM} files).
The next twelve integers are as above, all nonegative and less
than~$2^{31}$. We must have |bc-1<=ec<=65535|, and
$$\hbox{|lf=13+lh+2*(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$
-Note that an \.{OFM} font may contain as many as 65536 characters
+Note that an \.{OFM} font may contain as many as 65536 characters
(if |bc=0| and |ec=65535|), and as few as 0 characters (if |bc=ec+1|).
The rest of the \.{TFM} file may be regarded as a sequence of ten data
@@ -177,13 +177,13 @@ to have the same height, depth, or italic correction, the \.{TFM} format
imposes a limit of 16 different heights, 16 different depths, and
64 different italic corrections.
-For \.{OFM} files, two words (eight bytes) are used.
+For \.{OFM} files, two words (eight bytes) are used.
The arrangement is as follows.
\yskip\hang first and second bytes: |@!width_index| (16 bits)\par
\hang third byte: |@!height_index| (8 bits)\par
\hang fourth byte: |@!depth_index| (8~bits)\par
-\hang fifth and sixth bytes:
+\hang fifth and sixth bytes:
|@!italic_index| (14 bits) times 4, plus |@!tag| (2~bits)\par
\hang seventh and eighth bytes: |@!remainder| (16 bits)\par
\yskip\noindent
@@ -220,7 +220,7 @@ It returns the value of the internal font number that was just loaded.
If an error is detected, an error message is issued and no font
information is stored; |null_font| is returned in this case.
-@
+@
The |tag| field in a |char_info_word| has four values that explain how to
interpret the |remainder| field.
@@ -295,8 +295,8 @@ or kerning command is performed.
@ Extensible characters are specified by an |@!extensible_recipe|, which
-consists of four bytes in a \.{TFM} file,
-called |@!top|, |@!mid|, |@!bot|, and |@!rep| (in this order).
+consists of four bytes in a \.{TFM} file,
+called |@!top|, |@!mid|, |@!bot|, and |@!rep| (in this order).
In an \.{OFM} file, each field takes two bytes, for eight in total.
These bytes are the character codes of individual pieces used to
build up a large symbol. If |top|, |mid|, or |bot| are zero, they are not
@@ -539,13 +539,15 @@ scaled store_scaled_f(scaled sq, scaled z_in)
sq = sq / 256;
a = (eight_bits) ((sq + 128) % 256);
}
+ if (beta==0)
+ normal_error("vf", "vf scaling");
sw = (((((d * z) >> 8) + (c * z)) >> 8) + (b * z)) / beta;
if (a == 0)
return sw;
else if (a == 255)
return (sw - alpha);
else
- pdf_error("vf", "vf scaling");
+ normal_error("vf", "vf scaling");
return sw; /* not reached, just to make the compiler happy */
}
@@ -700,7 +702,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s)
if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0))
tfm_abort;
- /*
+ /*
We check to see that the \.{TFM} file doesn't end prematurely; but
no error message is given for files having more than |lf| words.
*/
@@ -768,6 +770,10 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s)
alpha = alpha + alpha;
};
beta = (char) (256 / alpha);
+
+ /* beta cannot be zero */
+ if (beta==0)
+ normal_error("vf", "vf reading");
alpha = alpha * z;
/* Read box dimensions */
@@ -813,7 +819,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s)
bchar = b;
} else {
#if 0
- if (b!=bchar) check_existence(b);
+ if (b!=bchar) check_existence(b);
#endif
if (c < 128) {
#if 0
@@ -872,7 +878,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s)
fkerns = 0;
if (bch_label != nl) {
k = bch_label;
-#if 0
+#if 0
if (skip_byte(k) > stop_flag)
k = lig_kern_restart(k);
#endif
@@ -904,7 +910,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s)
#if 0
if (skip_byte(k) > stop_flag)
k = lig_kern_restart(k);
-#endif
+#endif
while (1) {
if (skip_byte(k) <= stop_flag) {
if (op_byte(k) >= kern_flag) { /* kern */
diff --git a/Build/source/texk/web2c/luatexdir/font/tt_glyf.w b/Build/source/texk/web2c/luatexdir/font/tt_glyf.w
index 21711a6be7a..0345db62441 100644
--- a/Build/source/texk/web2c/luatexdir/font/tt_glyf.w
+++ b/Build/source/texk/web2c/luatexdir/font/tt_glyf.w
@@ -592,7 +592,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g)
for (i = 0; i < g->num_glyphs; i++) {
USHORT gid; /* old gid */
ULONG loc, len;
- //SHORT number_of_contours;
+ /*SHORT number_of_contours;*/
gid = g->gd[i].ogid;
if (gid >= maxp->numGlyphs)
diff --git a/Build/source/texk/web2c/luatexdir/font/vfovf.w b/Build/source/texk/web2c/luatexdir/font/vfovf.w
index 9b4361773ea..d1054a679ab 100644
--- a/Build/source/texk/web2c/luatexdir/font/vfovf.w
+++ b/Build/source/texk/web2c/luatexdir/font/vfovf.w
@@ -125,7 +125,7 @@ typedef struct vf_stack_record {
scaled stack_w, stack_x, stack_y, stack_z;
} vf_stack_record;
-@ get a byte from\.{VF} file
+@ get a byte from\.{VF} file
@c
#define vf_byte(a) \
{ \
@@ -150,7 +150,7 @@ typedef struct vf_stack_record {
}
-@ read |k| bytes as an integer from \.{VF} file
+@ read |k| bytes as an integer from \.{VF} file
beware: the |vf_read()| macro differs from |vf_read()| in vftovp.web for 1...3 byte words.
@c
#define vf_read(k, l) \
@@ -181,7 +181,7 @@ beware: the |vf_read()| macro differs from |vf_read()| in vftovp.web for 1...3 b
void pdf_check_vf(internal_font_number f)
{
if (font_type(f) == virtual_font_type)
- pdf_error("font", "command cannot be used with virtual font");
+ normal_error("font", "command cannot be used with virtual font");
}
static void
@@ -202,8 +202,10 @@ vf_local_font_warning(internal_font_number f, internal_font_number k,
}
-@ process a local font in \.{VF} file
+@ process a local font in \.{VF} file
@c
+int level = 0;
+
static internal_font_number
vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr)
{
@@ -264,20 +266,30 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr)
(*vf_cr)++;
append_char(junk);
}
- s = make_string();
- st = makecstring(s);
- k = tfm_lookup(st, fs);
- if (k == null_font)
- k = read_font_info(null_cs, st, fs, -1);
- free(st);
- if (k != null_font) {
- if (checksum != 0 && font_checksum(k) != 0
- && checksum != font_checksum(k))
- vf_local_font_warning(f, k, "checksum mismatch", (int) checksum,
- (int) font_checksum(k));
- if (ds != font_dsize(k))
- vf_local_font_warning(f, k, "design size mismatch", ds,
- font_dsize(k));
+ if (level > 5) {
+ normal_warning("vf","quitting at recurse depth > 5",true,true);
+ k = f ;
+ } else if ((level > 1) && (fs > 65536*1024)) {
+ normal_warning("vf","quitting when recursing at size > 65536*1024",true,true);
+ k = f ;
+ } else {
+ level += 1 ;
+ s = make_string();
+ st = makecstring(s);
+ k = tfm_lookup(st, fs);
+ if (k == null_font)
+ k = read_font_info(null_cs, st, fs, -1);
+ free(st);
+ level -= 1 ;
+ if (k != null_font) {
+ if (checksum != 0 && font_checksum(k) != 0
+ && checksum != font_checksum(k))
+ vf_local_font_warning(f, k, "checksum mismatch", (int) checksum,
+ (int) font_checksum(k));
+ if (ds != font_dsize(k))
+ vf_local_font_warning(f, k, "design size mismatch", ds,
+ font_dsize(k));
+ }
}
return k;
}
@@ -331,7 +343,7 @@ static int open_vf_file(const char *fn, unsigned char **vbuffer, int *vsize)
#define append_packet(k) vpackets[vf_np++] = (eight_bits)(k)
@ life is easier if all internal font commands are fnt4 and
- all character commands are set4 or put4
+ all character commands are set4 or put4
@c
#define append_fnt_set(k) \
@@ -349,7 +361,7 @@ static int open_vf_file(const char *fn, unsigned char **vbuffer, int *vsize)
append_packet((k & 0x000000FF)); \
}
-@ some of these things happen twice, adding a define is simplest
+@ some of these things happen twice, adding a define is simplest
@c
#define test_checksum() { vf_byte(tmp_b0); vf_byte(tmp_b1); \
@@ -662,7 +674,7 @@ void do_vf(internal_font_number f)
vf_stack_index stack_level;
int vf_z; /* multiplier */
int vf_alpha; /* correction for negative values */
- //char vf_beta; /* divisor */
+ /*char vf_beta;*/ /* divisor */
int vf_np;
eight_bits *vpackets;
memory_word tmp_w; /* accumulator */
@@ -1048,7 +1060,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize)
vf_stack_index stack_level;
int vf_z; /* multiplier */
int vf_alpha; /* correction for negative values */
- //char vf_beta; /* divisor */
+ /*char vf_beta;*/ /* divisor */
eight_bits *s;
scaled h, v;
scaled w, x, y, z;
@@ -1403,39 +1415,6 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize)
return 1;
}
-@ unused, remains for reference, for a while
-@c
-internal_font_number auto_expand_font(internal_font_number f, int e)
-{
- internal_font_number k;
- kerninfo *krn;
- charinfo *co;
- int i;
- scaled w;
- assert(0);
- k = copy_font(f);
- set_font_name(k, font_name(f));
- //set_font_expand_ratio(k, e);
- for (i = font_bc(k); i <= font_ec(k); i++) {
- if (quick_char_exists(k, i)) {
- co = get_charinfo(k, i);
- w = round_xn_over_d(char_width(f, i), 1000 + e, 1000);
- set_charinfo_width(co, w);
- w = round_xn_over_d(char_italic(f, i), 1000 + e, 1000);
- set_charinfo_italic(co, w);
- krn = get_charinfo_kerns(co);
- if (krn != NULL) {
- while (!kern_end((*krn))) {
- kern_kern(*krn) =
- round_xn_over_d(kern_kern(*krn), 1000 + e, 1000);
- krn++;
- }
- }
- }
- }
- return k;
-}
-
@ @c
internal_font_number
letter_space_font(internal_font_number f, int e, boolean nolig)
@@ -1464,7 +1443,7 @@ letter_space_font(internal_font_number f, int e, boolean nolig)
/* create the corresponding virtual font */
set_font_type(k, virtual_font_type);
-
+
for (c=font_bc(k);c<=font_ec(k);c++) {
if (quick_char_exists(k, c)) {
int half_w;
@@ -1498,7 +1477,7 @@ letter_space_font(internal_font_number f, int e, boolean nolig)
set_font_param(k, quad_code, -round_xn_over_d(quad(k), 1000-e, 1000));
} else {
set_font_param(k, quad_code, round_xn_over_d(quad(k), 1000+e, 1000));
- }
+ }
#endif
return k;
}
diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.w b/Build/source/texk/web2c/luatexdir/font/vfpacket.w
index 0842353225e..c885d809c96 100644
--- a/Build/source/texk/web2c/luatexdir/font/vfpacket.w
+++ b/Build/source/texk/web2c/luatexdir/font/vfpacket.w
@@ -93,7 +93,7 @@ int vf_packet_bytes(charinfo * co)
vfp += (int) k;
break;
default:
- pdf_error("vf", "invalid DVI command (1)");
+ normal_error("vf", "invalid DVI command (1)");
}
};
return (vfp - vf_packets);
@@ -190,13 +190,13 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph)
case packet_push_code:
vp->packet_stack_level++;
if (vp->packet_stack_level == packet_stack_size)
- pdf_error("vf", "packet_stack_level overflow");
+ normal_error("vf", "packet_stack_level overflow");
vp->packet_stack[vp->packet_stack_level] = *mat_p;
mat_p = &(vp->packet_stack[vp->packet_stack_level]);
break;
case packet_pop_code:
if (vp->packet_stack_level == vp->packet_stack_minlevel)
- pdf_error("vf", "packet_stack_level underflow");
+ normal_error("vf", "packet_stack_level underflow");
vp->packet_stack_level--;
mat_p = &(vp->packet_stack[vp->packet_stack_level]);
break;
@@ -268,7 +268,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph)
pdf->pstruct->need_tf = true;
break;
default:
- pdf_error("vf", "invalid DVI command (2)");
+ normal_error("vf", "invalid DVI command (2)");
}
synch_pos_with_cur(&localpos, save_posstruct, mat_p->pos); /* trivial case, always TLT */
}
@@ -324,7 +324,7 @@ int *packet_local_fonts(internal_font_number f, int *num)
vfp += i;
break;
default:
- pdf_error("vf", "invalid DVI command (3)");
+ normal_error("vf", "invalid DVI command (3)");
}
}
}
@@ -392,7 +392,7 @@ replace_packet_fonts(internal_font_number f, int *old_fontid,
vfp += k;
break;
default:
- pdf_error("vf", "invalid DVI command (4)");
+ normal_error("vf", "invalid DVI command (4)");
}
}
}
diff --git a/Build/source/texk/web2c/luatexdir/font/writeenc.w b/Build/source/texk/web2c/luatexdir/font/writeenc.w
index 54ce687d50a..a6e4ebaaeac 100644
--- a/Build/source/texk/web2c/luatexdir/font/writeenc.w
+++ b/Build/source/texk/web2c/luatexdir/font/writeenc.w
@@ -149,6 +149,7 @@ static void destroy_fe_entry(void *pa, void *pb)
if (p->glyph_names[i] != notdef)
xfree(p->glyph_names[i]);
xfree(p->glyph_names);
+ avl_destroy(p->tx_tree,NULL);
xfree(p);
}
diff --git a/Build/source/texk/web2c/luatexdir/font/writet1.w b/Build/source/texk/web2c/luatexdir/font/writet1.w
index 377efe750dd..16dff008e73 100644
--- a/Build/source/texk/web2c/luatexdir/font/writet1.w
+++ b/Build/source/texk/web2c/luatexdir/font/writet1.w
@@ -1567,14 +1567,25 @@ static void t1_flush_cs(PDF pdf, boolean is_subr)
}
}
xfree(ptr->data);
+ if (is_subr)
+ ptr->valid=false;
if (ptr->name != notdef)
xfree(ptr->name);
}
sprintf(t1_line_array, "%s", line_end);
t1_line_ptr = eol(t1_line_array);
t1_putline(pdf);
- if (is_subr)
- xfree(return_cs);
+ if (is_subr) {
+ end_tab = subr_tab + subr_size;
+ for (ptr = tab; ptr < end_tab; ptr++) {
+ if (ptr->valid) {
+ xfree(ptr->data);
+ if (ptr->name != notdef)
+ xfree(ptr->name);
+ }
+ }
+ xfree(return_cs);
+ }
xfree(tab);
xfree(start_line);
xfree(line_end);
@@ -1662,10 +1673,13 @@ static void t1_subset_charstrings(PDF pdf)
cs_dict_end = xstrdup(t1_line_array);
t1_mark_glyphs();
if (subr_tab != NULL) {
+
+
if (cs_token_pair == NULL)
luatex_fail
("This Type 1 font uses mismatched subroutine begin/end token pairs.");
t1_subr_flush();
+
}
for (cs_counter = 0, ptr = cs_tab; ptr < cs_ptr; ptr++)
if (ptr->used)
diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.w b/Build/source/texk/web2c/luatexdir/font/writetype2.w
index 618d1b5ce77..8980344afd7 100644
--- a/Build/source/texk/web2c/luatexdir/font/writetype2.w
+++ b/Build/source/texk/web2c/luatexdir/font/writetype2.w
@@ -236,7 +236,7 @@ static struct {
unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx, fd_entry * fd)
{
- //ULONG version;
+ /*ULONG version;*/
unsigned long offset = 0;
unsigned long num_dirs = 0;
diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.h b/Build/source/texk/web2c/luatexdir/image/epdf.h
index 6bd9734b9dc..09bc7cc84e4 100644
--- a/Build/source/texk/web2c/luatexdir/image/epdf.h
+++ b/Build/source/texk/web2c/luatexdir/image/epdf.h
@@ -197,13 +197,8 @@ PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe);
PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streamsize, const char *file_id);
-
#define STREAM_CHECKSUM_SIZE 16 // md5
-#if defined(_MSC_VER) // VS 2010 cannot compile log(ULONG_MAX)/log(16)
#define STRSTREAM_CHECKSUM_SIZE 1+((unsigned int)(log((double)ULONG_MAX)/log(16.0))) // djb2 printable digest as hex stream
-#else
-#define STRSTREAM_CHECKSUM_SIZE 1+((unsigned int)(log(ULONG_MAX)/log(16))) // djb2 printable digest as hex stream
-#endif
#define STREAM_FILE_ID_LEN 2048 // 2048 bytes are enough to make a strong almost-unique name
#define STREAM_URI "data:application/pdf,"
#define STREAM_URI_LEN 21 // length of "data:application/pdf," without final '\0'
diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
index cacaea11389..caa510497ba 100644
--- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
+++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
@@ -249,7 +249,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streams
pdf_doc->file_path, pdf_doc->occurences);
#endif
assert(pdf_doc->checksum != NULL);
- // As is now, checksum is in file_path, so this check is should be useless.
+ // As is now, checksum is in file_path, so this check should be useless.
if (strncmp(pdf_doc->checksum, checksum, STRSTREAM_CHECKSUM_SIZE) != 0) {
luatex_fail("PDF inclusion: stream has changed '%s'", file_path);
}
diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.w b/Build/source/texk/web2c/luatexdir/image/writeimg.w
index 561efd514c0..a93fb6de642 100644
--- a/Build/source/texk/web2c/luatexdir/image/writeimg.w
+++ b/Build/source/texk/web2c/luatexdir/image/writeimg.w
@@ -38,10 +38,6 @@
#include "lua.h" /* for |LUA_NOREF| */
#include "lauxlib.h"
-@ @c
-#define pdf_image_resolution int_par(pdf_image_resolution_code)
-#define pdf_pagebox int_par(pdf_pagebox_code)
-
@* Patch ImageTypeDetection 2003/02/08 by Heiko Oberdiek.
Function |readimage| performs some basic initializations.
@@ -125,7 +121,7 @@
#define HEADER_PDF "%PDF-1."
#define MAX_HEADER (sizeof(HEADER_PNG)-1)
#define HEADER_PDF_MEMSTREAM "data:application/pdf," /* see epdf.h */
-#define LEN_PDF_MEMSTREAM 21 /* see epdf.h */
+#define LEN_PDF_MEMSTREAM 21 /* see epdf.h */
static void check_type_by_header(image_dict * idict)
@@ -133,7 +129,7 @@ static void check_type_by_header(image_dict * idict)
int i;
FILE *file = NULL;
char header[MAX_HEADER];
- char prefix[LEN_PDF_MEMSTREAM+1];
+ char prefix[LEN_PDF_MEMSTREAM+1];
assert(idict != NULL);
if (img_type(idict) != IMG_TYPE_NONE) /* nothing to do */
@@ -143,7 +139,7 @@ static void check_type_by_header(image_dict * idict)
/* Like */
/* file = xfopen(img_filepath(idict), FOPEN_RBIN_MODE);*/
/* but we also check for a memstream object */
- assert(img_filepath(idict) && FOPEN_RBIN_MODE);
+ assert(img_filepath(idict) && FOPEN_RBIN_MODE);
file = fopen(img_filepath(idict), FOPEN_RBIN_MODE);
if (file == NULL) {
/* check the prefix of img_filepath(idict) */
@@ -448,9 +444,8 @@ void scan_pdfximage(PDF pdf)
img_attr(idict) = attr;
img_dimen(idict) = alt_rule;
img_transform(idict) = transform;
- pdf_last_ximage = img_objnum(idict);
- pdf_last_ximage_pages = img_totalpages(idict);
- pdf_last_ximage_colordepth = img_colordepth(idict);
+ last_saved_image_index = img_objnum(idict);
+ last_saved_image_pages = img_totalpages(idict);
}
@ @c
@@ -464,7 +459,7 @@ void scan_pdfrefximage(PDF pdf)
alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */
scan_int();
check_obj_type(pdf, obj_type_ximage, cur_val);
- new_whatsit(pdf_refximage_node);
+ tail_append(new_rule(image_rule));
idict = idict_array[obj_data_ptr(pdf, cur_val)];
if (alt_rule.wd != null_flag || alt_rule.ht != null_flag
|| alt_rule.dp != null_flag)
@@ -474,8 +469,8 @@ void scan_pdfrefximage(PDF pdf)
width(tail) = dim.wd;
height(tail) = dim.ht;
depth(tail) = dim.dp;
- pdf_ximage_transform(tail) = transform;
- pdf_ximage_index(tail) = img_index(idict);
+ rule_transform(tail) = transform;
+ rule_index(tail) = img_index(idict);
}
@ |tex_scale()| sequence of decisions:
@@ -702,23 +697,28 @@ void pdf_dict_add_img_filename(PDF pdf, image_dict * idict)
{
char s[21], *p;
assert(idict != NULL);
- /* for now PTEX.FileName only for PDF, but prepared for JPG, PNG, ... */
- if ((img_type(idict) != IMG_TYPE_PDF) || (img_type(idict) != IMG_TYPE_PDFMEMSTREAM))
- return;
- if (img_visiblefilename(idict) != NULL) {
- if (strlen(img_visiblefilename(idict)) == 0)
- return; /* empty string blocks PTEX.FileName output */
- else
- p = img_visiblefilename(idict);
- } else
- p = img_filepath(idict);
- // write additional information
- snprintf(s, 20, "%s.FileName", pdfkeyprefix);
- pdf_add_name(pdf, s);
- pdf_printf(pdf, " (%s)", convertStringToPDFString(p, strlen(p)));
+ if (pdf_image_addfilename>0) {
+ /* for now PTEX.FileName only for PDF, but prepared for JPG, PNG, ... */
+ if (! ( (img_type(idict) == IMG_TYPE_PDF) || (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) ))
+ return;
+ if (img_visiblefilename(idict) != NULL) {
+ if (strlen(img_visiblefilename(idict)) == 0) {
+ return; /* empty string blocks PTEX.FileName output */
+ } else {
+ p = img_visiblefilename(idict);
+ }
+ } else {
+ /* unset so let's use the default */
+ p = img_filepath(idict);
+ }
+ // write additional information
+ snprintf(s, 20, "%s.FileName", pdfkeyprefix);
+ pdf_add_name(pdf, s);
+ pdf_printf(pdf, " (%s)", convertStringToPDFString(p, strlen(p)));
+ }
}
-@ To allow the use of \.{\\pdfrefximage} inside saved boxes in -ini mode,
+@ To allow the use of box resources inside saved boxes in -ini mode,
the information in the array has to be (un)dumped with the format.
The next two routines take care of that.
diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.w b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
index 5d07e60038f..c661b6c8213 100644
--- a/Build/source/texk/web2c/luatexdir/lang/hyphen.w
+++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
@@ -41,6 +41,7 @@
#include "ptexlib.h"
+#include "lua/luatex-api.h"
#include <stdlib.h> /* for NULL, malloc */
#include <stdio.h> /* for fprintf */
@@ -61,7 +62,7 @@
@ TODO: should be moved to separate library
-@c
+@c
static unsigned char *hnj_strdup(const unsigned char *s)
{
unsigned char *new;
@@ -77,7 +78,7 @@ static unsigned char *hnj_strdup(const unsigned char *s)
@* Type definitions.
@ a little bit of a hash table implementation. This simply maps strings
- to state numbers
+ to state numbers
@c
typedef struct _HashTab HashTab;
@@ -224,7 +225,7 @@ static void delete_HashIter(HashIter * i)
}
-@ a |char*| hash function from ASU - adapted from Gtk+
+@ a |char*| hash function from ASU - adapted from Gtk+
@c
static unsigned int hnj_string_hash(const unsigned char *s)
@@ -243,7 +244,7 @@ static unsigned int hnj_string_hash(const unsigned char *s)
}
-@ assumes that key is not already present!
+@ assumes that key is not already present!
@c
static void state_insert(HashTab * hashtab, unsigned char *key, int state)
@@ -260,7 +261,7 @@ static void state_insert(HashTab * hashtab, unsigned char *key, int state)
}
-@ assumes that key is not already present!
+@ assumes that key is not already present!
@c
static void hyppat_insert(HashTab * hashtab, unsigned char *key, char *hyppat)
@@ -357,25 +358,27 @@ static int hnj_get_state(HyphenDict * dict,
@ Add a transition from state1 to state2 through ch - assumes that the
- transition does not already exist
+ transition does not already exist
@c
static void hnj_add_trans(HyphenDict * dict, int state1, int state2, int uni_ch)
{
int num_trans;
/* TH: this test was a bit too strict, it is quite normal for old
- patterns to have chars in the range 0-31 or 127-159 (inclusive).
- To ease the transition, let's only disallow NUL for now
+ patterns to have chars in the range 0-31 or 127-159 (inclusive).
+ To ease the transition, let's only disallow NUL for now
(this is probably a requirement of the code anyway).
*/
if (uni_ch == 0) {
- fprintf(stderr, "Character out of bounds: u%04x \n", uni_ch);
- exit(1);
+ char errmsg[256]; /* temp hack ... we will have a formatted error */
+ snprintf(errmsg, 255, "character out of bounds: u%04x", uni_ch);
+ errmsg[255] = '\0';
+ normal_error("hyphenation",errmsg); /* todo */
}
num_trans = dict->states[state1].num_trans;
if (num_trans == 0) {
dict->states[state1].trans = hnj_malloc(sizeof(HyphenTrans));
- } else {
+ } else {
/* TH: The old version did
} else if (!(num_trans & (num_trans - 1))) {
... hnj_realloc(dict->states[state1].trans,
@@ -624,7 +627,7 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
char * index2 = strnchr(index + 1, ',',clen-(index-repl));
if (index2) {
replindex = (signed char) atoi(index + 1) - 1;
- replcut = (signed char) atoi(index2 + 1);
+ replcut = (signed char) atoi(index2 + 1);
}
} else {
hnj_strchomp(repl + 1);
@@ -692,8 +695,7 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
e1++;
neworg = malloc((size_t) (l1 + 2 - e1));
sprintf(neworg, "%0*d", l1 + 1 - e1, 0); /* fill with right amount of '0' */
- hyppat_insert(dict->merged, newword,
- combine(neworg, subpat_pat));
+ hyppat_insert(dict->merged, newword, combine(neworg, subpat_pat));
} else {
combine(newpat_pat, subpat_pat);
}
@@ -759,12 +761,12 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
#ifdef VERBOSE
for (i = 0; i < HASH_SIZE; i++) {
for (e = dict->state_num->entries[i]; e; e = e->next) {
- printf("%d string %s state %d, fallback=%d\n", i, e->key,
- e->u.state, dict->states[e->u.state].fallback_state);
+ printf("%d string %s state %d, fallback=%d\n",
+ i, e->key, e->u.state, dict->states[e->u.state].fallback_state);
for (j = 0; j < dict->states[e->u.state].num_trans; j++) {
printf(" u%4x->%d\n",
- (int) dict->states[e->u.state].trans[j].uni_ch,
- dict->states[e->u.state].trans[j].new_state);
+ (int) dict->states[e->u.state].trans[j].uni_ch,
+ dict->states[e->u.state].trans[j].new_state);
}
}
}
@@ -828,7 +830,7 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
*/
int offset = (int) (char_num + 2 - (int) strlen(match));
#if 0
- printf ("%*s%s\n", offset,"", match);
+ printf("%*s%s\n", offset,"", match);
#endif
int m;
for (m = 0; match[m]; m++) {
@@ -841,7 +843,7 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
}
state = hstate->fallback_state;
#if 0
- printf (" back to %d\n", state);
+ printf(" back to %d\n", state);
#endif
}
/* nothing worked, let's go to the next character */
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w
index 438cf794137..4e9282e5f3f 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.w
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w
@@ -488,7 +488,7 @@ static char *hyphenation_exception(int exceptions, char *w)
if (lua_istable(L, -1)) { /* ?? */
lua_pushstring(L, w); /* word table */
lua_rawget(L, -2);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
ret = xstrdup(lua_tostring(L, -1));
}
lua_pop(L, 2);
@@ -578,6 +578,11 @@ static const char *PAT_ERROR[] = {
NULL
};
+/*
+ The exceptions are taken as-is: no min values are taken into account. One can
+ add normal patterns on-the-fly if needed.
+*/
+
static void do_exception(halfword wordstart, halfword r, char *replacement)
{
unsigned i;
@@ -723,6 +728,7 @@ static halfword find_next_wordstart(halfword r)
halfword t ;
while (r != null) {
switch (type(r)) {
+ case boundary_node:
case whatsit_node:
break;
case glue_node:
@@ -785,18 +791,19 @@ static int valid_wordend(halfword s)
register int clang = char_lang(s);
if (r == null)
return 1;
- while ((r != null) && ((type(r) == glyph_node && is_simple_character(r)
- && clang == char_lang(r)) ||
- (type(r) == kern_node && (subtype(r) == normal))
+ while ((r != null) && ( (type(r) == glyph_node && is_simple_character(r) && clang == char_lang(r))
+ || (type(r) == kern_node && (subtype(r) == normal))
)) {
r = vlink(r);
}
- if (r == null || (type(r) == glyph_node && is_simple_character(r)
- && clang != char_lang(r)) || type(r) == glue_node
- || type(r) == whatsit_node || type(r) == ins_node
- || type(r) == adjust_node || type(r) == penalty_node
- || (type(r) == kern_node
- && (subtype(r) == explicit || subtype(r) == acc_kern)))
+ if (r == null || (type(r) == glyph_node && is_simple_character(r) && clang != char_lang(r))
+ || type(r) == glue_node
+ || type(r) == boundary_node
+ || type(r) == whatsit_node
+ || type(r) == ins_node
+ || type(r) == adjust_node
+ || type(r) == penalty_node
+ || (type(r) == kern_node && (subtype(r) == explicit || subtype(r) == acc_kern)))
return 1;
return 0;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
index 96eafa8a22a..dee8057bb7b 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
@@ -1,5 +1,5 @@
/* lcallbacklib.c
-
+
Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -20,15 +20,15 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
-
int callback_count = 0;
int saved_callback_count = 0;
int callback_set[total_callbacks] = { 0 };
/* See also callback_callback_type in luatexcallbackids.h: they must have the same order ! */
+
static const char *const callbacknames[] = {
- "", /* empty on purpose */
+ "", /* empty on purpose */
"find_write_file",
"find_output_file",
"find_image_file",
@@ -62,18 +62,20 @@ static const char *const callbacknames[] = {
"pre_linebreak_filter",
"linebreak_filter",
"post_linebreak_filter",
+ "append_to_vlist_filter",
"mlist_to_hlist",
"finish_pdffile",
"finish_pdfpage",
"pre_dump","start_file", "stop_file",
"show_error_message","show_lua_error_hook",
- "pdf_stream_filter_callback",
+ "show_warning_message",
+ "hpack_quality", "vpack_quality",
NULL
};
int callback_callbacks_id = 0;
-int debug_callback_defined(int i)
+int debug_callback_defined(int i)
{
printf ("callback_defined(%s)\n", callbacknames[i]);
return callback_set[i];
@@ -82,14 +84,16 @@ int debug_callback_defined(int i)
void get_lua_boolean(const char *table, const char *name, boolean * target)
{
int stacktop;
+ int t;
stacktop = lua_gettop(Luas);
luaL_checkstack(Luas, 2, "out of stack space");
lua_getglobal(Luas, table);
if (lua_istable(Luas, -1)) {
lua_getfield(Luas, -1, name);
- if (lua_isboolean(Luas, -1)) {
+ t = lua_type(Luas, -1);
+ if (t == LUA_TBOOLEAN) {
*target = (boolean) (lua_toboolean(Luas, -1));
- } else if (lua_isnumber(Luas, -1)) {
+ } else if (t == LUA_TNUMBER) {
*target = (boolean) (lua_tonumber(Luas, -1) == 0 ? 0 : 1);
}
}
@@ -100,14 +104,16 @@ void get_lua_boolean(const char *table, const char *name, boolean * target)
void get_saved_lua_boolean(int r, const char *name, boolean * target)
{
int stacktop;
+ int t;
stacktop = lua_gettop(Luas);
luaL_checkstack(Luas, 2, "out of stack space");
lua_rawgeti(Luas, LUA_REGISTRYINDEX, r);
if (lua_istable(Luas, -1)) {
lua_getfield(Luas, -1, name);
- if (lua_isboolean(Luas, -1)) {
+ t = lua_type(Luas, -1);
+ if (t == LUA_TBOOLEAN) {
*target = (boolean) lua_toboolean(Luas, -1);
- } else if (lua_isnumber(Luas, -1)) {
+ } else if (t == LUA_TNUMBER) {
*target = (boolean) (lua_tonumber(Luas, -1) == 0 ? 0 : 1);
}
}
@@ -123,7 +129,7 @@ void get_lua_number(const char *table, const char *name, int *target)
lua_getglobal(Luas, table);
if (lua_istable(Luas, -1)) {
lua_getfield(Luas, -1, name);
- if (lua_isnumber(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TNUMBER) {
*target = (int)lua_tonumber(Luas, -1);
}
}
@@ -139,7 +145,7 @@ void get_saved_lua_number(int r, const char *name, int *target)
lua_rawgeti(Luas, LUA_REGISTRYINDEX, r);
if (lua_istable(Luas, -1)) {
lua_getfield(Luas, -1, name);
- if (lua_isnumber(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TNUMBER) {
*target=(int)lua_tonumber(Luas, -1);
}
}
@@ -147,16 +153,15 @@ void get_saved_lua_number(int r, const char *name, int *target)
return;
}
-
void get_lua_string(const char *table, const char *name, char **target)
{
int stacktop;
stacktop = lua_gettop(Luas);
luaL_checkstack(Luas, 2, "out of stack space");
lua_getglobal(Luas, table);
- if (lua_istable(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TTABLE) {
lua_getfield(Luas, -1, name);
- if (lua_isstring(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TSTRING) {
*target = xstrdup(lua_tostring(Luas, -1));
}
}
@@ -170,9 +175,9 @@ void get_saved_lua_string(int r, const char *name, char **target)
stacktop = lua_gettop(Luas);
luaL_checkstack(Luas, 2, "out of stack space");
lua_rawgeti(Luas, LUA_REGISTRYINDEX, r);
- if (lua_istable(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TTABLE) {
lua_getfield(Luas, -1, name);
- if (lua_isstring(Luas, -1)) {
+ if (lua_type(Luas, -1) == LUA_TSTRING) {
*target = xstrdup(lua_tostring(Luas, -1));
}
}
@@ -180,7 +185,6 @@ void get_saved_lua_string(int r, const char *name, char **target)
return;
}
-
#define CALLBACK_BOOLEAN 'b'
#define CALLBACK_INTEGER 'd'
#define CALLBACK_LINE 'l'
@@ -188,7 +192,8 @@ void get_saved_lua_string(int r, const char *name, char **target)
#define CALLBACK_STRING 'S'
#define CALLBACK_CHARNUM 'c'
#define CALLBACK_LSTRING 'L'
-
+#define CALLBACK_NODE 'N'
+#define CALLBACK_DIR 'D'
int run_saved_callback(int r, const char *name, const char *values, ...)
{
@@ -211,7 +216,6 @@ int run_saved_callback(int r, const char *name, const char *values, ...)
return ret;
}
-
boolean get_callback(lua_State * L, int i)
{
luaL_checkstack(L, 2, "out of stack space");
@@ -243,7 +247,6 @@ int run_and_save_callback(int i, const char *values, ...)
return ret;
}
-
int run_callback(int i, const char *values, ...)
{
va_list args;
@@ -304,8 +307,13 @@ int do_run_callback(int special, const char *values, va_list vl)
lua_pushboolean(L, va_arg(vl, int));
break;
case CALLBACK_LINE: /* a buffer section, with implied start */
- lua_pushlstring(L, (char *) (buffer + first),
- (size_t) va_arg(vl, int));
+ lua_pushlstring(L, (char *) (buffer + first), (size_t) va_arg(vl, int));
+ break;
+ case CALLBACK_NODE:
+ lua_nodelib_push_fast(L,va_arg(vl, int));
+ break;
+ case CALLBACK_DIR:
+ lua_push_dir_par(L,va_arg(vl, int));
break;
case '-':
narg--;
@@ -331,8 +339,8 @@ int do_run_callback(int special, const char *values, va_list vl)
lua_active--;
/* lua_remove(L, base); *//* remove traceback function */
if (i != 0) {
- /* Can't be more precise here, could be called before
- * TeX initialization is complete
+ /* Can't be more precise here, could be called before
+ * TeX initialization is complete
*/
if (!log_opened_global) {
fprintf(stderr, "This went wrong: %s\n", lua_tostring(L, -1));
@@ -349,37 +357,38 @@ int do_run_callback(int special, const char *values, va_list vl)
}
nres = -nres;
while (*values) {
- int b;
+ int b, t;
+ halfword p;
switch (*values++) {
case CALLBACK_BOOLEAN:
- if (!lua_isboolean(L, nres)) {
- fprintf(stderr, "Expected a boolean, not: %s\n",
- lua_typename(L, lua_type(L, nres)));
+ if (lua_type(L, nres) != LUA_TBOOLEAN) {
+ fprintf(stderr, "Expected a boolean, not: %s\n", lua_typename(L, lua_type(L, nres)));
goto EXIT;
}
b = lua_toboolean(L, nres);
*va_arg(vl, boolean *) = (boolean) b;
break;
case CALLBACK_INTEGER:
- if (!lua_isnumber(L, nres)) {
- fprintf(stderr, "Expected a number, not: %s\n",
- lua_typename(L, lua_type(L, nres)));
+ if (lua_type(L, nres) != LUA_TNUMBER) {
+ fprintf(stderr, "Expected a number, not: %s\n", lua_typename(L, lua_type(L, nres)));
goto EXIT;
}
- b=(int)lua_tonumber(L, nres);
+ b = (int) lua_tonumber(L, nres);
*va_arg(vl, int *) = b;
break;
- case CALLBACK_LINE: /* TeX line */
- if (!lua_isstring(L, nres)) {
- if (!lua_isnil(L, nres))
- fprintf(stderr, "Expected a string for (l), not: %s\n",
- lua_typename(L, lua_type(L, nres)));
+ case CALLBACK_LINE: /* TeX line ... happens frequently when we have a plug-in */
+ t = lua_type(L, nres);
+ if (t == LUA_TNIL) {
+ bufloc = 0;
goto EXIT;
- }
- s = lua_tolstring(L, nres, &len);
- if (s != NULL) { /* |len| can be zero */
- bufloc = va_arg(vl, int *);
- if (len != 0) {
+ } else if (t == LUA_TSTRING) {
+ s = lua_tolstring(L, nres, &len);
+ if (s == NULL) { /* |len| can be zero */
+ bufloc = 0;
+ } else if (len == 0) {
+ bufloc = 0;
+ } else {
+ bufloc = va_arg(vl, int *);
ret = *bufloc;
check_buffer_overflow(ret + (int) len);
strncpy((char *) (buffer + ret), s, len);
@@ -389,16 +398,14 @@ int do_run_callback(int special, const char *values, va_list vl)
(*bufloc)--;
}
} else {
- bufloc = 0;
+ fprintf(stderr, "Expected a string for (l), not: %s\n", lua_typename(L, lua_type(L, nres)));
+ goto EXIT;
}
break;
case CALLBACK_STRNUMBER: /* TeX string */
- if (!lua_isstring(L, nres)) {
- if (!lua_isnil(L, nres)) {
- fprintf(stderr, "Expected a string for (s), not: %s\n",
- lua_typename(L, lua_type(L, nres)));
- goto EXIT;
- }
+ if (lua_type(L, nres) != LUA_TSTRING) {
+ fprintf(stderr, "Expected a string for (s), not: %s\n", lua_typename(L, lua_type(L, nres)));
+ goto EXIT;
}
s = lua_tolstring(L, nres, &len);
if (s == NULL) /* |len| can be zero */
@@ -408,15 +415,11 @@ int do_run_callback(int special, const char *values, va_list vl)
}
break;
case CALLBACK_STRING: /* C string aka buffer */
- if (!lua_isstring(L, nres)) {
- if (!lua_isnil(L, nres)) {
- fprintf(stderr, "Expected a string for (S), not: %s\n",
- lua_typename(L, lua_type(L, nres)));
- goto EXIT;
- }
+ if (lua_type(L, nres) != LUA_TSTRING) {
+ fprintf(stderr, "Expected a string for (S), not: %s\n", lua_typename(L, lua_type(L, nres)));
+ goto EXIT;
}
s = lua_tolstring(L, nres, &len);
-
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
@@ -426,25 +429,29 @@ int do_run_callback(int special, const char *values, va_list vl)
}
break;
case CALLBACK_LSTRING: /* lstring */
- if (!lua_isstring(L, nres)) {
- if (!lua_isnil(L, nres)) {
- fprintf(stderr, "Expected a string for (S), not: %s\n",
- lua_typename(L, lua_type(L, nres)));
- goto EXIT;
- }
+ if (lua_type(L, nres) != LUA_TSTRING) {
+ fprintf(stderr, "Expected a string for (S), not: %s\n", lua_typename(L, lua_type(L, nres)));
+ goto EXIT;
}
s = lua_tolstring(L, nres, &len);
-
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
- lstring *ret = xmalloc(sizeof(lstring));
+ lstring *ret = xmalloc(sizeof(lstring));
ret->s = xmalloc((unsigned) (len + 1));
(void) memcpy(ret->s, s, (len + 1));
- ret->l = len;
+ ret->l = len;
*va_arg(vl, lstring **) = ret;
}
break;
+ case CALLBACK_NODE:
+ if (lua_type(L,nres) == LUA_TNIL) {
+ p = null;
+ } else {
+ p = *check_isnode(L,nres);
+ }
+ *va_arg(vl, int *) = p;
+ break;
default:
fprintf(stdout, "invalid return value type");
goto EXIT;
@@ -465,10 +472,15 @@ static int callback_register(lua_State * L)
{
int cb;
const char *s;
- if (!lua_isstring(L, 1) ||
- ((!lua_isfunction(L, 2)) &&
- (!lua_isnil(L, 2)) &&
- (!(lua_isboolean(L, 2) && lua_toboolean(L, 2) == 0)))) {
+ int t1, t2;
+ t1 = lua_type(L,1);
+ if (t1 != LUA_TSTRING) {
+ lua_pushnil(L);
+ lua_pushstring(L, "Invalid arguments to callback.register, first argument must be string.");
+ return 2;
+ }
+ t2 = lua_type(L,2);
+ if ((t2 != LUA_TFUNCTION) && (t2 != LUA_TNIL) && ((t2 != LUA_TBOOLEAN) && (lua_toboolean(L, 2) == 0))) {
lua_pushnil(L);
lua_pushstring(L, "Invalid arguments to callback.register.");
return 2;
@@ -483,9 +495,9 @@ static int callback_register(lua_State * L)
lua_pushstring(L, "No such callback exists.");
return 2;
}
- if (lua_isfunction(L, 2)) {
+ if (t2 == LUA_TFUNCTION) {
callback_set[cb] = cb;
- } else if (lua_isboolean(L, 2)) {
+ } else if (t2 == LUA_TBOOLEAN) {
callback_set[cb] = -1;
} else {
callback_set[cb] = 0;
@@ -503,7 +515,7 @@ static int callback_find(lua_State * L)
{
int cb;
const char *s;
- if (!lua_isstring(L, 1)) {
+ if (lua_type(L, 1) != LUA_TSTRING) {
lua_pushnil(L);
lua_pushstring(L, "Invalid arguments to callback.find.");
return 2;
@@ -524,7 +536,6 @@ static int callback_find(lua_State * L)
return 1;
}
-
static int callback_listf(lua_State * L)
{
int i;
diff --git a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
index d6d52ae68fd..fa40150370c 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
@@ -41,9 +41,9 @@ static int font_read_tfm(lua_State * L)
scaled s;
int k;
const char *cnom;
- if (lua_isstring(L, 1)) {
+ if (lua_type(L, 1) == LUA_TSTRING) {
cnom = lua_tostring(L, 1);
- if (lua_isnumber(L, 2)) {
+ if (lua_type(L, 2) == LUA_TNUMBER) {
s = (int) lua_tonumber(L, 2);
if (strlen(cnom)) {
f = get_fontid();
@@ -72,10 +72,10 @@ static int font_read_vf(lua_State * L)
{
int i;
const char *cnom;
- if (lua_isstring(L, 1)) {
+ if (lua_type(L, 1) == LUA_TSTRING) {
cnom = lua_tostring(L, 1);
if (strlen(cnom)) {
- if (lua_isnumber(L, 2)) {
+ if (lua_type(L, 2) == LUA_TNUMBER) {
i = (int) lua_tonumber(L, 2);
return make_vf_table(L, cnom, (scaled) i);
} else {
@@ -296,7 +296,7 @@ static int l_vf_char(lua_State * L)
internal_font_number lf = vsp->lf;
int ex_glyph = vsp->ex_glyph/1000;
if (!vsp->vflua)
- pdf_error("vf", "vf.char() outside virtual font");
+ normal_error("vf", "vf.char() outside virtual font");
k = (int) luaL_checkinteger(L, 1);
if (!char_exists(lf, (int) k)) {
char_warning(lf, (int) k);
@@ -319,7 +319,7 @@ static int l_vf_down(lua_State * L)
vf_struct *vsp = static_pdf->vfstruct;
packet_stack_record *mat_p;
if (!vsp->vflua)
- pdf_error("vf", "vf.down() outside virtual font");
+ normal_error("vf", "vf.down() outside virtual font");
i = (scaled) luaL_checkinteger(L, 1);
i = store_scaled_f(i, vsp->fs_f);
mat_p = &(vsp->packet_stack[vsp->packet_stack_level]);
@@ -332,7 +332,7 @@ static int l_vf_fontid(lua_State * L)
{
vf_struct *vsp = static_pdf->vfstruct;
if (!vsp->vflua)
- pdf_error("vf", "vf.fontid() outside virtual font");
+ normal_error("vf", "vf.fontid() outside virtual font");
vsp->lf = (int) luaL_checkinteger(L, 1);
return 0;
}
@@ -342,7 +342,7 @@ static int l_vf_image(lua_State * L)
int k;
vf_struct *vsp = static_pdf->vfstruct;
if (!vsp->vflua)
- pdf_error("vf", "vf.image() outside virtual font");
+ normal_error("vf", "vf.image() outside virtual font");
k = (int) luaL_checkinteger(L, 1);
vf_out_image(static_pdf, k);
return 0;
@@ -353,7 +353,7 @@ static int l_vf_node(lua_State * L)
int k;
vf_struct *vsp = static_pdf->vfstruct;
if (!vsp->vflua)
- pdf_error("vf", "vf.node() outside virtual font");
+ normal_error("vf", "vf.node() outside virtual font");
k = (int) luaL_checkinteger(L, 1);
hlist_out(static_pdf, (halfword) k);
return 0;
@@ -363,7 +363,7 @@ static int l_vf_nop(lua_State * L)
{
vf_struct *vsp = static_pdf->vfstruct;
if (!vsp->vflua)
- pdf_error("vf", "vf.nop() outside virtual font");
+ normal_error("vf", "vf.nop() outside virtual font");
return 0;
}
@@ -372,9 +372,9 @@ static int l_vf_pop(lua_State * L)
vf_struct *vsp = static_pdf->vfstruct;
packet_stack_record *mat_p;
if (!vsp->vflua)
- pdf_error("vf", "vf.pop() outside virtual font");
+ normal_error("vf", "vf.pop() outside virtual font");
if (vsp->packet_stack_level == vsp->packet_stack_minlevel)
- pdf_error("vf", "packet_stack_level underflow");
+ normal_error("vf", "packet_stack_level underflow");
vsp->packet_stack_level--;
mat_p = &(vsp->packet_stack[vsp->packet_stack_level]);
synch_pos_with_cur(static_pdf->posstruct, vsp->refpos, mat_p->pos);
@@ -386,11 +386,11 @@ static int l_vf_push(lua_State * L)
vf_struct *vsp = static_pdf->vfstruct;
packet_stack_record *mat_p;
if (!vsp->vflua)
- pdf_error("vf", "vf.push() outside virtual font");
+ normal_error("vf", "vf.push() outside virtual font");
mat_p = &(vsp->packet_stack[vsp->packet_stack_level]);
vsp->packet_stack_level++;
if (vsp->packet_stack_level == packet_stack_size)
- pdf_error("vf", "packet_stack_level overflow");
+ normal_error("vf", "packet_stack_level overflow");
vsp->packet_stack[vsp->packet_stack_level] = *mat_p;
mat_p = &(vsp->packet_stack[vsp->packet_stack_level]);
return 0;
@@ -402,7 +402,7 @@ static int l_vf_right(lua_State * L)
vf_struct *vsp = static_pdf->vfstruct;
packet_stack_record *mat_p;
if (!vsp->vflua)
- pdf_error("vf", "vf.right() outside virtual font");
+ normal_error("vf", "vf.right() outside virtual font");
mat_p = &(vsp->packet_stack[vsp->packet_stack_level]);
i = (scaled) luaL_checkinteger(L, 1);
i = store_scaled_f(i, vsp->fs_f);
@@ -417,7 +417,7 @@ static int l_vf_rule(lua_State * L)
vf_struct *vsp = static_pdf->vfstruct;
packet_stack_record *mat_p;
if (!vsp->vflua)
- pdf_error("vf", "vf.rule() outside virtual font");
+ normal_error("vf", "vf.rule() outside virtual font");
size.h = (scaled) luaL_checkinteger(L, 1);
size.v = (scaled) luaL_checkinteger(L, 2);
size.h = store_scaled_f(size.h, vsp->fs_f);
@@ -436,7 +436,7 @@ static int l_vf_special(lua_State * L)
int texstr;
vf_struct *vsp = static_pdf->vfstruct;
if (!vsp->vflua)
- pdf_error("vf", "vf.special() outside virtual font");
+ normal_error("vf", "vf.special() outside virtual font");
st.s = lua_tolstring(L, 1, &(st.l));
texstr = maketexlstring(st.s, st.l);
pdf_literal(static_pdf, texstr, scan_special, false);
diff --git a/Build/source/texk/web2c/luatexdir/lua/limglib.c b/Build/source/texk/web2c/luatexdir/lua/limglib.c
index 127faede0c7..1feb540e4c8 100644
--- a/Build/source/texk/web2c/luatexdir/lua/limglib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/limglib.c
@@ -1,5 +1,5 @@
/* limglib.c
-
+
Copyright 2006-2013 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -95,12 +95,30 @@ static const parm_struct img_parms[] = {
};
#define imgtype_max 7
-const char *imgtype_s[] =
- { "none", "pdf", "png", "jpg", "jp2", "jbig2", "stream", "memstream",NULL };
+
+const char *imgtype_s[] = {
+ "none",
+ "pdf",
+ "png",
+ "jpg",
+ "jp2",
+ "jbig2",
+ "stream",
+ "memstream",
+ NULL
+};
#define pagebox_max 5
-const char *pdfboxspec_s[] =
- { "none", "media", "crop", "bleed", "trim", "art", NULL };
+
+const char *pdfboxspec_s[] = {
+ "none",
+ "media",
+ "crop",
+ "bleed",
+ "trim",
+ "art",
+ NULL
+};
/**********************************************************************/
@@ -113,9 +131,8 @@ static void image_to_lua(lua_State * L, image * a)
lua_gettable(L, LUA_REGISTRYINDEX); /* t k u ... */
lua_pushvalue(L, -2); /* k t k u ... */
lua_gettable(L, -2); /* i? t k u ... */
- if (!lua_isnumber(L, -1)) /* !i t k u ... */
- luaL_error(L, "image_to_lua(): %s is not a valid image key",
- lua_tostring(L, -3));
+ if (lua_type(L, -1) != LUA_TNUMBER) /* !i t k u ... */
+ luaL_error(L, "image_to_lua(): %s is not a valid image key", lua_tostring(L, -3));
i = (int) lua_tointeger(L, -1); /* i t k u ... */
lua_pop(L, 3); /* u ... */
switch (i) {
@@ -283,9 +300,8 @@ static void lua_to_image(lua_State * L, image * a)
lua_gettable(L, LUA_REGISTRYINDEX); /* t v k t ... */
lua_pushvalue(L, -3); /* k t v k t ... */
lua_gettable(L, -2); /* i? t v k t ... */
- if (!lua_isnumber(L, -1)) /* !i t v k t ... */
- luaL_error(L, "lua_to_image(): %s is not a valid image key",
- lua_tostring(L, -4));
+ if (lua_type(L, -1) != LUA_TNUMBER) /* !i t v k t ... */
+ luaL_error(L, "lua_to_image(): %s is not a valid image key", lua_tostring(L, -4));
i = (int) lua_tointeger(L, -1); /* i t v k t ... */
lua_pop(L, 2); /* v k t ... */
switch (i) {
@@ -297,8 +313,7 @@ static void lua_to_image(lua_State * L, image * a)
else if (lua_type(L, -1) == LUA_TSTRING)
img_width(a) = dimen_to_number(L, lua_tostring(L, -1));
else
- luaL_error(L,
- "image.width needs integer or nil value or dimension string");
+ luaL_error(L, "image.width needs integer or nil value or dimension string");
break;
case P_HEIGHT:
if (lua_isnil(L, -1))
@@ -308,8 +323,7 @@ static void lua_to_image(lua_State * L, image * a)
else if (lua_type(L, -1) == LUA_TSTRING)
img_height(a) = dimen_to_number(L, lua_tostring(L, -1));
else
- luaL_error(L,
- "image.height needs integer or nil value or dimension string");
+ luaL_error(L, "image.height needs integer or nil value or dimension string");
break;
case P_DEPTH:
if (lua_isnil(L, -1))
@@ -319,11 +333,10 @@ static void lua_to_image(lua_State * L, image * a)
else if (lua_type(L, -1) == LUA_TSTRING)
img_depth(a) = dimen_to_number(L, lua_tostring(L, -1));
else
- luaL_error(L,
- "image.depth needs integer or nil value or dimension string");
+ luaL_error(L, "image.depth needs integer or nil value or dimension string");
break;
case P_TRANSFORM:
- if (lua_isnumber(L, -1))
+ if (lua_type(L, -1) == LUA_TNUMBER)
img_transform(a) = (int) lua_tointeger(L, -1);
else
luaL_error(L, "image.transform needs integer value");
@@ -334,7 +347,7 @@ static void lua_to_image(lua_State * L, image * a)
luaL_error(L, "image.filename is now read-only");
if (img_type(d) == IMG_TYPE_PDFSTREAM)
luaL_error(L, "image.filename can't be used with image.stream");
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
xfree(img_filename(d));
img_filename(d) = xstrdup(lua_tostring(L, -1));
} else
@@ -344,9 +357,8 @@ static void lua_to_image(lua_State * L, image * a)
if (img_state(d) >= DICT_FILESCANNED)
luaL_error(L, "image.visiblefilename is now read-only");
if (img_type(d) == IMG_TYPE_PDFSTREAM)
- luaL_error(L,
- "image.visiblefilename can't be used with image.stream");
- if (lua_isstring(L, -1)) {
+ luaL_error(L, "image.visiblefilename can't be used with image.stream");
+ if (lua_type(L, -1) == LUA_TSTRING) {
xfree(img_visiblefilename(d));
img_visiblefilename(d) = xstrdup(lua_tostring(L, -1));
} else
@@ -355,10 +367,11 @@ static void lua_to_image(lua_State * L, image * a)
case P_ATTR:
if (img_state(d) >= DICT_FILESCANNED)
luaL_error(L, "image.attr is now read-only");
- if (lua_isstring(L, -1) || lua_isnil(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
+ xfree(img_attr(d));
+ img_attr(d) = xstrdup(lua_tostring(L, -1));
+ } else if (lua_type(L, -1) == LUA_TNIL) {
xfree(img_attr(d));
- if (lua_isstring(L, -1))
- img_attr(d) = xstrdup(lua_tostring(L, -1));
} else
luaL_error(L, "image.attr needs string or nil value");
break;
@@ -380,7 +393,7 @@ static void lua_to_image(lua_State * L, image * a)
luaL_error(L, "image.colorspace is now read-only");
if (lua_isnil(L, -1))
img_colorspace(d) = 0;
- else if (lua_isnumber(L, -1))
+ else if (lua_type(L, -1) == LUA_TNUMBER)
img_colorspace(d) = (int) lua_tointeger(L, -1);
else
luaL_error(L, "image.colorspace needs integer or nil value");
@@ -388,9 +401,9 @@ static void lua_to_image(lua_State * L, image * a)
case P_PAGEBOX:
if (img_state(d) >= DICT_FILESCANNED)
luaL_error(L, "image.pagebox is now read-only");
- if (lua_isnil(L, -1))
+ if (lua_type(L, -1) == LUA_TNIL)
img_pagebox(d) = PDF_BOX_SPEC_NONE;
- else if (lua_isstring(L, -1))
+ else if (lua_type(L, -1) == LUA_TSTRING)
img_pagebox(d) = luaL_checkoption(L, -1, "none", pdfboxspec_s);
else
luaL_error(L, "image.pagebox needs string or nil value");
@@ -410,8 +423,7 @@ static void lua_to_image(lua_State * L, image * a)
else if (lua_type(L, -1) == LUA_TSTRING)
img_bbox(d)[i - 1] = dimen_to_number(L, lua_tostring(L, -1));
else
- luaL_error(L,
- "image.bbox table needs integer value or dimension string elements");
+ luaL_error(L, "image.bbox table needs integer value or dimension string elements");
lua_pop(L, 1); /* v k t ... */
}
img_set_bbox(d);
@@ -558,18 +570,25 @@ static halfword img_to_node(image * a)
ad = img_dict(a);
assert(ad != NULL);
assert(img_objnum(ad) != 0);
- n = new_node(whatsit_node, pdf_refximage_node);
- pdf_ximage_index(n) = img_index(ad);
+ n = new_rule(image_rule);
+ rule_index(n) = img_index(ad);
width(n) = img_width(a);
height(n) = img_height(a);
depth(n) = img_depth(a);
- pdf_ximage_transform(n) = img_transform(a);
+ rule_transform(n) = img_transform(a);
return n;
}
-typedef enum { WR_WRITE, WR_IMMEDIATEWRITE, WR_NODE, WR_VF_IMG } wrtype_e;
-const char *wrtype_s[] =
- { "img.write()", "img.immediatewrite()", "img.node()", "write vf image" };
+typedef enum {
+ WR_WRITE,
+ WR_IMMEDIATEWRITE,
+ WR_NODE,
+ WR_VF_IMG
+} wrtype_e;
+
+const char *wrtype_s[] = {
+ "img.write()", "img.immediatewrite()", "img.node()", "write vf image"
+};
static void setup_image(PDF pdf, image * a, wrtype_e writetype)
{
@@ -737,10 +756,10 @@ static int m_img_set(lua_State * L)
static int m_img_mul(lua_State * L)
{
lua_Number scale;
- if (lua_isnumber(L, 1)) { /* u? n */
+ if (lua_type(L, 1) == LUA_TNUMBER) { /* u? n */
(void) luaL_checkudata(L, 2, TYPE_IMG); /* u n */
lua_insert(L, -2); /* n a */
- } else if (lua_isnumber(L, 2)) { /* n u? */
+ } else if (lua_type(L, 2) != LUA_TNUMBER) { /* n u? */
(void) luaL_checkudata(L, 1, TYPE_IMG); /* n a */
} /* n a */
scale = lua_tonumber(L, 2); /* n a */
@@ -756,11 +775,9 @@ static int m_img_print(lua_State * L)
aa = (image **) luaL_checkudata(L, 1, TYPE_IMG);
d = img_dict(*aa);
if (img_pagename(d) != NULL && strlen(img_pagename(d)) != 0)
- lua_pushfstring(L, "<img{filename=\"%s\", page=\"%s\"}>",
- img_filename(d), img_pagename(d));
+ lua_pushfstring(L, "<img{filename=\"%s\", page=\"%s\"}>", img_filename(d), img_pagename(d));
else
- lua_pushfstring(L, "<img{filename=\"%s\", page=%d}>", img_filename(d),
- img_pagenum(d));
+ lua_pushfstring(L, "<img{filename=\"%s\", page=%d}>", img_filename(d), img_pagenum(d));
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/lkpselib.c b/Build/source/texk/web2c/luatexdir/lua/lkpselib.c
index d53c50426e4..d2fadcbfc26 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lkpselib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lkpselib.c
@@ -1,5 +1,5 @@
/* lkpselib.c
-
+
Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -184,24 +184,27 @@ int program_name_set = 0;
static int find_file(lua_State * L)
{
- int i;
+ int i, t;
const char *st;
unsigned ftype = kpse_tex_format;
int mexist = 0;
TEST_PROGRAM_NAME_SET;
- if (!lua_isstring(L, 1)) {
+ if (lua_type(L, 1) != LUA_TSTRING) {
luaL_error(L, "not a file name");
}
st = lua_tostring(L, 1);
i = lua_gettop(L);
while (i > 1) {
- if (lua_isboolean(L, i)) {
+ t = lua_type(L, i) ;
+ if (t == LUA_TBOOLEAN) {
mexist = lua_toboolean(L, i);
- } else if (lua_isnumber(L, i)) {
+ } else if (t == LUA_TNUMBER) {
mexist=(int)lua_tonumber(L, i);
- } else if (lua_isstring(L, i)) {
+ } else if (t == LUA_TSTRING) {
int op = luaL_checkoption(L, i, NULL, filetypenames);
ftype = filetypes[op];
+ } else {
+ /* ignore */
}
i--;
}
@@ -223,30 +226,30 @@ static int find_file(lua_State * L)
static int lua_kpathsea_find_file(lua_State * L)
{
- int i;
+ int i, t;
unsigned ftype = kpse_tex_format;
int mexist = 0;
kpathsea *kp = (kpathsea *) luaL_checkudata(L, 1, KPATHSEA_METATABLE);
const char *st = luaL_checkstring(L, 2);
i = lua_gettop(L);
while (i > 2) {
- if (lua_isboolean(L, i)) {
+ t = lua_type(L, i) ;
+ if (t == LUA_TBOOLEAN) {
mexist = (boolean) lua_toboolean(L, i);
- } else if (lua_isnumber(L, i)) {
+ } else if (t == LUA_TNUMBER) {
mexist=(int)lua_tonumber(L, i);
- } else if (lua_isstring(L, i)) {
+ } else if (t == LUA_TSTRING) {
int op = luaL_checkoption(L, i, NULL, filetypenames);
ftype = filetypes[op];
+ } else {
+ /* ignore */
}
i--;
}
- if (ftype == kpse_pk_format ||
- ftype == kpse_gf_format || ftype == kpse_any_glyph_format) {
+ if (ftype == kpse_pk_format || ftype == kpse_gf_format || ftype == kpse_any_glyph_format) {
/* ret.format, ret.name, ret.dpi */
kpse_glyph_file_type ret;
- lua_pushstring(L,
- kpathsea_find_glyph(*kp, st, (unsigned) mexist, ftype,
- &ret));
+ lua_pushstring(L, kpathsea_find_glyph(*kp, st, (unsigned) mexist, ftype, &ret));
} else {
if (mexist > 0)
mexist = 1;
@@ -368,7 +371,7 @@ static unsigned find_dpi(const_string s)
is, for a string S in MATCHES, its dirname must end with one of the
elements in SUBDIRS. For instance, if subdir=foo/bar, that will
match a string foo/bar/baz or /some/texmf/foo/bar/baz.
-
+
We don't reallocate the actual strings, just the list elements.
Perhaps later we will implement wildcards or // or something. */
@@ -599,17 +602,17 @@ static int do_lua_kpathsea_lookup(lua_State * L, kpathsea kpse, int idx)
if (lua_istable(L, -1)) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) { /* numeric value */
- if (lua_isstring(L, -1)) {
- char *s = xstrdup(lua_tostring(L, -1));
+ if (lua_type(L, -1) == LUA_TSTRING) {
+ char *s = xstrdup(lua_tostring(L, -1));
str_list_add(&subdir_paths, s);
- xfree(s);
+ xfree(s);
}
lua_pop(L, 1);
}
- } else if (lua_isstring(L, -1)) {
- char *s = xstrdup(lua_tostring(L, -1));
+ } else if (lua_type(L, -1) == LUA_TSTRING) {
+ char *s = xstrdup(lua_tostring(L, -1));
str_list_add(&subdir_paths, s);
- xfree(s);
+ xfree(s);
}
lua_pop(L, 1);
if (STR_LIST_LENGTH(subdir_paths) > 0) {
diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
index 616c0713a18..645780ca1c7 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
@@ -62,7 +62,7 @@ static int lang_patterns(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isstring(L, 2)) {
+ if (lua_type(L, 2) != LUA_TSTRING) {
return luaL_error(L, "lang.patterns(): argument should be a string");
}
load_patterns(*lang_ptr, (const unsigned char *) lua_tostring(L, 2));
@@ -91,7 +91,7 @@ static int lang_hyphenation(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isstring(L, 2)) {
+ if (lua_type(L, 2) != LUA_TSTRING) {
return luaL_error(L,
"lang.hyphenation(): argument should be a string");
}
@@ -112,9 +112,8 @@ static int lang_pre_hyphen_char(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isnumber(L, 2)) {
- return luaL_error(L,
- "lang.prehyphenchar(): argument should be a character number");
+ if (lua_type(L, 2) != LUA_TNUMBER) {
+ return luaL_error(L, "lang.prehyphenchar(): argument should be a character number");
}
(*lang_ptr)->pre_hyphen_char=(int)lua_tonumber(L, 2);
return 0;
@@ -129,9 +128,8 @@ static int lang_post_hyphen_char(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isnumber(L, 2)) {
- return luaL_error(L,
- "lang.posthyphenchar(): argument should be a character number");
+ if (lua_type(L, 2) != LUA_TNUMBER) {
+ return luaL_error(L, "lang.posthyphenchar(): argument should be a character number");
}
(*lang_ptr)->post_hyphen_char=(int)lua_tonumber(L, 2);
return 0;
@@ -147,9 +145,8 @@ static int lang_pre_exhyphen_char(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isnumber(L, 2)) {
- return luaL_error(L,
- "lang.preexhyphenchar(): argument should be a character number");
+ if (lua_type(L, 2) != LUA_TNUMBER) {
+ return luaL_error(L, "lang.preexhyphenchar(): argument should be a character number");
}
(*lang_ptr)->pre_exhyphen_char=(int)lua_tonumber(L, 2);
return 0;
@@ -164,9 +161,8 @@ static int lang_post_exhyphen_char(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isnumber(L, 2)) {
- return luaL_error(L,
- "lang.postexhyphenchar(): argument should be a character number");
+ if (lua_type(L, 2) != LUA_TNUMBER) {
+ return luaL_error(L, "lang.postexhyphenchar(): argument should be a character number");
}
(*lang_ptr)->post_exhyphen_char=(int)lua_tonumber(L, 2);
return 0;
@@ -182,9 +178,8 @@ static int lang_hyphenation_min(lua_State * L)
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
if (lua_gettop(L) != 1) {
- if (!lua_isnumber(L, 2)) {
- return luaL_error(L,
- "lang.hyphenationmin(): argument should be a number");
+ if (lua_type(L, 2) != LUA_TNUMBER) {
+ return luaL_error(L, "lang.hyphenationmin(): argument should be a number");
}
(*lang_ptr)->hyphenation_min=(int)lua_tonumber(L, 2);
return 0;
@@ -206,8 +201,8 @@ static int lang_clear_hyphenation(lua_State * L)
static int do_lang_clean(lua_State * L)
{
char *cleaned;
- if (!lua_isstring(L, 1)) {
- return luaL_error(L, "lang.clean(): argument should be a string");
+ if (lua_type(L, 1) != LUA_TSTRING) {
+ return luaL_error(L, "lang.clean(): argument should be a string");
}
(void) clean_hyphenation(lua_tostring(L, 1), &cleaned);
lua_pushstring(L, cleaned);
diff --git a/Build/source/texk/web2c/luatexdir/lua/llualib.c b/Build/source/texk/web2c/luatexdir/lua/llualib.c
index 23bec6bfc0a..a8760674911 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llualib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llualib.c
@@ -1,5 +1,5 @@
/* llualib.c
-
+
Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -90,7 +90,7 @@ void undump_luac_registers(void)
if (luabytecode_max >= 0) {
i = (unsigned) (luabytecode_max + 1);
if ((int) (UINT_MAX32 / (int) sizeof(bytecode) + 1) <= i) {
- lua_fatal_error("Corrupt format file");
+ fatal_error("Corrupt format file");
}
lua_bytecode_registers = xmalloc((unsigned) (i * sizeof(bytecode)));
luabytecode_bytes = (unsigned) (i * sizeof(bytecode));
@@ -278,7 +278,7 @@ static int set_luaname(lua_State * L)
free(luanames[k]);
luanames[k] = NULL;
}
- if (lua_isstring(L, 3)) {
+ if (lua_type(L,3) == LUA_TSTRING) {
s = lua_tostring(L, 3);
if (s != NULL)
luanames[k] = xstrdup(s);
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
index df7bebf9c67..68bd21199b5 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
@@ -64,7 +64,7 @@ typedef struct saved_tex_scanner {
static lua_token *check_istoken(lua_State * L, int ud);
-#define TOKEN_METATABLE "luatex_newtoken"
+#define TOKEN_METATABLE "luatex_token"
#define DEBUG 0
#define DEBUG_OUT stdout
@@ -95,7 +95,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_newtoken));
+ lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token));
lua_gettable(L, LUA_REGISTRYINDEX);
if (!lua_rawequal(L, -1, -2))
p = NULL;
@@ -126,7 +126,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_newtoken));
+ lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token));
lua_gettable(L, LUA_REGISTRYINDEX);
lua_setmetatable(L, -2);
}
@@ -136,7 +136,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_newtoken));
+ lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_token));
lua_gettable(L, LUA_REGISTRYINDEX);
lua_setmetatable(L, -2);
}
@@ -151,7 +151,7 @@ static void push_token(lua_State * L, int tok)
/* static int run_get_command_id(lua_State * L) */
/* { */
/* int cs = -1; */
-/* if (lua_isstring(L, -1)) { */
+/* if (lua_type(L, -1) == LUA_TSTRING) { */
/* cs = get_command_id(lua_tostring(L, -1)); */
/* } */
/* lua_pushnumber(L, cs); */
@@ -162,7 +162,7 @@ static void push_token(lua_State * L, int tok)
/* { */
/* const char *s; */
/* size_t k, cs = 0; */
-/* if (lua_isstring(L, -1)) { */
+/* if (lua_type(L, -1) == LUA_TSTRING) { */
/* s = lua_tolstring(L, -1, &k); */
/* cs = (size_t) string_lookup(s, k); */
/* } */
@@ -405,7 +405,7 @@ static int run_lookup(lua_State * L)
const char *s;
size_t l;
int cs, cmd, chr;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
s = lua_tolstring(L, -1, &l);
if (l > 0) {
cs = string_lookup(s, l);
@@ -422,7 +422,7 @@ static int run_lookup(lua_State * L)
static int run_build(lua_State * L)
{
int cmd, chr, cs;
- if (lua_isnumber(L, 1)) {
+ if (lua_type(L, 1) == LUA_TNUMBER) {
cs = 0;
chr = (int) lua_tointeger(L, 1);
cmd = (int) luaL_optinteger(L, 2, get_cat_code(int_par(cat_code_table_code),chr));
@@ -460,7 +460,7 @@ static int lua_tokenlib_getfield(lua_State * L)
{
lua_token *n;
const char *s;
- halfword t ;
+ halfword t, e ;
n = check_istoken(L, 1);
s = lua_tostring(L, 2);
t = token_info(n->token);
@@ -470,9 +470,40 @@ static int lua_tokenlib_getfield(lua_State * L)
} else {
lua_pushnumber(L, token_cmd(t));
}
+ } else if (lua_key_eq(s, index)) {
+ int cmd = (t >= cs_token_flag ? eq_type(t - cs_token_flag) : token_cmd(t));
+ e = equiv(t - cs_token_flag);
+ switch (cmd) {
+ case assign_int_cmd:
+ e -= count_base;
+ break;
+ case assign_attr_cmd:
+ e -= attribute_base;
+ break;
+ case assign_dimen_cmd:
+ e -= dimen_base;
+ break;
+ case assign_glue_cmd:
+ e -= skip_base;
+ break;
+ case assign_mu_glue_cmd:
+ e -= mu_skip_base;
+ break;
+ case assign_toks_cmd:
+ e -= toks_base;
+ break;
+ default:
+ e = -1;
+ break;
+ }
+ if ((e >= 0) && (e <= 65535)) {
+ lua_pushnumber(L, e);
+ } else {
+ lua_pushnil(L);
+ }
} else if (lua_key_eq(s, mode)) {
if (t >= cs_token_flag) {
- lua_pushnumber(L, equiv((t - cs_token_flag)));
+ lua_pushnumber(L, equiv(t - cs_token_flag));
} else {
lua_pushnumber(L, token_chr(t));
}
@@ -487,7 +518,7 @@ static int lua_tokenlib_getfield(lua_State * L)
else
lua_pushstring(L, (char *) s);
} else {
- lua_pushstring(L, "");
+ lua_pushnil(L);
}
} else if (lua_key_eq(s, id)) {
lua_pushnumber(L, n->token);
@@ -577,6 +608,7 @@ static int run_scan_token(lua_State * L)
/* [catcodetable] csname : \def\csname{} */
/* TODO: check for a quick way to set a macro to empty (HH) */
+
static int set_macro(lua_State * L)
{
const char *name = null;
@@ -591,7 +623,7 @@ static int set_macro(lua_State * L)
if (n == 0) {
return 0 ;
}
- if (lua_isnumber(L, 1)) {
+ if (lua_type(L, 1) == LUA_TNUMBER) {
if (n == 1)
return 0;
ct = (int) lua_tointeger(L, 1);
@@ -659,7 +691,7 @@ static int set_macro(lua_State * L)
}
}
if (_s > 0) {
- /* we havea potential \cs */
+ /* we have a potential \cs */
_cs = string_lookup(_name, _lname);
if (_cs == undefined_control_sequence) {
/* let's play safe and backtrack */
@@ -729,11 +761,11 @@ static const struct luaL_Reg tokenlib_m[] = {
-int luaopen_newtoken(lua_State * L)
+int luaopen_token(lua_State * L)
{
/* the main metatable of token userdata */
luaL_newmetatable(L, TOKEN_METATABLE);
luaL_register(L, NULL, tokenlib_m);
- luaL_register(L, "newtoken", tokenlib);
+ luaL_register(L, "token", tokenlib);
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
index 215297b3be1..437864c87a1 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -148,7 +148,7 @@
lua_getmetatable(L,1); \
lua_setmetatable(L,-2); \
} else { \
- lua_pushnil(L); \
+ lua_pushnil(L); \
} \
} while (0)
@@ -192,6 +192,14 @@
} \
} while (0)
+#define nodelib_check_glue_spec(n) do { \
+ n = glue_ptr(n); \
+ if ((!n) || (!valid_node(n))) { \
+ n = new_node(glue_spec_node,0); \
+ glue_ptr(n) = n; \
+ } \
+} while (0)
+
/* handy sometimes: */
/* static void stackDump (lua_State * L) { */
@@ -224,18 +232,6 @@
#define nodelib_getspec nodelib_getlist
#define nodelib_getaction nodelib_getlist
-/* a quick helper for dir nodes; there is only a small set of possible values */
-
-#define RETURN_DIR_VALUES(a) \
-if (s==luaS_##a##_ptr) { \
- return (dir_##a); \
-} else if (!absolute_only) { \
- if (s==luaS_p##a##_ptr) \
- return (dir_##a); \
- else if (s==luaS_m##a##_ptr) \
- return ((dir_##a)-64); \
-}
-
/* fetching a field from a node .. we can often use the reuse bot-of-stack metatable */
#define nodelib_pushlist(L,n) { lua_pushnumber(L,n); lua_nodelib_push(L); } /* can be: fast_metatable_or_nil(n) */
@@ -270,11 +266,11 @@ while (vlink(t)!=current && t != null) { \
/* maybe these qualify as macros, not functions */
-static halfword *maybe_isnode(lua_State * L, int ud)
+static halfword *maybe_isnode(lua_State * L, int i)
{
- halfword *p = lua_touserdata(L, ud);
+ halfword *p = lua_touserdata(L, i);
if (p != NULL) {
- if (lua_getmetatable(L, ud)) {
+ if (lua_getmetatable(L, i)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node));
lua_gettable(L, LUA_REGISTRYINDEX);
if (!lua_rawequal(L, -1, -2))
@@ -287,12 +283,12 @@ static halfword *maybe_isnode(lua_State * L, int ud)
/* we could make the message a function and just inline the rest (via a macro) */
-halfword *check_isnode(lua_State * L, int ud)
+halfword *check_isnode(lua_State * L, int i)
{
- halfword *p = maybe_isnode(L, ud);
+ halfword *p = maybe_isnode(L, i);
if (p != NULL)
return p;
- luatex_fail("There should have been a lua <node> here, not an object with type %s!", luaL_typename(L, ud));
+ luatex_fail("There should have been a lua <node> here, not an object with type %s!", luaL_typename(L, i));
return NULL;
}
@@ -434,7 +430,7 @@ void lua_nodelib_push(lua_State * L)
halfword n;
halfword *a;
n = -1;
- if (lua_isnumber(L, -1))
+ if (lua_type(L, -1) == LUA_TNUMBER)
n = (int) lua_tointeger(L, -1);
lua_pop(L, 1);
if ((n == null) || (n < 0) || (n > var_mem_max)) {
@@ -456,7 +452,7 @@ static void lua_nodelib_push_spec(lua_State * L)
halfword n;
halfword *a;
n = -1;
- if (lua_isnumber(L, -1))
+ if (lua_type(L, -1) == LUA_TNUMBER)
n = (halfword) lua_tointeger(L, -1);
lua_pop(L, 1);
if ((n < 0) || (n > var_mem_max)) {
@@ -474,11 +470,15 @@ static void lua_nodelib_push_spec(lua_State * L)
void lua_nodelib_push_fast(lua_State * L, halfword n)
{
halfword *a;
- a = lua_newuserdata(L, sizeof(halfword));
- *a = n;
- lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(luatex_node));
- lua_gettable(L, LUA_REGISTRYINDEX);
- lua_setmetatable(L, -2);
+ 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_setmetatable(L, -2);
+ } else {
+ lua_pushnil(L);
+ }
return;
}
@@ -1402,8 +1402,6 @@ static int lua_nodelib_copy_list(lua_State * L)
if ((lua_gettop(L) > 1) && (!lua_isnil(L,2)))
s = *check_isnode(L, 2);
m = do_copy_node_list(n, s);
-// lua_pushnumber(L, m);
-// lua_nodelib_push(L);
lua_nodelib_push_fast(L,m);
return 1;
@@ -1722,8 +1720,7 @@ static int lua_nodelib_dimensions(lua_State * L)
int i = 1;
int d = -1;
halfword n = null, p = null;
- /* maybe be more restrictive: LUA_TNUMBER i.e. it's not good to mix numbers and strings with digits */
- if (lua_isnumber(L, 1)) {
+ if (lua_type(L, 1) == LUA_TNUMBER) {
if (top < 4) {
lua_pushnil(L);
return 1;
@@ -1805,7 +1802,7 @@ static int lua_nodelib_mlist_to_hlist(lua_State * L)
boolean m;
n = *(check_isnode(L, 1));
//w = luaL_checkoption(L, 2, "text", math_style_names);
- assign_math_style(L,2,w);
+ assign_math_style(L,2,w);
luaL_checkany(L, 3);
m = lua_toboolean(L, 3);
mlist_to_hlist_args(n, w, m);
@@ -1950,24 +1947,20 @@ static int lua_nodelib_fields(lua_State * L)
}
lua_checkstack(L, 2);
lua_newtable(L);
- // lua_pushstring(L, "next");
lua_push_string_by_name(L,next);
lua_rawseti(L, -2, 0);
- // lua_pushstring(L, "id");
lua_push_string_by_name(L,id);
lua_rawseti(L, -2, 1);
if (nodetype_has_subtype(t)) {
- // lua_pushstring(L, "subtype");
lua_push_string_by_name(L,subtype);
lua_rawseti(L, -2, 2);
offset++;
}
+ if (nodetype_has_prev(t)) {
+ lua_push_string_by_name(L,prev);
+ lua_rawseti(L, -2, -1);
+ }
if (fields != NULL) {
- if (nodetype_has_prev(t)) {
-// lua_pushstring(L, "prev");
- lua_push_string_by_name(L,prev);
- lua_rawseti(L, -2, -1);
- }
for (i = 0; fields[i] != NULL; i++) {
lua_pushstring(L, fields[i]); /* todo */
lua_rawseti(L, -2, (i + offset));
@@ -1976,6 +1969,79 @@ static int lua_nodelib_fields(lua_State * L)
return 1;
}
+static int lua_nodelib_subtypes(lua_State * L)
+{
+ int i = -1;
+ int l = 0;
+ int t;
+ const char **subtypes = NULL;
+ const char *s ;
+ t = lua_type(L,1);
+ if (t == LUA_TSTRING) {
+ /* official accessors */
+ s = lua_tostring(L,1);
+ if (lua_key_eq(s,glyph)) subtypes = node_subtypes_glyph;
+ else if (lua_key_eq(s,glue)) { subtypes = node_subtypes_glue; l = 1; }
+ else if (lua_key_eq(s,penalty)) subtypes = node_subtypes_penalty;
+ else if (lua_key_eq(s,kern)) subtypes = node_subtypes_kern;
+ else if (lua_key_eq(s,rule)) subtypes = node_subtypes_rule;
+ else if (lua_key_eq(s,list)) subtypes = node_subtypes_list;
+ else if (lua_key_eq(s,disc)) subtypes = node_subtypes_disc;
+ else if (lua_key_eq(s,fill)) subtypes = node_subtypes_fill;
+ else if (lua_key_eq(s,leader)) { subtypes = node_subtypes_leader; l = 2; }
+ else if (lua_key_eq(s,marginkern)) subtypes = node_subtypes_marginkern;
+ else if (lua_key_eq(s,math)) subtypes = node_subtypes_math;
+ else if (lua_key_eq(s,noad)) subtypes = node_subtypes_noad;
+ else if (lua_key_eq(s,radical)) subtypes = node_subtypes_radical;
+ else if (lua_key_eq(s,accent)) subtypes = node_subtypes_accent;
+ else if (lua_key_eq(s,fence)) subtypes = node_subtypes_fence;
+ /* backend */
+ else if (lua_key_eq(s,pdf_destination)) subtypes = node_subtypes_pdf_destination;
+ else if (lua_key_eq(s,pdf_literal)) subtypes = node_subtypes_pdf_literal;
+ } else if (t == LUA_TNUMBER) {
+ /* maybe */
+ t = lua_tonumber(L,1);
+ if (t == glyph_node) subtypes = node_subtypes_glyph;
+ else if (t == glue_node) { subtypes = node_subtypes_glue; l = 1; }
+ else if (t == penalty_node) subtypes = node_subtypes_penalty;
+ else if (t == kern_node) subtypes = node_subtypes_kern;
+ else if (t == rule_node) subtypes = node_subtypes_rule;
+ else if (t == hlist_node) subtypes = node_subtypes_list;
+ else if (t == vlist_node) subtypes = node_subtypes_list;
+ else if (t == disc_node) subtypes = node_subtypes_disc;
+ else if (t == glue_spec_node) subtypes = node_subtypes_fill;
+ else if (t == margin_kern_node) subtypes = node_subtypes_marginkern;
+ else if (t == math_node) subtypes = node_subtypes_math;
+ else if (t == simple_noad) subtypes = node_subtypes_noad;
+ else if (t == radical_noad) subtypes = node_subtypes_radical;
+ else if (t == accent_noad) subtypes = node_subtypes_accent;
+ else if (t == fence_noad) subtypes = node_subtypes_fence;
+ /* backend */
+ else if (t == pdf_dest_node) subtypes = node_subtypes_pdf_destination;
+ else if (t == pdf_literal_node) subtypes = node_subtypes_pdf_literal;
+ }
+ if (subtypes != NULL) {
+ lua_checkstack(L, 2);
+ lua_newtable(L);
+ if (l < 2) {
+ for (i = 0; subtypes[i] != NULL; i++) {
+ lua_pushstring(L, subtypes[i]); /* todo */
+ lua_rawseti(L, -2, i);
+ }
+ }
+ if (l > 0) {
+ /* add leaders */
+ for (i = 0; node_subtypes_leader[i] != NULL; i++) {
+ lua_pushstring(L, node_subtypes_leader[i]); /* todo */
+ lua_rawseti(L, -2, 100 + i);
+ }
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ return 1;
+}
+
/* node.slide (find the end of a list and add prev links) */
static int lua_nodelib_slide(lua_State * L)
@@ -2469,20 +2535,9 @@ static int lua_nodelib_direct_count(lua_State * L)
);
}
-/* directions (could be a macro) */
-
-// static void nodelib_pushdir(lua_State * L, int n, boolean dirnode)
-// {
-// if (dirnode) {
-// lua_pushstring(L, dir_strings[n+64]);
-// } else {
-// lua_pushstring(L, dir_strings[n+64]+1);
-// }
-// }
-
/* getting and setting fields (helpers) */
-static int nodelib_getlist(lua_State * L, int n)
+int nodelib_getlist(lua_State * L, int n)
{
halfword *m;
if (lua_isuserdata(L, n)) {
@@ -2515,13 +2570,18 @@ static str_number nodelib_getstring(lua_State * L, int a)
return maketexlstring(s, k);
}
-
static int nodelib_cantset(lua_State * L, int n, const char *s)
{
luaL_error(L,"You cannot set field %s in a node of type %s",s,node_data[type(n)].name);
return 0;
}
+static int nodelib_nonwritable(lua_State * L, int n, const char *s)
+{
+ luaL_error(L,"You cannot set field %s in a non writable node of type %s",s,node_data[type(n)].name);
+ return 0;
+}
+
/* node.direct.getfield */
static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
@@ -2529,20 +2589,7 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
int t ;
t = subtype(n);
- if (t == dir_node) {
- if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, dir_dir(n), true);
- lua_push_dir_text(L, dir_dir(n));
- } else if (lua_key_eq(s, level)) {
- lua_pushnumber(L, dir_level(n));
- } else if (lua_key_eq(s, dvi_ptr)) {
- lua_pushnumber(L, dir_dvi_ptr(n));
- } else if (lua_key_eq(s, dir_h)) {
- lua_pushnumber(L, dir_dvi_h(n));
- } else {
- lua_pushnil(L);
- }
- } else if (t == user_defined_node) {
+ if (t == user_defined_node) {
if (lua_key_eq(s, user_id)) {
lua_pushnumber(L, user_node_id(n));
} else if (lua_key_eq(s, type)) {
@@ -2578,27 +2625,6 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
} else {
lua_pushnil(L);
}
- } else if (t == local_par_node) {
- if (lua_key_eq(s, pen_inter)) {
- lua_pushnumber(L, local_pen_inter(n));
- } else if (lua_key_eq(s, pen_broken)) {
- lua_pushnumber(L, local_pen_broken(n));
- } else if (lua_key_eq(s, dir)) {
-// nodelib_pushdir(L, local_par_dir(n), false);
- lua_push_dir_par(L, local_par_dir(n));
- } else if (lua_key_eq(s, box_left)) {
- /* can be: fast_metatable_or_nil(local_box_left(n)) */
- nodelib_pushlist(L, local_box_left(n));
- } else if (lua_key_eq(s, box_left_width)) {
- lua_pushnumber(L, local_box_left_width(n));
- } else if (lua_key_eq(s, box_right)) {
- /* can be: fast_metatable_or_nil(local_box_right(n)) */
- nodelib_pushlist(L, local_box_right(n));
- } else if (lua_key_eq(s, box_right_width)) {
- lua_pushnumber(L, local_box_right_width(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == pdf_literal_node) {
if (lua_key_eq(s, mode)) {
lua_pushnumber(L, pdf_literal_mode(n));
@@ -2682,32 +2708,6 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
} else {
lua_pushnil(L);
}
- } else if (t == pdf_refxform_node) {
- if (lua_key_eq(s, width)) {
- lua_pushnumber(L, width(n));
- } else if (lua_key_eq(s, depth)) {
- lua_pushnumber(L, depth(n));
- } else if (lua_key_eq(s, height)) {
- lua_pushnumber(L, height(n));
- } else if (lua_key_eq(s, objnum)) {
- lua_pushnumber(L, pdf_xform_objnum(n));
- } else {
- lua_pushnil(L);
- }
- } else if (t == pdf_refximage_node) {
- if (lua_key_eq(s, width)) {
- lua_pushnumber(L, width(n));
- } else if (lua_key_eq(s, depth)) {
- lua_pushnumber(L, depth(n));
- } else if (lua_key_eq(s, height)) {
- lua_pushnumber(L, height(n));
- } else if (lua_key_eq(s, transform)) {
- lua_pushnumber(L, pdf_ximage_transform(n));
- } else if (lua_key_eq(s, index)) {
- lua_pushnumber(L, pdf_ximage_index(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == write_node) {
if (lua_key_eq(s, stream)) {
lua_pushnumber(L, write_stream(n));
@@ -2738,6 +2738,28 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
} else {
lua_pushnil(L);
}
+ } else if (t == pdf_action_node) {
+ if (lua_key_eq(s, action_type)) {
+ lua_pushnumber(L, pdf_action_type(n));
+ } else if (lua_key_eq(s, named_id)) {
+ lua_pushnumber(L, pdf_action_named_id(n));
+ } else if (lua_key_eq(s, action_id)) {
+ if (pdf_action_named_id(n) == 1) {
+ tokenlist_to_luastring(L, pdf_action_id(n));
+ } else {
+ lua_pushnumber(L, pdf_action_id(n));
+ }
+ } else if (lua_key_eq(s, file)) {
+ tokenlist_to_luastring(L, pdf_action_file(n));
+ } else if (lua_key_eq(s, new_window)) {
+ lua_pushnumber(L, pdf_action_new_window(n));
+ } else if (lua_key_eq(s, data)) {
+ tokenlist_to_luastring(L, pdf_action_tokens(n));
+ } else if (lua_key_eq(s, ref_count)) {
+ lua_pushnumber(L, pdf_action_refcount(n));
+ } else {
+ lua_pushnil(L);
+ }
} else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
if (lua_key_eq(s, width)) {
lua_pushnumber(L, width(n));
@@ -2900,8 +2922,7 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, box_dir(n), false);
- lua_push_dir_par(L, box_dir(n));
+ lua_push_dir_par(L, box_dir(n));
} else if (lua_key_eq(s, shift)) {
lua_pushnumber(L, shift_amount(n));
} else if (lua_key_eq(s, glue_order)) {
@@ -2933,7 +2954,22 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else if (lua_key_eq(s, leader)) {
fast_metatable_or_nil(leader_ptr(n));
} else {
- lua_pushnil(L);
+ n = glue_ptr(n);
+ if (!n) {
+ lua_pushnil(L);
+ } else if (lua_key_eq(s, width)) {
+ lua_pushnumber(L, width(n));
+ } else if (lua_key_eq(s, stretch)) {
+ lua_pushnumber(L, stretch(n));
+ } else if (lua_key_eq(s, shrink)) {
+ lua_pushnumber(L, shrink(n));
+ } else if (lua_key_eq(s, stretch_order)) {
+ lua_pushnumber(L, stretch_order(n));
+ } else if (lua_key_eq(s, shrink_order)) {
+ lua_pushnumber(L, shrink_order(n));
+ } else {
+ lua_pushnil(L);
+ }
}
} else if (t == glue_spec_node) {
if (lua_key_eq(s, subtype)) {
@@ -2984,8 +3020,44 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, rule_dir(n), false);
- lua_push_dir_par(L, rule_dir(n));
+ lua_push_dir_par(L, rule_dir(n));
+ } else if (lua_key_eq(s, index)) {
+ lua_pushnumber(L, rule_index(n));
+ } else if (lua_key_eq(s, transform)) {
+ lua_pushnumber(L,rule_transform(n));
+ } else {
+ lua_pushnil(L);
+ }
+ } else if (t == dir_node) {
+ if (lua_key_eq(s, dir)) {
+ // nodelib_pushdir(L, dir_dir(n), true);
+ lua_push_dir_text(L, dir_dir(n));
+ } else if (lua_key_eq(s, level)) {
+ lua_pushnumber(L, dir_level(n));
+ } else if (lua_key_eq(s, dvi_ptr)) {
+ lua_pushnumber(L, dir_dvi_ptr(n));
+ } else if (lua_key_eq(s, dir_h)) {
+ lua_pushnumber(L, dir_dvi_h(n));
+ } else {
+ lua_pushnil(L);
+ }
+ } else if (t == local_par_node) {
+ if (lua_key_eq(s, pen_inter)) {
+ lua_pushnumber(L, local_pen_inter(n));
+ } else if (lua_key_eq(s, pen_broken)) {
+ lua_pushnumber(L, local_pen_broken(n));
+ } else if (lua_key_eq(s, dir)) {
+ lua_push_dir_par(L, local_par_dir(n));
+ } else if (lua_key_eq(s, box_left)) {
+ /* can be: fast_metatable_or_nil(local_box_left(n)) */
+ nodelib_pushlist(L, local_box_left(n));
+ } else if (lua_key_eq(s, box_left_width)) {
+ lua_pushnumber(L, local_box_left_width(n));
+ } else if (lua_key_eq(s, box_right)) {
+ /* can be: fast_metatable_or_nil(local_box_right(n)) */
+ nodelib_pushlist(L, local_box_right(n));
+ } else if (lua_key_eq(s, box_right_width)) {
+ lua_pushnumber(L, local_box_right_width(n));
} else {
lua_pushnil(L);
}
@@ -3085,10 +3157,12 @@ static int lua_nodelib_fast_getfield(lua_State * L)
fast_metatable_or_nil(subscr(n));
} else if (lua_key_eq(s, sup)) {
fast_metatable_or_nil(supscr(n));
- } else if (lua_key_eq(s, accent)) {
- fast_metatable_or_nil(accent_chr(n));
+ } else if ((lua_key_eq(s, top_accent))||(lua_key_eq(s, accent))) {
+ fast_metatable_or_nil(top_accent_chr(n));
} else if (lua_key_eq(s, bot_accent)) {
fast_metatable_or_nil(bot_accent_chr(n));
+ } else if (lua_key_eq(s, overlay_accent)) {
+ fast_metatable_or_nil(overlay_accent_chr(n));
} else {
lua_pushnil(L);
}
@@ -3204,30 +3278,6 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else {
lua_pushnil(L);
}
- } else if (t == action_node) {
- if (lua_key_eq(s, subtype)) {
- lua_pushnumber(L, subtype(n));/* dummy subtype */
- } else if (lua_key_eq(s, action_type)) {
- lua_pushnumber(L, pdf_action_type(n));
- } else if (lua_key_eq(s, named_id)) {
- lua_pushnumber(L, pdf_action_named_id(n));
- } else if (lua_key_eq(s, action_id)) {
- if (pdf_action_named_id(n) == 1) {
- tokenlist_to_luastring(L, pdf_action_id(n));
- } else {
- lua_pushnumber(L, pdf_action_id(n));
- }
- } else if (lua_key_eq(s, file)) {
- tokenlist_to_luastring(L, pdf_action_file(n));
- } else if (lua_key_eq(s, new_window)) {
- lua_pushnumber(L, pdf_action_new_window(n));
- } else if (lua_key_eq(s, data)) {
- tokenlist_to_luastring(L, pdf_action_tokens(n));
- } else if (lua_key_eq(s, ref_count)) {
- lua_pushnumber(L, pdf_action_refcount(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == unset_node) {
if (lua_key_eq(s, subtype)) {
lua_pushnumber(L, subtype(n));
@@ -3238,8 +3288,7 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, box_dir(n), false);
- lua_push_dir_par(L, box_dir(n));
+ lua_push_dir_par(L, box_dir(n));
} else if (lua_key_eq(s, shrink)) {
lua_pushnumber(L, glue_shrink(n));
} else if (lua_key_eq(s, glue_order)) {
@@ -3261,6 +3310,14 @@ static int lua_nodelib_fast_getfield(lua_State * L)
} else {
lua_pushnil(L);
}
+ } else if (t == boundary_node) {
+ if (lua_key_eq(s, subtype)) {
+ lua_pushnumber(L, subtype(n));
+ } else if (lua_key_eq(s, value)) {
+ lua_pushnumber(L, boundary_value(n));
+ } else {
+ lua_pushnil(L);
+ }
} else {
lua_pushnil(L);
}
@@ -3295,20 +3352,7 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
int t ;
t = subtype(n);
- if (t == dir_node) {
- if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, dir_dir(n), true);
- lua_push_dir_text(L, dir_dir(n));
- } else if (lua_key_eq(s, level)) {
- lua_pushnumber(L, dir_level(n));
- } else if (lua_key_eq(s, dvi_ptr)) {
- lua_pushnumber(L, dir_dvi_ptr(n));
- } else if (lua_key_eq(s, dir_h)) {
- lua_pushnumber(L, dir_dvi_h(n));
- } else {
- lua_pushnil(L);
- }
- } else if (t == user_defined_node) {
+ if (t == user_defined_node) {
if (lua_key_eq(s, user_id)) {
lua_pushnumber(L, user_node_id(n));
} else if (lua_key_eq(s, type)) {
@@ -3344,25 +3388,6 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
} else {
lua_pushnil(L);
}
- } else if (t == local_par_node) {
- if (lua_key_eq(s, pen_inter)) {
- lua_pushnumber(L, local_pen_inter(n));
- } else if (lua_key_eq(s, pen_broken)) {
- lua_pushnumber(L, local_pen_broken(n));
- } else if (lua_key_eq(s, dir)) {
-// nodelib_pushdir(L, local_par_dir(n), false);
- lua_push_dir_par(L, local_par_dir(n));
- } else if (lua_key_eq(s, box_left)) {
- nodelib_pushdirect_or_nil(local_box_left(n));
- } else if (lua_key_eq(s, box_left_width)) {
- lua_pushnumber(L, local_box_left_width(n));
- } else if (lua_key_eq(s, box_right)) {
- nodelib_pushdirect_or_nil(local_box_right(n));
- } else if (lua_key_eq(s, box_right_width)) {
- lua_pushnumber(L, local_box_right_width(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == pdf_literal_node) {
if (lua_key_eq(s, mode)) {
lua_pushnumber(L, pdf_literal_mode(n));
@@ -3446,32 +3471,6 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
} else {
lua_pushnil(L);
}
- } else if (t == pdf_refxform_node) {
- if (lua_key_eq(s, width)) {
- lua_pushnumber(L, width(n));
- } else if (lua_key_eq(s, depth)) {
- lua_pushnumber(L, depth(n));
- } else if (lua_key_eq(s, height)) {
- lua_pushnumber(L, height(n));
- } else if (lua_key_eq(s, objnum)) {
- lua_pushnumber(L, pdf_xform_objnum(n));
- } else {
- lua_pushnil(L);
- }
- } else if (t == pdf_refximage_node) {
- if (lua_key_eq(s, width)) {
- lua_pushnumber(L, width(n));
- } else if (lua_key_eq(s, depth)) {
- lua_pushnumber(L, depth(n));
- } else if (lua_key_eq(s, height)) {
- lua_pushnumber(L, height(n));
- } else if (lua_key_eq(s, transform)) {
- lua_pushnumber(L, pdf_ximage_transform(n));
- } else if (lua_key_eq(s, index)) {
- lua_pushnumber(L, pdf_ximage_index(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == write_node) {
if (lua_key_eq(s, stream)) {
lua_pushnumber(L, write_stream(n));
@@ -3502,6 +3501,28 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
} else {
lua_pushnil(L);
}
+ } else if (t == pdf_action_node) {
+ if (lua_key_eq(s, action_type)) {
+ lua_pushnumber(L, pdf_action_type(n));
+ } else if (lua_key_eq(s, named_id)) {
+ lua_pushnumber(L, pdf_action_named_id(n));
+ } else if (lua_key_eq(s, action_id)) {
+ if (pdf_action_named_id(n) == 1) {
+ tokenlist_to_luastring(L, pdf_action_id(n));
+ } else {
+ lua_pushnumber(L, pdf_action_id(n));
+ }
+ } else if (lua_key_eq(s, file)) {
+ tokenlist_to_luastring(L, pdf_action_file(n));
+ } else if (lua_key_eq(s, new_window)) {
+ lua_pushnumber(L, pdf_action_new_window(n));
+ } else if (lua_key_eq(s, data)) {
+ tokenlist_to_luastring(L, pdf_action_tokens(n));
+ } else if (lua_key_eq(s, ref_count)) {
+ lua_pushnumber(L, pdf_action_refcount(n));
+ } else {
+ lua_pushnil(L);
+ }
} else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
if (lua_key_eq(s, width)) {
lua_pushnumber(L, width(n));
@@ -3652,8 +3673,7 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, box_dir(n), false);
- lua_push_dir_par(L, box_dir(n));
+ lua_push_dir_par(L, box_dir(n));
} else if (lua_key_eq(s, shift)) {
lua_pushnumber(L, shift_amount(n));
} else if (lua_key_eq(s, glue_order)) {
@@ -3681,7 +3701,22 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else if (lua_key_eq(s, leader)) {
nodelib_pushdirect_or_nil(leader_ptr(n));
} else {
- lua_pushnil(L);
+ n = glue_ptr(n);
+ if (!n) {
+ lua_pushnil(L);
+ } else if (lua_key_eq(s, width)) {
+ lua_pushnumber(L, width(n));
+ } else if (lua_key_eq(s, stretch)) {
+ lua_pushnumber(L, stretch(n));
+ } else if (lua_key_eq(s, shrink)) {
+ lua_pushnumber(L, shrink(n));
+ } else if (lua_key_eq(s, stretch_order)) {
+ lua_pushnumber(L, stretch_order(n));
+ } else if (lua_key_eq(s, shrink_order)) {
+ lua_pushnumber(L, shrink_order(n));
+ } else {
+ lua_pushnil(L);
+ }
}
} else if (t == glue_spec_node) {
if (lua_key_eq(s, width)) {
@@ -3724,8 +3759,42 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, rule_dir(n), false);
- lua_push_dir_par(L, rule_dir(n));
+ lua_push_dir_par(L, rule_dir(n));
+ } else if (lua_key_eq(s, index)) {
+ lua_pushnumber(L, rule_index(n));
+ } else if (lua_key_eq(s, transform)) {
+ lua_pushnumber(L,rule_transform(n));
+ } else {
+ lua_pushnil(L);
+ }
+ } else if (t == dir_node) {
+ if (lua_key_eq(s, dir)) {
+ // nodelib_pushdir(L, dir_dir(n), true);
+ lua_push_dir_text(L, dir_dir(n));
+ } else if (lua_key_eq(s, level)) {
+ lua_pushnumber(L, dir_level(n));
+ } else if (lua_key_eq(s, dvi_ptr)) {
+ lua_pushnumber(L, dir_dvi_ptr(n));
+ } else if (lua_key_eq(s, dir_h)) {
+ lua_pushnumber(L, dir_dvi_h(n));
+ } else {
+ lua_pushnil(L);
+ }
+ } else if (t == local_par_node) {
+ if (lua_key_eq(s, pen_inter)) {
+ lua_pushnumber(L, local_pen_inter(n));
+ } else if (lua_key_eq(s, pen_broken)) {
+ lua_pushnumber(L, local_pen_broken(n));
+ } else if (lua_key_eq(s, dir)) {
+ lua_push_dir_par(L, local_par_dir(n));
+ } else if (lua_key_eq(s, box_left)) {
+ nodelib_pushdirect_or_nil(local_box_left(n));
+ } else if (lua_key_eq(s, box_left_width)) {
+ lua_pushnumber(L, local_box_left_width(n));
+ } else if (lua_key_eq(s, box_right)) {
+ nodelib_pushdirect_or_nil(local_box_right(n));
+ } else if (lua_key_eq(s, box_right_width)) {
+ lua_pushnumber(L, local_box_right_width(n));
} else {
lua_pushnil(L);
}
@@ -3804,10 +3873,12 @@ static int lua_nodelib_direct_getfield(lua_State * L)
nodelib_pushdirect_or_nil(subscr(n));
} else if (lua_key_eq(s, sup)) {
nodelib_pushdirect_or_nil(supscr(n));
- } else if (lua_key_eq(s, accent)) {
- nodelib_pushdirect_or_nil(accent_chr(n));
+ } else if ((lua_key_eq(s, top_accent))||(lua_key_eq(s, accent))) {
+ nodelib_pushdirect_or_nil(top_accent_chr(n));
} else if (lua_key_eq(s, bot_accent)) {
nodelib_pushdirect_or_nil(bot_accent_chr(n));
+ } else if (lua_key_eq(s, overlay_accent)) {
+ nodelib_pushdirect_or_nil(overlay_accent_chr(n));
} else {
lua_pushnil(L);
}
@@ -3903,28 +3974,6 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else {
lua_pushnil(L);
}
- } else if (t == action_node) {
- if (lua_key_eq(s, action_type)) {
- lua_pushnumber(L, pdf_action_type(n));
- } else if (lua_key_eq(s, named_id)) {
- lua_pushnumber(L, pdf_action_named_id(n));
- } else if (lua_key_eq(s, action_id)) {
- if (pdf_action_named_id(n) == 1) {
- tokenlist_to_luastring(L, pdf_action_id(n));
- } else {
- lua_pushnumber(L, pdf_action_id(n));
- }
- } else if (lua_key_eq(s, file)) {
- tokenlist_to_luastring(L, pdf_action_file(n));
- } else if (lua_key_eq(s, new_window)) {
- lua_pushnumber(L, pdf_action_new_window(n));
- } else if (lua_key_eq(s, data)) {
- tokenlist_to_luastring(L, pdf_action_tokens(n));
- } else if (lua_key_eq(s, ref_count)) {
- lua_pushnumber(L, pdf_action_refcount(n));
- } else {
- lua_pushnil(L);
- }
} else if (t == unset_node) {
if (lua_key_eq(s, width)) {
lua_pushnumber(L, width(n));
@@ -3933,8 +3982,7 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else if (lua_key_eq(s, depth)) {
lua_pushnumber(L, depth(n));
} else if (lua_key_eq(s, dir)) {
- // nodelib_pushdir(L, box_dir(n), false);
- lua_push_dir_par(L, box_dir(n));
+ lua_push_dir_par(L, box_dir(n));
} else if (lua_key_eq(s, shrink)) {
lua_pushnumber(L, glue_shrink(n));
} else if (lua_key_eq(s, glue_order)) {
@@ -3952,6 +4000,14 @@ static int lua_nodelib_direct_getfield(lua_State * L)
}
/* } else if (t == attribute_list_node) { */
/* lua_pushnil(L); */
+ } else if (t == boundary_node) {
+ if (lua_key_eq(s, subtype)) {
+ lua_pushnumber(L, subtype(n));
+ } else if (lua_key_eq(s, value)) {
+ lua_pushnumber(L, boundary_value(n));
+ } else {
+ lua_pushnil(L);
+ }
} else {
lua_pushnil(L);
}
@@ -4091,7 +4147,6 @@ static int font_tex_kerning(lua_State * L)
return 3;
}
-
/* node.protect_glyphs (returns also boolean because that signals callback) */
static int lua_nodelib_protect_glyphs(lua_State * L)
@@ -4243,9 +4298,6 @@ static int lua_nodelib_direct_first_glyph(lua_State * L)
/* return null; \ */
/* } while (0) */
-
-
-
/* node.has_glyph */
static int lua_nodelib_has_glyph(lua_State * L)
@@ -4489,19 +4541,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
int t ;
t = subtype(n);
- if (t == dir_node) {
- if (lua_key_eq(s, dir)) {
- dir_dir(n) = nodelib_getdir(L, 3, 0);
- } else if (lua_key_eq(s, level)) {
- dir_level(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dvi_ptr)) {
- dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dir_h)) {
- dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == pdf_literal_node) {
+ if (t == pdf_literal_node) {
if (lua_key_eq(s, mode)) {
pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, data)) {
@@ -4623,50 +4663,6 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
} else {
return nodelib_cantset(L, n, s);
}
- } else if (t == pdf_refxform_node) {
- if (lua_key_eq(s, width)) {
- width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, depth)) {
- depth(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, height)) {
- height(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, objnum)) {
- pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == pdf_refximage_node) {
- if (lua_key_eq(s, width)) {
- width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, depth)) {
- depth(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, height)) {
- height(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, transform)) {
- pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, index)) {
- pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == local_par_node) {
- if (lua_key_eq(s, pen_inter)) {
- local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, pen_broken)) {
- local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dir)) {
- local_par_dir(n) = nodelib_getdir(L, 3, 1);
- } else if (lua_key_eq(s, box_left)) {
- local_box_left(n) = nodelib_getlist(L, 3);
- } else if (lua_key_eq(s, box_left_width)) {
- local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, box_right)) {
- local_box_right(n) = nodelib_getlist(L, 3);
- } else if (lua_key_eq(s, box_right_width)) {
- local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
} else if (t == pdf_start_link_node) {
if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -4701,6 +4697,28 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
} else {
return nodelib_cantset(L, n, s);
}
+ } else if (t == pdf_action_node) {
+ if (lua_key_eq(s, action_type)) {
+ pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, named_id)) {
+ pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, action_id)) {
+ if (pdf_action_named_id(n) == 1) {
+ pdf_action_id(n) = nodelib_gettoks(L, 3);
+ } else {
+ pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
+ }
+ } else if (lua_key_eq(s, file)) {
+ pdf_action_file(n) = nodelib_gettoks(L, 3);
+ } else if (lua_key_eq(s, new_window)) {
+ pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, data)) {
+ pdf_action_tokens(n) = nodelib_gettoks(L, 3);
+ /* } else if (lua_key_eq(s, ref_count)) {
+ pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
} else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -4746,7 +4764,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
return nodelib_cantset(L, n, s);
}
} else if ((t == pdf_end_link_node) || (t == pdf_end_thread_node) || (t == save_pos_node) ||
- (t == pdf_save_node) || (t == pdf_restore_node) || (t == cancel_boundary_node)) {
+ (t == pdf_save_node) || (t == pdf_restore_node)) {
return nodelib_cantset(L, n, s);
} else {
/* do nothing */
@@ -4877,11 +4895,28 @@ static int lua_nodelib_fast_setfield(lua_State * L)
glue_ptr(n) = nodelib_getspec(L, 3);
} else if (lua_key_eq(s, leader)) {
leader_ptr(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, width)) {
+ nodelib_check_glue_spec(n);
+ width(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, stretch)) {
+ nodelib_check_glue_spec(n);
+ stretch(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, shrink)) {
+ nodelib_check_glue_spec(n);
+ shrink(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, stretch_order)) {
+ nodelib_check_glue_spec(n);
+ stretch_order(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, shrink_order)) {
+ nodelib_check_glue_spec(n);
+ shrink_order(n) = (quarterword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
} else if (t == glue_spec_node) {
- if (lua_key_eq(s, subtype)) {
+ if (!valid_node(n)) {
+ return nodelib_nonwritable(L, n, s);
+ } else if (lua_key_eq(s, subtype)) {
subtype(n) = (quarterword) lua_tointeger(L, 3); /* dummy, the only one that prevents move up */
} else if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -4892,12 +4927,7 @@ static int lua_nodelib_fast_setfield(lua_State * L)
} else if (lua_key_eq(s, stretch_order)) {
stretch_order(n) = (quarterword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, shrink_order)) {
- shrink_order(n) = (quarterword) lua_tointeger(L, 3);
- /* } else if (lua_key_eq(s, ref_count)) {
- glue_ref_count(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, writable)) {
- */
- /* can't be set */
+ shrink_order(n) = (quarterword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -4930,6 +4960,40 @@ static int lua_nodelib_fast_setfield(lua_State * L)
depth(n) = (halfword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, dir)) {
rule_dir(n) = nodelib_getdir(L, 3, 1);
+ } else if (lua_key_eq(s, index)) {
+ rule_index(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, transform)) {
+ rule_transform(n) = (halfword) lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
+ } else if (t == dir_node) {
+ if (lua_key_eq(s, dir)) {
+ dir_dir(n) = nodelib_getdir(L, 3, 0);
+ } else if (lua_key_eq(s, level)) {
+ dir_level(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dvi_ptr)) {
+ dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dir_h)) {
+ dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
+ } else if (t == local_par_node) {
+ if (lua_key_eq(s, pen_inter)) {
+ local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, pen_broken)) {
+ local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dir)) {
+ local_par_dir(n) = nodelib_getdir(L, 3, 1);
+ } else if (lua_key_eq(s, box_left)) {
+ local_box_left(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, box_left_width)) {
+ local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, box_right)) {
+ local_box_right(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, box_right_width)) {
+ local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -5015,7 +5079,7 @@ static int lua_nodelib_fast_setfield(lua_State * L)
if (lua_key_eq(s, subtype)) {
/* dummy subtype */
} else if (lua_key_eq(s, style)) {
- assign_math_style(L,3,subtype(n));
+ assign_math_style(L,3,subtype(n));
//subtype(n) = (quarterword) luaL_checkoption(L, 3, "text", math_style_names); /* not 2? */
} else {
/* return nodelib_cantset(L, n, s); */
@@ -5029,10 +5093,12 @@ static int lua_nodelib_fast_setfield(lua_State * L)
subscr(n) = nodelib_getlist(L, 3);
} else if (lua_key_eq(s, sup)) {
supscr(n) = nodelib_getlist(L, 3);
- } else if (lua_key_eq(s, accent)) {
- accent_chr(n) = nodelib_getlist(L, 3);
+ } else if ((lua_key_eq(s, top_accent))||(lua_key_eq(s, accent))) {
+ top_accent_chr(n) = nodelib_getlist(L, 3);
} else if (lua_key_eq(s, bot_accent)) {
bot_accent_chr(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, overlay_accent)) {
+ overlay_accent_chr(n) = nodelib_getlist(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -5148,30 +5214,6 @@ static int lua_nodelib_fast_setfield(lua_State * L)
} else {
return nodelib_cantset(L, n, s);
}
- } else if (t == action_node) {
- if (lua_key_eq(s, subtype)) {
- /* dummy subtype */
- } else if (lua_key_eq(s, action_type)) {
- pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, named_id)) {
- pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, action_id)) {
- if (pdf_action_named_id(n) == 1) {
- pdf_action_id(n) = nodelib_gettoks(L, 3);
- } else {
- pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
- }
- } else if (lua_key_eq(s, file)) {
- pdf_action_file(n) = nodelib_gettoks(L, 3);
- } else if (lua_key_eq(s, new_window)) {
- pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, data)) {
- pdf_action_tokens(n) = nodelib_gettoks(L, 3);
- /* } else if (lua_key_eq(s, ref_count)) {
- pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
- } else {
- return nodelib_cantset(L, n, s);
- }
} else if (t == unset_node) {
if (lua_key_eq(s, subtype)) {
/* dummy subtype */
@@ -5204,6 +5246,14 @@ static int lua_nodelib_fast_setfield(lua_State * L)
} else {
return nodelib_cantset(L, n, s);
}
+ } else if (t == boundary_node) {
+ if (lua_key_eq(s, subtype)) {
+ subtype(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, value)) {
+ boundary_value(n) = lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
} else {
return luaL_error(L, "You can't assign to this %s node (%d)\n", node_data[t].name, n);
}
@@ -5236,19 +5286,7 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
int t ;
t = subtype(n);
- if (t == dir_node) {
- if (lua_key_eq(s, dir)) {
- dir_dir(n) = nodelib_getdir(L, 3, 0);
- } else if (lua_key_eq(s, level)) {
- dir_level(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dvi_ptr)) {
- dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dir_h)) {
- dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == pdf_literal_node) {
+ if (t == pdf_literal_node) {
if (lua_key_eq(s, mode)) {
pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, data)) {
@@ -5369,50 +5407,6 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
} else {
return nodelib_cantset(L, n, s);
}
- } else if (t == pdf_refxform_node) {
- if (lua_key_eq(s, width)) {
- width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, depth)) {
- depth(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, height)) {
- height(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, objnum)) {
- pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == pdf_refximage_node) {
- if (lua_key_eq(s, width)) {
- width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, depth)) {
- depth(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, height)) {
- height(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, transform)) {
- pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, index)) {
- pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
- } else if (t == local_par_node) {
- if (lua_key_eq(s, pen_inter)) {
- local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, pen_broken)) {
- local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, dir)) {
- local_par_dir(n) = nodelib_getdir(L, 3, 1);
- } else if (lua_key_eq(s, box_left)) {
- local_box_left(n) = nodelib_getlist(L, 3);
- } else if (lua_key_eq(s, box_left_width)) {
- local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, box_right)) {
- local_box_right(n) = nodelib_getlist(L, 3);
- } else if (lua_key_eq(s, box_right_width)) {
- local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
- } else {
- return nodelib_cantset(L, n, s);
- }
} else if (t == pdf_start_link_node) {
if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -5447,6 +5441,28 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
} else {
return nodelib_cantset(L, n, s);
}
+ } else if (t == pdf_action_node) {
+ if (lua_key_eq(s, action_type)) {
+ pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, named_id)) {
+ pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, action_id)) {
+ if (pdf_action_named_id(n) == 1) {
+ pdf_action_id(n) = nodelib_gettoks(L, 3);
+ } else {
+ pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
+ }
+ } else if (lua_key_eq(s, file)) {
+ pdf_action_file(n) = nodelib_gettoks(L, 3);
+ } else if (lua_key_eq(s, new_window)) {
+ pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, data)) {
+ pdf_action_tokens(n) = nodelib_gettoks(L, 3);
+ /* } else if (lua_key_eq(s, ref_count)) {
+ pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
} else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -5492,7 +5508,7 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
return nodelib_cantset(L, n, s);
}
} else if ((t == pdf_end_link_node) || (t == pdf_end_thread_node) || (t == save_pos_node) ||
- (t == pdf_save_node) || (t == pdf_restore_node) || (t == cancel_boundary_node)) {
+ (t == pdf_save_node) || (t == pdf_restore_node)) {
return nodelib_cantset(L, n, s);
} else {
/* do nothing */
@@ -5661,7 +5677,7 @@ static int lua_nodelib_direct_setfield(lua_State * L)
/*if (lua_key_eq(s, id)) {
type(n) = (quarteword) lua_tointeger(L, 3);
- } else*/
+ } else*/
if (lua_key_eq(s, next)) {
halfword x = nodelib_popdirect(3);
if (x>0 && type(x) == glue_spec_node) {
@@ -5753,11 +5769,28 @@ static int lua_nodelib_direct_setfield(lua_State * L)
glue_ptr(n) = nodelib_popdirect(3);
} else if (lua_key_eq(s, leader)) {
leader_ptr(n) = nodelib_popdirect(3);
+ } else if (lua_key_eq(s, width)) {
+ nodelib_check_glue_spec(n);
+ width(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, stretch)) {
+ nodelib_check_glue_spec(n);
+ stretch(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, shrink)) {
+ nodelib_check_glue_spec(n);
+ shrink(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, stretch_order)) {
+ nodelib_check_glue_spec(n);
+ stretch_order(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, shrink_order)) {
+ nodelib_check_glue_spec(n);
+ shrink_order(n) = (quarterword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
} else if (t == glue_spec_node) {
- if (lua_key_eq(s, subtype)) {
+ if (!valid_node(n)) {
+ return nodelib_nonwritable(L, n, s);
+ } else if (lua_key_eq(s, subtype)) {
subtype(n) = (quarterword) lua_tointeger(L, 3); /* dummy, the only one that prevents move up */
} else if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_tointeger(L, 3);
@@ -5769,10 +5802,6 @@ static int lua_nodelib_direct_setfield(lua_State * L)
stretch_order(n) = (quarterword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, shrink_order)) {
shrink_order(n) = (quarterword) lua_tointeger(L, 3);
- /* } else if (lua_key_eq(s, ref_count)) {
- glue_ref_count(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, writable)) {
- */
} else {
return nodelib_cantset(L, n, s);
}
@@ -5805,15 +5834,49 @@ static int lua_nodelib_direct_setfield(lua_State * L)
depth(n) = (halfword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, dir)) {
rule_dir(n) = nodelib_getdir(L, 3, 1);
+ } else if (lua_key_eq(s, index)) {
+ rule_index(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, transform)) {
+ rule_transform(n) = (halfword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
- } else if (t == whatsit_node) {
+ } else if (t == dir_node) {
+ if (lua_key_eq(s, dir)) {
+ dir_dir(n) = nodelib_getdir(L, 3, 0);
+ } else if (lua_key_eq(s, level)) {
+ dir_level(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dvi_ptr)) {
+ dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dir_h)) {
+ dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
+ } else if (t == whatsit_node) {
if (lua_key_eq(s, subtype)) {
subtype(n) = (quarterword) lua_tointeger(L, 3);
} else {
lua_nodelib_direct_setfield_whatsit(L, n, s);
}
+ } else if (t == local_par_node) {
+ if (lua_key_eq(s, pen_inter)) {
+ local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, pen_broken)) {
+ local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, dir)) {
+ local_par_dir(n) = nodelib_getdir(L, 3, 1);
+ } else if (lua_key_eq(s, box_left)) {
+ local_box_left(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, box_left_width)) {
+ local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, box_right)) {
+ local_box_right(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, box_right_width)) {
+ local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
} else if (t == simple_noad) {
if (lua_key_eq(s, subtype)) {
subtype(n) = (quarterword) lua_tointeger(L, 3);
@@ -5890,7 +5953,7 @@ static int lua_nodelib_direct_setfield(lua_State * L)
if (lua_key_eq(s, subtype)) {
/* dummy subtype */
} else if (lua_key_eq(s, style)) {
- assign_math_style(L,2,subtype(n));
+ assign_math_style(L,2,subtype(n));
//subtype(n) = (quarterword) luaL_checkoption(L, 2, "text", math_style_names); /* was 3 */
} else {
/* return nodelib_cantset(L, n, s); */
@@ -5904,10 +5967,12 @@ static int lua_nodelib_direct_setfield(lua_State * L)
subscr(n) = nodelib_popdirect(3);
} else if (lua_key_eq(s, sup)) {
supscr(n) = nodelib_popdirect(3);
- } else if (lua_key_eq(s, accent)) {
- accent_chr(n) = nodelib_popdirect(3);
+ } else if ((lua_key_eq(s, top_accent))||(lua_key_eq(s, accent))) {
+ top_accent_chr(n) = nodelib_popdirect(3);
} else if (lua_key_eq(s, bot_accent)) {
bot_accent_chr(n) = nodelib_popdirect(3);
+ } else if (lua_key_eq(s, overlay_accent)) {
+ overlay_accent_chr(n) = nodelib_popdirect(3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -6023,30 +6088,6 @@ static int lua_nodelib_direct_setfield(lua_State * L)
} else {
return nodelib_cantset(L, n, s);
}
- } else if (t == action_node) {
- if (lua_key_eq(s, subtype)) {
- /* dummy subtype */
- } else if (lua_key_eq(s, action_type)) {
- pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, named_id)) {
- pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, action_id)) {
- if (pdf_action_named_id(n) == 1) {
- pdf_action_id(n) = nodelib_gettoks(L, 3);
- } else {
- pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
- }
- } else if (lua_key_eq(s, file)) {
- pdf_action_file(n) = nodelib_gettoks(L, 3);
- } else if (lua_key_eq(s, new_window)) {
- pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
- } else if (lua_key_eq(s, data)) {
- pdf_action_tokens(n) = nodelib_gettoks(L, 3);
- /* } else if (lua_key_eq(s, ref_count)) {
- pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
- } else {
- return nodelib_cantset(L, n, s);
- }
} else if (t == unset_node) {
if (lua_key_eq(s, subtype)) {
/* dummy subtype */
@@ -6079,6 +6120,14 @@ static int lua_nodelib_direct_setfield(lua_State * L)
} else {
return nodelib_cantset(L, n, s);
}
+ } else if (t == boundary_node) {
+ if (lua_key_eq(s, subtype)) {
+ subtype(n) = (quarterword) lua_tointeger(L, 3);
+ } else if (lua_key_eq(s, value)) {
+ boundary_value(n) = lua_tointeger(L, 3);
+ } else {
+ return nodelib_cantset(L, n, s);
+ }
} else {
return luaL_error(L, "You can't assign to this %s node (%d)\n", node_data[t].name, n);
}
@@ -6164,7 +6213,7 @@ static int lua_nodelib_direct_setbox(lua_State * L)
{
int isglobal = 0;
int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
+ if (n == 3 && (lua_type(L, 1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
if (lua_key_eq(s, global))
isglobal = 1;
@@ -6245,7 +6294,7 @@ static int lua_nodelib_attributes_to_table(lua_State * L) // hh
{ // <node|direct>
halfword n;
register halfword attribute;
- if (lua_isnumber(L,1)) {
+ if (lua_type(L,1) == LUA_TNUMBER) {
n = lua_tonumber(L,1);
} else {
n = *((halfword *) lua_touserdata(L, 1));
@@ -6279,7 +6328,7 @@ static int lua_nodelib_attributes_to_properties(lua_State * L)
{ // <node|direct>
halfword n;
register halfword attribute;
- if (lua_isnumber(L,1)) {
+ if (lua_type(L,1) == LUA_TNUMBER) {
n = lua_tonumber(L,1);
} else {
n = *((halfword *) lua_touserdata(L, 1));
@@ -6454,7 +6503,7 @@ static int lua_nodelib_set_property_t(lua_State * L) /* hh */
/* extra helpers */
-static int lua_nodelib_effective_glue(lua_State * L)
+static int lua_nodelib_effective_glue(lua_State * L)
{
halfword *glue;
halfword *parent;
@@ -6484,7 +6533,7 @@ static int lua_nodelib_effective_glue(lua_State * L)
}
-static int lua_nodelib_direct_effective_glue(lua_State * L)
+static int lua_nodelib_direct_effective_glue(lua_State * L)
{
halfword glue;
halfword parent;
@@ -6636,6 +6685,7 @@ static const struct luaL_Reg nodelib_f[] = {
{"end_of_math", lua_nodelib_end_of_math},
{"family_font", lua_nodelib_mfont},
{"fields", lua_nodelib_fields},
+ {"subtypes", lua_nodelib_subtypes},
{"first_character", lua_nodelib_first_character},
{"first_glyph", lua_nodelib_first_glyph},
{"flush_list", lua_nodelib_flush_list},
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index 71580145ba7..b1dca1b5c1e 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -20,6 +20,7 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
+#include "pdf/pdftables.h"
static int luapdfprint(lua_State * L)
{
@@ -29,52 +30,49 @@ static int luapdfprint(lua_State * L)
ctm_transform_modes literal_mode;
st.s = modestr_s = NULL;
n = lua_gettop(L);
- if (!lua_isstring(L, -1)) {
+ if (!lua_isstring(L, -1)) { /* or number */
luaL_error(L, "no string to print");
}
literal_mode = set_origin;
if (n == 2) {
- if (!lua_isstring(L, -2)) {
- luaL_error(L, "invalid argument for print literal mode");
+ if (lua_type(L,-2) != LUA_TSTRING) {
+ luaL_error(L, "invalid first argument for print literal mode");
} else {
- modestr_s = lua_tostring(L, -2);
- if (lua_key_eq(modestr_s,direct))
- literal_mode = direct_always;
- else if (lua_key_eq(modestr_s,page))
+ modestr_s = lua_tostring(L, -2);
+ if (lua_key_eq(modestr_s,direct))
+ literal_mode = direct_always;
+ else if (lua_key_eq(modestr_s,page))
literal_mode = direct_page;
else {
- luaL_error(L, "invalid argument for print literal mode");
+ luaL_error(L, "invalid first argument for print literal mode");
}
}
- } else {
- if (n != 1) {
- luaL_error(L, "invalid number of arguments");
- }
+ } else if (n != 1) {
+ luaL_error(L, "invalid number of arguments");
}
check_o_mode(static_pdf, "pdf.print()", 1 << OMODE_PDF, true);
switch (literal_mode) {
- case (set_origin):
- pdf_goto_pagemode(static_pdf);
- pdf_set_pos(static_pdf, static_pdf->posstruct->pos);
- (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos);
- break;
- case (direct_page):
- pdf_goto_pagemode(static_pdf);
- (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos);
- break;
- case (direct_always):
- pdf_end_string_nl(static_pdf);
- break;
- default:
- assert(0);
+ case (set_origin):
+ pdf_goto_pagemode(static_pdf);
+ pdf_set_pos(static_pdf, static_pdf->posstruct->pos);
+ (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos);
+ break;
+ case (direct_page):
+ pdf_goto_pagemode(static_pdf);
+ (void) calc_pdfpos(static_pdf->pstruct, static_pdf->posstruct->pos);
+ break;
+ case (direct_always):
+ pdf_end_string_nl(static_pdf);
+ break;
+ default:
+ assert(0);
}
st.s = lua_tolstring(L, n, &st.l);
pdf_out_block(static_pdf, st.s, st.l);
return 0;
}
-static unsigned char *fread_to_buf(lua_State * L, const char *filename,
- size_t * len)
+static unsigned char *fread_to_buf(lua_State * L, const char *filename, size_t * len)
{
int ilen = 0;
FILE *f;
@@ -100,7 +98,7 @@ static int l_immediateobj(lua_State * L)
if (global_shipping_mode != NOT_SHIPPING)
luaL_error(L, "pdf.immediateobj() can not be used with \\latelua");
n = lua_gettop(L);
- if (n > 0 && lua_type(L, 1) == LUA_TNUMBER) {
+ if ((n > 0) && (lua_type(L, 1) == LUA_TNUMBER)) {
first_arg++;
k=(int)lua_tonumber(L, 1);
check_obj_type(static_pdf, obj_type_obj, k);
@@ -112,69 +110,61 @@ static int l_immediateobj(lua_State * L)
}
pdf_last_obj = k;
switch (n - first_arg + 1) {
- case 0:
- luaL_error(L, "pdf.immediateobj() needs at least one argument");
- break;
- case 1:
- if (!lua_isstring(L, first_arg))
- luaL_error(L, "pdf.immediateobj() 1st argument must be string");
- pdf_begin_obj(static_pdf, k, OBJSTM_ALWAYS);
- st1.s = lua_tolstring(L, first_arg, &st1.l);
- pdf_out_block(static_pdf, st1.s, st1.l);
- /* already in pdf_end_obj:
- if (st1.s[st1.l - 1] != '\n')
- pdf_out(static_pdf, '\n');
- */
- pdf_end_obj(static_pdf);
- break;
- case 2:
- case 3:
- if (!lua_isstring(L, first_arg))
- luaL_error(L, "pdf.immediateobj() 1st argument must be string");
- if (!lua_isstring(L, first_arg + 1))
- luaL_error(L, "pdf.immediateobj() 2nd argument must be string");
- st1_s = lua_tostring(L, first_arg);
- st2.s = lua_tolstring(L, first_arg + 1, &st2.l);
- if (lua_key_eq(st1_s, file)) {
- if (n == first_arg + 2)
- luaL_error(L, "pdf.immediateobj() 3rd argument forbidden in file mode");
+ case 0:
+ luaL_error(L, "pdf.immediateobj() needs at least one argument");
+ break;
+ case 1:
+ if (!lua_isstring(L, first_arg)) /* or number */
+ luaL_error(L, "pdf.immediateobj() 1st argument must be string");
pdf_begin_obj(static_pdf, k, OBJSTM_ALWAYS);
- buf.s = fread_to_buf(L, st2.s, &buf.l);
- pdf_out_block(static_pdf, (const char *) buf.s, buf.l);
- /* already in pdf_end_obj:
- if (buf.s[buf.l - 1] != '\n')
- pdf_out(static_pdf, '\n');
- */
- xfree(buf.s);
+ st1.s = lua_tolstring(L, first_arg, &st1.l);
+ pdf_out_block(static_pdf, st1.s, st1.l);
pdf_end_obj(static_pdf);
- } else {
- pdf_begin_obj(static_pdf, k, OBJSTM_NEVER); /* not an object stream candidate! */
- pdf_begin_dict(static_pdf);
- if (n == first_arg + 2) { /* write attr text */
- if (!lua_isstring(L, first_arg + 2))
- luaL_error(L, "pdf.immediateobj() 3rd argument must be string");
- st3.s = lua_tolstring(L, first_arg + 2, &st3.l);
- pdf_out_block(static_pdf, st3.s, st3.l);
- if (st3.s[st3.l - 1] != '\n')
- pdf_out(static_pdf, '\n');
- }
- pdf_dict_add_streaminfo(static_pdf);
- pdf_end_dict(static_pdf);
- pdf_begin_stream(static_pdf);
- if (lua_key_eq(st1_s, stream)) {
- pdf_out_block(static_pdf, st2.s, st2.l);
- } else if (lua_key_eq(st1_s, streamfile)) {
+ break;
+ case 2:
+ case 3:
+ if (lua_type(L,first_arg) != LUA_TSTRING)
+ luaL_error(L, "pdf.immediateobj() 1st argument must be string");
+ if (!lua_isstring(L, first_arg + 1)) /* or number */
+ luaL_error(L, "pdf.immediateobj() 2nd argument must be string");
+ st1_s = lua_tostring(L, first_arg);
+ st2.s = lua_tolstring(L, first_arg + 1, &st2.l);
+ if (lua_key_eq(st1_s, file)) {
+ if (n == first_arg + 2)
+ luaL_error(L, "pdf.immediateobj() 3rd argument forbidden in file mode");
+ pdf_begin_obj(static_pdf, k, OBJSTM_ALWAYS);
buf.s = fread_to_buf(L, st2.s, &buf.l);
pdf_out_block(static_pdf, (const char *) buf.s, buf.l);
xfree(buf.s);
- } else
- luaL_error(L, "pdf.immediateobj() invalid argument");
- pdf_end_stream(static_pdf);
- pdf_end_obj(static_pdf);
- }
- break;
- default:
- luaL_error(L, "pdf.immediateobj() allows max. 3 arguments");
+ pdf_end_obj(static_pdf);
+ } else {
+ pdf_begin_obj(static_pdf, k, OBJSTM_NEVER); /* not an object stream candidate! */
+ pdf_begin_dict(static_pdf);
+ if (n == first_arg + 2) { /* write attr text */
+ if (!lua_isstring(L, first_arg + 2)) /* or number (maybe only string as it's an attr) */
+ luaL_error(L, "pdf.immediateobj() 3rd argument must be string");
+ st3.s = lua_tolstring(L, first_arg + 2, &st3.l);
+ pdf_out_block(static_pdf, st3.s, st3.l);
+ if (st3.s[st3.l - 1] != '\n')
+ pdf_out(static_pdf, '\n');
+ }
+ pdf_dict_add_streaminfo(static_pdf);
+ pdf_end_dict(static_pdf);
+ pdf_begin_stream(static_pdf);
+ if (lua_key_eq(st1_s, stream)) {
+ pdf_out_block(static_pdf, st2.s, st2.l);
+ } else if (lua_key_eq(st1_s, streamfile)) {
+ buf.s = fread_to_buf(L, st2.s, &buf.l);
+ pdf_out_block(static_pdf, (const char *) buf.s, buf.l);
+ xfree(buf.s);
+ } else
+ luaL_error(L, "pdf.immediateobj() invalid argument");
+ pdf_end_stream(static_pdf);
+ pdf_end_obj(static_pdf);
+ }
+ break;
+ default:
+ luaL_error(L, "pdf.immediateobj() allows max. 3 arguments");
}
lua_pushinteger(L, k);
return 1;
@@ -193,23 +183,16 @@ static int table_obj(lua_State * L)
attr.s = st.s = NULL;
attr.l = 0;
assert(lua_istable(L, 1)); /* t */
-
- /* get object "type" */
-
lua_key_rawgeti(type);
if (lua_isnil(L, -1)) /* !vs t */
luaL_error(L, "pdf.obj(): object \"type\" missing");
- if (!lua_isstring(L, -1)) /* !vs t */
+ if (lua_type(L,-1) != LUA_TSTRING) /* !vs t */
luaL_error(L, "pdf.obj(): object \"type\" must be string");
type = lua_tostring(L, -1);
-
if (! (lua_key_eq(type, raw) || lua_key_eq(type, stream))) {
luaL_error(L, "pdf.obj(): \"%s\" is not a valid object type", type); /* i vs t */
}
lua_pop(L, 1); /* t */
-
- /* get optional "immediate" */
-
lua_key_rawgeti(immediate);
if (!lua_isnil(L, -1)) { /* b? t */
if (!lua_isboolean(L, -1)) /* !b t */
@@ -222,7 +205,7 @@ static int table_obj(lua_State * L)
lua_key_rawgeti(objnum);
if (!lua_isnil(L, -1)) { /* vi? t */
- if (!lua_isnumber(L, -1)) /* !vi t */
+ if (lua_type(L,-1) != LUA_TNUMBER) /* !vi t */
luaL_error(L, "pdf.obj(): \"objnum\" must be integer");
k = (int) lua_tointeger(L, -1); /* vi t */
check_obj_type(static_pdf, obj_type_obj, k);
@@ -245,7 +228,7 @@ static int table_obj(lua_State * L)
if (!lua_isnil(L, -1)) { /* attr-s? t */
if (! lua_key_eq(type, stream))
luaL_error(L, "pdf.obj(): \"attr\" key not allowed for non-stream object");
- if (!lua_isstring(L, -1)) /* !attr-s t */
+ if (!lua_isstring(L, -1)) /* or number */ /* !attr-s t */
luaL_error(L, "pdf.obj(): object \"attr\" must be string");
if (immediate == 1) {
attr.s = lua_tolstring(L, -1, &attr.l); /* attr-s t */
@@ -262,7 +245,7 @@ static int table_obj(lua_State * L)
if (!lua_isnil(L, -1)) { /* vi? t */
if (lua_key_eq(type, raw))
luaL_error(L, "pdf.obj(): \"compresslevel\" key not allowed for raw object");
- if (!lua_isnumber(L, -1)) /* !vi t */
+ if (lua_type(L, -1) != LUA_TNUMBER) /* !vi t */
luaL_error(L, "pdf.obj(): \"compresslevel\" must be integer");
compress_level = (int) lua_tointeger(L, -1); /* vi t */
if (compress_level > 9)
@@ -309,20 +292,16 @@ static int table_obj(lua_State * L)
if (!lua_isnil(L, -2)) { /* file-s? string-s? t */
/* from string */
lua_pop(L, 1); /* string-s? t */
- if (!lua_isstring(L, -1)) /* !string-s t */
+ if (!lua_isstring(L, -1)) /* or number */ /* !string-s t */
luaL_error(L, "pdf.obj(): \"string\" must be string for raw object");
if (immediate == 1) {
st.s = lua_tolstring(L, -1, &st.l);
pdf_out_block(static_pdf, st.s, st.l);
- /* already in pdf_end_obj:
- if (st.s[st.l - 1] != '\n')
- pdf_out(static_pdf, '\n');
- */
} else
obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* t */
} else {
/* from file */
- if (!lua_isstring(L, -1)) /* !file-s nil t */
+ if (lua_type(L, -1) != LUA_TSTRING) /* !file-s nil t */
luaL_error(L, "pdf.obj(): \"file\" name must be string for raw object");
if (immediate == 1) {
st.s = lua_tolstring(L, -1, &st.l); /* file-s nil t */
@@ -362,7 +341,7 @@ static int table_obj(lua_State * L)
if (!lua_isnil(L, -2)) { /* file-s? string-s? t */
/* from string */
lua_pop(L, 1); /* string-s? t */
- if (!lua_isstring(L, -1)) /* !string-s t */
+ if (!lua_isstring(L, -1)) /* or number */ /* !string-s t */
luaL_error(L, "pdf.obj(): \"string\" must be string for stream object");
if (immediate == 1) {
st.s = lua_tolstring(L, -1, &st.l); /* string-s t */
@@ -371,7 +350,7 @@ static int table_obj(lua_State * L)
obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); /* t */
} else {
/* from file */
- if (!lua_isstring(L, -1)) /* !file-s nil t */
+ if (lua_type(L, -1) != LUA_TSTRING) /* !file-s nil t */
luaL_error(L, "pdf.obj(): \"file\" name must be string for stream object");
if (immediate == 1) {
st.s = lua_tolstring(L, -1, &st.l); /* file-s nil t */
@@ -398,7 +377,7 @@ static int orig_obj(lua_State * L)
int k;
const char *st_s = NULL ;
n = lua_gettop(L);
- if (n > 0 && lua_type(L, 1) == LUA_TNUMBER) {
+ if ((n > 0) && (lua_type(L, 1) == LUA_TNUMBER)) {
first_arg++;
k=(int)lua_tonumber(L, 1);
check_obj_type(static_pdf, obj_type_obj, k);
@@ -416,14 +395,14 @@ static int orig_obj(lua_State * L)
luaL_error(L, "pdf.obj() needs at least one argument");
break;
case 1:
- if (!lua_isstring(L, first_arg))
+ if (!lua_isstring(L, first_arg)) /* or number */
luaL_error(L, "pdf.obj() 1st argument must be string");
break;
case 2:
case 3:
- if (!lua_isstring(L, first_arg))
+ if (lua_type(L, first_arg) != LUA_TSTRING)
luaL_error(L, "pdf.obj() 1st argument must be string");
- if (!lua_isstring(L, first_arg + 1))
+ if (!lua_isstring(L, first_arg + 1)) /* or number */
luaL_error(L, "pdf.obj() 2nd argument must be string");
st_s = lua_tostring(L, first_arg);
if (lua_key_eq(st_s, file)) {
@@ -432,7 +411,7 @@ static int orig_obj(lua_State * L)
set_obj_obj_is_file(static_pdf, k);
} else {
if (n == first_arg + 2) { /* write attr text */
- if (!lua_isstring(L, -1))
+ if (!lua_isstring(L, -1)) /* or number */
luaL_error(L, "pdf.obj() 3rd argument must be string");
obj_obj_stream_attr(static_pdf, k) =
luaL_ref(Luas, LUA_REGISTRYINDEX);
@@ -488,11 +467,10 @@ static int l_reserveobj(lua_State * L)
switch (n) {
case 0:
static_pdf->obj_count++;
- pdf_last_obj =
- pdf_create_obj(static_pdf, obj_type_obj, static_pdf->obj_ptr + 1);
+ pdf_last_obj = pdf_create_obj(static_pdf, obj_type_obj, static_pdf->obj_ptr + 1);
break;
case 1:
- if (!lua_isstring(L, -1))
+ if (lua_type(L, -1) != LUA_TSTRING)
luaL_error(L, "pdf.reserveobj() optional argument must be string");
st_s = luaL_checkstring(L, 1);
if (lua_key_eq(st_s, annot)) {
@@ -538,6 +516,7 @@ static int l_get_pdf_value(lua_State * L, int key)
lua_rawget(L,-2);
return 1;
}
+
static int l_get_pageresources(lua_State * L) {
return l_get_pdf_value(L,lua_key_index(pageresources));
}
@@ -556,12 +535,25 @@ static int l_get_info(lua_State * L) {
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));
+}
+# define valid_pdf_key ( \
+ lua_key_eq(s,catalog) || \
+ lua_key_eq(s,info) || \
+ lua_key_eq(s,trailer) || \
+ lua_key_eq(s,names) || \
+ lua_key_eq(s,pageattributes) || \
+ lua_key_eq(s,pagesattributes) || \
+ lua_key_eq(s,pageresources) \
+)
static int getpdf(lua_State * L)
{
@@ -570,36 +562,30 @@ static int getpdf(lua_State * L)
if (lua_gettop(L) != 2) {
return 0;
}
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
s = lua_tostring(L, -1);
if (lua_key_eq(s,h)) {
lua_pushnumber(L, static_pdf->posstruct->pos.h);
- return 1;
+ return 1;
} else if (lua_key_eq(s,v)) {
lua_pushnumber(L, static_pdf->posstruct->pos.v);
- return 1;
- } else if (
- lua_key_eq(s,catalog) || lua_key_eq(s,info) || lua_key_eq(s,trailer) || lua_key_eq(s,names) ||
- lua_key_eq(s,pageattributes) || lua_key_eq(s,pagesattributes) || lua_key_eq(s,pageresources)
- ) {
+ return 1;
+ } else if (valid_pdf_key) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(pdf_data));
lua_gettable(L, LUA_REGISTRYINDEX);
/* [pdf table] [key] [pdf.data table] */
lua_replace(L, -3);
/* [pdf.data table] [key] */
- lua_rawget(L, -2);
- return 1;
+ lua_rawget(L, -2);
+ return 1;
}
}
return 0;
}
-
-
-
static int l_set_pdf_value(lua_State * L, int key)
{
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
/* [value] */
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(pdf_data));
lua_gettable(L, LUA_REGISTRYINDEX);
@@ -612,6 +598,7 @@ static int l_set_pdf_value(lua_State * L, int key)
}
return 0;
}
+
static int l_set_pageresources(lua_State * L) {
return l_set_pdf_value(L,lua_key_index(pageresources));
}
@@ -633,7 +620,12 @@ static int l_set_names(lua_State * L) {
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 setpdf(lua_State * L)
{
@@ -642,12 +634,9 @@ static int setpdf(lua_State * L)
if (lua_gettop(L) != 3) {
return 0;
}
- if (lua_isstring(L, -2)) {
- s = lua_tostring(L, -1);
- if (
- lua_key_eq(s,catalog) || lua_key_eq(s,info) || lua_key_eq(s,trailer) || lua_key_eq(s,names) ||
- lua_key_eq(s,pageattributes) || lua_key_eq(s,pagesattributes) || lua_key_eq(s,pageresources)
- ) {
+ 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);
/* [pdf table] [key] [value] [pdf.data table] */
@@ -659,7 +648,6 @@ static int setpdf(lua_State * L)
return 0;
}
-
static int l_objtype(lua_State * L)
{
int n = lua_gettop(L);
@@ -686,7 +674,7 @@ static int l_mapfile(lua_State * L)
{
char *s;
const char *st;
- if (lua_isstring(L, -1) && (st = lua_tostring(L, -1)) != NULL) {
+ if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) {
s = xstrdup(st);
process_map_item(s, MAPFILE);
free(s);
@@ -698,7 +686,7 @@ static int l_mapline(lua_State * L)
{
char *s;
const char *st;
- if (lua_isstring(L, -1) && (st = lua_tostring(L, -1)) != NULL) {
+ if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) {
s = xstrdup(st);
process_map_item(s, MAPLINE);
free(s);
@@ -765,43 +753,264 @@ static int l_hasmatrix(lua_State * L)
return 1 ;
}
+static int l_get_lastlink(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_last_link));
+ return 1 ;
+}
+
+static int l_get_retval(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_retval));
+ return 1 ;
+}
+
+static int l_get_lastobj(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_last_obj));
+ return 1 ;
+}
+
+static int l_get_lastannot(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_last_annot));
+ return 1 ;
+}
+
+/* maybe:
+
+ get_fontname : set_ff(i) obj_info(static_pdf, pdf_font_num(ff))
+ get_fontobjnum : set_ff(i) pdf_font_num(ff)
+ get_fontsize : font_size(i)
+ get_xformname : obj_info(static_pdf, i)
+
+*/
+
+static int l_get_compresslevel(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_compress_level));
+ return 1 ;
+}
+
+static int l_get_objcompresslevel(lua_State * L)
+{
+ lua_pushnumber(L, (pdf_objcompresslevel));
+ return 1 ;
+}
+
+static int l_set_compresslevel(lua_State * L)
+{
+ int c ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ if (c<0)
+ c = 0 ;
+ else if (c>9)
+ c = 9 ;
+ set_pdf_objcompresslevel(c);
+ }
+ return 0 ;
+}
+
+static int l_set_objcompresslevel(lua_State * L)
+{
+ int c ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ if (c<0)
+ c = 0 ;
+ else if (c>9)
+ c = 9 ;
+ set_pdf_compress_level(c);
+ }
+ return 0 ;
+}
+
+/* pdf stuff */
+
+static int getpdffontname(lua_State * L)
+{
+ int c, ff ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ pdf_check_vf(c);
+ if (!font_used(c))
+ pdf_init_font(static_pdf,c);
+ set_ff(c);
+ lua_pushnumber(L, (obj_info(static_pdf, pdf_font_num(ff))));
+ } else {
+ lua_pushnil(L);
+ }
+ return 1 ;
+}
+
+static int getpdffontobjnum(lua_State * L)
+{
+ int c, ff ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ pdf_check_vf(c);
+ if (!font_used(c))
+ pdf_init_font(static_pdf,c);
+ set_ff(c);
+ lua_pushnumber(L, (pdf_font_num(ff)));
+ } else {
+ lua_pushnil(L);
+ }
+ return 1 ;
+}
+
+static int getpdffontsize(lua_State * L)
+{
+ int c;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ lua_pushnumber(L, (font_size(c)));
+ } else {
+ lua_pushnil(L);
+ }
+ return 1 ;
+}
+
+static int getpdfpageref(lua_State * L)
+{
+ int c ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ lua_pushnumber(L, (pdf_get_obj(static_pdf, obj_type_page, c, false)));
+ } else {
+ lua_pushnil(L);
+ }
+ return 1 ;
+}
+
+static int getpdfxformname(lua_State * L)
+{
+ int c ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ check_obj_type(static_pdf, obj_type_xform, c);
+ lua_pushnumber(L, (obj_info(static_pdf, c)));
+ } else {
+ lua_pushnil(L);
+ }
+ return 1 ;
+}
+
+static int getpdfversion(lua_State * L)
+{
+ lua_pushnumber(L,1);
+ return 1 ;
+}
+
+static int getpdfminorversion(lua_State * L)
+{
+ /* lua_pushnumber(L,static_pdf->minor_version); */
+ lua_pushnumber(L,pdf_minor_version);
+ return 1 ;
+}
+
+static int setpdfminorversion(lua_State * L)
+{
+ int c ;
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ c = (int) lua_tointeger(L, 1);
+ if ((c >= 0) && (c <= 9)) {
+ static_pdf->minor_version = c;
+ set_pdf_minor_version(c);
+ }
+ }
+ return 0 ;
+}
+
+static int newpdfcolorstack(lua_State * L)
+{
+ const char *s = NULL;
+ const char *l = NULL;
+ int literal_mode = 0; /* set_origin */
+ boolean page_start = false;
+ int id ;
+ if (lua_type(L,1) != LUA_TSTRING) {
+ luaL_error(L, "pdf.newcolorstack() expects a string as first argument");
+ }
+ s = lua_tostring(L, 1);
+ if (lua_type(L,2) == LUA_TSTRING) {
+ l = lua_tostring(L, 2);
+ if (lua_key_eq(l,origin)) {
+ literal_mode = 0;
+ } else if (lua_key_eq(l,page)) {
+ literal_mode = 1; /* direct_page */
+ } else if (lua_key_eq(l,direct)) {
+ literal_mode = 2; /* direct_always */
+ } else {
+ luaL_error(L, "invalid literal mode in pdf.newcolorstack()");
+ }
+ }
+ if (lua_isboolean(L, 3)) {
+ page_start = lua_toboolean(L, 3);
+ }
+ id = newcolorstack(s, literal_mode, page_start);
+ lua_pushnumber(L, id);
+ return 1 ;
+}
static const struct luaL_Reg pdflib[] = {
- {"immediateobj", l_immediateobj},
- {"mapfile", l_mapfile},
- {"mapline", l_mapline},
- {"maxobjnum", l_maxobjnum},
- {"obj", l_obj},
- {"objtype", l_objtype},
- {"pageref", l_pageref},
- {"print", luapdfprint},
- {"refobj", l_refobj},
- {"registerannot", l_registerannot},
- {"reserveobj", l_reserveobj},
- {"getpos", l_getpos},
- {"gethpos", l_gethpos},
- {"getvpos", l_getvpos},
- {"getmatrix", l_getmatrix},
- {"hasmatrix", l_hasmatrix},
- {"setcatalog", l_set_catalog},
- {"setinfo", l_set_info},
- {"setnames", l_set_names},
- {"settrailer", l_set_trailer},
- {"setpageresources", l_set_pageresources},
- {"setpageattributes", l_set_pageattributes},
- {"setpagesattributes", l_set_pagesattributes},
- {"getcatalog", l_get_catalog},
- {"getinfo", l_get_info},
- {"getnames", l_get_names},
- {"gettrailer", l_get_trailer},
- {"getpageresources", l_get_pageresources},
- {"getpageattributes", l_get_pageattributes},
- {"getpagesattributes", l_get_pagesattributes},
- {NULL, NULL} /* sentinel */
+ { "immediateobj", l_immediateobj },
+ { "mapfile", l_mapfile },
+ { "mapline", l_mapline },
+ { "maxobjnum", l_maxobjnum },
+ { "obj", l_obj },
+ { "objtype", l_objtype },
+ { "pageref", l_pageref },
+ { "print", luapdfprint },
+ { "refobj", l_refobj },
+ { "registerannot", l_registerannot },
+ { "reserveobj", l_reserveobj },
+ { "getpos", l_getpos },
+ { "gethpos", l_gethpos },
+ { "getvpos", l_getvpos },
+ { "getmatrix", l_getmatrix },
+ { "hasmatrix", l_hasmatrix },
+ { "setcatalog", l_set_catalog },
+ { "setinfo", l_set_info },
+ { "setnames", l_set_names },
+ { "settrailer", l_set_trailer },
+ { "setpageresources", l_set_pageresources },
+ { "setpageattributes", l_set_pageattributes },
+ { "setpagesattributes", l_set_pagesattributes },
+ { "setxformresources", l_set_xformresources },
+ { "setxformattributes", l_set_xformattributes },
+ { "getcatalog", l_get_catalog },
+ { "getinfo", l_get_info },
+ { "getnames", l_get_names },
+ { "gettrailer", l_get_trailer },
+ { "getpageresources", l_get_pageresources },
+ { "getpageattributes", l_get_pageattributes },
+ { "getpagesattributes", l_get_pagesattributes },
+ { "getxformresources", l_get_xformresources },
+ { "getxformattributes", l_get_xformattributes },
+ { "getlastlink", l_get_lastlink },
+ { "getretval", l_get_retval },
+ { "getlastobj", l_get_lastobj },
+ { "getlastannot", l_get_lastannot },
+ { "getcompresslevel", l_get_compresslevel },
+ { "getobjcompresslevel", l_get_objcompresslevel },
+ { "setcompresslevel", l_set_compresslevel },
+ { "setobjcompresslevel", l_set_objcompresslevel },
+ /* moved from tex table */
+ { "fontname", getpdffontname},
+ { "fontobjnum", getpdffontobjnum},
+ { "fontsize", getpdffontsize},
+ { "pageref", getpdfpageref},
+ { "xformname", getpdfxformname},
+ { "getversion", getpdfversion},
+ { "getminorversion", getpdfminorversion},
+ { "setminorversion", setpdfminorversion},
+ { "newcolorstack", newpdfcolorstack},
+ /* sentinel */
+ {NULL, NULL}
};
-/**********************************************************************/
-
int luaopen_pdf(lua_State * L)
{
lua_pushstring(L,"pdf.data");
diff --git a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
index eeb447f5064..74781cbd6af 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
@@ -31,8 +31,6 @@ typedef const char *(*charfunc) (void);
typedef lua_Number(*numfunc) (void);
typedef int (*intfunc) (void);
-const char *last_lua_error;
-
static const char *getbanner(void)
{
return (const char *) luatex_banner;
@@ -43,7 +41,6 @@ static const char *getlogname(void)
return (const char *) texmf_log_name;
}
-
static const char *get_output_file_name(void)
{
if (static_pdf != NULL)
@@ -73,7 +70,20 @@ static const char *getlastluaerror(void)
return last_lua_error;
}
+static const char *getlastwarningtag(void)
+{
+ return last_warning_tag;
+}
+static const char *getlastwarningstr(void)
+{
+ return last_warning_str;
+}
+
+static const char *getlasterrorcontext(void)
+{
+ return last_error_context;
+}
static const char *luatexrevision(void)
{
@@ -189,6 +199,9 @@ static struct statistic stats[] = {
{"lasterrorstring", 'S', (void *) &getlasterror},
{"lastluaerrorstring", 'S', (void *) &getlastluaerror},
+ {"lastwarningtag", 'S', (void *) &getlastwarningtag},
+ {"lastwarningstring", 'S', (void *) &getlastwarningstr},
+ {"lasterrorcontext", 'S', (void *) &getlasterrorcontext},
/* seldom or never accessed */
@@ -240,6 +253,7 @@ static struct statistic stats[] = {
{"param_size", 'g', &param_size},
{"buf_size", 'g', &buf_size},
{"save_size", 'g', &save_size},
+ {"input_ptr", 'g', &input_ptr},
/* pdf stats */
{"obj_ptr", 'N', &get_obj_ptr},
{"obj_tab_size", 'N', &get_obj_tab_size},
@@ -331,7 +345,7 @@ static int getstats(lua_State * L)
{
const char *st;
int i;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
st = lua_tostring(L, -1);
i = stats_name_to_id(st);
if (i >= 0) {
@@ -361,10 +375,22 @@ static int statslist(lua_State * L)
return 1;
}
-
+static int resetmessages(lua_State * L)
+{
+ xfree(last_warning_str);
+ xfree(last_warning_tag);
+ xfree(last_error);
+ xfree(last_lua_error);
+ last_warning_str = NULL;
+ last_warning_tag = NULL;
+ last_error = NULL;
+ last_lua_error = NULL;
+ return 0;
+}
static const struct luaL_Reg statslib[] = {
{"list", statslist},
+ {"resetmessages", resetmessages},
{NULL, NULL} /* sentinel */
};
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c
index 5e4d515a848..2ae5812af22 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c
@@ -1,5 +1,5 @@
/* ltexiolib.c
-
+
Copyright 2006-2010 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -20,29 +20,40 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
-
typedef void (*texio_printer) (const char *);
static char *loggable_info = NULL;
-
static boolean get_selector_value(lua_State * L, int i, int *l)
{
boolean r = false;
- if (lua_isstring(L, i)) {
+ int t = lua_type(L,i);
+ if (t == LUA_TSTRING) {
const char *s = lua_tostring(L, i);
- if (lua_key_eq(s,log)) {
+ if (lua_key_eq(s,term_and_log)) {
+ *l = term_and_log;
+ r = true;
+ } else if (lua_key_eq(s,log)) {
*l = log_only;
r = true;
} else if (lua_key_eq(s,term)) {
*l = term_only;
r = true;
- } else if (lua_key_eq(s,term_and_log)) {
+ } else {
+ *l = term_and_log;
+ r = true;
+ }
+ } else if (t == LUA_TNUMBER) {
+ int n = lua_tonumber(L,i);
+ if (file_can_be_written(n)) {
+ *l = n;
+ r = true;
+ } else {
*l = term_and_log;
r = true;
}
} else {
- luaL_error(L, "first argument is not a string");
+ luaL_error(L, "first argument is not 'term and log', 'term', 'log' or a number");
}
return r;
}
@@ -53,19 +64,20 @@ static int do_texio_print(lua_State * L, texio_printer printfunction)
int i = 1;
int save_selector = selector;
int n = lua_gettop(L);
- if (n == 0 || !lua_isstring(L, -1)) {
- luaL_error(L, "no string to print");
+ if (n == 0 || !lua_isstring(L, -1)) { /* or number */
+ luaL_error(L, "no string to print"); /* or number */
}
if (n > 1) {
if (get_selector_value(L, i, &selector))
i++;
}
- if (selector != log_only && selector != term_only
- && selector != term_and_log) {
- normalize_selector(); /* sets selector */
+ if (selector != log_only && selector != term_only && selector != term_and_log) {
+ if (! valid_write_file(selector)) {
+ normalize_selector(); /* sets selector */
+ }
}
for (; i <= n; i++) {
- if (lua_isstring(L, i)) {
+ if (lua_isstring(L, i)) { /* or number */
s = lua_tostring(L, i);
printfunction(s);
} else {
@@ -87,7 +99,7 @@ static void do_texio_ini_print(lua_State * L, const char *extra)
i++;
}
for (; i <= n; i++) {
- if (lua_isstring(L, i)) {
+ if (lua_isstring(L, i)) { /* or number */
s = lua_tostring(L, i);
if (l == term_and_log || l == term_only)
fprintf(stdout, "%s%s", extra, s);
@@ -123,6 +135,7 @@ static int texio_printnl(lua_State * L)
}
/* at the point this function is called, the selector is log_only */
+
void flush_loggable_info(void)
{
if (loggable_info != NULL) {
@@ -132,11 +145,10 @@ void flush_loggable_info(void)
}
}
-
static const struct luaL_Reg texiolib[] = {
{"write", texio_print},
{"write_nl", texio_printnl},
- {NULL, NULL} /* sentinel */
+ {NULL, NULL}
};
int luaopen_texio(lua_State * L)
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index f3e12f9d4b3..e0b37f68fec 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -24,7 +24,6 @@ setter no prev link is created so we can presume that it's not used later on. */
#include "ptexlib.h"
#include "lua/luatex-api.h"
-
#define attribute(A) eqtb[attribute_base+(A)].hh.rh
#define dimen(A) eqtb[scaled_base+(A)].hh.rh
#undef skip
@@ -38,7 +37,6 @@ extern int unif_rand(int );
extern int norm_rand(void );
extern void init_randoms(int );
-
typedef struct {
char *text;
unsigned int tsize;
@@ -53,18 +51,16 @@ typedef struct {
char complete; /* currently still writing ? */
} spindle;
-#define PARTIAL_LINE 1
-#define FULL_LINE 0
+#define PARTIAL_LINE 1
+#define FULL_LINE 0
#define write_spindle spindles[spindle_index]
#define read_spindle spindles[(spindle_index-1)]
-static int spindle_size = 0;
+static int spindle_size = 0;
static spindle *spindles = NULL;
static int spindle_index = 0;
-
-
static void luac_store(lua_State * L, int i, int partial, int cattable)
{
char *st;
@@ -93,7 +89,6 @@ static void luac_store(lua_State * L, int i, int partial, int cattable)
}
}
-
static int do_luacprint(lua_State * L, int partial, int deftable)
{
int i, n;
@@ -112,7 +107,7 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
if (lua_type(L, startstrings) == LUA_TTABLE) {
for (i = 1;; i++) {
lua_rawgeti(L, startstrings, i);
- if (lua_isstring(L, -1)) {
+ if (lua_isstring(L,-1)) { /* or number */
luac_store(L, -1, partial, cattable);
lua_pop(L, 1);
} else {
@@ -121,7 +116,7 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
}
} else {
for (i = startstrings; i <= n; i++) {
- if (!lua_isstring(L, i)) {
+ if (!lua_isstring(L,1)) { /* or number */
luaL_error(L, "no string to print");
}
luac_store(L, i, partial, cattable);
@@ -141,9 +136,6 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
return 0;
}
-
-
-
static int luacwrite(lua_State * L)
{
return do_luacprint(L, FULL_LINE, NO_CAT_TABLE);
@@ -177,15 +169,15 @@ static int luactprint(lua_State * L)
cattable=(int)lua_tonumber(L, -1);
startstrings = 2;
if (cattable != -1 && cattable != -2 && !valid_catcode_table(cattable)) {
- cattable = DEFAULT_CAT_TABLE;
- }
+ cattable = DEFAULT_CAT_TABLE;
+ }
}
lua_pop(L, 1);
for (j = startstrings;; j++) {
lua_pushnumber(L, j);
lua_gettable(L, -2);
- if (lua_type(L, -1) == LUA_TSTRING) {
+ if (lua_isstring(L, -1)) { /* or number */
luac_store(L, -1, PARTIAL_LINE, cattable);
lua_pop(L, 1);
} else {
@@ -259,10 +251,7 @@ void luacstring_start(int n)
(void) n; /* for -W */
spindle_index++;
if (spindle_size == spindle_index) { /* add a new one */
- spindles =
- xrealloc(spindles,
- (unsigned) (sizeof(spindle) *
- (unsigned) (spindle_size + 1)));
+ spindles = xrealloc(spindles, (unsigned) (sizeof(spindle) * (unsigned) (spindle_size + 1)));
spindles[spindle_index].head = NULL;
spindles[spindle_index].tail = NULL;
spindles[spindle_index].complete = 0;
@@ -297,13 +286,21 @@ void luacstring_close(int n)
/* local (static) versions */
-#define check_index_range(j,s) \
- if (j<0 || j > 65535) { \
- luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); }
+#define check_index_range(j,s) \
+ if (j<0 || j > 65535) { \
+ luaL_error(L, "incorrect index specification for tex.%s()", s); }
+#define check_register(base) do { \
+ int k = get_item_index(L, lua_gettop(L), base); \
+ if ((k>=0) && (k <= 65535)) { \
+ lua_pushnumber(L,k); \
+ } else { \
+ lua_pushboolean(L,false); \
+ } \
+ return 1; \
+} while (1)
-static const char *scan_integer_part(lua_State * L, const char *ss, int *ret,
- int *radix_ret)
+static const char *scan_integer_part(lua_State * L, const char *ss, int *ret, int *radix_ret)
{
boolean negative = false; /* should the answer be negated? */
int m; /* |$2^{31}$ / radix|, the threshold of danger */
@@ -359,7 +356,7 @@ static const char *scan_integer_part(lua_State * L, const char *ss, int *ret,
vacuous = false;
if ((val >= m) && ((val > m) || (d > 7) || (radix1 != 10))) {
if (OK_so_far) {
- luaL_error(L, "Number too big");
+ luaL_error(L, "Number too big");
val = infinity;
OK_so_far = false;
}
@@ -470,7 +467,7 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret)
v = (x_height(get_cur_font()));
} else if (strncmp(s, "px", 2) == 0) {
s += 2;
- v = dimen_par(pdf_px_dimen_code);
+ v = dimen_par(px_dimen_code);
} else {
goto NOT_FOUND;
}
@@ -585,19 +582,17 @@ int dimen_to_number(lua_State * L, const char *s)
return j;
}
-
static int tex_scaledimen(lua_State * L)
-{ /* following vsetdimen() */
+{
int sp;
- if (!lua_isnumber(L, 1)) {
- if (lua_isstring(L, 1)) {
- sp = dimen_to_number(L, lua_tostring(L, 1));
- } else {
- luaL_error(L, "argument must be a string or a number");
- return 0;
- }
+ int t = lua_type(L, 1);
+ if (t == LUA_TNUMBER) {
+ sp = (int) lua_tonumber(L, 1);
+ } else if (t == LUA_TSTRING) {
+ sp = dimen_to_number(L, lua_tostring(L, 1));
} else {
- sp=(int)lua_tonumber(L, 1);
+ luaL_error(L, "argument must be a string or a number");
+ return 0;
}
lua_pushnumber(L, sp);
return 1;
@@ -613,7 +608,7 @@ static int texerror (lua_State * L)
l = 1; /* |errhlp| is terminated by a NULL entry */
for (i = 1;; i++) {
lua_rawgeti(L, n, i);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
l++;
lua_pop(L, 1);
} else {
@@ -626,7 +621,7 @@ static int texerror (lua_State * L)
memset(errhlp,0,l * sizeof(char *));
for (i = 1;; i++) {
lua_rawgeti(L, n, i);
- if (lua_isstring(L, -1)) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
errhlp[(i-1)] = lua_tostring(L,-1);
lua_pop(L, 1);
} else {
@@ -650,218 +645,290 @@ static int get_item_index(lua_State * L, int i, int base)
int cur_cs1;
const char *s;
switch (lua_type(L, i)) {
- case LUA_TSTRING:
- s = lua_tolstring(L, i, &kk);
- cur_cs1 = string_lookup(s, kk);
- if (cur_cs1 == undefined_control_sequence || cur_cs1 == undefined_cs_cmd)
- k = -1; /* guarandeed invalid */
- else
- k = (equiv(cur_cs1) - base);
- break;
- case LUA_TNUMBER:
- k = (int) luaL_checkinteger(L, i);
- break;
- default:
- luaL_error(L, "argument must be a string or a number");
- k = -1; /* not a valid index */
+ case LUA_TSTRING:
+ s = lua_tolstring(L, i, &kk);
+ cur_cs1 = string_lookup(s, kk);
+ if (cur_cs1 == undefined_control_sequence || cur_cs1 == undefined_cs_cmd)
+ k = -1; /* guarandeed invalid */
+ else
+ k = (equiv(cur_cs1) - base);
+ break;
+ case LUA_TNUMBER:
+ k = (int) luaL_checkinteger(L, i);
+ break;
+ default:
+ luaL_error(L, "argument must be a string or a number");
+ k = -1; /* not a valid index */
}
return k;
}
-static int vsetdimen(lua_State * L, int is_global)
-{
- int i, j, err;
- int k;
- int save_global_defs = int_par(global_defs_code);
- if (is_global)
- int_par(global_defs_code) = 1;
- i = lua_gettop(L);
- j = 0;
- /* find the value */
- if (!lua_isnumber(L, i)) {
- if (lua_isstring(L, i)) {
- j = dimen_to_number(L, lua_tostring(L, i));
- } else {
- luaL_error(L, "unsupported value type");
- }
- } else {
- j=(int)lua_tonumber(L, i);
- }
- k = get_item_index(L, (i - 1), scaled_base);
- check_index_range(k, "setdimen");
- err = set_tex_dimen_register(k, j);
- int_par(global_defs_code) = save_global_defs;
- if (err) {
- luaL_error(L, "incorrect value");
- }
- return 0;
+#define check_item_global(L,top,isglobal) \
+ if (top == 3 && (lua_type(L,1) == LUA_TSTRING)) { \
+ const char *s = lua_tostring(L, 1); \
+ if (lua_key_eq(s,global)) { \
+ isglobal = 1; \
+ } \
+ }
+
+#define set_item_index_plus(L, where, base, what, value, is_global, is_assign, set_register, glue) { \
+ size_t len; \
+ const char *str; \
+ int key, err, cs; \
+ int save_global_defs = int_par(global_defs_code); \
+ if (is_global) { \
+ int_par(global_defs_code) = 1; \
+ } \
+ switch (lua_type(L, where)) { \
+ case LUA_TSTRING: \
+ str = lua_tolstring(L, where, &len); \
+ cs = string_lookup(str, len); \
+ if (cs == undefined_control_sequence || cs == undefined_cs_cmd) { \
+ luaL_error(L, "incorrect %s name", what); \
+ } else { \
+ key = equiv(cs) - base; \
+ if (key >= 0 && key <= 65535) { \
+ err = set_register(key, value); \
+ if (err) { \
+ luaL_error(L, "incorrect %s value", what); \
+ } \
+ } else if (is_assign(eq_type(cs))) { \
+ if (glue) { \
+ int a = is_global; \
+ define(equiv(cs), assign_glue_cmd, value); \
+ } else { \
+ assign_internal_value((is_global ? 4 : 0), equiv(cs), value); \
+ } \
+ } else { \
+ luaL_error(L, "incorrect %s name", what); \
+ } \
+ } \
+ break; \
+ case LUA_TNUMBER: \
+ key = (int) luaL_checkinteger(L, where); \
+ if (key>=0 && key <= 65535) { \
+ err = set_register(key, value); \
+ if (err) { \
+ luaL_error(L, "incorrect %s value", what); \
+ } \
+ } else { \
+ luaL_error(L, "incorrect %s index", what); \
+ } \
+ break; \
+ default: \
+ luaL_error(L, "argument of 'set%s' must be a string or a number", what); \
+ } \
+ int_par(global_defs_code) = save_global_defs; \
+}
+
+static int gettex(lua_State * L);
+
+#define get_item_index_plus(L, where, base, what, value, is_assign, get_register, glue) { \
+ size_t len; \
+ const char *str; \
+ int key, cs; \
+ switch (lua_type(L, where)) { \
+ case LUA_TSTRING: \
+ str = lua_tolstring(L, where, &len); \
+ cs = string_lookup(str, len); \
+ if (cs == undefined_control_sequence || cs == undefined_cs_cmd) { \
+ luaL_error(L, "incorrect %s name", what); \
+ } else { \
+ key = equiv(cs) - base; \
+ if (key >= 0 && key <= 65535) { \
+ value = get_register(key); \
+ } else if (is_assign(eq_type(cs))) { \
+ gettex(L); /* lazy */ \
+ } else { \
+ luaL_error(L, "incorrect %s name", what); \
+ } \
+ } \
+ break; \
+ case LUA_TNUMBER: \
+ key = (int) luaL_checkinteger(L, where); \
+ if (key>=0 && key <= 65535) { \
+ value = get_register(key); \
+ } else { \
+ luaL_error(L, "incorrect %s index", what); \
+ } \
+ break; \
+ default: \
+ luaL_error(L, "argument of 'set%s' must be a string or a number", what); \
+ } \
+}
+
+static int isdimen(lua_State * L)
+{
+ check_register(scaled_base);
}
static int setdimen(lua_State * L)
{
int isglobal = 0;
- int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
- const char *s = lua_tostring(L, 1);
- if (lua_key_eq(s,global))
- isglobal = 1;
+ int value = 0;
+ int top = lua_gettop(L);
+ int t = lua_type(L, top);
+ check_item_global(L,top,isglobal);
+ if (t == LUA_TNUMBER) {
+ value = (int) lua_tonumber(L, top);
+ } else if (t == LUA_TSTRING) {
+ value = dimen_to_number(L, lua_tostring(L, top));
+ } else {
+ luaL_error(L, "unsupported %s value type","dimen");
}
- return vsetdimen(L, isglobal);
+ set_item_index_plus(L, top-1, scaled_base, "dimen", value, isglobal, is_dim_assign, set_tex_dimen_register, false);
+ return 0;
}
static int getdimen(lua_State * L)
{
- int j;
- int k;
- k = get_item_index(L, lua_gettop(L), scaled_base);
- check_index_range(k, "getdimen");
- j = get_tex_dimen_register(k);
- lua_pushnumber(L, j);
+ int value = 0;
+ get_item_index_plus(L, lua_gettop(L), scaled_base, "dimen", value, is_dim_assign, get_tex_dimen_register, false);
+ lua_pushnumber(L, value);
return 1;
}
-static int vsetskip(lua_State * L, int is_global)
+static int isskip(lua_State * L)
{
- int i, err;
- halfword *j;
- int k;
- int save_global_defs = int_par(global_defs_code);
- if (is_global)
- int_par(global_defs_code) = 1;
- i = lua_gettop(L);
- j = check_isnode(L, i); /* the value */
- k = get_item_index(L, (i - 1), skip_base);
- check_index_range(k, "setskip"); /* the index */
- err = set_tex_skip_register(k, *j);
- int_par(global_defs_code) = save_global_defs;
- if (err) {
- luaL_error(L, "incorrect value");
- }
- return 0;
+ check_register(skip_base);
}
static int setskip(lua_State * L)
{
int isglobal = 0;
- int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
- const char *s = lua_tostring(L, 1);
- if (lua_key_eq(s,global))
- isglobal = 1;
- }
- return vsetskip(L, isglobal);
+ halfword *value = NULL;
+ int top = lua_gettop(L);
+ check_item_global(L,top,isglobal);
+ value = check_isnode(L, top);
+ set_item_index_plus(L, top-1, skip_base, "skip", *value, isglobal, is_glue_assign, set_tex_skip_register, true);
+ return 0;
}
static int getskip(lua_State * L)
{
- halfword j;
- int k;
- k = get_item_index(L, lua_gettop(L), skip_base);
- check_index_range(k, "getskip");
- j = get_tex_skip_register(k);
- lua_nodelib_push_fast(L, j);
+ int value = 0;
+ get_item_index_plus(L, lua_gettop(L), skip_base, "skip", value, is_glue_assign, get_tex_skip_register, true);
+ if (value == null) {
+ lua_nodelib_push_fast(L, copy_node(zero_glue));
+ } else {
+ lua_nodelib_push_fast(L, copy_node(value));
+ }
return 1;
}
+static int ismuskip(lua_State * L)
+{
+ check_register(mu_skip_base);
+}
-
-static int vsetcount(lua_State * L, int is_global)
+static int setmuskip(lua_State * L)
{
- int i, j, err;
- int k;
- int save_global_defs = int_par(global_defs_code);
- if (is_global)
- int_par(global_defs_code) = 1;
- i = lua_gettop(L);
- j = (int) luaL_checkinteger(L, i);
- k = get_item_index(L, (i - 1), count_base);
- check_index_range(k, "setcount");
- err = set_tex_count_register(k, j);
- int_par(global_defs_code) = save_global_defs;
- if (err) {
- luaL_error(L, "incorrect value");
- }
+ int isglobal = 0;
+ halfword *value = NULL;
+ int top = lua_gettop(L);
+ check_item_global(L,top,isglobal);
+ value = check_isnode(L, top);
+ set_item_index_plus(L, top-1, mu_skip_base, "muskip", *value, isglobal, is_mu_glue_assign, set_tex_mu_skip_register, true);
return 0;
}
+static int getmuskip(lua_State * L)
+{
+ int value = 0;
+ get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, true);
+ lua_nodelib_push_fast(L, copy_node(value));
+ return 1;
+}
+
+static int iscount(lua_State * L)
+{
+ check_register(count_base);
+}
+
static int setcount(lua_State * L)
{
+ int t;
int isglobal = 0;
- int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
- const char *s = lua_tostring(L, 1);
- if (lua_key_eq(s,global))
- isglobal = 1;
+ int value = 0;
+ int top = lua_gettop(L);
+ check_item_global(L,top,isglobal);
+ t = lua_type(L,top);
+ if (t == LUA_TNUMBER || t == LUA_TSTRING) {
+ value = (int) lua_tonumber(L, top);
+ } else {
+ luaL_error(L, "unsupported %s value type","count");
}
- return vsetcount(L, isglobal);
+ set_item_index_plus(L, top-1, count_base, "count", value, isglobal, is_int_assign, set_tex_count_register, false);
+ return 0;
}
static int getcount(lua_State * L)
{
- int j;
- int k;
- k = get_item_index(L, lua_gettop(L), count_base);
- check_index_range(k, "getcount");
- j = get_tex_count_register(k);
- lua_pushnumber(L, j);
+ int value = 0;
+ get_item_index_plus(L, lua_gettop(L), count_base, "count", value, is_int_assign, get_tex_count_register, false);
+ lua_pushnumber(L, value);
return 1;
}
-
-static int vsetattribute(lua_State * L, int is_global)
+static int isattribute(lua_State * L)
{
- int i, j, err;
- int k;
- int save_global_defs = int_par(global_defs_code);
- if (is_global)
- int_par(global_defs_code) = 1;
- i = lua_gettop(L);
- j = (int) luaL_checkinteger(L, i);
- k = get_item_index(L, (i - 1), attribute_base);
- check_index_range(k, "setattribute");
- err = set_tex_attribute_register(k, j);
- int_par(global_defs_code) = save_global_defs;
- if (err) {
- luaL_error(L, "incorrect value");
- }
- return 0;
+ check_register(attribute_base);
}
+/* there are no system set attributes so this is a bit overkill */
+
static int setattribute(lua_State * L)
{
+ int t;
int isglobal = 0;
- int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
- const char *s = lua_tostring(L, 1);
- if (lua_key_eq(s,global))
- isglobal = 1;
+ int value = 0;
+ int top = lua_gettop(L);
+ check_item_global(L,top,isglobal);
+ t = lua_type(L,top);
+ if (t == LUA_TNUMBER || t == LUA_TSTRING) {
+ value = (int) lua_tonumber(L, top);
+ } else {
+ luaL_error(L, "unsupported %s value type","attribute");
}
- return vsetattribute(L, isglobal);
+ set_item_index_plus(L, top-1, attribute_base, "attribute", value, isglobal, is_attr_assign, set_tex_attribute_register, false);
+ return 0;
}
static int getattribute(lua_State * L)
{
- int j;
- int k;
- k = get_item_index(L, lua_gettop(L), attribute_base);
- check_index_range(k, "getattribute");
- j = get_tex_attribute_register(k);
- lua_pushnumber(L, j);
+ int value = 0;
+ get_item_index_plus(L, lua_gettop(L), attribute_base, "attribute", value, is_attr_assign, get_tex_attribute_register, false);
+ lua_pushnumber(L, value);
return 1;
}
-static int vsettoks(lua_State * L, int is_global)
+/* todo: we can avoid memcpy as there is no need to go through the pool */
+
+/* use string_to_toks */
+
+static int istoks(lua_State * L)
+{
+ check_register(toks_base);
+}
+
+static int settoks(lua_State * L)
{
- int i, err;
- int k;
+ int i, err, k;
lstring str;
char *s;
const char *ss;
+ int is_global = 0;
int save_global_defs = int_par(global_defs_code);
+ int n = lua_gettop(L);
+ if (n == 3 && (lua_type(L,1) == LUA_TSTRING)) {
+ const char *s = lua_tostring(L, 1);
+ if (lua_key_eq(s,global))
+ is_global = 1;
+ }
if (is_global)
int_par(global_defs_code) = 1;
i = lua_gettop(L);
- if (!lua_isstring(L, i)) {
+ if (lua_type(L,i) != LUA_TSTRING) {
luaL_error(L, "unsupported value type");
}
ss = lua_tolstring(L, i, &str.l);
@@ -879,16 +946,41 @@ static int vsettoks(lua_State * L, int is_global)
return 0;
}
-static int settoks(lua_State * L)
+static int scantoks(lua_State * L)
{
- int isglobal = 0;
+ int i, err, k, c;
+ lstring str;
+ char *s;
+ const char *ss;
+ int is_global = 0;
+ int save_global_defs = int_par(global_defs_code);
int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
+ if (n == 4 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
if (lua_key_eq(s,global))
- isglobal = 1;
+ is_global = 1;
}
- return vsettoks(L, isglobal);
+ /* action : vsettokscct(L, is_global); */
+ if (is_global)
+ int_par(global_defs_code) = 1;
+ i = lua_gettop(L);
+ if (lua_type(L,i) != LUA_TSTRING) {
+ luaL_error(L, "unsupported value type");
+ }
+ ss = lua_tolstring(L, i, &str.l);
+ s = xmalloc (str.l+1);
+ memcpy (s, ss, str.l+1);
+ str.s = (unsigned char *)s;
+ k = get_item_index(L, (i - 2), toks_base);
+ c = (int) luaL_checkinteger(L, i - 1);
+ check_index_range(k, "settoks");
+ err = scan_tex_toks_register(k, c, str);
+ xfree(str.s);
+ int_par(global_defs_code) = save_global_defs;
+ if (err) {
+ luaL_error(L, "incorrect value");
+ }
+ return 0;
}
static int gettoks(lua_State * L)
@@ -906,7 +998,7 @@ static int gettoks(lua_State * L)
return 1;
}
-static int get_box_id(lua_State * L, int i)
+static int get_box_id(lua_State * L, int i, boolean report)
{
const char *s;
int cur_cs1, cur_cmd1;
@@ -926,7 +1018,9 @@ static int get_box_id(lua_State * L, int i)
j=(int)lua_tonumber(L, (i));
break;
default:
- luaL_error(L, "argument must be a string or a number");
+ if (report) {
+ luaL_error(L, "argument must be a string or a number");
+ }
j = -1; /* not a valid box id */
}
return j;
@@ -935,20 +1029,27 @@ static int get_box_id(lua_State * L, int i)
static int getbox(lua_State * L)
{
int k, t;
- k = get_box_id(L, -1);
+ k = get_box_id(L, -1, true);
check_index_range(k, "getbox");
t = get_tex_box_register(k);
nodelist_to_lua(L, t);
return 1;
}
+static int isbox(lua_State * L)
+{
+ int k = get_box_id(L, -1, false);
+ lua_pushboolean(L,(k>=0 && k<=65535));
+ return 1;
+}
+
static int vsetbox(lua_State * L, int is_global)
{
int j, k, err;
int save_global_defs = int_par(global_defs_code);
if (is_global)
int_par(global_defs_code) = 1;
- k = get_box_id(L, -2);
+ k = get_box_id(L, -2, true);
check_index_range(k, "setbox");
if (lua_isboolean(L, -1)) {
j = lua_toboolean(L, -1);
@@ -959,8 +1060,7 @@ static int vsetbox(lua_State * L, int is_global)
} else {
j = nodelist_from_lua(L);
if (j != null && type(j) != hlist_node && type(j) != vlist_node) {
- luaL_error(L, "setbox: incompatible node type (%s)\n",
- get_node_name(type(j), subtype(j)));
+ luaL_error(L, "setbox: incompatible node type (%s)\n", get_node_name(type(j), subtype(j)));
return 0;
}
@@ -977,7 +1077,7 @@ static int setbox(lua_State * L)
{
int isglobal = 0;
int n = lua_gettop(L);
- if (n == 3 && lua_isstring(L, 1)) {
+ if (n == 3 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
if (lua_key_eq(s,global))
isglobal = 1;
@@ -987,7 +1087,8 @@ static int setbox(lua_State * L)
#define check_char_range(j,s,lim) \
if (j<0 || j >= lim) { \
- luaL_error(L, "incorrect character value %d for tex.%s()", (int)j, s); }
+ luaL_error(L, "incorrect character value %d for tex.%s()", (int)j, s); \
+ }
static int setcode (lua_State *L, void (*setone)(int,halfword,quarterword),
@@ -1000,12 +1101,12 @@ static int setcode (lua_State *L, void (*setone)(int,halfword,quarterword),
int f = 1;
if (n>1 && lua_type(L,1) == LUA_TTABLE)
f++;
- if (n>2 && lua_isstring(L, f)) {
+ if (n>2 && (lua_type(L,f) == LUA_TSTRING)) {
const char *s = lua_tostring(L, f);
if (lua_key_eq(s,global)) {
level = level_one;
- f++;
- }
+ f++;
+ }
}
ch = (int) luaL_checkinteger(L, f);
check_char_range(ch, name, 65536*17);
@@ -1015,7 +1116,7 @@ static int setcode (lua_State *L, void (*setone)(int,halfword,quarterword),
if (settwo != NULL && n-f == 2) {
ucval = (halfword) luaL_checkinteger(L, f+2);
check_char_range(ucval, name, lim);
- (settwo)(ch, ucval, level);
+ (settwo)(ch, ucval, level);
}
return 0;
}
@@ -1068,16 +1169,16 @@ static int setcatcode(lua_State * L)
int n = lua_gettop(L);
int f = 1;
if (n>1 && lua_type(L,1) == LUA_TTABLE)
- f++;
- if (n>2 && lua_isstring(L, f)) {
+ f++;
+ if (n>2 && (lua_type(L,f) == LUA_TSTRING)) {
const char *s = lua_tostring(L, f);
if (lua_key_eq(s,global)) {
level = level_one;
- f++;
- }
+ f++;
+ }
}
if (n-f == 2) {
- cattable = (int) luaL_checkinteger(L, -3);
+ cattable = (int) luaL_checkinteger(L, -3);
}
ch = (int) luaL_checkinteger(L, -2);
check_char_range(ch, "setcatcode", 65536*17);
@@ -1092,7 +1193,7 @@ static int getcatcode(lua_State * L)
int cattable = int_par(cat_code_table_code);
int ch = (int) luaL_checkinteger(L, -1);
if (lua_gettop(L)>=2 && lua_type(L,-2)==LUA_TNUMBER) {
- cattable = luaL_checkinteger(L, -2);
+ cattable = luaL_checkinteger(L, -2);
}
check_char_range(ch, "getcatcode", 65536*17);
lua_pushnumber(L, get_cat_code(cattable, ch));
@@ -1108,16 +1209,16 @@ static int setmathcode(lua_State * L)
int n = lua_gettop(L);
int f = 1;
if (n>1 && lua_type(L,1) == LUA_TTABLE)
- f++;
- if (n>2 && lua_isstring(L, f)) {
+ f++;
+ if (n>2 && (lua_type(L,f) == LUA_TSTRING)) {
const char *s = lua_tostring(L, f);
if (lua_key_eq(s,global)) {
level = level_one;
- f++;
- }
+ f++;
+ }
}
if (n-f!=1 || lua_type(L,f+1) != LUA_TTABLE) {
- luaL_error(L, "Bad arguments for tex.setmathcode()");
+ luaL_error(L, "Bad arguments for tex.setmathcode()");
}
ch = (int) luaL_checkinteger(L, -2);
check_char_range(ch, "setmathcode", 65536*17);
@@ -1153,7 +1254,17 @@ static int getmathcode(lua_State * L)
return 1;
}
-
+static int getmathcodes(lua_State * L)
+{
+ mathcodeval mval = { 0, 0, 0, 0 };
+ int ch = (int) luaL_checkinteger(L, -1);
+ check_char_range(ch, "getmathcodes", 65536*17);
+ mval = get_math_code(ch);
+ lua_pushnumber(L,mval.class_value);
+ lua_pushnumber(L,mval.family_value);
+ lua_pushnumber(L,mval.character_value);
+ return 3;
+}
static int setdelcode(lua_State * L)
{
@@ -1163,8 +1274,8 @@ static int setdelcode(lua_State * L)
int n = lua_gettop(L);
int f = 1;
if (n>1 && lua_type(L,1) == LUA_TTABLE)
- f++;
- if (n>2 && lua_isstring(L, f)) {
+ f++;
+ if (n>2 && (lua_type(L,f) == LUA_TSTRING)) {
const char *s = lua_tostring(L, f);
if (lua_key_eq(s,global)) {
level = level_one;
@@ -1215,7 +1326,18 @@ static int getdelcode(lua_State * L)
return 1;
}
-
+static int getdelcodes(lua_State * L)
+{
+ delcodeval mval = { 0, 0, 0, 0, 0, 0 };
+ int ch = (int) luaL_checkinteger(L, -1);
+ check_char_range(ch, "getdelcodes", 65536*17);
+ mval = get_del_code(ch);
+ lua_pushnumber(L,mval.small_family_value);
+ lua_pushnumber(L,mval.small_character_value);
+ lua_pushnumber(L,mval.large_family_value);
+ lua_pushnumber(L,mval.large_character_value);
+ return 4;
+}
static int settex(lua_State * L)
{
@@ -1226,11 +1348,38 @@ static int settex(lua_State * L)
int isglobal = 0;
j = 0;
i = lua_gettop(L);
- if (lua_isstring(L, (i - 1))) {
+ if (lua_type(L,i-1) == LUA_TSTRING) {
st = lua_tolstring(L, (i - 1), &k);
+
+ if (lua_key_eq(st,prevdepth)) {
+ if (lua_type(L, i) == LUA_TNUMBER) {
+ cur_list.prev_depth_field = lua_tonumber(L, i);
+ } else if (lua_type(L, i) == LUA_TSTRING) {
+ cur_list.prev_depth_field = dimen_to_number(L, lua_tostring(L, i));
+ } else {
+ luaL_error(L, "unsupported value type");
+ }
+ return 0;
+ } else if (lua_key_eq(st,prevgraf)) {
+ if (lua_type(L, i) != LUA_TNUMBER) {
+ cur_list.pg_field = lua_tonumber(L, i);
+ } else {
+ luaL_error(L, "unsupported value type");
+ }
+ return 0;
+ } else if (lua_key_eq(st,spacefactor)) {
+ if (lua_type(L, i) != LUA_TNUMBER) {
+ cur_list.space_factor_field = lua_tonumber(L, i);
+ } else {
+ luaL_error(L, "unsupported value type");
+ }
+ return 0;
+ }
+
+
texstr = maketexlstring(st, k);
if (is_primitive(texstr)) {
- if (i == 3 && lua_isstring(L, 1)) {
+ if (i == 3 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
if (lua_key_eq(s,global))
isglobal = 1;
@@ -1239,7 +1388,7 @@ static int settex(lua_State * L)
flush_str(texstr);
cur_cmd1 = eq_type(cur_cs1);
if (is_int_assign(cur_cmd1)) {
- if (lua_isnumber(L, i)) {
+ if (lua_type(L, i) == LUA_TNUMBER) {
int luai;
luai=(int)lua_tonumber(L, i);
assign_internal_value((isglobal ? 4 : 0),
@@ -1248,23 +1397,22 @@ static int settex(lua_State * L)
luaL_error(L, "unsupported value type");
}
} else if (is_dim_assign(cur_cmd1)) {
- if (!lua_isnumber(L, i)) {
- if (lua_isstring(L, i)) {
- j = dimen_to_number(L, lua_tostring(L, i));
- } else {
- luaL_error(L, "unsupported value type");
- }
- } else {
+ if (lua_type(L, i) == LUA_TNUMBER) {
j=(int)lua_tonumber(L, i);
+ } else if (lua_type(L, i) == LUA_TSTRING) {
+ j = dimen_to_number(L, lua_tostring(L, i));
+ } else {
+ luaL_error(L, "unsupported value type");
}
assign_internal_value((isglobal ? 4 : 0), equiv(cur_cs1), j);
} else if (is_glue_assign(cur_cmd1)) {
halfword *j1 = check_isnode(L, i); /* the value */
- { int a = isglobal;
- define(equiv(cur_cs1), assign_glue_cmd, *j1);
- }
+ {
+ int a = isglobal;
+ define(equiv(cur_cs1), assign_glue_cmd, *j1);
+ }
} else if (is_toks_assign(cur_cmd1)) {
- if (lua_isstring(L, i)) {
+ if (lua_type(L,i) == LUA_TSTRING) {
j = tokenlist_from_lua(L); /* uses stack -1 */
assign_internal_value((isglobal ? 4 : 0), equiv(cur_cs1), j);
@@ -1272,66 +1420,67 @@ static int settex(lua_State * L)
luaL_error(L, "unsupported value type");
}
- } else {
- /* people may want to add keys that are also primitives
- (|tex.wd| for example) so creating an error is not
- right here */
- if (lua_istable(L, (i - 2)))
- lua_rawset(L, (i - 2));
- /* luaL_error(L, "unsupported tex internal assignment"); */
- }
- } else {
- if (lua_istable(L, (i - 2)))
+ } else if (lua_istable(L, (i - 2))) {
+ /*
+ people may want to add keys that are also primitives |tex.wd| for example)
+ so creating an error is not right here
+ */
lua_rawset(L, (i - 2));
- }
- } else {
- if (lua_istable(L, (i - 2)))
+ }
+ } else if (lua_istable(L, (i - 2))) {
lua_rawset(L, (i - 2));
+ }
+ } else if (lua_istable(L, (i - 2))) {
+ lua_rawset(L, (i - 2));
}
return 0;
}
+/* todo: some will to the pdf namespace .. ignore > 31 */
+
static int do_convert(lua_State * L, int cur_code)
{
int texstr;
int i = -1;
char *str = NULL;
switch (cur_code) {
- case pdf_creation_date_code: /* ? */
- case pdf_insert_ht_code: /* arg <register int> */
- case pdf_ximage_bbox_code: /* arg 2 ints */
- case lua_code: /* arg complex */
- case lua_escape_string_code: /* arg token list */
- case pdf_colorstack_init_code: /* arg complex */
- case left_margin_kern_code: /* arg box */
- case right_margin_kern_code: /* arg box */
- break;
- case string_code: /* arg token */
- case meaning_code: /* arg token */
- break;
+ /* ignored (yet) */
+
+ case insert_ht_code: /* arg <register int> */
+ case lua_code: /* arg complex */
+ case lua_escape_string_code: /* arg token list */
+ case left_margin_kern_code: /* arg box */
+ case right_margin_kern_code: /* arg box */
+ case string_code: /* arg token */
+ case meaning_code: /* arg token */
+ break;
/* the next fall through, and come from 'official' indices! */
- case font_name_code: /* arg fontid */
- case font_identifier_code: /* arg fontid */
- case pdf_font_name_code: /* arg fontid */
- case pdf_font_objnum_code: /* arg fontid */
- case pdf_font_size_code: /* arg fontid */
- case uniform_deviate_code: /* arg int */
- case number_code: /* arg int */
- case roman_numeral_code: /* arg int */
- case pdf_page_ref_code: /* arg int */
- case pdf_xform_name_code: /* arg int */
- if (lua_gettop(L) < 1) {
- /* error */
- }
- i=(int)lua_tonumber(L, 1); /* these fall through! */
- default:
- texstr = the_convert_string(cur_code, i);
- if (texstr) {
- str = makecstring(texstr);
- flush_str(texstr);
- }
+
+ case font_name_code: /* arg fontid */
+ case font_identifier_code: /* arg fontid */
+ case uniform_deviate_code: /* arg int */
+ case number_code: /* arg int */
+ case roman_numeral_code: /* arg int */
+
+ if (lua_gettop(L) < 1) {
+ /* error */
+ }
+ i=(int)lua_tonumber(L, 1);
+
+ /* these fall through! */
+
+ default:
+ /* no backend here */
+ if (cur_code < 32) {
+ texstr = the_convert_string(cur_code, i);
+ if (texstr) {
+ str = makecstring(texstr);
+ flush_str(texstr);
+ }
+ }
}
+ /* end */
if (str) {
lua_pushstring(L, str);
free(str);
@@ -1341,7 +1490,6 @@ static int do_convert(lua_State * L, int cur_code)
return 1;
}
-
static int do_scan_internal(lua_State * L, int cur_cmd1, int cur_code)
{
int texstr;
@@ -1350,22 +1498,27 @@ static int do_scan_internal(lua_State * L, int cur_cmd1, int cur_code)
save_cur_val = cur_val;
save_cur_val_level = cur_val_level;
scan_something_simple(cur_cmd1, cur_code);
-
- if (cur_val_level == int_val_level ||
- cur_val_level == dimen_val_level || cur_val_level == attr_val_level) {
- lua_pushnumber(L, cur_val);
- } else if (cur_val_level == glue_val_level) {
- lua_nodelib_push_fast(L, cur_val);
- } else { /* dir_val_level, mu_val_level, tok_val_level */
- texstr = the_scanned_result();
- str = makecstring(texstr);
- if (str) {
- lua_pushstring(L, str);
- free(str);
- } else {
- lua_pushnil(L);
- }
- flush_str(texstr);
+ switch (cur_val_level) {
+ case int_val_level:
+ case dimen_val_level:
+ case attr_val_level:
+ lua_pushnumber(L, cur_val);
+ break;
+ case glue_val_level:
+ case mu_val_level:
+ lua_nodelib_push_fast(L, copy_node(cur_val));
+ break;
+ default:
+ texstr = the_scanned_result();
+ str = makecstring(texstr);
+ if (str) {
+ lua_pushstring(L, str);
+ free(str);
+ } else {
+ lua_pushnil(L);
+ }
+ flush_str(texstr);
+ break;
}
cur_val = save_cur_val;
cur_val_level = save_cur_val_level;
@@ -1377,69 +1530,64 @@ static int do_lastitem(lua_State * L, int cur_code)
int retval = 1;
switch (cur_code) {
/* the next two do not actually exist */
- case lastattr_code:
- case attrexpr_code:
- lua_pushnil(L);
- break;
- /* the expressions do something complicated with arguments, yuck */
- case numexpr_code:
- case dimexpr_code:
- case glueexpr_code:
- case muexpr_code:
- lua_pushnil(L);
- break;
- /* these read a glue or muglue, todo */
- case mu_to_glue_code:
- case glue_to_mu_code:
- case glue_stretch_order_code:
- case glue_shrink_order_code:
- case glue_stretch_code:
- case glue_shrink_code:
- lua_pushnil(L);
- break;
- /* these read a fontid and a char, todo */
- case font_char_wd_code:
- case font_char_ht_code:
- case font_char_dp_code:
- case font_char_ic_code:
- lua_pushnil(L);
- break;
- /* these read an integer, todo */
- case par_shape_length_code:
- case par_shape_indent_code:
- case par_shape_dimen_code:
- lua_pushnil(L);
- break;
- case lastpenalty_code:
- case lastkern_code:
- case lastskip_code:
- case last_node_type_code:
- case input_line_no_code:
- case badness_code:
- case pdf_last_obj_code:
- case pdf_last_xform_code:
- case pdf_last_ximage_code:
- case pdf_last_ximage_pages_code:
- case pdf_last_annot_code:
- case last_x_pos_code:
- case last_y_pos_code:
- case pdf_retval_code:
- case pdf_last_ximage_colordepth_code:
- case random_seed_code:
- case pdf_last_link_code:
- case luatex_version_code:
- case eTeX_minor_version_code:
- case eTeX_version_code:
- case current_group_level_code:
- case current_group_type_code:
- case current_if_level_code:
- case current_if_type_code:
- case current_if_branch_code:
- retval = do_scan_internal(L, last_item_cmd, cur_code);
- break;
- default:
- lua_pushnil(L);
- break;
+ case lastattr_code:
+ case attrexpr_code:
+ lua_pushnil(L);
+ break;
+ /* the expressions do something complicated with arguments, yuck */
+ case numexpr_code:
+ case dimexpr_code:
+ case glueexpr_code:
+ case muexpr_code:
+ lua_pushnil(L);
+ break;
+ /* these read a glue or muglue, todo */
+ case mu_to_glue_code:
+ case glue_to_mu_code:
+ case glue_stretch_order_code:
+ case glue_shrink_order_code:
+ case glue_stretch_code:
+ case glue_shrink_code:
+ lua_pushnil(L);
+ break;
+ /* these read a fontid and a char, todo */
+ case font_char_wd_code:
+ case font_char_ht_code:
+ case font_char_dp_code:
+ case font_char_ic_code:
+ lua_pushnil(L);
+ break;
+ /* these read an integer, todo */
+ case par_shape_length_code:
+ case par_shape_indent_code:
+ case par_shape_dimen_code:
+ lua_pushnil(L);
+ break;
+ case lastpenalty_code:
+ case lastkern_code:
+ case lastskip_code:
+ case last_node_type_code:
+ case input_line_no_code:
+ case badness_code:
+ case last_saved_box_resource_index_code:
+ case last_saved_image_resource_index_code:
+ case last_saved_image_resource_pages_code:
+ case last_x_pos_code:
+ case last_y_pos_code:
+ case random_seed_code:
+ case luatex_version_code:
+ case eTeX_minor_version_code:
+ case eTeX_version_code:
+ case current_group_level_code:
+ case current_group_type_code:
+ case current_if_level_code:
+ case current_if_type_code:
+ case current_if_branch_code:
+ retval = do_scan_internal(L, last_item_cmd, cur_code);
+ break;
+ default:
+ lua_pushnil(L);
+ break;
}
return retval;
}
@@ -1450,20 +1598,29 @@ static int tex_setmathparm(lua_State * L)
int k;
int n;
int l = cur_level;
+ void *p;
n = lua_gettop(L);
if ((n == 3) || (n == 4)) {
- if (n == 4 && lua_isstring(L, 1)) {
+ if (n == 4 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
if (lua_key_eq(s,global))
l = 1;
}
i = luaL_checkoption(L, (n - 2), NULL, math_param_names);
j = luaL_checkoption(L, (n - 1), NULL, math_style_names);
- if (!lua_isnumber(L, n))
- luaL_error(L, "argument must be a number");
- k=(int)lua_tonumber(L, n);
- def_math_param(i, j, (scaled) k, l);
+ if (i<0 && i>=math_param_last) {
+ /* invalid spec, just ignore it */
+ } else if (i>=math_param_first_mu_glue) {
+ p = lua_touserdata(L, n);
+ k = *((halfword *)p);
+ def_math_param(i, j, (scaled) k, l);
+ } else {
+ if (lua_type(L, n) == LUA_TNUMBER)
+ luaL_error(L, "argument must be a number");
+ k=(int)lua_tonumber(L, n);
+ def_math_param(i, j, (scaled) k, l);
+ }
}
return 0;
}
@@ -1476,7 +1633,16 @@ static int tex_getmathparm(lua_State * L)
i = luaL_checkoption(L, 1, NULL, math_param_names);
j = luaL_checkoption(L, 2, NULL, math_style_names);
k = get_math_param(i, j);
- lua_pushnumber(L, k);
+ if (i<0 && i>=math_param_last) {
+ lua_pushnil(L);
+ } else if (i>=math_param_first_mu_glue) {
+ if (k <= thick_mu_skip_code) {
+ k = glue_par(k);
+ }
+ lua_nodelib_push_fast(L, k);
+ } else {
+ lua_pushnumber(L, k);
+ }
}
return 1;
}
@@ -1491,21 +1657,6 @@ static int getfontidentifier(lua_State * L)
return do_convert(L, font_identifier_code);
}
-static int getpdffontname(lua_State * L)
-{
- return do_convert(L, pdf_font_name_code);
-}
-
-static int getpdffontobjnum(lua_State * L)
-{
- return do_convert(L, pdf_font_objnum_code);
-}
-
-static int getpdffontsize(lua_State * L)
-{
- return do_convert(L, pdf_font_size_code);
-}
-
static int getuniformdeviate(lua_State * L)
{
return do_convert(L, uniform_deviate_code);
@@ -1521,17 +1672,6 @@ static int getromannumeral(lua_State * L)
return do_convert(L, roman_numeral_code);
}
-static int getpdfpageref(lua_State * L)
-{
- return do_convert(L, pdf_page_ref_code);
-}
-
-static int getpdfxformname(lua_State * L)
-{
- return do_convert(L, pdf_xform_name_code);
-}
-
-
static int get_parshape(lua_State * L)
{
int n;
@@ -1555,16 +1695,27 @@ static int get_parshape(lua_State * L)
return 1;
}
-
static int gettex(lua_State * L)
{
int cur_cs1 = -1;
int retval = 1; /* default is to return nil */
int t = lua_gettop(L);
- if (lua_isstring(L, t)) { /* 1 == 'tex', 2 == 'boxmaxdepth', or 1 == 'boxmaxdepth' */
+ if (lua_type(L,t) == LUA_TSTRING) { /* 1 == 'tex', 2 == 'boxmaxdepth', or 1 == 'boxmaxdepth' */
int texstr;
size_t k;
const char *st = lua_tolstring(L, t, &k);
+
+ if (lua_key_eq(st,prevdepth)) {
+ lua_pushnumber(L, cur_list.prev_depth_field);
+ return 1;
+ } else if (lua_key_eq(st,prevgraf)) {
+ lua_pushnumber(L, cur_list.pg_field);
+ return 1;
+ } else if (lua_key_eq(st,spacefactor)) {
+ lua_pushnumber(L, cur_list.space_factor_field);
+ return 1;
+ }
+
texstr = maketexlstring(st, k);
cur_cs1 = prim_lookup(texstr); /* not found == relax == 0 */
flush_str(texstr);
@@ -1602,19 +1753,16 @@ static int gettex(lua_State * L)
lua_pushnil(L);
break;
}
- } else {
- if (t == 2) {
+ } else if (t == 2) {
lua_rawget(L, 1);
- }
}
return retval;
}
-
static int getlist(lua_State * L)
{
const char *str;
- if (lua_isstring(L, 2)) {
+ if (lua_type(L,2) == LUA_TSTRING) {
str = lua_tostring(L, 2);
if (lua_key_eq(str,page_ins_head)) {
if (vlink(page_ins_head) == page_ins_head)
@@ -1623,15 +1771,15 @@ static int getlist(lua_State * L)
lua_pushnumber(L, vlink(page_ins_head));
lua_nodelib_push(L);
} else if (lua_key_eq(str,contrib_head)) {
- alink(vlink(contrib_head)) = null ;
+ alink(vlink(contrib_head)) = null ;
lua_pushnumber(L, vlink(contrib_head));
lua_nodelib_push(L);
} else if (lua_key_eq(str,page_head)) {
- alink(vlink(page_head)) = null ;/*hh-ls */
+ alink(vlink(page_head)) = null ;/*hh-ls */
lua_pushnumber(L, vlink(page_head));
lua_nodelib_push(L);
} else if (lua_key_eq(str,temp_head)) {
- alink(vlink(temp_head)) = null ;/*hh-ls */
+ alink(vlink(temp_head)) = null ;/*hh-ls */
lua_pushnumber(L, vlink(temp_head));
lua_nodelib_push(L);
} else if (lua_key_eq(str,hold_head)) {
@@ -1671,7 +1819,7 @@ static int setlist(lua_State * L)
halfword *n_ptr;
const char *str;
halfword n = 0;
- if (lua_isstring(L, 2)) {
+ if (lua_type(L,2) == LUA_TSTRING) {
str = lua_tostring(L, 2);
if (lua_key_eq(str,best_size)) {
best_size = (int) lua_tointeger(L, 3);
@@ -1822,7 +1970,8 @@ static int getnest(lua_State * L)
{
int ptr;
list_state_record **nestitem;
- if (lua_isnumber(L, 2)) {
+ int t = lua_type(L, 2);
+ if (t == LUA_TNUMBER) {
ptr=(int)lua_tonumber(L, 2);
if (ptr >= 0 && ptr <= nest_ptr) {
nestitem = lua_newuserdata(L, sizeof(list_state_record *));
@@ -1832,7 +1981,7 @@ static int getnest(lua_State * L)
} else {
lua_pushnil(L);
}
- } else if (lua_isstring(L, 2)) {
+ } else if (t == LUA_TSTRING) {
const char *s = lua_tostring(L, 2);
if (lua_key_eq(s,ptr)) {
lua_pushnumber(L, nest_ptr);
@@ -1853,8 +2002,8 @@ static int setnest(lua_State * L)
static int do_integer_error(double m)
{
- const char *help[] =
- { "I can only go up to 2147483647='17777777777=" "7FFFFFFF,",
+ const char *help[] = {
+ "I can only go up to 2147483647='17777777777=" "7FFFFFFF,",
"so I'm using that number instead of yours.",
NULL
};
@@ -1862,7 +2011,6 @@ static int do_integer_error(double m)
return (m > 0.0 ? infinity : -infinity);
}
-
static int tex_roundnumber(lua_State * L)
{
double m = (double) lua_tonumber(L, 1) + 0.5;
@@ -1882,7 +2030,7 @@ static int tex_scaletable(lua_State * L)
while (lua_next(L, 1) != 0) { /* numeric value */
lua_pushvalue(L, -2);
lua_insert(L, -2);
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L,-2) == LUA_TNUMBER) {
double m = (double) lua_tonumber(L, -1) * delta + 0.5;
lua_pop(L, 1);
if (abs(m) > (double) infinity)
@@ -1892,7 +2040,7 @@ static int tex_scaletable(lua_State * L)
}
lua_rawset(L, 3);
}
- } else if (lua_isnumber(L, 1)) {
+ } else if (lua_type(L,1) == LUA_TNUMBER) {
double m = (double) lua_tonumber(L, 1) * delta + 0.5;
if (abs(m) > (double) infinity)
lua_pushnumber(L, do_integer_error(m));
@@ -1915,10 +2063,7 @@ static int tex_definefont(lua_State * L)
int i = 1;
int a = 0;
if (!no_new_control_sequence) {
- const char *help[] =
- { "You can't create a new font inside a \\csname\\endcsname pair",
- NULL
- };
+ const char *help[] = { "You can't create a new font inside a \\csname\\endcsname pair", NULL };
tex_error("Definition active", help);
}
if ((lua_gettop(L) == 3) && lua_isboolean(L, 1)) {
@@ -1991,10 +2136,13 @@ static int tex_extraprimitives(lua_State * L)
int cs = 0;
n = lua_gettop(L);
if (n == 0) {
- mask = etex_command + pdftex_command + luatex_command + umath_command;
+ mask = etex_command
+ + pdftex_command /* obsolete */
+ + umath_command /* obsolete */
+ + luatex_command;
} else {
for (i = 1; i <= n; i++) {
- if (lua_isstring(L, i)) {
+ if (lua_type(L,i) == LUA_TSTRING) {
const char *s = lua_tostring(L, i);
if (lua_key_eq(s,etex)) {
mask |= etex_command;
@@ -2002,11 +2150,12 @@ static int tex_extraprimitives(lua_State * L)
mask |= tex_command;
} else if (lua_key_eq(s,core)) {
mask |= core_command;
- } else if (lua_key_eq(s,pdftex)) {
+ } else if (lua_key_eq(s,pdftex)) { /* obsolete */
mask |= pdftex_command;
} else if (lua_key_eq(s,luatex)) {
- mask |= luatex_command | umath_command;
- } else if (lua_key_eq(s,umath)) {
+ mask |= luatex_command
+ | umath_command; /* obsolete */
+ } else if (lua_key_eq(s,umath)) { /* obsolete */
mask |= umath_command;
}
}
@@ -2045,7 +2194,7 @@ static int tex_enableprimitives(lua_State * L)
i = 1;
while (1) {
lua_rawgeti(L, 2, i);
- if (lua_isstring(L, 3)) {
+ if (lua_type(L,3) == LUA_TSTRING) {
const char *prim = lua_tostring(L, 3);
str_number s = maketexstring(prim);
halfword prim_val = prim_lookup(s);
@@ -2068,8 +2217,7 @@ static int tex_enableprimitives(lua_State * L)
val = string_lookup(newprim, newl);
if (val == undefined_control_sequence ||
eq_type(val) == undefined_cs_cmd) {
- primitive_def(newprim, newl, (quarterword) cur_cmd1,
- cur_chr1);
+ primitive_def(newprim, newl, (quarterword) cur_cmd1, cur_chr1);
}
free(newprim);
}
@@ -2090,55 +2238,55 @@ 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); \
- if (lua_type(L, -1) == LUA_TNUMBER) { \
- B=(int)lua_tonumber(L, -1); \
- } else { \
- B = (C); \
- } \
- lua_pop(L,1); \
+#define get_int_par(A,B,C) do { \
+ lua_pushstring(L,(A)); \
+ lua_gettable(L,-2); \
+ if (lua_type(L, -1) == LUA_TNUMBER) { \
+ B=(int)lua_tonumber(L, -1); \
+ } else { \
+ B = (C); \
+ } \
+ lua_pop(L,1); \
} while (0)
-#define get_intx_par(A,B,C,D,E) do { \
- lua_pushstring(L,(A)); \
- lua_gettable(L,-2); \
- if (lua_type(L, -1) == LUA_TNUMBER) { \
- B=(int)lua_tonumber(L, -1); \
- D = null; \
- } else if (lua_type(L, -1) == LUA_TTABLE){ \
- B = 0; \
- D = nodelib_topenalties(L, lua_gettop(L)); \
- } else { \
- B = (C); \
- D = (E); \
- } \
- lua_pop(L,1); \
+#define get_intx_par(A,B,C,D,E) do { \
+ lua_pushstring(L,(A)); \
+ lua_gettable(L,-2); \
+ if (lua_type(L, -1) == LUA_TNUMBER) { \
+ B=(int)lua_tonumber(L, -1); \
+ D = null; \
+ } else if (lua_type(L, -1) == LUA_TTABLE){ \
+ B = 0; \
+ D = nodelib_topenalties(L, lua_gettop(L)); \
+ } else { \
+ B = (C); \
+ D = (E); \
+ } \
+ lua_pop(L,1); \
} while (0)
-#define get_dimen_par(A,B,C) do { \
- lua_pushstring(L,(A)); \
- lua_gettable(L,-2); \
- if (lua_type(L, -1) == LUA_TNUMBER) { \
- B=(int)lua_tonumber(L, -1); \
- } else { \
- B = (C); \
- } \
- lua_pop(L,1); \
+#define get_dimen_par(A,B,C) do { \
+ lua_pushstring(L,(A)); \
+ lua_gettable(L,-2); \
+ if (lua_type(L, -1) == LUA_TNUMBER) { \
+ B=(int)lua_tonumber(L, -1); \
+ } else { \
+ B = (C); \
+ } \
+ lua_pop(L,1); \
} while (0)
-#define get_glue_par(A,B,C) do { \
- lua_pushstring(L,(A)); \
- lua_gettable(L,-2); \
- if (lua_type(L, -1) != LUA_TNIL) { \
- B = *check_isnode(L, -1); \
- } else { \
- B = (C); \
- } \
- lua_pop(L,1); \
+#define get_glue_par(A,B,C) do { \
+ lua_pushstring(L,(A)); \
+ lua_gettable(L,-2); \
+ if (lua_type(L, -1) != LUA_TNIL) { \
+ B = *check_isnode(L, -1); \
+ } else { \
+ B = (C); \
+ } \
+ lua_pop(L,1); \
} while (0)
@@ -2204,7 +2352,7 @@ static halfword nodelib_topenalties(lua_State * L, int i)
j = 2;
while (lua_next(L, i) != 0) {
j++;
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L, -1) == LUA_TNUMBER) {
int pen = 0;
pen=(int)lua_tonumber(L, -1);
varmem[p+j].cint = pen;
@@ -2216,9 +2364,6 @@ static halfword nodelib_topenalties(lua_State * L, int i)
return p;
}
-
-
-
static int tex_run_linebreak(lua_State * L)
{
@@ -2228,9 +2373,6 @@ static int tex_run_linebreak(lua_State * L)
int paragraph_dir = 0;
/* locally initialized parameters for line breaking */
int pretolerance, tracingparagraphs, tolerance, looseness,
- /*
- hyphenpenalty, exhyphenpenalty,
- */
adjustspacing, adjdemerits, protrudechars,
linepenalty, lastlinefit, doublehyphendemerits, finalhyphendemerits,
hangafter, interlinepenalty, widowpenalty, clubpenalty, brokenpenalty;
@@ -2245,9 +2387,7 @@ static int tex_run_linebreak(lua_State * L)
j = check_isnode(L, 1); /* the value */
vlink(temp_head) = *j;
p = *j;
- if ((!is_char_node(vlink(*j)))
- && ((type(vlink(*j)) == whatsit_node)
- && (subtype(vlink(*j)) == local_par_node))) {
+ if ((!is_char_node(vlink(*j))) && ((type(vlink(*j)) == local_par_node))) {
paragraph_dir = local_par_dir(vlink(*j));
}
@@ -2277,48 +2417,52 @@ 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("hyphenpenalty", hyphenpenalty, int_par(hyphen_penalty_code));
- get_int_par("exhyphenpenalty", exhyphenpenalty,
- int_par(ex_hyphen_penalty_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",
+ 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));
ext_do_line_break(paragraph_dir,
pretolerance, tracingparagraphs, tolerance,
emergencystretch, looseness,
- /*
- hyphenpenalty, exhyphenpenalty,
- */
adjustspacing,
parshape,
adjdemerits, protrudechars,
@@ -2359,7 +2503,7 @@ static int tex_run_linebreak(lua_State * L)
static int tex_shipout(lua_State * L)
{
- int boxnum = get_box_id(L, 1);
+ int boxnum = get_box_id(L, 1, true);
ship_out(static_pdf, box(boxnum), SHIPPING_PAGE);
box(boxnum) = null;
return 0;
@@ -2374,7 +2518,6 @@ static int tex_badness(lua_State * L)
return 1;
}
-
static int tex_run_boot(lua_State * L)
{
int n = lua_gettop(L);
@@ -2414,38 +2557,38 @@ static int tex_run_boot(lua_State * L)
/* tex is ready to go, now */
unhide_lua_table(Luas, "tex", tex_table_id);
unhide_lua_table(Luas, "pdf", pdf_table_id);
- unhide_lua_table(Luas, "newtoken", newtoken_table_id);
unhide_lua_table(Luas, "token", token_table_id);
+ unhide_lua_table(Luas, "oldtoken", oldtoken_table_id);
unhide_lua_table(Luas, "node", node_table_id);
lua_pushboolean(L, 1); /* true */
return 1;
-
}
/* tex random generators */
+
static int tex_init_rand(lua_State * L)
{
- int sp;
- if (!lua_isnumber(L, 1)) {
- luaL_error(L, "argument must be a number");
- return 0;
- }
- sp=(int)lua_tonumber(L, 1);
- init_randoms(sp);
- return 0;
+ int sp;
+ if (lua_type(L, 1) != LUA_TNUMBER) {
+ luaL_error(L, "argument must be a number");
+ return 0;
+ }
+ sp=(int)lua_tonumber(L, 1);
+ init_randoms(sp);
+ return 0;
}
static int tex_unif_rand(lua_State * L)
{
- int sp;
- if (!lua_isnumber(L, 1)) {
- luaL_error(L, "argument must be a number");
- return 0;
- }
- sp=(int)lua_tonumber(L, 1);
- lua_pushnumber(L, unif_rand(sp));
- return 1;
+ int sp;
+ if (lua_type(L, 1) != LUA_TNUMBER) {
+ luaL_error(L, "argument must be a number");
+ return 0;
+ }
+ sp=(int)lua_tonumber(L, 1);
+ lua_pushnumber(L, unif_rand(sp));
+ return 1;
}
static int tex_norm_rand(lua_State * L)
@@ -2455,68 +2598,35 @@ static int tex_norm_rand(lua_State * L)
}
/* Same as lua but with tex rng */
-static int lua_math_random (lua_State *L)
-{
- lua_Number rand_max = 0x7fffffff ;
- lua_Number r = unif_rand(rand_max) ;
- r = (r>=0 ? 0+r : 0-r) ;
- r = r / rand_max;
- switch (lua_gettop(L)) { /* check number of arguments */
- case 0: { /* no arguments */
- lua_pushnumber(L, r); /* Number between 0 and 1 */
- break;
- }
- case 1: { /* only upper limit */
- lua_Number u = luaL_checknumber(L, 1);
- luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty");
- lua_pushnumber(L, floor(r*u) + (lua_Number)(1.0)); /* [1, u] */
- break;
- }
- case 2: { /* lower and upper limits */
- lua_Number l = luaL_checknumber(L, 1);
- lua_Number u = luaL_checknumber(L, 2);
- luaL_argcheck(L, l <= u, 2, "interval is empty");
- lua_pushnumber(L, floor(r*(u-l+1)) + l); /* [l, u] */
- break;
- }
- default: return luaL_error(L, "wrong number of arguments");
- }
- return 1;
-}
-
-
-
-/* Experimental code can either become permanent or disappear. It is
-undocumented and mostly present in the experimental branch but for
-practical reasons we also have the setup code in the regular binary.
-The experimental_code array is indexed by i with 1<= i <= max_experimental_code,
-position 0 is not used */
-int experimental_code[MAX_EXPERIMENTAL_CODE_SIZE] = { 0 };
-
-static int set_experimental_code(lua_State *L)
+ static int lua_math_random (lua_State *L)
{
- int e, b, i ;
-
- if (lua_isboolean(L,1)) {
- e = 0 ;
- b = lua_toboolean(L,1) ;
- } else if (lua_isnumber(L,1) && lua_isboolean(L,2)) {
- e = (int) lua_tonumber(L, 1);
- b = lua_toboolean(L,2) ;
- } else {
- return luaL_error(L, "boolean or number and boolean expected");
- }
- if (e==0) {
- for (i=1;i<=max_experimental_code;i++) {
- experimental_code[i] = b;
+ lua_Number rand_max = 0x7fffffff ;
+ lua_Number r = unif_rand(rand_max) ;
+ r = (r>=0 ? 0+r : 0-r) ;
+ r = r / rand_max;
+ switch (lua_gettop(L)) { /* check number of arguments */
+ case 0: { /* no arguments */
+ lua_pushnumber(L, r); /* Number between 0 and 1 */
+ break;
}
- } else if (0<e && e<=max_experimental_code ) {
- experimental_code[e] = b;
- } else {
- return luaL_error(L, "first number out of range");
+ case 1: { /* only upper limit */
+ lua_Number u = luaL_checknumber(L, 1);
+ luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty");
+ lua_pushnumber(L, floor(r*u) + (lua_Number)(1.0)); /* [1, u] */
+ break;
+ }
+ case 2: { /* lower and upper limits */
+ lua_Number l = luaL_checknumber(L, 1);
+ lua_Number u = luaL_checknumber(L, 2);
+ luaL_argcheck(L, l <= u, 2, "interval is empty");
+ lua_pushnumber(L, floor(r*(u-l+1)) + l); /* [l, u] */
+ break;
+ }
+ default:
+ return luaL_error(L, "wrong number of arguments");
}
- return 0;
+ return 1;
}
static int tex_run_main(lua_State * L)
@@ -2542,6 +2652,91 @@ static int tex_show_context(lua_State * L)
return 0;
}
+static int tex_save_box_resource(lua_State * L)
+{
+ halfword boxnumber, boxdata;
+ int index, attributes, resources;
+ /* box attributes resources */
+ boxnumber = (halfword) lua_tonumber(L,1);
+ if (lua_type(L,2) == LUA_TSTRING) {
+ lua_pushvalue(L, 2);
+ attributes = luaL_ref(L, LUA_REGISTRYINDEX);
+ } else {
+ attributes = null;
+ }
+ if (lua_type(L,3) == LUA_TSTRING) {
+ lua_pushvalue(L, 3);
+ resources = luaL_ref(L, LUA_REGISTRYINDEX);
+ } else {
+ resources = null;
+ }
+ /* more or less same as scanner variant */
+ boxdata = box(boxnumber);
+ if (boxdata == null)
+ normal_error("pdf backend", "xforms cannot be used with a void box");
+ static_pdf->xform_count++;
+ index = pdf_create_obj(static_pdf, obj_type_xform, static_pdf->xform_count);
+ set_obj_data_ptr(static_pdf, index, pdf_get_mem(static_pdf, pdfmem_xform_size));
+ set_obj_xform_attr(static_pdf, index, null);
+ set_obj_xform_attr_str(static_pdf, index, attributes);
+ set_obj_xform_resources(static_pdf, index, null);
+ set_obj_xform_resources_str(static_pdf, index, resources);
+ set_obj_xform_box(static_pdf, index, (int) boxdata);
+ set_obj_xform_width(static_pdf, index, width(boxdata));
+ set_obj_xform_height(static_pdf, index, height(boxdata));
+ set_obj_xform_depth(static_pdf, index, depth(boxdata));
+ box(boxnumber) = null;
+ last_saved_box_index = index;
+ lua_pushnumber(L, index);
+ return 1;
+}
+
+static int tex_use_box_resource(lua_State * L)
+{
+ halfword rule;
+ int index = 0;
+ scaled_whd alt, nat, dim;
+ int top = lua_gettop(L);
+ alt.wd = null_flag;
+ alt.ht = null_flag;
+ alt.dp = null_flag;
+ if (top == 0)
+ return 0;
+ index = lua_tonumber(L,1);
+ if (top>1)
+ alt.wd = (scaled) lua_tonumber(L,2);
+ if (top>2)
+ alt.ht = (scaled) lua_tonumber(L,3);
+ if (top>3)
+ alt.dp = (scaled) lua_tonumber(L,4);
+ /* sort of the same as backend */
+ check_obj_type(static_pdf, obj_type_xform, index);
+ nat.wd = obj_xform_width(static_pdf, index);
+ nat.ht = obj_xform_height(static_pdf, index);
+ nat.dp = obj_xform_depth(static_pdf, index);
+ if (alt.wd != null_flag || alt.ht != null_flag || alt.dp != null_flag) {
+ dim = tex_scale(nat, alt);
+ } else {
+ dim = nat;
+ }
+ rule = new_rule(box_rule);
+ rule_index(rule) = index;
+ width(rule) = dim.wd;
+ height(rule) = dim.ht;
+ depth(rule) = dim.dp;
+ nodelist_to_lua(L, rule);
+ lua_pushnumber(L, (int) dim.wd);
+ lua_pushnumber(L, (int) dim.ht);
+ lua_pushnumber(L, (int) dim.dp);
+ return 4;
+}
+
+static int tex_build_page(lua_State * L)
+{
+ build_page();
+ return 0;
+}
+
void init_tex_table(lua_State * L)
{
lua_createtable(L, 0, 3);
@@ -2554,9 +2749,6 @@ void init_tex_table(lua_State * L)
lua_setglobal(L, "tex");
}
-
-
-
static const struct luaL_Reg texlib[] = {
{"run", tex_run_main}, /* may be needed */
{"finish", tex_run_end}, /* may be needed */
@@ -2567,16 +2759,26 @@ static const struct luaL_Reg texlib[] = {
{"sprint", luacsprint},
{"set", settex},
{"get", gettex},
+ {"isdimen", isdimen},
{"setdimen", setdimen},
{"getdimen", getdimen},
+ {"isskip", isskip},
{"setskip", setskip},
{"getskip", getskip},
+ {"ismuskip", ismuskip},
+ {"setmuskip", setmuskip},
+ {"getmuskip", getmuskip},
+ {"isattribute", isattribute},
{"setattribute", setattribute},
{"getattribute", getattribute},
+ {"iscount", iscount},
{"setcount", setcount},
{"getcount", getcount},
+ {"istoks", istoks},
{"settoks", settoks},
+ {"scantoks", scantoks},
{"gettoks", gettoks},
+ {"isbox", isbox},
{"setbox", setbox},
{"getbox", getbox},
{"setlist", setlist},
@@ -2587,10 +2789,12 @@ static const struct luaL_Reg texlib[] = {
{"getcatcode", getcatcode},
{"setdelcode", setdelcode},
{"getdelcode", getdelcode},
+ {"getdelcodes", getdelcodes},
{"setlccode", setlccode},
{"getlccode", getlccode},
{"setmathcode", setmathcode},
{"getmathcode", getmathcode},
+ {"getmathcodes", getmathcodes},
{"setsfcode", setsfcode},
{"getsfcode", getsfcode},
{"setuccode", setuccode},
@@ -2600,14 +2804,9 @@ static const struct luaL_Reg texlib[] = {
{"sp", tex_scaledimen},
{"fontname", getfontname},
{"fontidentifier", getfontidentifier},
- {"pdffontname", getpdffontname},
- {"pdffontobjnum", getpdffontobjnum},
- {"pdffontsize", getpdffontsize},
{"uniformdeviate", getuniformdeviate},
{"number", getnumber},
{"romannumeral", getromannumeral},
- {"pdfpageref", getpdfpageref},
- {"pdfxformname", getpdfxformname},
{"definefont", tex_definefont},
{"hashtokens", tex_hashpairs},
{"primitives", tex_primitives},
@@ -2624,29 +2823,34 @@ static const struct luaL_Reg texlib[] = {
{"normal_rand", tex_norm_rand},
{"lua_math_randomseed", tex_init_rand}, /* syntactic sugar */
{"lua_math_random", lua_math_random},
- {"set_experimental_code",set_experimental_code},
{"show_context", tex_show_context},
- {NULL, NULL} /* sentinel */
+ {"saveboxresource", tex_save_box_resource},
+ {"useboxresource", tex_use_box_resource},
+ /* just for testing: it will probably stay but maybe with options */
+ {"triggerbuildpage", tex_build_page},
+ /* sentinel */
+ {NULL, NULL}
};
int luaopen_tex(lua_State * L)
{
luaL_register(L, "tex", texlib);
/* *INDENT-OFF* */
- make_table(L, "attribute", "tex.attribute" ,"getattribute", "setattribute");
- make_table(L, "skip", "tex.skip" ,"getskip", "setskip");
- make_table(L, "dimen", "tex.dimen" ,"getdimen", "setdimen");
- make_table(L, "count", "tex.count" ,"getcount", "setcount");
- make_table(L, "toks", "tex.toks" ,"gettoks", "settoks");
- make_table(L, "box", "tex.box" ,"getbox", "setbox");
- make_table(L, "sfcode", "tex.sfcode" ,"getsfcode", "setsfcode");
- make_table(L, "lccode", "tex.lccode" ,"getlccode", "setlccode");
- make_table(L, "uccode", "tex.uccode" ,"getuccode", "setuccode");
- make_table(L, "catcode", "tex.catcode" ,"getcatcode", "setcatcode");
- make_table(L, "mathcode", "tex.mathcode" ,"getmathcode", "setmathcode");
- make_table(L, "delcode", "tex.delcode" ,"getdelcode", "setdelcode");
- make_table(L, "lists", "tex.lists" ,"getlist", "setlist");
- make_table(L, "nest", "tex.nest" ,"getnest", "setnest");
+ make_table(L, "attribute", "tex.attribute", "getattribute", "setattribute");
+ make_table(L, "skip", "tex.skip", "getskip", "setskip");
+ make_table(L, "muskip", "tex.muskip", "getmuskip", "setmuskip");
+ make_table(L, "dimen", "tex.dimen", "getdimen", "setdimen");
+ make_table(L, "count", "tex.count", "getcount", "setcount");
+ make_table(L, "toks", "tex.toks", "gettoks", "settoks");
+ make_table(L, "box", "tex.box", "getbox", "setbox");
+ make_table(L, "sfcode", "tex.sfcode", "getsfcode", "setsfcode");
+ make_table(L, "lccode", "tex.lccode", "getlccode", "setlccode");
+ make_table(L, "uccode", "tex.uccode", "getuccode", "setuccode");
+ make_table(L, "catcode", "tex.catcode", "getcatcode", "setcatcode");
+ make_table(L, "mathcode", "tex.mathcode", "getmathcode", "setmathcode");
+ make_table(L, "delcode", "tex.delcode", "getdelcode", "setdelcode");
+ make_table(L, "lists", "tex.lists", "getlist", "setlist");
+ make_table(L, "nest", "tex.nest", "getnest", "setnest");
/* *INDENT-ON* */
init_nest_lib(L);
/* make the meta entries */
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c b/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c
index fd3edb2921f..21686c6c3ec 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltokenlib.c
@@ -1,5 +1,5 @@
/* ltokenlib.c
-
+
Copyright 2006-2012 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -42,11 +42,13 @@ static unsigned char *get_cs_text(int cs)
static int test_expandable(lua_State * L)
{
int cmd = -1;
+ int t;
if (is_valid_token(L, -1)) {
get_token_cmd(L, -1);
- if (lua_isnumber(L, -1)) {
+ t = lua_type(L, -1);
+ if (t == LUA_TNUMBER) {
cmd = (int) lua_tointeger(L, -1);
- } else if (lua_isstring(L, -1)) {
+ } else if (t == LUA_TSTRING) {
cmd = get_command_id(lua_tostring(L, -1));
}
if (cmd > max_command_cmd) {
@@ -64,11 +66,13 @@ static int test_expandable(lua_State * L)
static int test_protected(lua_State * L)
{
int chr = -1;
+ int t;
if (is_valid_token(L, -1)) {
get_token_chr(L, -1);
- if (lua_isnumber(L, -1)) {
+ t = lua_type(L, -1);
+ if (t == LUA_TNUMBER) {
chr = (int) lua_tointeger(L, -1);
- } else if (lua_isstring(L, -1)) {
+ } else if (t == LUA_TSTRING) {
chr = get_command_id(lua_tostring(L, -1));
}
if (token_info(token_link(chr)) == protected_token) {
@@ -88,7 +92,7 @@ static int test_activechar(lua_State * L)
unsigned char *s;
int cs = 0;
get_token_cs(L, -1);
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L, -1) == LUA_TNUMBER) {
cs = (int) lua_tointeger(L, -1);
}
lua_pop(L, 1);
@@ -111,7 +115,7 @@ static int run_get_command_name(lua_State * L)
int cs;
if (is_valid_token(L, -1)) {
get_token_cmd(L, -1);
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L, -1) == LUA_TNUMBER) {
cs = (int) lua_tointeger(L, -1);
lua_pushstring(L, command_names[cs].cmd_name);
} else {
@@ -131,14 +135,14 @@ static int run_get_csname_name(lua_State * L)
if (is_valid_token(L, -1)) {
get_token_cmd(L, -1);
/*
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L, -1) == LUA_TNUMBER) {
cmd = (int) lua_tointeger(L, -1);
}
*/
lua_pop(L, 1);
cs = 0;
get_token_cs(L, -1);
- if (lua_isnumber(L, -1)) {
+ if (lua_type(L, -1) == LUA_TNUMBER) {
cs = (int) lua_tointeger(L, -1);
}
lua_pop(L, 1);
@@ -160,7 +164,7 @@ static int run_get_csname_name(lua_State * L)
static int run_get_command_id(lua_State * L)
{
int cs = -1;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
cs = get_command_id(lua_tostring(L, -1));
}
lua_pushnumber(L, cs);
@@ -172,7 +176,7 @@ static int run_get_csname_id(lua_State * L)
{
const char *s;
size_t k, cs = 0;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
s = lua_tolstring(L, -1, &k);
cs = (size_t) string_lookup(s, k);
}
@@ -217,7 +221,7 @@ static int run_lookup(lua_State * L)
size_t l;
int cs, cmd, chr;
int save_nncs;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
s = lua_tolstring(L, -1, &l);
if (l > 0) {
save_nncs = no_new_control_sequence;
@@ -238,7 +242,7 @@ static int run_lookup(lua_State * L)
static int run_build(lua_State * L)
{
int cmd, chr, cs;
- if (lua_isnumber(L, 1)) {
+ if (lua_type(L, 1) == LUA_TNUMBER) {
cs = 0;
chr = (int) lua_tointeger(L, 1);
cmd = (int) luaL_optinteger(L, 2, get_char_cat_code(chr));
@@ -277,8 +281,8 @@ static const struct luaL_Reg tokenlib[] = {
{NULL, NULL} /* sentinel */
};
-int luaopen_token(lua_State * L)
+int luaopen_oldtoken(lua_State * L)
{
- luaL_register(L, "token", tokenlib);
+ luaL_register(L, "oldtoken", tokenlib);
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/luagen.h b/Build/source/texk/web2c/luatexdir/lua/luagen.h
index ae30fa1313b..d49f60f02b8 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luagen.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luagen.h
@@ -1,5 +1,5 @@
/* luagen.h
-
+
Copyright 2009-2013 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -17,10 +17,4 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
-extern void lua_begin_page(PDF pdf);
-extern void lua_end_page(PDF pdf);
-
-extern void lua_place_glyph(PDF pdf, internal_font_number f, int c, int ex);
-extern void lua_place_rule(PDF pdf, scaledpos size);
-extern void finish_lua_file(PDF pdf);
+/* obsolete, one can intercept nodelist and flush as lua if needed */
diff --git a/Build/source/texk/web2c/luatexdir/lua/luagen.w b/Build/source/texk/web2c/luatexdir/lua/luagen.w
index caf377ae445..f5b01df8505 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luagen.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luagen.w
@@ -17,37 +17,4 @@
% You should have received a copy of the GNU General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
-@ @c
-
-
-#include "ptexlib.h"
-#include "pdf/pdfpage.h"
-
-@ @c
-void lua_begin_page(PDF pdf)
-{
- (void) pdf;
-}
-
-void lua_end_page(PDF pdf)
-{
- (void) pdf;
-}
-
-void lua_place_glyph(PDF pdf, internal_font_number f, int c, int ex)
-{
- (void) pdf;
- (void) f;
- printf("%c", (int) c);
-}
-
-void lua_place_rule(PDF pdf, scaledpos size)
-{
- (void) pdf;
- (void) size;
-}
-
-void finish_lua_file(PDF pdf)
-{
- (void) pdf;
-}
+/* obsolete */
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index 610aa06ec42..1fe90a888ac 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -27,7 +27,7 @@
#include "lua/luatex-api.h"
/* internalized strings: see luatex-api.h */
-set_make_keys;
+set_make_keys;
@
@@ -68,14 +68,9 @@ const_string LUATEX_IHELP[] = {
"",
" The following regular options are understood: ",
"",
- " --8bit ignored, input is assumed to be in UTF-8 encoding",
" --credits display credits and exit",
" --debug-format enable format debugging",
- " --default-translate-file=FILE ignored, input is assumed to be in UTF-8 encoding",
- " --disable-write18 disable \\write18{SHELL COMMAND}",
" --draftmode switch on draft mode (generates no output PDF)",
- " --enable-write18 enable \\write18{SHELL COMMAND}",
- " --etex ignored, the etex extensions are always active",
" --[no-]file-line-error disable/enable file:line:error style messages",
" --[no-]file-line-error-style aliases of --[no-]file-line-error",
" --fmt=FORMAT load the format file FORMAT",
@@ -91,30 +86,38 @@ const_string LUATEX_IHELP[] = {
" --output-comment=STRING use STRING for DVI file comment instead of date (no effect for PDF)",
" --output-directory=DIR use existing DIR as the directory to write files in",
" --output-format=FORMAT use FORMAT for job output; FORMAT is 'dvi' or 'pdf'",
- " --[no-]parse-first-line ignored",
" --progname=STRING set the program name to STRING",
" --recorder enable filename recorder",
" --safer disable easily exploitable lua commands",
" --[no-]shell-escape disable/enable \\write18{SHELL COMMAND}",
" --shell-restricted restrict \\write18 to a list of commands given in texmf.cnf",
" --synctex=NUMBER enable synctex",
- " --translate-file=FILE ignored, input is assumed to be in UTF-8 encoding",
" --version display version and exit",
"",
"Alternate behaviour models can be obtained by special switches",
"",
- " --luaonly run a lua file, then exit",
- " --luaconly byte-compile a lua file, then exit",
- " --luahashchars the bits used by current Lua interpreter for strings hashing",
+ " --luaonly run a lua file, then exit",
+ " --luaconly byte-compile a lua file, then exit",
+ " --luahashchars the bits used by current Lua interpreter for strings hashing",
#ifdef LuajitTeX
- " --jiton turns the JIT compiler on (default off)",
- " --jithash=STRING choose the hash function for the lua strings (lua51|luajit20: default lua51)",
+ " --jiton turns the JIT compiler on (default off)",
+ " --jithash=STRING choose the hash function for the lua strings (lua51|luajit20: default lua51)",
#endif
"",
"See the reference manual for more information about the startup process.",
NULL
};
+/*
+ " --8bit ignored, input is assumed to be in UTF-8 encoding",
+ " --default-translate-file=FILE ignored, input is assumed to be in UTF-8 encoding",
+ " --etex ignored, the etex extensions are always active",
+ " --disable-write18 disable \\write18{SHELL COMMAND}",
+ " --enable-write18 enable \\write18{SHELL COMMAND}",
+ " --[no-]parse-first-line ignored",
+ " --translate-file=FILE ignored, input is assumed to be in UTF-8 encoding",
+*/
+
@ The return value will be the directory of the executable, e.g.: \.{c:/TeX/bin}
@c
static char *ex_selfdir(char *argv0)
@@ -198,54 +201,66 @@ option table in a variable |long_options|.
@c
#define ARGUMENT_IS(a) STREQ (long_options[option_index].name, a)
-/* SunOS cc can't initialize automatic structs, so make this static. */
-static struct option long_options[]
-= { {"fmt", 1, 0, 0},
-{"lua", 1, 0, 0},
-{"luaonly", 0, 0, 0},
-{"luahashchars", 0, 0, 0},
+/*
+ SunOS cc can't initialize automatic structs, so make this static.
+*/
+
+/*
+ Nota Bene: we still intercept some options that other engines handle
+ so that existing scripted usage will not fail.
+*/
+
+static struct option long_options[] = {
+ {"fmt", 1, 0, 0},
+ {"lua", 1, 0, 0},
+ {"luaonly", 0, 0, 0},
+ {"luahashchars", 0, 0, 0},
#ifdef LuajitTeX
-{"jiton", 0, 0, 0},
-{"jithash", 1, 0, 0},
+ {"jiton", 0, 0, 0},
+ {"jithash", 1, 0, 0},
#endif
-{"safer", 0, &safer_option, 1},
-{"nosocket", 0, &nosocket_option, 1},
-{"help", 0, 0, 0},
-{"ini", 0, &ini_version, 1},
-{"interaction", 1, 0, 0},
-{"halt-on-error", 0, &haltonerrorp, 1},
-{"kpathsea-debug", 1, 0, 0},
-{"progname", 1, 0, 0},
-{"version", 0, 0, 0},
-{"credits", 0, 0, 0},
-{"recorder", 0, &recorder_enabled, 1},
-{"etex", 0, 0, 0},
-{"output-comment", 1, 0, 0},
-{"output-directory", 1, 0, 0},
-{"draftmode", 0, 0, 0},
-{"output-format", 1, 0, 0},
-{"shell-escape", 0, &shellenabledp, 1},
-{"no-shell-escape", 0, &shellenabledp, -1},
-{"enable-write18", 0, &shellenabledp, 1},
-{"disable-write18", 0, &shellenabledp, -1},
-{"shell-restricted", 0, 0, 0},
-{"debug-format", 0, &debug_format_file, 1},
-{"file-line-error-style", 0, &filelineerrorstylep, 1},
-{"no-file-line-error-style", 0, &filelineerrorstylep, -1},
- /* Shorter option names for the above. */
-{"file-line-error", 0, &filelineerrorstylep, 1},
-{"no-file-line-error", 0, &filelineerrorstylep, -1},
-{"jobname", 1, 0, 0},
-{"parse-first-line", 0, &parsefirstlinep, 1},
-{"no-parse-first-line", 0, &parsefirstlinep, -1},
-{"translate-file", 1, 0, 0},
-{"default-translate-file", 1, 0, 0},
-{"8bit", 0, 0, 0},
-{"mktex", 1, 0, 0},
-{"no-mktex", 1, 0, 0},
-/* Synchronization: just like "interaction" above */
-{"synctex", 1, 0, 0},
-{0, 0, 0, 0}
+ {"safer", 0, &safer_option, 1},
+ {"nosocket", 0, &nosocket_option, 1},
+ {"help", 0, 0, 0},
+ {"ini", 0, &ini_version, 1},
+ {"interaction", 1, 0, 0},
+ {"halt-on-error", 0, &haltonerrorp, 1},
+ {"kpathsea-debug", 1, 0, 0},
+ {"progname", 1, 0, 0},
+ {"version", 0, 0, 0},
+ {"credits", 0, 0, 0},
+ {"recorder", 0, &recorder_enabled, 1},
+ {"etex", 0, 0, 0},
+ {"output-comment", 1, 0, 0},
+ {"output-directory", 1, 0, 0},
+ {"draftmode", 0, 0, 0},
+ {"output-format", 1, 0, 0},
+ {"shell-escape", 0, &shellenabledp, 1},
+ {"no-shell-escape", 0, &shellenabledp, -1},
+ {"enable-write18", 0, &shellenabledp, 1},
+ {"disable-write18", 0, &shellenabledp, -1},
+ {"shell-restricted", 0, 0, 0},
+ {"debug-format", 0, &debug_format_file, 1},
+ {"file-line-error-style", 0, &filelineerrorstylep, 1},
+ {"no-file-line-error-style", 0, &filelineerrorstylep, -1},
+
+ /* Shorter option names for the above. */
+
+ {"file-line-error", 0, &filelineerrorstylep, 1},
+ {"no-file-line-error", 0, &filelineerrorstylep, -1},
+ {"jobname", 1, 0, 0},
+ {"parse-first-line", 0, &parsefirstlinep, 1},
+ {"no-parse-first-line", 0, &parsefirstlinep, -1},
+ {"translate-file", 1, 0, 0},
+ {"default-translate-file", 1, 0, 0},
+ {"8bit", 0, 0, 0},
+ {"mktex", 1, 0, 0},
+ {"no-mktex", 1, 0, 0},
+
+ /* Synchronization: just like "interaction" above */
+
+ {"synctex", 1, 0, 0},
+ {0, 0, 0, 0}
};
@ @c
@@ -370,20 +385,19 @@ static void parse_options(int ac, char **av)
restrictedshell = 1;
} else if (ARGUMENT_IS("output-format")) {
- pdf_output_option = 1;
+ output_mode_option = 1;
if (strcmp(optarg, "dvi") == 0) {
- pdf_output_value = 0;
+ output_mode_value = 0;
} else if (strcmp(optarg, "pdf") == 0) {
- pdf_output_value = 2;
+ output_mode_value = 1;
} else {
- WARNING1("Ignoring unknown value `%s' for --output-format",
- optarg);
- pdf_output_option = 0;
+ WARNING1("Ignoring unknown value `%s' for --output-format",optarg);
+ output_mode_option = 0;
}
} else if (ARGUMENT_IS("draftmode")) {
- pdf_draftmode_option = 1;
- pdf_draftmode_value = 1;
+ draft_mode_option = 1;
+ draft_mode_value = 1;
} else if (ARGUMENT_IS("mktex")) {
kpse_maketex_option(optarg, true);
@@ -421,12 +435,7 @@ static void parse_options(int ac, char **av)
"the terms of the GNU General Public License, version 2 or (at your option)\n"
"any later version. For more information about these matters, see the file\n"
"named COPYING and the LuaTeX source.\n\n"
-#ifdef LuajitTeX
- "LuaTeX is Copyright 2015 Taco Hoekwater, the LuaTeX Team.\n"
- "Libraries and JIT extensions by Luigi Scarso, the LuaTeX SwigLib team.\n");
-#else
- "Copyright 2015 Taco Hoekwater, the LuaTeX Team.\n");
-#endif
+ "LuaTeX is Copyright 2015 Taco Hoekwater and the LuaTeX Team.\n");
/* *INDENT-ON* */
uexit(0);
} else if (ARGUMENT_IS("credits")) {
@@ -434,33 +443,19 @@ static void parse_options(int ac, char **av)
initversionstring(&versions);
print_version_banner();
/* *INDENT-OFF* */
- puts("\n\nThe LuaTeX team is Hans Hagen, Hartmut Henkel, Taco Hoekwater.\n"
+ puts("\n\nThe LuaTeX team is Hans Hagen, Hartmut Henkel, Taco Hoekwater, Luigi Scarso.\n\n"
MyName " merges and builds upon (parts of) the code from these projects:\n\n"
- "tex by Donald Knuth\n"
- "etex by Peter Breitenlohner, Phil Taylor and friends\n"
- "omega by John Plaice and Yannis Haralambous\n"
- "aleph by Giuseppe Bilotta\n"
- "pdftex by Han The Thanh and friends\n"
- "kpathsea by Karl Berry, Olaf Weber and others\n"
- "lua by Roberto Ierusalimschy, Waldemar Celes\n"
- " and Luiz Henrique de Figueiredo\n"
- "metapost by John Hobby, Taco Hoekwater and friends.\n"
- "poppler by Derek Noonburg, Kristian H\\ogsberg (partial)\n"
-#ifdef LuajitTeX
- "fontforge by George Williams (partial)\n"
- "luajit by Mike Pall\n\n"
-#else
- "fontforge by George Williams (partial)\n\n"
-#endif
- "Some extensions to lua and additional lua libraries are used, as well as\n"
- "libraries for graphic inclusion. More details can be found in the source.\n"
- "Code development was sponsored by a grant from Colorado State University\n"
-#ifdef LuajitTeX
- "via the 'oriental tex' project, the TeX User Groups, and donations.\n"
- "The additional libraries and the LuaJIT extensions are provided by the LuaTeX SwigLib project.\n");
-#else
- "via the 'oriental tex' project, the TeX User Groups, and donations.\n");
-#endif
+ "tex : Donald Knuth\n"
+ "etex : Peter Breitenlohner, Phil Taylor and friends\n"
+ "omega : John Plaice and Yannis Haralambous\n"
+ "aleph : Giuseppe Bilotta\n"
+ "pdftex : Han The Thanh and friends\n"
+ "kpathsea : Karl Berry, Olaf Weber and others\n"
+ "lua : Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo\n"
+ "metapost : John Hobby, Taco Hoekwater and friends.\n"
+ "poppler : Derek Noonburg, Kristian H\\ogsberg (partial)\n"
+ "fontforge : George Williams (partial)\n"
+ "luajit : Mike Pall (used in LuajitTeX)\n");
/* *INDENT-ON* */
puts(versions);
uexit(0);
@@ -556,8 +551,8 @@ static char *find_filename(char *name, const char *envkey)
}
filename = xmalloc((unsigned) (strlen(dirname) + strlen(name) + 2));
filename = concat3(dirname, "/", name);
+ xfree(dirname);
if (is_readable(filename)) {
- xfree(dirname);
return filename;
}
xfree(filename);
@@ -787,8 +782,8 @@ static void setup_lua_path(lua_State * L)
@c
int tex_table_id;
int pdf_table_id;
-int newtoken_table_id;
int token_table_id;
+int oldtoken_table_id;
int node_table_id;
@ @c
@@ -798,7 +793,6 @@ 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];
-
#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
char **suffixlist;
@@ -946,7 +940,7 @@ void lua_initialize(int ac, char **av)
lua_settable(Luas,LUA_REGISTRYINDEX);
/* here start the key definitions */
- set_pack_type_index;
+ set_l_pack_type_index;
set_l_group_code_index;
set_l_math_style_name_index;
set_l_dir_par_index;
@@ -957,15 +951,18 @@ void lua_initialize(int ac, char **av)
if (startup_filename != NULL) {
given_file = xstrdup(startup_filename);
- startup_filename = find_filename(startup_filename, "LUATEXDIR");
+ if (lua_only) {
+ xfree(startup_filename);
+ }
+ startup_filename = find_filename(given_file, "LUATEXDIR");
}
/* now run the file */
if (startup_filename != NULL) {
char *v1;
/* hide the 'tex' and 'pdf' table */
tex_table_id = hide_lua_table(Luas, "tex");
- newtoken_table_id = hide_lua_table(Luas, "newtoken");
token_table_id = hide_lua_table(Luas, "token");
+ oldtoken_table_id = hide_lua_table(Luas, "oldtoken");
node_table_id = hide_lua_table(Luas, "node");
pdf_table_id = hide_lua_table(Luas, "pdf");
@@ -997,8 +994,8 @@ void lua_initialize(int ac, char **av)
/* unhide the 'tex' and 'pdf' table */
unhide_lua_table(Luas, "tex", tex_table_id);
unhide_lua_table(Luas, "pdf", pdf_table_id);
- unhide_lua_table(Luas, "newtoken", newtoken_table_id);
unhide_lua_table(Luas, "token", token_table_id);
+ unhide_lua_table(Luas, "oldtoken", oldtoken_table_id);
unhide_lua_table(Luas, "node", node_table_id);
/* |kpse_init| */
diff --git a/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w b/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
index 9ecd4d6d528..1305505fe2f 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
@@ -18,8 +18,6 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
#include "lua/luatex-api.h"
#include "lua/lauxlib_bridge.h"
@@ -28,7 +26,6 @@
lua_State *Luas = NULL;
int luastate_bytes = 0;
-
int lua_active = 0;
@ @c
@@ -57,8 +54,7 @@ void make_table(lua_State * L, const char *tab, const char *mttab, const char *g
}
@ @c
-static
-const char *getS(lua_State * L, void *ud, size_t * size)
+static const char *getS(lua_State * L, void *ud, size_t * size)
{
LoadS *ls = (LoadS *) ud;
(void) L;
@@ -118,9 +114,6 @@ void luafunctioncall(int slot)
lua_active--;
}
-
-
-
@ @c
static const luaL_Reg lualibs[] = {
{"", luaopen_base},
@@ -143,12 +136,12 @@ static const luaL_Reg lualibs[] = {
{"bit", luaopen_bit },
{NULL, NULL}
};
+
static const luaL_Reg lualibs_nofenv[] = {
{"lpeg", luaopen_lpeg},
{NULL, NULL}
};
-
@ @c
static void do_openlibs(lua_State * L)
{
@@ -220,29 +213,27 @@ static int luatex_dofile (lua_State *L) {
return lua_gettop(L) - n;
}
-
@ @c
void luainterpreter(void)
{
lua_State *L;
-
+
if (jithash_hashname==NULL){
- /* default lua51 */
+ /* default lua51 */
luajittex_choose_hash_function = 0;
jithash_hashname = (char *) xmalloc(strlen("lua51")+1);
- jithash_hashname = strcpy ( jithash_hashname, "lua51");
+ jithash_hashname = strcpy ( jithash_hashname, "lua51");
} else {
if (strcmp((const char*)jithash_hashname,"lua51")==0){
luajittex_choose_hash_function = 0;
}else if (strcmp((const char*)jithash_hashname,"luajit20")==0){
luajittex_choose_hash_function = 1;
} else {
- /* default lua51 */
+ /* default lua51 */
luajittex_choose_hash_function = 0;
- jithash_hashname = strcpy ( jithash_hashname, "lua51");
+ jithash_hashname = strcpy ( jithash_hashname, "lua51");
}
}
-
L = luaL_newstate() ;
/*L = lua_newstate(my_luaalloc, NULL);*/
@@ -261,7 +252,6 @@ void luainterpreter(void)
luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE|LUAJIT_MODE_OFF);
}
-
lua_pushcfunction(L,luatex_dofile);
lua_setglobal(L, "dofile");
lua_pushcfunction(L,luatex_loadfile);
@@ -311,8 +301,8 @@ void luainterpreter(void)
/* our own libraries */
luaopen_ff(L);
luaopen_tex(L);
- luaopen_newtoken(L);
luaopen_token(L);
+ luaopen_oldtoken(L);
luaopen_node(L);
luaopen_texio(L);
luaopen_kpse(L);
@@ -418,7 +408,6 @@ void unhide_lua_value(lua_State * L, const char *name, const char *item, int r)
}
}
-
@ @c
int lua_traceback(lua_State * L)
{
@@ -514,7 +503,6 @@ static void luacall(int p, int nameptr, boolean is_string) /* hh-ls: optimized l
lua_active--;
}
-
@ @c
void late_lua(PDF pdf, halfword p)
{
@@ -581,24 +569,23 @@ lua_State *luatex_error(lua_State * L, int is_fatal)
const_lstring luaerr;
char *err = NULL;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
luaerr.s = lua_tolstring(L, -1, &luaerr.l);
+ /* free last one ? */
err = (char *) xmalloc((unsigned) (luaerr.l + 1));
snprintf(err, (luaerr.l + 1), "%s", luaerr.s);
- last_lua_error = err;
+ last_lua_error = err; /* hm, what if we have several .. not freed */
}
if (is_fatal > 0) {
/* Normally a memory error from lua.
The pool may overflow during the |maketexlstring()|, but we
are crashing anyway so we may as well abort on the pool size */
- lua_fatal_error(err);
+ normal_error("lua",err);
/* never reached */
- xfree(err);
lua_close(L);
return (lua_State *) NULL;
} else {
- lua_norm_error(err);
- /* last_lua_error = err so no need to xfree(err) */
+ normal_warning("lua",err,true,true);
return L;
}
}
@@ -624,83 +611,77 @@ void preset_environment(lua_State * L, const parm_struct * p, const char *s)
lua_settable(L, LUA_REGISTRYINDEX); /* - */
}
-
@ @c
/*
-int luaL_typerror (void *LL, int narg, const char *tname)
-{
- lua_State *L = (lua_State *)LL;
- const char *msg = lua_pushfstring(L, "%s expected, got %s",
- tname, luaL_typename(L, narg));
- return luaL_argerror(L, narg, msg);
-}
+ int luaL_typerror (void *LL, int narg, const char *tname)
+ {
+ lua_State *L = (lua_State *)LL;
+ const char *msg = lua_pushfstring(L, "%s expected, got %s",
+ tname, luaL_typename(L, narg));
+ return luaL_argerror(L, narg, msg);
+ }
*/
-
/*
-
-
-Compatibility layer for luatex lua5.2
-
+ Compatibility layer for luatex lua5.2
*/
-
-
@ @c
LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
- void *p = lua_touserdata(L, ud);
- if (p != NULL) { /* value is a userdata? */
- if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
- luaL_getmetatable(L, tname); /* get correct metatable */
- if (!lua_rawequal(L, -1, -2)) /* not the same? */
- p = NULL; /* value is a userdata with wrong metatable */
- lua_pop(L, 2); /* remove both metatables */
- return p;
+ void *p = lua_touserdata(L, ud);
+ if (p != NULL) { /* value is a userdata? */
+ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
+ luaL_getmetatable(L, tname); /* get correct metatable */
+ if (!lua_rawequal(L, -1, -2)) /* not the same? */
+ p = NULL; /* value is a userdata with wrong metatable */
+ lua_pop(L, 2); /* remove both metatables */
+ return p;
+ }
}
- }
- return NULL; /* value is not a userdata with a metatable */
+ return NULL; /* value is not a userdata with a metatable */
}
@ @c
+
/* It's not ok. See lua-users.org/wiki/CompatibilityWithLuaFive for another solution */
+
LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
- /*luaL_checkversion(L);*/
- luaL_checkstack(L, nup, "too many upvalues");
- for (; l->name != NULL; l++) { /* fill the table with given functions */
- int i;
- for (i = 0; i < nup; i++) /* copy upvalues to the top */
- lua_pushvalue(L, -nup);
- lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
- lua_setfield(L, -(nup + 2), l->name);
- }
- lua_pop(L, nup); /* remove upvalues */
+ /*luaL_checkversion(L);*/
+ luaL_checkstack(L, nup, "too many upvalues");
+ for (; l->name != NULL; l++) { /* fill the table with given functions */
+ int i;
+ for (i = 0; i < nup; i++) /* copy upvalues to the top */
+ lua_pushvalue(L, -nup);
+ lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
+ lua_setfield(L, -(nup + 2), l->name);
+ }
+ lua_pop(L, nup); /* remove upvalues */
}
-
@ @c
LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
- lua_State *L = B->L;
- if (sz > LUAL_BUFFERSIZE )
- luaL_error(L, "buffer too large");
- return luaL_prepbuffer(B) ;
+ lua_State *L = B->L;
+ if (sz > LUAL_BUFFERSIZE )
+ luaL_error(L, "buffer too large");
+ return luaL_prepbuffer(B) ;
}
@ @c
LUA_API int lua_compare (lua_State *L, int o1, int o2, int op) {
- /*StkId o1, o2;*/
- int i = 0;
- lua_lock(L); /* may call tag method */
- /* o1 = index2addr(L, index1); */
- /* o2 = index2addr(L, index2); */
- /*if (isvalid(o1) && isvalid(o2)) {*/
+ /*StkId o1, o2;*/
+ int i = 0;
+ lua_lock(L); /* may call tag method */
+ /* o1 = index2addr(L, index1); */
+ /* o2 = index2addr(L, index2); */
+ /*if (isvalid(o1) && isvalid(o2)) {*/
switch (op) {
- case LUA_OPEQ: i = lua_equal(L, o1, o2); break;
- case LUA_OPLT: i = lua_lessthan(L, o1, o2); break;
- case LUA_OPLE: i = (lua_lessthan(L, o1, o2) || lua_equal(L, o1, o2)) ; break;
- default: luaL_error(L, "invalid option");
+ case LUA_OPEQ: i = lua_equal(L, o1, o2); break;
+ case LUA_OPLT: i = lua_lessthan(L, o1, o2); break;
+ case LUA_OPLE: i = (lua_lessthan(L, o1, o2) || lua_equal(L, o1, o2)) ; break;
+ default: luaL_error(L, "invalid option");
}
- /*}*/
- lua_unlock(L);
- return i;
+ /*}*/
+ lua_unlock(L);
+ return i;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w
index a9da3cb1c34..c1da8f2d1ca 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luanode.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w
@@ -18,47 +18,15 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
/* hh-ls: we make sure that lua never sees prev of head but also that when
-nodes are removedor inserted, temp nodes don't interfere */
+nodes are removed or inserted, temp nodes don't interfere */
@ @c
-
#include "ptexlib.h"
#include "lua/luatex-api.h"
-/* TO BE REMOVED
-static const char *group_code_names[] = {
- "",
- "simple",
- "hbox",
- "adjusted_hbox",
- "vbox",
- "vtop",
- "align",
- "no_align",
- "output",
- "math",
- "disc",
- "insert",
- "vcenter",
- "math_choice",
- "semi_simple",
- "math_shift",
- "math_left",
- "local_box",
- "split_off",
- "split_keep",
- "preamble",
- "align_set",
- "fin_row"
-};
-
-const char *pack_type_name[] = { "exactly", "additional" };
-*/
-
@ @c
-void
-lua_node_filter_s(int filterid, int extrainfo)
+void lua_node_filter_s(int filterid, int extrainfo)
{
lua_State *L = Luas;
int callback_id = callback_defined(filterid);
@@ -82,10 +50,8 @@ lua_node_filter_s(int filterid, int extrainfo)
return;
}
-
@ @c
-void
-lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
+void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
{
halfword ret;
int a;
@@ -134,8 +100,7 @@ lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail
}
@ @c
-int
-lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head)
+int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head)
{
int a;
register halfword *p;
@@ -160,7 +125,6 @@ lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head)
error();
return ret;
}
-
p = lua_touserdata(L, -1);
if (p != NULL) {
a = nodelist_from_lua(L);
@@ -171,12 +135,48 @@ lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head)
return ret;
}
-
+@ @c
+int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, boolean is_mirrored, halfword * result, int * next_depth, boolean * prev_set)
+{
+ register halfword *p;
+ lua_State *L = Luas;
+ int s_top = lua_gettop(L);
+ int callback_id = callback_defined(append_to_vlist_filter_callback);
+ if (box == null || callback_id <= 0) {
+ lua_settop(L, s_top);
+ return 0;
+ }
+ if (!get_callback(L, callback_id)) {
+ lua_settop(L, s_top);
+ return 0;
+ }
+ nodelist_to_lua(L, box);
+ lua_push_string_by_index(L,location);
+ lua_pushnumber(L, (int) prev_depth);
+ lua_pushboolean(L, is_mirrored);
+ if (lua_pcall(L, 4, 2, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
+ lua_settop(L, s_top);
+ error();
+ return 0;
+ }
+ if (lua_type(L,-1) == LUA_TNUMBER) {
+ *next_depth = lua_tonumber(L,-1);
+ *prev_set = true;
+ if (lua_type(L, -2) != LUA_TNIL) {
+ p = check_isnode(L, -2);
+ *result = *p;
+ }
+ } else if (lua_type(L, -1) != LUA_TNIL) {
+ p = check_isnode(L, -1);
+ *result = *p;
+ }
+ lua_settop(L, s_top);
+ return 1;
+}
@ @c
-halfword
-lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo,
- int pack_direction)
+halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction)
{
halfword ret;
lua_State *L = Luas;
@@ -224,8 +224,7 @@ lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo,
}
@ @c
-halfword
-lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd,
+halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd,
int extrainfo, int pack_direction)
{
halfword ret;
@@ -283,7 +282,6 @@ lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd,
return ret;
}
-
@ This is a quick hack to fix etex's \.{\\lastnodetype} now that
there are many more visible node types. TODO: check the
eTeX manual for the expected return values.
@@ -292,20 +290,12 @@ lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd,
int visible_last_node_type(int n)
{
int i = type(n);
- if (i == whatsit_node && subtype(n) == local_par_node)
- return -1;
- if (i == glyph_node) {
- if (is_ligature(n))
- return 7; /* old ligature value */
- else
- return 0; /* old character value */
- }
- if (i <= unset_node) {
- return i + 1;
- } else if (i <= delim_node) {
- return 15; /* so-called math nodes */
+ if (i != glyph_node) {
+ return get_etex_code(i);
+ } else if (is_ligature(n)) {
+ return 7; /* old ligature value */
} else {
- return -1;
+ return 0; /* old character value */
}
}
@@ -359,7 +349,6 @@ void copy_user_lua(pointer r, pointer p)
}
}
-
@ @c
void free_pdf_literal(pointer p)
{
@@ -389,7 +378,6 @@ void free_user_lua(pointer p)
}
}
-
@ @c
void show_pdf_literal(pointer p)
{
diff --git a/Build/source/texk/web2c/luatexdir/lua/luastuff.w b/Build/source/texk/web2c/luatexdir/lua/luastuff.w
index d247bb882b0..2ac671ae7a7 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luastuff.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luastuff.w
@@ -18,8 +18,6 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
#include "lua/luatex-api.h"
@@ -27,7 +25,6 @@
lua_State *Luas = NULL;
int luastate_bytes = 0;
-
int lua_active = 0;
@ @c
@@ -56,8 +53,7 @@ void make_table(lua_State * L, const char *tab, const char *mttab, const char *g
}
@ @c
-static
-const char *getS(lua_State * L, void *ud, size_t * size)
+static const char *getS(lua_State * L, void *ud, size_t * size)
{
LoadS *ls = (LoadS *) ud;
(void) L;
@@ -85,12 +81,10 @@ static void *my_luaalloc(void *ud, void *ptr, size_t osize, size_t nsize)
static int my_luapanic(lua_State * L)
{
(void) L; /* to avoid warnings */
- fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
- lua_tostring(L, -1));
+ fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", lua_tostring(L, -1));
return 0;
}
-
@ @c
void luafunctioncall(int slot)
{
@@ -116,10 +110,6 @@ void luafunctioncall(int slot)
lua_active--;
}
-
-
-
-
@ @c
static const luaL_Reg lualibs[] = {
{"", luaopen_base},
@@ -141,7 +131,6 @@ static const luaL_Reg lualibs[] = {
{NULL, NULL}
};
-
@ @c
static void do_openlibs(lua_State * L)
{
@@ -204,7 +193,6 @@ static int luatex_dofile (lua_State *L) {
return lua_gettop(L) - n;
}
-
@ @c
void luainterpreter(void)
{
@@ -267,8 +255,8 @@ void luainterpreter(void)
/* our own libraries */
luaopen_ff(L);
luaopen_tex(L);
+ luaopen_oldtoken(L);
luaopen_token(L);
- luaopen_newtoken(L);
luaopen_node(L);
luaopen_texio(L);
luaopen_kpse(L);
@@ -368,10 +356,9 @@ void unhide_lua_value(lua_State * L, const char *name, const char *item, int r)
}
}
-
@ @c
int lua_traceback(lua_State * L)
-{
+{
lua_getglobal(L, "debug");
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
@@ -464,8 +451,6 @@ static void luacall(int p, int nameptr, boolean is_string) /* hh-ls: optimized l
lua_active--;
}
-
-
@ @c
void late_lua(PDF pdf, halfword p)
{
@@ -532,24 +517,23 @@ lua_State *luatex_error(lua_State * L, int is_fatal)
const_lstring luaerr;
char *err = NULL;
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
luaerr.s = lua_tolstring(L, -1, &luaerr.l);
+ /* free last one ? */
err = (char *) xmalloc((unsigned) (luaerr.l + 1));
snprintf(err, (luaerr.l + 1), "%s", luaerr.s);
- last_lua_error = err;
+ last_lua_error = err; /* hm, what if we have several .. not freed */
}
if (is_fatal > 0) {
/* Normally a memory error from lua.
The pool may overflow during the |maketexlstring()|, but we
are crashing anyway so we may as well abort on the pool size */
- lua_fatal_error(err);
+ normal_error("lua",err);
/* never reached */
- xfree(err);
lua_close(L);
return (lua_State *) NULL;
} else {
- lua_norm_error(err);
- /* last_lua_error = err so no need to xfree(err) */
+ normal_warning("lua",err,true,true);
return L;
}
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index 3dff78d9b3c..8c99cf72519 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -17,10 +17,29 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
#ifndef LUATEX_API_H
# define LUATEX_API_H 1
+/* output modes, a bad place but this compiles at least */
+
+typedef enum { OMODE_NONE, OMODE_DVI, OMODE_PDF } output_mode ;
+
+# define MAX_OMODE 2 /* largest index in enum output_mode */
+
+extern int output_mode_used;
+extern int output_mode_option;
+extern int output_mode_value;
+extern int draft_mode_option;
+extern int draft_mode_value;
+
+/* get_o_mode translates from output_mode to output_mode_used */
+/* fix_o_mode freezes output_mode as soon as anything goes through the backend */
+
+extern output_mode get_o_mode(void);
+extern void fix_o_mode(void);
+
+/* till here */
+
# include <stdlib.h>
# include <stdio.h>
# include <stdarg.h>
@@ -53,15 +72,12 @@ extern void make_table(lua_State * L, const char *tab, const char *mttab, const
extern int luac_main(int argc, char *argv[]);
extern int luaopen_tex(lua_State * L);
-
extern int luaopen_pdf(lua_State * L);
-
-# define LUA_TEXFILEHANDLE "TEXFILE*"
-
extern int luaopen_texio(lua_State * L);
-
extern int luaopen_lang(lua_State * L);
+# define LUA_TEXFILEHANDLE "TEXFILE*"
+
extern lua_State *luatex_error(lua_State * L, int fatal);
extern int luaopen_unicode(lua_State * L);
@@ -112,14 +128,15 @@ extern int luaopen_vf(lua_State * L);
extern int font_to_lua(lua_State * L, int f);
extern int font_from_lua(lua_State * L, int f); /* return is boolean */
+extern int luaopen_oldtoken(lua_State * L);
extern int luaopen_token(lua_State * L);
-extern int luaopen_newtoken(lua_State * L);
extern void tokenlist_to_lua(lua_State * L, int p);
extern void tokenlist_to_luastring(lua_State * L, int p);
extern int tokenlist_from_lua(lua_State * L);
extern void lua_nodelib_push(lua_State * L);
extern int nodelib_getdir(lua_State * L, int n, int absolute_only);
+extern int nodelib_getlist(lua_State * L, int n);
extern int luaopen_node(lua_State * L);
extern void nodelist_to_lua(lua_State * L, int n);
@@ -172,9 +189,6 @@ extern int saved_callback_count;
extern const char *luatex_banner;
-extern const char *last_lua_error;
-
-
/* luastuff.h */
typedef struct {
@@ -182,8 +196,7 @@ typedef struct {
int idx; /* index within img_parms array */
} parm_struct;
-extern void preset_environment(lua_State * L, const parm_struct * p,
- const char *s);
+extern void preset_environment(lua_State * L, const parm_struct * p, const char *s);
extern char *startup_filename;
extern int safer_option;
@@ -198,17 +211,15 @@ extern int program_name_set; /* in lkpselib.c */
extern char **argv;
extern int argc;
-extern int loader_C_luatex(lua_State * L, const char *name,
- const char *filename);
-extern int loader_Call_luatex(lua_State * L, const char *name,
- const char *filename);
+extern int loader_C_luatex(lua_State * L, const char *name, const char *filename);
+extern int loader_Call_luatex(lua_State * L, const char *name, const char *filename);
extern void init_tex_table(lua_State * L);
extern int tex_table_id;
extern int pdf_table_id;
-extern int newtoken_table_id;
extern int token_table_id;
+extern int oldtoken_table_id;
extern int node_table_id;
extern int main_initialize(void);
@@ -217,7 +228,6 @@ extern int lua_traceback(lua_State * L);
extern int luainit;
-
extern char *luanames[];
extern int ff_get_ttc_index(char *ffname, char *psname); /* luafontloader/src/luafflib.c */
@@ -242,27 +252,22 @@ extern char **environ;
*/
-/*#define init_luaS_index(a) do { */
#define init_lua_key(a) do { \
lua_pushliteral(Luas,#a); \
luaS_##a##_ptr = lua_tostring(Luas,-1); \
luaS_##a##_index = luaL_ref (Luas,LUA_REGISTRYINDEX); \
} while (0)
- /*#define init_luaS_index_s(a,b) do { */
#define init_lua_key_alias(a,b) do { \
lua_pushliteral(Luas,b); \
luaS_##a##_ptr = lua_tostring(Luas,-1); \
luaS_##a##_index = luaL_ref (Luas,LUA_REGISTRYINDEX); \
} while (0)
- /*#define make_luaS_index(a) */
#define make_lua_key(a) \
int luaS_##a##_index = 0; \
const char * luaS_##a##_ptr = NULL
-
-/*#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr)*/
#define lua_key_eq(a,b) (a==luaS_##b##_ptr)
#define luaS_index(a) luaS_##a##_index
@@ -272,7 +277,6 @@ extern char **environ;
extern int luaS_##a##_index ; \
extern const char * luaS_##a##_ptr
-
#define lua_key_rawgeti(a) \
lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index);\
lua_rawget(L, -2)
@@ -282,9 +286,9 @@ extern char **environ;
lua_rawget(L, -1+n)
/*
-Unfortunately floor is already redefined as
+Unfortunately floor is already redefined as
#define floor ((integer)floor((double)(a)))
-so
+so
#define lua_uroundnumber(a,b) (unsigned int)floor((double)(lua_tonumber(a,b)+0.5))
is useless.
*/
@@ -294,7 +298,6 @@ is useless.
extern int lua_numeric_field_by_index(lua_State *, int , int);
extern unsigned int lua_unsigned_numeric_field_by_index(lua_State *, int , int);
-
/* Currently we sometimes use numbers and sometimes strings in node properties. We can
make that consistent by having a check on number and if not then assign a string. The
strings are prehashed and we make a bunch of lua tables that have these values. We can
@@ -305,27 +308,26 @@ preassign these at startup time. */
#define PACK_TYPE_SIZE 4
#define GROUP_CODE_SIZE 23
#define MATH_STYLE_NAME_SIZE 8
-#define DIR_PAR_SIZE 128
-#define DIR_TEXT_SIZE 128
+#define APPEND_LIST_SIZE 5
+#define DIR_PAR_SIZE 8
+#define DIR_TEXT_SIZE 8
-extern int l_pack_type_index [PACK_TYPE_SIZE] ;
+extern int l_pack_type_index [PACK_TYPE_SIZE];
extern int l_group_code_index [GROUP_CODE_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_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_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+64])
-#define lua_push_dir_text(L,dir) lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index[dir+64])
-
+#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])
#define lua_push_string_by_index(L,index) lua_rawgeti(L, LUA_REGISTRYINDEX, index)
#define lua_push_string_by_name(L,index) lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(index))
-
-#define set_pack_type_index \
+#define set_l_pack_type_index \
l_pack_type_index[0] = lua_key_index(exactly); \
l_pack_type_index[1] = lua_key_index(additional); \
l_pack_type_index[2] = lua_key_index(cal_expand_ratio);\
@@ -368,24 +370,23 @@ l_math_style_name_index[7] = lua_key_index(crampedscriptscript)
#define set_l_dir_par_index \
l_dir_par_index[0] = lua_key_index(TLT);\
-l_dir_par_index[4] = lua_key_index(TRT);\
-l_dir_par_index[9] = lua_key_index(LTL);\
-l_dir_par_index[24] = lua_key_index(RTT);\
-l_dir_par_index[64] = lua_key_index(TLT);\
-l_dir_par_index[68] = lua_key_index(TRT);\
-l_dir_par_index[73] = lua_key_index(LTL);\
-l_dir_par_index[88] = lua_key_index(RTT);\
+l_dir_par_index[1] = lua_key_index(TRT);\
+l_dir_par_index[2] = lua_key_index(LTL);\
+l_dir_par_index[3] = lua_key_index(RTT);\
+l_dir_par_index[4] = lua_key_index(TLT);\
+l_dir_par_index[5] = lua_key_index(TRT);\
+l_dir_par_index[6] = lua_key_index(LTL);\
+l_dir_par_index[7] = lua_key_index(RTT);\
#define set_l_dir_text_index \
l_dir_text_index[0] = lua_key_index(mTLT);\
-l_dir_text_index[4] = lua_key_index(mTRT);\
-l_dir_text_index[9] = lua_key_index(mLTL);\
-l_dir_text_index[24] = lua_key_index(mRTT);\
-l_dir_text_index[64] = lua_key_index(pTLT);\
-l_dir_text_index[68] = lua_key_index(pTRT);\
-l_dir_text_index[73] = lua_key_index(pLTL);\
-l_dir_text_index[88] = lua_key_index(pRTT);\
-
+l_dir_text_index[1] = lua_key_index(mTRT);\
+l_dir_text_index[2] = lua_key_index(mLTL);\
+l_dir_text_index[3] = lua_key_index(mRTT);\
+l_dir_text_index[4] = lua_key_index(pTLT);\
+l_dir_text_index[5] = lua_key_index(pTRT);\
+l_dir_text_index[6] = lua_key_index(pLTL);\
+l_dir_text_index[7] = lua_key_index(pRTT);\
#define set_make_keys \
make_lua_key(cmdname);make_lua_key(expandable);make_lua_key(protected);\
@@ -476,6 +477,8 @@ make_lua_key(encodingbytes);\
make_lua_key(encodingname);\
make_lua_key(end);\
make_lua_key(etex);\
+make_lua_key(equation);\
+make_lua_key(equation_number);\
make_lua_key(exactly);\
make_lua_key(expansion_factor);\
make_lua_key(ext);\
@@ -485,14 +488,17 @@ make_lua_key(extensible);\
make_lua_key(extra_space);\
make_lua_key(fam);\
make_lua_key(fast);\
+make_lua_key(fence);\
make_lua_key(file);\
make_lua_key(filename);\
+make_lua_key(fill);\
make_lua_key(fin_row);\
make_lua_key(font);\
make_lua_key(fonts);\
make_lua_key(format);\
make_lua_key(fullname);\
make_lua_key(global);\
+make_lua_key(glue);\
make_lua_key(glue_order);\
make_lua_key(glue_set);\
make_lua_key(glue_sign);\
@@ -532,12 +538,14 @@ make_lua_key(log);\
make_lua_key(lua);\
make_lua_key(lua_functions);\
make_lua_key(luatex);\
-make_lua_key(luatex_newtoken);\
make_lua_key(luatex_node);\
+make_lua_key(luatex_oldtoken);\
+make_lua_key(luatex_token);\
make_lua_key(mLTL);\
make_lua_key(mRTT);\
make_lua_key(mTLT);\
make_lua_key(mTRT);\
+make_lua_key(marginkern);\
make_lua_key(mark);\
make_lua_key(math);\
make_lua_key(math_choice);\
@@ -568,8 +576,11 @@ make_lua_key(num);\
make_lua_key(number);\
make_lua_key(objcompression);\
make_lua_key(objnum);\
+make_lua_key(oldmath);\
make_lua_key(ordering);\
+make_lua_key(origin);\
make_lua_key(output);\
+make_lua_key(overlay_accent);\
make_lua_key(pLTL);\
make_lua_key(pRTT);\
make_lua_key(pTLT);\
@@ -583,11 +594,14 @@ make_lua_key(pagesattributes);\
make_lua_key(parameters);\
make_lua_key(pdf_data);\
make_lua_key(pdftex);\
+make_lua_key(pdf_destination);\
+make_lua_key(pdf_literal);\
make_lua_key(pen_broken);\
make_lua_key(pen_inter);\
make_lua_key(penalty);\
make_lua_key(pop);\
make_lua_key(post);\
+make_lua_key(post_linebreak);\
make_lua_key(pre);\
make_lua_key(pre_adjust);\
make_lua_key(pre_adjust_head);\
@@ -601,6 +615,7 @@ make_lua_key(psname);\
make_lua_key(ptr);\
make_lua_key(push);\
make_lua_key(quad);\
+make_lua_key(radical);\
make_lua_key(raw);\
make_lua_key(ref_count);\
make_lua_key(reg);\
@@ -608,6 +623,7 @@ make_lua_key(registry);\
make_lua_key(renew);\
make_lua_key(rep);\
make_lua_key(replace);\
+make_lua_key(resources);\
make_lua_key(right);\
make_lua_key(right_boundary);\
make_lua_key(right_protruding);\
@@ -677,17 +693,19 @@ make_lua_key(value);\
make_lua_key(vbox);\
make_lua_key(vcenter);\
make_lua_key(version);\
+make_lua_key(vert_italic);\
make_lua_key(vert_variants);\
make_lua_key(vmode_par);\
make_lua_key(vtop);\
make_lua_key(width);\
make_lua_key(writable);\
make_lua_key(x_height);\
+make_lua_key(xformresources);\
+make_lua_key(xformattributes);\
make_lua_key(xoffset);\
make_lua_key(xyz_zoom);\
make_lua_key(yoffset)
-
#define set_init_keys \
init_lua_key(cmdname);init_lua_key(expandable);init_lua_key(protected);\
init_lua_key(LTL);\
@@ -776,6 +794,8 @@ init_lua_key(encodingbytes);\
init_lua_key(encodingname);\
init_lua_key(end);\
init_lua_key(etex);\
+init_lua_key(equation);\
+init_lua_key(equation_number);\
init_lua_key(exactly);\
init_lua_key(expansion_factor);\
init_lua_key(ext);\
@@ -785,14 +805,17 @@ init_lua_key(extensible);\
init_lua_key(extra_space);\
init_lua_key(fam);\
init_lua_key(fast);\
+init_lua_key(fence);\
init_lua_key(file);\
init_lua_key(filename);\
+init_lua_key(fill);\
init_lua_key(fin_row);\
init_lua_key(font);\
init_lua_key(fonts);\
init_lua_key(format);\
init_lua_key(fullname);\
init_lua_key(global);\
+init_lua_key(glue);\
init_lua_key(glue_order);\
init_lua_key(glue_set);\
init_lua_key(glue_sign);\
@@ -830,8 +853,12 @@ init_lua_key(list);\
init_lua_key(local_box);\
init_lua_key(log);\
init_lua_key(lua);\
+init_lua_key(lua_functions);\
init_lua_key(luatex);\
-init_lua_key(luatex_newtoken);\
+init_lua_key(luatex_node);\
+init_lua_key(luatex_oldtoken);\
+init_lua_key(luatex_token);\
+init_lua_key(marginkern);\
init_lua_key(mark);\
init_lua_key(math);\
init_lua_key(math_choice);\
@@ -860,8 +887,11 @@ init_lua_key(num);\
init_lua_key(number);\
init_lua_key(objcompression);\
init_lua_key(objnum);\
+init_lua_key(oldmath);\
+init_lua_key(origin);\
init_lua_key(ordering);\
init_lua_key(output);\
+init_lua_key(overlay_accent);\
init_lua_key(page);\
init_lua_key(page_head);\
init_lua_key(page_ins_head);\
@@ -870,11 +900,14 @@ init_lua_key(pageresources);\
init_lua_key(pagesattributes);\
init_lua_key(parameters);\
init_lua_key(pdftex);\
+init_lua_key(pdf_destination);\
+init_lua_key(pdf_literal);\
init_lua_key(pen_broken);\
init_lua_key(pen_inter);\
init_lua_key(penalty);\
init_lua_key(pop);\
init_lua_key(post);\
+init_lua_key(post_linebreak);\
init_lua_key(pre);\
init_lua_key(pre_adjust);\
init_lua_key(pre_adjust_head);\
@@ -888,6 +921,7 @@ init_lua_key(psname);\
init_lua_key(ptr);\
init_lua_key(push);\
init_lua_key(quad);\
+init_lua_key(radical);\
init_lua_key(raw);\
init_lua_key(ref_count);\
init_lua_key(reg);\
@@ -895,6 +929,7 @@ init_lua_key(registry);\
init_lua_key(renew);\
init_lua_key(rep);\
init_lua_key(replace);\
+init_lua_key(resources);\
init_lua_key(right);\
init_lua_key(right_boundary);\
init_lua_key(right_protruding);\
@@ -963,12 +998,15 @@ init_lua_key(value);\
init_lua_key(vbox);\
init_lua_key(vcenter);\
init_lua_key(version);\
+init_lua_key(vert_italic);\
init_lua_key(vert_variants);\
init_lua_key(vmode_par);\
init_lua_key(vtop);\
init_lua_key(width);\
init_lua_key(writable);\
init_lua_key(x_height);\
+init_lua_key(xformresources);\
+init_lua_key(xformattributes);\
init_lua_key(xoffset);\
init_lua_key(xyz_zoom);\
init_lua_key(yoffset);\
@@ -988,12 +1026,11 @@ init_lua_key_alias(pTRT,"+TRT");\
init_lua_key_alias(pdf_data,"pdf.data");\
init_lua_key_alias(term_and_log,"term and log")
-
#define assign_math_style(L,n,target) do { \
- if (lua_isnumber(L,n)) { \
+ if (lua_type(L,n) == LUA_TNUMBER) { \
/* new, often same as subtype anyway */ \
target = lua_tonumber(L,n); \
- } else if (lua_isstring(L,n)) { \
+ } else if (lua_type(L,n) == LUA_TSTRING) { \
const char *s = lua_tostring(L, n); \
if (lua_key_eq(s,display)) { \
target = 0; \
@@ -1019,40 +1056,17 @@ init_lua_key_alias(term_and_log,"term and log")
} \
} while(0)
-
-
-
#ifdef __MINGW32__
extern FILE *_cairo_win32_tmpfile( void );
#define tmpfile() _cairo_win32_tmpfile()
#endif /* __MINGW32__ */
-
-
-/*
-* experimental code (no primitive):
-
- 0 = all
- 1 = retain math nodes
-
-*/
-
-#define max_experimental_code 1
-#define MAX_EXPERIMENTAL_CODE_SIZE max_experimental_code+1
-/* to be indexed by i with 1<= i <=max_experimental_code */
-extern int experimental_code[MAX_EXPERIMENTAL_CODE_SIZE] ;
-
-
#endif /* LUATEX_API_H */
-
-
-
/* */
/* These keys have to available to different files */
/* */
-
use_lua_key(cmdname);use_lua_key(expandable);use_lua_key(protected);
use_lua_key(LTL);
@@ -1142,6 +1156,8 @@ use_lua_key(encodingbytes);
use_lua_key(encodingname);
use_lua_key(end);
use_lua_key(etex);
+use_lua_key(equation);\
+use_lua_key(equation_number);\
use_lua_key(exactly);
use_lua_key(expansion_factor);
use_lua_key(ext);
@@ -1151,14 +1167,17 @@ use_lua_key(extensible);
use_lua_key(extra_space);
use_lua_key(fam);
use_lua_key(fast);
+use_lua_key(fence);
use_lua_key(file);
use_lua_key(filename);
+use_lua_key(fill);
use_lua_key(fin_row);
use_lua_key(font);
use_lua_key(fonts);
use_lua_key(format);
use_lua_key(fullname);
use_lua_key(global);
+use_lua_key(glue);
use_lua_key(glue_order);
use_lua_key(glue_set);
use_lua_key(glue_sign);
@@ -1198,12 +1217,14 @@ use_lua_key(log);
use_lua_key(lua);
use_lua_key(lua_functions);
use_lua_key(luatex);
-use_lua_key(luatex_newtoken);
use_lua_key(luatex_node);
+use_lua_key(luatex_oldtoken);
+use_lua_key(luatex_token);
use_lua_key(mLTL);
use_lua_key(mRTT);
use_lua_key(mTLT);
use_lua_key(mTRT);
+use_lua_key(marginkern);
use_lua_key(mark);
use_lua_key(math);
use_lua_key(math_choice);
@@ -1234,8 +1255,11 @@ use_lua_key(num);
use_lua_key(number);
use_lua_key(objcompression);
use_lua_key(objnum);
+use_lua_key(oldmath);
+use_lua_key(origin);
use_lua_key(ordering);
use_lua_key(output);
+use_lua_key(overlay_accent);
use_lua_key(pLTL);
use_lua_key(pRTT);
use_lua_key(pTLT);
@@ -1249,11 +1273,14 @@ use_lua_key(pagesattributes);
use_lua_key(parameters);
use_lua_key(pdf_data);
use_lua_key(pdftex);
+use_lua_key(pdf_destination);\
+use_lua_key(pdf_literal);\
use_lua_key(pen_broken);
use_lua_key(pen_inter);
use_lua_key(penalty);
use_lua_key(pop);
use_lua_key(post);
+use_lua_key(post_linebreak);
use_lua_key(pre);
use_lua_key(pre_adjust);
use_lua_key(pre_adjust_head);
@@ -1267,6 +1294,7 @@ use_lua_key(psname);
use_lua_key(ptr);
use_lua_key(push);
use_lua_key(quad);
+use_lua_key(radical);
use_lua_key(raw);
use_lua_key(ref_count);
use_lua_key(reg);
@@ -1274,6 +1302,7 @@ use_lua_key(registry);
use_lua_key(renew);
use_lua_key(rep);
use_lua_key(replace);
+use_lua_key(resources);
use_lua_key(right);
use_lua_key(right_boundary);
use_lua_key(right_protruding);
@@ -1343,12 +1372,15 @@ use_lua_key(value);
use_lua_key(vbox);
use_lua_key(vcenter);
use_lua_key(version);
+use_lua_key(vert_italic);
use_lua_key(vert_variants);
use_lua_key(vmode_par);
use_lua_key(vtop);
use_lua_key(width);
use_lua_key(writable);
use_lua_key(x_height);
+use_lua_key(xformresources);
+use_lua_key(xformattributes);
use_lua_key(xoffset);
use_lua_key(xyz_zoom);
use_lua_key(yoffset);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
index cf91a6f7bf8..f0ff08eec54 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatoken.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
#include "lua/luatex-api.h"
@@ -60,6 +59,8 @@ command_item command_names[] = {
{"halign", halign_cmd, NULL},
{"valign", valign_cmd, NULL},
{"no_align", no_align_cmd, NULL},
+ {"novrule", no_vrule_cmd, NULL},
+ {"nohrule", no_hrule_cmd, NULL},
{"vrule", vrule_cmd, NULL},
{"hrule", hrule_cmd, NULL},
{"insert", insert_cmd, NULL},
@@ -84,12 +85,15 @@ command_item command_names[] = {
{"vcenter", vcenter_cmd, NULL},
{"case_shift", case_shift_cmd, NULL},
{"message", message_cmd, NULL},
+ {"normal", normal_cmd, NULL},
{"extension", extension_cmd, NULL},
+ {"option", option_cmd, NULL},
{"in_stream", in_stream_cmd, NULL},
{"begin_group", begin_group_cmd, NULL},
{"end_group", end_group_cmd, NULL},
{"omit", omit_cmd, NULL},
{"ex_space", ex_space_cmd, NULL},
+ {"boundary", boundary_cmd, NULL},
{"no_boundary", no_boundary_cmd, NULL},
{"radical", radical_cmd, NULL},
{"super_sub_script", super_sub_script_cmd, NULL},
@@ -140,7 +144,9 @@ command_item command_names[] = {
{"hyph_data", hyph_data_cmd, NULL},
{"set_interaction", set_interaction_cmd, NULL},
{"letterspace_font", letterspace_font_cmd, NULL},
- {"pdf_copy_font", pdf_copy_font_cmd, NULL},
+ {"expand_font",expand_font_cmd, NULL},
+ {"copy_font", copy_font_cmd, NULL},
+ {"set_font_id", set_font_id_cmd, NULL},
{"undefined_cs", undefined_cs_cmd, NULL},
{"expand_after", expand_after_cmd, NULL},
{"no_expand", no_expand_cmd, NULL},
@@ -243,7 +249,7 @@ static int get_cur_cs(lua_State * L)
ret = 0;
cur_cs = 0;
lua_getfield(L, -1, "name");
- if (lua_isstring(L, -1)) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
s = lua_tolstring(L, -1, &l);
if (l > 0) {
if ((last + (int) l) > buf_size)
@@ -301,7 +307,7 @@ void tokenlist_to_luastring(lua_State * L, int p)
char *s;
s = tokenlist_to_cstring(p, 1, &l);
lua_pushlstring(L, s, (size_t) l);
- free(s);
+ free(s);
}
@@ -309,14 +315,15 @@ void tokenlist_to_luastring(lua_State * L, int p)
int tokenlist_from_lua(lua_State * L)
{
const char *s;
- int tok;
+ int tok, t;
size_t i, j;
halfword p, q, r;
r = get_avail();
token_info(r) = 0; /* ref count */
token_link(r) = null;
p = r;
- if (lua_istable(L, -1)) {
+ t = lua_type(L, -1);
+ if (t == LUA_TTABLE) {
j = lua_rawlen(L, -1);
if (j > 0) {
for (i = 1; i <= j; i++) {
@@ -329,7 +336,7 @@ int tokenlist_from_lua(lua_State * L)
};
}
return r;
- } else if (lua_isstring(L, -1)) {
+ } else if (t == LUA_TSTRING) {
s = lua_tolstring(L, -1, &j);
for (i = 0; i < j; i++) {
if (s[i] == 32) {
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/fontviewbase.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/fontviewbase.c
index 24798ad09ee..aa0ed46aeb8 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/fontviewbase.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/fontviewbase.c
@@ -112,6 +112,9 @@ static void FontViewBase_Free(FontViewBase *fv) {
int i;
FontViewBase *prev;
+ if (fv->cidmaster)
+ EncMapFree(fv->cidmaster->map);
+
if ( fv->nextsame==NULL && fv->sf->fv==fv ) {
EncMapFree(fv->map);
SplineFontFree(fv->cidmaster?fv->cidmaster:fv->sf);
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macenc.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macenc.c
index 66128685dcc..7dd59529e7f 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macenc.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macenc.c
@@ -1144,8 +1144,10 @@ return( NULL );
inlen = strlen(in);
outlen = (inlen+1)*4;
out = (char *) (ret = galloc(outlen+2));
- if(iconv(toutf8,&in,&inlen,&out,&outlen)==-1)
-return( NULL );
+ if(iconv(toutf8,&in,&inlen,&out,&outlen)==-1){
+ if (ret) free(ret) ;
+ if (toutf8) iconv_close(toutf8);
+return( NULL );}
out[0] = '\0';
iconv_close(toutf8);
#ifdef UNICHAR_16
@@ -1153,12 +1155,14 @@ return( NULL );
#else
toutf8 = iconv_open("UTF-8","UCS4");
#endif
- if ( toutf8==(iconv_t) -1 || toutf8==NULL )
-return( NULL );
+ if ( toutf8==(iconv_t) -1 || toutf8==NULL ){
+ if (ret) free(ret);
+ if (toutf8) iconv_close(toutf8);
+return( NULL );}
in = (char *) strdup(ret);
inlen = strlen(in);
outlen = (inlen+1)*4;
- out = (char *) (ret = galloc(outlen+2));
+ out = (char *) (ret = grealloc(ret,outlen+2));
if(iconv(toutf8,&in,&inlen,&out,&outlen)==-1)
return( NULL );
out[0] = '\0';
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
index 0a79633f11e..7586416fb16 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
@@ -478,7 +478,12 @@ return( NULL );
char *cstr = galloc(inlen);
ICONV_CONST char *in = cstr;
char *out;
- str = galloc(outlen+2);
+#ifdef UNICHAR_16
+ str = galloc(outlen+2);
+#else
+ str = galloc(outlen+sizeof(unichar_t));
+#endif
+ /*str = galloc(outlen+2);*/
out = (char *) str;
iconv(enc->tounicode,&in,&inlen,&out,&outlen);
out[0] = '\0'; out[1] = '\0';
@@ -4256,6 +4261,7 @@ static void ApplyVariationSequenceSubtable(FILE *ttf,uint32 vs_map,
}
}
}
+ free(vs_data);
}
static enum uni_interp amscheck(struct ttfinfo *info, EncMap *map) {
@@ -5062,6 +5068,8 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) {
nm[j] = getc(ttf);
nm[j] = '\0';
if ( indexes[i]<info->glyph_cnt && info->chars[indexes[i]]!=NULL ) {
+ if (info->chars[indexes[i]]->name)
+ free( info->chars[indexes[i]]->name );
info->chars[indexes[i]]->name = nm;
#if 0 /* Too many fonts have badly named glyphs */
if ( info->chars[indexes[i]]->unicodeenc==-1 )
@@ -5917,6 +5925,12 @@ static SplineFont *SFFillFromTTF(struct ttfinfo *info) {
SFRelativeWinAsDs(sf);
free(info->savetab);
+ /*if (info->chars) {
+ int i;
+ for(i=0; info->chars[i]; i++)
+ if (info->chars[i]->name)
+ free(info->chars[i]->name);
+ }*/
sf->loadvalidation_state =
(info->bad_ps_fontname ?lvs_bad_ps_fontname:0) |
(info->bad_glyph_data ?lvs_bad_glyph_table:0) |
@@ -6062,6 +6076,8 @@ static SplineFont *SFFillFromTTFInfo(struct ttfinfo *info) {
sf->pfminfo = info->pfminfo ;
free(info->savetab);
+ if (info->chosenname)
+ free(info->chosenname);
if ( sf->copyright==NULL )
sf->copyright = info->copyright;
else
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
index a3b610a7174..84e062c013e 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
@@ -496,7 +496,7 @@ return( _ReadSplineFont(NULL,filename,openflags));
SplineFont *ReadSplineFontInfo(char *filename,enum openflags openflags) {
SplineFont *sf, *sf_ptr;
- char **fontlist;
+ char **fontlist;
char *pt =NULL, *strippedname=filename, *paren=NULL, *rparen=NULL, *fullname=filename;
FILE *foo = NULL;
int checked = 0;
@@ -533,8 +533,11 @@ return( NULL );
sf = SFReadTTFInfo(fullname,0,openflags);
checked = 't';
} else if ((ch1=='t' && ch2=='t' && ch3=='c' && ch4=='f')) {
- /* read all fonts in a collection */
+ char **old_fontlist;
+ int i;
+ /* read all fonts in a collection */
fontlist = NamesReadTTF(fullname);
+ old_fontlist = fontlist;
if (fontlist) {
while (*fontlist != NULL) {
snprintf(s,511, "%s(%s)", fullname,*fontlist);
@@ -544,6 +547,12 @@ return( NULL );
sf = sf_ptr;
fontlist++;
}
+ /* fontlist is (g)allocated */
+ fontlist = old_fontlist;
+ for(i=0; fontlist[i]; i++)
+ free(fontlist[i]);
+ free(fontlist);
+ old_fontlist = NULL;
}
} else if ( strmatch(fullname+strlen(strippedname)-4, ".bin")==0 ||
strmatch(fullname+strlen(strippedname)-4, ".hqx")==0 ||
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil.c
index a3eb2203bf1..f68ddc81d39 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil.c
@@ -4313,6 +4313,7 @@ return;
for ( i=0; i < sf->layer_cnt; ++i )
free (sf->layers[i].name);
free(sf->layers);
+ free(sf->MATH);
free(sf);
}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
index 5cf5076bbcc..91dcfeee028 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
@@ -88,7 +88,6 @@ static const char *otf_lookup_type_enum[] = {
eight_nulls(), eight_nulls(),
};
-
static const char *anchor_type_enum[] = {
"mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL
};
@@ -150,8 +149,6 @@ static int is_userdata(lua_State *L, int b, const char *utype)
return 0;
}
-
-
static void lua_ff_pushfont(lua_State * L, SplineFont * sf)
{
SplineFont **a;
@@ -211,17 +208,18 @@ static int ff_open(lua_State * L)
fclose(l);
} else {
lua_pushnil(L);
- lua_pushfstring(L, "font loading failed for %s (read error)\n",
- fontname);
+ lua_pushfstring(L, "font loading failed for %s (read error)\n", fontname);
return 2;
}
args = lua_gettop(L);
- if (args >= 2 && lua_isstring(L, 2)) {
- if (*(fontname + strlen(fontname)) != ')') {
+ if (args >= 2 && (lua_type(L, 2) == LUA_TSTRING)) {
+ len = strlen(fontname);
+ if (*(fontname + len) != ')') {
/* possibly fails for embedded parens in the font name */
- snprintf(s, 511, "%s(%s)", fontname, lua_tolstring(L, 2, &len));
if (len == 0) {
snprintf(s, 511, "%s", fontname);
+ } else {
+ snprintf(s, 511, "%s(%s)", fontname, lua_tolstring(L, 2, &len));
}
}
} else {
@@ -256,13 +254,11 @@ static int ff_open(lua_State * L)
}
} else {
lua_pushnil(L);
- lua_pushfstring(L, "font loading failed: empty string given\n",
- fontname);
+ lua_pushfstring(L, "font loading failed: empty string given\n", fontname);
}
return 2;
}
-
static int ff_close(lua_State * L)
{
SplineFont **sf;
@@ -340,8 +336,6 @@ static int ff_apply_afmfile(lua_State * L)
return 1;
}
-
-
static void dump_intfield(lua_State * L, const char *name, long int field)
{
lua_checkstack(L, 2);
@@ -366,10 +360,8 @@ static void dump_realfield(lua_State * L, const char *name, real field)
lua_rawset(L, -3);
}
-
#define dump_cond_intfield(a,b,c) if ((c)!=0) { dump_intfield ((a),(b),(c)); }
-
static void dump_stringfield(lua_State * L, const char *name, const char *field)
{
lua_checkstack(L, 2);
@@ -386,7 +378,6 @@ static void dump_char_ref(lua_State * L, struct splinechar *spchar)
lua_rawset(L, -3);
}
-
static void dump_lstringfield(lua_State * L, const char *name, char *field, int len)
{
lua_checkstack(L, 2);
@@ -422,7 +413,6 @@ static char *make_tag_string(unsigned int field)
return (char *) tag_string;
}
-
static void dump_tag(lua_State * L, const char *name, unsigned int field)
{
lua_checkstack(L, 2);
@@ -452,35 +442,34 @@ static void dump_subtable_name(lua_State * L, const char *name, struct lookup_su
}
}
-
-
-#define NESTED_TABLE(a,b,c) { \
- int k = 1; \
- next = b; \
- while (next != NULL) { \
- lua_checkstack(L,2); \
- lua_pushnumber(L,k); k++; \
- lua_createtable(L,0,c); \
- a(L, next); \
- lua_rawset(L,-3); \
- next = next->next; \
- } }
-
-#define NESTED_TABLE_SF(a,b,c,d) { \
- int k = 1; \
- next = b; \
- while (next != NULL) { \
- lua_checkstack(L,2); \
- lua_pushnumber(L,k); k++; \
- lua_createtable(L,0,d); \
- if (a(L, next, c)) \
- lua_rawset(L,-3); \
- else { \
- lua_pop(L,2); \
- } \
- next = next->next; \
- } }
-
+#define NESTED_TABLE(a,b,c) { \
+ int k = 1;\
+ next = b; \
+ while (next != NULL) { \
+ lua_checkstack(L,2); \
+ lua_pushnumber(L,k); k++; \
+ lua_createtable(L,0,c); \
+ a(L, next); \
+ lua_rawset(L,-3); \
+ next = next->next; \
+ } \
+}
+
+#define NESTED_TABLE_SF(a,b,c,d) { \
+ int k = 1; \
+ next = b; \
+ while (next != NULL) { \
+ lua_checkstack(L,2); \
+ lua_pushnumber(L,k); k++; \
+ lua_createtable(L,0,d); \
+ if (a(L, next, c)) \
+ lua_rawset(L,-3); \
+ else { \
+ lua_pop(L,2); \
+ } \
+ next = next->next; \
+ } \
+}
static void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl)
{
@@ -676,8 +665,6 @@ static void handle_splinecharlist(lua_State * L, struct splinecharlist *scl)
}
}
-
-
/* vs is the "variation selector" a unicode codepoint which modifieds */
/* the code point before it. If vs is -1 then unienc is just an */
/* alternate encoding (greek Alpha and latin A), but if vs is one */
@@ -686,7 +673,6 @@ static void handle_splinecharlist(lua_State * L, struct splinecharlist *scl)
/* fid is currently unused, but may, someday, be used to do ttcs */
/* NOTE: GlyphInfo displays vs==-1 as vs==0, and fixes things up */
-
static int handle_altuni(lua_State * L, struct altuni *au)
{
struct altuni *next = au;
@@ -694,24 +680,23 @@ static int handle_altuni(lua_State * L, struct altuni *au)
int k = 1;
lua_checkstack(L, 3);
while (next != NULL) {
- if (next->unienc<0x10FFFF) {
- lua_newtable(L);
- dump_intfield(L, "unicode", next->unienc);
- i++;
- if (next->vs != -1)
- dump_intfield(L, "variant", next->vs);
- /* dump_intfield(L, "fid", next->fid); */
- lua_rawseti(L, -2, k++);
- } else {
- printf("ignoring variant %i %i\n",next->unienc,next->vs);
- }
- next = next->next;
+ if (next->unienc<0x10FFFF) {
+ lua_newtable(L);
+ dump_intfield(L, "unicode", next->unienc);
+ i++;
+ if (next->vs != -1) {
+ dump_intfield(L, "variant", next->vs);
+ /* dump_intfield(L, "fid", next->fid); */
+ }
+ lua_rawseti(L, -2, k++);
+ } else {
+ printf("ignoring variant %i %i\n",next->unienc,next->vs);
+ }
+ next = next->next;
}
return i;
}
-
-
#define interesting_vr(a) (((a)->xoff!=0) || ((a)->yoff!=0) || ((a)->h_adv_off!=0) || ((a)->v_adv_off!=0))
static void handle_vr(lua_State * L, struct vr *pos)
@@ -779,7 +764,6 @@ static void do_handle_generic_pst(lua_State * L, struct generic_pst *pst)
lua_rawset(L, -3);
}
-
static void handle_generic_pst(lua_State * L, struct generic_pst *pst)
{
struct generic_pst *next;
@@ -901,7 +885,6 @@ static void do_handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
lua_pop(L, 1);
}
-
static void handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
{
struct anchorpoint *next;
@@ -957,8 +940,6 @@ static void handle_mathkern(lua_State * L, struct mathkern *mk)
lua_setfield(L, -2, "bottom_left");
}
-
-
static void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics)
{
DBounds bb;
@@ -1125,42 +1106,41 @@ static void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvm
}
}
-const char *panose_values_0[] =
- { "Any", "No Fit", "Text and Display", "Script", "Decorative",
- "Pictorial"
+const char *panose_values_0[] = {
+ "Any", "No Fit", "Text and Display", "Script", "Decorative", "Pictorial"
};
-const char *panose_values_1[] =
- { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove",
+const char *panose_values_1[] = {
+ "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove",
"Obtuse Square Cove",
"Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans",
"Obtuse Sans", "Perp Sans", "Flared", "Rounded"
};
-const char *panose_values_2[] =
- { "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
+const char *panose_values_2[] = {
+ "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
"Medium", "Demi", "Bold", "Heavy", "Black", "Nord"
};
-const char *panose_values_3[] =
- { "Any", "No Fit", "Old Style", "Modern", "Even Width",
+const char *panose_values_3[] = {
+ "Any", "No Fit", "Old Style", "Modern", "Even Width",
"Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced"
};
-const char *panose_values_4[] =
- { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
+const char *panose_values_4[] = {
+ "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
"Medium", "Medium High", "High", "Very High"
};
-const char *panose_values_5[] =
- { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional",
+const char *panose_values_5[] = {
+ "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional",
"Gradual/Vertical",
"Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal",
"Instant/Vertical"
};
-const char *panose_values_6[] =
- { "Any", "No Fit", "Straight Arms/Horizontal", "Straight Arms/Wedge",
+const char *panose_values_6[] = {
+ "Any", "No Fit", "Straight Arms/Horizontal", "Straight Arms/Wedge",
"Straight Arms/Vertical",
"Straight Arms/Single Serif", "Straight Arms/Double Serif",
"Non-Straight Arms/Horizontal",
@@ -1169,8 +1149,8 @@ const char *panose_values_6[] =
"Non-Straight Arms/Double Serif"
};
-const char *panose_values_7[] =
- { "Any", "No Fit", "Normal/Contact", "Normal/Weighted", "Normal/Boxed",
+const char *panose_values_7[] = {
+ "Any", "No Fit", "Normal/Contact", "Normal/Weighted", "Normal/Boxed",
"Normal/Flattened",
"Normal/Rounded", "Normal/Off Center", "Normal/Square", "Oblique/Contact",
"Oblique/Weighted",
@@ -1178,16 +1158,16 @@ const char *panose_values_7[] =
"Oblique/Off Center", "Oblique/Square"
};
-const char *panose_values_8[] =
- { "Any", "No Fit", "Standard/Trimmed", "Standard/Pointed",
+const char *panose_values_8[] = {
+ "Any", "No Fit", "Standard/Trimmed", "Standard/Pointed",
"Standard/Serifed", "High/Trimmed",
"High/Pointed", "High/Serifed", "Constant/Trimmed", "Constant/Pointed",
"Constant/Serifed",
"Low/Trimmed", "Low/Pointed", "Low/Serifed"
};
-const char *panose_values_9[] =
- { "Any", "No Fit", "Constant/Small", "Constant/Standard",
+const char *panose_values_9[] = {
+ "Any", "No Fit", "Constant/Small", "Constant/Standard",
"Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large"
};
@@ -1450,14 +1430,12 @@ static void do_handle_ttflangname(lua_State * L, struct ttflangname *names)
lua_setfield(L, -2, "names");
}
-
static void handle_ttflangname(lua_State * L, struct ttflangname *names)
{
struct ttflangname *next;
NESTED_TABLE(do_handle_ttflangname, names, 2);
}
-
static void do_handle_anchorclass(lua_State * L, struct anchorclass *anchor)
{
@@ -1549,43 +1527,41 @@ static void handle_kernclass(lua_State * L, struct kernclass *kerns, const char
}
-#define DUMP_NUMBER_ARRAY(s,cnt,item) { \
- if (cnt>0 && item != NULL) { \
- int kk; \
- lua_newtable(L); \
- for (kk=0;kk<cnt;kk++) { \
- lua_pushnumber(L,(kk+1)); \
- lua_pushnumber(L,item[kk]); \
- lua_rawset(L,-3); } \
+#define DUMP_NUMBER_ARRAY(s,cnt,item) { \
+ if (cnt>0 && item != NULL) { \
+ int kk; \
+ lua_newtable(L); \
+ for (kk=0;kk<cnt;kk++) { \
+ lua_pushnumber(L,(kk+1)); \
+ lua_pushnumber(L,item[kk]); \
+ lua_rawset(L,-3); } \
lua_setfield(L,-2,s); } }
-#define DUMP_STRING_ARRAY(s,cnt,item) { \
- if (cnt>0 && item!=NULL) { \
- int kk; \
- lua_newtable(L); \
- for (kk=0;kk<cnt;kk++) { \
- lua_pushnumber(L,(kk+1)); \
- lua_pushstring(L,item[kk]); \
- lua_rawset(L,-3); } \
+#define DUMP_STRING_ARRAY(s,cnt,item) { \
+ if (cnt>0 && item!=NULL) { \
+ int kk; \
+ lua_newtable(L); \
+ for (kk=0;kk<cnt;kk++) { \
+ lua_pushnumber(L,(kk+1)); \
+ lua_pushstring(L,item[kk]); \
+ lua_rawset(L,-3); } \
lua_setfield(L,-2,s); } }
-#define DUMP_EXACT_STRING_ARRAY(s,cnt,item) { \
- if (cnt>0 && item!=NULL) { \
- int kk; \
- lua_newtable(L); \
- for (kk=0;kk<cnt;kk++) { \
- lua_pushnumber(L,(kk)); \
- lua_pushstring(L,item[kk]); \
- lua_rawset(L,-3); } \
+#define DUMP_EXACT_STRING_ARRAY(s,cnt,item) { \
+ if (cnt>0 && item!=NULL) { \
+ int kk; \
+ lua_newtable(L); \
+ for (kk=0;kk<cnt;kk++) { \
+ lua_pushnumber(L,(kk)); \
+ lua_pushstring(L,item[kk]); \
+ lua_rawset(L,-3); } \
lua_setfield(L,-2,s); } }
-
static void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format)
{
int k;
-
if (format == pst_glyphs) {
lua_newtable(L);
@@ -1727,76 +1703,51 @@ static void handle_otfname(lua_State * L, struct otfname *oname)
NESTED_TABLE(do_handle_otfname, oname, 2);
}
-
-
-
static void handle_MATH(lua_State * L, struct MATH *MATH)
{
dump_intfield(L, "ScriptPercentScaleDown", MATH->ScriptPercentScaleDown);
- dump_intfield(L, "ScriptScriptPercentScaleDown",
- MATH->ScriptScriptPercentScaleDown);
- dump_intfield(L, "DelimitedSubFormulaMinHeight",
- MATH->DelimitedSubFormulaMinHeight);
- dump_intfield(L, "DisplayOperatorMinHeight",
- MATH->DisplayOperatorMinHeight);
+ dump_intfield(L, "ScriptScriptPercentScaleDown", MATH->ScriptScriptPercentScaleDown);
+ dump_intfield(L, "DelimitedSubFormulaMinHeight", MATH->DelimitedSubFormulaMinHeight);
+ dump_intfield(L, "DisplayOperatorMinHeight", MATH->DisplayOperatorMinHeight);
dump_intfield(L, "MathLeading", MATH->MathLeading);
dump_intfield(L, "AxisHeight", MATH->AxisHeight);
dump_intfield(L, "AccentBaseHeight", MATH->AccentBaseHeight);
- dump_intfield(L, "FlattenedAccentBaseHeight",
- MATH->FlattenedAccentBaseHeight);
+ dump_intfield(L, "FlattenedAccentBaseHeight", MATH->FlattenedAccentBaseHeight);
dump_intfield(L, "SubscriptShiftDown", MATH->SubscriptShiftDown);
dump_intfield(L, "SubscriptTopMax", MATH->SubscriptTopMax);
- dump_intfield(L, "SubscriptBaselineDropMin",
- MATH->SubscriptBaselineDropMin);
+ dump_intfield(L, "SubscriptBaselineDropMin", MATH->SubscriptBaselineDropMin);
dump_intfield(L, "SuperscriptShiftUp", MATH->SuperscriptShiftUp);
- dump_intfield(L, "SuperscriptShiftUpCramped",
- MATH->SuperscriptShiftUpCramped);
+ dump_intfield(L, "SuperscriptShiftUpCramped", MATH->SuperscriptShiftUpCramped);
dump_intfield(L, "SuperscriptBottomMin", MATH->SuperscriptBottomMin);
- dump_intfield(L, "SuperscriptBaselineDropMax",
- MATH->SuperscriptBaselineDropMax);
+ dump_intfield(L, "SuperscriptBaselineDropMax", MATH->SuperscriptBaselineDropMax);
dump_intfield(L, "SubSuperscriptGapMin", MATH->SubSuperscriptGapMin);
- dump_intfield(L, "SuperscriptBottomMaxWithSubscript",
- MATH->SuperscriptBottomMaxWithSubscript);
+ dump_intfield(L, "SuperscriptBottomMaxWithSubscript", MATH->SuperscriptBottomMaxWithSubscript);
dump_intfield(L, "SpaceAfterScript", MATH->SpaceAfterScript);
dump_intfield(L, "UpperLimitGapMin", MATH->UpperLimitGapMin);
- dump_intfield(L, "UpperLimitBaselineRiseMin",
- MATH->UpperLimitBaselineRiseMin);
+ dump_intfield(L, "UpperLimitBaselineRiseMin", MATH->UpperLimitBaselineRiseMin);
dump_intfield(L, "LowerLimitGapMin", MATH->LowerLimitGapMin);
- dump_intfield(L, "LowerLimitBaselineDropMin",
- MATH->LowerLimitBaselineDropMin);
+ dump_intfield(L, "LowerLimitBaselineDropMin", MATH->LowerLimitBaselineDropMin);
dump_intfield(L, "StackTopShiftUp", MATH->StackTopShiftUp);
- dump_intfield(L, "StackTopDisplayStyleShiftUp",
- MATH->StackTopDisplayStyleShiftUp);
+ dump_intfield(L, "StackTopDisplayStyleShiftUp", MATH->StackTopDisplayStyleShiftUp);
dump_intfield(L, "StackBottomShiftDown", MATH->StackBottomShiftDown);
- dump_intfield(L, "StackBottomDisplayStyleShiftDown",
- MATH->StackBottomDisplayStyleShiftDown);
+ dump_intfield(L, "StackBottomDisplayStyleShiftDown", MATH->StackBottomDisplayStyleShiftDown);
dump_intfield(L, "StackGapMin", MATH->StackGapMin);
dump_intfield(L, "StackDisplayStyleGapMin", MATH->StackDisplayStyleGapMin);
dump_intfield(L, "StretchStackTopShiftUp", MATH->StretchStackTopShiftUp);
- dump_intfield(L, "StretchStackBottomShiftDown",
- MATH->StretchStackBottomShiftDown);
+ dump_intfield(L, "StretchStackBottomShiftDown", MATH->StretchStackBottomShiftDown);
dump_intfield(L, "StretchStackGapAboveMin", MATH->StretchStackGapAboveMin);
dump_intfield(L, "StretchStackGapBelowMin", MATH->StretchStackGapBelowMin);
- dump_intfield(L, "FractionNumeratorShiftUp",
- MATH->FractionNumeratorShiftUp);
- dump_intfield(L, "FractionNumeratorDisplayStyleShiftUp",
- MATH->FractionNumeratorDisplayStyleShiftUp);
- dump_intfield(L, "FractionDenominatorShiftDown",
- MATH->FractionDenominatorShiftDown);
- dump_intfield(L, "FractionDenominatorDisplayStyleShiftDown",
- MATH->FractionDenominatorDisplayStyleShiftDown);
+ dump_intfield(L, "FractionNumeratorShiftUp", MATH->FractionNumeratorShiftUp);
+ dump_intfield(L, "FractionNumeratorDisplayStyleShiftUp", MATH->FractionNumeratorDisplayStyleShiftUp);
+ dump_intfield(L, "FractionDenominatorShiftDown", MATH->FractionDenominatorShiftDown);
+ dump_intfield(L, "FractionDenominatorDisplayStyleShiftDown", MATH->FractionDenominatorDisplayStyleShiftDown);
dump_intfield(L, "FractionNumeratorGapMin", MATH->FractionNumeratorGapMin);
- dump_intfield(L, "FractionNumeratorDisplayStyleGapMin",
- MATH->FractionNumeratorDisplayStyleGapMin);
+ dump_intfield(L, "FractionNumeratorDisplayStyleGapMin", MATH->FractionNumeratorDisplayStyleGapMin);
dump_intfield(L, "FractionRuleThickness", MATH->FractionRuleThickness);
- dump_intfield(L, "FractionDenominatorGapMin",
- MATH->FractionDenominatorGapMin);
- dump_intfield(L, "FractionDenominatorDisplayStyleGapMin",
- MATH->FractionDenominatorDisplayStyleGapMin);
- dump_intfield(L, "SkewedFractionHorizontalGap",
- MATH->SkewedFractionHorizontalGap);
- dump_intfield(L, "SkewedFractionVerticalGap",
- MATH->SkewedFractionVerticalGap);
+ dump_intfield(L, "FractionDenominatorGapMin", MATH->FractionDenominatorGapMin);
+ dump_intfield(L, "FractionDenominatorDisplayStyleGapMin", MATH->FractionDenominatorDisplayStyleGapMin);
+ dump_intfield(L, "SkewedFractionHorizontalGap", MATH->SkewedFractionHorizontalGap);
+ dump_intfield(L, "SkewedFractionVerticalGap", MATH->SkewedFractionVerticalGap);
dump_intfield(L, "OverbarVerticalGap", MATH->OverbarVerticalGap);
dump_intfield(L, "OverbarRuleThickness", MATH->OverbarRuleThickness);
dump_intfield(L, "OverbarExtraAscender", MATH->OverbarExtraAscender);
@@ -1804,14 +1755,12 @@ static void handle_MATH(lua_State * L, struct MATH *MATH)
dump_intfield(L, "UnderbarRuleThickness", MATH->UnderbarRuleThickness);
dump_intfield(L, "UnderbarExtraDescender", MATH->UnderbarExtraDescender);
dump_intfield(L, "RadicalVerticalGap", MATH->RadicalVerticalGap);
- dump_intfield(L, "RadicalDisplayStyleVerticalGap",
- MATH->RadicalDisplayStyleVerticalGap);
+ dump_intfield(L, "RadicalDisplayStyleVerticalGap", MATH->RadicalDisplayStyleVerticalGap);
dump_intfield(L, "RadicalRuleThickness", MATH->RadicalRuleThickness);
dump_intfield(L, "RadicalExtraAscender", MATH->RadicalExtraAscender);
dump_intfield(L, "RadicalKernBeforeDegree", MATH->RadicalKernBeforeDegree);
dump_intfield(L, "RadicalKernAfterDegree", MATH->RadicalKernAfterDegree);
- dump_intfield(L, "RadicalDegreeBottomRaisePercent",
- MATH->RadicalDegreeBottomRaisePercent);
+ dump_intfield(L, "RadicalDegreeBottomRaisePercent", MATH->RadicalDegreeBottomRaisePercent);
dump_intfield(L, "MinConnectorOverlap", MATH->MinConnectorOverlap);
}
@@ -1828,14 +1777,12 @@ static void do_handle_baselangextent(lua_State * L, struct baselangextent *ble)
lua_setfield(L, -2, "features");
}
-
static void handle_baselangextent(lua_State * L, struct baselangextent *ble)
{
struct baselangextent *next;
NESTED_TABLE(do_handle_baselangextent, ble, 4);
}
-
static void handle_base(lua_State * L, struct Base *Base)
{
int i;
@@ -1871,7 +1818,6 @@ static void handle_base(lua_State * L, struct Base *Base)
}
}
-
static void handle_axismap(lua_State * L, struct axismap *am)
{
int i;
@@ -1893,7 +1839,6 @@ static void handle_axismap(lua_State * L, struct axismap *am)
dump_realfield(L, "max", am->max);
}
-
static void handle_mmset(lua_State * L, struct mmset *mm)
{
int i;
@@ -1953,8 +1898,6 @@ static void handle_mmset(lua_State * L, struct mmset *mm)
dump_stringfield(L, "ndv", mm->ndv);
}
-
-
static void handle_splinefont(lua_State * L, struct splinefont *sf)
{
int k;
@@ -2529,7 +2472,6 @@ const char *font_glyph_keys[] = {
NULL
};
-
static int ff_fields(lua_State * L)
{
int i;
@@ -2552,8 +2494,6 @@ static int ff_fields(lua_State * L)
return 1;
}
-
-
static int ff_glyphs_index(lua_State * L)
{
@@ -2566,8 +2506,7 @@ static int ff_glyphs_index(lua_State * L)
/* sf = *check_isfont(L, -1); */
if (!(is_userdata(L, -1, FONT_METATABLE) ||
is_userdata(L, -1, FONT_SUBFONT_METATABLE))) {
- return luaL_error(L,
- "fontloader.__index: expected a (sub)font userdata object\n");
+ return luaL_error(L, "fontloader.__index: expected a (sub)font userdata object\n");
}
sf = *((SplineFont **)lua_touserdata(L, -1));
@@ -2618,12 +2557,10 @@ static int ff_glyph_index(lua_State * L)
int key;
glyph = *check_isglyph(L, 1);
if (glyph == NULL) {
- return luaL_error(L,
- "fontloader.glyph.__index: glyph is nonexistent\n");
+ return luaL_error(L, "fontloader.glyph.__index: glyph is nonexistent\n");
}
- if (!lua_isstring(L, 2)) { /* 1 == 'font' */
- return luaL_error(L,
- "fontloader.glyph.__index: can only be indexed by string\n");
+ if (lua_type(L, 2) != LUA_TSTRING) { /* 1 == 'font' */
+ return luaL_error(L, "fontloader.glyph.__index: can only be indexed by string\n");
}
key = luaL_checkoption(L, 2, NULL, font_glyph_keys);
switch (key) {
@@ -2800,7 +2737,6 @@ static int ff_glyph_index(lua_State * L)
return 1;
}
-
static int ff_index(lua_State * L)
{
SplineFont *sf;
@@ -2808,20 +2744,16 @@ static int ff_index(lua_State * L)
/* sf = *check_isfont(L, 1); */
if (!(is_userdata(L, 1, FONT_METATABLE) ||
is_userdata(L, 1, FONT_SUBFONT_METATABLE))) {
- return luaL_error(L,
- "fontloader.__index: expected a (sub)font userdata object\n");
+ return luaL_error(L, "fontloader.__index: expected a (sub)font userdata object\n");
}
sf = *((SplineFont **)lua_touserdata(L, 1));
if (sf == NULL) {
- /* return luaL_error(L, */
- /* "fontloader.__index: font is nonexistent or freed already\n");*/
lua_pushnil(L);
return 1;
}
- if (!lua_isstring(L, 2)) { /* 1 == 'font' */
- return luaL_error(L,
- "fontloader.__index: can only be indexed by string\n");
+ if (lua_type(L, 2) != LUA_TSTRING) { /* 1 == 'font' */
+ return luaL_error(L, "fontloader.__index: can only be indexed by string\n");
}
key = luaL_checkoption(L, 2, NULL, font_keys);
switch (key) {
@@ -3215,14 +3147,14 @@ static int ff_index(lua_State * L)
case FK_extrema_bound:
lua_pushnumber(L, sf->extrema_bound);
break;
- default: /* can't actually happen, |luaL_checkoption| raises an error instead */
+ default:
+ /* can't actually happen, |luaL_checkoption| raises an error instead */
lua_pushnil(L);
break;
}
return 1;
}
-
static int ff_info(lua_State * L)
{
SplineFont *sf;
@@ -3234,8 +3166,7 @@ static int ff_info(lua_State * L)
fontname = luaL_checkstring(L, 1);
if (!strlen(fontname)) {
lua_pushnil(L);
- lua_pushfstring(L, "font loading failed: empty string given\n",
- fontname);
+ lua_pushfstring(L, "font loading failed: empty string given\n", fontname);
return 2;
}
/* test fontname for existance */
@@ -3244,11 +3175,9 @@ static int ff_info(lua_State * L)
fclose(l);
} else {
lua_pushnil(L);
- lua_pushfstring(L, "font loading failed for %s (read error)\n",
- fontname);
+ lua_pushfstring(L, "font loading failed for %s (read error)\n", fontname);
return 2;
}
-
gww_error_count = 0;
fontnamecopy = xstrdup(fontname);
sf = ReadSplineFontInfo(fontnamecopy, openflags);
@@ -3303,9 +3232,10 @@ static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf,
fclose(f);
return;
}
- /* errors */
- fprintf(stdout, "\n%s => CFF, failed\n", sf->filename);
-
+ /* snprintf(errmsg, 255, "%s => CFF, failed", sf->filename); */
+ /* normal_error("fontloader",errmsg); */ /* TODO */
+ fprintf(stdout,"%s => CFF, failed", sf->filename);
+ exit(EXIT_FAILURE);
}
/* exported for writecff.c */
@@ -3343,7 +3273,8 @@ int ff_get_ttc_index(char *ffname, char *psname)
sf = ReadSplineFontInfo((char *) ffname, openflags);
if (sf == NULL) {
- perror("font loading failed unexpectedly\n");
+ /* normal_error("fontloader","font loading failed unexpectedly"); */ /* TODO */
+ fprintf(stdout,"font loading failed unexpectedly\n");
exit(EXIT_FAILURE);
}
while (sf != NULL) {
@@ -3407,7 +3338,6 @@ int luaopen_ff(lua_State * L)
lua_rawset(L, -3);
lua_pop(L, 1);
-
luaL_openlib(L, "fontloader", fllib, 0);
return 1;
diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c
index 4ce58c3aba6..726288a6176 100644
--- a/Build/source/texk/web2c/luatexdir/luatex.c
+++ b/Build/source/texk/web2c/luatexdir/luatex.c
@@ -27,10 +27,10 @@
#define TeX
int luatex_svn = luatex_svn_revision;
-int luatex_version = 81; /* \.{\\luatexversion} */
-int luatex_revision = '1'; /* \.{\\luatexrevision} */
-int luatex_date_info = 2015100800; /* the compile date is now hardwired */
-const char *luatex_version_string = "beta-0.81.1";
+int luatex_version = 85; /* \.{\\luatexversion} */
+int luatex_revision = '0'; /* \.{\\luatexrevision} */
+int luatex_date_info = 2015111400; /* the compile date is now hardwired */
+const char *luatex_version_string = "beta-0.85.0";
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 7660e829d6f..368a0234014 100644
--- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
+++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
@@ -55,13 +55,15 @@ typedef enum {
pre_linebreak_filter_callback,
linebreak_filter_callback,
post_linebreak_filter_callback,
+ append_to_vlist_filter_callback,
mlist_to_hlist_callback,
finish_pdffile_callback,
finish_pdfpage_callback,
pre_dump_callback,
start_file_callback, stop_file_callback,
- show_error_message_callback,show_lua_error_hook_callback,
- pdf_stream_filter_callback,
+ show_error_message_callback, show_lua_error_hook_callback,
+ show_warning_message_callback,
+ hpack_quality_callback, vpack_quality_callback,
total_callbacks
} callback_callback_types;
@@ -85,8 +87,7 @@ extern void get_saved_lua_boolean(int i, const char *name, boolean * target);
extern void get_saved_lua_number(int i, const char *name, int *target);
extern void get_saved_lua_string(int i, const char *name, char **target);
-extern void get_lua_boolean(const char *table, const char *name,
- boolean * target);
+extern void get_lua_boolean(const char *table, const char *name, boolean * target);
extern void get_lua_number(const char *table, const char *name, int *target);
extern void get_lua_string(const char *table, const char *name, char **target);
@@ -127,7 +128,7 @@ static const char *const filetypes_right[] = { "?", ")", "}", ">", ">", ">>" } ;
(void) run_callback(report_id, "dS->",left,name); \
} \
} \
-} while (0)
+} while (0)
#define report_stop_file(right) do { \
if (tracefilenames) { \
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
index 13b5bef3e57..ed9ba48a2ce 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.h
@@ -17,61 +17,33 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
#ifndef PDFACTION_H
# define PDFACTION_H
-/* pdf action spec */
-
-# define pdf_action_size 4
-
-typedef enum {
- pdf_action_page = 0,
- pdf_action_goto,
- pdf_action_thread,
- pdf_action_user
-} pdf_action_type;
-
-typedef enum {
- pdf_window_notset,
- pdf_window_new,
- pdf_window_nonew,
-} pdf_window_type;
-
-
-# define pdf_action_type(a) type((a) + 1) /* enum pdf_action_type */
-# define pdf_action_named_id(a) subtype((a) + 1) /* boolean */
-# define pdf_action_id(a) vlink((a) + 1) /* number or toks */
-# define pdf_action_file(a) vinfo((a) + 2) /* toks */
-# define pdf_action_new_window(a) vlink((a) + 2) /* enum pdf_window_type */
-# define pdf_action_tokens(a) vinfo((a) + 3) /* toks */
-# define pdf_action_refcount(a) vlink((a) + 3) /* number */
-
-/* increase count of references to this action. this is used to speed up copy_node() */
+/* increase count of references to this action. this is used to speed up
+ copy_node() */
# define add_action_ref(a) pdf_action_refcount((a))++
-/* decrease count of references to this
- action; free it if there is no reference to this action*/
-
-# define delete_action_ref(a) { \
- if (pdf_action_refcount(a) == null) { \
- delete_action_node(a); \
- } else { \
- pdf_action_refcount(a)--; \
- } \
- }
-
-
-# define set_pdf_action_type(A,B) pdf_action_type(A)=B
-# define set_pdf_action_tokens(A,B) pdf_action_tokens(A)=B
-# define set_pdf_action_file(A,B) pdf_action_file(A)=B
-# define set_pdf_action_id(A,B) pdf_action_id(A)=B
-# define set_pdf_action_named_id(A,B) pdf_action_named_id(A)=B
+/* decrease count of references to this action; free it if there is no reference
+ to this action */
+
+# define delete_action_ref(a) { \
+ if (pdf_action_refcount(a) == null) { \
+ flush_node(a); \
+ } else { \
+ pdf_action_refcount(a)--; \
+ } \
+}
+
+# define set_pdf_action_type(A,B) pdf_action_type(A)=B
+# define set_pdf_action_tokens(A,B) pdf_action_tokens(A)=B
+# define set_pdf_action_file(A,B) pdf_action_file(A)=B
+# define set_pdf_action_id(A,B) pdf_action_id(A)=B
+# define set_pdf_action_named_id(A,B) pdf_action_named_id(A)=B
# define set_pdf_action_new_window(A,B) pdf_action_new_window(A)=B
extern halfword scan_action(PDF pdf);
extern void write_action(PDF pdf, halfword p);
-extern void delete_action_node(halfword a);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
index 8c1f084475f..65c1afcc352 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfaction.w
@@ -22,35 +22,13 @@
#include "ptexlib.h"
-@ @c
-static halfword new_action_node(void)
-{
- return new_node(action_node, 0);
-}
-
-@ @c
-void delete_action_node(halfword a)
-{
- if (pdf_action_type(a) == pdf_action_user) {
- delete_token_ref(pdf_action_tokens(a));
- } else {
- if (pdf_action_file(a) != null)
- delete_token_ref(pdf_action_file(a));
- if (pdf_action_type(a) == pdf_action_page)
- delete_token_ref(pdf_action_tokens(a));
- else if (pdf_action_named_id(a) > 0)
- delete_token_ref(pdf_action_id(a));
- }
- free_node(a, pdf_action_size);
-}
-
@ read an action specification
@c
halfword scan_action(PDF pdf)
{
int p;
(void) pdf;
- p = new_action_node();
+ p = new_node(whatsit_node, pdf_action_node);
if (scan_keyword("user"))
set_pdf_action_type(p, pdf_action_user);
else if (scan_keyword("goto"))
@@ -58,7 +36,7 @@ halfword scan_action(PDF pdf)
else if (scan_keyword("thread"))
set_pdf_action_type(p, pdf_action_thread);
else
- pdf_error("ext1", "action type missing");
+ normal_error("pdf backend", "action type missing");
if (pdf_action_type(p) == pdf_action_user) {
scan_pdf_ext_toks();
set_pdf_action_tokens(p, def_ref);
@@ -70,11 +48,11 @@ halfword scan_action(PDF pdf)
}
if (scan_keyword("page")) {
if (pdf_action_type(p) != pdf_action_goto)
- pdf_error("ext1", "only GoTo action can be used with `page'");
+ normal_error("pdf backend", "only GoTo action can be used with 'page'");
set_pdf_action_type(p, pdf_action_page);
scan_int();
if (cur_val <= 0)
- pdf_error("ext1", "page number must be positive");
+ normal_error("pdf backend", "page number must be positive");
set_pdf_action_id(p, cur_val);
set_pdf_action_named_id(p, 0);
scan_pdf_ext_toks();
@@ -86,15 +64,14 @@ halfword scan_action(PDF pdf)
} else if (scan_keyword("num")) {
if ((pdf_action_type(p) == pdf_action_goto) &&
(pdf_action_file(p) != null))
- pdf_error("ext1",
- "`goto' option cannot be used with both `file' and `num'");
+ normal_error("pdf backend", "'goto' option cannot be used with both 'file' and 'num'");
scan_int();
if (cur_val <= 0)
- pdf_error("ext1", "num identifier must be positive");
+ normal_error("pdf backend", "num identifier must be positive");
set_pdf_action_named_id(p, 0);
set_pdf_action_id(p, cur_val);
} else {
- pdf_error("ext1", "identifier type missing");
+ normal_error("pdf backend", "identifier type missing");
}
if (scan_keyword("newwindow")) {
set_pdf_action_new_window(p, pdf_window_new);
@@ -115,8 +92,7 @@ halfword scan_action(PDF pdf)
(((pdf_action_type(p) != pdf_action_goto) &&
(pdf_action_type(p) != pdf_action_page)) ||
(pdf_action_file(p) == null)))
- pdf_error("ext1",
- "`newwindow'/`nonewwindow' must be used with `goto' and `file' option");
+ normal_error("pdf backend","'newwindow' or 'nonewwindow' must be used with 'goto' and 'file' option");
return p;
}
@@ -153,17 +129,14 @@ void write_action(PDF pdf, halfword p)
if (pdf_action_file(p) == null) {
pdf_add_name(pdf, "D");
pdf_begin_array(pdf);
- pdf_add_ref(pdf,
- pdf_get_obj(pdf, obj_type_page, pdf_action_id(p),
- false));
+ pdf_add_ref(pdf, pdf_get_obj(pdf, obj_type_page, pdf_action_id(p), false));
} else {
pdf_add_name(pdf, "D");
pdf_begin_array(pdf);
pdf_print_int(pdf, pdf_action_id(p) - 1);
}
{
- char *tokstr =
- tokenlist_to_cstring(pdf_action_tokens(p), true, NULL);
+ char *tokstr = tokenlist_to_cstring(pdf_action_tokens(p), true, NULL);
pdf_printf(pdf, " %s", tokstr);
pdf_end_array(pdf);
xfree(tokstr);
@@ -172,8 +145,7 @@ void write_action(PDF pdf, halfword p)
case pdf_action_goto:
if (pdf_action_file(p) == null) {
pdf_dict_add_name(pdf, "S", "GoTo");
- d = pdf_get_obj(pdf, obj_type_dest, pdf_action_id(p),
- pdf_action_named_id(p));
+ d = pdf_get_obj(pdf, obj_type_dest, pdf_action_id(p), pdf_action_named_id(p));
} else
pdf_dict_add_name(pdf, "S", "GoToR");
if (pdf_action_named_id(p) > 0) {
@@ -183,18 +155,15 @@ void write_action(PDF pdf, halfword p)
} else if (pdf_action_file(p) == null) {
pdf_dict_add_ref(pdf, "D", d);
} else {
- pdf_error("ext4",
- "`goto' option cannot be used with both `file' and `num'");
+ normal_error("pdf backend","'goto' option cannot be used with both 'file' and 'num'");
}
break;
case pdf_action_thread:
pdf_dict_add_name(pdf, "S", "Thread");
if (pdf_action_file(p) == null) {
- d = pdf_get_obj(pdf, obj_type_thread, pdf_action_id(p),
- pdf_action_named_id(p));
+ d = pdf_get_obj(pdf, obj_type_thread, pdf_action_id(p), pdf_action_named_id(p));
if (pdf_action_named_id(p) > 0) {
- char *tokstr =
- tokenlist_to_cstring(pdf_action_id(p), true, NULL);
+ char *tokstr = tokenlist_to_cstring(pdf_action_id(p), true, NULL);
pdf_dict_add_string(pdf, "D", tokstr);
xfree(tokstr);
} else if (pdf_action_file(p) == null) {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
index b6c95e8ff7d..67bcc69a40c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfannot.w
@@ -30,7 +30,7 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
scaled_whd alt_rule;
int k;
if (global_shipping_mode == SHIPPING_FORM)
- pdf_error("ext4", "annotations cannot be inside an XForm");
+ normal_error("pdf backend", "annotations cannot be inside an XForm");
if (doing_leaders)
return;
if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) {
@@ -82,7 +82,7 @@ void scan_annot(PDF pdf)
k = cur_val;
check_obj_type(pdf, obj_type_annot, k);
if (obj_annot_ptr(pdf, k) != 0)
- pdf_error("ext1", "annot object in use");
+ normal_error("pdf backend", "annot object in use");
} else {
k = pdf_create_obj(pdf, obj_type_annot, 0);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
index 7047d36b169..cab0a4cb0ae 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.h
@@ -27,7 +27,7 @@
# define STACK_INCREMENT 8
-int newcolorstack(int s, int literal_mode, boolean pagestart);
+int newcolorstack(const char *s, int literal_mode, boolean pagestart);
int colorstackused(void);
int colorstackpop(int colstack_no);
int colorstackcurrent(int colstack_no);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index e44f06ba47c..eb48ab89ca6 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -39,7 +39,7 @@ They have the following properties:
freed if the stack is cleared.
-@ Color Stack
+@ Color Stack
@c
#define MAX_COLORSTACKS 32768
/* The colorstack number is stored in two bytes (info field of the node) */
@@ -104,11 +104,10 @@ int colorstackused(void)
A new color stack is setup with the given parameters.
The stack number is returned or -1 in case of error (no room).
@c
-int newcolorstack(int s, int literal_mode, boolean page_start)
+int newcolorstack(const char *str, int literal_mode, boolean page_start)
{
colstack_type *colstack;
int colstack_num;
- char *str;
init_colorstacks();
@@ -135,24 +134,21 @@ int newcolorstack(int s, int literal_mode, boolean page_start)
colstack->form_used = 0;
colstack->literal_mode = literal_mode;
colstack->page_start = page_start;
- str = makecstring(s);
- if (*str == 0) {
- colstack->page_current = NULL;
- colstack->form_current = NULL;
- colstack->form_init = NULL;
- } else {
+ colstack->page_current = NULL;
+ colstack->form_current = NULL;
+ colstack->form_init = NULL;
+ if (str) {
colstack->page_current = xstrdup(str);
colstack->form_current = xstrdup(str);
colstack->form_init = xstrdup(str);
}
- free(str);
return colstack_num;
}
@ @c
#define get_colstack(n) (&colstacks[n])
-@ Puts a string on top of the string pool and updates |pool_ptr|.
+@ Puts a string on top of the string pool and updates |pool_ptr|.
@c
static void put_cstring_on_str_pool(char *str)
{
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
index cb7ee758568..7aefc45288f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfdest.w
@@ -22,9 +22,6 @@
#include "ptexlib.h"
-@ @c
-#define pdf_dest_margin dimen_par(pdf_dest_margin_code)
-
@ Here we implement subroutines for work with objects and related things.
Some of them are used in former parts too, so we need to declare them
forward.
@@ -65,7 +62,7 @@ with the same identifier already exists and give a warning if needed.
@c
void warn_dest_dup(int id, small_number byname, const char *s1, const char *s2)
{
- pdf_warning(s1, "destination with the same identifier (", false, false);
+ normal_warning(s1, "destination with the same identifier (", false, false);
if (byname > 0) {
tprint("name");
print_mark(id);
@@ -87,13 +84,13 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
scaled_whd alt_rule;
int k;
if (global_shipping_mode == SHIPPING_FORM)
- pdf_error("ext4", "destinations cannot be inside an XForm");
+ normal_error("pdf backend", "destinations cannot be inside an XForm");
if (doing_leaders)
return;
k = pdf_get_obj(pdf, obj_type_dest, pdf_dest_id(p), pdf_dest_named_id(p));
if (obj_dest_ptr(pdf, k) != null) {
warn_dest_dup(pdf_dest_id(p), (small_number) pdf_dest_named_id(p),
- "ext4", "has been already used, duplicate ignored");
+ "pdf backend", "has been already used, duplicate ignored");
return;
}
obj_dest_ptr(pdf, k) = p;
@@ -140,8 +137,7 @@ void write_out_pdf_mark_destinations(PDF pdf)
if ((k = get_page_resources_list(pdf, obj_type_dest)) != NULL) {
while (k != NULL) {
if (is_obj_written(pdf, k->info)) {
- pdf_error("ext5",
- "destination has been already written (this shouldn't happen)");
+ normal_error("pdf backend","destination has been already written (this shouldn't happen)");
} else {
int i;
i = obj_dest_ptr(pdf, k->info);
@@ -195,7 +191,7 @@ void write_out_pdf_mark_destinations(PDF pdf)
pdf_add_rect_spec(pdf, i);
break;
default:
- pdf_error("ext5", "unknown dest type");
+ normal_error("pdf backend", "unknown dest type");
break;
}
pdf_end_array(pdf);
@@ -220,9 +216,9 @@ void scan_pdfdest(PDF pdf)
if (scan_keyword("num")) {
scan_int();
if (cur_val <= 0)
- pdf_error("ext1", "num identifier must be positive");
+ normal_error("pdf backend", "num identifier must be positive");
if (cur_val > max_halfword)
- pdf_error("ext1", "number too big");
+ normal_error("pdf backend", "number too big");
set_pdf_dest_id(cur_list.tail_field, cur_val);
set_pdf_dest_named_id(cur_list.tail_field, 0);
} else if (scan_keyword("name")) {
@@ -230,14 +226,14 @@ void scan_pdfdest(PDF pdf)
set_pdf_dest_id(cur_list.tail_field, def_ref);
set_pdf_dest_named_id(cur_list.tail_field, 1);
} else {
- pdf_error("ext1", "identifier type missing");
+ normal_error("pdf backend", "identifier type missing");
}
if (scan_keyword("xyz")) {
set_pdf_dest_type(cur_list.tail_field, pdf_dest_xyz);
if (scan_keyword("zoom")) {
scan_int();
if (cur_val > max_halfword)
- pdf_error("ext1", "number too big");
+ normal_error("pdf backend", "number too big");
set_pdf_dest_xyz_zoom(cur_list.tail_field, cur_val);
} else {
set_pdf_dest_xyz_zoom(cur_list.tail_field, null);
@@ -257,7 +253,7 @@ void scan_pdfdest(PDF pdf)
} else if (scan_keyword("fit")) {
set_pdf_dest_type(cur_list.tail_field, pdf_dest_fit);
} else {
- pdf_error("ext1", "destination type missing");
+ normal_error("pdf backend", "destination type missing");
}
/* Scan an optional space */
get_x_token();
@@ -281,7 +277,7 @@ void scan_pdfdest(PDF pdf)
if ((k != 0) && (obj_dest_ptr(pdf, k) != null)) {
warn_dest_dup(pdf_dest_id(cur_list.tail_field),
(small_number) pdf_dest_named_id(cur_list.tail_field),
- "ext4", "has been already used, duplicate ignored");
+ "pdf backend", "has been already used, duplicate ignored");
flush_node_list(cur_list.tail_field);
cur_list.tail_field = q;
vlink(q) = null;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h b/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
index 414d1588d59..78726a0aa9e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.h
@@ -22,25 +22,8 @@
# define PDFFONT_H
extern scaled_whd output_one_char(PDF pdf, halfword p);
-
extern void pdf_init_font(PDF pdf, internal_font_number f);
extern internal_font_number pdf_set_font(PDF pdf, internal_font_number f);
-
-extern int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */
-
-extern internal_font_number tfm_lookup(char *s, scaled fs);
-
-extern void set_expand_params(internal_font_number f, boolean auto_expand,
- int stretch_limit, int shrink_limit,
- int font_step);
-
-extern void read_expand_font(void);
-extern void new_letterspaced_font(small_number a);
-extern void make_font_copy(small_number a);
-
extern void pdf_include_chars(PDF);
-extern void glyph_to_unicode(void);
-
-extern int fix_expand_value(internal_font_number f, int e);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 57332605d42..4a7319db8a3 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -24,12 +24,6 @@
#include "ptexlib.h"
-@ @c
-#define font_id_text(A) cs_text(font_id_base+(A)) /* a frozen font identifier's name */
-
-int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */
-
-
@ As \pdfTeX{} should also act as a back-end driver, it needs to support virtual
fonts too. Information about virtual fonts can be found in the source of some
\.{DVI}-related programs.
@@ -38,7 +32,6 @@ Whenever we want to write out a character in a font to PDF output, we
should check whether the used character is a virtual or real character.
The |has_packet()| C macro checks for this condition.
-
@ The following code typesets a character to PDF output
@c
@@ -194,199 +187,6 @@ internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
return ff;
}
-@ Here come some subroutines to deal with expanded fonts for HZ-algorithm.
-return 1 == identical
-@c
-static boolean cmp_font_name(int id, char *tt)
-{
- char *tid;
- if (!is_valid_font(id))
- return 0;
- tid = font_name(id);
- if (tt == NULL && tid == NULL)
- return 1;
- if (tt == NULL || tid == NULL || strcmp(tid, tt) != 0)
- return 0;
- return 1;
-}
-
-@ @c
-internal_font_number tfm_lookup(char *s, scaled fs)
-{ /* looks up for a TFM with name |s| loaded at |fs| size; if found then flushes |s| */
- internal_font_number k;
- if (fs != 0) {
- for (k = 1; k <= max_font_id(); k++) {
- if (cmp_font_name(k, s) && font_size(k) == fs) {
- return k;
- }
- }
- } else {
- for (k = 1; k <= max_font_id(); k++) {
- if (cmp_font_name(k, s)) {
- return k;
- }
- }
- }
- return null_font;
-}
-
-@ @c
-int fix_expand_value(internal_font_number f, int e)
-{ /* return the multiple of |font_step(f)| that is nearest to |e| */
- int step;
- int max_expand;
- boolean neg;
- if (e == 0)
- return 0;
- if (e < 0) {
- e = -e;
- neg = true;
- max_expand = font_max_shrink(f);
- } else {
- neg = false;
- max_expand = font_max_stretch(f);
- }
- if (e > max_expand) {
- e = max_expand;
- } else {
- step = font_step(f);
- if (e % step > 0)
- e = step * round_xn_over_d(e, 1, step);
- }
- if (neg)
- e = -e;
- return e;
-}
-
-@ @c
-void set_expand_params(internal_font_number f, boolean auto_expand,
- int stretch_limit, int shrink_limit, int font_step)
-{ /* expand a font with given parameters */
- set_font_step(f, font_step);
- set_font_auto_expand(f, auto_expand);
- set_font_max_shrink(f, shrink_limit);
- set_font_max_stretch(f, stretch_limit);
-}
-
-@ @c
-void read_expand_font(void)
-{ /* read font expansion spec and load expanded font */
- int shrink_limit, stretch_limit, font_step;
- internal_font_number f;
- boolean auto_expand;
- /* read font expansion parameters */
- scan_font_ident();
- f = cur_val;
- if (f == null_font)
- pdf_error("font expansion", "invalid font identifier");
- //if (pdf_font_blink(f) != null_font)
- // pdf_error("font expansion",
- // "\\fontexpand cannot be used this way (the base font has been expanded)");
- scan_optional_equals();
- scan_int();
- stretch_limit = fix_int(cur_val, 0, 1000);
- scan_int();
- shrink_limit = fix_int(cur_val, 0, 500);
- scan_int();
- font_step = fix_int(cur_val, 0, 100);
- if (font_step == 0)
- pdf_error("font expansion", "invalid step");
- stretch_limit = stretch_limit - stretch_limit % font_step;
- if (stretch_limit < 0)
- stretch_limit = 0;
- shrink_limit = shrink_limit - shrink_limit % font_step;
- if (shrink_limit < 0)
- shrink_limit = 0;
- if ((stretch_limit == 0) && (shrink_limit == 0))
- pdf_error("font expansion", "invalid limit(s)");
- auto_expand = false;
- if (scan_keyword("autoexpand")) {
- auto_expand = true;
- /* Scan an optional space */
- get_x_token();
- if (cur_cmd != spacer_cmd)
- back_input();
- }
-
- if (font_step(f) != 0) {
- /* this font has been expanded, ensure the expansion parameters are identical */
- if (font_step(f) != font_step)
- pdf_error("font expansion",
- "font has been expanded with different expansion step");
-
- if (((font_max_stretch(f) == 0) && (stretch_limit != 0)) ||
- ((font_max_stretch(f) > 0)
- && (font_max_stretch(f) != stretch_limit)))
- pdf_error("font expansion",
- "font has been expanded with different stretch limit");
-
- if (((font_max_shrink(f) == 0) && (shrink_limit != 0)) ||
- ((font_max_shrink(f) > 0)
- && (font_max_shrink(f) != shrink_limit)))
- pdf_error("font expansion",
- "font has been expanded with different shrink limit");
-
- if (font_auto_expand(f) != auto_expand)
- pdf_error("font expansion",
- "font has been expanded with different auto expansion value");
- } else {
- if (font_used(f))
- pdf_warning("font expansion",
- "font should be expanded before its first use", true,
- true);
- set_expand_params(f, auto_expand, stretch_limit, shrink_limit,
- font_step);
- }
-}
-
-@ @c
-void new_letterspaced_font(small_number a)
-{ /* letter-space a font by creating a virtual font */
- pointer u; /* user's font identifier */
- str_number t; /* name for the frozen font identifier */
- internal_font_number f, k;
- boolean nolig = false;
- get_r_token();
- u = cur_cs;
- if (u >= hash_base)
- t = cs_text(u);
- else
- t = maketexstring("FONT");
- define(u, set_font_cmd, null_font);
- scan_optional_equals();
- scan_font_ident();
- k = cur_val;
- scan_int();
- if (scan_keyword("nolig"))
- nolig=true;
- f = letter_space_font(k, fix_int(cur_val, -1000, 1000), nolig);
- equiv(u) = f;
- eqtb[font_id_base + f] = eqtb[u];
- font_id_text(f) = t;
-}
-
-@ @c
-void make_font_copy(small_number a)
-{ /* make a font copy for further use with font expansion */
- pointer u; /* user's font identifier */
- str_number t; /* name for the frozen font identifier */
- internal_font_number f, k;
- get_r_token();
- u = cur_cs;
- if (u >= hash_base)
- t = cs_text(u);
- else
- t = maketexstring("FONT");
- define(u, set_font_cmd, null_font);
- scan_optional_equals();
- scan_font_ident();
- k = cur_val;
- f = copy_font_info(k);
- equiv(u) = f;
- eqtb[font_id_base + f] = eqtb[u];
- font_id_text(f) = t;
-}
-
@ @c
void pdf_include_chars(PDF pdf)
{
@@ -396,7 +196,7 @@ void pdf_include_chars(PDF pdf)
scan_font_ident();
f = cur_val;
if (f == null_font)
- pdf_error("font", "invalid font identifier");
+ normal_error("pdf backend", "invalid font identifier for 'includechars'");
pdf_check_vf(cur_val);
if (!font_used(f))
pdf_init_font(pdf, f);
@@ -409,18 +209,3 @@ void pdf_include_chars(PDF pdf)
}
flush_str(s);
}
-
-@ @c
-void glyph_to_unicode(void)
-{
- str_number s1, s2;
- scan_pdf_ext_toks();
- s1 = tokens_to_string(def_ref);
- delete_token_ref(def_ref);
- scan_pdf_ext_toks();
- s2 = tokens_to_string(def_ref);
- delete_token_ref(def_ref);
- def_tounicode(s1, s2);
- flush_str(s2);
- flush_str(s1);
-}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
index eb77fccc001..d0677c1748f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
@@ -66,12 +66,7 @@ written bytes.
ff = A; \
} while (0)
-typedef enum { NOT_SHIPPING, SHIPPING_PAGE, SHIPPING_FORM } shipping_mode_e;
-
-extern int pdf_output_option;
-extern int pdf_output_value;
-extern int pdf_draftmode_option;
-extern int pdf_draftmode_value;
+typedef enum { NOT_SHIPPING, SHIPPING_PAGE, SHIPPING_FORM } shipping_mode_e; /* needs pdf_prefix */
extern scaled one_hundred_inch;
extern scaled one_inch;
@@ -187,8 +182,6 @@ extern char *convertStringToPDFString(const char *in, int len);
extern void init_start_time(PDF);
extern char *getcreationdate(PDF);
-extern void pdf_error(const char *t, const char *p);
-extern void pdf_warning(const char *t, const char *p, boolean pr, boolean ap);
extern void check_o_mode(PDF pdf, const char *s, int o_mode, boolean errorflag);
extern void set_job_id(PDF, int, int, int, int);
@@ -199,7 +192,6 @@ extern void print_pdf_table_string(PDF pdf, const char *s);
extern const char *get_pdf_table_string(const char *s);
extern int get_pdf_table_bool(PDF, const char *, int);
-extern void fix_o_mode(PDF pdf);
extern void ensure_output_state(PDF pdf, output_state s);
extern PDF init_pdf_struct(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index d825b885a49..8ba7a8872a7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -18,8 +18,6 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
@ @c
@@ -38,10 +36,11 @@ PDF static_pdf = NULL;
@ commandline interface
@c
-int pdf_output_option;
-int pdf_output_value;
-int pdf_draftmode_option;
-int pdf_draftmode_value;
+int output_mode_used;
+int output_mode_option;
+int output_mode_value;
+int draft_mode_option;
+int draft_mode_value;
halfword pdf_info_toks; /* additional keys of Info dictionary */
halfword pdf_catalog_toks; /* additional keys of Catalog dictionary */
@@ -52,6 +51,7 @@ shipping_mode_e global_shipping_mode = NOT_SHIPPING; /* set to |shipping_m
@ Create a new buffer |strbuf_s| of size |size| and maximum allowed size |limit|.
Initialize it and set |p| to begin of data.
+
@c
strbuf_s *new_strbuf(size_t size, size_t limit)
{
@@ -68,6 +68,7 @@ strbuf_s *new_strbuf(size_t size, size_t limit)
}
@ Check that |n| bytes more fit into buffer; increase it if required.
+
@c
static void strbuf_room(strbuf_s * b, size_t n)
{
@@ -89,6 +90,7 @@ static void strbuf_room(strbuf_s * b, size_t n)
}
@ Seek to position |offset| within buffer. Position must be valid.
+
@c
void strbuf_seek(strbuf_s * b, off_t offset)
{
@@ -97,6 +99,7 @@ void strbuf_seek(strbuf_s * b, off_t offset)
}
@ Get the current buffer fill level, the number of characters.
+
@c
size_t strbuf_offset(strbuf_s * b)
{
@@ -104,6 +107,7 @@ size_t strbuf_offset(strbuf_s * b)
}
@ Put one character into buffer. Make room before if needed.
+
@c
void strbuf_putchar(strbuf_s * b, unsigned char c)
{
@@ -113,6 +117,7 @@ void strbuf_putchar(strbuf_s * b, unsigned char c)
}
@ Dump filled buffer part to PDF.
+
@c
void strbuf_flush(PDF pdf, strbuf_s * b)
{
@@ -121,6 +126,7 @@ void strbuf_flush(PDF pdf, strbuf_s * b)
}
@ Free all dynamically allocated buffer structures.
+
@c
void strbuf_free(strbuf_s * b)
{
@@ -129,6 +135,7 @@ void strbuf_free(strbuf_s * b)
}
@ |init_pdf_struct()| is called early, only once, from maincontrol.w
+
@c
PDF init_pdf_struct(PDF pdf)
{
@@ -138,7 +145,8 @@ PDF init_pdf_struct(PDF pdf)
memset(pdf, 0, sizeof(pdf_output_file));
pdf->job_name = makecstring(job_name);
- pdf->o_mode = OMODE_NONE; /* will be set by |fix_o_mode()| */
+ output_mode_used = OMODE_NONE; /* will be set by |fix_o_mode()| */
+ pdf->o_mode = output_mode_used; /* used by synctex, we need to use output_mode_used there */
pdf->o_state = ST_INITIAL;
/* init PDF and object stream writing */
@@ -146,14 +154,12 @@ PDF init_pdf_struct(PDF pdf)
memset(pdf->os, 0, sizeof(os_struct));
os->buf[PDFOUT_BUF] = new_strbuf(inf_pdfout_buf_size, sup_pdfout_buf_size);
os->buf[OBJSTM_BUF] = new_strbuf(inf_objstm_buf_size, sup_objstm_buf_size);
- os->buf[LUASTM_BUF] = new_strbuf(0, 0);
os->obj = xtalloc(PDF_OS_MAX_OBJS, os_obj_data);
os->cur_objstm = 0;
- os->trigger_luastm = false;
os->curbuf = PDFOUT_BUF;
pdf->buf = os->buf[os->curbuf];
-
+
/* Later ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE) */
/* in ttf_init_font will need 236 bytes, so we start with 256 bytes as in pdftex. */
pdf->fb = new_strbuf(256, 100000000);
@@ -228,36 +234,28 @@ int pdf_get_mem(PDF pdf, int s)
return ret;
}
-@ |get_o_mode| translates from |pdf_output| to |o_mode|.
+@ there are defined in |luatex-api.h|, so we need |luatex-api.c|:
@c
-static output_mode get_o_mode(void)
+output_mode get_o_mode(void)
{
output_mode o_mode;
- if (pdf_output > 0) {
- /* ls-hh: for the moment disabled ... incomplete old experiment */
- /*
- if (pdf_output == 2009)
- o_mode = OMODE_LUA;
- else
- */
- o_mode = OMODE_PDF;
+ if (int_par(output_mode_code) > 0) {
+ o_mode = OMODE_PDF;
} else
o_mode = OMODE_DVI;
return o_mode;
}
-@ |fix_o_mode| freezes |pdf->o_mode| as soon as anything goes through
-the backend, be it \.{PDF}, \.{DVI}, or \.{Lua}.
-
-@c
-void fix_o_mode(PDF pdf)
+void fix_o_mode(void)
{
output_mode o_mode = get_o_mode();
- if (pdf->o_mode == OMODE_NONE)
- pdf->o_mode = o_mode;
- else if (pdf->o_mode != o_mode)
- pdf_error("setup", "\\pdfoutput can only be changed before anything is written to the output");
+ if (output_mode_used == OMODE_NONE) {
+ output_mode_used = o_mode;
+ static_pdf->o_mode = output_mode_used; /* used by synctex, we need to use output_mode_used there */
+ } else if (output_mode_used != o_mode) {
+ normal_error("pdf backend", "\\outputmode can only be changed before anything is written to the output");
+ }
}
@ This ensures that |pdfminorversion| is set only before any bytes have
@@ -274,15 +272,16 @@ void fix_pdf_minorversion(PDF pdf)
char msg[256];
(void) snprintf(msg, 255, "LuaTeX error (illegal pdfminorversion %d)", (int) pdf_minor_version);
tex_error(msg, hlp);
- pdf_minor_version = 4;
+ pdf->minor_version = 4;
+ } else {
+ pdf->minor_version = pdf_minor_version;
}
- pdf->minor_version = pdf_minor_version;
} else {
/* Check that variables for \.{PDF} output are unchanged */
if (pdf->minor_version != pdf_minor_version)
- pdf_error("setup", "\\pdfminorversion cannot be changed after data is written to the PDF file");
- if (pdf->draftmode != pdf_draftmode)
- pdf_error("setup", "\\pdfdraftmode cannot be changed after data is written to the PDF file");
+ normal_error("pdf backend", "minorversion cannot be changed after data is written to the PDF file");
+ if (pdf->draftmode != int_par(draft_mode_code))
+ normal_error("pdf backend", "draftmode cannot be changed after data is written to the PDF file");
}
if (pdf->draftmode != 0) {
pdf->compress_level = 0; /* re-fix it, might have been changed inbetween */
@@ -413,11 +412,7 @@ void pdf_flush(PDF pdf)
pdf->zip_write_state = NO_ZIP;
strbuf_seek(pdf->buf, 0);
if (saved_pdf_gone > pdf->gone)
- pdf_error("file size", "File size exceeds architectural limits (pdf_gone wraps around)");
- break;
- case LUASTM_BUF:
- luaL_addsize(&(os->b), strbuf_offset(pdf->buf));
- pdf->buf->p = pdf->buf->data = (unsigned char *) luaL_prepbuffer(&(os->b)); /* for next stream piece */
+ normal_error("pdf backend", "file size exceeds architectural limits (pdf_gone wraps around)");
break;
case OBJSTM_BUF:
break;
@@ -444,7 +439,6 @@ static void pdf_prepare_obj(PDF pdf, int k, int pdf_os_threshold)
{
os_struct *os = pdf->os;
strbuf_s *obuf = os->buf[OBJSTM_BUF];
- assert(os->curbuf != LUASTM_BUF);
assert(pdf_os_threshold >= OBJSTM_ALWAYS);
if (pdf->objcompresslevel >= pdf_os_threshold)
pdf_buffer_select(pdf, OBJSTM_BUF);
@@ -456,9 +450,6 @@ static void pdf_prepare_obj(PDF pdf, int k, int pdf_os_threshold)
obj_offset(pdf, k) = pdf_offset(pdf);
obj_os_idx(pdf, k) = PDF_OS_MAX_OBJS; /* mark it as not included in any ObjStm */
break;
- case LUASTM_BUF:
- assert(0);
- break;
case OBJSTM_BUF:
if (os->cur_objstm == 0) {
os->cur_objstm =
@@ -483,6 +474,7 @@ static void pdf_prepare_obj(PDF pdf, int k, int pdf_os_threshold)
@ Set the active buffer pointer.
Make sure that there are at least |n| bytes free in that buffer,
flush if needed.
+
@c
void pdf_room(PDF pdf, int n)
{
@@ -500,11 +492,6 @@ void pdf_room(PDF pdf, int n)
else
pdf_flush(pdf);
break;
- case LUASTM_BUF:
- if ((size_t) n > buf->size)
- overflow("PDF output buffer", (unsigned) buf->size);
- pdf_flush(pdf);
- break;
case OBJSTM_BUF:
strbuf_room(buf, (size_t) n); /* just grow it */
break;
@@ -545,6 +532,7 @@ void pdf_printf(PDF pdf, const char *fmt, ...)
}
@ print out a string to PDF buffer
+
@c
void pdf_print(PDF pdf, str_number s)
{
@@ -561,6 +549,7 @@ void pdf_print(PDF pdf, str_number s)
}
@ print out a integer to PDF buffer
+
@c
void pdf_print_int(PDF pdf, longinteger n)
{
@@ -598,6 +587,7 @@ void print_pdffloat(PDF pdf, pdffloat f)
}
@ print out |s| as string in PDF output
+
@c
void pdf_print_str(PDF pdf, const char *s)
{
@@ -631,27 +621,17 @@ void pdf_print_str(PDF pdf, const char *s)
}
@ begin a stream (needs to have a stream dictionary also)
+
@c
void pdf_begin_stream(PDF pdf)
{
os_struct *os = pdf->os;
- strbuf_s *lbuf = os->buf[LUASTM_BUF];
assert(os->curbuf == PDFOUT_BUF);
assert(pdf->buf == os->buf[os->curbuf]);
assert(pdf->zip_write_state == NO_ZIP);
pdf_puts(pdf, "\nstream\n");
pdf_save_offset(pdf);
pdf_flush(pdf);
-
- if (callback_defined(pdf_stream_filter_callback)) {
- /*if (os->trigger_luastm) {*/
- os->trigger_luastm = false; /* this was just a trigger */
- luaL_buffinit(Luas, &(os->b));
- lbuf->p = lbuf->data = (unsigned char *) luaL_prepbuffer(&(os->b));
- lbuf->size = lbuf->limit = LUAL_BUFFERSIZE;
- os->curbuf = LUASTM_BUF;
- pdf->buf = os->buf[os->curbuf];
- }
if (pdf->stream_deflate) {
assert(pdf->compress_level > 0);
pdf->zip_write_state = ZIP_WRITING;
@@ -662,23 +642,11 @@ void pdf_begin_stream(PDF pdf)
}
@ end a stream
+
@c
void pdf_end_stream(PDF pdf)
{
- typedef struct strbuf_const_s_ {
- unsigned const char *data; /* a PDF stream buffer */
- unsigned const char *p; /* pointer to the next character in the PDF stream buffer */
- size_t size; /* currently allocated size of the PDF stream buffer, grows dynamically */
- size_t limit; /* maximum allowed PDF stream buffer size */
- } strbuf_const_s;
-
-
os_struct *os = pdf->os;
- /* Old code, */
- /* strbuf_s *lbuf = os->buf[LUASTM_BUF]; */
- strbuf_const_s *lbuf = (strbuf_const_s * )os->buf[LUASTM_BUF];
- const_lstring ls;
- int callback_id ;
assert(pdf->buf == os->buf[os->curbuf]);
switch (os->curbuf) {
case PDFOUT_BUF:
@@ -686,33 +654,6 @@ void pdf_end_stream(PDF pdf)
pdf->zip_write_state = ZIP_FINISH;
pdf_flush(pdf); /* sets pdf->last_byte */
break;
- case LUASTM_BUF:
- luaL_addsize(&(os->b), strbuf_offset(os->buf[LUASTM_BUF]));
- luaL_pushresult(&(os->b));
- /* now the complete page stream is on the Lua stack */
- /* TODO: pagestream filter callback here */
-
- callback_id = callback_defined(pdf_stream_filter_callback);
- if (callback_id > 0) {
- run_callback(callback_id, "S->S");
- }
-
- ls.s = lua_tolstring(Luas, -1, &ls.l);
- /* lbuf->data = (unsigned char *) ls.s; */
- lbuf->data = (unsigned const char *) ls.s;
- lbuf->p = lbuf->data + ls.l;
- os->curbuf = LUASTM_BUF;
- pdf->buf = os->buf[os->curbuf];
- if (pdf->zip_write_state == ZIP_WRITING) {
- pdf->zip_write_state = ZIP_FINISH;
- write_zip(pdf);
- } else
- write_nozip(pdf);
- lua_pop(Luas, 1);
- os->curbuf = PDFOUT_BUF;
- pdf->buf = os->buf[os->curbuf];
- assert(pdf->buf->data == pdf->buf->p);
- break;
case OBJSTM_BUF:
assert(0);
break;
@@ -742,29 +683,21 @@ accurary.
@c
#define max_integer 0x7FFFFFFF /* $2^{31}-1$ */
-/* scaled value corresponds to 100in, exact, 473628672 */
-scaled one_hundred_inch = 7227 * 65536;
-
-/* scaled value corresponds to 1in (rounded to 4736287) */
-scaled one_inch = (7227 * 65536 + 50) / 100;
-
-/* scaled value corresponds to 1truein (rounded!) */
-scaled one_true_inch = (7227 * 65536 + 50) / 100;
-
-/* scaled value corresponds to 100bp */
-scaled one_hundred_bp = (7227 * 65536) / 72;
+scaled one_hundred_inch = 7227 * 65536; /* scaled value corresponds to 100in, exact, 473628672 */
+scaled one_inch = (7227 * 65536 + 50) / 100; /* scaled value corresponds to 1in (rounded to 4736287) */
+scaled one_true_inch = (7227 * 65536 + 50) / 100; /* scaled value corresponds to 1truein (rounded!) */
+scaled one_hundred_bp = (7227 * 65536) / 72; /* scaled value corresponds to 100bp */
+scaled one_bp = 65781; /* scaled value corresponds to 1bp (rounded to 65782) */
-/* scaled value corresponds to 1bp (rounded to 65782) */
-/* changed on 20110411 to be exactly 65781, as in tex itself,
- because this value is also used for \pdfpxdimen */
-scaled one_bp = 65781;
+/*
+ one_bp is changed on 20110411 to be exactly 65781, as in tex itself, because this value
+ is also used for \pdfpxdimen
+*/
-/* $10^0..10^9$ */
int ten_pow[10] = {
- 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
+ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 /* $10^0..10^9$ */
};
-
@ The function |divide_scaled| divides |s| by |m| using |dd| decimal
digits of precision. It is defined in C because it is a good candidate
for optimizations that are not possible in pascal.
@@ -798,7 +731,6 @@ scaled round_xn_over_d(scaled x, int n, unsigned int d)
return (-(scaled) u);
}
-
@ @c
void pdf_add_bp(PDF pdf, scaled s)
{ /* print scaled as |bp| */
@@ -954,19 +886,24 @@ static void destroy_page_resources_tree(PDF pdf)
@* Subroutines to print out various PDF objects.
-@ print out an integer |n| with fixed width |w|; used for outputting cross-reference table
+@ print out an integer |n| with fixed width |w|; used for outputting cross-reference table. The
+specification says that an offset must take 10 bytes.
@c
-static void pdf_print_fw_int(PDF pdf, longinteger n, size_t w)
+static void pdf_print_fw_int(PDF pdf, longinteger n)
{
- int k; /* $0\le k\le23$ */
- unsigned char digits[24];
- k = (int) w;
+ unsigned char digits[11];
+
+ int k = 10;
do {
k--;
digits[k] = (unsigned char) ('0' + (n % 10));
n /= 10;
} while (k != 0);
- pdf_out_block(pdf, (const char *) digits, w);
+ if (n!=0)
+ /* the absolute value of $n$ is greater than 9999999999 */
+ normal_error("pdf backend", "offset exceeds 10 bytes, try enabling object compression.");
+ digits[10]='\0';
+ pdf_puts(pdf, (const char *) digits);
}
@ print out an integer |n| as a fixed number |w| of bytes; used for outputting \.{/XRef} cross-reference stream
@@ -985,6 +922,7 @@ static void pdf_out_bytes(PDF pdf, longinteger n, size_t w)
}
@ print out |s| as string in PDF output
+
@c
void pdf_print_str_ln(PDF pdf, const char *s)
{
@@ -1007,6 +945,7 @@ void pdf_print_toks(PDF pdf, halfword p)
}
@ prints a rect spec
+
@c
void pdf_add_rect_spec(PDF pdf, halfword r)
{
@@ -1017,6 +956,7 @@ void pdf_add_rect_spec(PDF pdf, halfword r)
}
@ output a rectangle specification to PDF file
+
@c
void pdf_rectangle(PDF pdf, halfword r)
{
@@ -1030,8 +970,9 @@ void pdf_rectangle(PDF pdf, halfword r)
@ @c
static void init_pdf_outputparameters(PDF pdf)
{
- assert(pdf->o_mode == OMODE_PDF);
- pdf->draftmode = fix_int(pdf_draftmode, 0, 1);
+ int pk_mode;
+ assert(output_mode_used == OMODE_PDF);
+ pdf->draftmode = fix_int(int_par(draft_mode_code), 0, 1);
pdf->compress_level = fix_int(pdf_compress_level, 0, 9);
pdf->decimal_digits = fix_int(pdf_decimal_digits, 0, 4);
pdf->gamma = fix_int(pdf_gamma, 0, 1000000);
@@ -1046,9 +987,7 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->os_enable = true;
} else {
if (pdf->objcompresslevel > 0) {
- pdf_warning("Object streams",
- "\\pdfobjcompresslevel > 0 requires \\pdfminorversion > 4. Object streams disabled now.",
- true, true);
+ normal_warning("pdf backend","objcompresslevel > 0 requires minorversion > 4", true, true);
pdf->objcompresslevel = 0;
}
pdf->os_enable = false;
@@ -1058,8 +997,9 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->pk_scale_factor =
divide_scaled(72, pdf->pk_resolution, 5 + pdf->decimal_digits);
if (!callback_defined(read_pk_file_callback)) {
- if (pdf_pk_mode != null) {
- char *s = tokenlist_to_cstring(pdf_pk_mode, true, NULL);
+ pk_mode = pdf_pk_mode; /* lookup once */
+ if (pk_mode != null) {
+ char *s = tokenlist_to_cstring(pk_mode, true, NULL);
kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, s, nil);
xfree(s);
} else {
@@ -1085,7 +1025,7 @@ static void ensure_output_file_open(PDF pdf, const char *ext)
if (job_name == 0)
open_log_file();
fn = pack_job_name(ext);
- if (pdf->draftmode == 0 || pdf->o_mode == OMODE_DVI) {
+ if (pdf->draftmode == 0 || output_mode_used == OMODE_DVI) {
while (!lua_b_open_out(&pdf->file, fn))
fn = prompt_file_name("file name for output", ext);
}
@@ -1096,7 +1036,7 @@ static void ensure_output_file_open(PDF pdf, const char *ext)
static void ensure_pdf_header_written(PDF pdf)
{
assert(pdf->o_state == ST_FILE_OPEN);
- assert(pdf->o_mode == OMODE_PDF);
+ assert(output_mode_used == OMODE_PDF);
/* Initialize variables for \.{PDF} output */
fix_pdf_minorversion(pdf);
init_pdf_outputparameters(pdf);
@@ -1118,32 +1058,28 @@ void ensure_output_state(PDF pdf, output_state s)
ensure_output_state(pdf, s - 1);
switch (s - 1) {
case ST_INITIAL:
- fix_o_mode(pdf);
+ fix_o_mode();
break;
case ST_OMODE_FIX:
- switch (pdf->o_mode) {
+ switch (output_mode_used) {
case OMODE_DVI:
ensure_output_file_open(pdf, ".dvi");
break;
case OMODE_PDF:
ensure_output_file_open(pdf, ".pdf");
break;
- case OMODE_LUA:
- break;
default:
assert(0);
}
break;
case ST_FILE_OPEN:
- switch (pdf->o_mode) {
+ switch (output_mode_used) {
case OMODE_DVI:
ensure_dvi_header_written(pdf);
break;
case OMODE_PDF:
ensure_pdf_header_written(pdf);
break;
- case OMODE_LUA:
- break;
default:
assert(0);
}
@@ -1211,6 +1147,7 @@ static void pdf_os_write_objstream(PDF pdf)
}
@ begin a PDF dictionary
+
@c
void pdf_begin_dict(PDF pdf)
{
@@ -1219,6 +1156,7 @@ void pdf_begin_dict(PDF pdf)
}
@ end a PDF dictionary
+
@c
void pdf_end_dict(PDF pdf)
{
@@ -1227,6 +1165,7 @@ void pdf_end_dict(PDF pdf)
}
@ add integer object to dict
+
@c
void pdf_dict_add_bool(PDF pdf, const char *key, int i)
{
@@ -1235,6 +1174,7 @@ void pdf_dict_add_bool(PDF pdf, const char *key, int i)
}
@ add integer object to dict
+
@c
void pdf_dict_add_int(PDF pdf, const char *key, int i)
{
@@ -1243,6 +1183,7 @@ void pdf_dict_add_int(PDF pdf, const char *key, int i)
}
@ add name object to dict
+
@c
void pdf_dict_add_name(PDF pdf, const char *key, const char *val)
{
@@ -1251,6 +1192,7 @@ void pdf_dict_add_name(PDF pdf, const char *key, const char *val)
}
@ add string object to dict
+
@c
void pdf_dict_add_string(PDF pdf, const char *key, const char *val)
{
@@ -1264,6 +1206,7 @@ void pdf_dict_add_string(PDF pdf, const char *key, const char *val)
}
@ add name reference to dict
+
@c
void pdf_dict_add_ref(PDF pdf, const char *key, int num)
{
@@ -1272,6 +1215,7 @@ void pdf_dict_add_ref(PDF pdf, const char *key, int num)
}
@ add objects of different types
+
@c
void pdf_add_null(PDF pdf)
{
@@ -1334,6 +1278,7 @@ void pdf_add_ref(PDF pdf, int num)
@ add stream length and filter entries to a stream dictionary,
remember file position for seek
+
@c
void pdf_dict_add_streaminfo(PDF pdf)
{
@@ -1350,6 +1295,7 @@ void pdf_dict_add_streaminfo(PDF pdf)
}
@ begin a PDF array
+
@c
void pdf_begin_array(PDF pdf)
{
@@ -1358,6 +1304,7 @@ void pdf_begin_array(PDF pdf)
}
@ end a PDF array
+
@c
void pdf_end_array(PDF pdf)
{
@@ -1366,6 +1313,7 @@ void pdf_end_array(PDF pdf)
}
@ begin a PDF object
+
@c
void pdf_begin_obj(PDF pdf, int i, int pdf_os_threshold)
{
@@ -1377,9 +1325,6 @@ void pdf_begin_obj(PDF pdf, int i, int pdf_os_threshold)
case PDFOUT_BUF:
pdf_printf(pdf, "%d 0 obj\n", (int) i);
break;
- case LUASTM_BUF:
- assert(0);
- break;
case OBJSTM_BUF:
if (pdf->compress_level == 0)
pdf_printf(pdf, "%% %d 0 obj\n", (int) i); /* debugging help */
@@ -1391,6 +1336,7 @@ void pdf_begin_obj(PDF pdf, int i, int pdf_os_threshold)
}
@ end a PDF object
+
@c
void pdf_end_obj(PDF pdf)
{
@@ -1400,9 +1346,6 @@ void pdf_end_obj(PDF pdf)
case PDFOUT_BUF:
pdf_puts(pdf, "\nendobj\n"); /* end a PDF object */
break;
- case LUASTM_BUF:
- assert(0);
- break;
case OBJSTM_BUF:
os->idx++; /* = number of objects collected so far in ObjStm */
os->o_ctr++; /* only for statistics */
@@ -1686,47 +1629,10 @@ void remove_pdffile(PDF pdf)
}
}
-@ @c
-void pdf_error(const char *t, const char *p)
-{
- normalize_selector();
- print_err("LuaTeX error");
- if (t != NULL) {
- tprint(" (");
- tprint(t);
- tprint(")");
- }
- tprint(": ");
- if (p != NULL)
- tprint(p);
- succumb();
-}
-
-@ @c
-void pdf_warning(const char *t, const char *p, boolean prepend_nl,
- boolean append_nl)
-{
- if (prepend_nl)
- print_ln();
- tprint("LuaTeX warning");
- if (t != NULL) {
- tprint(" (");
- tprint(t);
- tprint(")");
- }
- tprint(": ");
- if (p != NULL)
- tprint(p);
- if (append_nl)
- print_ln();
- if (history == spotless)
- history = warning_issued;
-}
-
@ Use |check_o_mode()| in the backend-specific "Implement..." chunks
@c
-void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
+void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict) /* s ignored now */
{
char warn_string[100];
@@ -1734,14 +1640,15 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
const char *m = NULL;
/* in warn mode (strict == false):
- only check, don't do |fix_o_mode()| here! |pdf->o_mode| is left
+ only check, don't do |fix_o_mode()| here! |output_mode_used| is left
in possibly wrong state until real output, ok.
*/
- if (pdf->o_mode == OMODE_NONE)
+ if (output_mode_used == OMODE_NONE)
o_mode = get_o_mode();
else
- o_mode = pdf->o_mode;
+ o_mode = output_mode_used;
+ pdf->o_mode = output_mode_used; /* used by synctex, we need to use output_mode_used there */
if (!((1 << o_mode) & o_mode_bitpattern)) { /* warning or error */
switch (o_mode) {
case OMODE_DVI:
@@ -1750,18 +1657,15 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
case OMODE_PDF:
m = "PDF";
break;
- case OMODE_LUA:
- m = "Lua";
- break;
default:
assert(0);
}
- snprintf(warn_string, 99, "not allowed in %s mode (\\pdfpoutput = %d)",
- m, (int) pdf_output);
+ snprintf(warn_string, 99, "%s not allowed in %s mode (outputmode = %d)",
+ s, m, (int) int_par(output_mode_code));
if (strict)
- pdf_error(s, warn_string);
+ normal_error("pdf backend", warn_string);
else
- pdf_warning(s, warn_string, true, true);
+ normal_warning("pdf backend", warn_string, true, true);
} else if (strict)
ensure_output_state(pdf, ST_HEADER_WRITTEN);
}
@@ -1817,12 +1721,10 @@ char *get_resname_prefix(PDF pdf)
@ @c
#define mag int_par(mag_code)
-#define pdf_xform_attr equiv(pdf_xform_attr_loc)
-#define pdf_xform_resources equiv(pdf_xform_resources_loc)
-
void pdf_begin_page(PDF pdf)
{
pdffloat f;
+ int xform_attributes;
scaled form_margin = 0; /* was one_bp until SVN4066 */
ensure_output_state(pdf, ST_HEADER_WRITTEN);
init_pdf_pagecalculations(pdf);
@@ -1851,13 +1753,19 @@ void pdf_begin_page(PDF pdf)
pdf_begin_dict(pdf);
pdf_dict_add_name(pdf, "Type", "XObject");
pdf_dict_add_name(pdf, "Subtype", "Form");
- if (pdf_xform_attr != null)
- pdf_print_toks(pdf, pdf_xform_attr);
+ xform_attributes = pdf_xform_attr; /* lookup once */
+ if (xform_attributes != null)
+ pdf_print_toks(pdf, xform_attributes);
if (obj_xform_attr(pdf, pdf_cur_form) != null) {
pdf_print_toks(pdf, obj_xform_attr(pdf, pdf_cur_form));
delete_token_ref(obj_xform_attr(pdf, pdf_cur_form));
set_obj_xform_attr(pdf, pdf_cur_form, null);
}
+ if (obj_xform_attr_str(pdf, pdf_cur_form) != null) {
+ lua_pdf_literal(pdf, obj_xform_attr_str(pdf, pdf_cur_form));
+ luaL_unref(Luas, LUA_REGISTRYINDEX, obj_xform_attr_str(pdf, pdf_cur_form));
+ set_obj_xform_attr_str(pdf, pdf_cur_form, null);
+ }
pdf_add_name(pdf, "BBox");
pdf_begin_array(pdf);
pdf_add_bp(pdf, -form_margin);
@@ -1880,7 +1788,6 @@ void pdf_begin_page(PDF pdf)
/* Start stream of page/form contents */
pdf_dict_add_streaminfo(pdf);
pdf_end_dict(pdf);
- pdf->os->trigger_luastm = false; /* if it's true, the page stream goes through Lua */
pdf_begin_stream(pdf);
if (global_shipping_mode == SHIPPING_PAGE) {
/* Adjust transformation matrix for the magnification ratio */
@@ -1910,7 +1817,7 @@ void print_pdf_table_string(PDF pdf, const char *s)
lua_rawget(Luas, LUA_REGISTRYINDEX);
lua_pushstring(Luas, s); /* s t ... */
lua_rawget(Luas, -2); /* s? t ... */
- if (lua_isstring(Luas, -1)) { /* s t ... */
+ if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
ls = lua_tolstring(Luas, -1, &len);
if (len > 0) {
if (pdf->cave == 1)
@@ -1930,20 +1837,22 @@ const char *get_pdf_table_string(const char *s)
lua_rawget(Luas, LUA_REGISTRYINDEX);
lua_pushstring(Luas, s); /* s t ... */
lua_rawget(Luas, -2); /* s? t ... */
- if (lua_isstring(Luas, -1)) { /* s t ... */
+ if (lua_type(Luas, -1) == LUA_TSTRING) { /* s t ... */
ls.s = lua_tolstring(Luas, -1, &ls.l);
- /* s is supposed to be anchored (e.g in the registry)
- so it's not garbage collected */
+ /*
+ s is supposed to be anchored (e.g in the registry)
+ so it's not garbage collected
+ */
lua_pop(Luas, 2); /* ... */
- return ls.s;
+ return ls.s;
}
lua_pop(Luas, 2); /* ... */
return NULL ;
}
@ @c
-#define pdf_page_attr equiv(pdf_page_attr_loc)
-#define pdf_page_resources equiv(pdf_page_resources_loc)
+// #define pdf_page_attr equiv(pdf_page_attr_loc)
+// #define pdf_page_resources equiv(pdf_page_resources_loc)
void pdf_end_page(PDF pdf)
{
@@ -1954,19 +1863,18 @@ void pdf_end_page(PDF pdf)
pdf_object_list *annot_list, *bead_list, *link_list, *ol, *ol1;
scaledpos save_cur_page_size; /* to save |pdf->page_size| during flushing pending forms */
shipping_mode_e save_shipping_mode;
+ int xform_resources;
+ int page_resources, page_attributes;
int procset = PROCSET_PDF;
/* Finish stream of page/form contents */
pdf_goto_pagemode(pdf);
if (pos_stack_used > 0) {
- luatex_fail("%u unmatched \\pdfsave after %s shipout",
- (unsigned int) pos_stack_used,
- ((global_shipping_mode ==
- SHIPPING_PAGE) ? "page" : "form"));
+ luatex_fail("%u unmatched 'save' after %s shipout", (unsigned int) pos_stack_used,
+ ((global_shipping_mode == SHIPPING_PAGE) ? "page" : "form"));
}
pdf_end_stream(pdf);
pdf_end_obj(pdf);
-
/* hh-ls : new call back finish_pdfpage_callback */
callback_id = callback_defined(finish_pdfpage_callback);
if (callback_id > 0)
@@ -1989,8 +1897,9 @@ void pdf_end_page(PDF pdf)
pdf_add_mag_bp(pdf, pdf->page_size.h);
pdf_add_mag_bp(pdf, pdf->page_size.v);
pdf_end_array(pdf);
- if (pdf_page_attr != null)
- pdf_print_toks(pdf, pdf_page_attr);
+ page_attributes = pdf_page_attr ; /* lookup once */
+ if (page_attributes != null)
+ pdf_print_toks(pdf, page_attributes);
print_pdf_table_string(pdf, "pageattributes");
pdf_dict_add_ref(pdf, "Parent", pdf->last_pages);
if (pdf->img_page_group_val != 0) {
@@ -2142,17 +2051,24 @@ void pdf_end_page(PDF pdf)
pdf_begin_dict(pdf);
/* Print additional resources */
if (global_shipping_mode == SHIPPING_PAGE) {
- if (pdf_page_resources != null)
- pdf_print_toks(pdf, pdf_page_resources);
+ page_resources = pdf_page_resources; /* lookup once */
+ if (page_resources != null)
+ pdf_print_toks(pdf, page_resources);
print_pdf_table_string(pdf, "pageresources");
} else {
- if (pdf_xform_resources != null)
- pdf_print_toks(pdf, pdf_xform_resources);
+ xform_resources = pdf_xform_resources; /* lookup once */
+ if (xform_resources != null)
+ pdf_print_toks(pdf, xform_resources);
if (obj_xform_resources(pdf, pdf_cur_form) != null) {
pdf_print_toks(pdf, obj_xform_resources(pdf, pdf_cur_form));
delete_token_ref(obj_xform_resources(pdf, pdf_cur_form));
set_obj_xform_resources(pdf, pdf_cur_form, null);
}
+ if (obj_xform_resources_str(pdf, pdf_cur_form) != null) {
+ lua_pdf_literal(pdf, obj_xform_resources_str(pdf, pdf_cur_form));
+ luaL_unref(Luas, LUA_REGISTRYINDEX, obj_xform_resources_str(pdf, pdf_cur_form));
+ set_obj_xform_resources_str(pdf, pdf_cur_form, null);
+ }
}
/* Generate font resources */
@@ -2228,7 +2144,7 @@ static void check_nonexisting_destinations(PDF pdf)
int k;
for (k = pdf->head_tab[obj_type_dest]; k != 0; k = obj_link(pdf, k)) {
if (obj_dest_ptr(pdf, k) == null) {
- pdf_warning("dest", NULL, false, false);
+ normal_warning("pdf backend", "dest ", false, false);
if (obj_info(pdf, k) < 0) {
tprint("name{");
print(-obj_info(pdf, k));
@@ -2262,7 +2178,7 @@ static void check_nonexisting_pages(PDF pdf)
/* search from the end backward until the last real page is found */
for (p = avl_t_last(&t, page_tree);
p != NULL && obj_aux(pdf, p->objptr) == 0; p = avl_t_prev(&t)) {
- pdf_warning("dest", "Page ", false, false);
+ normal_warning("pdf backend", "Page ", false, false);
print_int(obj_info(pdf, p->objptr));
tprint(" has been referenced but does not exist!");
print_ln();
@@ -2423,13 +2339,13 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
&&
(!str_eq_str
(pdf_font_attr(i), pdf_font_attr(k)))) {
- pdf_warning("\\pdffontattr", "fonts ", false, false);
+ normal_warning("pdf backend","fontattr in ", false, false);
print_font_identifier(i);
tprint(" and ");
print_font_identifier(k);
- tprint
- (" have conflicting attributes; I will ignore the attributes assigned to ");
+ tprint(" have conflicting attributes; the attributes assigned to ");
print_font_identifier(i);
+ tprint(" are ignored");
print_ln();
print_ln();
}
@@ -2583,14 +2499,14 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
pdf_puts(pdf, "xref\n");
pdf_puts(pdf, "0 ");
pdf_print_int_ln(pdf, pdf->obj_ptr + 1);
- pdf_print_fw_int(pdf, obj_link(pdf, 0), 10);
+ pdf_print_fw_int(pdf, obj_link(pdf, 0));
pdf_puts(pdf, " 65535 f \n");
for (k = 1; k <= pdf->obj_ptr; k++) {
if (!is_obj_written(pdf, k)) {
- pdf_print_fw_int(pdf, obj_link(pdf, k), 10);
+ pdf_print_fw_int(pdf, obj_link(pdf, k));
pdf_puts(pdf, " 00000 f \n");
} else {
- pdf_print_fw_int(pdf, obj_offset(pdf, k), 10);
+ pdf_print_fw_int(pdf, obj_offset(pdf, k));
pdf_puts(pdf, " 00000 n \n");
}
}
@@ -2643,9 +2559,7 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision)
if (pdf->draftmode == 0)
close_file(pdf->file);
else
- pdf_warning(NULL,
- "\\pdfdraftmode enabled, not changing output pdf",
- true, true);
+ normal_warning("pdf backend","draftmode enabled, not changing output pdf",true, true);
}
if (callback_id == 0) {
@@ -2679,9 +2593,9 @@ void scan_pdfcatalog(PDF pdf)
pdf_catalog_toks = concat_tokens(pdf_catalog_toks, def_ref);
if (scan_keyword("openaction")) {
if (pdf_catalog_openaction != 0) {
- pdf_error("ext1", "duplicate of openaction");
+ normal_error("pdf backend", "duplicate of openaction");
} else {
- check_o_mode(pdf, "\\pdfcatalog", 1 << OMODE_PDF, true);
+ check_o_mode(pdf, "catalog", 1 << OMODE_PDF, true);
p = scan_action(pdf);
pdf_catalog_openaction = pdf_create_obj(pdf, obj_type_others, 0);
pdf_begin_obj(pdf, pdf_catalog_openaction, OBJSTM_ALWAYS);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
index f9b6cf52619..29795990eab 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfimage.w
@@ -145,10 +145,10 @@ void place_img(PDF pdf, image_dict * idict, scaled_whd dim, int transform)
void pdf_place_image(PDF pdf, halfword p)
{
scaled_whd dim;
- image_dict *idict = idict_array[pdf_ximage_index(p)];
+ image_dict *idict = idict_array[rule_index(p)];
assert(idict != NULL);
dim.wd = width(p);
dim.ht = height(p);
dim.dp = depth(p);
- place_img(pdf, idict, dim, pdf_ximage_transform(p));
+ place_img(pdf, idict, dim, rule_transform(p));
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
index 3a5bc327add..89fb1057567 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflink.w
@@ -22,9 +22,6 @@
#include "ptexlib.h"
-@ @c
-#define pdf_link_margin dimen_par(pdf_link_margin_code)
-
@ To implement nested link annotations, we need a stack to hold copy of
|pdf_start_link_node|'s that are being written out, together with their box
nesting level.
@@ -53,10 +50,11 @@ void pop_link_level(PDF pdf)
void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
scaled_whd alt_rule;
+ int k;
if (type(p) == vlist_node)
- pdf_error("ext4", "\\pdfstartlink ended up in vlist");
+ normal_error("pdf backend", "'startlink' ended up in vlist");
if (global_shipping_mode == SHIPPING_FORM)
- pdf_error("ext4", "link annotations cannot be inside an XForm");
+ normal_error("pdf backend", "link annotations cannot be inside an XForm");
assert(type(parent_box) == hlist_node);
if (is_obj_scheduled(pdf, pdf_link_objnum(p)))
pdf_link_objnum(p) = pdf_create_obj(pdf, obj_type_others, 0);
@@ -66,7 +64,9 @@ void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
alt_rule.dp = depth(p);
set_rect_dimens(pdf, p, parent_box, cur, alt_rule, pdf_link_margin);
obj_annot_ptr(pdf, pdf_link_objnum(p)) = p; /* the reference for the pdf annot object must be set here */
- addto_page_resources(pdf, obj_type_link, pdf_link_objnum(p));
+ k = pdf_link_objnum(p);
+ set_obj_scheduled(pdf, pdf_link_objnum(p));
+ addto_page_resources(pdf, obj_type_link, k);
}
@ @c
@@ -75,13 +75,11 @@ void end_link(PDF pdf, halfword p)
halfword q;
scaledpos pos = pdf->posstruct->pos;
if (type(p) == vlist_node)
- pdf_error("ext4", "\\pdfendlink ended up in vlist");
+ normal_error("pdf backend","'endlink' ended up in vlist");
if (pdf->link_stack_ptr < 1)
- pdf_error("ext4",
- "pdf link_stack empty, \\pdfendlink used without \\pdfstartlink?");
+ normal_error("pdf backend","pdf link_stack empty, 'endlink' used without 'startlink'");
if (pdf->link_stack[pdf->link_stack_ptr].nesting_level != cur_s)
- pdf_error("ext4",
- "\\pdfendlink ended up in different nesting level than \\pdfstartlink");
+ normal_error("pdf backend","'endlink' ended up in different nesting level than 'startlink'");
/* N.B.: test for running link must be done on |link_node| and not |ref_link_node|,
as |ref_link_node| can be set by |do_link| or |append_link| already */
@@ -89,11 +87,11 @@ void end_link(PDF pdf, halfword p)
if (is_running(width(pdf->link_stack[pdf->link_stack_ptr].link_node))) {
q = pdf->link_stack[pdf->link_stack_ptr].ref_link_node;
if (global_shipping_mode == SHIPPING_PAGE && matrixused()) {
- matrixrecalculate(pos.h + pdf_link_margin);
+ matrixrecalculate(pos.h + pdf_link_margin);
pdf_ann_left(q) = getllx() - pdf_link_margin;
- pdf_ann_top(q) = pdf->page_size.v - getury() - pdf_link_margin;
+ pdf_ann_top(q) = getlly() - pdf_link_margin;
pdf_ann_right(q) = geturx() + pdf_link_margin;
- pdf_ann_bottom(q) = pdf->page_size.v - getlly() + pdf_link_margin;
+ pdf_ann_bottom(q) = getury() + pdf_link_margin;
} else {
switch (pdf->posstruct->dir) {
case dir_TLT:
@@ -139,6 +137,7 @@ void append_link(PDF pdf, halfword parent_box, scaledpos cur, small_number i)
set_rect_dimens(pdf, p, parent_box, cur, alt_rule, pdf_link_margin);
k = pdf_create_obj(pdf, obj_type_others, 0);
obj_annot_ptr(pdf, k) = p;
+ set_obj_scheduled(pdf, pdf_link_objnum(p));
addto_page_resources(pdf, obj_type_link, k);
}
@@ -148,7 +147,7 @@ void scan_startlink(PDF pdf)
int k;
halfword r;
if (abs(cur_list.mode_field) == vmode)
- pdf_error("ext1", "\\pdfstartlink cannot be used in vertical mode");
+ normal_error("pdf backend", "startlink cannot be used in vertical mode");
k = pdf_create_obj(pdf, obj_type_others, 0);
new_annot_whatsit(pdf_start_link_node);
set_pdf_link_attr(cur_list.tail_field, null);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
index c1764f49c0c..bf32cb8c629 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.w
@@ -20,12 +20,10 @@
\def\pdfTeX{pdf\TeX}
@ @c
-
-
#include "ptexlib.h"
@ @c
-pos_info_structure pos_info; /* to be accessed from Lua */
+pos_info_structure pos_info; /* to be accessed from Lua */
static backend_struct *backend = NULL;
backend_function *backend_out, *backend_out_whatsit;
@@ -44,10 +42,10 @@ static void missing_backend_function(PDF pdf, halfword p)
else
s = "node";
n = get_node_name(type(p), subtype(p));
- b = backend[pdf->o_mode].name;
+ b = backend[output_mode_used].name;
snprintf(backend_string, strlen(b) + 10, "%s back-end", b);
snprintf(err_string, 59, "no output function for \"%s\" %s", n, s);
- pdf_error(backend_string, err_string);
+ normal_error(backend_string, err_string);
}
@ @c
@@ -62,24 +60,22 @@ static void init_pdf_backend_functions(void)
{
backend_struct *p = &backend[OMODE_PDF];
p->name = strdup("PDF");
- p->node_fu[rule_node] = &pdf_place_rule; /* 2 */
- p->node_fu[glyph_node] = &pdf_place_glyph; /* 37 */
- p->whatsit_fu[special_node] = &pdf_special; /* 3 */
- p->whatsit_fu[pdf_literal_node] = &pdf_out_literal; /* 8 */
- p->whatsit_fu[pdf_refobj_node] = &pdf_ref_obj; /* 10 */
- p->whatsit_fu[pdf_refxform_node] = &pdf_place_form; /* 12 */
- p->whatsit_fu[pdf_refximage_node] = &pdf_place_image; /* 14 */
- p->whatsit_fu[pdf_annot_node] = &do_annot; /* 15 */
- p->whatsit_fu[pdf_start_link_node] = &do_link; /* 16 */
- p->whatsit_fu[pdf_end_link_node] = &end_link; /* 17 */
- p->whatsit_fu[pdf_dest_node] = &do_dest; /* 19 */
- p->whatsit_fu[pdf_thread_node] = &do_thread; /* 20 */
- p->whatsit_fu[pdf_end_thread_node] = &end_thread; /* 22 */
- p->whatsit_fu[late_lua_node] = &late_lua; /* 35 */
- p->whatsit_fu[pdf_colorstack_node] = &pdf_out_colorstack; /* 39 */
- p->whatsit_fu[pdf_setmatrix_node] = &pdf_out_setmatrix; /* 40 */
- p->whatsit_fu[pdf_save_node] = &pdf_out_save; /* 41 */
- p->whatsit_fu[pdf_restore_node] = &pdf_out_restore; /* 42 */
+ p->node_fu[rule_node] = &pdf_place_rule;
+ p->node_fu[glyph_node] = &pdf_place_glyph;
+ p->whatsit_fu[special_node] = &pdf_special;
+ p->whatsit_fu[pdf_literal_node] = &pdf_out_literal;
+ p->whatsit_fu[pdf_refobj_node] = &pdf_ref_obj;
+ p->whatsit_fu[pdf_annot_node] = &do_annot;
+ p->whatsit_fu[pdf_start_link_node] = &do_link;
+ p->whatsit_fu[pdf_end_link_node] = &end_link;
+ p->whatsit_fu[pdf_dest_node] = &do_dest;
+ p->whatsit_fu[pdf_thread_node] = &do_thread;
+ p->whatsit_fu[pdf_end_thread_node] = &end_thread;
+ p->whatsit_fu[late_lua_node] = &late_lua;
+ p->whatsit_fu[pdf_colorstack_node] = &pdf_out_colorstack;
+ p->whatsit_fu[pdf_setmatrix_node] = &pdf_out_setmatrix;
+ p->whatsit_fu[pdf_save_node] = &pdf_out_save;
+ p->whatsit_fu[pdf_restore_node] = &pdf_out_restore;
}
@ @c
@@ -87,21 +83,12 @@ static void init_dvi_backend_functions(void)
{
backend_struct *p = &backend[OMODE_DVI];
p->name = strdup("DVI");
- p->node_fu[rule_node] = &dvi_place_rule; /* 2 */
- p->node_fu[glyph_node] = &dvi_place_glyph; /* 37 */
- p->whatsit_fu[special_node] = &dvi_special; /* 3 */
- p->whatsit_fu[late_lua_node] = &late_lua; /* 35 */
+ p->node_fu[rule_node] = &dvi_place_rule;
+ p->node_fu[glyph_node] = &dvi_place_glyph;
+ p->whatsit_fu[special_node] = &dvi_special;
+ p->whatsit_fu[late_lua_node] = &late_lua;
}
-@ @c
-static void init_lua_backend_functions(void)
-{
- backend_struct *p = &backend[OMODE_LUA];
- p->name = strdup("Lua");
- p->node_fu[rule_node] = &lua_place_rule; /* 2 */
- p->node_fu[glyph_node] = &lua_place_glyph; /* 37 */
- p->whatsit_fu[late_lua_node] = &late_lua; /* 35 */
-}
@ @c
void init_backend_functionpointers(output_mode o_mode)
@@ -110,10 +97,8 @@ void init_backend_functionpointers(output_mode o_mode)
if (backend == NULL) {
backend = xmalloc((MAX_OMODE + 1) * sizeof(backend_struct));
for (i = 0; i <= MAX_OMODE; i++) {
- backend[i].node_fu =
- xmalloc((MAX_NODE_TYPE + 1) * sizeof(backend_function));
- backend[i].whatsit_fu =
- xmalloc((MAX_WHATSIT_TYPE + 1) * sizeof(backend_function));
+ backend[i].node_fu = xmalloc((MAX_NODE_TYPE + 1) * sizeof(backend_function));
+ backend[i].whatsit_fu = xmalloc((MAX_WHATSIT_TYPE + 1) * sizeof(backend_function));
for (j = 0; j < MAX_NODE_TYPE + 1; j++)
backend[i].node_fu[j] = &missing_backend_function;
for (j = 0; j < MAX_WHATSIT_TYPE + 1; j++)
@@ -122,7 +107,6 @@ void init_backend_functionpointers(output_mode o_mode)
init_none_backend_functions();
init_dvi_backend_functions();
init_pdf_backend_functions();
- init_lua_backend_functions();
}
backend_out = backend[o_mode].node_fu;
backend_out_whatsit = backend[o_mode].whatsit_fu;
@@ -153,6 +137,7 @@ static scaled simple_advance_width(halfword p)
w += width(q);
break;
case disc_node:
+ /* hh: the frontend should append already */
if (vlink(no_break(q)) != null)
w += simple_advance_width(no_break(q));
default:
@@ -163,16 +148,13 @@ static scaled simple_advance_width(halfword p)
}
@ @c
-static halfword calculate_width_to_enddir(halfword p, real cur_glue,
- scaled cur_g, halfword this_box)
+static halfword calculate_width_to_enddir(halfword p, real cur_glue, scaled cur_g, halfword this_box)
{
int dir_nest = 1;
halfword q = p, enddir_ptr = p;
scaled w = 0;
- halfword g; /* this is normally a global variable, but that is just too hideous */
- /* to me, it looks like the next is needed. but Aleph doesn't do that, so let us not do it either */
- real glue_temp; /* glue value before rounding */
- /* |w:=w-cur_g; cur_glue:=0;| */
+ halfword g; /* this is normally a global variable, but that is just too hideous */
+ real glue_temp; /* glue value before rounding */
int g_sign = glue_sign(this_box);
int g_order = glue_order(this_box);
while ((q != null) && (vlink(q) != null)) {
@@ -190,6 +172,15 @@ static halfword calculate_width_to_enddir(halfword p, real cur_glue,
case kern_node:
w += width(q);
break;
+ case math_node:
+ /* begin mathskip code */
+ if (glue_ptr(q) == zero_glue) {
+ w += surround(q);
+ break;
+ } else {
+ /* fall through: mathskip */
+ }
+ /* end mathskip code */
case glue_node:
g = glue_ptr(q);
w += width(g) - cur_g;
@@ -209,33 +200,28 @@ static halfword calculate_width_to_enddir(halfword p, real cur_glue,
w += cur_g;
break;
case disc_node:
+ /* hh: the frontend should append already */
if (vlink(no_break(q)) != null)
w += simple_advance_width(no_break(q));
break;
- case math_node:
- w += surround(q);
- break;
- case whatsit_node:
- if (subtype(q) == dir_node) {
- if (dir_dir(q) >= 0)
- dir_nest++;
- else
- dir_nest--;
- if (dir_nest == 0) {
- enddir_ptr = q;
- dir_cur_h(enddir_ptr) = w;
- q = null;
- }
- } else if ((subtype(q) == pdf_refxform_node)
- || (subtype(q) == pdf_refximage_node))
- w += width(q);
+ case dir_node:
+ if (dir_dir(q) >= 0)
+ dir_nest++;
+ else
+ dir_nest--;
+ if (dir_nest == 0) {
+ enddir_ptr = q;
+ dir_cur_h(enddir_ptr) = w;
+ q = null;
+ }
break;
default:
break;
}
}
}
- if (enddir_ptr == p) /* no enddir found, just transport w by begindir */
+ if (enddir_ptr == p)
+ /* no enddir found, just transport w by begindir */
dir_cur_h(enddir_ptr) = w;
return enddir_ptr;
}
@@ -251,9 +237,9 @@ implementations, due to machine-dependent rounding in the glue calculations.)
@c
void out_what(PDF pdf, halfword p)
{
- int j; /* write stream number */
- switch (subtype(p)) {
- /* function(pdf, p) */
+ switch (subtype(p)) { /* function(pdf, p) */
+ case special_node: /* |pdf_special(pdf, p)|; */
+ case late_lua_node: /* |late_lua(pdf, p)|; */
case pdf_save_node: /* |pdf_out_save(pdf, p)|; */
case pdf_restore_node: /* |pdf_out_restore(pdf, p)|; */
case pdf_end_link_node: /* |end_link(pdf, p)|; */
@@ -261,43 +247,34 @@ void out_what(PDF pdf, halfword p)
case pdf_literal_node: /* |pdf_out_literal(pdf, p)|; */
case pdf_colorstack_node: /* |pdf_out_colorstack(pdf, p)|; */
case pdf_setmatrix_node: /* |pdf_out_setmatrix(pdf, p)|; */
- case special_node: /* |pdf_special(pdf, p)|; */
- case late_lua_node: /* |late_lua(pdf, p)|; */
case pdf_refobj_node: /* |pdf_ref_obj(pdf, p)| */
backend_out_whatsit[subtype(p)] (pdf, p);
break;
case open_node:
case write_node:
case close_node:
- /* Do some work that has been queued up for \.{\\write} */
+ /* do some work that has been queued up for \.{\\write} */
if (!doing_leaders) {
- j = write_stream(p);
+ int j = write_stream(p);
if (subtype(p) == write_node) {
write_out(p);
- } else {
- if (write_open[j])
- lua_a_close_out(write_file[j]);
- if (subtype(p) == close_node) {
- write_open[j] = false;
- } else if (j < 16) {
- char *fn;
- cur_name = open_name(p);
- cur_area = open_area(p);
- cur_ext = open_ext(p);
- if (cur_ext == get_nullstr())
- cur_ext = maketexstring(".tex");
- fn = pack_file_name(cur_name, cur_area, cur_ext);
- while (!lua_a_open_out(&(write_file[j]), fn, (j + 1)))
- fn = prompt_file_name("output file name", ".tex");
- write_open[j] = true;
+ } else if (subtype(p) == close_node) {
+ close_write_file(j);
+ } else if (valid_write_file(j)) {
+ char *fn;
+ close_write_file(j);
+ cur_name = open_name(p);
+ cur_area = open_area(p);
+ cur_ext = open_ext(p);
+ if (cur_ext == get_nullstr())
+ cur_ext = maketexstring(".tex");
+ fn = pack_file_name(cur_name, cur_area, cur_ext);
+ while (! open_write_file(j,fn)) {
+ fn = prompt_file_name("output file name", ".tex");
}
}
}
break;
- case dir_node: /* in a vlist */
- break;
- case local_par_node:
- case cancel_boundary_node:
case user_defined_node:
break;
default:
@@ -312,7 +289,6 @@ void hlist_out(PDF pdf, halfword this_box)
posstructure localpos; /* the position structure local within this function */
posstructure *refpos; /* the list origin pos. on the page, provided by the caller */
-
scaledpos cur = { 0, 0 }, tmpcur, basepoint;
scaledpos size = { 0, 0 }; /* rule dimensions */
scaled effective_horizontal;
@@ -333,6 +309,7 @@ void hlist_out(PDF pdf, halfword this_box)
int i; /* index to scan |pdf_link_stack| */
int save_loc = 0; /* DVI! \.{DVI} byte location upon entry */
scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */
+ int synctex = int_par(synctex_code) ;
g_order = glue_order(this_box);
g_sign = glue_sign(this_box);
@@ -347,23 +324,21 @@ void hlist_out(PDF pdf, halfword this_box)
if (cur_s > max_push)
max_push = cur_s;
- if (pdf->o_mode == OMODE_DVI) {
- if (cur_s > 0) { /* DVI! */
- dvi_push(); /* DVI! */
- save_dvi = dvi; /* DVI! */
+ if (output_mode_used == OMODE_DVI) {
+ if (cur_s > 0) {
+ dvi_push();
+ save_dvi = dvi;
}
- save_loc = dvi_offset + dvi_ptr /* DVI! */ ;
+ save_loc = dvi_offset + dvi_ptr;
}
- /* Create link annotations for the current hbox if needed */
for (i = 1; i <= pdf->link_stack_ptr; i++) {
assert(is_running(width(pdf->link_stack[i].link_node)));
if (pdf->link_stack[i].nesting_level == cur_s)
append_link(pdf, this_box, cur, (small_number) i);
}
- /* Start hlist {\sl Sync\TeX} information record */
- if (int_par(synctex_code))
+ if (synctex)
synctexhlist(this_box);
while (p != null) {
@@ -382,17 +357,13 @@ void hlist_out(PDF pdf, halfword this_box)
synch_pos_with_cur(pdf->posstruct, refpos, cur);
p = vlink(p);
} while (is_char_node(p));
- /* Record current point {\sl Sync\TeX} information */
- if (int_par(synctex_code))
+ if (synctex)
synctexcurrent();
} else {
- /* Output the non-|char_node| |p| for |hlist_out|
- and move to the next node */
+ /* output the non-|char_node| |p| for |hlist_out| and move to the next node */
switch (type(p)) {
case hlist_node:
case vlist_node:
- /* (\pdfTeX) Output a box in an hlist */
-
if (textdir_parallel(box_dir(p), localpos.dir)) {
effective_horizontal = width(p);
basepoint.v = 0;
@@ -415,28 +386,27 @@ void hlist_out(PDF pdf, halfword this_box)
}
if (is_rotated(localpos.dir)) {
if (partextdir_eq(localpos.dir, box_dir(p)))
- basepoint.v = -width(p) / 2; /* `up' */
+ basepoint.v = -width(p) / 2; /* up */
else
- basepoint.v = width(p) / 2; /* `down' */
+ basepoint.v = width(p) / 2; /* down */
} else if (is_mirrored(localpos.dir)) {
if (partextdir_eq(localpos.dir, box_dir(p)))
basepoint.v = 0;
else
- basepoint.v = width(p); /* `down' */
+ basepoint.v = width(p); /* down */
} else {
if (partextdir_eq(localpos.dir, box_dir(p)))
- basepoint.v = -width(p); /* `up' */
+ basepoint.v = -width(p); /* up */
else
basepoint.v = 0;
}
}
if (!is_mirrored(localpos.dir))
- basepoint.v = basepoint.v + shift_amount(p); /* shift the box `down' */
+ basepoint.v = basepoint.v + shift_amount(p); /* shift the box down */
else
- basepoint.v = basepoint.v - shift_amount(p); /* shift the box `up' */
+ basepoint.v = basepoint.v - shift_amount(p); /* shift the box up */
if (list_ptr(p) == null) {
- /* Record void list {\sl Sync\TeX} information */
- if (int_par(synctex_code)) {
+ if (synctex) {
if (type(p) == vlist_node)
synctexvoidvlist(p, this_box);
else
@@ -455,9 +425,10 @@ void hlist_out(PDF pdf, halfword this_box)
cur.h += effective_horizontal;
break;
case disc_node:
+ /* hh: the frontend should append already */
if (vlink(no_break(p)) != null) {
if (subtype(p) != select_disc) {
- q = tail_of_list(vlink(no_break(p))); /* TODO, this should be a tlink */
+ q = tail_of_list(vlink(no_break(p))); /* this could be a tlink */
vlink(q) = vlink(p);
q = vlink(no_break(p));
vlink(no_break(p)) = null;
@@ -479,11 +450,47 @@ void hlist_out(PDF pdf, halfword this_box)
}
goto FIN_RULE;
break;
+ case dir_node:
+ /* output a reflection instruction if the direction has changed */
+ if (dir_dir(p) >= 0) {
+ /*
+ Calculate the needed width to the matching |enddir|, return the
+ |enddir| node, with width info
+ */
+ enddir_ptr = calculate_width_to_enddir(p, cur_glue, cur_g, this_box);
+ if (textdir_parallel(dir_dir(p), localpos.dir)) {
+ dir_cur_h(enddir_ptr) += cur.h;
+ if (textdir_opposite(dir_dir(p), localpos.dir))
+ cur.h = dir_cur_h(enddir_ptr);
+ } else
+ dir_cur_h(enddir_ptr) = cur.h;
+ if (enddir_ptr != p) {
+ /* only if it is an enddir */
+ dir_cur_v(enddir_ptr) = cur.v;
+ dir_refpos_h(enddir_ptr) = refpos->pos.h;
+ dir_refpos_v(enddir_ptr) = refpos->pos.v;
+ /* negative: mark it as |enddir| */
+ dir_dir(enddir_ptr) = localpos.dir - dir_swap;
+ }
+ /* fake a nested |hlist_out| */
+ synch_pos_with_cur(pdf->posstruct, refpos, cur);
+ refpos->pos = pdf->posstruct->pos;
+ localpos.dir = dir_dir(p);
+ cur.h = 0;
+ cur.v = 0;
+ } else {
+ refpos->pos.h = dir_refpos_h(p);
+ refpos->pos.v = dir_refpos_v(p);
+ localpos.dir = dir_dir(p) + dir_swap;
+ cur.h = dir_cur_h(p);
+ cur.v = dir_cur_v(p);
+ }
+ break;
case whatsit_node:
- /* Output the whatsit node |p| in |hlist_out| */
+ /* output the whatsit node |p| in |hlist_out| */
switch (subtype(p)) {
case save_pos_node:
- pdf_last_pos = pdf->posstruct->pos;
+ last_position = pdf->posstruct->pos;
pos_info.curpos = pdf->posstruct->pos;
pos_info.boxpos.pos = refpos->pos;
pos_info.boxpos.dir = localpos.dir;
@@ -491,100 +498,50 @@ void hlist_out(PDF pdf, halfword this_box)
pos_info.boxdim.ht = height(this_box);
pos_info.boxdim.dp = depth(this_box);
break;
- /* |function(pdf, p, this_box, cur)|; too many args for |out_what()| */
- case pdf_annot_node: /* |do_annot(pdf, p, this_box, cur);| */
- case pdf_start_link_node: /* |do_link(pdf, p, this_box, cur);| */
- case pdf_dest_node: /* |do_dest(pdf, p, this_box, cur);| */
+ case pdf_annot_node:
+ case pdf_start_link_node:
+ case pdf_dest_node:
case pdf_start_thread_node:
- case pdf_thread_node: /* |do_thread(pdf, p, this_box, cur);| */
+ case pdf_thread_node:
backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
break;
- case pdf_refxform_node: /* |pdf_place_form(pdf, pdf_xform_objnum(p));| */
- case pdf_refximage_node: /* |pdf_place_image(pdf, pdf_ximage_idx(p));| */
- /* Output a Form node in a hlist */
- /* Output an Image node in a hlist */
- switch (localpos.dir) {
- case dir_TLT:
- pos_down(depth(p));
- break;
- case dir_TRT:
- pos_left(width(p));
- pos_down(depth(p));
- break;
- case dir_LTL:
- pos_left(height(p));
- pos_down(width(p));
- break;
- case dir_RTT:
- pos_left(depth(p));
- pos_down(width(p));
- break;
- default:
- assert(0);
- }
- backend_out_whatsit[subtype(p)] (pdf, p);
- cur.h += width(p);
- break;
- case dir_node:
- /* Output a reflection instruction if the direction has changed */
- if (dir_dir(p) >= 0) {
- /* Calculate the needed width to the matching |enddir|, return the |enddir| node,
- with width info */
- enddir_ptr =
- calculate_width_to_enddir(p, cur_glue, cur_g,
- this_box);
- if (textdir_parallel(dir_dir(p), localpos.dir)) {
- dir_cur_h(enddir_ptr) += cur.h;
- if (textdir_opposite(dir_dir(p), localpos.dir))
- cur.h = dir_cur_h(enddir_ptr);
- } else
- dir_cur_h(enddir_ptr) = cur.h;
- if (enddir_ptr != p) { /* only if it is an enddir */
- dir_cur_v(enddir_ptr) = cur.v;
- dir_refpos_h(enddir_ptr) = refpos->pos.h;
- dir_refpos_v(enddir_ptr) = refpos->pos.v;
- dir_dir(enddir_ptr) = localpos.dir - 64; /* negative: mark it as |enddir| */
- }
- /* fake a nested |hlist_out| */
- synch_pos_with_cur(pdf->posstruct, refpos, cur);
- refpos->pos = pdf->posstruct->pos;
- localpos.dir = dir_dir(p);
- cur.h = 0;
- cur.v = 0;
- } else {
- refpos->pos.h = dir_refpos_h(p);
- refpos->pos.v = dir_refpos_v(p);
- localpos.dir = dir_dir(p) + 64;
- cur.h = dir_cur_h(p);
- cur.v = dir_cur_v(p);
- }
- break;
default:
out_what(pdf, p);
}
break;
+ case math_node:
+ if (synctex) {
+ synctexmath(p, this_box);
+ }
+ /* begin mathskip code */
+ if (glue_ptr(p) == zero_glue) {
+ cur.h += surround(p);
+ break;
+ } else {
+ /* fall through: mathskip */
+ }
+ /* end mathskip code */
case glue_node:
- /* (\pdfTeX) Move right or output leaders */
{
- halfword g = glue_ptr(p);
- rule.wd = width(g) - cur_g;
- if (g_sign != normal) {
- if (g_sign == stretching) {
- if (stretch_order(g) == g_order) {
- cur_glue = cur_glue + stretch(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue); /* real multiplication */
+ /* move right or output leaders, we use real multiplication */
+ halfword g = glue_ptr(p);
+ rule.wd = width(g) - cur_g;
+ if (g_sign != normal) {
+ if (g_sign == stretching) {
+ if (stretch_order(g) == g_order) {
+ cur_glue = cur_glue + stretch(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
+ cur_g = float_round(glue_temp);
+ }
+ } else if (shrink_order(g) == g_order) {
+ cur_glue = cur_glue - shrink(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
cur_g = float_round(glue_temp);
}
- } else if (shrink_order(g) == g_order) {
- cur_glue = cur_glue - shrink(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue);
- cur_g = float_round(glue_temp);
- }
}
rule.wd = rule.wd + cur_g;
if (subtype(p) >= a_leaders) {
- /* (\pdfTeX) Output leaders in an hlist, |goto fin_rule| if a rule
- or to |next_p| if done */
+ /* output leaders in an hlist, |goto fin_rule| if a rule or to |next_p| if done */
leader_box = leader_ptr(p);
if (type(leader_box) == rule_node) {
rule.ht = height(leader_box);
@@ -599,9 +556,10 @@ void hlist_out(PDF pdf, halfword this_box)
rule.wd = rule.wd + 10; /* compensate for floating-point rounding */
edge = cur.h + rule.wd;
lx = 0;
- /* Let |cur.h| be the position of the first box, and set |leader_wd+lx|
- to the spacing between corresponding parts of boxes */
-
+ /*
+ let |cur.h| be the position of the first box, and set |leader_wd+lx|
+ to the spacing between corresponding parts of boxes
+ */
if (subtype(p) == g_leaders) {
save_h = cur.h;
switch (localpos.dir) {
@@ -611,19 +569,15 @@ void hlist_out(PDF pdf, halfword this_box)
cur.h -= refpos->pos.h - shipbox_refpos.h;
break;
case dir_TRT:
- cur.h =
- refpos->pos.h - shipbox_refpos.h - cur.h;
+ cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
cur.h = leader_wd * (cur.h / leader_wd);
- cur.h =
- refpos->pos.h - shipbox_refpos.h - cur.h;
+ cur.h = refpos->pos.h - shipbox_refpos.h - cur.h;
break;
case dir_LTL:
case dir_RTT:
- cur.h =
- refpos->pos.v - shipbox_refpos.v - cur.h;
+ cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
cur.h = leader_wd * (cur.h / leader_wd);
- cur.h =
- refpos->pos.v - shipbox_refpos.v - cur.h;
+ cur.h = refpos->pos.v - shipbox_refpos.v - cur.h;
break;
default:
assert(0);
@@ -636,8 +590,8 @@ void hlist_out(PDF pdf, halfword this_box)
if (cur.h < save_h)
cur.h += leader_wd;
} else {
- lq = rule.wd / leader_wd; /* the number of box copies */
- lr = rule.wd % leader_wd; /* the remaining space */
+ lq = rule.wd / leader_wd; /* the number of box copies */
+ lr = rule.wd % leader_wd; /* the remaining space */
if (subtype(p) == c_leaders) {
cur.h += lr / 2;
} else {
@@ -645,43 +599,35 @@ void hlist_out(PDF pdf, halfword this_box)
cur.h += (lr - (lq - 1) * lx) / 2;
}
}
-
while (cur.h + leader_wd <= edge) {
- /* (\pdfTeX) Output a leader box at |cur.h|,
- then advance |cur.h| by |leader_wd+lx| */
-
- if (pardir_parallel
- (box_dir(leader_box), localpos.dir)) {
+ /* output a leader box at |cur.h|, then advance |cur.h| by |leader_wd+lx| */
+ if (pardir_parallel(box_dir(leader_box), localpos.dir)) {
basepoint.v = 0;
- if (textdir_opposite
- (box_dir(leader_box), localpos.dir))
+ if (textdir_opposite(box_dir(leader_box), localpos.dir))
basepoint.h = width(leader_box);
else
basepoint.h = 0;
} else {
if (!is_mirrored(box_dir(leader_box))) {
- if (partextdir_eq
- (box_dir(leader_box), localpos.dir))
+ if (partextdir_eq(box_dir(leader_box), localpos.dir))
basepoint.h = height(leader_box);
else
basepoint.h = depth(leader_box);
} else {
- if (partextdir_eq
- (box_dir(leader_box), localpos.dir))
+ if (partextdir_eq(box_dir(leader_box), localpos.dir))
basepoint.h = depth(leader_box);
else
basepoint.h = height(leader_box);
}
- if (partextdir_eq
- (localpos.dir, box_dir(leader_box)))
+ if (partextdir_eq(localpos.dir, box_dir(leader_box)))
basepoint.v = -(width(leader_box) / 2);
else
basepoint.v = (width(leader_box) / 2);
}
if (!is_mirrored(localpos.dir))
- basepoint.v = basepoint.v + shift_amount(leader_box); /* shift the box `down' */
+ basepoint.v = basepoint.v + shift_amount(leader_box); /* shift the box down */
else
- basepoint.v = basepoint.v - shift_amount(leader_box); /* shift the box `up' */
+ basepoint.v = basepoint.v - shift_amount(leader_box); /* shift the box up */
assert(cur.v == 0);
tmpcur.h = cur.h + basepoint.h;
tmpcur.v = basepoint.v;
@@ -706,28 +652,22 @@ void hlist_out(PDF pdf, halfword this_box)
cur.h += width(p);
break;
case kern_node:
- /* Record |kern_node| {\sl Sync\TeX} information */
- if (int_par(synctex_code))
+ if (synctex)
synctexkern(p, this_box);
cur.h += width(p);
break;
- case math_node:
- /* Record |math_node| {\sl Sync\TeX} information */
- if (int_par(synctex_code))
- synctexmath(p, this_box);
- cur.h += surround(p);
- break;
default:
break;
}
goto NEXTP;
FIN_RULE:
- /* (\pdfTeX) Output a rule in an hlist */
+ /* output a rule in an hlist */
if (is_running(rule.ht))
rule.ht = height(this_box);
if (is_running(rule.dp))
rule.dp = depth(this_box);
- if ((rule.ht + rule.dp) > 0 && rule.wd > 0) { /* we don't output empty rules */
+ /* we don't output empty rules */
+ if ((rule.ht + rule.dp) > 0 && rule.wd > 0) {
switch (localpos.dir) {
case dir_TLT:
size.h = rule.wd;
@@ -755,12 +695,18 @@ void hlist_out(PDF pdf, halfword this_box)
default:
assert(0);
}
- backend_out[rule_node] (pdf, p, size); /* |pdf_place_rule(pdf, p, rule.ht + rule.dp, rule.wd);| */
+ if (type(p) == glue_node) {
+ q = leader_ptr(p);
+ if ((q) && (type(q) == rule_node)) {
+ backend_out[rule_node] (pdf, q, size);
+ }
+ } else {
+ backend_out[rule_node] (pdf, p, size);
+ }
}
MOVE_PAST:
cur.h += rule.wd;
- /* Record horizontal |rule_node| or |glue_node| {\sl Sync\TeX} information */
- if (int_par(synctex_code)) {
+ if (synctex) {
synch_pos_with_cur(pdf->posstruct, refpos, cur);
synctexhorizontalruleorglue(p, this_box);
}
@@ -770,15 +716,14 @@ void hlist_out(PDF pdf, halfword this_box)
}
}
- /* Finish hlist {\sl Sync\TeX} information record */
- if (int_par(synctex_code))
+ if (synctex)
synctextsilh(this_box);
- if (pdf->o_mode == OMODE_DVI) {
- prune_movements(save_loc); /* DVI! */
- if (cur_s > 0) { /* DVI! */
- dvi_pop(save_loc); /* DVI! */
- dvi = save_dvi; /* DVI! */
+ if (output_mode_used == OMODE_DVI) {
+ prune_movements(save_loc);
+ if (cur_s > 0) {
+ dvi_pop(save_loc);
+ dvi = save_dvi;
}
}
cur_s--;
@@ -788,28 +733,30 @@ void hlist_out(PDF pdf, halfword this_box)
@ @c
void vlist_out(PDF pdf, halfword this_box)
{
- posstructure localpos; /* the position structure local within this function */
- posstructure *refpos; /* the list origin pos. on the page, provided by the caller */
+ posstructure localpos; /* the position structure local within this function */
+ posstructure *refpos; /* the list origin pos. on the page, provided by the caller */
scaledpos cur, tmpcur, basepoint;
- scaledpos size = { 0, 0 }; /* rule dimensions */
+ scaledpos size = { 0, 0 }; /* rule dimensions */
scaled effective_vertical;
- scaled save_v; /* what |cur.v| should pop to */
- scaled top_edge; /* the top coordinate for this box */
- scaled edge; /* bottom boundary of leader space */
- glue_ord g_order; /* applicable order of infinity for glue */
- int g_sign; /* selects type of glue */
- halfword p; /* current position in the vlist */
- halfword leader_box; /* the leader box being replicated */
- scaled leader_ht; /* height of leader box being replicated */
- scaled lx; /* extra space between leader boxes */
- boolean outer_doing_leaders; /* were we doing leaders? */
- real glue_temp; /* glue value before rounding */
- real cur_glue = 0.0; /* glue seen so far */
- scaled cur_g = 0; /* rounded equivalent of |cur_glue| times the glue ratio */
+ scaled save_v; /* what |cur.v| should pop to */
+ scaled top_edge; /* the top coordinate for this box */
+ scaled edge; /* bottom boundary of leader space */
+ glue_ord g_order; /* applicable order of infinity for glue */
+ int g_sign; /* selects type of glue */
+ halfword p; /* current position in the vlist */
+ halfword q; /* temp */
+ halfword leader_box; /* the leader box being replicated */
+ scaled leader_ht; /* height of leader box being replicated */
+ scaled lx; /* extra space between leader boxes */
+ boolean outer_doing_leaders; /* were we doing leaders? */
+ real glue_temp; /* glue value before rounding */
+ real cur_glue = 0.0; /* glue seen so far */
+ scaled cur_g = 0; /* rounded equivalent of |cur_glue| times the glue ratio */
scaled_whd rule;
- int save_loc = 0; /* DVI! \.{DVI} byte location upon entry */
- scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */
+ int save_loc = 0; /* DVI byte location upon entry */
+ scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */
+ int synctex = int_par(synctex_code) ;
g_order = (glue_ord) glue_order(this_box);
g_sign = glue_sign(this_box);
@@ -828,38 +775,38 @@ void vlist_out(PDF pdf, halfword this_box)
if (cur_s > max_push)
max_push = cur_s;
- if (pdf->o_mode == OMODE_DVI) {
- if (cur_s > 0) { /* DVI! */
- dvi_push(); /* DVI! */
- save_dvi = dvi; /* DVI! */
+ if (output_mode_used == OMODE_DVI) {
+ if (cur_s > 0) {
+ dvi_push();
+ save_dvi = dvi;
}
- save_loc = dvi_offset + dvi_ptr; /* DVI! */
+ save_loc = dvi_offset + dvi_ptr;
}
- /* Start vlist {\sl Sync\TeX} information record */
- if (int_par(synctex_code))
+ if (synctex)
synctexvlist(this_box);
- /* Create thread for the current vbox if needed */
+ /* create thread for the current vbox if needed */
check_running_thread(pdf, this_box, cur);
while (p != null) {
if (is_char_node(p)) {
- confusion("vlistout"); /* this can't happen */
+ confusion("vlistout"); /* this can't happen */
} else {
- /* Output the non-|char_node| |p| for |vlist_out| */
-
+ /* output the non-|char_node| |p| for |vlist_out| */
switch (type(p)) {
case hlist_node:
case vlist_node:
- /* (\pdfTeX) Output a box in a vlist */
+ /*
+ output a box in a vlist:
+
+ todo: the direct test to switch between |width(p)| and |-width(p)|
+ is definately wrong, because it does not nest properly. But at least
+ it fixes a very obvious problem that otherwise occured with
+ \.{\\pardir TLT} in a document with \.{\\bodydir TRT}, and so it
+ will have to do for now. (hh: is this still true?)
- /* TODO: the direct test to switch between |width(p)| and |-width(p)|
- is definately wrong, because it does not nest properly. But at least
- it fixes a very obvious problem that otherwise occured with
- \.{\\pardir TLT} in a document with \.{\\bodydir TRT}, and so it
- will have to do for now.
- */
+ */
if (pardir_parallel(box_dir(p), localpos.dir)) {
effective_vertical = height(p) + depth(p);
if ((type(p) == hlist_node) && is_mirrored(box_dir(p)))
@@ -888,11 +835,10 @@ void vlist_out(PDF pdf, halfword this_box)
else
basepoint.v = width(p);
}
- basepoint.h = basepoint.h + shift_amount(p); /* shift the box `right' */
+ basepoint.h = basepoint.h + shift_amount(p); /* shift the box right */
if (list_ptr(p) == null) {
cur.v += effective_vertical;
- /* Record void list {\sl Sync\TeX} information */
- if (int_par(synctex_code)) {
+ if (synctex) {
synch_pos_with_cur(pdf->posstruct, refpos, cur);
if (type(p) == vlist_node)
synctexvoidvlist(p, this_box);
@@ -926,10 +872,10 @@ void vlist_out(PDF pdf, halfword this_box)
goto FIN_RULE;
break;
case whatsit_node:
- /* Output the whatsit node |p| in |vlist_out| */
+ /* output the whatsit node |p| in |vlist_out| */
switch (subtype(p)) {
case save_pos_node:
- pdf_last_pos = pdf->posstruct->pos;
+ last_position = pdf->posstruct->pos;
pos_info.curpos = pdf->posstruct->pos;
pos_info.boxpos.pos = refpos->pos;
pos_info.boxpos.dir = localpos.dir;
@@ -937,64 +883,38 @@ void vlist_out(PDF pdf, halfword this_box)
pos_info.boxdim.ht = height(this_box);
pos_info.boxdim.dp = depth(this_box);
break;
- /* |function(pdf, p, this_box, cur)|; too many args for |out_what()| */
- case pdf_annot_node: /* |do_annot(pdf, p, this_box, cur);| */
- case pdf_start_link_node: /* |do_link(pdf, p, this_box, cur);| */
- case pdf_dest_node: /* |do_dest(pdf, p, this_box, cur);| */
+ case pdf_annot_node:
+ case pdf_start_link_node:
+ case pdf_dest_node:
case pdf_start_thread_node:
- case pdf_thread_node: /* |do_thread(pdf, p, this_box, cur);| */
+ case pdf_thread_node:
backend_out_whatsit[subtype(p)] (pdf, p, this_box, cur);
break;
- case pdf_refxform_node: /* |pdf_place_form(pdf, pdf_xform_objnum(p));| */
- case pdf_refximage_node: /* |pdf_place_image(pdf, pdf_ximage_idx(p));| */
- /* Output a Form node in a vlist */
- /* Output an Image node in a vlist */
- switch (localpos.dir) {
- case dir_TLT:
- pos_down(height(p) + depth(p));
- break;
- case dir_TRT:
- pos_left(width(p));
- pos_down(height(p) + depth(p));
- break;
- case dir_LTL:
- pos_down(width(p));
- break;
- case dir_RTT:
- pos_left(height(p) + depth(p));
- pos_down(width(p));
- break;
- default:
- assert(0);
- }
- backend_out_whatsit[subtype(p)] (pdf, p);
- cur.v += height(p) + depth(p);
- break;
default:
out_what(pdf, p);
}
break;
case glue_node:
- /* (\pdfTeX) Move down or output leaders */
{
- halfword g = glue_ptr(p);
- rule.ht = width(g) - cur_g;
- if (g_sign != normal) {
- if (g_sign == stretching) {
- if (stretch_order(g) == g_order) {
- cur_glue = cur_glue + stretch(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue); /* real multiplication */
+ /* move down or output leaders, we use real multiplication */
+ halfword g = glue_ptr(p);
+ rule.ht = width(g) - cur_g;
+ if (g_sign != normal) {
+ if (g_sign == stretching) {
+ if (stretch_order(g) == g_order) {
+ cur_glue = cur_glue + stretch(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
+ cur_g = float_round(glue_temp);
+ }
+ } else if (shrink_order(g) == g_order) {
+ cur_glue = cur_glue - shrink(g);
+ vet_glue(float_cast(glue_set(this_box)) * cur_glue);
cur_g = float_round(glue_temp);
}
- } else if (shrink_order(g) == g_order) {
- cur_glue = cur_glue - shrink(g);
- vet_glue(float_cast(glue_set(this_box)) * cur_glue);
- cur_g = float_round(glue_temp);
- }
}
rule.ht = rule.ht + cur_g;
if (subtype(p) >= a_leaders) {
- /* (\pdfTeX) Output leaders in a vlist, |goto fin_rule| if a rule or to |next_p| if done */
+ /* output leaders in a vlist, |goto fin_rulefin_rule| if a rule or to |next_p| if done */
leader_box = leader_ptr(p);
if (type(leader_box) == rule_node) {
rule.wd = width(leader_box);
@@ -1006,9 +926,10 @@ void vlist_out(PDF pdf, halfword this_box)
rule.ht = rule.ht + 10; /* compensate for floating-point rounding */
edge = cur.v + rule.ht;
lx = 0;
- /* Let |cur.v| be the position of the first box, and set |leader_ht+lx|
- to the spacing between corresponding parts of boxes */
-
+ /*
+ let |cur.v| be the position of the first box, and set |leader_ht+lx|
+ to the spacing between corresponding parts of boxes
+ */
if (subtype(p) == g_leaders) {
save_v = cur.v;
switch (localpos.dir) {
@@ -1018,19 +939,15 @@ void vlist_out(PDF pdf, halfword this_box)
cur.v -= refpos->pos.h - shipbox_refpos.h;
break;
case dir_RTT:
- cur.v =
- refpos->pos.h - shipbox_refpos.h - cur.v;
+ cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
cur.v = leader_ht * (cur.v / leader_ht);
- cur.v =
- refpos->pos.h - shipbox_refpos.h - cur.v;
+ cur.v = refpos->pos.h - shipbox_refpos.h - cur.v;
break;
case dir_TLT:
case dir_TRT:
- cur.v =
- refpos->pos.v - shipbox_refpos.v - cur.v;
+ cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
cur.v = leader_ht * (cur.v / leader_ht);
- cur.v =
- refpos->pos.v - shipbox_refpos.v - cur.v;
+ cur.v = refpos->pos.v - shipbox_refpos.v - cur.v;
break;
default:
assert(0);
@@ -1039,14 +956,12 @@ void vlist_out(PDF pdf, halfword this_box)
cur.v += leader_ht;
} else if (subtype(p) == a_leaders) {
save_v = cur.v;
- cur.v =
- top_edge +
- leader_ht * ((cur.v - top_edge) / leader_ht);
+ cur.v = top_edge + leader_ht * ((cur.v - top_edge) / leader_ht);
if (cur.v < save_v)
cur.v += leader_ht;
} else {
- lq = rule.ht / leader_ht; /* the number of box copies */
- lr = rule.ht % leader_ht; /* the remaining space */
+ lq = rule.ht / leader_ht; /* the number of box copies */
+ lr = rule.ht % leader_ht; /* the remaining space */
if (subtype(p) == c_leaders) {
cur.v += lr / 2;
} else {
@@ -1056,8 +971,7 @@ void vlist_out(PDF pdf, halfword this_box)
}
while (cur.v + leader_ht <= edge) {
- /* (\pdfTeX) Output a leader box at |cur.v|,
- then advance |cur.v| by |leader_ht+lx| */
+ /* output a leader box at |cur.v|, then advance |cur.v| by |leader_ht+lx| */
assert(cur.h == 0);
tmpcur.h = shift_amount(leader_box);
tmpcur.v = cur.v + height(leader_box);
@@ -1086,10 +1000,11 @@ void vlist_out(PDF pdf, halfword this_box)
}
goto NEXTP;
FIN_RULE:
- /* (\pdfTeX) Output a rule in a vlist, |goto next_p| */
+ /* output a rule in a vlist, |goto next_p| */
if (is_running(rule.wd))
rule.wd = width(this_box);
- if ((rule.ht + rule.dp) > 0 && rule.wd > 0) { /* we don't output empty rules */
+ /* we don't output empty rules */
+ if ((rule.ht + rule.dp) > 0 && rule.wd > 0) {
switch (localpos.dir) {
case dir_TLT:
size.h = rule.wd;
@@ -1116,7 +1031,14 @@ void vlist_out(PDF pdf, halfword this_box)
default:
assert(0);
}
- backend_out[rule_node] (pdf, p, size); /* |pdf_place_rule(pdf, rule.ht, rule.wd);| */
+ if (type(p) == glue_node) {
+ q = leader_ptr(p);
+ if ((q) && (type(q) == rule_node)) {
+ backend_out[rule_node] (pdf, q, size);
+ }
+ } else {
+ backend_out[rule_node] (pdf, p, size);
+ }
}
cur.v += rule.ht + rule.dp;
goto NEXTP;
@@ -1127,15 +1049,14 @@ void vlist_out(PDF pdf, halfword this_box)
}
synch_pos_with_cur(pdf->posstruct, refpos, cur);
}
- /* Finish vlist {\sl Sync\TeX} information record */
- if (int_par(synctex_code))
+ if (synctex)
synctextsilv(this_box);
- if (pdf->o_mode == OMODE_DVI) {
- prune_movements(save_loc); /* DVI! */
- if (cur_s > 0) { /* DVI! */
- dvi_pop(save_loc); /* DVI! */
- dvi = save_dvi; /* DVI! */
+ if (output_mode_used == OMODE_DVI) {
+ prune_movements(save_loc);
+ if (cur_s > 0) {
+ dvi_pop(save_loc);
+ dvi = save_dvi;
}
}
cur_s--;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
index fee8f23aa20..dae67234a51 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
@@ -103,12 +103,10 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
pdfstructure *p = pdf->pstruct;
if (s >= STRING_OFFSET) { /* needed for |out_save| */
j = 0;
+ /* the next is obsolete, in fact, specials are obsolete in pdf mode */
if (literal_mode == scan_special) {
if (!(str_in_cstr(s, "PDF:", 0) || str_in_cstr(s, "pdf:", 0))) {
- if (warn
- &&
- ((!(str_in_cstr(s, "SRC:", 0) || str_in_cstr(s, "src:", 0)))
- || (str_length(s) == 0)))
+ if (warn && ((!(str_in_cstr(s, "SRC:", 0) || str_in_cstr(s, "src:", 0))) || (str_length(s) == 0)))
tprint_nl("Non-PDF special ignored!");
return;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
index fa5f582cf61..ad392338509 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h
@@ -21,7 +21,7 @@
#ifndef PDFOBJ_H
# define PDFOBJ_H
-/* data structure for \.{\\pdfobj} and \.{\\pdfrefobj} */
+/* data structure for \.{\\pdfextension obj} and \.{\\pdfextension refobj} */
# define set_pdf_obj_objnum(A, B) pdf_obj_objnum(A) = (B)
@@ -54,8 +54,6 @@
/**********************************************************************/
-extern int pdf_last_obj;
-
extern void init_obj_obj(PDF pdf, int k);
extern void pdf_write_obj(PDF pdf, int n);
extern void scan_obj(PDF pdf);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
index 865b93f8856..a3aa09f3860 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.w
@@ -18,13 +18,9 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
#include "lua/luatex-api.h"
-int pdf_last_obj;
-
@ write a raw PDF object
@c
@@ -34,8 +30,8 @@ void pdf_write_obj(PDF pdf, int k)
const_lstring st;
size_t li; /* index into |data.s| */
int saved_compress_level = pdf->compress_level;
- int os_threshold = OBJSTM_ALWAYS; /* gives compressed objects for \.{\\pdfobjcompresslevel} >= |OBJSTM_ALWAYS| */
- int l = 0; /* possibly a lua registry reference */
+ int os_threshold = OBJSTM_ALWAYS; /* gives compressed objects for \.{\\pdfvariable objcompresslevel} >= |OBJSTM_ALWAYS| */
+ int l = 0; /* possibly a lua registry reference */
int ll = 0;
data.s = NULL;
if (obj_obj_pdfcompresslevel(pdf, k) > -1) /* -1 = "unset" */
@@ -48,7 +44,8 @@ void pdf_write_obj(PDF pdf, int k)
l = obj_obj_stream_attr(pdf, k);
if (l != LUA_NOREF) {
lua_rawgeti(Luas, LUA_REGISTRYINDEX, l);
- assert(lua_isstring(Luas, -1));
+ if (lua_type(Luas,-1) != LUA_TSTRING)
+ normal_error("pdf backend","invalid object");
st.s = lua_tolstring(Luas, -1, &li);
st.l = li;
pdf_out_block(pdf, st.s, st.l);
@@ -64,7 +61,8 @@ void pdf_write_obj(PDF pdf, int k)
pdf_begin_obj(pdf, k, os_threshold);
l = obj_obj_data(pdf, k);
lua_rawgeti(Luas, LUA_REGISTRYINDEX, l);
- assert(lua_isstring(Luas, -1));
+ if (lua_type(Luas,-1) != LUA_TSTRING)
+ normal_error("pdf backend","invalid object");
st.s = lua_tolstring(Luas, -1, &li);
st.l = li;
lua_pop(Luas, 1);
@@ -80,21 +78,21 @@ void pdf_write_obj(PDF pdf, int k)
res = run_callback(callback_id, "S->bSd", fnam, &file_opened, &data.s, &ll);
data.l = (size_t) ll;
if (!file_opened)
- pdf_error("ext5", "cannot open file for embedding");
+ normal_error("pdf backend", "cannot open file for embedding");
} else {
byte_file f; /* the data file's FILE* */
if (!fnam)
fnam = st.s;
if (!luatex_open_input(&f, fnam, kpse_tex_format, FOPEN_RBIN_MODE, true))
- pdf_error("ext5", "cannot open file for embedding");
+ normal_error("pdf backend", "cannot open file for embedding");
res = read_data_file(f, &data.s, &ll);
data.l = (size_t) ll;
close_file(f);
}
if (data.l == 0L)
- pdf_error("ext5", "empty file for embedding");
+ normal_error("pdf backend", "empty file for embedding");
if (!res)
- pdf_error("ext5", "error reading file for embedding");
+ normal_error("pdf backend", "error reading file for embedding");
tprint("<<");
tprint(st.s);
pdf_out_block(pdf, (const char *) data.s, data.l);
@@ -132,11 +130,11 @@ void init_obj_obj(PDF pdf, int k)
obj_obj_objstm_threshold(pdf, k) = OBJSTM_UNSET; /* unset */
}
-@ The \.{\\pdfobj} primitive is used to create a ``raw'' object in the PDF
+@ The \.{\\pdfextension obj} primitive is used to create a ``raw'' object in the PDF
output file. The object contents will be hold in memory and will be written
- out only when the object is referenced by \.{\\pdfrefobj}. When \.{\\pdfobj}
- is used with \.{\\immediate}, the object contents will be written out
- immediately. Objects referenced in the current page are appended into
+ out only when the object is referenced by \.{\\pdfextension refobj}. When
+ \.{\\pdfextension obj} is used with \.{\\immediate}, the object contents will be
+ written out immediately. Objects referenced in the current page are appended into
|pdf_obj_list|.
@c
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
index 1dafb0499b3..306a4b630aa 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfoutline.w
@@ -96,15 +96,22 @@ static int outline_list_count(PDF pdf, pointer p)
@ @c
void scan_pdfoutline(PDF pdf)
{
- halfword p, q, r;
- int i, j, k, l;
+ halfword q, r;
+ int i, k, l;
+ int j = 0;
+ halfword p = NULL;
if (scan_keyword("attr")) {
scan_pdf_ext_toks();
r = def_ref;
} else {
r = 0;
}
- p = scan_action(pdf);
+ if (scan_keyword("useobjnum")) {
+ scan_int();
+ j = cur_val;
+ } else {
+ p = scan_action(pdf);
+ }
if (scan_keyword("count")) {
scan_int();
i = cur_val;
@@ -113,11 +120,13 @@ void scan_pdfoutline(PDF pdf)
}
scan_pdf_ext_toks();
q = def_ref;
- j = pdf_create_obj(pdf, obj_type_others, 0);
- pdf_begin_obj(pdf, j, OBJSTM_ALWAYS);
- write_action(pdf, p);
- pdf_end_obj(pdf);
- delete_action_ref(p);
+ if (j == 0) {
+ j = pdf_create_obj(pdf, obj_type_others, 0);
+ pdf_begin_obj(pdf, j, OBJSTM_ALWAYS);
+ write_action(pdf, p);
+ pdf_end_obj(pdf);
+ delete_action_ref(p);
+ }
k = pdf_create_obj(pdf, obj_type_outline, 0);
set_obj_outline_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_outline_size));
set_obj_outline_action_objnum(pdf, k, j);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
index 31cf4ac3124..4470e53cbfb 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.w
@@ -209,18 +209,19 @@ void pdf_do_page_undivert(int divnum, int curdivnum)
@ write a /Pages object
@c
-#define pdf_pages_attr equiv(pdf_pages_attr_loc)
static void write_pages(PDF pdf, pages_entry * p, int parent)
{
int i;
+ int pages_attributes ;
assert(p != NULL);
pdf_begin_obj(pdf, p->objnum, OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
pdf_dict_add_name(pdf, "Type", "Pages");
if (parent == 0) { /* it's root */
- if (pdf_pages_attr != null) {
- pdf_print_toks(pdf, pdf_pages_attr);
+ pages_attributes = pdf_pages_attr; /* lookup once */
+ if (pages_attributes != null) {
+ pdf_print_toks(pdf, pages_attributes);
pdf_out(pdf, ' ');
}
print_pdf_table_string(pdf, "pagesattributes");
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
index 2dac756ddde..a9d670c1154 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfrule.w
@@ -29,36 +29,45 @@ void pdf_place_rule(PDF pdf, halfword q, scaledpos size)
pdfpos dim;
pdfstructure *p = pdf->pstruct;
scaledpos pos = pdf->posstruct->pos;
- (void) q;
- pdf_goto_pagemode(pdf);
- dim.h.m = i64round(size.h * p->k1);
- dim.h.e = p->pdf.h.e;
- dim.v.m = i64round(size.v * p->k1);
- dim.v.e = p->pdf.v.e;
- pdf_puts(pdf, "q\n");
- if (size.v <= one_bp) {
- pos.v += i32round(0.5 * size.v);
- pdf_set_pos_temp(pdf, pos);
- pdf_puts(pdf, "[]0 d 0 J ");
- print_pdffloat(pdf, dim.v);
- pdf_puts(pdf, " w 0 0 m ");
- print_pdffloat(pdf, dim.h);
- pdf_puts(pdf, " 0 l S\n");
- } else if (size.h <= one_bp) {
- pos.h += i32round(0.5 * size.h);
- pdf_set_pos_temp(pdf, pos);
- pdf_puts(pdf, "[]0 d 0 J ");
- print_pdffloat(pdf, dim.h);
- pdf_puts(pdf, " w 0 0 m 0 ");
- print_pdffloat(pdf, dim.v);
- pdf_puts(pdf, " l S\n");
+ /* (void) q; */
+ if (subtype(q) == box_rule) {
+ pdf_place_form(pdf,q);
+ } else if (subtype(q) == image_rule) {
+ pdf_place_image(pdf,q);
+ } else if (subtype(q) == empty_rule) {
+ /* place nothing, only take space */
} else {
- pdf_set_pos_temp(pdf, pos);
- pdf_puts(pdf, "0 0 ");
- print_pdffloat(pdf, dim.h);
- pdf_out(pdf, ' ');
- print_pdffloat(pdf, dim.v);
- pdf_puts(pdf, " re f\n");
+ /* normal_rule or >= 100 being a leader rule */
+ pdf_goto_pagemode(pdf);
+ dim.h.m = i64round(size.h * p->k1);
+ dim.h.e = p->pdf.h.e;
+ dim.v.m = i64round(size.v * p->k1);
+ dim.v.e = p->pdf.v.e;
+ pdf_puts(pdf, "q\n");
+ if (size.v <= one_bp) {
+ pos.v += i32round(0.5 * size.v);
+ pdf_set_pos_temp(pdf, pos);
+ pdf_puts(pdf, "[]0 d 0 J ");
+ print_pdffloat(pdf, dim.v);
+ pdf_puts(pdf, " w 0 0 m ");
+ print_pdffloat(pdf, dim.h);
+ pdf_puts(pdf, " 0 l S\n");
+ } else if (size.h <= one_bp) {
+ pos.h += i32round(0.5 * size.h);
+ pdf_set_pos_temp(pdf, pos);
+ pdf_puts(pdf, "[]0 d 0 J ");
+ print_pdffloat(pdf, dim.h);
+ pdf_puts(pdf, " w 0 0 m 0 ");
+ print_pdffloat(pdf, dim.v);
+ pdf_puts(pdf, " l S\n");
+ } else {
+ pdf_set_pos_temp(pdf, pos);
+ pdf_puts(pdf, "0 0 ");
+ print_pdffloat(pdf, dim.h);
+ pdf_out(pdf, ' ');
+ print_pdffloat(pdf, dim.v);
+ pdf_puts(pdf, " re f\n");
+ }
+ pdf_puts(pdf, "Q\n");
}
- pdf_puts(pdf, "Q\n");
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
index 204daf2959c..4c88dec6182 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
@@ -53,15 +53,14 @@ static void checkpdfrestore(scaledpos pos)
{
scaledpos diff;
if (pos_stack_used == 0) {
- luatex_warn("%s", "\\pdfrestore: missing \\pdfsave");
+ luatex_warn("%s", "'restore' is missing a 'save'");
return;
}
pos_stack_used--;
diff.h = pos.h - pos_stack[pos_stack_used].pos.h;
diff.v = pos.v - pos_stack[pos_stack_used].pos.v;
if (diff.h != 0 || diff.v != 0) {
- luatex_warn("Misplaced \\pdfrestore by (%dsp, %dsp)", (int) diff.h,
- (int) diff.v);
+ luatex_warn("misplaced 'restore' by (%dsp, %dsp)", (int) diff.h, (int) diff.v);
}
if (global_shipping_mode == SHIPPING_PAGE) {
matrix_stack_used = pos_stack[pos_stack_used].matrix_stack;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
index 70bbb34c10c..ba9317e776d 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
@@ -22,7 +22,7 @@
#include "ptexlib.h"
-@ stack for \.{\\pdfsetmatrix}
+@ stack for \.{\\pdfextension setmatrix}
@c
matrix_entry *matrix_stack = NULL;
@@ -49,7 +49,7 @@ static void matrix_stack_room(void)
}
}
-@ \.{\\pdfsetmatrix{a b c d}}
+@ \.{\\pdfextension setmatrix{a b c d}}
|e| := pos.h
@@ -58,7 +58,7 @@ static void matrix_stack_room(void)
|M_top|: current active matrix at the top of
the matrix stack
- The origin of \.{\\pdfsetmatrix} is the current point.
+ The origin of \.{\\pdfextension setmatrix} is the current point.
The annotation coordinate system is the original
page coordinate system. When pdfTeX calculates
annotation rectangles it does not take into
@@ -84,7 +84,7 @@ static void matrix_stack_room(void)
@c
static void pdfsetmatrix(const char *in, scaledpos pos)
{
- /* Argument of \.{\\pdfsetmatrix} starts with |str_pool[in]| and ends
+ /* Argument of \.{\\pdfextension setmatrix} starts with |str_pool[in]| and ends
before |str_pool[pool_ptr]|. */
matrix_entry x, *y, *z;
@@ -92,7 +92,7 @@ static void pdfsetmatrix(const char *in, scaledpos pos)
if (global_shipping_mode == SHIPPING_PAGE) {
if (sscanf((const char *) in, " %lf %lf %lf %lf ",
&x.a, &x.b, &x.c, &x.d) != 4) {
- luatex_warn("Unrecognized format of \\pdfsetmatrix{%s}", in);
+ luatex_warn("unrecognized format of setmatrix: {%s}", in);
return;
}
/* calculate this transformation matrix */
@@ -128,7 +128,7 @@ static void pdfsetmatrix(const char *in, scaledpos pos)
( e f 1 )
}
-If \.{\\pdfsetmatrix} wasn't used, then return the value unchanged.
+If \.{\\pdfextension setmatrix} wasn't used, then return the value unchanged.
@c
/* Return values for matrix tranform functions */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
index f3166eeccec..b75cb339c13 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfshipout.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ @c
@@ -33,8 +32,6 @@
#define page_right_offset dimen_par(page_right_offset_code)
#define page_top_offset dimen_par(page_top_offset_code)
#define page_width dimen_par(page_width_code)
-#define pdf_h_origin dimen_par(pdf_h_origin_code)
-#define pdf_v_origin dimen_par(pdf_v_origin_code)
#define tracing_output int_par(tracing_output_code)
#define tracing_stats int_par(tracing_stats_code)
#define v_offset dimen_par(v_offset_code)
@@ -58,8 +55,8 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
refpoint.pos.v = 0;
ensure_output_state(pdf, ST_HEADER_WRITTEN);
- fix_o_mode(pdf); /* this is only for complaining if \.{\\pdfoutput} has changed */
- init_backend_functionpointers(pdf->o_mode);
+ fix_o_mode(); /* this is only for complaining if \.{\\outputmode} has changed */
+ init_backend_functionpointers(output_mode_used);
pdf->f_cur = null_font;
@@ -105,10 +102,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
/* Ship box |p| out */
if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction)
- pdf_warning("\\shipout",
- "\\pagedir != \\bodydir; "
- "\\box\\outputbox may be placed wrongly on the page.", true,
- true);
+ normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page", true, true);
/* Update the values of |max_h| and |max_v|; but if the page is too large, |goto done| */
/* Sometimes the user will generate a huge page because other error messages
are being ignored. Such pages are not output to the \.{dvi} file, since they
@@ -178,14 +172,14 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
/* Think in upright page/paper coordinates (page origin = lower left edge).
First preset |refpoint.pos| to the DVI origin (near upper left page edge). */
- switch (pdf->o_mode) {
+ switch (output_mode_used) {
case OMODE_DVI:
+ /* hh: how can we end up here? */
refpoint.pos.h = one_true_inch;
refpoint.pos.v = pdf->page_size.v - one_true_inch;
dvi = refpoint.pos;
break;
case OMODE_PDF:
- case OMODE_LUA:
refpoint.pos.h = pdf_h_origin;
refpoint.pos.v = pdf->page_size.v - pdf_v_origin;
break;
@@ -220,7 +214,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
cur.v = height(p);
synch_pos_with_cur(pdf->posstruct, &refpoint, cur);
} else { /* shipping a /Form */
- assert(pdf->o_mode == OMODE_PDF);
+ assert(output_mode_used == OMODE_PDF);
pdf->posstruct->dir = box_dir(p);
switch (pdf->posstruct->dir) {
case dir_TLT:
@@ -262,31 +256,27 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
shipbox_refpos = pdf->posstruct->pos; /* for \.{\\gleaders} */
- switch (pdf->o_mode) {
- case OMODE_DVI:
- assert(shipping_mode == SHIPPING_PAGE);
- dvi_begin_page(pdf);
- break;
- case OMODE_PDF:
- pdf_begin_page(pdf);
- break;
- case OMODE_LUA:
- assert(shipping_mode == SHIPPING_PAGE);
- lua_begin_page(pdf);
- break;
- default:
- assert(0);
+ switch (output_mode_used) {
+ case OMODE_DVI:
+ assert(shipping_mode == SHIPPING_PAGE);
+ dvi_begin_page(pdf);
+ break;
+ case OMODE_PDF:
+ pdf_begin_page(pdf);
+ break;
+ default:
+ normal_error("pdf backend", "unknown output mode");
}
switch (type(p)) {
- case vlist_node:
- vlist_out(pdf, p);
- break;
- case hlist_node:
- hlist_out(pdf, p);
- break;
- default:
- assert(0);
+ case vlist_node:
+ vlist_out(pdf, p);
+ break;
+ case hlist_node:
+ hlist_out(pdf, p);
+ break;
+ default:
+ normal_error("pdf backend", "no vlist or hlist in (xform) shipout");
}
if (shipping_mode == SHIPPING_PAGE)
@@ -295,18 +285,15 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
/* Finish shipping */
- switch (pdf->o_mode) {
- case OMODE_DVI:
- dvi_end_page(pdf);
- break;
- case OMODE_PDF:
- pdf_end_page(pdf);
- break;
- case OMODE_LUA:
- lua_end_page(pdf);
- break;
- default:
- assert(0);
+ switch (output_mode_used) {
+ case OMODE_DVI:
+ dvi_end_page(pdf);
+ break;
+ case OMODE_PDF:
+ pdf_end_page(pdf);
+ break;
+ default:
+ normal_error("pdf backend", "unknown output mode");
}
DONE:
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index a06915abd70..8dd3286e426 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -119,24 +119,41 @@ extern void undump_pdftex_data(PDF pdf);
# define set_height(A, B) height(A) = (B)
# define set_depth(A, B) depth(A) = (B)
-/* interface definitions for eqtb locations */
-# define pdf_compress_level int_par(pdf_compress_level_code)
-# define pdf_decimal_digits int_par(pdf_decimal_digits_code)
-# define pdf_draftmode int_par(pdf_draftmode_code)
-# define pdf_gamma int_par(pdf_gamma_code)
-# define pdf_gen_tounicode int_par(pdf_gen_tounicode_code)
-# define pdf_image_apply_gamma int_par(pdf_image_apply_gamma_code)
-# define pdf_image_gamma int_par(pdf_image_gamma_code)
-# define pdf_image_hicolor int_par(pdf_image_hicolor_code)
-# define pdf_inclusion_copy_font int_par(pdf_inclusion_copy_font_code)
-# define pdf_inclusion_errorlevel int_par(pdf_inclusion_errorlevel_code)
-# define pdf_minor_version int_par(pdf_minor_version_code)
-# define pdf_move_chars int_par(pdf_move_chars_code)
-# define pdf_objcompresslevel int_par(pdf_objcompresslevel_code)
-# define pdf_output int_par(pdf_output_code)
-# define pdf_pk_mode equiv(pdf_pk_mode_loc)
-# define pdf_pk_resolution int_par(pdf_pk_resolution_code)
-# define pdf_replace_font int_par(pdf_replace_font_code)
-# define pdf_unique_resname int_par(pdf_unique_resname_code)
+/* pdf backend definitions */
+
+# define pdf_compress_level get_tex_extension_count_register("pdf_compresslevel", 9)
+# define pdf_decimal_digits get_tex_extension_count_register("pdf_decimaldigits", 3)
+# define pdf_image_resolution get_tex_extension_count_register("pdf_imageresolution", 72)
+# define pdf_pk_resolution get_tex_extension_count_register("pdf_pkresolution", 72)
+# define pdf_unique_resname get_tex_extension_count_register("pdf_uniqueresname", 0)
+# define pdf_minor_version get_tex_extension_count_register("pdf_minorversion", 4)
+# define pdf_pagebox get_tex_extension_count_register("pdf_pagebox", 0)
+# define pdf_inclusion_errorlevel get_tex_extension_count_register("pdf_inclusionerrorlevel", 0)
+# define pdf_gamma get_tex_extension_count_register("pdf_gamma", 1000)
+# define pdf_image_apply_gamma get_tex_extension_count_register("pdf_imageapplygamma", 0)
+# define pdf_image_gamma get_tex_extension_count_register("pdf_imagegamma", 2200)
+# define pdf_image_hicolor get_tex_extension_count_register("pdf_imagehicolor", 1)
+# define pdf_image_addfilename get_tex_extension_count_register("pdf_imageaddfilename", 1)
+# define pdf_objcompresslevel get_tex_extension_count_register("pdf_objcompresslevel", 0)
+# define pdf_inclusion_copy_font get_tex_extension_count_register("pdf_inclusioncopyfonts", 0)
+# define pdf_gen_tounicode get_tex_extension_count_register("pdf_gentounicode", 0)
+# define pdf_replace_font get_tex_extension_count_register("pdf_replacefont", 0)
+
+# define pdf_h_origin get_tex_extension_dimen_register("pdf_horigin", one_inch)
+# define pdf_v_origin get_tex_extension_dimen_register("pdf_vorigin", one_inch)
+# define pdf_thread_margin get_tex_extension_dimen_register("pdf_threadmargin", 0)
+# define pdf_dest_margin get_tex_extension_dimen_register("pdf_destmargin", 0)
+# define pdf_link_margin get_tex_extension_dimen_register("pdf_linkmargin", 0)
+
+# define pdf_page_attr get_tex_extension_toks_register("pdf_pageattr")
+# define pdf_page_resources get_tex_extension_toks_register("pdf_pageresources")
+# define pdf_pages_attr get_tex_extension_toks_register("pdf_pagesattr")
+# define pdf_xform_attr get_tex_extension_toks_register("pdf_xformattr")
+# define pdf_xform_resources get_tex_extension_toks_register("pdf_xformresources")
+# define pdf_pk_mode get_tex_extension_toks_register("pdf_pkmode")
+
+# define set_pdf_minor_version(i) set_tex_extension_count_register("pdf_minorversion",i)
+# define set_pdf_compress_level(i) set_tex_extension_count_register("pdf_compresslevel",i)
+# define set_pdf_objcompresslevel(i) set_tex_extension_count_register("pdf_objcompresslevel",i)
#endif /* PDFTABLES_H */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
index dac6741d316..72f0474e922 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.w
@@ -29,7 +29,7 @@ const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1] =
"bead", "beads", "objstm", "others"
};
-@ AVL sort oentry into |avl_table[]|
+@ AVL sort entry into |avl_table[]|
@c
static int compare_info(const void *pa, const void *pb, void *param)
{
@@ -113,7 +113,7 @@ static int avl_find_str_obj(PDF pdf, int t, char *s)
return p->objptr;
}
-@ Create an object with type |t| and identifier |i|
+@ Create an object with type |t| and identifier |i|
@c
int pdf_create_obj(PDF pdf, int t, int i)
@@ -204,12 +204,12 @@ int pdf_get_obj(PDF pdf, int t, int i, boolean byname)
return r;
}
-@ object checking
+@ object checking
@c
void check_obj_exists(PDF pdf, int objnum)
{
if (objnum < 0 || objnum > pdf->obj_ptr)
- pdf_error("ext1", "cannot find referenced object");
+ normal_error("pdf backend", "cannot find referenced object");
}
void check_obj_type(PDF pdf, int t, int objnum)
@@ -224,7 +224,7 @@ void check_obj_type(PDF pdf, int t, int objnum)
s = (char *) xtalloc(128, char);
snprintf(s, 127, "referenced object has wrong type %s; should be %s",
pdf_obj_typenames[u], pdf_obj_typenames[t]);
- pdf_error("ext1", s);
+ normal_error("pdf backend", s);
}
}
@@ -366,8 +366,8 @@ void dump_pdftex_data(PDF pdf)
x = pdf->head_tab[obj_type_ximage];
dump_int(x);
dump_int(pdf_last_obj);
- dump_int(pdf_last_xform);
- dump_int(pdf_last_ximage);
+ dump_int(last_saved_box_index);
+ dump_int(last_saved_image_index);
}
@ And restoring the pdftex data structures from the format. The
@@ -434,6 +434,6 @@ void undump_pdftex_data(PDF pdf)
undump_int(x);
pdf->head_tab[obj_type_ximage] = x;
undump_int(pdf_last_obj);
- undump_int(pdf_last_xform);
- undump_int(pdf_last_ximage);
+ undump_int(last_saved_box_index);
+ undump_int(last_saved_image_index);
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
index 92021645875..85f7007aa67 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfthread.w
@@ -23,17 +23,16 @@
#include "ptexlib.h"
@ @c
-#define pdf_thread_margin dimen_par(pdf_thread_margin_code)
#define page_width dimen_par(page_width_code)
#define page_height dimen_par(page_height_code)
-@ Threads are handled in similar way as link annotations
+@ Threads are handled in similar way as link annotations
@c
void append_bead(PDF pdf, halfword p)
{
int a, b, c, t;
if (global_shipping_mode == SHIPPING_FORM)
- pdf_error("ext4", "threads cannot be inside an XForm");
+ normal_error("pdf backend", "threads cannot be inside an XForm");
t = pdf_get_obj(pdf, obj_type_thread, pdf_thread_id(p),
pdf_thread_named_id(p));
b = pdf_create_obj(pdf, obj_type_others, 0);
@@ -64,7 +63,7 @@ void do_thread(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
{
scaled_whd alt_rule;
if ((type(p) == hlist_node) && (subtype(p) == pdf_start_thread_node))
- pdf_error("ext4", "\\pdfstartthread ended up in hlist");
+ normal_error("pdf backend", "'startthread' ended up in hlist");
if (doing_leaders)
return;
if (subtype(p) == pdf_start_thread_node) {
@@ -115,10 +114,9 @@ void end_thread(PDF pdf, halfword p)
{
scaledpos pos = pdf->posstruct->pos;
if (type(p) == hlist_node)
- pdf_error("ext4", "\\pdfendthread ended up in hlist");
+ normal_error("pdf backend", "'endthread' ended up in hlist");
if (pdf->thread_level != cur_s)
- pdf_error("ext4",
- "\\pdfendthread ended up in different nesting level than \\pdfstartthread");
+ normal_error("pdf backend", "'endthread' ended up in different nesting level than 'startthread'");
if (is_running(pdf->thread.dp) && (pdf->last_thread != null)) {
switch (pdf->posstruct->dir) {
case dir_TLT:
@@ -140,7 +138,7 @@ void end_thread(PDF pdf, halfword p)
pdf->last_thread = null;
}
-@ The following function are needed for outputing article thread.
+@ The following function are needed for outputing article thread.
@c
void thread_title(PDF pdf, int t)
{
@@ -156,7 +154,7 @@ void thread_title(PDF pdf, int t)
void pdf_fix_thread(PDF pdf, int t)
{
halfword a;
- pdf_warning("thread", "destination", false, false);
+ normal_warning("pdf backend", "thread destination", false, false);
if (obj_info(pdf, t) < 0) {
tprint("name{");
print(-obj_info(pdf, t));
@@ -246,9 +244,9 @@ void scan_thread_id(void)
if (scan_keyword("num")) {
scan_int();
if (cur_val <= 0)
- pdf_error("ext1", "num identifier must be positive");
+ normal_error("pdf backend", "num identifier must be positive");
if (cur_val > max_halfword)
- pdf_error("ext1", "number too big");
+ normal_error("pdf backend", "number too big");
set_pdf_thread_id(cur_list.tail_field, cur_val);
set_pdf_thread_named_id(cur_list.tail_field, 0);
} else if (scan_keyword("name")) {
@@ -256,7 +254,7 @@ void scan_thread_id(void)
set_pdf_thread_id(cur_list.tail_field, def_ref);
set_pdf_thread_named_id(cur_list.tail_field, 1);
} else {
- pdf_error("ext1", "identifier type missing");
+ normal_error("pdf backend", "identifier type missing");
}
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index 065aba0aa57..b25d74d1cc9 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
#ifndef PDFTYPES_H
# define PDFTYPES_H
@@ -52,7 +51,6 @@ typedef enum {
typedef enum {
PDFOUT_BUF,
OBJSTM_BUF,
- LUASTM_BUF
} buffer_e;
/* This stucture holds everything that is needed for the actual pdf generation.
@@ -102,10 +100,6 @@ typedef struct {
typedef enum { PMODE_NONE, PMODE_PAGE, PMODE_TEXT, PMODE_CHARARRAY, PMODE_CHAR
} pos_mode;
-typedef enum { OMODE_NONE, OMODE_DVI, OMODE_PDF, OMODE_LUA } output_mode;
-
-# define MAX_OMODE 3 /* largest index in enum output_mode */
-
typedef enum { ST_INITIAL, ST_OMODE_FIX, ST_FILE_OPEN, ST_HEADER_WRITTEN,
ST_FILE_CLOSED
} output_state;
@@ -222,12 +216,10 @@ typedef struct os_struct_ {
os_obj_data *obj; /* array of object stream objects */
strbuf_s *buf[3];
buffer_e curbuf; /* select into which buffer to output */
- luaL_Buffer b; /* Lua buffer connected to luastm_buf */
unsigned int cur_objstm; /* number of current object stream object */
unsigned int idx; /* index of object within object stream [1...PDF_OS_MAX_OBJS - 1] */
unsigned int ostm_ctr; /* statistics: counter for object stream objects */
unsigned int o_ctr; /* statistics: counter for objects within object streams */
- int trigger_luastm;
} os_struct;
/**********************************************************************/
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
index 3c5a1913317..9c62f71c0a2 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
@@ -21,9 +21,9 @@
#ifndef PDFXFORM_H
# define PDFXFORM_H
-/* data structure for \.{\\pdfxform} and \.{\\pdfrefxform} */
+/* data structure for box resources */
-# define pdfmem_xform_size 6 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
+# define pdfmem_xform_size 8 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
# define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B
@@ -36,6 +36,8 @@
attributes */
# define obj_xform_resources(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 5] /* additional xform
Resources */
+# define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6]
+# define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7]
# define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B
@@ -44,6 +46,8 @@
# define set_obj_xform_box(pdf,A,B) obj_xform_box(pdf,A)=B
# define set_obj_xform_attr(pdf,A,B) obj_xform_attr(pdf,A)=B
# define set_obj_xform_resources(pdf,A,B) obj_xform_resources(pdf,A)=B
+# define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B
+# define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B
extern int pdf_cur_form; /* the form being output */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
index 1f789960845..46a0910f6f7 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -18,11 +18,7 @@
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-
-
#include "ptexlib.h"
-
-@ @c
#include "pdf/pdfpage.h"
@ @c
@@ -36,7 +32,8 @@ void pdf_place_form(PDF pdf, halfword p)
scaled x, y;
pdffloat cm[6];
pdfstructure *q = pdf->pstruct;
- int r = 6, objnum = pdf_xform_objnum(p);
+ int r = 6;
+ int objnum = rule_index(p);
nat.wd = obj_xform_width(pdf, objnum);
nat.ht = obj_xform_height(pdf, objnum);
nat.dp = obj_xform_depth(pdf, objnum);
@@ -65,6 +62,8 @@ void pdf_place_form(PDF pdf, halfword p)
addto_page_resources(pdf, obj_type_xform, objnum);
}
+/* we will store token lists as strings too */
+
@ @c
void scan_pdfxform(PDF pdf)
{
@@ -79,22 +78,24 @@ void scan_pdfxform(PDF pdf)
} else {
set_obj_xform_attr(pdf, k, null);
}
+ set_obj_xform_attr_str(pdf, k, null);
if (scan_keyword("resources")) {
scan_pdf_ext_toks();
set_obj_xform_resources(pdf, k, def_ref);
} else {
set_obj_xform_resources(pdf, k, null);
}
+ set_obj_xform_resources_str(pdf, k, null);
scan_int();
p = box(cur_val);
if (p == null)
- pdf_error("ext1", "\\pdfxform cannot be used with a void box");
+ normal_error("pdf backend", "xforms cannot be used with a void box");
set_obj_xform_box(pdf, k, p); /* save pointer to the box */
set_obj_xform_width(pdf, k, width(p));
set_obj_xform_height(pdf, k, height(p));
set_obj_xform_depth(pdf, k, depth(p));
box(cur_val) = null;
- pdf_last_xform = k;
+ last_saved_box_index = k;
}
@ @c
@@ -102,17 +103,15 @@ void scan_pdfxform(PDF pdf)
void scan_pdfrefxform(PDF pdf)
{
- int transform = 0;
scaled_whd alt_rule, dim, nat;
alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */
scan_int();
check_obj_type(pdf, obj_type_xform, cur_val);
- new_whatsit(pdf_refxform_node);
+ tail_append(new_rule(box_rule));
nat.wd = obj_xform_width(pdf, cur_val);
nat.ht = obj_xform_height(pdf, cur_val);
nat.dp = obj_xform_depth(pdf, cur_val);
- if (alt_rule.wd != null_flag || alt_rule.ht != null_flag
- || alt_rule.dp != null_flag) {
+ if (alt_rule.wd != null_flag || alt_rule.ht != null_flag || alt_rule.dp != null_flag) {
dim = tex_scale(nat, alt_rule);
} else {
dim = nat;
@@ -120,6 +119,5 @@ void scan_pdfrefxform(PDF pdf)
width(tail) = dim.wd;
height(tail) = dim.ht;
depth(tail) = dim.dp;
- pdf_xform_transform(tail) = transform; /* not implemented yet */
- pdf_xform_objnum(tail) = cur_val;
+ rule_index(tail) = cur_val;
}
diff --git a/Build/source/texk/web2c/luatexdir/ptexlib.h b/Build/source/texk/web2c/luatexdir/ptexlib.h
index 5855931d854..3d05b8661c5 100644
--- a/Build/source/texk/web2c/luatexdir/ptexlib.h
+++ b/Build/source/texk/web2c/luatexdir/ptexlib.h
@@ -149,25 +149,25 @@ size_t T##_limit
# define str_prefix(s1, s2) (strncmp((s1), (s2), strlen(s2)) == 0)
-/* that was ptexmac.h */
-
# include "tex/mainbody.h"
# include "tex/expand.h"
# include "tex/conditional.h"
-# include "pdf/pdftypes.h"
-/* synctex */
+# include "pdf/pdftypes.h" /* the backend data structure, shared between dvi and pdf */
+
# include "synctex.h"
# include "utils/avlstuff.h"
# include "utils/managed-sa.h"
+
# include "image/writeimg.h"
+
# include "dvi/dvigen.h"
+
+# include "pdf/pdftables.h"
# include "pdf/pdfpagetree.h"
# include "pdf/pdfgen.h"
# include "pdf/pdfpage.h"
-# include "pdf/pdftables.h"
-
# include "pdf/pdfaction.h"
# include "pdf/pdfannot.h"
# include "pdf/pdfcolorstack.h"
@@ -194,8 +194,10 @@ size_t T##_limit
# include "font/luatexfont.h"
# include "font/mapfile.h"
+
# include "utils/utils.h"
# include "utils/unistring.h"
+
# include "image/writejbig2.h"
# include "image/pdftoepdf.h"
@@ -244,15 +246,20 @@ extern halfword new_ligkern(halfword head, halfword tail);
extern halfword handle_ligaturing(halfword head, halfword tail);
extern halfword handle_kerning(halfword head, halfword tail);
-halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type,
- int extrainfo, int d);
-void lua_node_filter(int filterid, int extrainfo, halfword head_node,
- halfword * tail_node);
-halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type,
- scaled maxd, int extrainfo, int d);
-void lua_node_filter_s(int filterid, int extrainfo);
-int lua_linebreak_callback(int is_broken, halfword head_node,
- halfword * new_head);
+halfword lua_hpack_filter(
+ halfword head_node, scaled size, int pack_type, int extrainfo, int d);
+void lua_node_filter(
+ int filterid, int extrainfo, halfword head_node,
+ halfword * tail_node);
+halfword lua_vpack_filter(
+ halfword head_node, scaled size, int pack_type, scaled maxd, int extrainfo, int d);
+void lua_node_filter_s(
+ int filterid, int extrainfo);
+int lua_linebreak_callback(
+ int is_broken, halfword head_node, halfword * new_head);
+int lua_appendtovlist_callback(
+ halfword box, int location, halfword prev_depth, boolean is_mirrored,
+ halfword * result, int * next_depth, boolean * prev_set);
void lua_pdf_literal(PDF pdf, int i);
void copy_pdf_literal(pointer r, pointer p);
@@ -361,9 +368,7 @@ extern string normalize_quotes(const_string name, const_string mesg);
extern string dump_name;
extern const_string c_job_name;
-extern halfword *check_isnode(lua_State * L, int ud);
-extern void lua_nodelib_push_fast(lua_State * L, halfword n);
-
+extern halfword *check_isnode(lua_State * L, int i);
extern void lua_nodelib_push_fast(lua_State * L, halfword n);
extern halfword list_node_mem_usage(void);
@@ -379,6 +384,4 @@ extern extinfo *copy_variants(extinfo * o);
extern int program_name_set; /* in lkpselib.c */
-
-
#endif /* PTEXLIB_H */
diff --git a/Build/source/texk/web2c/luatexdir/tex/align.w b/Build/source/texk/web2c/luatexdir/tex/align.w
index 5b8a1a4417e..75c3f932252 100644
--- a/Build/source/texk/web2c/luatexdir/tex/align.w
+++ b/Build/source/texk/web2c/luatexdir/tex/align.w
@@ -45,9 +45,8 @@ void init_col(void);
@ It's sort of a miracle whenever \.{\\halign} and \.{\\valign} work, because
they cut across so many of the control structures of \TeX.
-Therefore the
-present page is probably not the best place for a beginner to start reading
-this program; it is better to master everything else first.
+Therefore the present page is probably not the best place for a beginner to
+start reading this program; it is better to master everything else first.
Let us focus our thoughts on an example of what the input might be, in order
to get some idea about how the alignment miracle happens. The example doesn't
@@ -172,8 +171,6 @@ called upon to step in and do some little action, but most of the time
these routines just lurk in the background. It's something like
post-hypnotic suggestion.
-
-
@ We have mentioned that alignrecords contain no |height| or |depth| fields.
Their |glue_sign| and |glue_order| are pre-empted as well, since it
is necessary to store information about what to do when a template ends.
@@ -185,7 +182,6 @@ This information is called the |extra_info| field.
#define span_ptr(A) vinfo((A)+1) /* column spanning list */
#define extra_info(A) vinfo((A)+list_offset) /* info to remember during template */
-
@ Alignments can occur within alignments, so a small stack is used to access
the alignrecord information. At each level we have a |preamble| pointer,
indicating the beginning of the preamble list; a |cur_align| pointer,
@@ -219,6 +215,13 @@ pointer cur_pre_head = null, cur_pre_tail = null; /* pre-adjustment list p
@ Alignment stack maintenance is handled by a pair of trivial routines
called |push_alignment| and |pop_alignment|.
+(HH:) It makes not much sense to add support for an \.{attr} keyword to
+\.{\\halign} and \.{\\valign} because then we need to decide if we tag
+rows or cells or both or come up with \.{cellattr} and \.{rowattr} and
+such. But then it even makes sense to have explicit commands (in addition
+to the seperator) to tags individual cells. Too muss hassle for now and the
+advantages are not that large.
+
@c
static void push_alignment(void)
{
@@ -773,7 +776,7 @@ void fin_row(void)
pop_nest();
if (cur_pre_head != cur_pre_tail)
append_list(cur_pre_head, cur_pre_tail);
- append_to_vlist(p);
+ append_to_vlist(p,lua_key_index(alignment));
if (cur_head != cur_tail)
append_list(cur_head, cur_tail);
} else {
@@ -817,7 +820,7 @@ void fin_align(void)
else
o = 0;
/* Go through the preamble list, determining the column widths and
- * changing the alignrecords to dummy unset boxes
+ * changing the alignrecords to dummy unset boxes
*/
/* It's time now to dismantle the preamble list and to compute the column
@@ -952,11 +955,11 @@ value is changed to zero and so is the next tabskip.
if (cur_list.mode_field == -vmode) {
type(q) = hlist_node;
- subtype(q) = HLIST_SUBTYPE_ALIGNROW;
+ subtype(q) = align_row_list;
width(q) = width(p);
} else {
type(q) = vlist_node;
- subtype(q) = HLIST_SUBTYPE_ALIGNROW;
+ subtype(q) = align_row_list;
height(q) = height(p);
}
glue_order(q) = glue_order(p);
@@ -1004,7 +1007,7 @@ value is changed to zero and so is the next tabskip.
vlink(u) = rr;
u = vlink(u);
t = t + width(s);
- subtype(u) = HLIST_SUBTYPE_ALIGNCELL;
+ subtype(u) = align_cell_list;
if (cur_list.mode_field == -vmode) {
width(u) = width(s);
} else {
@@ -1046,7 +1049,7 @@ value is changed to zero and so is the next tabskip.
}
width(r) = w;
type(r) = hlist_node;
- subtype(r) = HLIST_SUBTYPE_ALIGNCELL;
+ subtype(r) = align_cell_list;
} else {
/* Make the unset node |r| into a |vlist_node| of height |w|,
@@ -1078,7 +1081,7 @@ value is changed to zero and so is the next tabskip.
}
height(r) = w;
type(r) = vlist_node;
- subtype(r) = HLIST_SUBTYPE_ALIGNCELL;
+ subtype(r) = align_cell_list;
}
/* subtype(r) = 0; */
@@ -1107,7 +1110,7 @@ value is changed to zero and so is the next tabskip.
vlink(q) = null;
q = hpack(q, 0, additional, -1);
shift_amount(q) = o;
- subtype(q) = HLIST_SUBTYPE_ALIGNCELL;
+ subtype(q) = align_cell_list;
vlink(q) = r;
vlink(s) = q;
}
@@ -1123,7 +1126,7 @@ value is changed to zero and so is the next tabskip.
and ends at |cur_list.tail_field|. This list will be merged with the one that encloses
it. (In case the enclosing mode is |mmode|, for displayed formulas,
we will need to insert glue before and after the display; that part of the
- program will be deferred until we're more familiar with such operations.)
+ program will be deferred until we're more familiar with such operations.)
*/
pd = cur_list.prev_depth_field;
p = vlink(cur_list.head_field);
@@ -1138,15 +1141,12 @@ value is changed to zero and so is the next tabskip.
cur_list.tail_field = q;
if (cur_list.mode_field == vmode) {
if (!output_active)
- // lua_node_filter_s(buildpage_filter_callback, "alignment");
- lua_node_filter_s(buildpage_filter_callback,lua_key_index(alignment));
+ lua_node_filter_s(buildpage_filter_callback,lua_key_index(alignment));
build_page();
}
}
}
-
-
@ The token list |omit_template| just referred to is a constant token
list that contains the special control sequence \.{\\endtemplate} only.
diff --git a/Build/source/texk/web2c/luatexdir/tex/buildpage.w b/Build/source/texk/web2c/luatexdir/tex/buildpage.w
index 54a57d15d0d..a1807b91993 100644
--- a/Build/source/texk/web2c/luatexdir/tex/buildpage.w
+++ b/Build/source/texk/web2c/luatexdir/tex/buildpage.w
@@ -402,16 +402,9 @@ void build_page(void)
}
break;
+ case boundary_node:
case whatsit_node:
- /* Prepare to move whatsit |p| to the current page,
- then |goto contribute| */
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node)) {
- page_total = page_total + page_depth + height(p);
- page_depth = depth(p);
- }
goto CONTRIBUTE;
-
break;
case glue_node:
if (page_contents < box_there)
@@ -1050,8 +1043,7 @@ void resume_after_output(void)
flush_node_list(page_disc);
page_disc = null;
pop_nest();
- //lua_node_filter_s(buildpage_filter_callback, "after_output");
lua_node_filter_s(buildpage_filter_callback,lua_key_index(after_output));
- build_page();
+ build_page();
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h
index c8200ab93f8..b14c59f783f 100644
--- a/Build/source/texk/web2c/luatexdir/tex/commands.h
+++ b/Build/source/texk/web2c/luatexdir/tex/commands.h
@@ -1,5 +1,5 @@
/* commands.h
-
+
Copyright 2008 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -61,162 +61,164 @@ The ``expandable'' commands come first.
*/
typedef enum {
- relax_cmd = 0, /* do nothing ( \.{\\relax} ) */
-# define escape_cmd relax_cmd /* escape delimiter (called \.\\ in {\sl The \TeX book\/}) */
- left_brace_cmd, /* beginning of a group ( \.\{ ) */
- right_brace_cmd, /* ending of a group ( \.\} ) */
- math_shift_cmd, /* mathematics shift character ( \.\$ ) */
- tab_mark_cmd, /* alignment delimiter ( \.\&, \.{\\span} ) */
- car_ret_cmd, /* end of line ( |carriage_return|, \.{\\cr}, \.{\\crcr} ) */
-# define out_param_cmd car_ret_cmd /* output a macro parameter */
- mac_param_cmd, /* macro parameter symbol ( \.\# ) */
- sup_mark_cmd, /* superscript ( \.{\char'136} ) */
- sub_mark_cmd, /* subscript ( \.{\char'137} ) */
- endv_cmd, /* end of \<v_j> list in alignment template */
-# define ignore_cmd endv_cmd /* characters to ignore ( \.{\^\^@@} ) */
- spacer_cmd, /* characters equivalent to blank space ( \.{\ } ) */
- letter_cmd, /* characters regarded as letters ( \.{A..Z}, \.{a..z} ) */
- other_char_cmd, /* none of the special character types */
- par_end_cmd, /* end of paragraph ( \.{\\par} ) */
-# define active_char_cmd par_end_cmd /* characters that invoke macros ( \.{\char`\~} ) */
-# define match_cmd par_end_cmd /* match a macro parameter */
- stop_cmd, /* end of job ( \.{\\end}, \.{\\dump} ) */
-# define comment_cmd stop_cmd /* characters that introduce comments ( \.\% ) */
-# define end_match_cmd stop_cmd /* end of parameters to macro */
- delim_num_cmd, /* specify delimiter numerically ( \.{\\delimiter} ) */
-# define invalid_char_cmd delim_num_cmd /* characters that shouldn't appear ( \.{\^\^?} ) */
-# define max_char_code_cmd delim_num_cmd
- /* largest catcode for individual characters */
- char_num_cmd, /* character specified numerically ( \.{\\char} ) */
- math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */
- mark_cmd, /* mark definition ( \.{\\mark} ) */
- xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */
- make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */
- hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */
- vmove_cmd, /* vertical motion ( \.{\\raise}, \.{\\lower} ) */
- un_hbox_cmd, /* unglue a box ( \.{\\unhbox}, \.{\\unhcopy} ) */
- un_vbox_cmd, /* unglue a box ( \.{\\unvbox}, \.{\\unvcopy} or
- \.{\\pagediscards}, \.{\\splitdiscards} ) */
- remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */
- hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */
- vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */
- mskip_cmd, /* math glue ( \.{\\mskip} ) */
- kern_cmd, /* fixed space ( \.{\\kern}) */
- mkern_cmd, /* math kern ( \.{\\mkern} ) */
- leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */
- halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */
- valign_cmd, /* vertical table alignment ( \.{\\valign} ) */
- no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */
- vrule_cmd, /* vertical rule ( \.{\\vrule} ) */
- hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */
- insert_cmd, /* vlist inserted in box ( \.{\\insert} ) */
- vadjust_cmd, /* vlist inserted in enclosing paragraph ( \.{\\vadjust} ) */
- ignore_spaces_cmd, /* gobble |spacer| tokens ( \.{\\ignorespaces} ) */
- after_assignment_cmd, /* save till assignment is done ( \.{\\afterassignment} ) */
- after_group_cmd, /* save till group is done ( \.{\\aftergroup} ) */
- break_penalty_cmd, /* additional badness ( \.{\\penalty} ) */
- start_par_cmd, /* begin paragraph ( \.{\\indent}, \.{\\noindent} ) */
- ital_corr_cmd, /* italic correction ( \.{\\/} ) */
- accent_cmd, /* attach accent in text ( \.{\\accent} ) */
- math_accent_cmd, /* attach accent in math ( \.{\\mathaccent} ) */
- discretionary_cmd, /* discretionary texts ( \.{\\-}, \.{\\discretionary} ) */
- eq_no_cmd, /* equation number ( \.{\\eqno}, \.{\\leqno} ) */
- left_right_cmd, /* variable delimiter ( \.{\\left}, \.{\\right} or \.{\\middle} ) */
- math_comp_cmd, /* component of formula ( \.{\\mathbin}, etc.~) */
- limit_switch_cmd, /* diddle limit conventions ( \.{\\displaylimits}, etc.~) */
- above_cmd, /* generalized fraction ( \.{\\above}, \.{\\atop}, etc.~) */
- math_style_cmd, /* style specification ( \.{\\displaystyle}, etc.~) */
- math_choice_cmd, /* choice specification ( \.{\\mathchoice} ) */
- non_script_cmd, /* conditional math glue ( \.{\\nonscript} ) */
- vcenter_cmd, /* vertically center a vbox ( \.{\\vcenter} ) */
- case_shift_cmd, /* force specific case ( \.{\\lowercase}, \.{\\uppercase}~) */
- message_cmd, /* send to user ( \.{\\message}, \.{\\errmessage} ) */
- extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
- in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */
- begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */
- end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */
- omit_cmd, /* omit alignment template ( \.{\\omit} ) */
- ex_space_cmd, /* explicit space ( \.{\\\ } ) */
- no_boundary_cmd, /* suppress boundary ligatures ( \.{\\noboundary} ) */
- radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
- super_sub_script_cmd, /* explicit super- or subscript */
- math_shift_cs_cmd, /* start- and endmath */
- end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
- char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
- assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
- char_given_cmd, /* character code defined by \.{\\chardef} */
-# define min_internal_cmd char_given_cmd
- /* the smallest code that can follow \.{\\the} */
- math_given_cmd, /* math code defined by \.{\\mathchardef} */
- xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
- last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
+ relax_cmd = 0, /* do nothing ( \.{\\relax} ) */
+# define escape_cmd relax_cmd /* escape delimiter (called \.\\ in {\sl The \TeX book\/}) */
+ left_brace_cmd, /* beginning of a group ( \.\{ ) */
+ right_brace_cmd, /* ending of a group ( \.\} ) */
+ math_shift_cmd, /* mathematics shift character ( \.\$ ) */
+ tab_mark_cmd, /* alignment delimiter ( \.\&, \.{\\span} ) */
+ car_ret_cmd, /* end of line ( |carriage_return|, \.{\\cr}, \.{\\crcr} ) */
+# define out_param_cmd car_ret_cmd /* output a macro parameter */
+ mac_param_cmd, /* macro parameter symbol ( \.\# ) */
+ sup_mark_cmd, /* superscript ( \.{\char'136} ) */
+ sub_mark_cmd, /* subscript ( \.{\char'137} ) */
+ endv_cmd, /* end of \<v_j> list in alignment template */
+# define ignore_cmd endv_cmd /* characters to ignore ( \.{\^\^@@} ) */
+ spacer_cmd, /* characters equivalent to blank space ( \.{\ } ) */
+ letter_cmd, /* characters regarded as letters ( \.{A..Z}, \.{a..z} ) */
+ other_char_cmd, /* none of the special character types */
+ par_end_cmd, /* end of paragraph ( \.{\\par} ) */
+# define active_char_cmd par_end_cmd /* characters that invoke macros ( \.{\char`\~} ) */
+# define match_cmd par_end_cmd /* match a macro parameter */
+ stop_cmd, /* end of job ( \.{\\end}, \.{\\dump} ) */
+# define comment_cmd stop_cmd /* characters that introduce comments ( \.\% ) */
+# define end_match_cmd stop_cmd /* end of parameters to macro */
+ delim_num_cmd, /* specify delimiter numerically ( \.{\\delimiter} ) */
+# define invalid_char_cmd delim_num_cmd /* characters that shouldn't appear ( \.{\^\^?} ) */
+# define max_char_code_cmd delim_num_cmd /* largest catcode for individual characters */
+ char_num_cmd, /* character specified numerically ( \.{\\char} ) */
+ math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */
+ mark_cmd, /* mark definition ( \.{\\mark} ) */
+ xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */
+ make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */
+ hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */
+ vmove_cmd, /* vertical motion ( \.{\\raise}, \.{\\lower} ) */
+ un_hbox_cmd, /* unglue a box ( \.{\\unhbox}, \.{\\unhcopy} ) */
+ un_vbox_cmd, /* unglue a box ( \.{\\unvbox}, \.{\\unvcopy} or \.{\\pagediscards}, \.{\\splitdiscards} ) */
+ remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */
+ hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */
+ vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */
+ mskip_cmd, /* math glue ( \.{\\mskip} ) */
+ kern_cmd, /* fixed space ( \.{\\kern}) */
+ mkern_cmd, /* math kern ( \.{\\mkern} ) */
+ leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */
+ halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */
+ valign_cmd, /* vertical table alignment ( \.{\\valign} ) */
+ no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */
+ vrule_cmd, /* vertical rule ( \.{\\vrule} ) */
+ hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */
+ no_vrule_cmd, /* no rule, just reserve space ( \.{\\novrule} )*/
+ no_hrule_cmd, /* no rule, just reserve space ( \.{\\nohrule} )*/
+ insert_cmd, /* vlist inserted in box ( \.{\\insert} ) */
+ vadjust_cmd, /* vlist inserted in enclosing paragraph ( \.{\\vadjust} ) */
+ ignore_spaces_cmd, /* gobble |spacer| tokens ( \.{\\ignorespaces} ) */
+ after_assignment_cmd, /* save till assignment is done ( \.{\\afterassignment} ) */
+ after_group_cmd, /* save till group is done ( \.{\\aftergroup} ) */
+ break_penalty_cmd, /* additional badness ( \.{\\penalty} ) */
+ start_par_cmd, /* begin paragraph ( \.{\\indent}, \.{\\noindent} ) */
+ ital_corr_cmd, /* italic correction ( \.{\\/} ) */
+ accent_cmd, /* attach accent in text ( \.{\\accent} ) */
+ math_accent_cmd, /* attach accent in math ( \.{\\mathaccent} ) */
+ discretionary_cmd, /* discretionary texts ( \.{\\-}, \.{\\discretionary} ) */
+ eq_no_cmd, /* equation number ( \.{\\eqno}, \.{\\leqno} ) */
+ left_right_cmd, /* variable delimiter ( \.{\\left}, \.{\\right} or \.{\\middle} ) */
+ math_comp_cmd, /* component of formula ( \.{\\mathbin}, etc.~) */
+ limit_switch_cmd, /* diddle limit conventions ( \.{\\displaylimits}, etc.~) */
+ above_cmd, /* generalized fraction ( \.{\\above}, \.{\\atop}, etc.~) */
+ math_style_cmd, /* style specification ( \.{\\displaystyle}, etc.~) */
+ math_choice_cmd, /* choice specification ( \.{\\mathchoice} ) */
+ non_script_cmd, /* conditional math glue ( \.{\\nonscript} ) */
+ vcenter_cmd, /* vertically center a vbox ( \.{\\vcenter} ) */
+ case_shift_cmd, /* force specific case ( \.{\\lowercase}, \.{\\uppercase}~) */
+ message_cmd, /* send to user ( \.{\\message}, \.{\\errmessage} ) */
+ normal_cmd, /* general extensions to \TeX\ that don't fit into a category */
+ extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
+ option_cmd,
+ in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */
+ begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */
+ end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */
+ omit_cmd, /* omit alignment template ( \.{\\omit} ) */
+ ex_space_cmd, /* explicit space ( \.{\\\ } ) */
+ boundary_cmd, /* insert boundry node with value ( \.{\\boundary} ) */
+ no_boundary_cmd, /* suppress boundary ligatures ( \.{\\noboundary} ) */
+ radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
+ super_sub_script_cmd, /* explicit super- or subscript */
+ math_shift_cs_cmd, /* start- and endmath */
+ end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
+ char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
+ assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
+ char_given_cmd, /* character code defined by \.{\\chardef} */
+# define min_internal_cmd char_given_cmd /* the smallest code that can follow \.{\\the} */
+ math_given_cmd, /* math code defined by \.{\\mathchardef} */
+ xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
+ last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
# define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */
- toks_register_cmd, /* token list register ( \.{\\toks} ) */
- assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
- assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
- assign_attr_cmd, /* user-defined attributes */
- assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
- assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
- assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
- assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
- assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
- set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
- set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
- set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
- set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
- set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
- set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
- set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
- def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
- def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
- extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
- extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
- def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
- set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
- set_font_cmd, /* set current font ( font identifiers ) */
- def_font_cmd, /* define a font file ( \.{\\font} ) */
- register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
- assign_box_dir_cmd, /* (\.{\\boxdir}) */
- assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
-# define max_internal_cmd assign_dir_cmd
- /* the largest code that can follow \.{\\the} */
- advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */
- multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */
- divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */
- prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */
- let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */
- shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */
- read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */
- def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */
- set_box_cmd, /* set a box ( \.{\\setbox} ) */
- hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */
- set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */
- letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */
- pdf_copy_font_cmd, /* create a new font instance ( \.{\\pdfcopyfont} ) */
- undefined_cs_cmd, /* initial state of most |eq_type| fields */
- expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
- no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
- input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or
- \.{\\scantokens} or \.{\\scantextokens} ) */
- if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
- fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
- cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
- convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
- the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
- top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
- call_cmd, /* non-long, non-outer control sequence */
- long_call_cmd, /* long, non-outer control sequence */
- outer_call_cmd, /* non-long, outer control sequence */
- long_outer_call_cmd, /* long, outer control sequence */
- end_template_cmd, /* end of an alignment template */
- dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
- glue_ref_cmd, /* the equivalent points to a glue specification */
- shape_ref_cmd, /* the equivalent points to a parshape specification */
- box_ref_cmd, /* the equivalent points to a box node, or is |null| */
- data_cmd, /* the equivalent is simply a halfword number */
+ toks_register_cmd, /* token list register ( \.{\\toks} ) */
+ assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
+ assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
+ assign_attr_cmd, /* user-defined attributes */
+ assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
+ assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
+ assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
+ assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
+ assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
+ set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
+ set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
+ set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
+ set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
+ set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
+ set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
+ set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
+ def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
+ def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
+ extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
+ extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
+ def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
+ set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
+ set_font_cmd, /* set current font ( font identifiers ) */
+ def_font_cmd, /* define a font file ( \.{\\font} ) */
+ register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
+ assign_box_dir_cmd, /* (\.{\\boxdir}) */
+ assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
+# define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */
+ advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */
+ multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */
+ divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */
+ prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */
+ let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */
+ shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */
+ read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */
+ def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */
+ set_box_cmd, /* set a box ( \.{\\setbox} ) */
+ hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */
+ set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */
+ letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */
+ expand_font_cmd, /* expand glyphs ( \.{\\expandglyphsinfont} ) */
+ copy_font_cmd, /* create a new font instance ( \.{\\copyfont} ) */
+ set_font_id_cmd,
+ undefined_cs_cmd, /* initial state of most |eq_type| fields */
+ expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
+ no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
+ input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or \.{\\scantokens} or \.{\\scantextokens} ) */
+ if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
+ fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
+ cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
+ convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
+ the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
+ top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
+ call_cmd, /* non-long, non-outer control sequence */
+ long_call_cmd, /* long, non-outer control sequence */
+ outer_call_cmd, /* non-long, outer control sequence */
+ long_outer_call_cmd, /* long, outer control sequence */
+ end_template_cmd, /* end of an alignment template */
+ dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
+ glue_ref_cmd, /* the equivalent points to a glue specification */
+ shape_ref_cmd, /* the equivalent points to a parshape specification */
+ box_ref_cmd, /* the equivalent points to a box node, or is |null| */
+ data_cmd, /* the equivalent is simply a halfword number */
} tex_command_code;
-# define max_command_cmd pdf_copy_font_cmd /* the largest command code seen at |big_switch| */
+# define max_command_cmd set_font_id_cmd /* the largest command code seen at |big_switch| */
# define last_cmd data_cmd
# define max_non_prefixed_command last_item_cmd
@@ -224,7 +226,8 @@ typedef enum {
above_code = 0,
over_code = 1,
atop_code = 2,
- delimited_code = 3
+ skewed_code = 3,
+ delimited_code = 4,
} fraction_codes;
typedef enum {
@@ -236,21 +239,12 @@ typedef enum {
etex_code, /* command code for \.{\\eTeXVersion} */
format_name_code, /* command code for \.{\\AlephVersion} */
luatex_banner_code, /* command code for \.{\\luatexbanner}: */
- pdf_font_name_code, /* command code for \.{\\pdffontname} */
- pdf_font_objnum_code, /* command code for \.{\\pdffontobjnum} */
- pdf_font_size_code, /* command code for \.{\\pdffontsize} */
- pdf_page_ref_code, /* command code for \.{\\pdfpageref} */
- pdf_xform_name_code, /* command code for \.{\\pdfxformname} */
left_margin_kern_code, /* command code for \.{\\leftmarginkern} */
right_margin_kern_code, /* command code for \.{\\rightmarginkern} */
- pdf_creation_date_code, /* command code for \.{\\pdfcreationdate} */
uniform_deviate_code, /* command code for \.{\\uniformdeviate} */
normal_deviate_code, /* command code for \.{\\normaldeviate} */
- pdf_insert_ht_code, /* command code for \.{\\pdfinsertht} */
- pdf_ximage_bbox_code, /* command code for \.{\\pdfximagebbox} */
lua_code, /* command code for \.{\\directlua} */
lua_escape_string_code, /* command code for \.{\\luaescapestring} */
- pdf_colorstack_init_code, /* command code for \.{\\pdfcolorstackinit} */
luatex_revision_code, /* command code for \.{\\luatexrevision} */
luatex_date_code, /* command code for \.{\\luatexdate} */
math_style_code, /* command code for \.{\\mathstyle} */
@@ -261,61 +255,90 @@ typedef enum {
font_id_code, /* command code for \.{\\fontid} */
uchar_code, /* command code for \.{\\Uchar} */
lua_function_code, /* command code for \.{\\luafunction} */
+ insert_ht_code, /* command code for \.{\\insertht} */
+ math_char_class_code,
+ math_char_fam_code,
+ math_char_slot_code,
+ /* backend */
+ dvi_feedback_code,
+ pdf_feedback_code,
+ dvi_variable_code,
+ pdf_variable_code,
} convert_codes;
typedef enum {
- lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
- lastattr_code, /* not used */
- lastkern_code, /* code for \.{\\lastkern} */
- lastskip_code, /* code for \.{\\lastskip} */
- last_node_type_code, /* code for \.{\\lastnodetype} */
- input_line_no_code, /* code for \.{\\inputlineno} */
- badness_code, /* code for \.{\\badness} */
- pdf_last_obj_code, /* code for \.{\\pdflastobj} */
- pdf_last_xform_code, /* code for \.{\\pdflastxform} */
- pdf_last_ximage_code, /* code for \.{\\pdflastximage} */
- pdf_last_ximage_pages_code, /* code for \.{\\pdflastximagepages} */
- pdf_last_annot_code, /* code for \.{\\pdflastannot} */
- last_x_pos_code, /* code for \.{\\lastxpos} */
- last_y_pos_code, /* code for \.{\\lastypos} */
- pdf_retval_code, /* global multi-purpose return value */
- pdf_last_ximage_colordepth_code, /* code for \.{\\pdflastximagecolordepth} */
- random_seed_code, /* code for \.{\\pdfrandomseed} */
- pdf_last_link_code, /* code for \.{\\pdflastlink} */
- luatex_version_code, /* code for \.{\\luatexversion} */
- eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
- eTeX_version_code, /* code for \.{\\eTeXversion} */
-# define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
- current_group_level_code, /* code for \.{\\currentgrouplevel} */
- current_group_type_code, /* code for \.{\\currentgrouptype} */
- current_if_level_code, /* code for \.{\\currentiflevel} */
- current_if_type_code, /* code for \.{\\currentiftype} */
- current_if_branch_code, /* code for \.{\\currentifbranch} */
- glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
- glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
- font_char_wd_code, /* code for \.{\\fontcharwd} */
-# define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
- font_char_ht_code, /* code for \.{\\fontcharht} */
- font_char_dp_code, /* code for \.{\\fontchardp} */
- font_char_ic_code, /* code for \.{\\fontcharic} */
- par_shape_length_code, /* code for \.{\\parshapelength} */
- par_shape_indent_code, /* code for \.{\\parshapeindent} */
- par_shape_dimen_code, /* code for \.{\\parshapedimen} */
- glue_stretch_code, /* code for \.{\\gluestretch} */
- glue_shrink_code, /* code for \.{\\glueshrink} */
- mu_to_glue_code, /* code for \.{\\mutoglue} */
-# define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
- glue_to_mu_code, /* code for \.{\\gluetomu} */
-# define eTeX_mu glue_to_mu_code
- /* first of \eTeX\ codes for muglue */
- numexpr_code, /* code for \.{\\numexpr} */
-# define eTeX_expr numexpr_code /* first of \eTeX\ codes for expressions */
- attrexpr_code, /* not used */
- dimexpr_code, /* code for \.{\\dimexpr} */
- glueexpr_code, /* code for \.{\\glueexpr} */
- muexpr_code, /* code for \.{\\muexpr} */
+ pdf_font_name_code = 32, /* command code for \.{\\pdffeedback fontname} */
+ pdf_font_objnum_code, /* command code for \.{\\pdffeedback fontobjnum} */
+ pdf_font_size_code, /* command code for \.{\\pdffeedback fontsize} */
+ pdf_page_ref_code, /* command code for \.{\\pdffeedback pageref} */
+ pdf_xform_name_code, /* command code for \.{\\pdffeedback xformname} */
+ pdf_creation_date_code, /* command code for \.{\\pdffeedback creationdate} */
+ pdf_colorstack_init_code, /* command code for \.{\\pdffeedback colorstackinit} */
+ pdf_last_obj_code,
+ pdf_last_annot_code,
+ pdf_retval_code,
+ pdf_last_link_code,
+ pdf_version_code,
+ pdf_revision_code,
+} convert_codes_pdf;
+
+typedef enum {
+ lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
+ lastattr_code, /* not used */
+ lastkern_code, /* code for \.{\\lastkern} */
+ lastskip_code, /* code for \.{\\lastskip} */
+ last_node_type_code, /* code for \.{\\lastnodetype} */
+ input_line_no_code, /* code for \.{\\inputlineno} */
+ badness_code, /* code for \.{\\badness} */
+ last_saved_box_resource_index_code, /* code for \.{\\lastsavedboxresourceindex} */
+ last_saved_image_resource_index_code, /* code for \.{\\lastsavedimageresourceindex} */
+ last_saved_image_resource_pages_code, /* code for \.{\\lastsavedimageresourcepages} */
+ last_x_pos_code, /* code for \.{\\lastxpos} */
+ last_y_pos_code, /* code for \.{\\lastypos} */
+ random_seed_code, /* code for \.{\\randomseed} */
+ luatex_version_code, /* code for \.{\\luatexversion} */
+ eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
+ eTeX_version_code, /* code for \.{\\eTeXversion} */
+# define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
+ current_group_level_code, /* code for \.{\\currentgrouplevel} */
+ current_group_type_code, /* code for \.{\\currentgrouptype} */
+ current_if_level_code, /* code for \.{\\currentiflevel} */
+ current_if_type_code, /* code for \.{\\currentiftype} */
+ current_if_branch_code, /* code for \.{\\currentifbranch} */
+ glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
+ glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
+ font_char_wd_code, /* code for \.{\\fontcharwd} */
+# define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
+ font_char_ht_code, /* code for \.{\\fontcharht} */
+ font_char_dp_code, /* code for \.{\\fontchardp} */
+ font_char_ic_code, /* code for \.{\\fontcharic} */
+ par_shape_length_code, /* code for \.{\\parshapelength} */
+ par_shape_indent_code, /* code for \.{\\parshapeindent} */
+ par_shape_dimen_code, /* code for \.{\\parshapedimen} */
+ glue_stretch_code, /* code for \.{\\gluestretch} */
+ glue_shrink_code, /* code for \.{\\glueshrink} */
+ mu_to_glue_code, /* code for \.{\\mutoglue} */
+# define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
+ glue_to_mu_code, /* code for \.{\\gluetomu} */
+# define eTeX_mu glue_to_mu_code /* first of \eTeX\ codes for muglue */
+ numexpr_code, /* code for \.{\\numexpr} */
+# define eTeX_expr numexpr_code /* first of \eTeX\ codes for expressions */
+ attrexpr_code, /* not used */
+ dimexpr_code, /* code for \.{\\dimexpr} */
+ glueexpr_code, /* code for \.{\\glueexpr} */
+ muexpr_code, /* code for \.{\\muexpr} */
} last_item_codes;
+
+typedef enum {
+ save_cat_code_table_code=0,
+ init_cat_code_table_code,
+ set_random_seed_code,
+ save_pos_code,
+ late_lua_code,
+ expand_font_code,
+} normal_codes;
+
# define explicit 1
# define acc_kern 2
# define lp_code_base 2
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w
index 2b0f1d83bc5..de4db31ee60 100644
--- a/Build/source/texk/web2c/luatexdir/tex/commands.w
+++ b/Build/source/texk/web2c/luatexdir/tex/commands.w
@@ -1,4 +1,4 @@
-% commands.w
+ % commands.w
%
% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
%
@@ -32,284 +32,128 @@ now, so that we don't have to list all those parameter names anywhere else.
void initialize_commands(void)
{
- primitive_tex("lineskip", assign_glue_cmd, glue_base + line_skip_code,
- glue_base);
- primitive_tex("baselineskip", assign_glue_cmd,
- glue_base + baseline_skip_code, glue_base);
- primitive_tex("parskip", assign_glue_cmd, glue_base + par_skip_code,
- glue_base);
- primitive_tex("abovedisplayskip", assign_glue_cmd,
- glue_base + above_display_skip_code, glue_base);
- primitive_tex("belowdisplayskip", assign_glue_cmd,
- glue_base + below_display_skip_code, glue_base);
- primitive_tex("abovedisplayshortskip", assign_glue_cmd,
- glue_base + above_display_short_skip_code, glue_base);
- primitive_tex("belowdisplayshortskip", assign_glue_cmd,
- glue_base + below_display_short_skip_code, glue_base);
- primitive_tex("leftskip", assign_glue_cmd, glue_base + left_skip_code,
- glue_base);
- primitive_tex("rightskip", assign_glue_cmd, glue_base + right_skip_code,
- glue_base);
- primitive_tex("topskip", assign_glue_cmd, glue_base + top_skip_code,
- glue_base);
- primitive_tex("splittopskip", assign_glue_cmd,
- glue_base + split_top_skip_code, glue_base);
- primitive_tex("tabskip", assign_glue_cmd, glue_base + tab_skip_code,
- glue_base);
- primitive_tex("spaceskip", assign_glue_cmd, glue_base + space_skip_code,
- glue_base);
- primitive_tex("xspaceskip", assign_glue_cmd, glue_base + xspace_skip_code,
- glue_base);
- primitive_tex("parfillskip", assign_glue_cmd,
- glue_base + par_fill_skip_code, glue_base);
- primitive_tex("thinmuskip", assign_mu_glue_cmd,
- glue_base + thin_mu_skip_code, glue_base + thin_mu_skip_code);
- 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_tex("lineskip", assign_glue_cmd, glue_base + line_skip_code, glue_base);
+ primitive_tex("baselineskip", assign_glue_cmd, glue_base + baseline_skip_code, glue_base);
+ primitive_tex("parskip", assign_glue_cmd, glue_base + par_skip_code, glue_base);
+ primitive_tex("abovedisplayskip", assign_glue_cmd, glue_base + above_display_skip_code, glue_base);
+ primitive_tex("belowdisplayskip", assign_glue_cmd, glue_base + below_display_skip_code, glue_base);
+ primitive_tex("abovedisplayshortskip", assign_glue_cmd, glue_base + above_display_short_skip_code, glue_base);
+ primitive_tex("belowdisplayshortskip", assign_glue_cmd, glue_base + below_display_short_skip_code, glue_base);
+ primitive_tex("leftskip", assign_glue_cmd, glue_base + left_skip_code, glue_base);
+ primitive_tex("rightskip", assign_glue_cmd, glue_base + right_skip_code, glue_base);
+ primitive_tex("topskip", assign_glue_cmd, glue_base + top_skip_code, glue_base);
+ primitive_tex("splittopskip", assign_glue_cmd, glue_base + split_top_skip_code, glue_base);
+ primitive_tex("tabskip", assign_glue_cmd, glue_base + tab_skip_code, glue_base);
+ primitive_tex("spaceskip", assign_glue_cmd, glue_base + space_skip_code, glue_base);
+ primitive_tex("xspaceskip", assign_glue_cmd, glue_base + xspace_skip_code, glue_base);
+ primitive_tex("parfillskip", assign_glue_cmd, glue_base + par_fill_skip_code, glue_base);
+ primitive_tex("thinmuskip", assign_mu_glue_cmd, glue_base + thin_mu_skip_code, glue_base + thin_mu_skip_code);
+ 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_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);
- primitive_tex("everydisplay", assign_toks_cmd, every_display_loc,
- local_base);
+ primitive_tex("everydisplay", assign_toks_cmd, every_display_loc, local_base);
primitive_tex("everyhbox", assign_toks_cmd, every_hbox_loc, local_base);
primitive_tex("everyvbox", assign_toks_cmd, every_vbox_loc, local_base);
primitive_tex("everyjob", assign_toks_cmd, every_job_loc, local_base);
primitive_tex("everycr", assign_toks_cmd, every_cr_loc, local_base);
primitive_tex("errhelp", assign_toks_cmd, err_help_loc, local_base);
- primitive_pdftex("pdfpagesattr", assign_toks_cmd, pdf_pages_attr_loc,
- local_base);
- primitive_pdftex("pdfpageattr", assign_toks_cmd, pdf_page_attr_loc,
- local_base);
- primitive_pdftex("pdfpageresources", assign_toks_cmd,
- pdf_page_resources_loc, local_base);
- primitive_pdftex("pdfxformattr", assign_toks_cmd, pdf_xform_attr_loc,
- local_base);
- primitive_pdftex("pdfxformresources", assign_toks_cmd,
- pdf_xform_resources_loc, local_base);
- primitive_pdftex("pdfpkmode", assign_toks_cmd, pdf_pk_mode_loc, local_base);
/* The integer parameter names must be entered into the hash table */
- primitive_tex("pretolerance", assign_int_cmd, int_base + pretolerance_code,
- int_base);
- primitive_tex("tolerance", assign_int_cmd, int_base + tolerance_code,
- int_base);
- primitive_tex("linepenalty", assign_int_cmd, int_base + line_penalty_code,
- int_base);
- primitive_tex("hyphenpenalty", assign_int_cmd,
- int_base + hyphen_penalty_code, int_base);
- primitive_tex("exhyphenpenalty", assign_int_cmd,
- int_base + ex_hyphen_penalty_code, int_base);
- primitive_tex("clubpenalty", assign_int_cmd, int_base + club_penalty_code,
- int_base);
- primitive_tex("widowpenalty", assign_int_cmd, int_base + widow_penalty_code,
- int_base);
- primitive_tex("displaywidowpenalty", assign_int_cmd,
- int_base + display_widow_penalty_code, int_base);
- primitive_tex("brokenpenalty", assign_int_cmd,
- int_base + broken_penalty_code, int_base);
- primitive_tex("binoppenalty", assign_int_cmd,
- int_base + bin_op_penalty_code, int_base);
- primitive_tex("relpenalty", assign_int_cmd, int_base + rel_penalty_code,
- int_base);
- primitive_tex("predisplaypenalty", assign_int_cmd,
- int_base + pre_display_penalty_code, int_base);
- primitive_tex("postdisplaypenalty", assign_int_cmd,
- int_base + post_display_penalty_code, int_base);
- primitive_tex("interlinepenalty", assign_int_cmd,
- int_base + inter_line_penalty_code, int_base);
- primitive_tex("doublehyphendemerits", assign_int_cmd,
- int_base + double_hyphen_demerits_code, int_base);
- primitive_tex("finalhyphendemerits", assign_int_cmd,
- int_base + final_hyphen_demerits_code, int_base);
- primitive_tex("adjdemerits", assign_int_cmd, int_base + adj_demerits_code,
- int_base);
+
+ primitive_tex("pretolerance", assign_int_cmd, int_base + pretolerance_code, int_base);
+ primitive_tex("tolerance", assign_int_cmd, int_base + tolerance_code, int_base);
+ primitive_tex("linepenalty", assign_int_cmd, int_base + line_penalty_code, int_base);
+ primitive_tex("hyphenpenalty", assign_int_cmd, int_base + hyphen_penalty_code, int_base);
+ primitive_tex("exhyphenpenalty", assign_int_cmd, int_base + ex_hyphen_penalty_code, int_base);
+ primitive_tex("clubpenalty", assign_int_cmd, int_base + club_penalty_code, int_base);
+ primitive_tex("widowpenalty", assign_int_cmd, int_base + widow_penalty_code, int_base);
+ primitive_tex("displaywidowpenalty", assign_int_cmd, int_base + display_widow_penalty_code, int_base);
+ primitive_tex("brokenpenalty", assign_int_cmd, int_base + broken_penalty_code, int_base);
+ primitive_tex("binoppenalty", assign_int_cmd, int_base + bin_op_penalty_code, int_base);
+ primitive_tex("relpenalty", assign_int_cmd, int_base + rel_penalty_code, int_base);
+ primitive_tex("predisplaypenalty", assign_int_cmd, int_base + pre_display_penalty_code, int_base);
+ primitive_tex("postdisplaypenalty", assign_int_cmd, int_base + post_display_penalty_code, int_base);
+ primitive_tex("interlinepenalty", assign_int_cmd, int_base + inter_line_penalty_code, int_base);
+ primitive_tex("doublehyphendemerits", assign_int_cmd, int_base + double_hyphen_demerits_code, int_base);
+ primitive_tex("finalhyphendemerits", assign_int_cmd, int_base + final_hyphen_demerits_code, int_base);
+ primitive_tex("adjdemerits", assign_int_cmd, int_base + adj_demerits_code, int_base);
primitive_tex("mag", assign_int_cmd, int_base + mag_code, int_base);
- primitive_tex("delimiterfactor", assign_int_cmd,
- int_base + delimiter_factor_code, int_base);
- primitive_tex("looseness", assign_int_cmd, int_base + looseness_code,
- int_base);
+ primitive_tex("delimiterfactor", assign_int_cmd, int_base + delimiter_factor_code, int_base);
+ primitive_tex("looseness", assign_int_cmd, int_base + looseness_code, int_base);
primitive_tex("time", assign_int_cmd, int_base + time_code, int_base);
primitive_tex("day", assign_int_cmd, int_base + day_code, int_base);
primitive_tex("month", assign_int_cmd, int_base + month_code, int_base);
primitive_tex("year", assign_int_cmd, int_base + year_code, int_base);
- primitive_tex("showboxbreadth", assign_int_cmd,
- int_base + show_box_breadth_code, int_base);
- primitive_tex("showboxdepth", assign_int_cmd,
- int_base + show_box_depth_code, int_base);
- primitive_tex("hbadness", assign_int_cmd, int_base + hbadness_code,
- int_base);
- primitive_tex("vbadness", assign_int_cmd, int_base + vbadness_code,
- int_base);
+ primitive_tex("showboxbreadth", assign_int_cmd, int_base + show_box_breadth_code, int_base);
+ primitive_tex("showboxdepth", assign_int_cmd, int_base + show_box_depth_code, int_base);
+ primitive_tex("hbadness", assign_int_cmd, int_base + hbadness_code, int_base);
+ primitive_tex("vbadness", assign_int_cmd, int_base + vbadness_code, int_base);
primitive_tex("pausing", assign_int_cmd, int_base + pausing_code, int_base);
- primitive_tex("tracingonline", assign_int_cmd,
- int_base + tracing_online_code, int_base);
- primitive_tex("tracingmacros", assign_int_cmd,
- int_base + tracing_macros_code, int_base);
- primitive_tex("tracingstats", assign_int_cmd, int_base + tracing_stats_code,
- int_base);
- primitive_tex("tracingparagraphs", assign_int_cmd,
- int_base + tracing_paragraphs_code, int_base);
- primitive_tex("tracingpages", assign_int_cmd, int_base + tracing_pages_code,
- int_base);
- primitive_tex("tracingoutput", assign_int_cmd,
- int_base + tracing_output_code, int_base);
- primitive_tex("tracinglostchars", assign_int_cmd,
- int_base + tracing_lost_chars_code, int_base);
- primitive_tex("tracingcommands", assign_int_cmd,
- int_base + tracing_commands_code, int_base);
- primitive_tex("tracingrestores", assign_int_cmd,
- int_base + tracing_restores_code, int_base);
+ primitive_tex("tracingonline", assign_int_cmd, int_base + tracing_online_code, int_base);
+ primitive_tex("tracingmacros", assign_int_cmd, int_base + tracing_macros_code, int_base);
+ primitive_tex("tracingstats", assign_int_cmd, int_base + tracing_stats_code, int_base);
+ primitive_tex("tracingparagraphs", assign_int_cmd, int_base + tracing_paragraphs_code, int_base);
+ primitive_tex("tracingpages", assign_int_cmd, int_base + tracing_pages_code, int_base);
+ primitive_tex("tracingoutput", assign_int_cmd, int_base + tracing_output_code, int_base);
+ primitive_tex("tracinglostchars", assign_int_cmd, int_base + tracing_lost_chars_code, int_base);
+ primitive_tex("tracingcommands", assign_int_cmd, int_base + tracing_commands_code, int_base);
+ primitive_tex("tracingrestores", assign_int_cmd, int_base + tracing_restores_code, int_base);
primitive_tex("uchyph", assign_int_cmd, int_base + uc_hyph_code, int_base);
- primitive_tex("outputpenalty", assign_int_cmd,
- int_base + output_penalty_code, int_base);
- primitive_tex("maxdeadcycles", assign_int_cmd,
- int_base + max_dead_cycles_code, int_base);
- primitive_tex("hangafter", assign_int_cmd, int_base + hang_after_code,
- int_base);
- primitive_tex("floatingpenalty", assign_int_cmd,
- int_base + floating_penalty_code, int_base);
- primitive_tex("globaldefs", assign_int_cmd, int_base + global_defs_code,
- int_base);
+ primitive_tex("outputpenalty", assign_int_cmd, int_base + output_penalty_code, int_base);
+ primitive_tex("maxdeadcycles", assign_int_cmd, int_base + max_dead_cycles_code, int_base);
+ primitive_tex("hangafter", assign_int_cmd, int_base + hang_after_code, int_base);
+ primitive_tex("floatingpenalty", assign_int_cmd, int_base + floating_penalty_code, int_base);
+ primitive_tex("globaldefs", assign_int_cmd, int_base + global_defs_code, int_base);
primitive_tex("fam", assign_int_cmd, int_base + cur_fam_code, int_base);
- primitive_tex("escapechar", assign_int_cmd, int_base + escape_char_code,
- int_base);
- primitive_tex("defaulthyphenchar", assign_int_cmd,
- int_base + default_hyphen_char_code, int_base);
- primitive_tex("defaultskewchar", assign_int_cmd,
- int_base + default_skew_char_code, int_base);
- primitive_tex("endlinechar", assign_int_cmd, int_base + end_line_char_code,
- int_base);
- primitive_tex("newlinechar", assign_int_cmd, int_base + new_line_char_code,
- int_base);
- primitive_tex("language", assign_int_cmd, int_base + language_code,
- int_base);
- primitive_tex("setlanguage", assign_int_cmd, int_base + cur_lang_code,
- int_base);
- primitive_tex("exhyphenchar", assign_int_cmd,
- int_base + ex_hyphen_char_code, int_base);
- primitive_tex("lefthyphenmin", assign_int_cmd,
- int_base + left_hyphen_min_code, int_base);
- primitive_tex("righthyphenmin", assign_int_cmd,
- int_base + right_hyphen_min_code, int_base);
- primitive_tex("holdinginserts", assign_int_cmd,
- int_base + holding_inserts_code, int_base);
- primitive_tex("errorcontextlines", assign_int_cmd,
- int_base + error_context_lines_code, int_base);
- primitive_luatex("luastartup", assign_int_cmd,
- int_base + luastartup_id_code, int_base);
- primitive_luatex("nokerns", assign_int_cmd, int_base + disable_kern_code,
- int_base);
- primitive_luatex("noligs", assign_int_cmd, int_base + disable_lig_code,
- int_base);
- primitive_luatex("catcodetable", assign_int_cmd,
- int_base + cat_code_table_code, int_base);
- primitive_luatex("outputbox", assign_int_cmd, int_base + output_box_code,
- int_base);
- primitive_pdftex("pdfoutput", assign_int_cmd, int_base + pdf_output_code,
- int_base);
- primitive_pdftex("pdfcompresslevel", assign_int_cmd,
- int_base + pdf_compress_level_code, int_base);
- primitive_pdftex("pdfobjcompresslevel", assign_int_cmd,
- int_base + pdf_objcompresslevel_code, int_base);
- primitive_pdftex("pdfdecimaldigits", assign_int_cmd,
- int_base + pdf_decimal_digits_code, int_base);
- primitive_pdftex("pdfimageresolution", assign_int_cmd,
- int_base + pdf_image_resolution_code, int_base);
- primitive_pdftex("pdfpkresolution", assign_int_cmd,
- int_base + pdf_pk_resolution_code, int_base);
- primitive_pdftex("pdfuniqueresname", assign_int_cmd,
- int_base + pdf_unique_resname_code, int_base);
- primitive_pdftex("pdfoptionpdfminorversion", assign_int_cmd,
- int_base + pdf_minor_version_code, int_base);
- primitive_pdftex("pdfminorversion", assign_int_cmd,
- int_base + pdf_minor_version_code, int_base);
- primitive_pdftex("pdfpagebox", assign_int_cmd, int_base + pdf_pagebox_code,
- int_base);
- primitive_pdftex("pdfinclusionerrorlevel", assign_int_cmd,
- int_base + pdf_inclusion_errorlevel_code, int_base);
- primitive_pdftex("pdfgamma", assign_int_cmd, int_base + pdf_gamma_code,
- int_base);
- primitive_pdftex("pdfimagegamma", assign_int_cmd,
- int_base + pdf_image_gamma_code, int_base);
- primitive_pdftex("pdfimagehicolor", assign_int_cmd,
- int_base + pdf_image_hicolor_code, int_base);
- primitive_pdftex("pdfimageapplygamma", assign_int_cmd,
- int_base + pdf_image_apply_gamma_code, int_base);
- primitive_luatex("adjustspacing", assign_int_cmd,
- int_base + adjust_spacing_code, int_base);
- primitive_luatex("protrudechars", assign_int_cmd,
- int_base + protrude_chars_code, int_base);
- primitive_pdftex("pdftracingfonts", assign_int_cmd,
- int_base + pdf_tracing_fonts_code, int_base);
- primitive_pdftex("pdfgentounicode", assign_int_cmd,
- int_base + pdf_gen_tounicode_code, int_base);
- primitive_pdftex("pdfdraftmode", assign_int_cmd,
- int_base + pdf_draftmode_code, int_base);
- primitive_pdftex("pdfinclusioncopyfonts", assign_int_cmd,
- int_base + pdf_inclusion_copy_font_code, int_base);
- primitive_pdftex("pdfreplacefont", assign_int_cmd,
- int_base + pdf_replace_font_code, int_base);
- primitive_tex("parindent", assign_dimen_cmd, dimen_base + par_indent_code,
- dimen_base);
- primitive_tex("mathsurround", assign_dimen_cmd,
- dimen_base + math_surround_code, dimen_base);
- primitive_tex("lineskiplimit", assign_dimen_cmd,
- dimen_base + line_skip_limit_code, dimen_base);
- primitive_tex("hsize", assign_dimen_cmd, dimen_base + hsize_code,
- dimen_base);
- primitive_tex("vsize", assign_dimen_cmd, dimen_base + vsize_code,
- dimen_base);
- primitive_tex("maxdepth", assign_dimen_cmd, dimen_base + max_depth_code,
- dimen_base);
- primitive_tex("splitmaxdepth", assign_dimen_cmd,
- dimen_base + split_max_depth_code, dimen_base);
- primitive_tex("boxmaxdepth", assign_dimen_cmd,
- dimen_base + box_max_depth_code, dimen_base);
- primitive_tex("hfuzz", assign_dimen_cmd, dimen_base + hfuzz_code,
- dimen_base);
- primitive_tex("vfuzz", assign_dimen_cmd, dimen_base + vfuzz_code,
- dimen_base);
- primitive_tex("delimitershortfall", assign_dimen_cmd,
- dimen_base + delimiter_shortfall_code, dimen_base);
- primitive_tex("nulldelimiterspace", assign_dimen_cmd,
- dimen_base + null_delimiter_space_code, dimen_base);
- primitive_tex("scriptspace", assign_dimen_cmd,
- dimen_base + script_space_code, dimen_base);
- primitive_tex("predisplaysize", assign_dimen_cmd,
- dimen_base + pre_display_size_code, dimen_base);
- primitive_tex("displaywidth", assign_dimen_cmd,
- dimen_base + display_width_code, dimen_base);
- primitive_tex("displayindent", assign_dimen_cmd,
- dimen_base + display_indent_code, dimen_base);
- primitive_tex("overfullrule", assign_dimen_cmd,
- dimen_base + overfull_rule_code, dimen_base);
- primitive_tex("hangindent", assign_dimen_cmd, dimen_base + hang_indent_code,
- dimen_base);
- primitive_tex("hoffset", assign_dimen_cmd, dimen_base + h_offset_code,
- dimen_base);
- primitive_tex("voffset", assign_dimen_cmd, dimen_base + v_offset_code,
- dimen_base);
- primitive_tex("emergencystretch", assign_dimen_cmd,
- dimen_base + emergency_stretch_code, dimen_base);
- primitive_pdftex("pdfhorigin", assign_dimen_cmd,
- dimen_base + pdf_h_origin_code, dimen_base);
- primitive_pdftex("pdfvorigin", assign_dimen_cmd,
- dimen_base + pdf_v_origin_code, dimen_base);
- primitive_luatex("pagewidth", assign_dimen_cmd, dimen_base + page_width_code,
- dimen_base);
- primitive_luatex("pageheight", assign_dimen_cmd,
- dimen_base + page_height_code, dimen_base);
- primitive_pdftex("pdflinkmargin", assign_dimen_cmd,
- dimen_base + pdf_link_margin_code, dimen_base);
- primitive_pdftex("pdfdestmargin", assign_dimen_cmd,
- dimen_base + pdf_dest_margin_code, dimen_base);
- primitive_pdftex("pdfthreadmargin", assign_dimen_cmd,
- dimen_base + pdf_thread_margin_code, dimen_base);
- primitive_pdftex("pdfpxdimen", assign_dimen_cmd,
- dimen_base + pdf_px_dimen_code, dimen_base);
+ primitive_tex("escapechar", assign_int_cmd, int_base + escape_char_code, int_base);
+ primitive_tex("defaulthyphenchar", assign_int_cmd, int_base + default_hyphen_char_code, int_base);
+ primitive_tex("defaultskewchar", assign_int_cmd, int_base + default_skew_char_code, int_base);
+ primitive_tex("endlinechar", assign_int_cmd, int_base + end_line_char_code, int_base);
+ primitive_tex("newlinechar", assign_int_cmd, int_base + new_line_char_code, int_base);
+ primitive_tex("language", assign_int_cmd, int_base + language_code, int_base);
+ primitive_tex("setlanguage", assign_int_cmd, int_base + cur_lang_code, int_base);
+ primitive_tex("exhyphenchar", assign_int_cmd, int_base + ex_hyphen_char_code, int_base);
+ primitive_tex("lefthyphenmin", assign_int_cmd, int_base + left_hyphen_min_code, int_base);
+ primitive_tex("righthyphenmin", assign_int_cmd, int_base + right_hyphen_min_code, int_base);
+ primitive_tex("holdinginserts", assign_int_cmd, int_base + holding_inserts_code, int_base);
+ primitive_tex("errorcontextlines", assign_int_cmd, int_base + error_context_lines_code, int_base);
+ primitive_luatex("luastartup", assign_int_cmd, int_base + luastartup_id_code, int_base);
+ primitive_luatex("nokerns", assign_int_cmd, int_base + disable_kern_code, int_base);
+ primitive_luatex("noligs", assign_int_cmd, int_base + disable_lig_code, int_base);
+ primitive_luatex("catcodetable", assign_int_cmd, int_base + cat_code_table_code, int_base);
+ primitive_luatex("outputbox", assign_int_cmd, int_base + output_box_code, int_base);
+ primitive_luatex("outputmode", assign_int_cmd, int_base + output_mode_code, int_base);
+ primitive_luatex("adjustspacing", assign_int_cmd, int_base + adjust_spacing_code, int_base);
+ primitive_luatex("protrudechars", assign_int_cmd, int_base + protrude_chars_code, int_base);
+ primitive_luatex("tracingfonts", assign_int_cmd, int_base + tracing_fonts_code, int_base);
+ primitive_luatex("draftmode", assign_int_cmd, int_base + draft_mode_code, int_base);
+ primitive_tex("parindent", assign_dimen_cmd, dimen_base + par_indent_code, dimen_base);
+ primitive_tex("mathsurround", assign_dimen_cmd, dimen_base + math_surround_code, dimen_base);
+ primitive_tex("lineskiplimit", assign_dimen_cmd, dimen_base + line_skip_limit_code, dimen_base);
+ primitive_tex("hsize", assign_dimen_cmd, dimen_base + hsize_code, dimen_base);
+ primitive_tex("vsize", assign_dimen_cmd, dimen_base + vsize_code, dimen_base);
+ primitive_tex("maxdepth", assign_dimen_cmd, dimen_base + max_depth_code, dimen_base);
+ primitive_tex("splitmaxdepth", assign_dimen_cmd, dimen_base + split_max_depth_code, dimen_base);
+ primitive_tex("boxmaxdepth", assign_dimen_cmd, dimen_base + box_max_depth_code, dimen_base);
+ primitive_tex("hfuzz", assign_dimen_cmd, dimen_base + hfuzz_code, dimen_base);
+ primitive_tex("vfuzz", assign_dimen_cmd, dimen_base + vfuzz_code, dimen_base);
+ primitive_tex("delimitershortfall", assign_dimen_cmd, dimen_base + delimiter_shortfall_code, dimen_base);
+ primitive_tex("nulldelimiterspace", assign_dimen_cmd, dimen_base + null_delimiter_space_code, dimen_base);
+ primitive_tex("scriptspace", assign_dimen_cmd, dimen_base + script_space_code, dimen_base);
+ primitive_tex("predisplaysize", assign_dimen_cmd, dimen_base + pre_display_size_code, dimen_base);
+ primitive_tex("displaywidth", assign_dimen_cmd, dimen_base + display_width_code, dimen_base);
+ primitive_tex("displayindent", assign_dimen_cmd, dimen_base + display_indent_code, dimen_base);
+ primitive_tex("overfullrule", assign_dimen_cmd, dimen_base + overfull_rule_code, dimen_base);
+ primitive_tex("hangindent", assign_dimen_cmd, dimen_base + hang_indent_code, dimen_base);
+ primitive_tex("hoffset", assign_dimen_cmd, dimen_base + h_offset_code, dimen_base);
+ primitive_tex("voffset", assign_dimen_cmd, dimen_base + v_offset_code, dimen_base);
+ primitive_tex("emergencystretch", assign_dimen_cmd, dimen_base + emergency_stretch_code, dimen_base);
+ primitive_luatex("pagewidth", assign_dimen_cmd, dimen_base + page_width_code, dimen_base);
+ primitive_luatex("pageheight", assign_dimen_cmd, dimen_base + page_height_code, dimen_base);
+ primitive_luatex("pxdimen", assign_dimen_cmd, dimen_base + px_dimen_code, dimen_base);
/* Many of \TeX's primitives need no |equiv|, since they are identifiable
by their |eq_type| alone. These primitives are loaded into the hash table
@@ -325,7 +169,7 @@ void initialize_commands(void)
primitive_tex("char", char_num_cmd, 0, 0);
primitive_tex("csname", cs_name_cmd, 0, 0);
primitive_tex("delimiter", delim_num_cmd, 0, 0);
- primitive_umath("Udelimiter", delim_num_cmd, 1, 0);
+ primitive_luatex("Udelimiter", delim_num_cmd, 1, 0);
primitive_tex("divide", divide_cmd, 0, 0);
primitive_tex("endcsname", end_cs_name_cmd, 0, 0);
primitive_tex("endgroup", end_group_cmd, 0, 0);
@@ -334,7 +178,9 @@ void initialize_commands(void)
primitive_tex("expandafter", expand_after_cmd, 0, 0);
primitive_tex("font", def_font_cmd, 0, 0);
primitive_luatex("letterspacefont", letterspace_font_cmd, 0, 0);
- primitive_pdftex("pdfcopyfont", pdf_copy_font_cmd, 0, 0);
+ primitive_luatex("expandglyphsinfont", normal_cmd, expand_font_code, 0);
+ primitive_luatex("copyfont", copy_font_cmd, 0, 0);
+ primitive_luatex("setfontid", set_font_id_cmd, 0, 0);
primitive_tex("fontdimen", assign_font_dimen_cmd, 0, 0);
primitive_tex("halign", halign_cmd, 0, 0);
primitive_tex("hrule", hrule_cmd, 0, 0);
@@ -343,14 +189,17 @@ void initialize_commands(void)
primitive_luatex("leftghost", char_ghost_cmd, 0, 0);
primitive_tex("mark", mark_cmd, 0, 0);
primitive_tex("mathaccent", math_accent_cmd, 0, 0);
- primitive_umath("Umathaccent", math_accent_cmd, 1, 0);
+ primitive_luatex("Umathaccent", math_accent_cmd, 1, 0);
primitive_tex("mathchar", math_char_num_cmd, 0, 0);
- primitive_umath("Umathchar", math_char_num_cmd, 1, 0);
- primitive_umath("Umathcharnum", math_char_num_cmd, 2, 0);
+ primitive_luatex("Umathchar", math_char_num_cmd, 1, 0);
+ primitive_luatex("Umathcharnum", math_char_num_cmd, 2, 0);
primitive_tex("mathchoice", math_choice_cmd, 0, 0);
- primitive_umath("Ustack", math_choice_cmd, 1, 0);
+ primitive_luatex("Ustack", math_choice_cmd, 1, 0);
primitive_tex("multiply", multiply_cmd, 0, 0);
primitive_tex("noalign", no_align_cmd, 0, 0);
+ primitive_luatex("nohrule", no_vrule_cmd, 0, 0);
+ primitive_luatex("novrule", no_hrule_cmd, 0, 0);
+ primitive_tex("boundary", boundary_cmd, 0, 0);
primitive_tex("noboundary", no_boundary_cmd, 0, 0);
primitive_tex("noexpand", no_expand_cmd, 0, 0);
primitive_luatex("primitive", no_expand_cmd, 1, 0);
@@ -360,12 +209,13 @@ void initialize_commands(void)
primitive_tex("penalty", break_penalty_cmd, 0, 0);
primitive_tex("prevgraf", set_prev_graf_cmd, 0, 0);
primitive_tex("radical", radical_cmd, 0, 0);
- primitive_umath("Uradical", radical_cmd, 1, 0);
- primitive_umath("Uroot", radical_cmd, 2, 0);
- primitive_umath("Uunderdelimiter", radical_cmd, 3, 0);
- primitive_umath("Uoverdelimiter", radical_cmd, 4, 0);
- primitive_umath("Udelimiterunder", radical_cmd, 5, 0);
- primitive_umath("Udelimiterover", radical_cmd, 6, 0);
+ primitive_luatex("Uradical", radical_cmd, 1, 0);
+ primitive_luatex("Uroot", radical_cmd, 2, 0);
+ primitive_luatex("Uunderdelimiter", radical_cmd, 3, 0);
+ primitive_luatex("Uoverdelimiter", radical_cmd, 4, 0);
+ primitive_luatex("Udelimiterunder", radical_cmd, 5, 0);
+ primitive_luatex("Udelimiterover", radical_cmd, 6, 0);
+ primitive_luatex("Uhextensible", radical_cmd, 7, 0);
primitive_tex("read", read_to_cs_cmd, 0, 0);
primitive_tex("relax", relax_cmd, too_big_char, too_big_char);
cs_text(frozen_relax) = maketexstring("relax");
@@ -390,8 +240,12 @@ void initialize_commands(void)
@ These are in a separate module due to a CWEAVE limitation.
@<Create a bunch of primitives@>=
- /* The processing of \.{\\input} involves the |start_input| subroutine,
- which will be declared later; the processing of \.{\\endinput} is trivial. */
+
+ /*
+ The processing of \.{\\input} involves the |start_input| subroutine,
+ which will be declared later; the processing of \.{\\endinput} is trivial.
+ */
+
primitive_tex("input", input_cmd, 0, 0);
primitive_tex("endinput", input_cmd, 1, 0);
primitive_tex("topmark", top_bot_mark_cmd, top_mark_code, 0);
@@ -402,19 +256,18 @@ void initialize_commands(void)
primitive_luatex("clearmarks", mark_cmd, clear_marks_code, 0);
primitive_etex("marks", mark_cmd, marks_code, 0);
primitive_etex("topmarks", top_bot_mark_cmd, top_mark_code + marks_code, 0);
- primitive_etex("firstmarks", top_bot_mark_cmd, first_mark_code + marks_code,
- 0);
+ primitive_etex("firstmarks", top_bot_mark_cmd, first_mark_code + marks_code, 0);
primitive_etex("botmarks", top_bot_mark_cmd, bot_mark_code + marks_code, 0);
- primitive_etex("splitfirstmarks", top_bot_mark_cmd,
- split_first_mark_code + marks_code, 0);
- primitive_etex("splitbotmarks", top_bot_mark_cmd,
- split_bot_mark_code + marks_code, 0);
-
- /* The hash table is initialized with `\.{\\count}', `\.{\\attribute}',
- `\.{\\dimen}', `\.{\\skip}', and `\.{\\muskip}' all having |register|
- as their command code; they are distinguished by the |chr_code|, which
- is either |int_val|, |attr_val|, |dimen_val|, |glue_val|, or |mu_val|.
- */
+ primitive_etex("splitfirstmarks", top_bot_mark_cmd, split_first_mark_code + marks_code, 0);
+ primitive_etex("splitbotmarks", top_bot_mark_cmd, split_bot_mark_code + marks_code, 0);
+
+ /*
+ The hash table is initialized with `\.{\\count}', `\.{\\attribute}',
+ `\.{\\dimen}', `\.{\\skip}', and `\.{\\muskip}' all having |register|
+ as their command code; they are distinguished by the |chr_code|, which
+ is either |int_val|, |attr_val|, |dimen_val|, |glue_val|, or |mu_val|.
+ */
+
primitive_tex("count", register_cmd, int_val_level, 0);
primitive_luatex("attribute", register_cmd, attr_val_level, 0);
primitive_tex("dimen", register_cmd, dimen_val_level, 0);
@@ -434,19 +287,12 @@ void initialize_commands(void)
primitive_tex("inputlineno", last_item_cmd, input_line_no_code, 0);
primitive_tex("badness", last_item_cmd, badness_code, 0);
primitive_luatex("luatexversion", last_item_cmd, luatex_version_code, 0);
- primitive_pdftex("pdflastobj", last_item_cmd, pdf_last_obj_code, 0);
- primitive_pdftex("pdflastxform", last_item_cmd, pdf_last_xform_code, 0);
- primitive_pdftex("pdflastximage", last_item_cmd, pdf_last_ximage_code, 0);
- primitive_pdftex("pdflastximagepages", last_item_cmd,
- pdf_last_ximage_pages_code, 0);
- primitive_pdftex("pdflastannot", last_item_cmd, pdf_last_annot_code, 0);
+ primitive_luatex("lastsavedboxresourceindex", last_item_cmd, last_saved_box_resource_index_code, 0);
+ primitive_luatex("lastsavedimageresourceindex", last_item_cmd, last_saved_image_resource_index_code, 0);
+ primitive_luatex("lastsavedimageresourcepages", last_item_cmd, last_saved_image_resource_pages_code, 0);
primitive_luatex("lastxpos", last_item_cmd, last_x_pos_code, 0);
primitive_luatex("lastypos", last_item_cmd, last_y_pos_code, 0);
- primitive_pdftex("pdfretval", last_item_cmd, pdf_retval_code, 0);
- primitive_pdftex("pdflastximagecolordepth", last_item_cmd,
- pdf_last_ximage_colordepth_code, 0);
primitive_luatex("randomseed", last_item_cmd, random_seed_code, 0);
- primitive_pdftex("pdflastlink", last_item_cmd, pdf_last_link_code, 0);
primitive_tex("number", convert_cmd, number_code, 0);
primitive_tex("romannumeral", convert_cmd, roman_numeral_code, 0);
@@ -458,17 +304,9 @@ void initialize_commands(void)
primitive_luatex("luatexrevision", convert_cmd, luatex_revision_code, 0);
primitive_luatex("luatexdatestamp", convert_cmd, luatex_date_code, 0);
primitive_luatex("luatexbanner", convert_cmd, luatex_banner_code, 0);
- primitive_pdftex("pdffontname", convert_cmd, pdf_font_name_code, 0);
- primitive_pdftex("pdffontobjnum", convert_cmd, pdf_font_objnum_code, 0);
- primitive_pdftex("pdffontsize", convert_cmd, pdf_font_size_code, 0);
- primitive_pdftex("pdfpageref", convert_cmd, pdf_page_ref_code, 0);
primitive_luatex("leftmarginkern", convert_cmd, left_margin_kern_code, 0);
primitive_luatex("rightmarginkern", convert_cmd, right_margin_kern_code, 0);
- primitive_pdftex("pdfxformname", convert_cmd, pdf_xform_name_code, 0);
- primitive_pdftex("pdfcreationdate", convert_cmd, pdf_creation_date_code, 0);
primitive_luatex("uniformdeviate", convert_cmd, uniform_deviate_code, 0);
- primitive_pdftex("pdfcolorstackinit", convert_cmd, pdf_colorstack_init_code,
- 0);
primitive_luatex("normaldeviate", convert_cmd, normal_deviate_code, 0);
primitive_core("directlua", convert_cmd, lua_code, 0);
primitive_luatex("luafunction", convert_cmd, lua_function_code, 0);
@@ -477,10 +315,12 @@ void initialize_commands(void)
primitive_luatex("expanded", convert_cmd, expanded_code, 0);
primitive_tex("jobname", convert_cmd, job_name_code, 0);
primitive_luatex("formatname", convert_cmd, format_name_code, 0);
- primitive_pdftex("pdfinsertht", convert_cmd, pdf_insert_ht_code, 0);
- primitive_pdftex("pdfximagebbox", convert_cmd, pdf_ximage_bbox_code, 0);
primitive_luatex("Uchar", convert_cmd, uchar_code, 0);
+ primitive_luatex("Umathcharclass", convert_cmd, math_char_class_code, 0);
+ primitive_luatex("Umathcharfam", convert_cmd, math_char_fam_code, 0);
+ primitive_luatex("Umathcharslot", convert_cmd, math_char_slot_code, 0);
+
primitive_tex("if", if_test_cmd, if_char_code, 0);
primitive_tex("ifcat", if_test_cmd, if_cat_code, 0);
primitive_tex("ifnum", if_test_cmd, if_int_code, 0);
@@ -506,17 +346,18 @@ void initialize_commands(void)
primitive_tex("or", fi_or_else_cmd, or_code, 0);
primitive_tex("else", fi_or_else_cmd, else_code, 0);
- /* \TeX\ always knows at least one font, namely the null font. It has no
- characters, and its seven parameters are all equal to zero. */
+ /*
+ \TeX\ always knows at least one font, namely the null font. It has no
+ characters, and its seven parameters are all equal to zero.
+ */
+
primitive_tex("nullfont", set_font_cmd, null_font, 0);
cs_text(frozen_null_font) = maketexstring("nullfont");
eqtb[frozen_null_font] = eqtb[cur_val];
primitive_tex("span", tab_mark_cmd, span_code, tab_mark_cmd_code);
- primitive_luatex("aligntab", tab_mark_cmd, tab_mark_cmd_code,
- tab_mark_cmd_code);
- primitive_luatex("alignmark", mac_param_cmd, tab_mark_cmd_code,
- tab_mark_cmd_code);
+ primitive_luatex("aligntab", tab_mark_cmd, tab_mark_cmd_code, tab_mark_cmd_code);
+ primitive_luatex("alignmark", mac_param_cmd, tab_mark_cmd_code, tab_mark_cmd_code);
primitive_tex("cr", car_ret_cmd, cr_code, cr_code);
cs_text(frozen_cr) = maketexstring("cr");
eqtb[frozen_cr] = eqtb[cur_val];
@@ -538,8 +379,10 @@ void initialize_commands(void)
primitive_tex("pageshrink", set_page_dimen_cmd, 6, 0);
primitive_tex("pagedepth", set_page_dimen_cmd, 7, 0);
- /* Either \.{\\dump} or \.{\\end} will cause |main_control| to enter the
- endgame, since both of them have `|stop|' as their command code. */
+ /*
+ Either \.{\\dump} or \.{\\end} will cause |main_control| to enter the
+ endgame, since both of them have `|stop|' as their command code.
+ */
primitive_tex("end", stop_cmd, 0, 0);
primitive_tex("dump", stop_cmd, 1, 0);
@@ -589,11 +432,10 @@ void initialize_commands(void)
primitive_luatex("localleftbox", assign_local_box_cmd, 0, 0);
primitive_luatex("localrightbox", assign_local_box_cmd, 1, 0);
- primitive_umath("Ustartmath", math_shift_cs_cmd, text_style, 0);
- primitive_umath("Ustopmath", math_shift_cs_cmd, cramped_text_style, 0);
- primitive_umath("Ustartdisplaymath", math_shift_cs_cmd, display_style, 0);
- primitive_umath("Ustopdisplaymath", math_shift_cs_cmd,
- cramped_display_style, 0);
+ primitive_luatex("Ustartmath", math_shift_cs_cmd, text_style, 0);
+ primitive_luatex("Ustopmath", math_shift_cs_cmd, cramped_text_style, 0);
+ primitive_luatex("Ustartdisplaymath", math_shift_cs_cmd, display_style, 0);
+ primitive_luatex("Ustopdisplaymath", math_shift_cs_cmd, cramped_display_style, 0);
primitive_tex("eqno", eq_no_cmd, 0, 0);
primitive_tex("leqno", eq_no_cmd, 1, 0);
primitive_tex("mathord", math_comp_cmd, ord_noad_type, 0);
@@ -613,26 +455,27 @@ void initialize_commands(void)
primitive_tex("textstyle", math_style_cmd, text_style, 0);
primitive_tex("scriptstyle", math_style_cmd, script_style, 0);
primitive_tex("scriptscriptstyle", math_style_cmd, script_script_style, 0);
- primitive_luatex("crampeddisplaystyle", math_style_cmd,
- cramped_display_style, 0);
+ primitive_luatex("crampeddisplaystyle", math_style_cmd, cramped_display_style, 0);
primitive_luatex("crampedtextstyle", math_style_cmd, cramped_text_style, 0);
- primitive_luatex("crampedscriptstyle", math_style_cmd, cramped_script_style,
- 0);
- primitive_luatex("crampedscriptscriptstyle", math_style_cmd,
- cramped_script_script_style, 0);
- primitive_umath("Usuperscript", super_sub_script_cmd, sup_mark_cmd,
- sup_mark_cmd);
- primitive_umath("Usubscript", super_sub_script_cmd, sub_mark_cmd,
- sup_mark_cmd);
+ primitive_luatex("crampedscriptstyle", math_style_cmd, cramped_script_style, 0);
+ primitive_luatex("crampedscriptscriptstyle", math_style_cmd, cramped_script_script_style, 0);
+ primitive_luatex("Usuperscript", super_sub_script_cmd, sup_mark_cmd, sup_mark_cmd);
+ primitive_luatex("Usubscript", super_sub_script_cmd, sub_mark_cmd, sup_mark_cmd);
primitive_tex("above", above_cmd, above_code, 0);
primitive_tex("over", above_cmd, over_code, 0);
primitive_tex("atop", above_cmd, atop_code, 0);
+ primitive_luatex("Uskewed", above_cmd, skewed_code, 0);
primitive_tex("abovewithdelims", above_cmd, delimited_code + above_code, 0);
primitive_tex("overwithdelims", above_cmd, delimited_code + over_code, 0);
primitive_tex("atopwithdelims", above_cmd, delimited_code + atop_code, 0);
+ primitive_luatex("Uskewedwithdelims", above_cmd, delimited_code + skewed_code, 0);
primitive_tex("left", left_right_cmd, left_noad_side, 0);
primitive_tex("right", left_right_cmd, right_noad_side, 0);
primitive_tex("middle", left_right_cmd, middle_noad_side, 0);
+ primitive_tex("Uleft", left_right_cmd, 10+left_noad_side, 0);
+ primitive_tex("Uright", left_right_cmd, 10+right_noad_side, 0);
+ primitive_tex("Umiddle", left_right_cmd, 10+middle_noad_side, 0);
+ primitive_luatex("Uvextensible", left_right_cmd, 10+no_noad_side, 0);
cs_text(frozen_right) = maketexstring("right");
eqtb[frozen_right] = eqtb[cur_val];
@@ -647,8 +490,8 @@ void initialize_commands(void)
primitive_tex("futurelet", let_cmd, normal + 1, 0);
primitive_tex("chardef", shorthand_def_cmd, char_def_code, 0);
primitive_tex("mathchardef", shorthand_def_cmd, math_char_def_code, 0);
- primitive_umath("Umathchardef", shorthand_def_cmd, xmath_char_def_code, 0);
- primitive_umath("Umathcharnumdef", shorthand_def_cmd, umath_char_def_code, 0);
+ primitive_luatex("Umathchardef", shorthand_def_cmd, xmath_char_def_code, 0);
+ primitive_luatex("Umathcharnumdef", shorthand_def_cmd, umath_char_def_code, 0);
primitive_tex("countdef", shorthand_def_cmd, count_def_code, 0);
primitive_luatex("attributedef", shorthand_def_cmd, attribute_def_code, 0);
primitive_tex("dimendef", shorthand_def_cmd, dimen_def_code, 0);
@@ -664,239 +507,129 @@ void initialize_commands(void)
primitive_tex("textfont", def_family_cmd, text_size, 0);
primitive_tex("scriptfont", def_family_cmd, script_size, 0);
primitive_tex("scriptscriptfont", def_family_cmd, script_script_size, 0);
- primitive_umath("Umathquad", set_math_param_cmd, math_param_quad, 0);
- primitive_umath("Umathaxis", set_math_param_cmd, math_param_axis, 0);
-
+ primitive_luatex("Umathquad", set_math_param_cmd, math_param_quad, 0);
+ primitive_luatex("Umathaxis", set_math_param_cmd, math_param_axis, 0);
@ These are in a separate module due to a CWEAVE limitation.
@<Create the math param primitives@>=
- primitive_umath("Umathoperatorsize", set_math_param_cmd,
- math_param_operator_size, 0);
- primitive_umath("Umathoverbarkern", set_math_param_cmd,
- math_param_overbar_kern, 0);
- primitive_umath("Umathoverbarrule", set_math_param_cmd,
- math_param_overbar_rule, 0);
- primitive_umath("Umathoverbarvgap", set_math_param_cmd,
- math_param_overbar_vgap, 0);
- primitive_umath("Umathunderbarkern", set_math_param_cmd,
- math_param_underbar_kern, 0);
- primitive_umath("Umathunderbarrule", set_math_param_cmd,
- math_param_underbar_rule, 0);
- primitive_umath("Umathunderbarvgap", set_math_param_cmd,
- math_param_underbar_vgap, 0);
- primitive_umath("Umathradicalkern", set_math_param_cmd,
- math_param_radical_kern, 0);
- primitive_umath("Umathradicalrule", set_math_param_cmd,
- math_param_radical_rule, 0);
- primitive_umath("Umathradicalvgap", set_math_param_cmd,
- math_param_radical_vgap, 0);
- primitive_umath("Umathradicaldegreebefore", set_math_param_cmd,
- math_param_radical_degree_before, 0);
- primitive_umath("Umathradicaldegreeafter", set_math_param_cmd,
- math_param_radical_degree_after, 0);
- primitive_umath("Umathradicaldegreeraise", set_math_param_cmd,
- math_param_radical_degree_raise, 0);
- primitive_umath("Umathstackvgap", set_math_param_cmd,
- math_param_stack_vgap, 0);
- primitive_umath("Umathstacknumup", set_math_param_cmd,
- math_param_stack_num_up, 0);
- primitive_umath("Umathstackdenomdown", set_math_param_cmd,
- math_param_stack_denom_down, 0);
- primitive_umath("Umathfractionrule", set_math_param_cmd,
- math_param_fraction_rule, 0);
- primitive_umath("Umathfractionnumvgap", set_math_param_cmd,
- math_param_fraction_num_vgap, 0);
- primitive_umath("Umathfractionnumup", set_math_param_cmd,
- math_param_fraction_num_up, 0);
- primitive_umath("Umathfractiondenomvgap", set_math_param_cmd,
- math_param_fraction_denom_vgap, 0);
- primitive_umath("Umathfractiondenomdown", set_math_param_cmd,
- math_param_fraction_denom_down, 0);
- primitive_umath("Umathfractiondelsize", set_math_param_cmd,
- math_param_fraction_del_size, 0);
- primitive_umath("Umathlimitabovevgap", set_math_param_cmd,
- math_param_limit_above_vgap, 0);
- primitive_umath("Umathlimitabovebgap", set_math_param_cmd,
- math_param_limit_above_bgap, 0);
- primitive_umath("Umathlimitabovekern", set_math_param_cmd,
- math_param_limit_above_kern, 0);
- primitive_umath("Umathlimitbelowvgap", set_math_param_cmd,
- math_param_limit_below_vgap, 0);
- primitive_umath("Umathlimitbelowbgap", set_math_param_cmd,
- math_param_limit_below_bgap, 0);
- primitive_umath("Umathlimitbelowkern", set_math_param_cmd,
- math_param_limit_below_kern, 0);
- primitive_umath("Umathunderdelimitervgap", set_math_param_cmd,
- math_param_under_delimiter_vgap, 0);
- primitive_umath("Umathunderdelimiterbgap", set_math_param_cmd,
- math_param_under_delimiter_bgap, 0);
- primitive_umath("Umathoverdelimitervgap", set_math_param_cmd,
- math_param_over_delimiter_vgap, 0);
- primitive_umath("Umathoverdelimiterbgap", set_math_param_cmd,
- math_param_over_delimiter_bgap, 0);
- primitive_umath("Umathsubshiftdrop", set_math_param_cmd,
- math_param_sub_shift_drop, 0);
- primitive_umath("Umathsupshiftdrop", set_math_param_cmd,
- math_param_sup_shift_drop, 0);
- primitive_umath("Umathsubshiftdown", set_math_param_cmd,
- math_param_sub_shift_down, 0);
- primitive_umath("Umathsubsupshiftdown", set_math_param_cmd,
- math_param_sub_sup_shift_down, 0);
- primitive_umath("Umathsubtopmax", set_math_param_cmd,
- math_param_sub_top_max, 0);
- primitive_umath("Umathsupshiftup", set_math_param_cmd,
- math_param_sup_shift_up, 0);
- primitive_umath("Umathsupbottommin", set_math_param_cmd,
- math_param_sup_bottom_min, 0);
- primitive_umath("Umathsupsubbottommax", set_math_param_cmd,
- math_param_sup_sub_bottom_max, 0);
- primitive_umath("Umathsubsupvgap", set_math_param_cmd,
- math_param_subsup_vgap, 0);
- primitive_umath("Umathspaceafterscript", set_math_param_cmd,
- math_param_space_after_script, 0);
- primitive_umath("Umathconnectoroverlapmin", set_math_param_cmd,
- math_param_connector_overlap_min, 0);
- primitive_umath("Umathordordspacing", set_math_param_cmd,
- math_param_ord_ord_spacing, 0);
- primitive_umath("Umathordopspacing", set_math_param_cmd,
- math_param_ord_op_spacing, 0);
- primitive_umath("Umathordbinspacing", set_math_param_cmd,
- math_param_ord_bin_spacing, 0);
- primitive_umath("Umathordrelspacing", set_math_param_cmd,
- math_param_ord_rel_spacing, 0);
- primitive_umath("Umathordopenspacing", set_math_param_cmd,
- math_param_ord_open_spacing, 0);
- primitive_umath("Umathordclosespacing", set_math_param_cmd,
- math_param_ord_close_spacing, 0);
- primitive_umath("Umathordpunctspacing", set_math_param_cmd,
- math_param_ord_punct_spacing, 0);
- primitive_umath("Umathordinnerspacing", set_math_param_cmd,
- math_param_ord_inner_spacing, 0);
- primitive_umath("Umathopordspacing", set_math_param_cmd,
- math_param_op_ord_spacing, 0);
- primitive_umath("Umathopopspacing", set_math_param_cmd,
- math_param_op_op_spacing, 0);
- primitive_umath("Umathopbinspacing", set_math_param_cmd,
- math_param_op_bin_spacing, 0);
- primitive_umath("Umathoprelspacing", set_math_param_cmd,
- math_param_op_rel_spacing, 0);
- primitive_umath("Umathopopenspacing", set_math_param_cmd,
- math_param_op_open_spacing, 0);
- primitive_umath("Umathopclosespacing", set_math_param_cmd,
- math_param_op_close_spacing, 0);
- primitive_umath("Umathoppunctspacing", set_math_param_cmd,
- math_param_op_punct_spacing, 0);
- primitive_umath("Umathopinnerspacing", set_math_param_cmd,
- math_param_op_inner_spacing, 0);
- primitive_umath("Umathbinordspacing", set_math_param_cmd,
- math_param_bin_ord_spacing, 0);
- primitive_umath("Umathbinopspacing", set_math_param_cmd,
- math_param_bin_op_spacing, 0);
- primitive_umath("Umathbinbinspacing", set_math_param_cmd,
- math_param_bin_bin_spacing, 0);
- primitive_umath("Umathbinrelspacing", set_math_param_cmd,
- math_param_bin_rel_spacing, 0);
- primitive_umath("Umathbinopenspacing", set_math_param_cmd,
- math_param_bin_open_spacing, 0);
- primitive_umath("Umathbinclosespacing", set_math_param_cmd,
- math_param_bin_close_spacing, 0);
- primitive_umath("Umathbinpunctspacing", set_math_param_cmd,
- math_param_bin_punct_spacing, 0);
- primitive_umath("Umathbininnerspacing", set_math_param_cmd,
- math_param_bin_inner_spacing, 0);
- primitive_umath("Umathrelordspacing", set_math_param_cmd,
- math_param_rel_ord_spacing, 0);
- primitive_umath("Umathrelopspacing", set_math_param_cmd,
- math_param_rel_op_spacing, 0);
- primitive_umath("Umathrelbinspacing", set_math_param_cmd,
- math_param_rel_bin_spacing, 0);
- primitive_umath("Umathrelrelspacing", set_math_param_cmd,
- math_param_rel_rel_spacing, 0);
- primitive_umath("Umathrelopenspacing", set_math_param_cmd,
- math_param_rel_open_spacing, 0);
- primitive_umath("Umathrelclosespacing", set_math_param_cmd,
- math_param_rel_close_spacing, 0);
- primitive_umath("Umathrelpunctspacing", set_math_param_cmd,
- math_param_rel_punct_spacing, 0);
- primitive_umath("Umathrelinnerspacing", set_math_param_cmd,
- math_param_rel_inner_spacing, 0);
- primitive_umath("Umathopenordspacing", set_math_param_cmd,
- math_param_open_ord_spacing, 0);
- primitive_umath("Umathopenopspacing", set_math_param_cmd,
- math_param_open_op_spacing, 0);
- primitive_umath("Umathopenbinspacing", set_math_param_cmd,
- math_param_open_bin_spacing, 0);
- primitive_umath("Umathopenrelspacing", set_math_param_cmd,
- math_param_open_rel_spacing, 0);
- primitive_umath("Umathopenopenspacing", set_math_param_cmd,
- math_param_open_open_spacing, 0);
- primitive_umath("Umathopenclosespacing", set_math_param_cmd,
- math_param_open_close_spacing, 0);
- primitive_umath("Umathopenpunctspacing", set_math_param_cmd,
- math_param_open_punct_spacing, 0);
- primitive_umath("Umathopeninnerspacing", set_math_param_cmd,
- math_param_open_inner_spacing, 0);
- primitive_umath("Umathcloseordspacing", set_math_param_cmd,
- math_param_close_ord_spacing, 0);
- primitive_umath("Umathcloseopspacing", set_math_param_cmd,
- math_param_close_op_spacing, 0);
- primitive_umath("Umathclosebinspacing", set_math_param_cmd,
- math_param_close_bin_spacing, 0);
- primitive_umath("Umathcloserelspacing", set_math_param_cmd,
- math_param_close_rel_spacing, 0);
- primitive_umath("Umathcloseopenspacing", set_math_param_cmd,
- math_param_close_open_spacing, 0);
- primitive_umath("Umathcloseclosespacing", set_math_param_cmd,
- math_param_close_close_spacing, 0);
- primitive_umath("Umathclosepunctspacing", set_math_param_cmd,
- math_param_close_punct_spacing, 0);
- primitive_umath("Umathcloseinnerspacing", set_math_param_cmd,
- math_param_close_inner_spacing, 0);
- primitive_umath("Umathpunctordspacing", set_math_param_cmd,
- math_param_punct_ord_spacing, 0);
- primitive_umath("Umathpunctopspacing", set_math_param_cmd,
- math_param_punct_op_spacing, 0);
- primitive_umath("Umathpunctbinspacing", set_math_param_cmd,
- math_param_punct_bin_spacing, 0);
- primitive_umath("Umathpunctrelspacing", set_math_param_cmd,
- math_param_punct_rel_spacing, 0);
- primitive_umath("Umathpunctopenspacing", set_math_param_cmd,
- math_param_punct_open_spacing, 0);
- primitive_umath("Umathpunctclosespacing", set_math_param_cmd,
- math_param_punct_close_spacing, 0);
- primitive_umath("Umathpunctpunctspacing", set_math_param_cmd,
- math_param_punct_punct_spacing, 0);
- primitive_umath("Umathpunctinnerspacing", set_math_param_cmd,
- math_param_punct_inner_spacing, 0);
- primitive_umath("Umathinnerordspacing", set_math_param_cmd,
- math_param_inner_ord_spacing, 0);
- primitive_umath("Umathinneropspacing", set_math_param_cmd,
- math_param_inner_op_spacing, 0);
- primitive_umath("Umathinnerbinspacing", set_math_param_cmd,
- math_param_inner_bin_spacing, 0);
- primitive_umath("Umathinnerrelspacing", set_math_param_cmd,
- math_param_inner_rel_spacing, 0);
- primitive_umath("Umathinneropenspacing", set_math_param_cmd,
- math_param_inner_open_spacing, 0);
- primitive_umath("Umathinnerclosespacing", set_math_param_cmd,
- math_param_inner_close_spacing, 0);
- primitive_umath("Umathinnerpunctspacing", set_math_param_cmd,
- math_param_inner_punct_spacing, 0);
- primitive_umath("Umathinnerinnerspacing", set_math_param_cmd,
- math_param_inner_inner_spacing, 0);
+ primitive_luatex("Umathoperatorsize", set_math_param_cmd, math_param_operator_size, 0);
+ primitive_luatex("Umathoverbarkern", set_math_param_cmd, math_param_overbar_kern, 0);
+ primitive_luatex("Umathoverbarrule", set_math_param_cmd, math_param_overbar_rule, 0);
+ primitive_luatex("Umathoverbarvgap", set_math_param_cmd, math_param_overbar_vgap, 0);
+ primitive_luatex("Umathunderbarkern", set_math_param_cmd, math_param_underbar_kern, 0);
+ primitive_luatex("Umathunderbarrule", set_math_param_cmd, math_param_underbar_rule, 0);
+ primitive_luatex("Umathunderbarvgap", set_math_param_cmd, math_param_underbar_vgap, 0);
+ primitive_luatex("Umathradicalkern", set_math_param_cmd, math_param_radical_kern, 0);
+ primitive_luatex("Umathradicalrule", set_math_param_cmd, math_param_radical_rule, 0);
+ primitive_luatex("Umathradicalvgap", set_math_param_cmd, math_param_radical_vgap, 0);
+ primitive_luatex("Umathradicaldegreebefore", set_math_param_cmd, math_param_radical_degree_before, 0);
+ primitive_luatex("Umathradicaldegreeafter", set_math_param_cmd, math_param_radical_degree_after, 0);
+ primitive_luatex("Umathradicaldegreeraise", set_math_param_cmd, math_param_radical_degree_raise, 0);
+ primitive_luatex("Umathstackvgap", set_math_param_cmd, math_param_stack_vgap, 0);
+ primitive_luatex("Umathstacknumup", set_math_param_cmd, math_param_stack_num_up, 0);
+ primitive_luatex("Umathstackdenomdown", set_math_param_cmd, math_param_stack_denom_down, 0);
+ primitive_luatex("Umathfractionrule", set_math_param_cmd, math_param_fraction_rule, 0);
+ primitive_luatex("Umathfractionnumvgap", set_math_param_cmd, math_param_fraction_num_vgap, 0);
+ primitive_luatex("Umathfractionnumup", set_math_param_cmd, math_param_fraction_num_up, 0);
+ primitive_luatex("Umathfractiondenomvgap", set_math_param_cmd, math_param_fraction_denom_vgap, 0);
+ primitive_luatex("Umathfractiondenomdown", set_math_param_cmd, math_param_fraction_denom_down, 0);
+ primitive_luatex("Umathfractiondelsize", set_math_param_cmd, math_param_fraction_del_size, 0);
+ primitive_luatex("Umathskewedfractionvgap", set_math_param_cmd, math_param_skewed_fraction_vgap, 0);
+ primitive_luatex("Umathskewedfractionhgap", set_math_param_cmd, math_param_skewed_fraction_hgap, 0);
+ primitive_luatex("Umathlimitabovevgap", set_math_param_cmd, math_param_limit_above_vgap, 0);
+ primitive_luatex("Umathlimitabovebgap", set_math_param_cmd, math_param_limit_above_bgap, 0);
+ primitive_luatex("Umathlimitabovekern", set_math_param_cmd, math_param_limit_above_kern, 0);
+ primitive_luatex("Umathlimitbelowvgap", set_math_param_cmd, math_param_limit_below_vgap, 0);
+ primitive_luatex("Umathlimitbelowbgap", set_math_param_cmd, math_param_limit_below_bgap, 0);
+ primitive_luatex("Umathlimitbelowkern", set_math_param_cmd, math_param_limit_below_kern, 0);
+ primitive_luatex("Umathunderdelimitervgap", set_math_param_cmd, math_param_under_delimiter_vgap, 0);
+ primitive_luatex("Umathunderdelimiterbgap", set_math_param_cmd, math_param_under_delimiter_bgap, 0);
+ primitive_luatex("Umathoverdelimitervgap", set_math_param_cmd, math_param_over_delimiter_vgap, 0);
+ primitive_luatex("Umathoverdelimiterbgap", set_math_param_cmd, math_param_over_delimiter_bgap, 0);
+ primitive_luatex("Umathsubshiftdrop", set_math_param_cmd, math_param_sub_shift_drop, 0);
+ primitive_luatex("Umathsupshiftdrop", set_math_param_cmd, math_param_sup_shift_drop, 0);
+ primitive_luatex("Umathsubshiftdown", set_math_param_cmd, math_param_sub_shift_down, 0);
+ primitive_luatex("Umathsubsupshiftdown", set_math_param_cmd, math_param_sub_sup_shift_down, 0);
+ primitive_luatex("Umathsubtopmax", set_math_param_cmd, math_param_sub_top_max, 0);
+ primitive_luatex("Umathsupshiftup", set_math_param_cmd, math_param_sup_shift_up, 0);
+ primitive_luatex("Umathsupbottommin", set_math_param_cmd, math_param_sup_bottom_min, 0);
+ primitive_luatex("Umathsupsubbottommax", set_math_param_cmd, math_param_sup_sub_bottom_max, 0);
+ primitive_luatex("Umathsubsupvgap", set_math_param_cmd, math_param_subsup_vgap, 0);
+ primitive_luatex("Umathspaceafterscript", set_math_param_cmd, math_param_space_after_script, 0);
+ primitive_luatex("Umathconnectoroverlapmin", set_math_param_cmd, math_param_connector_overlap_min, 0);
+ primitive_luatex("Umathordordspacing", set_math_param_cmd, math_param_ord_ord_spacing, 0);
+ primitive_luatex("Umathordopspacing", set_math_param_cmd, math_param_ord_op_spacing, 0);
+ primitive_luatex("Umathordbinspacing", set_math_param_cmd, math_param_ord_bin_spacing, 0);
+ primitive_luatex("Umathordrelspacing", set_math_param_cmd, math_param_ord_rel_spacing, 0);
+ primitive_luatex("Umathordopenspacing", set_math_param_cmd, math_param_ord_open_spacing, 0);
+ primitive_luatex("Umathordclosespacing", set_math_param_cmd, math_param_ord_close_spacing, 0);
+ primitive_luatex("Umathordpunctspacing", set_math_param_cmd, math_param_ord_punct_spacing, 0);
+ primitive_luatex("Umathordinnerspacing", set_math_param_cmd, math_param_ord_inner_spacing, 0);
+ primitive_luatex("Umathopordspacing", set_math_param_cmd, math_param_op_ord_spacing, 0);
+ primitive_luatex("Umathopopspacing", set_math_param_cmd, math_param_op_op_spacing, 0);
+ primitive_luatex("Umathopbinspacing", set_math_param_cmd, math_param_op_bin_spacing, 0);
+ primitive_luatex("Umathoprelspacing", set_math_param_cmd, math_param_op_rel_spacing, 0);
+ primitive_luatex("Umathopopenspacing", set_math_param_cmd, math_param_op_open_spacing, 0);
+ primitive_luatex("Umathopclosespacing", set_math_param_cmd, math_param_op_close_spacing, 0);
+ primitive_luatex("Umathoppunctspacing", set_math_param_cmd, math_param_op_punct_spacing, 0);
+ primitive_luatex("Umathopinnerspacing", set_math_param_cmd, math_param_op_inner_spacing, 0);
+ primitive_luatex("Umathbinordspacing", set_math_param_cmd, math_param_bin_ord_spacing, 0);
+ primitive_luatex("Umathbinopspacing", set_math_param_cmd, math_param_bin_op_spacing, 0);
+ primitive_luatex("Umathbinbinspacing", set_math_param_cmd, math_param_bin_bin_spacing, 0);
+ primitive_luatex("Umathbinrelspacing", set_math_param_cmd, math_param_bin_rel_spacing, 0);
+ primitive_luatex("Umathbinopenspacing", set_math_param_cmd, math_param_bin_open_spacing, 0);
+ primitive_luatex("Umathbinclosespacing", set_math_param_cmd, math_param_bin_close_spacing, 0);
+ primitive_luatex("Umathbinpunctspacing", set_math_param_cmd, math_param_bin_punct_spacing, 0);
+ primitive_luatex("Umathbininnerspacing", set_math_param_cmd, math_param_bin_inner_spacing, 0);
+ primitive_luatex("Umathrelordspacing", set_math_param_cmd, math_param_rel_ord_spacing, 0);
+ primitive_luatex("Umathrelopspacing", set_math_param_cmd, math_param_rel_op_spacing, 0);
+ primitive_luatex("Umathrelbinspacing", set_math_param_cmd, math_param_rel_bin_spacing, 0);
+ primitive_luatex("Umathrelrelspacing", set_math_param_cmd, math_param_rel_rel_spacing, 0);
+ primitive_luatex("Umathrelopenspacing", set_math_param_cmd, math_param_rel_open_spacing, 0);
+ primitive_luatex("Umathrelclosespacing", set_math_param_cmd, math_param_rel_close_spacing, 0);
+ primitive_luatex("Umathrelpunctspacing", set_math_param_cmd, math_param_rel_punct_spacing, 0);
+ primitive_luatex("Umathrelinnerspacing", set_math_param_cmd, math_param_rel_inner_spacing, 0);
+ primitive_luatex("Umathopenordspacing", set_math_param_cmd, math_param_open_ord_spacing, 0);
+ primitive_luatex("Umathopenopspacing", set_math_param_cmd, math_param_open_op_spacing, 0);
+ primitive_luatex("Umathopenbinspacing", set_math_param_cmd, math_param_open_bin_spacing, 0);
+ primitive_luatex("Umathopenrelspacing", set_math_param_cmd, math_param_open_rel_spacing, 0);
+ primitive_luatex("Umathopenopenspacing", set_math_param_cmd, math_param_open_open_spacing, 0);
+ primitive_luatex("Umathopenclosespacing", set_math_param_cmd, math_param_open_close_spacing, 0);
+ primitive_luatex("Umathopenpunctspacing", set_math_param_cmd, math_param_open_punct_spacing, 0);
+ primitive_luatex("Umathopeninnerspacing", set_math_param_cmd, math_param_open_inner_spacing, 0);
+ primitive_luatex("Umathcloseordspacing", set_math_param_cmd, math_param_close_ord_spacing, 0);
+ primitive_luatex("Umathcloseopspacing", set_math_param_cmd, math_param_close_op_spacing, 0);
+ primitive_luatex("Umathclosebinspacing", set_math_param_cmd, math_param_close_bin_spacing, 0);
+ primitive_luatex("Umathcloserelspacing", set_math_param_cmd, math_param_close_rel_spacing, 0);
+ primitive_luatex("Umathcloseopenspacing", set_math_param_cmd, math_param_close_open_spacing, 0);
+ primitive_luatex("Umathcloseclosespacing", set_math_param_cmd, math_param_close_close_spacing, 0);
+ primitive_luatex("Umathclosepunctspacing", set_math_param_cmd, math_param_close_punct_spacing, 0);
+ primitive_luatex("Umathcloseinnerspacing", set_math_param_cmd, math_param_close_inner_spacing, 0);
+ primitive_luatex("Umathpunctordspacing", set_math_param_cmd, math_param_punct_ord_spacing, 0);
+ primitive_luatex("Umathpunctopspacing", set_math_param_cmd, math_param_punct_op_spacing, 0);
+ primitive_luatex("Umathpunctbinspacing", set_math_param_cmd, math_param_punct_bin_spacing, 0);
+ primitive_luatex("Umathpunctrelspacing", set_math_param_cmd, math_param_punct_rel_spacing, 0);
+ primitive_luatex("Umathpunctopenspacing", set_math_param_cmd, math_param_punct_open_spacing, 0);
+ primitive_luatex("Umathpunctclosespacing", set_math_param_cmd, math_param_punct_close_spacing, 0);
+ primitive_luatex("Umathpunctpunctspacing", set_math_param_cmd, math_param_punct_punct_spacing, 0);
+ primitive_luatex("Umathpunctinnerspacing", set_math_param_cmd, math_param_punct_inner_spacing, 0);
+ primitive_luatex("Umathinnerordspacing", set_math_param_cmd, math_param_inner_ord_spacing, 0);
+ primitive_luatex("Umathinneropspacing", set_math_param_cmd, math_param_inner_op_spacing, 0);
+ primitive_luatex("Umathinnerbinspacing", set_math_param_cmd, math_param_inner_bin_spacing, 0);
+ primitive_luatex("Umathinnerrelspacing", set_math_param_cmd, math_param_inner_rel_spacing, 0);
+ primitive_luatex("Umathinneropenspacing", set_math_param_cmd, math_param_inner_open_spacing, 0);
+ primitive_luatex("Umathinnerclosespacing", set_math_param_cmd, math_param_inner_close_spacing, 0);
+ primitive_luatex("Umathinnerpunctspacing", set_math_param_cmd, math_param_inner_punct_spacing, 0);
+ primitive_luatex("Umathinnerinnerspacing", set_math_param_cmd, math_param_inner_inner_spacing, 0);
@ These are in a separate module due to a CWEAVE limitation.
@<Create another bunch of primitives@>=
- primitive_umath("Umathcode", extdef_math_code_cmd, math_code_base,
- math_code_base);
- primitive_umath("Udelcode", extdef_del_code_cmd, del_code_base,
- del_code_base);
- primitive_umath("Umathcodenum", extdef_math_code_cmd, math_code_base + 1,
- math_code_base);
- primitive_umath("Udelcodenum", extdef_del_code_cmd, del_code_base + 1,
- del_code_base);
+ primitive_luatex("Umathcode", extdef_math_code_cmd, math_code_base, math_code_base);
+ primitive_luatex("Udelcode", extdef_del_code_cmd, del_code_base, del_code_base);
+ primitive_luatex("Umathcodenum", extdef_math_code_cmd, math_code_base + 1, math_code_base);
+ primitive_luatex("Udelcodenum", extdef_del_code_cmd, del_code_base + 1, del_code_base);
primitive_tex("hyphenation", hyph_data_cmd, 0, 0);
primitive_tex("patterns", hyph_data_cmd, 1, 0);
primitive_luatex("prehyphenchar", hyph_data_cmd, 2, 0);
@@ -926,84 +659,50 @@ void initialize_commands(void)
primitive_tex("showthe", xray_cmd, show_the_code, 0);
primitive_tex("showlists", xray_cmd, show_lists, 0);
- primitive_tex("openout", extension_cmd, open_node, 0);
- primitive_tex("write", extension_cmd, write_node, 0);
+ primitive_tex("openout", extension_cmd, open_code, 0);
+ primitive_tex("write", extension_cmd, write_code, 0);
write_loc = cur_val;
- primitive_tex("closeout", extension_cmd, close_node, 0);
- primitive_tex("special", extension_cmd, special_node, 0);
+ primitive_tex("closeout", extension_cmd, close_code, 0);
+ primitive_tex("special", extension_cmd, special_code, 0);
cs_text(frozen_special) = maketexstring("special");
eqtb[frozen_special] = eqtb[cur_val];
primitive_tex("immediate", extension_cmd, immediate_code, 0);
- primitive_luatex("localinterlinepenalty", assign_int_cmd,
- int_base + local_inter_line_penalty_code, int_base);
- primitive_luatex("localbrokenpenalty", assign_int_cmd,
- int_base + local_broken_penalty_code, int_base);
- primitive_luatex("pagedir", assign_dir_cmd, int_base + page_direction_code,
- dir_base);
- primitive_luatex("bodydir", assign_dir_cmd, int_base + body_direction_code,
- dir_base);
- primitive_luatex("pardir", assign_dir_cmd, int_base + par_direction_code,
- dir_base);
- primitive_luatex("textdir", assign_dir_cmd, int_base + text_direction_code,
- dir_base);
- primitive_luatex("mathdir", assign_dir_cmd, int_base + math_direction_code,
- dir_base);
- primitive_luatex("pageleftoffset", assign_dimen_cmd,
- dimen_base + page_left_offset_code, dimen_base);
- primitive_luatex("pagetopoffset", assign_dimen_cmd,
- dimen_base + page_top_offset_code, dimen_base);
- primitive_luatex("pagerightoffset", assign_dimen_cmd,
- dimen_base + page_right_offset_code, dimen_base);
- primitive_luatex("pagebottomoffset", assign_dimen_cmd,
- dimen_base + page_bottom_offset_code, dimen_base);
- primitive_pdftex("pdfliteral", extension_cmd, pdf_literal_node, 0);
- primitive_pdftex("pdfcolorstack", extension_cmd, pdf_colorstack_node, 0);
- primitive_pdftex("pdfsetmatrix", extension_cmd, pdf_setmatrix_node, 0);
- primitive_pdftex("pdfsave", extension_cmd, pdf_save_node, 0);
- primitive_pdftex("pdfrestore", extension_cmd, pdf_restore_node, 0);
- primitive_pdftex("pdfobj", extension_cmd, pdf_obj_code, 0);
- primitive_pdftex("pdfrefobj", extension_cmd, pdf_refobj_node, 0);
- primitive_pdftex("pdfxform", extension_cmd, pdf_xform_code, 0);
- primitive_pdftex("pdfrefxform", extension_cmd, pdf_refxform_node, 0);
- primitive_pdftex("pdfximage", extension_cmd, pdf_ximage_code, 0);
- primitive_pdftex("pdfrefximage", extension_cmd, pdf_refximage_node, 0);
- primitive_pdftex("pdfannot", extension_cmd, pdf_annot_node, 0);
- primitive_pdftex("pdfstartlink", extension_cmd, pdf_start_link_node, 0);
- primitive_pdftex("pdfendlink", extension_cmd, pdf_end_link_node, 0);
- primitive_pdftex("pdfoutline", extension_cmd, pdf_outline_code, 0);
- primitive_pdftex("pdfdest", extension_cmd, pdf_dest_node, 0);
- primitive_pdftex("pdfthread", extension_cmd, pdf_thread_node, 0);
- primitive_pdftex("pdfstartthread", extension_cmd, pdf_start_thread_node, 0);
- primitive_pdftex("pdfendthread", extension_cmd, pdf_end_thread_node, 0);
- primitive_luatex("savepos", extension_cmd, save_pos_node, 0);
- primitive_pdftex("pdfinfo", extension_cmd, pdf_info_code, 0);
- primitive_pdftex("pdfcatalog", extension_cmd, pdf_catalog_code, 0);
- primitive_pdftex("pdfnames", extension_cmd, pdf_names_code, 0);
- primitive_pdftex("pdfincludechars", extension_cmd, pdf_include_chars_code,
- 0);
- primitive_pdftex("pdffontattr", extension_cmd, pdf_font_attr_code, 0);
- primitive_pdftex("pdfmapfile", extension_cmd, pdf_map_file_code, 0);
- primitive_pdftex("pdfmapline", extension_cmd, pdf_map_line_code, 0);
- primitive_pdftex("pdftrailer", extension_cmd, pdf_trailer_code, 0);
- primitive_luatex("savecatcodetable", extension_cmd,
- save_cat_code_table_code, 0);
- primitive_luatex("initcatcodetable", extension_cmd,
- init_cat_code_table_code, 0);
- primitive_luatex("setrandomseed", extension_cmd, set_random_seed_code,
- 0);
- primitive_luatex("latelua", extension_cmd, late_lua_node, 0);
- primitive_pdftex("expandglyphsinfont", extension_cmd, font_expand_code, 0);
- primitive_pdftex("pdfglyphtounicode", extension_cmd,
- pdf_glyph_to_unicode_code, 0);
-
- /* some of the internal integer parameters are not associated with actual
- primitives at all. */
-
- primitive_no("nolocalwhatsits", assign_int_cmd,
- int_base + no_local_whatsits_code, int_base);
- primitive_no("nolocaldirs", assign_int_cmd,
- int_base + no_local_dirs_code, int_base);
+ primitive_luatex("localinterlinepenalty", assign_int_cmd, int_base + local_inter_line_penalty_code, int_base);
+ primitive_luatex("localbrokenpenalty", assign_int_cmd, int_base + local_broken_penalty_code, int_base);
+ primitive_luatex("pagedir", assign_dir_cmd, int_base + page_direction_code, dir_base);
+ primitive_luatex("bodydir", assign_dir_cmd, int_base + body_direction_code, dir_base);
+ primitive_luatex("pardir", assign_dir_cmd, int_base + par_direction_code, dir_base);
+ primitive_luatex("textdir", assign_dir_cmd, int_base + text_direction_code, dir_base);
+ primitive_luatex("mathdir", assign_dir_cmd, int_base + math_direction_code, dir_base);
+ primitive_luatex("pageleftoffset", assign_dimen_cmd, dimen_base + page_left_offset_code, dimen_base);
+ primitive_luatex("pagetopoffset", assign_dimen_cmd, dimen_base + page_top_offset_code, dimen_base);
+ primitive_luatex("pagerightoffset", assign_dimen_cmd, dimen_base + page_right_offset_code, dimen_base);
+ primitive_luatex("pagebottomoffset", assign_dimen_cmd, dimen_base + page_bottom_offset_code, dimen_base);
+ primitive_luatex("saveboxresource", extension_cmd, save_box_resource_code, 0);
+ primitive_luatex("useboxresource", extension_cmd, use_box_resource_code, 0);
+ primitive_luatex("saveimageresource", extension_cmd, save_image_resource_code, 0);
+ primitive_luatex("useimageresource", extension_cmd, use_image_resource_code, 0);
+ primitive_luatex("savepos", normal_cmd, save_pos_code, 0);
+ primitive_luatex("savecatcodetable", normal_cmd, save_cat_code_table_code, 0);
+ primitive_luatex("initcatcodetable", normal_cmd, init_cat_code_table_code, 0);
+ primitive_luatex("setrandomseed", normal_cmd, set_random_seed_code, 0);
+ primitive_luatex("latelua", normal_cmd, late_lua_code, 0);
+ primitive_luatex("insertht", convert_cmd, insert_ht_code, 0);
+ primitive_luatex("dviextension", extension_cmd, dvi_extension_code, 0);
+ primitive_luatex("dvifeedback", convert_cmd, dvi_feedback_code, 0);
+ primitive_luatex("dvivariable", convert_cmd, dvi_variable_code, 0);
+ primitive_luatex("pdfextension", extension_cmd, pdf_extension_code, 0);
+ primitive_luatex("pdffeedback", convert_cmd, pdf_feedback_code, 0);
+ primitive_luatex("pdfvariable", convert_cmd, pdf_variable_code, 0);
+ primitive_luatex("mathoption", option_cmd, math_option_code, 0);
+
+ /*
+ some of the internal integer parameters are not associated with actual
+ primitives at all.
+ */
+ primitive_no("nolocalwhatsits", assign_int_cmd, int_base + no_local_whatsits_code, int_base);
+ primitive_no("nolocaldirs", assign_int_cmd, int_base + no_local_dirs_code, int_base);
@ @c
@@ -1011,50 +710,35 @@ void initialize_etex_commands(void)
{
primitive_etex("lastnodetype", last_item_cmd, last_node_type_code, 0);
primitive_etex("eTeXversion", last_item_cmd, eTeX_version_code, 0);
- primitive_etex("eTeXminorversion", last_item_cmd, eTeX_minor_version_code,
- 0);
+ primitive_etex("eTeXminorversion", last_item_cmd, eTeX_minor_version_code, 0);
primitive_etex("eTeXrevision", convert_cmd, eTeX_revision_code, 0);
- /* First we implement the additional \eTeX\ parameters in the table of equivalents. */
+ /*
+ First we implement the additional \eTeX\ parameters in the table of equivalents.
+ */
primitive_etex("everyeof", assign_toks_cmd, every_eof_loc, local_base);
- primitive_etex("tracingassigns", assign_int_cmd,
- int_base + tracing_assigns_code, int_base);
- primitive_etex("tracinggroups", assign_int_cmd,
- int_base + tracing_groups_code, int_base);
- primitive_etex("tracingifs", assign_int_cmd, int_base + tracing_ifs_code,
- int_base);
- primitive_etex("tracingscantokens", assign_int_cmd,
- int_base + tracing_scan_tokens_code, int_base);
- primitive_etex("tracingnesting", assign_int_cmd,
- int_base + tracing_nesting_code, int_base);
- primitive_etex("predisplaydirection", assign_int_cmd,
- int_base + pre_display_direction_code, int_base);
- primitive_etex("lastlinefit", assign_int_cmd, int_base + last_line_fit_code,
- int_base);
- primitive_etex("savingvdiscards", assign_int_cmd,
- int_base + saving_vdiscards_code, int_base);
- primitive_etex("savinghyphcodes", assign_int_cmd,
- int_base + saving_hyph_codes_code, int_base);
- primitive_luatex("suppressfontnotfounderror", assign_int_cmd,
- int_base + suppress_fontnotfound_error_code, int_base);
- primitive_luatex("suppresslongerror", assign_int_cmd,
- int_base + suppress_long_error_code, int_base);
- primitive_luatex("suppressmathparerror", assign_int_cmd,
- int_base + suppress_mathpar_error_code, int_base);
- primitive_luatex("suppressifcsnameerror", assign_int_cmd,
- int_base + suppress_ifcsname_error_code, int_base);
- primitive_luatex("suppressoutererror", assign_int_cmd,
- int_base + suppress_outer_error_code, int_base);
- primitive_luatex("matheqnogapstep", assign_int_cmd,
- int_base + math_eqno_gap_step_code, int_base);
- primitive_luatex("synctex", assign_int_cmd, int_base + synctex_code,
- int_base);
-
- primitive_etex("currentgrouplevel", last_item_cmd, current_group_level_code,
- 0);
- primitive_etex("currentgrouptype", last_item_cmd, current_group_type_code,
- 0);
+ primitive_etex("tracingassigns", assign_int_cmd, int_base + tracing_assigns_code, int_base);
+ primitive_etex("tracinggroups", assign_int_cmd, int_base + tracing_groups_code, int_base);
+ primitive_etex("tracingifs", assign_int_cmd, int_base + tracing_ifs_code, int_base);
+ primitive_etex("tracingscantokens", assign_int_cmd, int_base + tracing_scan_tokens_code, int_base);
+ primitive_etex("tracingnesting", assign_int_cmd, int_base + tracing_nesting_code, int_base);
+ primitive_etex("predisplaydirection", assign_int_cmd, int_base + pre_display_direction_code, int_base);
+ primitive_etex("lastlinefit", assign_int_cmd, int_base + last_line_fit_code, int_base);
+ primitive_etex("savingvdiscards", assign_int_cmd, int_base + saving_vdiscards_code, int_base);
+ primitive_etex("savinghyphcodes", assign_int_cmd, int_base + saving_hyph_codes_code, int_base);
+ primitive_luatex("suppressfontnotfounderror", assign_int_cmd, int_base + suppress_fontnotfound_error_code, int_base);
+ primitive_luatex("suppresslongerror", assign_int_cmd, int_base + suppress_long_error_code, int_base);
+ primitive_luatex("suppressmathparerror", assign_int_cmd, int_base + suppress_mathpar_error_code, int_base);
+ primitive_luatex("suppressifcsnameerror", assign_int_cmd, int_base + suppress_ifcsname_error_code, int_base);
+ primitive_luatex("suppressoutererror", assign_int_cmd, int_base + suppress_outer_error_code, int_base);
+ primitive_luatex("matheqnogapstep", assign_int_cmd, int_base + math_eqno_gap_step_code, int_base);
+ primitive_luatex("mathdisplayskipmode", assign_int_cmd, int_base + math_display_skip_mode_code, int_base);
+ primitive_luatex("mathscriptsmode", assign_int_cmd, int_base + math_scripts_mode_code, int_base);
+ primitive_luatex("synctex", assign_int_cmd, int_base + synctex_code, int_base);
+
+ primitive_etex("currentgrouplevel", last_item_cmd, current_group_level_code, 0);
+ primitive_etex("currentgrouptype", last_item_cmd, current_group_type_code, 0);
primitive_etex("currentiflevel", last_item_cmd, current_if_level_code, 0);
primitive_etex("currentiftype", last_item_cmd, current_if_type_code, 0);
@@ -1069,29 +753,41 @@ void initialize_etex_commands(void)
primitive_etex("parshapedimen", last_item_cmd, par_shape_dimen_code, 0);
primitive_etex("showgroups", xray_cmd, show_groups, 0);
- /* The \.{\\showtokens} command displays a token list. */
+
+ /*
+ The \.{\\showtokens} command displays a token list.
+ */
+
primitive_etex("showtokens", xray_cmd, show_tokens, 0);
+
/*
- The \.{\\unexpanded} primitive prevents expansion of tokens much as
- the result from \.{\\the} applied to a token variable. The
- \.{\\detokenize} primitive converts a token list into a list of
- character tokens much as if the token list were written to a file. We
- use the fact that the command modifiers for \.{\\unexpanded} and
- \.{\\detokenize} are odd whereas those for \.{\\the} and \.{\\showthe}
- are even.
- */
+ The \.{\\unexpanded} primitive prevents expansion of tokens much as
+ the result from \.{\\the} applied to a token variable. The
+ \.{\\detokenize} primitive converts a token list into a list of
+ character tokens much as if the token list were written to a file. We
+ use the fact that the command modifiers for \.{\\unexpanded} and
+ \.{\\detokenize} are odd whereas those for \.{\\the} and \.{\\showthe}
+ are even.
+ */
+
primitive_etex("unexpanded", the_cmd, 1, 0);
primitive_etex("detokenize", the_cmd, show_tokens, 0);
- /* The \.{\\showifs} command displays all currently active conditionals. */
+ /*
+ The \.{\\showifs} command displays all currently active conditionals.
+ */
primitive_etex("showifs", xray_cmd, show_ifs, 0);
- /* The \.{\\interactionmode} primitive allows to query and set the interaction mode. */
+ /*
+ The \.{\\interactionmode} primitive allows to query and set the interaction mode.
+ */
primitive_etex("interactionmode", set_page_int_cmd, 2, 0);
- /* The |scan_tokens| feature of \eTeX\ defines the \.{\\scantokens} primitive. */
+ /*
+ The |scan_tokens| feature of \eTeX\ defines the \.{\\scantokens} primitive.
+ */
primitive_etex("scantokens", input_cmd, 2, 0);
primitive_luatex("scantextokens", input_cmd, 3, 0);
@@ -1106,26 +802,25 @@ void initialize_etex_commands(void)
primitive_luatex("ifabsnum", if_test_cmd, if_abs_num_code, 0);
primitive_luatex("ifabsdim", if_test_cmd, if_abs_dim_code, 0);
- /* The |protected| feature of \eTeX\ defines the \.{\\protected} prefix
- command for macro definitions. Such macros are protected against
- expansions when lists of expanded tokens are built, e.g., for \.{\\edef}
- or during \.{\\write}. */
+ /*
+ The |protected| feature of \eTeX\ defines the \.{\\protected} prefix
+ command for macro definitions. Such macros are protected against
+ expansions when lists of expanded tokens are built, e.g., for \.{\\edef}
+ or during \.{\\write}.
+ */
primitive_etex("protected", prefix_cmd, 8, 0);
- /* Here are the additional \eTeX\ primitives for expressions. */
+ /*
+ Here are the additional \eTeX\ primitives for expressions.
+ */
- primitive_etex("numexpr", last_item_cmd,
- eTeX_expr - int_val_level + int_val_level, 0);
- primitive_etex("dimexpr", last_item_cmd,
- eTeX_expr - int_val_level + dimen_val_level, 0);
- primitive_etex("glueexpr", last_item_cmd,
- eTeX_expr - int_val_level + glue_val_level, 0);
- primitive_etex("muexpr", last_item_cmd,
- eTeX_expr - int_val_level + mu_val_level, 0);
+ primitive_etex("numexpr", last_item_cmd, eTeX_expr - int_val_level + int_val_level, 0);
+ primitive_etex("dimexpr", last_item_cmd, eTeX_expr - int_val_level + dimen_val_level, 0);
+ primitive_etex("glueexpr", last_item_cmd, eTeX_expr - int_val_level + glue_val_level, 0);
+ primitive_etex("muexpr", last_item_cmd, eTeX_expr - int_val_level + mu_val_level, 0);
- primitive_etex("gluestretchorder", last_item_cmd, glue_stretch_order_code,
- 0);
+ primitive_etex("gluestretchorder", last_item_cmd, glue_stretch_order_code, 0);
primitive_etex("glueshrinkorder", last_item_cmd, glue_shrink_order_code, 0);
primitive_etex("gluestretch", last_item_cmd, glue_stretch_code, 0);
primitive_etex("glueshrink", last_item_cmd, glue_shrink_code, 0);
@@ -1133,25 +828,26 @@ void initialize_etex_commands(void)
primitive_etex("mutoglue", last_item_cmd, mu_to_glue_code, 0);
primitive_etex("gluetomu", last_item_cmd, glue_to_mu_code, 0);
- /* The \.{\\pagediscards} and \.{\\splitdiscards} commands share the
- command code |un_vbox| with \.{\\unvbox} and \.{\\unvcopy}, they are
- distinguished by their |chr_code| values |last_box_code| and
- |vsplit_code|. These |chr_code| values are larger than |box_code| and
- |copy_code|. */
+ /*
+ The \.{\\pagediscards} and \.{\\splitdiscards} commands share the
+ command code |un_vbox| with \.{\\unvbox} and \.{\\unvcopy}, they are
+ distinguished by their |chr_code| values |last_box_code| and
+ |vsplit_code|. These |chr_code| values are larger than |box_code| and
+ |copy_code|.
+ */
primitive_etex("pagediscards", un_vbox_cmd, last_box_code, 0);
primitive_etex("splitdiscards", un_vbox_cmd, vsplit_code, 0);
- /* The \.{\\interlinepenalties}, \.{\\clubpenalties}, \.{\\widowpenalties},
- and \.{\\displaywidowpenalties} commands allow to define arrays of
- penalty values to be used instead of the corresponding single values. */
- primitive_etex("interlinepenalties", set_etex_shape_cmd,
- inter_line_penalties_loc, etex_pen_base);
- primitive_etex("clubpenalties", set_etex_shape_cmd, club_penalties_loc,
- etex_pen_base);
- primitive_etex("widowpenalties", set_etex_shape_cmd, widow_penalties_loc,
- etex_pen_base);
- primitive_etex("displaywidowpenalties", set_etex_shape_cmd,
- display_widow_penalties_loc, etex_pen_base);
+ /*
+ The \.{\\interlinepenalties}, \.{\\clubpenalties}, \.{\\widowpenalties},
+ and \.{\\displaywidowpenalties} commands allow to define arrays of
+ penalty values to be used instead of the corresponding single values.
+ */
+
+ primitive_etex("interlinepenalties", set_etex_shape_cmd, inter_line_penalties_loc, etex_pen_base);
+ primitive_etex("clubpenalties", set_etex_shape_cmd, club_penalties_loc, etex_pen_base);
+ primitive_etex("widowpenalties", set_etex_shape_cmd, widow_penalties_loc, etex_pen_base);
+ primitive_etex("displaywidowpenalties", set_etex_shape_cmd, display_widow_penalties_loc, etex_pen_base);
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/conditional.w b/Build/source/texk/web2c/luatexdir/tex/conditional.w
index 8c312a536c8..4c25a7a922f 100644
--- a/Build/source/texk/web2c/luatexdir/tex/conditional.w
+++ b/Build/source/texk/web2c/luatexdir/tex/conditional.w
@@ -25,7 +25,7 @@
@ @c
#define box(A) eqtb[box_base+(A)].hh.rh
-@* We consider now the way \TeX\ handles various kinds of \.{\\if} commands.
+@* We consider now the way \TeX\ handles various kinds of \.{\\if} commands.
@ Conditions can be inside conditions, and this nesting has a stack
that is independent of the |save_stack|.
@@ -73,7 +73,7 @@ void pass_text(void)
l = 0;
skip_line = line;
while (1) {
- get_token_lua();
+ get_next(); /* get_token_lua(); */
if (cur_cmd == fi_or_else_cmd) {
if (l == 0)
break;
@@ -381,11 +381,11 @@ void conditional(void)
*/
save_scanner_status = scanner_status;
scanner_status = normal;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
n = cur_cs;
p = cur_cmd;
q = cur_chr;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
if (cur_cmd != p) {
b = false;
} else if (cur_cmd < call_cmd) {
@@ -418,8 +418,9 @@ void conditional(void)
scanner_status = save_scanner_status;
break;
case if_eof_code:
+ /* bad this system check here as it's an extension*/
scan_four_bit_int_or_18();
- if (cur_val == 18)
+ if (cur_val == write_target_system)
b = !shellenabledp;
else
b = (read_open[cur_val] == closed);
@@ -459,7 +460,7 @@ void conditional(void)
case if_primitive_code:
save_scanner_status = scanner_status;
scanner_status = normal;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
scanner_status = save_scanner_status;
m = prim_lookup(cs_text(cur_cs));
b = ((cur_cmd != undefined_cs_cmd) &&
@@ -473,7 +474,7 @@ void conditional(void)
are allowed, but we might be scanning a macro definition or preamble. */
save_scanner_status = scanner_status;
scanner_status = normal;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
b = (cur_cmd != undefined_cs_cmd);
scanner_status = save_scanner_status;
break;
diff --git a/Build/source/texk/web2c/luatexdir/tex/directions.h b/Build/source/texk/web2c/luatexdir/tex/directions.h
index b595032f48e..34a89cc29a2 100644
--- a/Build/source/texk/web2c/luatexdir/tex/directions.h
+++ b/Build/source/texk/web2c/luatexdir/tex/directions.h
@@ -21,307 +21,108 @@
#ifndef DIRECTIONS_H
# define DIRECTIONS_H
-# define dir_T 0
-# define dir_L 1
-# define dir_B 2
-# define dir_R 3
-
-# define dir_TLT 0
-# define dir_TRT 4
-# define dir_LTL 9
-# define dir_RTT 24
-
-extern const char *dir_strings[128];
-
- /* # define dir_array_size 25 *//* |dir_RTT + 1| */
-
-/* inv(primary) == tertiary */
/*
-boolean _is_mirrored[dir_array_size];
-_is_mirrored[dir_TLT] = 0;
-_is_mirrored[dir_TRT] = 0;
-_is_mirrored[dir_LTL] = 0;
-_is_mirrored[dir_RTT] = 0;
-*/
-
-# define is_mirrored(a) 0
+ # define dir_TLT 0
+ # define dir_TRT 4
+ # define dir_LTL 9
+ # define dir_RTT 24
-/* secondary == tertiary */
-/*
-boolean _is_rotated[dir_array_size];
-_is_rotated[dir_TLT] = 0;
-_is_rotated[dir_TRT] = 0;
-_is_rotated[dir_LTL] = 0;
-_is_rotated[dir_RTT] = 1;
+ extern const char *dir_strings[128];
*/
-# define is_rotated(a) (a == dir_RTT)
+# define dir_TLT 0 /* maybe use this one as unset value */
+# define dir_TRT 1 /* or swhould we avoid that one because it's a signal too */
+# define dir_LTL 2
+# define dir_RTT 3
-/* secondary == secondary */
-/*
-boolean _textdir_parallel[dir_array_size][dir_array_size];
-_textdir_parallel[dir_TLT][dir_TLT] = 1;
-_textdir_parallel[dir_TLT][dir_TRT] = 1;
-_textdir_parallel[dir_TLT][dir_LTL] = 0;
-_textdir_parallel[dir_TLT][dir_RTT] = 0;
-_textdir_parallel[dir_TRT][dir_TLT] = 1;
-_textdir_parallel[dir_TRT][dir_TRT] = 1;
-_textdir_parallel[dir_TRT][dir_LTL] = 0;
-_textdir_parallel[dir_TRT][dir_RTT] = 0;
-_textdir_parallel[dir_LTL][dir_TLT] = 0;
-_textdir_parallel[dir_LTL][dir_TRT] = 0;
-_textdir_parallel[dir_LTL][dir_LTL] = 1;
-_textdir_parallel[dir_LTL][dir_RTT] = 1;
-_textdir_parallel[dir_RTT][dir_TLT] = 0;
-_textdir_parallel[dir_RTT][dir_TRT] = 0;
-_textdir_parallel[dir_RTT][dir_LTL] = 1;
-_textdir_parallel[dir_RTT][dir_RTT] = 1;
-*/
+extern const char *dir_strings[8];
-# define textdir_parallel(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT)) || \
- ((a == dir_LTL || a == dir_RTT)&&(b == dir_LTL || b == dir_RTT)))
+extern int dir_swap;
+# define RETURN_DIR_VALUES(a) \
+ if (s==luaS_##a##_ptr) { \
+ return (dir_##a); \
+ } else if (!absolute_only) { \
+ if (s==luaS_p##a##_ptr) \
+ return (dir_##a); \
+ else if (s==luaS_m##a##_ptr) \
+ return ((dir_##a)-4); \
+ }
-/* primary == primary */
-/*
-boolean _pardir_parallel[dir_array_size][dir_array_size];
-_pardir_parallel[dir_TLT][dir_TLT] = 1;
-_pardir_parallel[dir_TLT][dir_TRT] = 1;
-_pardir_parallel[dir_TLT][dir_LTL] = 0;
-_pardir_parallel[dir_TLT][dir_RTT] = 0;
-_pardir_parallel[dir_TRT][dir_TLT] = 1;
-_pardir_parallel[dir_TRT][dir_TRT] = 1;
-_pardir_parallel[dir_TRT][dir_LTL] = 0;
-_pardir_parallel[dir_TRT][dir_RTT] = 0;
-_pardir_parallel[dir_LTL][dir_TLT] = 0;
-_pardir_parallel[dir_LTL][dir_TRT] = 0;
-_pardir_parallel[dir_LTL][dir_LTL] = 1;
-_pardir_parallel[dir_LTL][dir_RTT] = 1;
-_pardir_parallel[dir_RTT][dir_TLT] = 0;
-_pardir_parallel[dir_RTT][dir_TRT] = 0;
-_pardir_parallel[dir_RTT][dir_LTL] = 1;
-_pardir_parallel[dir_RTT][dir_RTT] = 1;
-*/
+# define BOX_DIR_VALUE(a) \
+ ((s==luaS_p##a##_ptr) : (dir_##a) ? ((s==luaS_m##a##_ptr) : ((dir_##a)-4) ? luaS_pTLT))
+# define is_mirrored(a) 0
-# define pardir_parallel(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT)) || \
- ((a == dir_LTL || a == dir_RTT)&&(b == dir_LTL || b == dir_RTT)))
-
-
-/* inv(primary) == primary */
-/*
-boolean _pardir_opposite[dir_array_size][dir_array_size];
-_pardir_opposite[dir_TLT][dir_TLT] = 0;
-_pardir_opposite[dir_TLT][dir_TRT] = 0;
-_pardir_opposite[dir_TLT][dir_LTL] = 0;
-_pardir_opposite[dir_TLT][dir_RTT] = 0;
-_pardir_opposite[dir_TRT][dir_TLT] = 0;
-_pardir_opposite[dir_TRT][dir_TRT] = 0;
-_pardir_opposite[dir_TRT][dir_LTL] = 0;
-_pardir_opposite[dir_TRT][dir_RTT] = 0;
-_pardir_opposite[dir_LTL][dir_TLT] = 0;
-_pardir_opposite[dir_LTL][dir_TRT] = 0;
-_pardir_opposite[dir_LTL][dir_LTL] = 0;
-_pardir_opposite[dir_LTL][dir_RTT] = 1;
-_pardir_opposite[dir_RTT][dir_TLT] = 0;
-_pardir_opposite[dir_RTT][dir_TRT] = 0;
-_pardir_opposite[dir_RTT][dir_LTL] = 1;
-_pardir_opposite[dir_RTT][dir_RTT] = 0;
-*/
-
-# define pardir_opposite(a,b) ((a == dir_LTL && b == dir_RTT)||(a == dir_RTT && b == dir_LTL))
-
+# define is_rotated(a) (a == dir_RTT)
-/* inv(secondary) == secondary */
-/*
-boolean _textdir_opposite[dir_array_size][dir_array_size];
-_textdir_opposite[dir_TLT][dir_TLT] = 0;
-_textdir_opposite[dir_TLT][dir_TRT] = 1;
-_textdir_opposite[dir_TLT][dir_LTL] = 0;
-_textdir_opposite[dir_TLT][dir_RTT] = 0;
-_textdir_opposite[dir_TRT][dir_TLT] = 1;
-_textdir_opposite[dir_TRT][dir_TRT] = 0;
-_textdir_opposite[dir_TRT][dir_LTL] = 0;
-_textdir_opposite[dir_TRT][dir_RTT] = 0;
-_textdir_opposite[dir_LTL][dir_TLT] = 0;
-_textdir_opposite[dir_LTL][dir_TRT] = 0;
-_textdir_opposite[dir_LTL][dir_LTL] = 0;
-_textdir_opposite[dir_LTL][dir_RTT] = 0;
-_textdir_opposite[dir_RTT][dir_TLT] = 0;
-_textdir_opposite[dir_RTT][dir_TRT] = 0;
-_textdir_opposite[dir_RTT][dir_LTL] = 0;
-_textdir_opposite[dir_RTT][dir_RTT] = 0;
-*/
+# define textdir_parallel(a,b) ( \
+ ((a == dir_TLT || a == dir_TRT) && (b == dir_TLT || b == dir_TRT)) || \
+ ((a == dir_LTL || a == dir_RTT) && (b == dir_LTL || b == dir_RTT)) \
+)
-# define textdir_opposite(a,b) ((a == dir_TLT && b == dir_TRT)||(a == dir_TRT && b == dir_TLT))
+# define pardir_parallel(a,b) ( \
+ ((a == dir_TLT || a == dir_TRT) && (b == dir_TLT || b == dir_TRT)) || \
+ ((a == dir_LTL || a == dir_RTT) && (b == dir_LTL || b == dir_RTT)) \
+)
+# define pardir_opposite(a,b) ( \
+ (a == dir_LTL && b == dir_RTT) || \
+ (a == dir_RTT && b == dir_LTL) \
+)
-/* inv(tertiary) == tertiary */
-/*
-boolean _glyphdir_opposite[dir_array_size][dir_array_size];
-_glyphdir_opposite[dir_TLT][dir_TLT] = 0;
-_glyphdir_opposite[dir_TLT][dir_TRT] = 0;
-_glyphdir_opposite[dir_TLT][dir_LTL] = 0;
-_glyphdir_opposite[dir_TLT][dir_RTT] = 0;
-_glyphdir_opposite[dir_TRT][dir_TLT] = 0;
-_glyphdir_opposite[dir_TRT][dir_TRT] = 0;
-_glyphdir_opposite[dir_TRT][dir_LTL] = 0;
-_glyphdir_opposite[dir_TRT][dir_RTT] = 0;
-_glyphdir_opposite[dir_LTL][dir_TLT] = 0;
-_glyphdir_opposite[dir_LTL][dir_TRT] = 0;
-_glyphdir_opposite[dir_LTL][dir_LTL] = 0;
-_glyphdir_opposite[dir_LTL][dir_RTT] = 0;
-_glyphdir_opposite[dir_RTT][dir_TLT] = 0;
-_glyphdir_opposite[dir_RTT][dir_TRT] = 0;
-_glyphdir_opposite[dir_RTT][dir_LTL] = 0;
-_glyphdir_opposite[dir_RTT][dir_RTT] = 0;
-*/
+# define textdir_opposite(a,b) ( \
+ (a == dir_TLT && b == dir_TRT) || \
+ (a == dir_TRT && b == dir_TLT) \
+)
# define glyphdir_opposite(a,b) 0
-
-/* primary == primary */
-/*
-boolean _pardir_eq[dir_array_size][dir_array_size];
-_pardir_eq[dir_TLT][dir_TLT] = 1;
-_pardir_eq[dir_TLT][dir_TRT] = 1;
-_pardir_eq[dir_TLT][dir_LTL] = 0;
-_pardir_eq[dir_TLT][dir_RTT] = 0;
-_pardir_eq[dir_TRT][dir_TLT] = 1;
-_pardir_eq[dir_TRT][dir_TRT] = 1;
-_pardir_eq[dir_TRT][dir_LTL] = 0;
-_pardir_eq[dir_TRT][dir_RTT] = 0;
-_pardir_eq[dir_LTL][dir_TLT] = 0;
-_pardir_eq[dir_LTL][dir_TRT] = 0;
-_pardir_eq[dir_LTL][dir_LTL] = 1;
-_pardir_eq[dir_LTL][dir_RTT] = 0;
-_pardir_eq[dir_RTT][dir_TLT] = 0;
-_pardir_eq[dir_RTT][dir_TRT] = 0;
-_pardir_eq[dir_RTT][dir_LTL] = 0;
-_pardir_eq[dir_RTT][dir_RTT] = 1;
-*/
-
-# define pardir_eq(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT))|| \
- (a == dir_LTL && b == dir_LTL) || \
- (a == dir_RTT && b == dir_RTT))
-
-/* secondary == secondary */
-/*
-boolean _textdir_eq[dir_array_size][dir_array_size];
-_textdir_eq[dir_TLT][dir_TLT] = 1;
-_textdir_eq[dir_TLT][dir_TRT] = 0;
-_textdir_eq[dir_TLT][dir_LTL] = 0;
-_textdir_eq[dir_TLT][dir_RTT] = 0;
-_textdir_eq[dir_TRT][dir_TLT] = 0;
-_textdir_eq[dir_TRT][dir_TRT] = 1;
-_textdir_eq[dir_TRT][dir_LTL] = 0;
-_textdir_eq[dir_TRT][dir_RTT] = 0;
-_textdir_eq[dir_LTL][dir_TLT] = 0;
-_textdir_eq[dir_LTL][dir_TRT] = 0;
-_textdir_eq[dir_LTL][dir_LTL] = 1;
-_textdir_eq[dir_LTL][dir_RTT] = 1;
-_textdir_eq[dir_RTT][dir_TLT] = 0;
-_textdir_eq[dir_RTT][dir_TRT] = 0;
-_textdir_eq[dir_RTT][dir_LTL] = 1;
-_textdir_eq[dir_RTT][dir_RTT] = 1;
-*/
-
-# define textdir_eq(a,b) ((a == dir_TLT && b == dir_TLT) || \
- (a == dir_TRT && b == dir_TRT) || \
- (a == dir_LTL && (b == dir_LTL || b == dir_RTT)) || \
- (a == dir_RTT && (b == dir_LTL || b == dir_RTT))
-
-
-/* tertiary == tertiary */
-/*
-boolean _glyphdir_eq[dir_array_size][dir_array_size];
-_glyphdir_eq[dir_TLT][dir_TLT] = 1;
-_glyphdir_eq[dir_TLT][dir_TRT] = 1;
-_glyphdir_eq[dir_TLT][dir_LTL] = 0;
-_glyphdir_eq[dir_TLT][dir_RTT] = 1;
-_glyphdir_eq[dir_TRT][dir_TLT] = 1;
-_glyphdir_eq[dir_TRT][dir_TRT] = 1;
-_glyphdir_eq[dir_TRT][dir_LTL] = 0;
-_glyphdir_eq[dir_TRT][dir_RTT] = 1;
-_glyphdir_eq[dir_LTL][dir_TLT] = 0;
-_glyphdir_eq[dir_LTL][dir_TRT] = 0;
-_glyphdir_eq[dir_LTL][dir_LTL] = 1;
-_glyphdir_eq[dir_LTL][dir_RTT] = 0;
-_glyphdir_eq[dir_RTT][dir_TLT] = 1;
-_glyphdir_eq[dir_RTT][dir_TRT] = 1;
-_glyphdir_eq[dir_RTT][dir_LTL] = 0;
-_glyphdir_eq[dir_RTT][dir_RTT] = 1;
-*/
-
-# define glyphdir_eq(a,b) ((a != dir_LTL && b != dir_LTL) || \
- (a == dir_LTL && b == dir_LTL))
-
-
-/* primary == secondary */
-/*
-boolean _partextdir_eq[dir_array_size][dir_array_size];
-_partextdir_eq[dir_TLT][dir_TLT] = 0;
-_partextdir_eq[dir_TLT][dir_TRT] = 0;
-_partextdir_eq[dir_TLT][dir_LTL] = 1;
-_partextdir_eq[dir_TLT][dir_RTT] = 1;
-_partextdir_eq[dir_TRT][dir_TLT] = 0;
-_partextdir_eq[dir_TRT][dir_TRT] = 0;
-_partextdir_eq[dir_TRT][dir_LTL] = 1;
-_partextdir_eq[dir_TRT][dir_RTT] = 1;
-_partextdir_eq[dir_LTL][dir_TLT] = 1;
-_partextdir_eq[dir_LTL][dir_TRT] = 0;
-_partextdir_eq[dir_LTL][dir_LTL] = 0;
-_partextdir_eq[dir_LTL][dir_RTT] = 0;
-_partextdir_eq[dir_RTT][dir_TLT] = 0;
-_partextdir_eq[dir_RTT][dir_TRT] = 1;
-_partextdir_eq[dir_RTT][dir_LTL] = 0;
-_partextdir_eq[dir_RTT][dir_RTT] = 0;
-*/
-
-# define partextdir_eq(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_LTL || b == dir_RTT)) || \
- (a == dir_LTL && b == dir_TLT) || \
- (a == dir_RTT && b == dir_TRT))
-
-
-/* secondary != tertiary */
-/*
-boolean _textglyphdir_orthogonal[dir_array_size]
-_textglyphdir_orthogonal[dir_TLT] = 1;
-_textglyphdir_orthogonal[dir_TRT] = 1;
-_textglyphdir_orthogonal[dir_LTL] = 1;
-_textglyphdir_orthogonal[dir_RTT] = 0;
-*/
+# define pardir_eq(a,b) ( \
+ ((a == dir_TLT || a == dir_TRT) && (b == dir_TLT || b == dir_TRT)) || \
+ (a == dir_LTL && b == dir_LTL) || \
+ (a == dir_RTT && b == dir_RTT) \
+)
+
+# define textdir_eq(a,b) ( \
+ (a == dir_TLT && b == dir_TLT) || \
+ (a == dir_TRT && b == dir_TRT) || \
+ (a == dir_LTL && (b == dir_LTL || b == dir_RTT)) || \
+ (a == dir_RTT && (b == dir_LTL || b == dir_RTT) \
+)
+
+# define glyphdir_eq(a,b) ( \
+ (a != dir_LTL && b != dir_LTL) || \
+ (a == dir_LTL && b == dir_LTL) \
+)
+
+# define partextdir_eq(a,b) ( \
+ ((a == dir_TLT || a == dir_TRT)&&(b == dir_LTL || b == dir_RTT)) || \
+ (a == dir_LTL && b == dir_TLT) || \
+ (a == dir_RTT && b == dir_TRT) \
+)
# define textglyphdir_orthogonal(a) (a != dir_RTT)
-/* secondary == L */
-/*
-boolean _textdir_is[dir_array_size];
-_textdir_is[dir_TLT] = 1;
-_textdir_is[dir_TRT] = 1;
-_textdir_is[dir_LTL] = 1;
-_textdir_is[dir_RTT] = 0;
-*/
-
# define textdir_is_L(a) (a == dir_TLT)
-# define push_dir(a,b) \
- { halfword dir_tmp=new_dir((a)); \
- vlink(dir_tmp)=b; \
- b=dir_tmp; \
- }
+# define push_dir(a,b) { \
+ halfword dir_tmp=new_dir((a)); \
+ vlink(dir_tmp)=b; \
+ b=dir_tmp; \
+}
-# define push_dir_node(a,b) \
- { halfword dir_tmp=copy_node((a)); \
- vlink(dir_tmp)=b; \
- b=dir_tmp; \
- }
+# define push_dir_node(a,b) { \
+ halfword dir_tmp=copy_node((a)); \
+ vlink(dir_tmp)=b; \
+ b=dir_tmp; \
+}
-# define pop_dir_node(b) \
- { halfword dir_tmp=b; \
- b=vlink(dir_tmp); \
- flush_node(dir_tmp); \
- }
+# define pop_dir_node(b) { \
+ halfword dir_tmp=b; \
+ b=vlink(dir_tmp); \
+ flush_node(dir_tmp); \
+}
extern halfword dir_ptr;
@@ -339,8 +140,7 @@ extern halfword do_push_dir_node(halfword p, halfword a);
extern halfword do_pop_dir_node(halfword p);
scaled pack_width(int curdir, int pdir, halfword p, boolean isglyph);
-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);
void update_text_dir_ptr(int val);
diff --git a/Build/source/texk/web2c/luatexdir/tex/directions.w b/Build/source/texk/web2c/luatexdir/tex/directions.w
index 54f5586bc6b..addde937df7 100644
--- a/Build/source/texk/web2c/luatexdir/tex/directions.w
+++ b/Build/source/texk/web2c/luatexdir/tex/directions.w
@@ -87,7 +87,7 @@ void initialize_directions(void)
halfword new_dir(int s)
{
halfword p; /* the new node */
- p = new_node(whatsit_node, dir_node);
+ p = new_node(dir_node, 0);
dir_dir(p) = s;
dir_dvi_ptr(p) = -1;
dir_level(p) = cur_level;
@@ -100,6 +100,8 @@ it here instead of there avoid the nodelib having to know
about the actual values of |dir_TRT| etc.
@c
+
+/*
const char *dir_strings[128] = {
"-TLT","???", "???", "???", "-TRT","???", "???", "???",
"???", "-LTL","???", "???", "???", "???", "???", "???",
@@ -116,19 +118,27 @@ const char *dir_strings[128] = {
"???", "???", "???", "???", "???", "???", "???", "???",
"???", "???", "???", "???", "???", "???", "???", "???",
"???", "???", "???", "???", "???", "???", "???", "???",
- "???", "???", "???", "???", "???", "???", "???", "???" };
+ "???", "???", "???", "???", "???", "???", "???", "???"
+};
+
+int dir_swap = 64;
+*/
+
+const char *dir_strings[8] = {
+ "-TLT","-TRT","-LTL","-RTT",
+ "+TLT","+TRT","+LTL","+RTT",
+};
+
+int dir_swap = 4;
const char *string_dir(int d)
{
- return (dir_strings[d+64]+1);
+ return (dir_strings[d+dir_swap]+1);
}
-
@ @c
void print_dir(int d)
{
- /* hh-ls: todo: just fetch the string pt from the registry ... then the above can go */
-
tprint(string_dir(d));
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
index a13a456072a..727951b9f32 100644
--- a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
+++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
@@ -26,8 +26,8 @@
#define prev_depth cur_list.prev_depth_field
/* 907 = sum of the values of the bytes of "don knuth" */
-/* The next FORMAT_ID will be 907+5 */
-#define FORMAT_ID (907+4)
+/* The next FORMAT_ID will be 907+7 */
+#define FORMAT_ID (907+6)
#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 02e53e381ab..f21bf04c6a0 100644
--- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -49,7 +49,6 @@ emphasize this distinction.
# define script_size 1 /* size code for the medium size in a family */
# define script_script_size 2 /* size code for the smallest size in a family */
-
/*
Each entry in |eqtb| is a |memory_word|. Most of these words are of type
|two_halves|, and subdivided into three fields:
@@ -71,7 +70,6 @@ This may be a font number, a pointer into |mem|, or a variety of other
things.
*/
-
/*
Many locations in |eqtb| have symbolic names. The purpose of the next
paragraphs is to define these names, and to set up the initial values of the
@@ -88,8 +86,6 @@ locations for control sequences that are perpetually defined
(since they are used in error recovery).
*/
-
-
/*
@ Region 3 of |eqtb| contains the |number_regs| \.{\\skip} registers, as well as the
glue parameters defined here. It is important that the ``muskip''
@@ -119,157 +115,146 @@ complete failure.
here, and the |number_regs| \.{\\dimen} registers.
*/
-# define null_cs 1 /* equivalent of \.{\\csname\\endcsname} */
-# define hash_base (null_cs+1) /* beginning of region 2, for the hash table */
-# define frozen_control_sequence (hash_base+hash_size) /* for error recovery */
-# define frozen_protection (frozen_control_sequence) /* inaccessible but definable */
-# define frozen_cr (frozen_control_sequence+1) /* permanent `\.{\\cr}' */
-# define frozen_end_group (frozen_control_sequence+2) /* permanent `\.{\\endgroup}' */
-# define frozen_right (frozen_control_sequence+3) /* permanent `\.{\\right}' */
-# define frozen_fi (frozen_control_sequence+4) /* permanent `\.{\\fi}' */
-# define frozen_end_template (frozen_control_sequence+5)
- /* permanent `\.{\\endtemplate}' */
-# define frozen_endv (frozen_control_sequence+6)
- /* second permanent `\.{\\endtemplate}' */
-# define frozen_relax (frozen_control_sequence+7) /* permanent `\.{\\relax}' */
-# define end_write (frozen_control_sequence+8) /* permanent `\.{\\endwrite}' */
-# define frozen_dont_expand (frozen_control_sequence+9 )
- /* permanent `\.{\\notexpanded:}' */
-# define frozen_primitive (frozen_control_sequence+11 ) /* permanent `\.{\\pdfprimitive}' */
-# define frozen_special (frozen_control_sequence+12 ) /* permanent `\.{\\special}' */
-# define frozen_null_font (frozen_control_sequence+13 ) /* permanent `\.{\\nullfont}' */
-# define font_id_base (frozen_null_font-font_base ) /* begins table of |number_fonts| permanent font identifiers */
+# define null_cs 1 /* equivalent of \.{\\csname\\endcsname} */
+# define hash_base (null_cs+1) /* beginning of region 2, for the hash table */
+# define frozen_control_sequence (hash_base+hash_size) /* for error recovery */
+# define frozen_protection (frozen_control_sequence) /* inaccessible but definable */
+# define frozen_cr (frozen_control_sequence+1) /* permanent `\.{\\cr}' */
+# define frozen_end_group (frozen_control_sequence+2) /* permanent `\.{\\endgroup}' */
+# define frozen_right (frozen_control_sequence+3) /* permanent `\.{\\right}' */
+# define frozen_fi (frozen_control_sequence+4) /* permanent `\.{\\fi}' */
+# define frozen_end_template (frozen_control_sequence+5) /* permanent `\.{\\endtemplate}' */
+# define frozen_endv (frozen_control_sequence+6) /* second permanent `\.{\\endtemplate}' */
+# define frozen_relax (frozen_control_sequence+7) /* permanent `\.{\\relax}' */
+# define end_write (frozen_control_sequence+8) /* permanent `\.{\\endwrite}' */
+# define frozen_dont_expand (frozen_control_sequence+9 ) /* permanent `\.{\\notexpanded:}' */
+# define frozen_primitive (frozen_control_sequence+11 ) /* permanent `\.{\\primitive}' */
+# define frozen_special (frozen_control_sequence+12 ) /* permanent `\.{\\special}' */
+# define frozen_null_font (frozen_control_sequence+13 ) /* permanent `\.{\\nullfont}' */
+# define font_id_base (frozen_null_font-font_base ) /* begins table of |number_fonts| permanent font identifiers */
# define undefined_control_sequence (frozen_null_font+number_fonts)
-# define glue_base (undefined_control_sequence+1) /* beginning of region 3 */
-
-# define line_skip_code 0 /* interline glue if |baseline_skip| is infeasible */
-# define baseline_skip_code 1 /* desired glue between baselines */
-# define par_skip_code 2 /* extra glue just above a paragraph */
-# define above_display_skip_code 3 /* extra glue just above displayed math */
-# define below_display_skip_code 4 /* extra glue just below displayed math */
-# define above_display_short_skip_code 5
- /* glue above displayed math following short lines */
-# define below_display_short_skip_code 6
- /* glue below displayed math following short lines */
-# define left_skip_code 7 /* glue at left of justified lines */
-# define right_skip_code 8 /* glue at right of justified lines */
-# define top_skip_code 9 /* glue at top of main pages */
-# define split_top_skip_code 10 /* glue at top of split pages */
-# define tab_skip_code 11 /* glue between aligned entries */
-# define space_skip_code 12 /* glue between words (if not |zero_glue|) */
-# define xspace_skip_code 13 /* glue after sentences (if not |zero_glue|) */
-# define par_fill_skip_code 14 /* glue on last line of paragraph */
-# define thin_mu_skip_code 15 /* thin space in math formula */
-# define med_mu_skip_code 16 /* medium space in math formula */
-# define thick_mu_skip_code 17 /* thick space in math formula */
-# define glue_pars 18 /* total number of glue parameters */
-
-# define skip_base (glue_base+glue_pars)
- /* table of |number_regs| ``skip'' registers */
-# define mu_skip_base (skip_base+number_regs) /* table of |number_regs| ``muskip'' registers */
-# define local_base (mu_skip_base+number_regs) /* beginning of region 4 */
-
-# define par_shape_loc (local_base) /* specifies paragraph shape */
-# define output_routine_loc (local_base+1) /* points to token list for \.{\\output} */
-# define every_par_loc (local_base+2) /* points to token list for \.{\\everypar} */
-# define every_math_loc (local_base+3) /* points to token list for \.{\\everymath} */
-# define every_display_loc (local_base+4) /* points to token list for \.{\\everydisplay} */
-# define every_hbox_loc (local_base+5) /* points to token list for \.{\\everyhbox} */
-# define every_vbox_loc (local_base+6) /* points to token list for \.{\\everyvbox} */
-# define every_job_loc (local_base+7) /* points to token list for \.{\\everyjob} */
-# define every_cr_loc (local_base+8) /* points to token list for \.{\\everycr} */
-# define err_help_loc (local_base+9) /* points to token list for \.{\\errhelp} */
-# define every_eof_loc (local_base+10) /* points to token list for \.{\\everyeof} */
-# define tex_toks (local_base+11) /* end of (e-)\TeX's token list parameters */
-# define pdftex_first_loc (tex_toks) /* base for \pdfTeX's token list parameters */
-# define pdf_pages_attr_loc (pdftex_first_loc + 0) /* points to token list for \.{\\pdfpagesattr} */
-# define pdf_page_attr_loc (pdftex_first_loc + 1) /* points to token list for \.{\\pdfpageattr} */
-# define pdf_page_resources_loc (pdftex_first_loc + 2) /* points to token list for \.{\\pdfpageresources} */
-# define pdf_xform_attr_loc (pdftex_first_loc + 3) /* points to token list for \.{\\pdfxformattr} */
-# define pdf_xform_resources_loc (pdftex_first_loc + 4) /* points to token list for \.{\\pdfxformresources} */
-# define pdf_pk_mode_loc (pdftex_first_loc + 5) /* points to token list for \.{\\pdfpkmode} */
-# define pdf_toks (pdftex_first_loc+6) /* end of \pdfTeX's token list parameters */
-# define toks_base (pdf_toks) /* table of |number_regs| token list registers */
-# define etex_pen_base (toks_base+number_regs) /* start of table of \eTeX's penalties */
-# define inter_line_penalties_loc (etex_pen_base) /* additional penalties between lines */
-# define club_penalties_loc (etex_pen_base+1) /* penalties for creating club lines */
-# define widow_penalties_loc (etex_pen_base+2) /* penalties for creating widow lines */
-# define display_widow_penalties_loc (etex_pen_base+3) /* ditto, just before a display */
-# define etex_pens (etex_pen_base+4) /* end of table of \eTeX's penalties */
+# define glue_base (undefined_control_sequence+1) /* beginning of region 3 */
+
+# define line_skip_code 0 /* interline glue if |baseline_skip| is infeasible */
+# define baseline_skip_code 1 /* desired glue between baselines */
+# define par_skip_code 2 /* extra glue just above a paragraph */
+# define above_display_skip_code 3 /* extra glue just above displayed math */
+# define below_display_skip_code 4 /* extra glue just below displayed math */
+# define above_display_short_skip_code 5 /* glue above displayed math following short lines */
+# define below_display_short_skip_code 6 /* glue below displayed math following short lines */
+# define left_skip_code 7 /* glue at left of justified lines */
+# define right_skip_code 8 /* glue at right of justified lines */
+# define top_skip_code 9 /* glue at top of main pages */
+# define split_top_skip_code 10 /* glue at top of split pages */
+# define tab_skip_code 11 /* glue between aligned entries */
+# define space_skip_code 12 /* glue between words (if not |zero_glue|) */
+# define xspace_skip_code 13 /* glue after sentences (if not |zero_glue|) */
+# define par_fill_skip_code 14 /* glue on last line of paragraph */
+# define thin_mu_skip_code 15 /* thin space in math formula */
+# define med_mu_skip_code 16 /* medium space in math formula */
+# define thick_mu_skip_code 17 /* thick space in math formula */
+# define math_skip_code 18
+# define glue_pars 19 /* total number of glue parameters */
+
+# define skip_base (glue_base+glue_pars) /* table of |number_regs| ``skip'' registers */
+# define mu_skip_base (skip_base+number_regs) /* table of |number_regs| ``muskip'' registers */
+# define local_base (mu_skip_base+number_regs) /* beginning of region 4 */
+
+# define par_shape_loc (local_base) /* specifies paragraph shape */
+# define output_routine_loc (local_base+1) /* points to token list for \.{\\output} */
+# define every_par_loc (local_base+2) /* points to token list for \.{\\everypar} */
+# define every_math_loc (local_base+3) /* points to token list for \.{\\everymath} */
+# define every_display_loc (local_base+4) /* points to token list for \.{\\everydisplay} */
+# define every_hbox_loc (local_base+5) /* points to token list for \.{\\everyhbox} */
+# define every_vbox_loc (local_base+6) /* points to token list for \.{\\everyvbox} */
+# define every_job_loc (local_base+7) /* points to token list for \.{\\everyjob} */
+# define every_cr_loc (local_base+8) /* points to token list for \.{\\everycr} */
+# define err_help_loc (local_base+9) /* points to token list for \.{\\errhelp} */
+# define every_eof_loc (local_base+10) /* points to token list for \.{\\everyeof} */
+
+/* define toks_base (local_base+11) */ /* table of |number_regs| token list registers */
+
+# define backend_toks_base (local_base+11)
+# define backend_toks_last (backend_toks_base+10)
+
+# define toks_base (backend_toks_last+1) /* table of |number_regs| token list registers */
+
+# define etex_pen_base (toks_base+number_regs) /* start of table of \eTeX's penalties */
+# define inter_line_penalties_loc (etex_pen_base) /* additional penalties between lines */
+# define club_penalties_loc (etex_pen_base+1) /* penalties for creating club lines */
+# define widow_penalties_loc (etex_pen_base+2) /* penalties for creating widow lines */
+# define display_widow_penalties_loc (etex_pen_base+3) /* ditto, just before a display */
+# define etex_pens (etex_pen_base+4) /* end of table of \eTeX's penalties */
# define local_left_box_base (etex_pens)
# define local_right_box_base (local_left_box_base+1)
-# define box_base (local_right_box_base+1) /* table of |number_regs| box registers */
-# define cur_font_loc (box_base+number_regs) /* internal font number outside math mode */
-# define internal_math_param_base (cur_font_loc+1 ) /* current math parameter data index */
-# define cat_code_base (internal_math_param_base+1) /* current category code data index */
-# define lc_code_base (cat_code_base+1) /* table of |number_chars| lowercase mappings */
-# define uc_code_base (lc_code_base+1) /* table of |number_chars| uppercase mappings */
-# define sf_code_base (uc_code_base+1) /* table of |number_chars| spacefactor mappings */
-# define math_code_base (sf_code_base+1)
- /* table of |number_chars| math mode mappings */
-# define int_base (math_code_base+1) /* beginning of region 5 */
-
-# define pretolerance_code 0 /* badness tolerance before hyphenation */
-# define tolerance_code 1 /* badness tolerance after hyphenation */
-# define line_penalty_code 2 /* added to the badness of every line */
-# define hyphen_penalty_code 3 /* penalty for break after discretionary hyphen */
-# define ex_hyphen_penalty_code 4 /* penalty for break after explicit hyphen */
-# define club_penalty_code 5 /* penalty for creating a club line */
-# define widow_penalty_code 6 /* penalty for creating a widow line */
-# define display_widow_penalty_code 7 /* ditto, just before a display */
-# define broken_penalty_code 8 /* penalty for breaking a page at a broken line */
-# define bin_op_penalty_code 9 /* penalty for breaking after a binary operation */
-# define rel_penalty_code 10 /* penalty for breaking after a relation */
-# define pre_display_penalty_code 11 /* penalty for breaking just before a displayed formula */
-# define post_display_penalty_code 12 /* penalty for breaking just after a displayed formula */
-# define inter_line_penalty_code 13 /* additional penalty between lines */
-# define double_hyphen_demerits_code 14 /* demerits for double hyphen break */
-# define final_hyphen_demerits_code 15 /* demerits for final hyphen break */
-# define adj_demerits_code 16 /* demerits for adjacent incompatible lines */
-# define mag_code 17 /* magnification ratio */
-# define delimiter_factor_code 18 /* ratio for variable-size delimiters */
-# define looseness_code 19 /* change in number of lines for a paragraph */
-# define time_code 20 /* current time of day */
-# define day_code 21 /* current day of the month */
-# define month_code 22 /* current month of the year */
-# define year_code 23 /* current year of our Lord */
-# define show_box_breadth_code 24 /* nodes per level in |show_box| */
-# define show_box_depth_code 25 /* maximum level in |show_box| */
-# define hbadness_code 26 /* hboxes exceeding this badness will be shown by |hpack| */
-# define vbadness_code 27 /* vboxes exceeding this badness will be shown by |vpack| */
-# define pausing_code 28 /* pause after each line is read from a file */
-# define tracing_online_code 29 /* show diagnostic output on terminal */
-# define tracing_macros_code 30 /* show macros as they are being expanded */
-# define tracing_stats_code 31 /* show memory usage if \TeX\ knows it */
-# define tracing_paragraphs_code 32 /* show line-break calculations */
-# define tracing_pages_code 33 /* show page-break calculations */
-# define tracing_output_code 34 /* show boxes when they are shipped out */
-# define tracing_lost_chars_code 35 /* show characters that aren't in the font */
-# define tracing_commands_code 36 /* show command codes at |big_switch| */
-# define tracing_restores_code 37 /* show equivalents when they are restored */
-# define uc_hyph_code 38 /* hyphenate words beginning with a capital letter */
-# define output_penalty_code 39 /* penalty found at current page break */
-# define max_dead_cycles_code 40
- /* bound on consecutive dead cycles of output */
-# define hang_after_code 41 /* hanging indentation changes after this many lines */
-# define floating_penalty_code 42 /* penalty for insertions heldover after a split */
-# define global_defs_code 43 /* override \.{\\global} specifications */
-# define cur_fam_code 44 /* current family */
-# define escape_char_code 45 /* escape character for token output */
-# define default_hyphen_char_code 46 /* value of \.{\\hyphenchar} when a font is loaded */
-# define default_skew_char_code 47 /* value of \.{\\skewchar} when a font is loaded */
-# define end_line_char_code 48 /* character placed at the right end of the buffer */
-# define new_line_char_code 49 /* character that prints as |print_ln| */
-# define language_code 50 /* current hyphenation table */
-# define left_hyphen_min_code 51
- /* minimum left hyphenation fragment size */
-# define right_hyphen_min_code 52 /* minimum right hyphenation fragment size */
-# define holding_inserts_code 53
- /* do not remove insertion nodes from \.{\\box255} */
-# define error_context_lines_code 54 /* maximum intermediate line pairs shown */
-# define local_inter_line_penalty_code 55 /* local \.{\\interlinepenalty} */
-# define local_broken_penalty_code 56 /* local \.{\\brokenpenalty} */
-# define no_local_whatsits_code 57 /* counts local whatsits */
+# define box_base (local_right_box_base+1) /* table of |number_regs| box registers */
+# define cur_font_loc (box_base+number_regs) /* internal font number outside math mode */
+# define internal_math_param_base (cur_font_loc+1 ) /* current math parameter data index */
+# define cat_code_base (internal_math_param_base+1) /* current category code data index */
+# define lc_code_base (cat_code_base+1) /* table of |number_chars| lowercase mappings */
+# define uc_code_base (lc_code_base+1) /* table of |number_chars| uppercase mappings */
+# define sf_code_base (uc_code_base+1) /* table of |number_chars| spacefactor mappings */
+# define math_code_base (sf_code_base+1) /* table of |number_chars| math mode mappings */
+# define int_base (math_code_base+1) /* beginning of region 5 */
+
+# define pretolerance_code 0 /* badness tolerance before hyphenation */
+# define tolerance_code 1 /* badness tolerance after hyphenation */
+# define line_penalty_code 2 /* added to the badness of every line */
+# define hyphen_penalty_code 3 /* penalty for break after discretionary hyphen */
+# define ex_hyphen_penalty_code 4 /* penalty for break after explicit hyphen */
+# define club_penalty_code 5 /* penalty for creating a club line */
+# define widow_penalty_code 6 /* penalty for creating a widow line */
+# define display_widow_penalty_code 7 /* ditto, just before a display */
+# define broken_penalty_code 8 /* penalty for breaking a page at a broken line */
+# define bin_op_penalty_code 9 /* penalty for breaking after a binary operation */
+# define rel_penalty_code 10 /* penalty for breaking after a relation */
+# define pre_display_penalty_code 11 /* penalty for breaking just before a displayed formula */
+# define post_display_penalty_code 12 /* penalty for breaking just after a displayed formula */
+# define inter_line_penalty_code 13 /* additional penalty between lines */
+# define double_hyphen_demerits_code 14 /* demerits for double hyphen break */
+# define final_hyphen_demerits_code 15 /* demerits for final hyphen break */
+# define adj_demerits_code 16 /* demerits for adjacent incompatible lines */
+# define mag_code 17 /* magnification ratio */
+# define delimiter_factor_code 18 /* ratio for variable-size delimiters */
+# define looseness_code 19 /* change in number of lines for a paragraph */
+# define time_code 20 /* current time of day */
+# define day_code 21 /* current day of the month */
+# define month_code 22 /* current month of the year */
+# define year_code 23 /* current year of our Lord */
+# define show_box_breadth_code 24 /* nodes per level in |show_box| */
+# define show_box_depth_code 25 /* maximum level in |show_box| */
+# define hbadness_code 26 /* hboxes exceeding this badness will be shown by |hpack| */
+# define vbadness_code 27 /* vboxes exceeding this badness will be shown by |vpack| */
+# define pausing_code 28 /* pause after each line is read from a file */
+# define tracing_online_code 29 /* show diagnostic output on terminal */
+# define tracing_macros_code 30 /* show macros as they are being expanded */
+# define tracing_stats_code 31 /* show memory usage if \TeX\ knows it */
+# define tracing_paragraphs_code 32 /* show line-break calculations */
+# define tracing_pages_code 33 /* show page-break calculations */
+# define tracing_output_code 34 /* show boxes when they are shipped out */
+# define tracing_lost_chars_code 35 /* show characters that aren't in the font */
+# define tracing_commands_code 36 /* show command codes at |big_switch| */
+# define tracing_restores_code 37 /* show equivalents when they are restored */
+# define uc_hyph_code 38 /* hyphenate words beginning with a capital letter */
+# define output_penalty_code 39 /* penalty found at current page break */
+# define max_dead_cycles_code 40 /* bound on consecutive dead cycles of output */
+# define hang_after_code 41 /* hanging indentation changes after this many lines */
+# define floating_penalty_code 42 /* penalty for insertions heldover after a split */
+# define global_defs_code 43 /* override \.{\\global} specifications */
+# define cur_fam_code 44 /* current family */
+# define escape_char_code 45 /* escape character for token output */
+# define default_hyphen_char_code 46 /* value of \.{\\hyphenchar} when a font is loaded */
+# define default_skew_char_code 47 /* value of \.{\\skewchar} when a font is loaded */
+# define end_line_char_code 48 /* character placed at the right end of the buffer */
+# define new_line_char_code 49 /* character that prints as |print_ln| */
+# define language_code 50 /* current hyphenation table */
+# define left_hyphen_min_code 51 /* minimum left hyphenation fragment size */
+# define right_hyphen_min_code 52 /* minimum right hyphenation fragment size */
+# define holding_inserts_code 53 /* do not remove insertion nodes from \.{\\box255} */
+# define error_context_lines_code 54 /* maximum intermediate line pairs shown */
+# define local_inter_line_penalty_code 55 /* local \.{\\interlinepenalty} */
+# define local_broken_penalty_code 56 /* local \.{\\brokenpenalty} */
+# define no_local_whatsits_code 57 /* counts local whatsits */
# define no_local_dirs_code 58
# define luastartup_id_code 60
@@ -277,120 +262,101 @@ here, and the |number_regs| \.{\\dimen} registers.
# define disable_kern_code 62
# define cat_code_table_code 63
# define output_box_code 64
-# define cur_lang_code 65 /* current language id */
+# define cur_lang_code 65 /* current language id */
# define ex_hyphen_char_code 66
-# define hyphenation_min_code 67 /* minimum word length */
-# define adjust_spacing_code 68 /*level of spacing adjusting */
-# define protrude_chars_code 69 /*protrude chars at left/right edge of paragraphs */
-
-# define pdftex_first_integer_code 70 /*base for \pdfTeX's integer parameters */
-# define pdf_output_code (pdftex_first_integer_code + 0)
- /*switch on PDF output if positive */
-# define pdf_compress_level_code (pdftex_first_integer_code + 1)
- /*compress level of streams */
-# define pdf_decimal_digits_code (pdftex_first_integer_code + 2)
- /*digits after the decimal point of numbers */
-# define pdf_image_resolution_code (pdftex_first_integer_code + 3) /*default image resolution */
-# define pdf_pk_resolution_code (pdftex_first_integer_code + 4) /*default resolution of PK font */
-# define pdf_unique_resname_code (pdftex_first_integer_code + 5)
- /*generate unique names for resouces */
-# define pdf_minor_version_code (pdftex_first_integer_code + 6) /*fractional part of the PDF version produced */
-# define pdf_pagebox_code (pdftex_first_integer_code + 7) /*default pagebox to use for PDF inclusion */
-# define pdf_inclusion_errorlevel_code (pdftex_first_integer_code + 8) /*if the PDF inclusion should treat pdfs
- newer than |pdf_minor_version| as an error */
-# define pdf_gamma_code (pdftex_first_integer_code + 9)
-# define pdf_image_gamma_code (pdftex_first_integer_code + 10)
-# define pdf_image_hicolor_code (pdftex_first_integer_code + 11)
-# define pdf_image_apply_gamma_code (pdftex_first_integer_code + 12)
-# define pdf_tracing_fonts_code (pdftex_first_integer_code + 13)
- /*level of font detail in log */
-# define pdf_objcompresslevel_code (pdftex_first_integer_code + 14) /*activate object streams */
-# define pdf_gen_tounicode_code (pdftex_first_integer_code + 15)
- /*generate ToUnicode for fonts? */
-# define pdf_draftmode_code (pdftex_first_integer_code + 16) /*switch on draftmode if positive */
-# define pdf_replace_font_code (pdftex_first_integer_code + 17) /*generate ToUnicode for fonts? */
-# define pdf_inclusion_copy_font_code (pdftex_first_integer_code + 18) /*generate ToUnicode for fonts? */
-# define pdf_int_pars (pdftex_first_integer_code + 19) /*total number of \pdfTeX's integer parameters */
-# define etex_first_integer_code (pdf_int_pars) /*base for \eTeX's integer parameters */
-# define tracing_assigns_code (etex_first_integer_code) /*show assignments */
-# define tracing_groups_code (etex_first_integer_code+1) /*show save/restore groups */
-# define tracing_ifs_code (etex_first_integer_code+2) /*show conditionals */
-# define tracing_scan_tokens_code (etex_first_integer_code+3) /*show pseudo file open and close */
-# define tracing_nesting_code (etex_first_integer_code+4) /*show incomplete groups and ifs within files */
-# define pre_display_direction_code (etex_first_integer_code+5) /*text direction preceding a display */
-# define last_line_fit_code (etex_first_integer_code+6) /*adjustment for last line of paragraph */
-# define saving_vdiscards_code (etex_first_integer_code+7)
- /*save items discarded from vlists */
-# define saving_hyph_codes_code (etex_first_integer_code+8) /*save hyphenation codes for languages */
-# define suppress_fontnotfound_error_code (etex_first_integer_code+9) /*suppress errors for missing fonts */
-# define suppress_long_error_code (etex_first_integer_code+10) /*suppress errors for missing fonts */
-# define suppress_ifcsname_error_code (etex_first_integer_code+11)
- /*suppress errors for failed \.{\\ifcsname} */
-# define suppress_outer_error_code (etex_first_integer_code+12) /*suppress errors for \.{\\outer} */
-# define suppress_mathpar_error_code (etex_first_integer_code+13) /*suppress errors for \.{\\par}} in math */
-# define math_eqno_gap_step_code (etex_first_integer_code+14) /* factor/1000 used for distance between eq and eqno */
-# define synctex_code (etex_first_integer_code+15) /* is synctex file generation enabled ? */
-
-# define tex_int_pars (synctex_code+1) /* total number of integer parameters */
+# define hyphenation_min_code 67 /* minimum word length */
+# define adjust_spacing_code 68 /* level of spacing adjusting */
+# define protrude_chars_code 69 /* protrude chars at left/right edge of paragraphs */
+# define output_mode_code 70 /* switch on PDF output if positive */
+# define draft_mode_code 71
+# define tracing_fonts_code 72
+# define tracing_assigns_code 73 /* show assignments */
+# define tracing_groups_code 74 /* show save/restore groups */
+# define tracing_ifs_code 75 /* show conditionals */
+# define tracing_scan_tokens_code 76 /* show pseudo file open and close */
+# define tracing_nesting_code 77 /* show incomplete groups and ifs within files */
+# define pre_display_direction_code 78 /* text direction preceding a display */
+# define last_line_fit_code 79 /* adjustment for last line of paragraph */
+# define saving_vdiscards_code 80 /* save items discarded from vlists */
+# define saving_hyph_codes_code 81 /* save hyphenation codes for languages */
+# define suppress_fontnotfound_error_code 82 /* suppress errors for missing fonts */
+# define suppress_long_error_code 83 /* suppress errors for missing fonts */
+# define suppress_ifcsname_error_code 84 /* suppress errors for failed \.{\\ifcsname} */
+# define suppress_outer_error_code 85 /* suppress errors for \.{\\outer} */
+# define suppress_mathpar_error_code 86 /* suppress errors for \.{\\par}} in math */
+# define math_eqno_gap_step_code 87 /* factor/1000 used for distance between eq and eqno */
+# define math_display_skip_mode_code 88
+# define math_scripts_mode_code 89
+# define synctex_code 90 /* is synctex file generation enabled ? */
+
+# define math_no_italic_compensation_code 91 /* just for tracing, can change */
+# define math_no_char_italic_code 92 /* just for tracing, can change */
+# define math_use_old_fraction_scaling_code 93 /* just for tracing, can change */
+# define math_old_code 94 /* this one is stable */
+
+# define math_option_code 95
+
+# define backend_int_base (math_option_code+1)
+# define backend_int_last (backend_int_base+20)
+
+# define tex_int_pars (backend_int_last+1) /* total number of integer parameters */
# define page_direction_code (tex_int_pars)
# define body_direction_code (tex_int_pars+1)
# define par_direction_code (tex_int_pars+2)
# define text_direction_code (tex_int_pars+3)
# define math_direction_code (tex_int_pars+4)
-# define int_pars (tex_int_pars+5) /*total number of integer parameters */
+
+# define int_pars (tex_int_pars+5) /* total number of integer parameters */
# define dir_base (int_base+tex_int_pars)
-# define count_base (int_base+int_pars) /*|number_regs| user \.{\\count} registers */
-# define attribute_base (count_base+number_regs)
- /*|number_attrs| user \.{\\attribute} registers */
-# define del_code_base (attribute_base+number_attrs) /*|number_chars| delimiter code mappings */
-# define dimen_base (del_code_base+1) /*beginning of region 6 */
-
-# define par_indent_code 0 /* indentation of paragraphs */
-# define math_surround_code 1 /* space around math in text */
-# define line_skip_limit_code 2 /* threshold for |line_skip| instead of |baseline_skip| */
-# define hsize_code 3 /* line width in horizontal mode */
-# define vsize_code 4 /* page height in vertical mode */
-# define max_depth_code 5 /* maximum depth of boxes on main pages */
-# define split_max_depth_code 6 /* maximum depth of boxes on split pages */
-# define box_max_depth_code 7 /* maximum depth of explicit vboxes */
-# define hfuzz_code 8 /* tolerance for overfull hbox messages */
-# define vfuzz_code 9 /* tolerance for overfull vbox messages */
-# define delimiter_shortfall_code 10 /* maximum amount uncovered by variable delimiters */
-# define null_delimiter_space_code 11 /* blank space in null delimiters */
-# define script_space_code 12 /* extra space after subscript or superscript */
-# define pre_display_size_code 13 /* length of text preceding a display */
-# define display_width_code 14 /* length of line for displayed equation */
-# define display_indent_code 15 /* indentation of line for displayed equation */
-# define overfull_rule_code 16 /* width of rule that identifies overfull hboxes */
-# define hang_indent_code 17 /* amount of hanging indentation */
-# define h_offset_code 18 /* amount of horizontal offset when shipping pages out */
-# define v_offset_code 19 /* amount of vertical offset when shipping pages out */
-# define emergency_stretch_code 20 /* reduces badnesses on final pass of line-breaking */
+# define count_base (int_base+int_pars) /* |number_regs| user \.{\\count} registers */
+# define attribute_base (count_base+number_regs) /* |number_attrs| user \.{\\attribute} registers */
+# define del_code_base (attribute_base+number_attrs) /* |number_chars| delimiter code mappings */
+# define dimen_base (del_code_base+1) /* beginning of region 6 */
+
+# define par_indent_code 0 /* indentation of paragraphs */
+# define math_surround_code 1 /* space around math in text */
+# define line_skip_limit_code 2 /* threshold for |line_skip| instead of |baseline_skip| */
+# define hsize_code 3 /* line width in horizontal mode */
+# define vsize_code 4 /* page height in vertical mode */
+# define max_depth_code 5 /* maximum depth of boxes on main pages */
+# define split_max_depth_code 6 /* maximum depth of boxes on split pages */
+# define box_max_depth_code 7 /* maximum depth of explicit vboxes */
+# define hfuzz_code 8 /* tolerance for overfull hbox messages */
+# define vfuzz_code 9 /* tolerance for overfull vbox messages */
+# define delimiter_shortfall_code 10 /* maximum amount uncovered by variable delimiters */
+# define null_delimiter_space_code 11 /* blank space in null delimiters */
+# define script_space_code 12 /* extra space after subscript or superscript */
+# define pre_display_size_code 13 /* length of text preceding a display */
+# define display_width_code 14 /* length of line for displayed equation */
+# define display_indent_code 15 /* indentation of line for displayed equation */
+# define overfull_rule_code 16 /* width of rule that identifies overfull hboxes */
+# define hang_indent_code 17 /* amount of hanging indentation */
+# define h_offset_code 18 /* amount of horizontal offset when shipping pages out */
+# define v_offset_code 19 /* amount of vertical offset when shipping pages out */
+# define emergency_stretch_code 20 /* reduces badnesses on final pass of line-breaking */
# define page_left_offset_code 21
# define page_top_offset_code 22
# define page_right_offset_code 23
# define page_bottom_offset_code 24
-# define pdftex_first_dimen_code 25 /* first number defined in this section */
-# define pdf_h_origin_code (pdftex_first_dimen_code + 0) /* horigin of the PDF output */
-# define pdf_v_origin_code (pdftex_first_dimen_code + 1) /* vorigin of the PDF output */
-# define page_width_code (pdftex_first_dimen_code + 2) /* page width of the PDF output */
-# define page_height_code (pdftex_first_dimen_code + 3) /* page height of the PDF output */
-# define pdf_link_margin_code (pdftex_first_dimen_code + 4) /* link margin in the PDF output */
-# define pdf_dest_margin_code (pdftex_first_dimen_code + 5) /* dest margin in the PDF output */
-# define pdf_thread_margin_code (pdftex_first_dimen_code + 6) /* thread margin in the PDF output */
-# define pdf_px_dimen_code (pdftex_first_dimen_code + 7)
-# define pdftex_last_dimen_code (pdftex_first_dimen_code + 7) /* last number defined in this section */
-# define dimen_pars (pdftex_last_dimen_code + 1)
- /* total number of dimension parameters */
-
-# define scaled_base (dimen_base+dimen_pars) /* table of |number_regs| user-defined \.{\\dimen} registers */
-# define eqtb_size (scaled_base+biggest_reg) /* largest subscript of |eqtb| */
+# define px_dimen_code 25
+# define page_width_code 26 /* page width of the output */
+# define page_height_code 27 /* page height of the output */
+
+/* define dimen_pars (page_height_code + 1) */ /* total number of dimension parameters */
+
+# define backend_dimen_base (page_height_code+1)
+# define backend_dimen_last (backend_dimen_base+10)
+
+# define dimen_pars (backend_dimen_last + 1) /* total number of dimension parameters */
+
+# define scaled_base (dimen_base+dimen_pars) /* table of |number_regs| user-defined \.{\\dimen} registers */
+# define eqtb_size (scaled_base+biggest_reg) /* largest subscript of |eqtb| */
extern memory_word *eqtb;
-extern halfword eqtb_top; /* maximum of the |eqtb| */
+extern halfword eqtb_top; /* maximum of the |eqtb| */
extern quarterword xeq_level[(eqtb_size + 1)];
extern void initialize_equivalents(void);
@@ -399,10 +365,9 @@ extern void initialize_equivalents(void);
# define eq_type_field(A) (A).hh.b0
# define equiv_field(A) (A).hh.rh
-# define eq_level(A) eq_level_field(eqtb[(A)]) /* level of definition */
-# define eq_type(A) eq_type_field(eqtb[(A)]) /* command code for equivalent */
-# define equiv(A) equiv_field(eqtb[(A)])
- /* equivalent value */
+# define eq_level(A) eq_level_field(eqtb[(A)]) /* level of definition */
+# define eq_type(A) eq_type_field(eqtb[(A)]) /* command code for equivalent */
+# define equiv(A) equiv_field(eqtb[(A)]) /* equivalent value */
# define set_eq_level(A,B) eq_level((A)) = (B)
# define set_eq_type(A,B) eq_type((A)) = (B)
@@ -414,19 +379,17 @@ typedef struct save_record_ {
memory_word word_;
} save_record;
-
extern save_record *save_stack;
-extern int save_ptr; /* first unused entry on |save_stack| */
-extern int max_save_stack; /* maximum usage of save stack */
-extern quarterword cur_level; /* current nesting level for groups */
-extern group_code cur_group; /* current group type */
-extern int cur_boundary; /* where the current level begins */
-
+extern int save_ptr; /* first unused entry on |save_stack| */
+extern int max_save_stack; /* maximum usage of save stack */
+extern quarterword cur_level; /* current nesting level for groups */
+extern group_code cur_group; /* current group type */
+extern int cur_boundary; /* where the current level begins */
-# define save_type(A) save_stack[(A)].type_ /* classifies a |save_stack| entry */
-# define save_level(A) save_stack[(A)].level_ /* saved level for regions 5 and 6, or group code */
-# define save_value(A) save_stack[(A)].word_.cint /* |eqtb| location or token or |save_stack| location */
-# define save_word(A) save_stack[(A)].word_ /* |eqtb| entry */
+# define save_type(A) save_stack[(A)].type_ /* classifies a |save_stack| entry */
+# define save_level(A) save_stack[(A)].level_ /* saved level for regions 5 and 6, or group code */
+# define save_value(A) save_stack[(A)].word_.cint /* |eqtb| location or token or |save_stack| location */
+# define save_word(A) save_stack[(A)].word_ /* |eqtb| entry */
/*
We use the notation |saved(k)| to stand for an item that
@@ -443,10 +406,10 @@ appears in location |save_ptr+k| of the save stack.
saved_value(A) = (D); \
} while (0)
-# define restore_old_value 0 /* |save_type| when a value should be restored later */
-# define restore_zero 1 /* |save_type| when an undefined entry should be restored */
-# define insert_token 2 /* |save_type| when a token is being saved for later use */
-# define level_boundary 3 /* |save_type| corresponding to beginning of group */
+# define restore_old_value 0 /* |save_type| when a value should be restored later */
+# define restore_zero 1 /* |save_type| when an undefined entry should be restored */
+# define insert_token 2 /* |save_type| when a token is being saved for later use */
+# define level_boundary 3 /* |save_type| corresponding to beginning of group */
# define saved_line 4
# define saved_adjust 5
# define saved_insert 6
@@ -488,7 +451,6 @@ one that starts with \.{\\begingroup} should end with \.{\\endgroup}.
*/
-
typedef enum {
bottom_level = 0, /* group code for the outside world */
simple_group, /* group code for local structure only */
@@ -515,30 +477,36 @@ typedef enum {
fin_row_group /* box code for a provisory line in an alignment */
} tex_group_codes;
-# define max_group_code local_box_group /* which is wrong, but is what the web says */
+# define max_group_code local_box_group /* which is wrong, but is what the web says */
-extern int cur_cmd; /* current command set by |get_next| */
-extern halfword cur_chr; /* operand of current command */
-extern halfword cur_cs; /* control sequence found here, zero if none found */
-extern halfword cur_tok; /* packed representative of |cur_cmd| and |cur_chr| */
+extern int cur_cmd; /* current command set by |get_next| */
+extern halfword cur_chr; /* operand of current command */
+extern halfword cur_cs; /* control sequence found here, zero if none found */
+extern halfword cur_tok; /* packed representative of |cur_cmd| and |cur_chr| */
extern void show_cur_cmd_chr(void);
-extern void new_save_level(group_code c); /* begin a new level of grouping */
-extern void eq_destroy(memory_word w); /* gets ready to forget |w| */
-extern void eq_save(halfword p, quarterword l); /* saves |eqtb[p]| */
+extern void new_save_level(group_code c); /* begin a new level of grouping */
+extern void eq_destroy(memory_word w); /* gets ready to forget |w| */
+extern void eq_save(halfword p, quarterword l); /* saves |eqtb[p]| */
extern void eq_define(halfword p, quarterword t, halfword e); /* new data for |eqtb| */
extern void eq_word_define(halfword p, int w);
extern void geq_define(halfword p, quarterword t, halfword e); /* global |eq_define| */
-extern void geq_word_define(halfword p, int w); /* global |eq_word_define| */
+extern void geq_word_define(halfword p, int w); /* global |eq_word_define| */
extern void save_for_after(halfword t);
-extern void unsave(void); /* pops the top level off the save stack */
-extern void restore_trace(halfword p, const char *s); /* |eqtb[p]| has just been restored or retained */
+extern void unsave(void); /* pops the top level off the save stack */
+extern void restore_trace(halfword p, const char *s); /* |eqtb[p]| has just been restored or retained */
extern void show_save_groups(void);
-# define level_zero 0 /* level for undefined quantities */
-# define level_one 1 /* outermost level for defined quantities */
+# define level_zero 0 /* level for undefined quantities */
+# define level_one 1 /* outermost level for defined quantities */
extern void show_eqtb(halfword n);
+/* more will move here */
+
+#define space_skip glue_par(space_skip_code)
+#define xspace_skip glue_par(xspace_skip_code)
+#define math_skip glue_par(math_skip_code)
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.h b/Build/source/texk/web2c/luatexdir/tex/errors.h
index b7f46431e5d..101e78adb71 100644
--- a/Build/source/texk/web2c/luatexdir/tex/errors.h
+++ b/Build/source/texk/web2c/luatexdir/tex/errors.h
@@ -40,6 +40,13 @@ extern int interactionoption; /* set from command line */
extern void initialize_errors(void);
extern char *last_error;
+extern char *last_lua_error;
+extern char *last_warning_tag;
+extern char *last_warning_str;
+extern char *last_error_context;
+
+extern void set_last_error_context(void);
+
extern void print_err(const char *s);
extern void fixup_selector(boolean log_opened);
@@ -85,14 +92,14 @@ extern void int_error(int n);
extern void normalize_selector(void);
extern void succumb(void);
extern void fatal_error(const char *s);
-extern void lua_norm_error(const char *s);
-extern void lua_fatal_error(const char *s);
extern void overflow(const char *s, unsigned int n);
extern void confusion(const char *s);
extern void check_interrupt(void);
extern void pause_for_instructions(void);
extern void tex_error(const char *msg, const char **hlp);
+extern void normal_error(const char *t, const char *p);
+extern void normal_warning(const char *t, const char *p, boolean pr, boolean ap);
extern void back_error(void);
extern void ins_error(void);
diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.w b/Build/source/texk/web2c/luatexdir/tex/errors.w
index dd32f5b7a28..e11fcd908fe 100644
--- a/Build/source/texk/web2c/luatexdir/tex/errors.w
+++ b/Build/source/texk/web2c/luatexdir/tex/errors.w
@@ -17,15 +17,17 @@
% You should have received a copy of the GNU General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
-@ @c
+@ TODO: we need to use a formatted normal_error in:
+hyphen.w
+luafflib.c
+@ @c
#include "ptexlib.h"
@ @c
#define new_line_char int_par(new_line_char_code)
-
@ When something anomalous is detected, \TeX\ typically does something like this:
$$\vbox{\halign{#\hfil\cr
|print_err("Something anomalous has been detected");|\cr
@@ -55,9 +57,36 @@ int interactionoption; /* set from command line */
/* ls-hh: so, new code only kicks in when we have a callback defined */
char *last_error = NULL;
+char *last_lua_error = NULL;
+char *last_warning_tag = NULL;
+char *last_warning_str = NULL;
+char *last_error_context = NULL;
+
int err_old_setting = 0 ;
int in_error = 0 ;
+void set_last_error_context(void)
+{
+ str_number str;
+ int sel = selector;
+ int saved_new_line_char;
+ int saved_new_string_line;
+ selector = new_string;
+ saved_new_line_char = new_line_char;
+ saved_new_string_line = new_string_line;
+ new_line_char = 10;
+ new_string_line = 10;
+ show_context();
+ xfree(last_error_context);
+ str = make_string();
+ last_error_context = makecstring(str);
+ flush_str(str);
+ selector = sel;
+ new_line_char = saved_new_line_char;
+ new_string_line = saved_new_string_line;
+ return;
+}
+
void flush_err(void)
{
str_number s_error;
@@ -113,8 +142,8 @@ void print_err(const char *s)
might be unusual. The only possible values of |selector| at the time of
error messages are
-\yskip\hang|no_print| (when |interaction=batch_mode|
- and |log_file| not yet open);
+\yskip
+\hang|no_print| (when |interaction=batch_mode| and |log_file| not yet open);
\hang|term_only| (when |interaction>batch_mode| and |log_file| not yet open);
@@ -133,7 +162,6 @@ void fixup_selector(boolean logopened)
selector = selector + 2;
}
-
@ A global variable |deletions_allowed| is set |false| if the |get_next|
routine is active when |error| is called; this ensures that |get_next|
and related routines like |get_token| will never be called recursively.
@@ -157,8 +185,6 @@ int error_count; /* the number of scrolled errors since the last
int interrupt; /* should \TeX\ pause for instructions? */
boolean OK_to_interrupt; /* should interrupts be observed? */
-
-
@ The value of |history| is initially |fatal_error_stop|, but it will
be changed to |spotless| if \TeX\ survives the initialization process.
@@ -175,7 +201,6 @@ void initialize_errors(void)
/* |history| is initialized elsewhere */
}
-
@ It is possible for |error| to be called recursively if some error arises
when |get_token| is being used to delete a token, and/or if some fatal error
occurs while \TeX\ is trying to fix a non-fatal one. But such recursion
@@ -188,7 +213,6 @@ is never more than two levels deep.
const char *help_line[7]; /* helps for the next |error| */
boolean use_err_help; /* should the |err_help| list be shown? */
-
@ The |jump_out| procedure just cuts across all active procedure levels and
exits the program. It is used when there is no recovery from a particular error.
@@ -223,6 +247,7 @@ void error(void)
history = error_message_issued;
callback_id = callback_defined(show_error_hook_callback);
if (callback_id > 0) {
+ set_last_error_context();
run_callback(callback_id, "->");
} else {
print_char('.');
@@ -314,7 +339,6 @@ void error(void)
/* Print the help information and |goto continue| */
if (use_err_help) {
give_err_help();
- use_err_help = false;
} else {
if (help_line[0] == NULL) {
help2
@@ -385,17 +409,18 @@ void error(void)
default:
break;
}
- /* Print the menu of available options */
- tprint
- ("Type <return> to proceed, S to scroll future error messages,");
- tprint_nl("R to run without stopping, Q to run quietly,");
- tprint_nl("I to insert something, ");
- if (base_ptr > 0)
- tprint("E to edit your file,");
- if (deletions_allowed)
- tprint_nl
- ("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
- tprint_nl("H for help, X to quit.");
+ if (!use_err_help) {
+ /* Print the menu of available options */
+ tprint("Type <return> to proceed, S to scroll future error messages,");
+ tprint_nl("R to run without stopping, Q to run quietly,");
+ tprint_nl("I to insert something, ");
+ if (base_ptr > 0)
+ tprint("E to edit your file,");
+ if (deletions_allowed)
+ tprint_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
+ tprint_nl("H for help, X to quit.");
+ }
+ use_err_help = false;
}
}
@@ -422,8 +447,6 @@ void error(void)
print_ln();
}
-
-
@ A dozen or so error messages end with a parenthesized integer, so we
save a teeny bit of program space by declaring the following procedure:
@@ -436,7 +459,6 @@ void int_error(int n)
error();
}
-
@ In anomalous cases, the print selector might be in an unknown state;
the following subroutine is called to fix things just enough to keep
running a bit longer.
@@ -479,36 +501,6 @@ void fatal_error(const char *s)
succumb();
}
-@ @c
-void lua_norm_error(const char *s)
-{ /* lua found a problem */
- int saved_new_line_char;
- int report_id ;
- saved_new_line_char = new_line_char;
- new_line_char = 10;
- report_id = callback_defined(show_lua_error_hook_callback);
- if (report_id == 0) {
- print_err("LuaTeX error ");
- tprint(s);
- } else {
- (void) run_callback(report_id, "->");
- }
- help2("The lua interpreter ran into a problem, so the",
- "remainder of this lua chunk will be ignored.");
- error();
- new_line_char = saved_new_line_char;
-}
-
-@ @c
-void lua_fatal_error(const char *s)
-{ /* lua found a problem */
- new_line_char = 10;
- normalize_selector();
- print_err("LuaTeX fatal error ");
- tprint(s);
- succumb();
-}
-
@ Here is the most dreaded error message
@c
void overflow(const char *s, unsigned int n)
@@ -524,7 +516,6 @@ void overflow(const char *s, unsigned int n)
succumb();
}
-
@ The program might sometime run completely amok, at which point there is
no choice but to stop. If no previous error has been detected, that's bad
news; a message is printed that is really intended for the \TeX\
@@ -550,7 +541,6 @@ void confusion(const char *s)
succumb();
}
-
@ Users occasionally want to interrupt \TeX\ while it's running.
If the runtime system allows this, one can implement
a routine that sets the global variable |interrupt| to some nonzero value
@@ -566,8 +556,6 @@ void check_interrupt(void)
pause_for_instructions();
}
-
-
@ When an interrupt has been detected, the program goes into its
highest interaction level and lets the user have nearly the full flexibility of
the |error| routine. \TeX\ checks for interrupts only at times when it is
@@ -631,8 +619,6 @@ void ins_error(void)
error();
}
-
-
@ When \TeX\ wants to typeset a character that doesn't exist, the
character node is not created; thus the output routine can assume
that characters exist when it sees them. The following procedure
@@ -671,3 +657,68 @@ void char_warning(internal_font_number f, int c)
int_par(tracing_online_code) = old_setting;
}
}
+
+@ @c
+void normal_error(const char *t, const char *p)
+{
+ normalize_selector();
+ print_err("error ");
+ if (t != NULL) {
+ tprint(" (");
+ tprint(t);
+ tprint(")");
+ }
+ tprint(": ");
+ if (p != NULL)
+ tprint(p);
+ succumb();
+}
+
+@ @c
+void normal_warning(const char *t, const char *p, boolean prepend_nl, boolean append_nl)
+{
+ int report_id ;
+ if (strcmp(t,"lua") == 0) {
+ int saved_new_line_char;
+ saved_new_line_char = new_line_char;
+ new_line_char = 10;
+ report_id = callback_defined(show_lua_error_hook_callback);
+ if (report_id == 0) {
+ tprint(p);
+ help2("The lua interpreter ran into a problem, so the",
+ "remainder of this lua chunk will be ignored.");
+ } else {
+ (void) run_callback(report_id, "->");
+ }
+ error();
+ new_line_char = saved_new_line_char;
+ } else {
+ report_id = callback_defined(show_warning_message_callback);
+ if (report_id > 0) {
+ /* free last ones */
+ xfree(last_warning_str);
+ xfree(last_warning_tag);
+ last_warning_str = (string) xmalloc(strlen(p) + 1);
+ last_warning_tag = (string) xmalloc(strlen(t) + 1);
+ strcpy(last_warning_str,p);
+ strcpy(last_warning_tag,t);
+ run_callback(report_id, "->");
+ } else {
+ if (prepend_nl)
+ print_ln();
+ tprint("warning ");
+ if (t != NULL) {
+ tprint(" (");
+ tprint(t);
+ tprint(")");
+ }
+ tprint(": ");
+ if (p != NULL)
+ tprint(p);
+ if (append_nl)
+ print_ln();
+ }
+ if (history == spotless)
+ history = warning_issued;
+ }
+}
diff --git a/Build/source/texk/web2c/luatexdir/tex/expand.w b/Build/source/texk/web2c/luatexdir/tex/expand.w
index aad2cb10042..5fa2cd7f08f 100644
--- a/Build/source/texk/web2c/luatexdir/tex/expand.w
+++ b/Build/source/texk/web2c/luatexdir/tex/expand.w
@@ -57,7 +57,7 @@ recursive calls don't invalidate them.
@^recursion@>
@c
-boolean is_in_csname = false;
+int is_in_csname = 0;
@ @c
void expand(void)
@@ -320,7 +320,7 @@ void manufacture_csname(void)
lstring *ss;
r = get_avail();
p = r; /* head of the list of characters */
- is_in_csname = true;
+ is_in_csname += 1;
do {
get_x_token();
if (cur_cs == 0)
@@ -330,10 +330,9 @@ void manufacture_csname(void)
/* Complain about missing \.{\\endcsname} */
complain_missing_csname();
}
- is_in_csname = false;
/* Look up the characters of list |r| in the hash table, and set |cur_cs| */
-
ss = tokenlist_to_lstring(r, true);
+ is_in_csname -= 1;
if (ss->l > 0) {
no_new_control_sequence = false;
cur_cs = string_lookup((char *) ss->s, ss->l);
@@ -373,7 +372,7 @@ common cases.
void get_x_token(void)
{ /* sets |cur_cmd|, |cur_chr|, |cur_tok|, and expands macros */
RESTART:
- get_token_lua();
+ get_next(); /* get_token_lua(); */
if (cur_cmd <= max_command_cmd)
goto DONE;
if (cur_cmd >= call_cmd) {
@@ -404,8 +403,8 @@ void x_token(void)
{ /* |get_x_token| without the initial |get_next| */
while (cur_cmd > max_command_cmd) {
expand();
- get_token_lua();
- }
+ get_next(); /* get_token_lua(); */
+ }
if (cur_cs == 0)
cur_tok = token_val(cur_cmd, cur_chr);
else
diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.h b/Build/source/texk/web2c/luatexdir/tex/extensions.h
index ad6dd784861..589a714445d 100644
--- a/Build/source/texk/web2c/luatexdir/tex/extensions.h
+++ b/Build/source/texk/web2c/luatexdir/tex/extensions.h
@@ -21,43 +21,62 @@
#ifndef EXTENSIONS_H
# define EXTENSIONS_H
-extern alpha_file write_file[16];
-extern halfword write_file_mode[16];
-extern halfword write_file_translation[16];
-extern boolean write_open[18];
+# define write_target_direct 16
+# define write_target_special 17
+# define write_target_system 18
+# define write_target_overflow last_file_selector+16 /* a signal that we write to console */
+# define last_write_open last_file_selector+2 /* keeps track of open state */
+
+extern alpha_file write_file[last_file_selector+1];
+extern halfword write_file_mode[last_file_selector+1];
+extern halfword write_file_translation[last_file_selector+1];
+extern boolean write_open[last_write_open+1];
+
+# define valid_write_file(n) (((n>=0) && (n<16)) || ((n>18) && (n<last_file_selector)))
+# define file_can_be_written(n) (valid_write_file(n) && write_open[n])
+
+extern void expand_macros_in_tokenlist(halfword p);
+extern void write_out(halfword p);
+extern void finalize_write_files(void);
+extern void initialize_write_files(void);
+extern void close_write_file(int id);
+extern boolean open_write_file(int id, char *fn);
+
extern scaled neg_wd;
extern scaled pos_wd;
extern scaled neg_ht;
extern halfword write_loc;
-extern void do_extension(PDF pdf);
+extern void do_extension(int immediate);
+
+extern void do_extension_dvi(int immediate);
+extern void do_extension_pdf(int immediate);
+
+extern void do_resource_dvi(int immediate, int code);
+extern void do_resource_pdf(int immediate, int code);
+
+extern void do_feedback_dvi();
+extern void do_feedback_pdf();
+
+extern int pdf_last_annot;
+extern int pdf_last_link;
+extern int pdf_last_obj;
+extern int pdf_retval;
/* Three extra node types carry information from |main_control|. */
/*
User defined whatsits can be inserted into node lists to pass data
-along from one lua call to anotherb without interference from the
+along from one lua call to another without interference from the
typesetting engine itself. Each has an id, a type, and a value. The
type of the value depends on the |user_node_type| field.
*/
extern void new_whatsit(int s);
-extern void new_write_whatsit(int w);
extern void scan_pdf_ext_toks(void);
-extern halfword prev_rightmost(halfword s, halfword e);
-extern int pdf_last_xform;
-extern int pdf_last_ximage;
-extern int pdf_last_ximage_pages;
-extern int pdf_last_ximage_colordepth;
-extern int pdf_last_annot;
-extern int pdf_last_link;
-extern scaledpos pdf_last_pos;
-extern halfword concat_tokens(halfword q, halfword r);
-extern int pdf_retval;
-
-extern halfword make_local_par_node(void);
+extern halfword concat_tokens(halfword q, halfword r);
/*
The \.{\\pagediscards} and \.{\\splitdiscards} commands share the
@@ -80,17 +99,26 @@ extern halfword last_line_fill; /* the |par_fill_skip| glue node of the new para
# define get_tex_dimen_register(j) dimen(j)
# define get_tex_skip_register(j) skip(j)
+# define get_tex_mu_skip_register(j) mu_skip(j)
# define get_tex_count_register(j) count(j)
# define get_tex_attribute_register(j) attribute(j)
# define get_tex_box_register(j) box(j)
+extern int get_tex_extension_count_register(const char *s, int d);
+extern void set_tex_extension_count_register(const char *s, int d);
+extern int get_tex_extension_dimen_register(const char *s, int d);
+extern void set_tex_extension_dimen_register(const char *s, int d);
+extern int get_tex_extension_toks_register (const char *s);
+
extern int set_tex_dimen_register(int j, scaled v);
extern int set_tex_skip_register(int j, halfword v);
+extern int set_tex_mu_skip_register(int j, halfword v);
extern int set_tex_count_register(int j, scaled v);
extern int set_tex_box_register(int j, scaled v);
extern int set_tex_attribute_register(int j, scaled v);
extern int get_tex_toks_register(int l);
extern int set_tex_toks_register(int j, lstring s);
+extern int scan_tex_toks_register(int j, int c, lstring s);
extern scaled get_tex_box_width(int j);
extern int set_tex_box_width(int j, scaled v);
extern scaled get_tex_box_height(int j);
@@ -114,4 +142,62 @@ extern int restrictedshell;
extern char *output_comment;
extern boolean debug_format_file;
+extern int last_saved_box_index ;
+extern int last_saved_image_index ;
+extern int last_saved_image_pages ;
+extern scaledpos last_position ;
+
+typedef enum {
+ /* traditional extensions */
+ open_code = 0,
+ write_code,
+ close_code,
+ reserved_extension_code, // 3: we moved special below immediate //
+ reserved_immediate_code, // 4: same number as main codes, expected value //
+ /* backend specific implementations */
+ special_code,
+ save_box_resource_code,
+ use_box_resource_code,
+ save_image_resource_code,
+ use_image_resource_code,
+ /* backend */
+ dvi_extension_code,
+ pdf_extension_code,
+} extension_codes ;
+
+/* for the moment there */
+
+typedef enum {
+ /* reserved, first needs to be larger than max extension_codes */
+ pdf_literal_code = 32,
+ pdf_dest_code,
+ pdf_annot_code,
+ pdf_save_code,
+ pdf_restore_code,
+ pdf_setmatrix_code,
+ pdf_obj_code,
+ pdf_refobj_code,
+ pdf_colorstack_code,
+ pdf_start_link_code,
+ pdf_end_link_code,
+ pdf_link_data_code,
+ pdf_start_thread_code,
+ pdf_end_thread_code,
+ pdf_thread_code,
+ pdf_outline_code,
+ pdf_glyph_to_unicode_code,
+ pdf_catalog_code,
+ pdf_font_attr_code,
+ pdf_map_file_code,
+ pdf_map_line_code,
+ pdf_include_chars_code,
+ pdf_info_code,
+ pdf_names_code,
+ pdf_trailer_code,
+} pdf_extension_codes;
+
+typedef enum {
+ dvi_literal_code = 32, /* alias for special */
+} dvi_extension_codes;
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.w b/Build/source/texk/web2c/luatexdir/tex/extensions.w
index 30b7c05e02c..fee0d3d025e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/extensions.w
+++ b/Build/source/texk/web2c/luatexdir/tex/extensions.w
@@ -21,8 +21,6 @@
\def\pdfTeX{pdf\TeX}
@ @c
-
-
#include "ptexlib.h"
@ @c
@@ -33,18 +31,12 @@
#define dir_save cur_list.dirs_field
#define tracing_nesting int_par(tracing_nesting_code)
+#define tracing_online int_par(tracing_online_code)
#define box(A) eqtb[box_base+(A)].hh.rh
#define global_defs int_par(global_defs_code)
#define cat_code_table int_par(cat_code_table_code)
-#define par_direction int_par(par_direction_code)
#define toks(A) equiv(toks_base+(A))
-#define local_inter_line_penalty int_par(local_inter_line_penalty_code)
-#define local_broken_penalty int_par(local_broken_penalty_code)
-#define local_left_box equiv(local_left_box_base)
-#define local_right_box equiv(local_right_box_base)
-
-
@ The program above includes a bunch of ``hooks'' that allow further
capabilities to be added without upsetting \TeX's basic structure.
Most of these hooks are concerned with ``whatsit'' nodes, which are
@@ -107,409 +99,415 @@ greater than 15, while |write_open[17]| represents a negative stream number,
and both of these variables are always |false|.
@c
-alpha_file write_file[16];
-halfword write_file_mode[16];
-halfword write_file_translation[16];
-boolean write_open[18];
+alpha_file write_file[last_file_selector+1];
+halfword write_file_mode[last_file_selector+1];
+halfword write_file_translation[last_file_selector+1];
+boolean write_open[last_write_open+1];
+
scaled neg_wd;
scaled pos_wd;
scaled neg_ht;
-
@ The variable |write_loc| just introduced is used to provide an
appropriate error message in case of ``runaway'' write texts.
@c
halfword write_loc; /* |eqtb| address of \.{\\write} */
+/*
+ hh: eventually i'll make \pdfextension a lua token parsed function;
+ a complication is that sometimes token lists are delayed
+*/
@ When an |extension| command occurs in |main_control|, in any mode,
the |do_extension| routine is called.
@c
-void do_extension(PDF pdf)
+int last_saved_image_index ;
+int last_saved_image_pages ;
+int last_saved_box_index ;
+scaledpos last_position = { 0, 0 };
+
+void do_extension_dvi(int immediate)
{
- int i, k; /* all-purpose integers */
- halfword p; /* all-purpose pointer */
- switch (cur_chr) {
- case open_node:
- /* Implement \.{\\openout} */
- new_write_whatsit(open_node_size);
- scan_optional_equals();
- scan_file_name();
- open_name(tail) = cur_name;
- open_area(tail) = cur_area;
- open_ext(tail) = cur_ext;
- break;
- case write_node:
- /* Implement \.{\\write} */
- /* When `\.{\\write 12\{...\}}' appears, we scan the token list `\.{\{...\}}'
- without expanding its macros; the macros will be expanded later when this
- token list is rescanned. */
- k = cur_cs;
- new_write_whatsit(write_node_size);
- cur_cs = k;
- p = scan_toks(false, false);
- write_tokens(tail) = def_ref;
- break;
- case close_node:
- /* Implement \.{\\closeout} */
- new_write_whatsit(write_node_size);
- write_tokens(tail) = null;
- break;
- case special_node:
- /* Implement \.{\\special} */
- /* When `\.{\\special\{...\}}' appears, we expand the macros in the token
- list as in \.{\\xdef} and \.{\\mark}. */
+ if (scan_keyword("literal")) {
new_whatsit(special_node);
write_stream(tail) = null;
- p = scan_toks(false, true);
+ scan_toks(false, true);
write_tokens(tail) = def_ref;
- break;
- case immediate_code:
- /* Implement \.{\\immediate} */
- /* To write a token list, we must run it through \TeX's scanner, expanding
- macros and \.{\\the} and \.{\\number}, etc. This might cause runaways,
- if a delimited macro parameter isn't matched, and runaways would be
- extremely confusing since we are calling on \TeX's scanner in the middle
- of a \.{\\shipout} command. Therefore we will put a dummy control sequence as
- a ``stopper,'' right after the token list. This control sequence is
- artificially defined to be \.{\\outer}.
-
- The presence of `\.{\\immediate}' causes the |do_extension| procedure
- to descend to one level of recursion. Nothing happens unless \.{\\immediate}
- is followed by `\.{\\openout}', `\.{\\write}', or `\.{\\closeout}'.
- */
- get_x_token();
- if (cur_cmd == extension_cmd) {
- if (cur_chr <= close_node) {
- p = tail;
- /* |do_extension()| and |out_what()| here can only be open, write, or close */
- do_extension(pdf); /* append a whatsit node */
- out_what(pdf, tail); /* do the action immediately */
+ } else {
+ normal_error("dvi backend", "unknown \\dviextension");
+ }
+}
+
+void do_extension_pdf(int immediate)
+{
+ int i, k;
+
+ i = 0 ;
+ if (scan_keyword("literal")) i = pdf_literal_code ;
+ else if (scan_keyword("dest")) i = pdf_dest_code ;
+ else if (scan_keyword("annot")) i = pdf_annot_code ;
+ else if (scan_keyword("save")) i = pdf_save_code ;
+ else if (scan_keyword("restore")) i = pdf_restore_code ;
+ else if (scan_keyword("setmatrix")) i = pdf_setmatrix_code ;
+ else if (scan_keyword("obj")) i = pdf_obj_code ;
+ else if (scan_keyword("refobj")) i = pdf_refobj_code ;
+ else if (scan_keyword("colorstack")) i = pdf_colorstack_code ;
+ else if (scan_keyword("startlink")) i = pdf_start_link_code ;
+ else if (scan_keyword("endlink")) i = pdf_end_link_code ;
+ else if (scan_keyword("startthread")) i = pdf_start_thread_code ;
+ else if (scan_keyword("endthread")) i = pdf_end_thread_code ;
+ else if (scan_keyword("thread")) i = pdf_thread_code ;
+ else if (scan_keyword("outline")) i = pdf_outline_code ;
+ else if (scan_keyword("glyphtounicode")) i = pdf_glyph_to_unicode_code ;
+ else if (scan_keyword("catalog")) i = pdf_catalog_code ;
+ else if (scan_keyword("fontattr")) i = pdf_font_attr_code ;
+ else if (scan_keyword("mapfile")) i = pdf_map_file_code ;
+ else if (scan_keyword("mapline")) i = pdf_map_line_code ;
+ else if (scan_keyword("includechars")) i = pdf_include_chars_code ;
+ else if (scan_keyword("info")) i = pdf_info_code ;
+ else if (scan_keyword("names")) i = pdf_names_code ;
+ else if (scan_keyword("trailer")) i = pdf_trailer_code ;
+
+ switch (i) {
+ case pdf_literal_code:
+ new_whatsit(pdf_literal_node);
+ if (scan_keyword("direct"))
+ set_pdf_literal_mode(tail, direct_always);
+ else if (scan_keyword("page"))
+ set_pdf_literal_mode(tail, direct_page);
+ else
+ set_pdf_literal_mode(tail, set_origin);
+ scan_pdf_ext_toks();
+ set_pdf_literal_type(tail, normal);
+ set_pdf_literal_data(tail, def_ref);
+ break;
+ case pdf_dest_code:
+ scan_pdfdest(static_pdf);
+ break;
+ case pdf_annot_code:
+ scan_annot(static_pdf);
+ break;
+ case pdf_setmatrix_code:
+ new_whatsit(pdf_setmatrix_node);
+ scan_pdf_ext_toks();
+ set_pdf_setmatrix_data(tail, def_ref);
+ break;
+ case pdf_save_code:
+ new_whatsit(pdf_save_node);
+ break;
+ case pdf_restore_code:
+ new_whatsit(pdf_restore_node);
+ break;
+ case pdf_obj_code:
+ scan_obj(static_pdf);
+ if (immediate) {
+ if (obj_data_ptr(static_pdf, pdf_last_obj) == 0) /* this object has not been initialized yet */
+ normal_error("pdf backend","\\pdfextension obj 'reserveobjnum' cannot be used with \\immediate");
+ pdf_write_obj(static_pdf, pdf_last_obj);
+ }
+ break;
+ case pdf_refobj_code:
+ scan_refobj(static_pdf);
+ break;
+ case pdf_colorstack_code:
+ scan_int();
+ if (cur_val >= colorstackused()) {
+ print_err("Unknown color stack number ");
+ print_int(cur_val);
+ help3
+ ("Allocate and initialize a color stack with \\pdfextension colorstackinit.",
+ "I'll use default color stack 0 here.",
+ "Proceed, with fingers crossed.");
+ error();
+ cur_val = 0;
+ }
+ if (cur_val < 0) {
+ print_err("Invalid negative color stack number");
+ help2("I'll use default color stack 0 here.",
+ "Proceed, with fingers crossed.");
+ error();
+ cur_val = 0;
+ }
+ if (scan_keyword("set"))
+ i = colorstack_set;
+ else if (scan_keyword("push"))
+ i = colorstack_push;
+ else if (scan_keyword("pop"))
+ i = colorstack_pop;
+ else if (scan_keyword("current"))
+ i = colorstack_current;
+ else
+ i = -1; /* error */
+ if (i >= 0) {
+ new_whatsit(pdf_colorstack_node);
+ set_pdf_colorstack_stack(tail, cur_val);
+ set_pdf_colorstack_cmd(tail, i);
+ set_pdf_colorstack_data(tail, null);
+ if (i <= colorstack_data) {
+ scan_pdf_ext_toks();
+ set_pdf_colorstack_data(tail, def_ref);
+ }
+ } else {
+ print_err("Color stack action is missing");
+ help3("The expected actions for \\pdfextension colorstack:",
+ " set, push, pop, current",
+ "I'll ignore the color stack command.");
+ error();
+ }
+ break;
+ case pdf_start_link_code:
+ scan_startlink(static_pdf);
+ break;
+ case pdf_end_link_code:
+ if (abs(mode) == vmode)
+ normal_error("pdf backend", "\\pdfextension endlink cannot be used in vertical mode");
+ new_whatsit(pdf_end_link_node);
+ break;
+ case pdf_start_thread_code:
+ new_annot_whatsit(pdf_start_thread_node);
+ scan_thread_id();
+ break;
+ case pdf_end_thread_code:
+ new_whatsit(pdf_end_thread_node);
+ break;
+ case pdf_outline_code:
+ scan_pdfoutline(static_pdf);
+ break;
+ case pdf_glyph_to_unicode_code:
+ glyph_to_unicode();
+ break;
+ case pdf_catalog_code:
+ scan_pdfcatalog(static_pdf);
+ break;
+ case pdf_font_attr_code:
+ /*
+ The font attributes are simply initialized to zero now, this is easier to deal with from C than an
+ empty \TeX{} string, and surely nobody will want to set font attr to a string containing a single zero,
+ as that would be nonsensical in the PDF output.
+ */
+ scan_font_ident();
+ k = cur_val;
+ if (k == null_font)
+ normal_error("pdf backend", "invalid font identifier");
+ scan_pdf_ext_toks();
+ set_pdf_font_attr(k, tokens_to_string(def_ref));
+ if (str_length(pdf_font_attr(k)) == 0) {
+ flush_str((str_ptr - 1)); /* from |tokens_to_string| */
+ set_pdf_font_attr(k, 0);
+ }
+ break;
+ case pdf_map_file_code:
+ scan_pdf_ext_toks();
+ pdfmapfile(def_ref);
+ delete_token_ref(def_ref);
+ break;
+ case pdf_map_line_code:
+ scan_pdf_ext_toks();
+ pdfmapline(def_ref);
+ delete_token_ref(def_ref);
+ break;
+ case pdf_include_chars_code:
+ pdf_include_chars(static_pdf);
+ break;
+ case pdf_info_code:
+ scan_pdf_ext_toks();
+ pdf_info_toks = concat_tokens(pdf_info_toks, def_ref);
+ break;
+ case pdf_names_code:
+ scan_pdf_ext_toks();
+ pdf_names_toks = concat_tokens(pdf_names_toks, def_ref);
+ break;
+ case pdf_thread_code:
+ new_annot_whatsit(pdf_thread_node);
+ scan_thread_id();
+ break;
+ case pdf_trailer_code:
+ scan_pdf_ext_toks();
+ pdf_trailer_toks = concat_tokens(pdf_trailer_toks, def_ref);
+ break;
+ default:
+ normal_error("pdf backend", "unknown \\pdfextension keyword");
+ break ;
+ }
+}
+
+void do_resource_dvi(int immediate, int code)
+{
+}
+
+void do_resource_pdf(int immediate, int code)
+{
+ switch (code) {
+ case use_box_resource_code:
+ scan_pdfrefxform(static_pdf);
+ break;
+ case use_image_resource_code:
+ scan_pdfrefximage(static_pdf);
+ break;
+ case save_box_resource_code:
+ scan_pdfxform(static_pdf);
+ if (immediate) {
+ pdf_cur_form = last_saved_box_index;
+ ship_out(static_pdf, obj_xform_box(static_pdf, last_saved_box_index), SHIPPING_FORM);
+ }
+ break;
+ case save_image_resource_code:
+ fix_pdf_minorversion(static_pdf);
+ scan_pdfximage(static_pdf);
+ if (immediate) {
+ pdf_write_image(static_pdf, last_saved_image_index);
+ }
+ break;
+ }
+}
+
+/*
+
+ Ad immediate:
+
+ To write a token list, we must run it through \TeX's scanner, expanding
+ macros and \.{\\the} and \.{\\number}, etc. This might cause runaways,
+ if a delimited macro parameter isn't matched, and runaways would be
+ extremely confusing since we are calling on \TeX's scanner in the middle
+ of a \.{\\shipout} command. Therefore we will put a dummy control sequence as
+ a ``stopper,'' right after the token list. This control sequence is
+ artificially defined to be \.{\\outer}.
+
+ The presence of `\.{\\immediate}' causes the |do_extension| procedure
+ to descend to one level of recursion. Nothing happens unless \.{\\immediate}
+ is followed by `\.{\\openout}', `\.{\\write}', or `\.{\\closeout}'.
+
+*/
+
+/* extensions are backend related */
+
+@ The next subroutine uses |cur_chr| to decide what sort of whatsit is
+involved, and also inserts a |write_stream| number.
+
+@c
+static void new_write_whatsit(int w, int check)
+{
+ new_whatsit(cur_chr);
+ if (check) {
+ /* so we check with open and close */
+ scan_limited_int(last_file_selector,NULL);
+ } else {
+ /* but we're tolerant with the rest */
+ scan_int();
+ if (cur_val < 0)
+ cur_val = term_only;
+ else if ((cur_val > last_file_selector) || (cur_val == write_target_direct) || (cur_val == write_target_special)) {
+ /* hh: i need to check what 17 is supposed to do. so let's kind of reserve it */
+ cur_val = write_target_overflow;
+ }
+ }
+ write_stream(tail) = cur_val;
+}
+
+void do_extension(int immediate)
+{
+ halfword p; /* all-purpose pointer */
+ if (cur_cmd == extension_cmd) {
+ /* these have their own range starting at 0 */
+ switch (cur_chr) {
+ case open_code:
+ p = tail;
+ new_write_whatsit(open_node_size,1);
+ scan_optional_equals();
+ scan_file_name();
+ open_name(tail) = cur_name;
+ open_area(tail) = cur_area;
+ open_ext(tail) = cur_ext;
+ if (immediate) {
+ out_what(static_pdf, tail);
flush_node_list(tail);
tail = p;
vlink(p) = null;
- } else {
- switch (cur_chr) {
- case pdf_obj_code:
- check_o_mode(pdf, "\\immediate\\pdfobj", 1 << OMODE_PDF,
- true);
- do_extension(pdf); /* scan object and set |pdf_last_obj| */
- if (obj_data_ptr(pdf, pdf_last_obj) == 0) /* this object has not been initialized yet */
- pdf_error("ext1",
- "`\\pdfobj reserveobjnum' cannot be used with \\immediate");
- pdf_write_obj(pdf, pdf_last_obj);
- break;
- case pdf_xform_code:
- check_o_mode(pdf, "\\immediate\\pdfxform", 1 << OMODE_PDF,
- true);
- do_extension(pdf); /* scan form and set |pdf_last_xform| */
- pdf_cur_form = pdf_last_xform;
- ship_out(pdf, obj_xform_box(pdf, pdf_last_xform), SHIPPING_FORM);
+ }
+ break;
+ case write_code:
+ /*
+ When `\.{\\write 12\{...\}}' appears, we scan the token list `\.{\{...\}}'
+ without expanding its macros; the macros will be expanded later when this
+ token list is rescanned.
+ */
+ p = tail;
+ new_write_whatsit(write_node_size,0);
+ cur_cs = write_stream(tail);
+ scan_toks(false, false);
+ write_tokens(tail) = def_ref;
+ if (immediate) {
+ out_what(static_pdf, tail);
+ flush_node_list(tail);
+ tail = p;
+ vlink(p) = null;
+ }
+ break;
+ case close_code:
+ p = tail;
+ new_write_whatsit(close_node_size,1);
+ write_tokens(tail) = null;
+ if (immediate) {
+ out_what(static_pdf, tail);
+ flush_node_list(tail);
+ tail = p;
+ vlink(p) = null;
+ }
+ break;
+ case special_code:
+ /*
+ When `\.{\\special\{...\}}' appears, we expand the macros in the token
+ list as in \.{\\xdef} and \.{\\mark}.
+ */
+ new_whatsit(special_node);
+ write_stream(tail) = null;
+ p = scan_toks(false, true);
+ write_tokens(tail) = def_ref;
+ break;
+ case immediate_code:
+ get_x_token();
+ do_extension(1);
+ break;
+ case use_box_resource_code:
+ case use_image_resource_code:
+ case save_box_resource_code:
+ case save_image_resource_code:
+ switch (get_o_mode()) {
+ case OMODE_DVI:
+ do_resource_dvi(0,cur_chr);
break;
- case pdf_ximage_code:
- check_o_mode(pdf, "\\immediate\\pdfximage", 1 << OMODE_PDF,
- true);
- do_extension(pdf); /* scan image and set |pdf_last_ximage| */
- pdf_write_image(pdf, pdf_last_ximage);
+ case OMODE_PDF:
+ do_resource_pdf(0,cur_chr);
break;
default:
- back_input();
break;
- }
- }
- } else {
- back_input();
- }
- break;
- case pdf_annot_node:
- /* Implement \.{\\pdfannot} */
- check_o_mode(pdf, "\\pdfannot", 1 << OMODE_PDF, false);
- scan_annot(pdf);
- break;
- case pdf_catalog_code:
- /* Implement \.{\\pdfcatalog} */
- check_o_mode(pdf, "\\pdfcatalog", 1 << OMODE_PDF, true); /* writes an object */
- scan_pdfcatalog(pdf);
- break;
- case pdf_dest_node:
- /* Implement \.{\\pdfdest} */
- check_o_mode(pdf, "\\pdfdest", 1 << OMODE_PDF, false);
- scan_pdfdest(pdf);
- break;
- case pdf_end_link_node:
- /* Implement \.{\\pdfendlink} */
- check_o_mode(pdf, "\\pdfendlink", 1 << OMODE_PDF, false);
- if (abs(mode) == vmode)
- pdf_error("ext1", "\\pdfendlink cannot be used in vertical mode");
- new_whatsit(pdf_end_link_node);
- break;
- case pdf_end_thread_node:
- /* Implement \.{\\pdfendthread} */
- check_o_mode(pdf, "\\pdfendthread", 1 << OMODE_PDF, false);
- new_whatsit(pdf_end_thread_node);
- break;
- case pdf_font_attr_code:
- /* Implement \.{\\pdffontattr} */
- /* A change from Thanh's original code: the font attributes are simply
- initialized to zero now, this is easier to deal with from C than an
- empty \TeX{} string, and surely nobody will want to set
- \.{\\pdffontattr} to a string containing a single zero, as that
- would be nonsensical in the PDF output. */
- check_o_mode(pdf, "\\pdffontattr", 1 << OMODE_PDF, false);
- scan_font_ident();
- k = cur_val;
- if (k == null_font)
- pdf_error("font", "invalid font identifier");
- scan_pdf_ext_toks();
- set_pdf_font_attr(k, tokens_to_string(def_ref));
- if (str_length(pdf_font_attr(k)) == 0) {
- flush_str((str_ptr - 1)); /* from |tokens_to_string| */
- set_pdf_font_attr(k, 0);
- }
- break;
- case font_expand_code:
- /* Implement \.{\\fontexpand} */
- read_expand_font();
- break;
- case pdf_include_chars_code:
- /* Implement \.{\\pdfincludechars} */
- check_o_mode(pdf, "\\pdfincludechars", 1 << OMODE_PDF, false);
- pdf_include_chars(pdf);
- break;
- case pdf_info_code:
- /* Implement \.{\\pdfinfo} */
- check_o_mode(pdf, "\\pdfinfo", 1 << OMODE_PDF, false);
- scan_pdf_ext_toks();
- pdf_info_toks = concat_tokens(pdf_info_toks, def_ref);
- break;
- case pdf_literal_node:
- /* Implement \.{\\pdfliteral} */
- check_o_mode(pdf, "\\pdfliteral", 1 << OMODE_PDF, false);
- new_whatsit(pdf_literal_node);
- if (scan_keyword("direct"))
- set_pdf_literal_mode(tail, direct_always);
- else if (scan_keyword("page"))
- set_pdf_literal_mode(tail, direct_page);
- else
- set_pdf_literal_mode(tail, set_origin);
- scan_pdf_ext_toks();
- set_pdf_literal_type(tail, normal);
- set_pdf_literal_data(tail, def_ref);
- break;
- case pdf_colorstack_node:
- /* Implement \.{\\pdfcolorstack} */
- check_o_mode(pdf, "\\pdfcolorstack", 1 << OMODE_PDF, false);
- /* Scan and check the stack number and store in |cur_val| */
- scan_int();
- if (cur_val >= colorstackused()) {
- print_err("Unknown color stack number ");
- print_int(cur_val);
- help3
- ("Allocate and initialize a color stack with \\pdfcolorstackinit.",
- "I'll use default color stack 0 here.",
- "Proceed, with fingers crossed.");
- error();
- cur_val = 0;
- }
- if (cur_val < 0) {
- print_err("Invalid negative color stack number");
- help2("I'll use default color stack 0 here.",
- "Proceed, with fingers crossed.");
- error();
- cur_val = 0;
- }
- if (scan_keyword("set"))
- i = colorstack_set;
- else if (scan_keyword("push"))
- i = colorstack_push;
- else if (scan_keyword("pop"))
- i = colorstack_pop;
- else if (scan_keyword("current"))
- i = colorstack_current;
- else
- i = -1; /* error */
-
- if (i >= 0) {
- new_whatsit(pdf_colorstack_node);
- set_pdf_colorstack_stack(tail, cur_val);
- set_pdf_colorstack_cmd(tail, i);
- set_pdf_colorstack_data(tail, null);
- if (i <= colorstack_data) {
- scan_pdf_ext_toks();
- set_pdf_colorstack_data(tail, def_ref);
- }
- } else {
- print_err("Color stack action is missing");
- help3("The expected actions for \\pdfcolorstack:",
- " set, push, pop, current",
- "I'll ignore the color stack command.");
- error();
- }
- break;
- case pdf_setmatrix_node:
- /* Implement \.{\\pdfsetmatrix} */
- check_o_mode(pdf, "\\pdfsetmatrix", 1 << OMODE_PDF, false);
- new_whatsit(pdf_setmatrix_node);
- scan_pdf_ext_toks();
- set_pdf_setmatrix_data(tail, def_ref);
- break;
- case pdf_save_node:
- /* Implement \.{\\pdfsave} */
- check_o_mode(pdf, "\\pdfsave", 1 << OMODE_PDF, false);
- new_whatsit(pdf_save_node);
- break;
- case pdf_restore_node:
- /* Implement \.{\\pdfrestore} */
- check_o_mode(pdf, "\\pdfrestore", 1 << OMODE_PDF, false);
- new_whatsit(pdf_restore_node);
- break;
- case pdf_map_file_code:
- /* Implement \.{\\pdfmapfile} */
- check_o_mode(pdf, "\\pdfmapfile", 1 << OMODE_PDF, false);
- scan_pdf_ext_toks();
- pdfmapfile(def_ref);
- delete_token_ref(def_ref);
- break;
- case pdf_map_line_code:
- /* Implement \.{\\pdfmapline} */
- check_o_mode(pdf, "\\pdfmapline", 1 << OMODE_PDF, false);
- scan_pdf_ext_toks();
- pdfmapline(def_ref);
- delete_token_ref(def_ref);
- break;
- case pdf_names_code:
- /* Implement \.{\\pdfnames} */
- check_o_mode(pdf, "\\pdfnames", 1 << OMODE_PDF, false);
- scan_pdf_ext_toks();
- pdf_names_toks = concat_tokens(pdf_names_toks, def_ref);
- break;
- case pdf_obj_code:
- /* Implement \.{\\pdfobj} */
- check_o_mode(pdf, "\\pdfobj", 1 << OMODE_PDF, false);
- scan_obj(pdf);
- break;
- case pdf_outline_code:
- /* Implement \.{\\pdfoutline} */
- check_o_mode(pdf, "\\pdfoutline", 1 << OMODE_PDF, true);
- scan_pdfoutline(pdf);
- break;
- case pdf_refobj_node:
- /* Implement \.{\\pdfrefobj} */
- check_o_mode(pdf, "\\pdfrefobj", 1 << OMODE_PDF, false);
- scan_refobj(pdf);
- break;
- case pdf_refxform_node:
- /* Implement \.{\\pdfrefxform} */
- check_o_mode(pdf, "\\pdfrefxform", 1 << OMODE_PDF, false);
- scan_pdfrefxform(pdf);
- break;
- case pdf_refximage_node:
- /* Implement \.{\\pdfrefximage} */
- check_o_mode(pdf, "\\pdfrefximage", 1 << OMODE_PDF, false);
- scan_pdfrefximage(pdf);
- break;
- case save_pos_node:
- /* Implement \.{\\savepos} */
- new_whatsit(save_pos_node);
- break;
- case pdf_start_link_node:
- /* Implement \.{\\pdfstartlink} */
- check_o_mode(pdf, "\\pdfstartlink", 1 << OMODE_PDF, false);
- scan_startlink(pdf);
- break;
- case pdf_start_thread_node:
- /* Implement \.{\\pdfstartthread} */
- check_o_mode(pdf, "\\pdfstartthread", 1 << OMODE_PDF, false);
- new_annot_whatsit(pdf_start_thread_node);
- scan_thread_id();
- break;
- case pdf_thread_node:
- /* Implement \.{\\pdfthread} */
- check_o_mode(pdf, "\\pdfthread", 1 << OMODE_PDF, false);
- new_annot_whatsit(pdf_thread_node);
- scan_thread_id();
- break;
- case pdf_trailer_code:
- /* Implement \.{\\pdftrailer} */
- check_o_mode(pdf, "\\pdftrailer", 1 << OMODE_PDF, false);
- scan_pdf_ext_toks();
- pdf_trailer_toks = concat_tokens(pdf_trailer_toks, def_ref);
- break;
- case pdf_xform_code:
- /* Implement \.{\\pdfxform} */
- check_o_mode(pdf, "\\pdfxform", 1 << OMODE_PDF, false);
- scan_pdfxform(pdf);
- break;
- case pdf_ximage_code:
- /* Implement \.{\\pdfximage} */
- check_o_mode(pdf, "\\pdfximage", 1 << OMODE_PDF, false);
- /* png, jpeg, and pdf image handling depends on this done so early: */
- fix_pdf_minorversion(pdf);
- scan_pdfximage(pdf);
- break;
- case save_cat_code_table_code:
- /* Implement \.{\\savecatcodetable} */
- scan_int();
- if ((cur_val < 0) || (cur_val > 0x7FFF)) {
- print_err("Invalid \\catcode table");
- help1("All \\catcode table ids must be between 0 and 0x7FFF");
- error();
- } else {
- if (cur_val == cat_code_table) {
- print_err("Invalid \\catcode table");
- help1("You cannot overwrite the current \\catcode table");
- error();
- } else {
- copy_cat_codes(cat_code_table, cur_val);
}
- }
- break;
- case init_cat_code_table_code:
- /* Implement \.{\\initcatcodetable} */
- scan_int();
- if ((cur_val < 0) || (cur_val > 0x7FFF)) {
- print_err("Invalid \\catcode table");
- help1("All \\catcode table ids must be between 0 and 0x7FFF");
- error();
- } else {
- if (cur_val == cat_code_table) {
- print_err("Invalid \\catcode table");
- help1("You cannot overwrite the current \\catcode table");
- error();
+ break;
+ /* backend extensions have their own range starting at 32 */
+ case dvi_extension_code:
+ if (get_o_mode() == OMODE_DVI)
+ do_extension_dvi(immediate);
+ break;
+ case pdf_extension_code:
+ if (get_o_mode() == OMODE_PDF)
+ do_extension_pdf(immediate);
+ break;
+ default:
+ if (immediate) {
+ back_input();
} else {
- initex_cat_codes(cur_val);
+ confusion("ext1x");
}
+ break;
}
- break;
- case set_random_seed_code:
- /* Implement \.{\\setrandomseed} */
- /* Negative random seed values are silently converted to positive ones */
- scan_int();
- if (cur_val < 0)
- negate(cur_val);
- random_seed = cur_val;
- init_randoms(random_seed);
- break;
- case pdf_glyph_to_unicode_code:
- /* Implement \.{\\pdfglyphtounicode} */
- glyph_to_unicode();
- break;
- case late_lua_node:
- /* Implement \.{\\latelua} */
- new_whatsit(late_lua_node); /* type == normal */
- late_lua_name(tail) = scan_lua_state();
- (void) scan_toks(false, false);
- late_lua_data(tail) = def_ref;
- break;
- default:
- confusion("ext1");
- break;
+ } else {
+ /* no extension command, quite certainly following \immediate */
+ back_input();
}
}
-
@ Here is a subroutine that creates a whatsit node having a given |subtype|
and a given number of words. It initializes only the first word of the whatsit,
and appends it to the current list.
@@ -523,78 +521,191 @@ void new_whatsit(int s)
tail = p;
}
-
-@ The next subroutine uses |cur_chr| to decide what sort of whatsit is
-involved, and also inserts a |write_stream| number.
+@ The final line of this routine is slightly subtle; at least, the author
+didn't think about it until getting burnt! There is a used-up token list
+@^Knuth, Donald Ervin@>
+on the stack, namely the one that contained |end_write_token|. (We
+insert this artificial `\.{\\endwrite}' to prevent runaways, as explained
+above.) If it were not removed, and if there were numerous writes on a
+single page, the stack would overflow.
@c
-void new_write_whatsit(int w)
+#define end_write_token cs_token_flag+end_write
+
+void expand_macros_in_tokenlist(halfword p)
{
- new_whatsit(cur_chr);
- if (w != write_node_size) {
- scan_four_bit_int();
- } else {
- scan_int();
- if (cur_val < 0)
- cur_val = 17;
- else if ((cur_val > 15) && (cur_val != 18))
- cur_val = 16;
+ int old_mode; /* saved |mode| */
+ pointer q, r; /* temporary variables for list manipulation */
+ q = get_avail();
+ token_info(q) = right_brace_token + '}';
+ r = get_avail();
+ token_link(q) = r;
+ token_info(r) = end_write_token;
+ begin_token_list(q, inserted);
+ begin_token_list(write_tokens(p), write_text);
+ q = get_avail();
+ token_info(q) = left_brace_token + '{';
+ begin_token_list(q, inserted);
+ /* now we're ready to scan
+ `\.\{$\langle\,$token list$\,\rangle$\.{\} \\endwrite}' */
+ old_mode = mode;
+ mode = 0;
+ /* disable \.{\\prevdepth}, \.{\\spacefactor}, \.{\\lastskip}, \.{\\prevgraf} */
+ cur_cs = write_loc;
+ q = scan_toks(false, true); /* expand macros, etc. */
+ get_token();
+ if (cur_tok != end_write_token) {
+ /* Recover from an unbalanced write command */
+ const char *hlp[] = {
+ "On this page there's a \\write with fewer real {'s than }'s.",
+ "I can't handle that very well; good luck.", NULL
+ };
+ tex_error("Unbalanced write command", hlp);
+ do {
+ get_token();
+ } while (cur_tok != end_write_token);
}
- write_stream(tail) = cur_val;
+ mode = old_mode;
+ end_token_list(); /* conserve stack space */
}
-
-@ We have to check whether \.{\\pdfoutput} is set for using \pdfTeX{}
- extensions.
-
-@c
-void scan_pdf_ext_toks(void)
+void write_out(halfword p)
{
- (void) scan_toks(false, true); /* like \.{\\special} */
+ int old_setting; /* holds print |selector| */
+ int j; /* write stream number */
+ boolean clobbered; /* system string is ok? */
+ int ret; /* return value from |runsystem| */
+ char *s, *ss; /* line to be written, as a C string */
+ int callback_id;
+ int lua_retval;
+ expand_macros_in_tokenlist(p);
+ old_setting = selector;
+ j = write_stream(p);
+ if (j == write_target_system) {
+ selector = new_string;
+ } else if (write_open[j]) {
+ selector = j;
+ } else if ((j == term_only) && (selector == term_and_log)) {
+ /* write to the terminal if file isn't open */
+ selector = log_only;
+ tprint_nl("");
+ } else {
+ tprint_nl("");
+ }
+ s = tokenlist_to_cstring(def_ref, false, NULL);
+ if (selector < no_print) {
+ /* selector is a file */
+ callback_id = callback_defined(process_output_buffer_callback);
+ if (callback_id > 0) {
+ /* fix up the output buffer using callbacks */
+ lua_retval = run_callback(callback_id, "S->S", s, &ss);
+ if ((lua_retval == true) && (ss != NULL)) {
+ xfree(s);
+ s = ss;
+ }
+ }
+ }
+ tprint(s);
+ xfree(s);
+ print_ln();
+ flush_list(def_ref);
+ if (j == write_target_system) {
+ cur_string[cur_length] = '\0'; /* Convert newline to null. */
+ if (tracing_online <= 0)
+ selector = log_only; /* Show what we're doing in the log file. */
+ else
+ selector = term_and_log; /* Show what we're doing. */
+ /* If the log file isn't open yet, we can only send output to the terminal.
+ Calling |open_log_file| from here seems to result in bad data in the log.
+ */
+ if (!log_opened_global)
+ selector = term_only;
+ tprint_nl("runsystem(");
+ tprint((char *) cur_string);
+ tprint(")...");
+ if (shellenabledp) {
+ clobbered = false;
+ if (strlen((char *) cur_string) != cur_length)
+ clobbered = true;
+ /* minimal checking: NUL not allowed in argument string of |system|() */
+ if (clobbered) {
+ tprint("clobbered");
+ } else {
+ /* We have the command. See if we're allowed to execute it,
+ and report in the log. We don't check the actual exit status of
+ the command, or do anything with the output. */
+ ret = runsystem((char *) cur_string);
+ if (ret == -1)
+ tprint("quotation error in system command");
+ else if (ret == 0)
+ tprint("disabled (restricted)");
+ else if (ret == 1)
+ tprint("executed");
+ else if (ret == 2)
+ tprint("executed safely (allowed)");
+ }
+ } else {
+ tprint("disabled"); /* |shellenabledp| false */
+ }
+ print_char('.');
+ tprint_nl("");
+ print_ln();
+ cur_length = 0; /* erase the string */
+ }
+ selector = old_setting;
}
-@ We need to check whether the referenced object exists.
+void finalize_write_files(void) {
+ int k;
+ for (k = 0; k <= last_file_selector; k++) {
+ if (write_open[k]) {
+ lua_a_close_out(write_file[k]);
+ }
+ }
+}
-finds the node preceding the rightmost node |e|; |s| is some node before |e|
-@c
-halfword prev_rightmost(halfword s, halfword e)
-{
- halfword p = s;
- if (p == null)
- return null;
- while (vlink(p) != e) {
- p = vlink(p);
- if (p == null)
- return null;
+void initialize_write_files(void) {
+ int k;
+ for (k = 0; k <= last_write_open; k++) {
+ write_open[k] = false;
}
- return p;
}
-@ \.{\\pdfxform} and \.{\\pdfrefxform} are similiar to \.{\\pdfobj} and
- \.{\\pdfrefobj}
+void close_write_file(int id) {
+ if (write_open[id]) {
+ lua_a_close_out(write_file[id]);
+ write_open[id] = false;
+ }
+}
-@c
-int pdf_last_xform;
+boolean open_write_file(int id, char *fn) {
+ if (lua_a_open_out(&(write_file[id]), fn, (id + 1))) {
+ write_open[id] = true;
+ return true;
+ } else {
+ return false;
+ }
+}
-@ \.{\\pdfximage} and \.{\\pdfrefximage} are similiar to \.{\\pdfxform} and
- \.{\\pdfrefxform}. As we have to scan |<rule spec>| quite often, it is better
- have a |rule_node| that holds the most recently scanned |<rule spec>|.
+@ We have to check whether \.{\\outputmode} is set for using \pdfTeX{}
+ extensions.
@c
-int pdf_last_ximage;
-int pdf_last_ximage_pages;
-int pdf_last_ximage_colordepth;
-int pdf_last_annot;
+void scan_pdf_ext_toks(void)
+{
+ (void) scan_toks(false, true); /* like \.{\\special} */
+}
-@ pdflastlink needs an extra global variable
+@ the pdflast* need extra global variables
@c
+int pdf_last_annot;
int pdf_last_link;
-scaledpos pdf_last_pos = { 0, 0 };
-
+int pdf_last_obj;
+int pdf_retval; /* global multi-purpose return value */
-@ To implement primitives as \.{\\pdfinfo}, \.{\\pdfcatalog} or
-\.{\\pdfnames} we need to concatenate tokens lists.
+@ To implement primitives as \.{\\pdfextension info}, \.{\\pdfextension catalog} or
+\.{\\pdfextension names} we need to concatenate tokens lists.
@c
halfword concat_tokens(halfword q, halfword r)
@@ -610,33 +721,6 @@ halfword concat_tokens(halfword q, halfword r)
return q;
}
-@ @c
-int pdf_retval; /* global multi-purpose return value */
-
-@ @c
-halfword make_local_par_node(void)
-/* This function creates a |local_paragraph| node */
-{
- halfword p, q;
- p = new_node(whatsit_node, local_par_node);
- local_pen_inter(p) = local_inter_line_penalty;
- local_pen_broken(p) = local_broken_penalty;
- if (local_left_box != null) {
- q = copy_node_list(local_left_box);
- local_box_left(p) = q;
- local_box_left_width(p) = width(local_left_box);
- }
- if (local_right_box != null) {
- q = copy_node_list(local_right_box);
- local_box_right(p) = q;
- local_box_right_width(p) = width(local_right_box);
- }
- local_par_dir(p) = par_direction;
- return p;
-}
-
-
-
@ The \eTeX\ features available in extended mode are grouped into two
categories: (1)~Some of them are permanently enabled and have no
semantic effect as long as none of the additional primitives are
@@ -646,14 +730,12 @@ an \eTeX\ state variable named \.{\\...state}; the feature is enabled,
resp.\ disabled by assigning a positive, resp.\ non-positive value to
that integer.
-
@ In order to handle \.{\\everyeof} we need an array |eof_seen| of
boolean variables.
@c
boolean *eof_seen; /* has eof been seen? */
-
@ The |print_group| procedure prints the current level of grouping and
the name corresponding to |cur_group|.
@@ -726,7 +808,6 @@ void print_group(boolean e)
}
}
-
@ The |group_trace| procedure is called when a new level of grouping
begins (|e=false|) or ends (|e=true|) with |saved_value(-1)| containing the
line number.
@@ -756,7 +837,6 @@ and |cond_ptr| values for each input file.
save_pointer *grp_stack; /* initial |cur_boundary| */
halfword *if_stack; /* initial |cond_ptr| */
-
@ When a group ends that was apparently entered in a different input
file, the |group_warning| procedure is invoked in order to update the
|grp_stack|. If moreover \.{\\tracingnesting} is positive we want to
@@ -803,7 +883,6 @@ void group_warning(void)
}
}
-
@ When a conditional ends that was apparently started in a different
input file, the |if_warning| procedure is invoked in order to update the
|if_stack|. If moreover \.{\\tracingnesting} is positive we want to
@@ -901,19 +980,67 @@ void file_warning(void)
@ @c
halfword last_line_fill; /* the |par_fill_skip| glue node of the new paragraph */
-
@ The lua interface needs some extra functions. The functions
themselves are quite boring, but they are handy because otherwise this
internal stuff has to be accessed from C directly, where lots of the
defines are not available.
@c
+#define dimen(A) eqtb[scaled_base+(A)].hh.rh
+#define count(A) eqtb[count_base+(A)].hh.rh
+
#define get_tex_dimen_register(j) dimen(j)
#define get_tex_skip_register(j) skip(j)
+#define get_tex_mu_skip_register(j) mu_skip(j)
#define get_tex_count_register(j) count(j)
#define get_tex_attribute_register(j) attribute(j)
#define get_tex_box_register(j) box(j)
+int get_tex_extension_count_register(const char *s, int d)
+{
+ int cs;
+ cs = string_lookup(s,strlen(s));
+ if ((cs == undefined_control_sequence || cs == undefined_cs_cmd))
+ return d;
+ return (int) get_tex_count_register((equiv(cs) - count_base));
+}
+
+void set_tex_extension_count_register(const char *s, int d)
+{
+ int cs;
+ cs = string_lookup(s,strlen(s));
+ if ((cs == undefined_control_sequence || cs == undefined_cs_cmd))
+ return;
+ get_tex_count_register((equiv(cs) - count_base)) = d;
+}
+
+int get_tex_extension_dimen_register(const char *s, int d)
+{
+ int cs;
+ cs = string_lookup(s,strlen(s));
+ if ((cs == undefined_control_sequence || cs == undefined_cs_cmd))
+ return d;
+ return (int) get_tex_dimen_register((equiv(cs) - scaled_base));
+}
+
+void set_tex_extension_dimen_register(const char *s, int d)
+{
+ int cs;
+ cs = string_lookup(s,strlen(s));
+ if ((cs == undefined_control_sequence || cs == undefined_cs_cmd))
+ return;
+ get_tex_dimen_register((equiv(cs) - scaled_base)) = d;
+}
+
+int get_tex_extension_toks_register(const char *s)
+{
+ int cs;
+ cs = string_lookup(s,strlen(s));
+ if ((cs == undefined_control_sequence || cs == undefined_cs_cmd))
+ return null;
+ return toks((equiv(cs) - toks_base)); /* a pointer to a token list */
+}
+
int set_tex_dimen_register(int j, scaled v)
{
int a; /* return non-nil for error */
@@ -938,6 +1065,19 @@ int set_tex_skip_register(int j, halfword v)
return 0;
}
+int set_tex_mu_skip_register(int j, halfword v)
+{
+ int a; /* return non-nil for error */
+ if (global_defs > 0)
+ a = 4;
+ else
+ a = 0;
+ if (type(v) != glue_spec_node)
+ return 1;
+ word_define(j + mu_skip_base, v);
+ return 0;
+}
+
int set_tex_count_register(int j, scaled v)
{
int a; /* return non-nil for error */
@@ -1000,6 +1140,22 @@ int set_tex_toks_register(int j, lstring s)
return 0;
}
+int scan_tex_toks_register(int j, int c, lstring s)
+{
+ halfword ref;
+ int a;
+ ref = get_avail();
+ (void) str_scan_toks(c,s);
+ set_token_ref_count(ref, 0);
+ set_token_link(ref, token_link(temp_token_head));
+ if (global_defs > 0)
+ a = 4;
+ else
+ a = 0;
+ define(j + toks_base, call_cmd, ref);
+ return 0;
+}
+
scaled get_tex_box_width(int j)
{
halfword q = box(j);
@@ -1034,7 +1190,6 @@ int set_tex_box_height(int j, scaled v)
return 0;
}
-
scaled get_tex_box_depth(int j)
{
halfword q = box(j);
@@ -1052,7 +1207,6 @@ int set_tex_box_depth(int j, scaled v)
return 0;
}
-
@ This section is devoted to the {\sl Synchronize \TeX nology}
- or simply {\sl Sync\TeX} - used to synchronize between input and output.
This section explains how synchronization basics are implemented.
@@ -1086,7 +1240,6 @@ the {\sl Sync\TeX} related options, and the {\sl Sync\TeX} controller will read
@c
int synctexoption;
-
@ A convenient primitive is provided:
\.{\\synctex=1} in the input source file enables synchronization whereas
\.{\\synctex=0} disables it.
@@ -1103,7 +1256,6 @@ the correct value when quite everything is initialized.
@c
int synctexoffset; /* holds the true value of |synctex_code| */
-
@ Synchronization is achieved with the help of an auxiliary file named
`\.{{\sl jobname}.synctex}' ({\sl jobname} is the contents of the
\.{\\jobname} macro), where a {\sl Sync\TeX} controller implemented
@@ -1165,7 +1317,6 @@ If the input comes from the terminal or a pseudo file, the |synctex_tag| is set
It results in automatically disabling synchronization for material
input from the terminal or pseudo files.
-
Synchronized nodes are boxes, math, kern and glue nodes.
Other nodes should be synchronized too, in particular math noads.
\TeX\ assumes that math, kern and glue nodes have the same size,
@@ -1190,7 +1341,6 @@ Of course, all this assumes that {\sl Sync\TeX} is turned off from the command l
@^synctex@>
@^synchronization@>
-
@ Here are extra variables for Web2c. (This numbering of the
system-dependent section allows easy integration of Web2c and e-\TeX, etc.)
@^<system dependencies@>
@@ -1209,7 +1359,7 @@ int shellenabledp;
int restrictedshell;
char *output_comment;
-@ Are we printing extra info as we read the format file?
+@ Are we printing extra info as we read the format file?
@c
boolean debug_format_file;
diff --git a/Build/source/texk/web2c/luatexdir/tex/inputstack.w b/Build/source/texk/web2c/luatexdir/tex/inputstack.w
index 0f591c3c776..aaeec71e65f 100644
--- a/Build/source/texk/web2c/luatexdir/tex/inputstack.w
+++ b/Build/source/texk/web2c/luatexdir/tex/inputstack.w
@@ -378,7 +378,7 @@ void show_context(void)
}
for (q = p; q <= first_count - 1; q++)
print_valid_utf8(q);
- print_ln();
+ print_ln();
for (q = 1; q <= n; q++)
print_char(' '); /* print |n| spaces to begin line~2 */
if (m + n <= error_line)
diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.h b/Build/source/texk/web2c/luatexdir/tex/linebreak.h
index af51d2c25a9..9ac444b7a37 100644
--- a/Build/source/texk/web2c/luatexdir/tex/linebreak.h
+++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.h
@@ -70,33 +70,34 @@ extern halfword find_protchar_right(halfword l, halfword r);
/* skipable nodes at the margins during character protrusion */
-# define cp_skipable(a) ((! is_char_node((a))) && \
- ((type((a)) == ins_node) \
- || (type((a)) == mark_node) \
- || (type((a)) == adjust_node) \
- || (type((a)) == penalty_node) \
- || ((type((a)) == whatsit_node) && \
- (subtype((a)) != pdf_refximage_node) && \
- (subtype((a)) != pdf_refxform_node)) \
- /* reference to an image or XObject form */ \
- || ((type((a)) == disc_node) && \
- (vlink_pre_break(a) == null) && \
- (vlink_post_break(a) == null) && \
- (vlink_no_break(a) == null)) \
- /* an empty |disc_node| */ \
- || ((type((a)) == math_node) && \
- (surround((a)) == 0)) \
- || ((type((a)) == kern_node) && \
- ((width((a)) == 0) || \
- (subtype((a)) == normal))) \
- || ((type((a)) == glue_node) && \
- (glue_ptr((a)) == zero_glue)) \
- || ((type((a)) == hlist_node) && \
- (width((a)) == 0) && \
- (height((a)) == 0) && \
- (depth((a)) == 0) && \
- (list_ptr((a)) == null)) \
- ))
+# define zero_dimensions(a) ( \
+ (width((a)) == 0) && \
+ (height((a)) == 0) && \
+ (depth((a)) == 0) \
+)
+
+# define empty_disc(a) ( \
+ (vlink_pre_break(a) == null) && \
+ (vlink_post_break(a) == null) && \
+ (vlink_no_break(a) == null) \
+)
+
+# define cp_skipable(a) ( (! is_char_node((a))) && ( \
+ (type((a)) == ins_node) \
+ || (type((a)) == mark_node) \
+ || (type((a)) == adjust_node) \
+ || (type((a)) == penalty_node) \
+ || (type((a)) == boundary_node) \
+ || (type((a)) == whatsit_node) \
+ || (type((a)) == dir_node) \
+ || (type((a)) == local_par_node) \
+ || ((type((a)) == rule_node) && zero_dimensions(a)) \
+ || ((type((a)) == disc_node) && empty_disc(a)) \
+ || ((type((a)) == math_node) && (surround((a)) == 0)) \
+ || ((type((a)) == kern_node) && ((width((a)) == 0) || (subtype((a)) == normal))) \
+ || ((type((a)) == glue_node) && (glue_ptr((a)) == zero_glue)) \
+ || ((type((a)) == hlist_node) && (list_ptr((a)) == null) && zero_dimensions(a)) \
+) )
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
index e8cd3542a46..90167e43938 100644
--- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w
+++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
@@ -155,16 +155,16 @@ void line_break(boolean d, int line_break_context)
addressof(cur_list.tail_field));
if (callback_id > 0) {
/* find the correct value for the |just_box| */
- halfword box_search = cur_list.tail_field;
+ halfword box_search = cur_list.tail_field;
just_box = null;
- if (box_search != null) {
+ if (box_search != null) {
do {
- if (type(box_search) == hlist_node) {
+ if (type(box_search) == hlist_node) {
just_box = box_search;
}
box_search = vlink(box_search);
} while (box_search != null);
- }
+ }
if (just_box == null) {
help3
("A linebreaking routine should return a non-empty list of nodes",
@@ -176,17 +176,13 @@ void line_break(boolean d, int line_break_context)
} else {
if (int_par(tracing_paragraphs_code) > 0) {
begin_diagnostic();
- tprint_nl
- ("Lua linebreak_filter failed, reverting to default on line ");
print_int(line);
end_diagnostic(true);
}
}
}
if (callback_id == 0) {
- if ((!is_char_node(vlink(temp_head)))
- && ((type(vlink(temp_head)) == whatsit_node)
- && (subtype(vlink(temp_head)) == local_par_node)))
+ if ((!is_char_node(vlink(temp_head))) && ((type(vlink(temp_head)) == local_par_node)))
paragraph_dir = local_par_dir(vlink(temp_head));
else
assert(0); /* |paragraph_dir = 0|; */
@@ -196,10 +192,6 @@ void line_break(boolean d, int line_break_context)
int_par(tolerance_code),
dimen_par(emergency_stretch_code),
int_par(looseness_code),
- /*
- int_par(hyphen_penalty_code),
- int_par(ex_hyphen_penalty_code),
- */
int_par(adjust_spacing_code),
equiv(par_shape_loc),
int_par(adj_demerits_code),
@@ -217,8 +209,8 @@ void line_break(boolean d, int line_break_context)
int_par(inter_line_penalty_code),
int_par(club_penalty_code),
equiv(club_penalties_loc),
- (d ? equiv(display_widow_penalties_loc) : equiv(widow_penalties_loc)),
- (d ? int_par(display_widow_penalty_code) : int_par(widow_penalty_code)),
+ (d ? equiv(display_widow_penalties_loc) : equiv(widow_penalties_loc)),
+ (d ? int_par(display_widow_penalty_code) : int_par(widow_penalty_code)),
int_par(broken_penalty_code),
final_par_glue);
}
@@ -306,14 +298,14 @@ static short hlist_stack_level = 0;
static void push_node(halfword p)
{
if (hlist_stack_level >= max_hlist_stack)
- pdf_error("push_node", "stack overflow");
+ normal_error("push_node","stack overflow");
hlist_stack[hlist_stack_level++] = p;
}
static halfword pop_node(void)
{
if (hlist_stack_level <= 0) /* would point to some bug */
- pdf_error("pop_node", "stack underflow (internal error)");
+ normal_error("pop_node","stack underflow (internal error)");
return hlist_stack[--hlist_stack_level];
}
@@ -333,23 +325,20 @@ static boolean check_expand_pars(internal_font_number f)
if (cur_font_step < 0)
cur_font_step = font_step(f);
else if (cur_font_step != font_step(f))
- pdf_error("font expansion",
- "using fonts with different step of expansion in one paragraph is not allowed");
+ normal_error("font expansion","using fonts with different step of expansion in one paragraph is not allowed");
m = font_max_stretch(f);
if (m != 0) {
if (max_stretch_ratio < 0)
max_stretch_ratio = m;
else if (max_stretch_ratio != m)
- pdf_error("font expansion",
- "using fonts with different limit of expansion in one paragraph is not allowed");
+ normal_error("font expansion","using fonts with different limit of expansion in one paragraph is not allowed");
}
m = font_max_shrink(f);
if (m != 0) {
if (max_shrink_ratio < 0)
max_shrink_ratio = -m;
else if (max_shrink_ratio != -m)
- pdf_error("font expansion",
- "using fonts with different limit of expansion in one paragraph is not allowed");
+ normal_error("font expansion","using fonts with different limit of expansion in one paragraph is not allowed");
}
return true;
}
@@ -361,33 +350,44 @@ static boolean check_expand_pars(internal_font_number f)
{
halfword t;
boolean run;
- if ((vlink(l) != null) && (type(l) == hlist_node) && (width(l) == 0)
- && (height(l) == 0) && (depth(l) == 0) && (list_ptr(l) == null)) {
- l = vlink(l); /*for paragraph start with \.{\\parindent} = 0pt */
- } else if (d) {
+ boolean done = false ;
+ while ((vlink(l) != null) && (type(l) == hlist_node) && zero_dimensions(l) && (list_ptr(l) == null)) {
+ /*for paragraph start with \.{\\parindent} = 0pt or any empty hbox */
+ l = vlink(l);
+ done = true ;
+ }
+ if ((!done) && (type(l) == local_par_node)) {
+ l = vlink(l);
+ done = true ;
+ }
+ if ((!done) && d) {
while ((vlink(l) != null) && (!(is_char_node(l) || non_discardable(l)))) {
- l = vlink(l); /* std.\ discardables at line break, \TeX book, p 95 */
+ /* std.\ discardables at line break, \TeX book, p 95 */
+ l = vlink(l);
}
}
- hlist_stack_level = 0;
- run = true;
- do {
- t = l;
- while (run && (type(l) == hlist_node) && (list_ptr(l) != null)) {
- push_node(l);
- l = list_ptr(l);
- }
- while (run && cp_skipable(l)) {
- while ((vlink(l) == null) && (hlist_stack_level > 0)) {
- l = pop_node(); /* don't visit this node again */
- run = false;
+ if (type(l) != glyph_node) {
+ hlist_stack_level = 0;
+ run = true;
+ do {
+ t = l;
+ while (run && (type(l) == hlist_node) && (list_ptr(l) != null)) {
+ push_node(l);
+ l = list_ptr(l);
}
- if (vlink(l) != null)
- l = vlink(l);
- else if (hlist_stack_level == 0)
- run = false;
- }
- } while (t != l);
+ while (run && cp_skipable(l)) {
+ while ((vlink(l) == null) && (hlist_stack_level > 0)) {
+ l = pop_node(); /* don't visit this node again */
+ run = false;
+ }
+ if (vlink(l) != null) {
+ l = vlink(l);
+ } else if (hlist_stack_level == 0) {
+ run = false;
+ }
+ }
+ } while (t != l);
+ }
return l;
}
@@ -723,11 +723,11 @@ static int line_diff; /*the difference between the current line number
#define kern_break() { \
if ((!is_char_node(vlink(cur_p))) && auto_breaking) \
if (type(vlink(cur_p))==glue_node) \
- ext_try_break(0,unhyphenated_node, line_break_dir, adjust_spacing, \
- par_shape_ptr, adj_demerits, \
- tracing_paragraphs, protrude_chars, \
- line_penalty, last_line_fit, \
- double_hyphen_demerits, final_hyphen_demerits,first_p,cur_p); \
+ ext_try_break(0,unhyphenated_node, line_break_dir, adjust_spacing, \
+ par_shape_ptr, adj_demerits, \
+ tracing_paragraphs, protrude_chars, \
+ line_penalty, last_line_fit, \
+ double_hyphen_demerits, final_hyphen_demerits,first_p,cur_p); \
if (type(cur_p)!=math_node) active_width[1]+=width(cur_p); \
else active_width[1]+=surround(cur_p); \
}
@@ -777,8 +777,7 @@ Replacement texts and discretionary texts are supposed to contain
only character nodes, kern nodes, and box or rule nodes.
@c
-static void add_to_widths(halfword s, int line_break_dir,
- int adjust_spacing, scaled * widths)
+static void add_to_widths(halfword s, int line_break_dir, int adjust_spacing, scaled * widths)
{
while (s != null) {
if (is_char_node(s)) {
@@ -795,7 +794,7 @@ static void add_to_widths(halfword s, int line_break_dir,
widths[1] += pack_width(line_break_dir, box_dir(s), s, false);
break;
case kern_node:
- if ((adjust_spacing > 1) && (subtype(s) == normal)) {
+ if ((adjust_spacing == 2) && (subtype(s) == normal)) {
add_kern_stretch(widths[8], s);
add_kern_shrink(widths[9], s);
}
@@ -806,7 +805,7 @@ static void add_to_widths(halfword s, int line_break_dir,
case disc_node: /* TH temp */
break;
default:
- confusion("add_disc_widths");
+ confusion("invalid node found in discretionary"); /* todo: report type */
}
}
s = vlink(s);
@@ -819,8 +818,7 @@ It is used only once, but deserves it own function because of orthogonality
with the |add_to_widths| function.
@c
-static void sub_from_widths(halfword s, int line_break_dir,
- int adjust_spacing, scaled * widths)
+static void sub_from_widths(halfword s, int line_break_dir, int adjust_spacing, scaled * widths)
{
while (s != null) {
/* Subtract the width of node |s| from |break_width|; */
@@ -838,7 +836,7 @@ static void sub_from_widths(halfword s, int line_break_dir,
widths[1] -= pack_width(line_break_dir, box_dir(s), s, false);
break;
case kern_node:
- if ((adjust_spacing > 1) && (subtype(s) == normal)) {
+ if ((adjust_spacing == 2) && (subtype(s) == normal)) {
sub_kern_stretch(widths[8], s);
sub_kern_shrink(widths[9], s);
}
@@ -849,7 +847,7 @@ static void sub_from_widths(halfword s, int line_break_dir,
case disc_node: /* TH temp */
break;
default:
- confusion("sub_disc_widths");
+ confusion("invalid node found in discretionary"); /* todo: report type */
break;
}
}
@@ -879,9 +877,7 @@ static void sub_from_widths(halfword s, int line_break_dir,
@c
static void
-compute_break_width(int break_type, int line_break_dir, int adjust_spacing,
- halfword p
- /*, halfword s */ )
+compute_break_width(int break_type, int line_break_dir, int adjust_spacing, halfword p)
{
halfword s; /* glue and other 'whitespace' to be skipped after a break
* used if unhyphenated, or |post_break==empty| */
@@ -914,10 +910,8 @@ compute_break_width(int break_type, int line_break_dir, int adjust_spacing,
path, as we are talking about the breaking on {\it this} position.
*/
- sub_from_widths(vlink_no_break(p), line_break_dir, adjust_spacing,
- break_width);
- add_to_widths(vlink_post_break(p), line_break_dir, adjust_spacing,
- break_width);
+ sub_from_widths(vlink_no_break(p), line_break_dir, adjust_spacing, break_width);
+ add_to_widths(vlink_post_break(p), line_break_dir, adjust_spacing, break_width);
do_one_seven_eight(add_disc_width_to_break_width);
if (vlink_post_break(p) == null) {
s = vlink(p); /* no |post_break|: 'skip' any 'whitespace' following */
@@ -927,6 +921,15 @@ compute_break_width(int break_type, int line_break_dir, int adjust_spacing,
}
while (s != null) {
switch (type(s)) {
+ case math_node:
+ /* begin mathskip code */
+ if (math_skip == zero_glue) {
+ break_width[1] -= surround(s);
+ break;
+ } else {
+ /* fall through */
+ }
+ /* end mathskip code */
case glue_node:
/*Subtract glue from |break_width|; */
{
@@ -938,9 +941,6 @@ compute_break_width(int break_type, int line_break_dir, int adjust_spacing,
break;
case penalty_node:
break;
- case math_node:
- break_width[1] -= surround(s);
- break;
case kern_node:
if (subtype(s) != explicit)
return;
@@ -1163,8 +1163,7 @@ ext_try_break(int pi,
if (no_break_yet) {
no_break_yet = false;
do_all_eight(set_break_width_to_background);
- compute_break_width(break_type, line_break_dir,
- adjust_spacing, cur_p);
+ compute_break_width(break_type, line_break_dir, adjust_spacing, cur_p);
}
/* Insert a delta node to prepare for breaks at |cur_p|; */
/* We use the fact that |type(active)<>delta_node|. */
@@ -1317,8 +1316,7 @@ ext_try_break(int pi,
o = find_protchar_right(l1, o);
}
/* now the left margin */
- if ((l1 != null) && (type(l1) == disc_node)
- && (vlink_post_break(l1) != null)) {
+ if ((l1 != null) && (type(l1) == disc_node) && (vlink_post_break(l1) != null)) {
/* FIXME: first 'char' could be a disc! */
l1 = vlink_post_break(l1); /* protrude the first char */
} else {
@@ -1326,7 +1324,7 @@ ext_try_break(int pi,
}
shortfall += (left_pw(l1) + right_pw(o));
}
- if ((shortfall != 0) && (adjust_spacing > 1)) {
+ if ((shortfall != 0) && (adjust_spacing == 2)) {
margin_kern_stretch = 0;
margin_kern_shrink = 0;
if (protrude_chars > 1) {
@@ -1345,15 +1343,13 @@ ext_try_break(int pi,
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;
+ 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)) {
if ((total_font_shrink + margin_kern_shrink) > -shortfall)
- shortfall = -((total_font_shrink + margin_kern_shrink) /
- (max_shrink_ratio / cur_font_step)) / 2;
+ shortfall = -((total_font_shrink + margin_kern_shrink) / (max_shrink_ratio / cur_font_step)) / 2;
else
shortfall += (total_font_shrink + margin_kern_shrink);
}
@@ -1630,10 +1626,6 @@ ext_do_line_break(int paragraph_dir,
int tolerance,
scaled emergency_stretch,
int looseness,
- /*
- int hyphen_penalty,
- int ex_hyphen_penalty,
- */
int adjust_spacing,
halfword par_shape_ptr,
int adj_demerits,
@@ -1801,9 +1793,8 @@ ext_do_line_break(int paragraph_dir,
auto_breaking = true;
cur_p = vlink(temp_head);
/* LOCAL: Initialize with first |local_paragraph| node */
- if ((cur_p != null) && (type(cur_p) == whatsit_node)
- && (subtype(cur_p) == local_par_node)) {
- alink(cur_p) = temp_head; /* this used to be an assert, but may as well force it */
+ if ((cur_p != null) && (type(cur_p) == local_par_node)) {
+ alink(cur_p) = temp_head; /* this used to be an assert, but may as well force it */
internal_pen_inter = local_pen_inter(cur_p);
internal_pen_broken = local_pen_broken(cur_p);
init_internal_left_box = local_box_left(cur_p);
@@ -1852,8 +1843,8 @@ ext_do_line_break(int paragraph_dir,
#endif
}
}
- if (cur_p == null) { /* TODO */
- confusion("linebreak_tail");
+ if (cur_p == null) {
+ normal_error("linebreak","invalid list tail, probably missing glue");
}
/* Determine legal breaks: As we move through the hlist, we need to keep
the |active_width| array up to date, so that the badness of individual
@@ -1870,33 +1861,34 @@ ext_do_line_break(int paragraph_dir,
case rule_node:
active_width[1] += width(cur_p);
break;
- case whatsit_node:
- /* Advance past a whatsit node in the |line_break| loop; */
- switch (subtype(cur_p)) {
- case local_par_node: /* LOCAL: Advance past a |local_paragraph| node; */
- internal_pen_inter = local_pen_inter(cur_p);
- internal_pen_broken = local_pen_broken(cur_p);
- internal_left_box = local_box_left(cur_p);
- internal_left_box_width = local_box_left_width(cur_p);
- internal_right_box = local_box_right(cur_p);
- internal_right_box_width = local_box_right_width(cur_p);
- break;
- case dir_node: /* DIR: Adjust the dir stack for the |line_break| routine; */
- if (dir_dir(cur_p) >= 0) {
- line_break_dir = dir_dir(cur_p);
- push_dir_node(cur_p,dir_ptr); /* adds to |dir_ptr| */
- } else {
- pop_dir_node(dir_ptr);
- if (dir_ptr != null)
- line_break_dir = dir_dir(dir_ptr);
- }
- break;
- case pdf_refxform_node:
- case pdf_refximage_node:
- active_width[1] += width(cur_p);
+ case dir_node: /* DIR: Adjust the dir stack for the |line_break| routine; */
+ if (dir_dir(cur_p) >= 0) {
+ line_break_dir = dir_dir(cur_p);
+ push_dir_node(cur_p,dir_ptr); /* adds to |dir_ptr| */
+ } else {
+ pop_dir_node(dir_ptr);
+ if (dir_ptr != null)
+ line_break_dir = dir_dir(dir_ptr);
}
- /* / Advance past a whatsit node in the |line_break| loop/; */
break;
+ case local_par_node: /* LOCAL: Advance past a |local_paragraph| node; */
+ internal_pen_inter = local_pen_inter(cur_p);
+ internal_pen_broken = local_pen_broken(cur_p);
+ internal_left_box = local_box_left(cur_p);
+ internal_left_box_width = local_box_left_width(cur_p);
+ internal_right_box = local_box_right(cur_p);
+ internal_right_box_width = local_box_right_width(cur_p);
+ break;
+ case math_node:
+ auto_breaking = (subtype(cur_p) == after);
+ /* begin mathskip code */
+ if (math_skip == zero_glue) {
+ kern_break();
+ break;
+ } else {
+ /* fall through */
+ }
+ /* end mathskip code */
case glue_node:
/* If node |cur_p| is a legal breakpoint, call |try_break|;
then update the active widths by including the glue in
@@ -1926,13 +1918,18 @@ ext_do_line_break(int paragraph_dir,
active_width[1] += width(q);
active_width[2 + stretch_order(q)] += stretch(q);
active_width[7] += shrink(q);
+ /* begin mathskip code */
+ if (type(cur_p)==math_node) {
+ active_width[1]+=surround(cur_p);
+ }
+ /* end mathskip code */
break;
case kern_node:
if (subtype(cur_p) == explicit) {
kern_break();
} else {
active_width[1] += width(cur_p);
- if ((adjust_spacing > 1) && (subtype(cur_p) == normal)) {
+ if ((adjust_spacing == 2) && (subtype(cur_p) == normal)) {
add_kern_stretch(active_width[8], cur_p);
add_kern_shrink(active_width[9], cur_p);
}
@@ -1970,8 +1967,7 @@ ext_do_line_break(int paragraph_dir,
double_hyphen_demerits,
final_hyphen_demerits, first_p, cur_p);
} else {
- add_to_widths(s, line_break_dir, adjust_spacing,
- disc_width);
+ add_to_widths(s, line_break_dir, adjust_spacing, disc_width);
do_one_seven_eight(add_disc_width_to_active_width);
ext_try_break(actual_penalty, hyphenated_node,
line_break_dir, adjust_spacing,
@@ -1990,8 +1986,7 @@ ext_do_line_break(int paragraph_dir,
assert(type(vlink(cur_p)) == disc_node &&
subtype(vlink(cur_p)) == select_disc);
s = vlink_pre_break(vlink(cur_p));
- add_to_widths(s, line_break_dir, adjust_spacing,
- disc_width);
+ add_to_widths(s, line_break_dir, adjust_spacing, disc_width);
ext_try_break(actual_penalty, hyphenated_node,
line_break_dir, adjust_spacing,
par_shape_ptr, adj_demerits,
@@ -2008,8 +2003,7 @@ ext_do_line_break(int paragraph_dir,
do_one_seven_eight(reset_disc_width);
/* add select |no_break| to |active_width| */
s = vlink_no_break(vlink(cur_p));
- add_to_widths(s, line_break_dir, adjust_spacing,
- disc_width);
+ add_to_widths(s, line_break_dir, adjust_spacing, disc_width);
ext_try_break(actual_penalty, hyphenated_node,
line_break_dir, adjust_spacing,
par_shape_ptr, adj_demerits,
@@ -2024,12 +2018,7 @@ ext_do_line_break(int paragraph_dir,
}
}
s = vlink_no_break(cur_p);
- add_to_widths(s, line_break_dir, adjust_spacing,
- active_width);
- break;
- case math_node:
- auto_breaking = (subtype(cur_p) == after);
- kern_break();
+ add_to_widths(s, line_break_dir, adjust_spacing, active_width);
break;
case penalty_node:
ext_try_break(penalty(cur_p), unhyphenated_node, line_break_dir,
@@ -2039,6 +2028,9 @@ ext_do_line_break(int paragraph_dir,
double_hyphen_demerits, final_hyphen_demerits,
first_p, cur_p);
break;
+ case boundary_node:
+ case whatsit_node:
+ /* / Advance past a whatsit node in the |line_break| loop/; */
case mark_node:
case ins_node:
case adjust_node:
diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.w b/Build/source/texk/web2c/luatexdir/tex/mainbody.w
index 030e58024f3..745a1531019 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mainbody.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.w
@@ -436,11 +436,17 @@ void main_body(void)
while ((iloc < ilimit) && (buffer[iloc] == ' '))
incr(iloc);
}
- if (pdf_output_option != 0)
- int_par(pdf_output_code) = pdf_output_value;
- if (pdf_draftmode_option != 0)
- pdf_draftmode = static_pdf->draftmode = pdf_draftmode_value;
+ if (output_mode_option != 0)
+ int_par(output_mode_code) = output_mode_value;
+ if (draft_mode_option != 0) {
+ int_par(draft_mode_code) = draft_mode_value;
+ }
+ /* this is specific for the pdf backend */
+ if (int_par(draft_mode_code) != 0) { /* should move */
+ static_pdf->draftmode = int_par(draft_mode_code);
+ }
pdf_init_map_file((char *) pdftex_map);
+ /* */
if (end_line_char_inactive)
decr(ilimit);
else
@@ -486,14 +492,10 @@ This program doesn't bother to close the input files that may still be open.
@c
void close_files_and_terminate(void)
{
- int k; /* all-purpose index */
int callback_id;
PDF pdf = static_pdf;
callback_id = callback_defined(stop_run_callback);
- /* Finish the extensions */
- for (k = 0; k <= 15; k++)
- if (write_open[k])
- lua_a_close_out(write_file[k]);
+ finalize_write_files();
if (int_par(tracing_stats_code) > 0) {
if (callback_id == 0) {
/* Output statistics about this job */
@@ -529,24 +531,21 @@ void close_files_and_terminate(void)
}
}
wake_up_terminal();
+ /* rubish, these pdf arguments, passed, needs to be fixed, e.g. with a dummy in dvi */
ensure_output_state(pdf, ST_OMODE_FIX);
- switch (pdf->o_mode) {
+ switch (output_mode_used) {
case OMODE_NONE: /* during initex run */
break;
case OMODE_PDF:
if (history == fatal_error_stop) {
remove_pdffile(pdf);
- print_err
- (" ==> Fatal error occurred, no output PDF file produced!");
+ print_err(" ==> Fatal error occurred, no output PDF file produced!");
} else
finish_pdf_file(pdf, luatex_version, get_luatexrevision());
break;
case OMODE_DVI:
finish_dvi_file(pdf, luatex_version, get_luatexrevision());
break;
- case OMODE_LUA:
- finish_lua_file(pdf);
- break;
default:
assert(0);
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h
index 192b83e1c36..ea22ff80dc7 100644
--- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h
+++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h
@@ -1,5 +1,5 @@
/* maincontrol.h
-
+
Copyright 2009 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -156,8 +156,10 @@ extern void fixup_directions(void);
/* Assignments from Lua need helpers. */
# define is_int_assign(cmd) (cmd==assign_int_cmd)
+# define is_attr_assign(cmd) (cmd==assign_attr_cmd)
# define is_dim_assign(cmd) (cmd==assign_dimen_cmd)
# define is_glue_assign(cmd) (cmd==assign_glue_cmd)
+# define is_mu_glue_assign(cmd) (cmd==assign_mu_glue_cmd)
# define is_toks_assign(cmd) (cmd==assign_toks_cmd)
# define show_code 0 /* \.{\\show} */
diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
index e78220d5cb8..0219320ec41 100644
--- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
+++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
@@ -23,6 +23,8 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
+/* these will move to equivalents.h */
+
@ @c
#define explicit 1
#define acc_kern 2
@@ -32,7 +34,7 @@
#define tag_code 5
#define auto_kern explicit
#define no_lig_code 6
-
+#define gp_code_base 7
#define prev_depth cur_list.prev_depth_field
#define space_factor cur_list.space_factor_field
@@ -55,13 +57,9 @@
#define page_top_offset dimen_par(page_top_offset_code)
#define page_right_offset dimen_par(page_right_offset_code)
#define page_bottom_offset dimen_par(page_bottom_offset_code)
-#define pdf_h_origin dimen_par(pdf_h_origin_code)
-#define pdf_v_origin dimen_par(pdf_v_origin_code)
-#define pdf_px_dimen dimen_par(pdf_px_dimen_code)
+#define px_dimen dimen_par(px_dimen_code)
-#define pdf_image_resolution int_par(pdf_image_resolution_code)
-
-#define math_eqno_gap_step int_par(math_eqno_gap_step_code)
+#define math_eqno_gap_step int_par(math_eqno_gap_step_code)
#define escape_char int_par(escape_char_code)
#define max_dead_cycles int_par(max_dead_cycles_code)
@@ -73,6 +71,7 @@
#define looseness int_par(looseness_code)
#define space_skip glue_par(space_skip_code)
#define xspace_skip glue_par(xspace_skip_code)
+#define math_skip glue_par(math_skip_code)
#define every_vbox equiv(every_vbox_loc)
#define split_top_skip glue_par(split_top_skip_code)
@@ -250,12 +249,24 @@ static void run_app_space (void) {
}
}
-@ Append a |cancel_boundary_node|
+@ Append a |boundary_node|
@c
static void run_no_boundary (void) {
- new_whatsit(cancel_boundary_node);
+ halfword n ;
+ n = new_node(boundary_node,cancel_boundary);
+ couple_nodes(tail, n);
+ tail = n;
+}
+static void run_boundary (void) {
+ halfword n ;
+ n = new_node(boundary_node,user_boundary);
+ scan_int();
+ boundary_value(n) = cur_val;
+ couple_nodes(tail, n);
+ tail = n;
}
+
@ @c
static void run_char_ghost (void) {
int t;
@@ -294,7 +305,7 @@ static void run_ignore_spaces (void) {
} else {
int t = scanner_status;
scanner_status = normal;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
scanner_status = t;
cur_cs = prim_lookup(cs_text(cur_cs));
if (cur_cs != undefined_primitive) {
@@ -627,9 +638,105 @@ static void run_after_group (void) {
@ @c
static void run_extension (void) {
- do_extension(static_pdf);
+ do_extension(0);
}
+static void run_normal (void) {
+{
+ switch (cur_chr) {
+ case save_pos_code:
+ new_whatsit(save_pos_node);
+ break;
+ case save_cat_code_table_code:
+ scan_int();
+ if ((cur_val < 0) || (cur_val > 0x7FFF)) {
+ print_err("Invalid \\catcode table");
+ help1("All \\catcode table ids must be between 0 and 0x7FFF");
+ error();
+ } else {
+ if (cur_val == cat_code_table) {
+ print_err("Invalid \\catcode table");
+ help1("You cannot overwrite the current \\catcode table");
+ error();
+ } else {
+ copy_cat_codes(cat_code_table, cur_val);
+ }
+ }
+ break;
+ case init_cat_code_table_code:
+ scan_int();
+ if ((cur_val < 0) || (cur_val > 0x7FFF)) {
+ print_err("Invalid \\catcode table");
+ help1("All \\catcode table ids must be between 0 and 0x7FFF");
+ error();
+ } else {
+ if (cur_val == cat_code_table) {
+ print_err("Invalid \\catcode table");
+ help1("You cannot overwrite the current \\catcode table");
+ error();
+ } else {
+ initex_cat_codes(cur_val);
+ }
+ }
+ break;
+ case set_random_seed_code:
+ /* Negative random seed values are silently converted to positive ones */
+ scan_int();
+ if (cur_val < 0)
+ negate(cur_val);
+ random_seed = cur_val;
+ init_randoms(random_seed);
+ break;
+ case late_lua_code:
+ new_whatsit(late_lua_node); /* type == normal */
+ late_lua_name(tail) = scan_lua_state();
+ (void) scan_toks(false, false);
+ late_lua_data(tail) = def_ref;
+ break;
+ case expand_font_code:
+ read_expand_font();
+ break;
+ default:
+ confusion("int1");
+ break;
+ }
+ }
+}
+
+/*
+ this is experimental and not used for production, only for testing and writing
+ macros
+
+*/
+
+static void run_option(void) {
+ int a = 0 ;
+ switch (cur_chr) {
+ case math_option_code:
+ if (scan_keyword("old")) {
+ scan_int();
+ word_define(int_base+math_old_code, cur_val);
+ /* math_no_char_italic = cur_val; */
+ } else if (scan_keyword("noitaliccompensation")) {
+ scan_int();
+ word_define(int_base+math_no_italic_compensation_code, cur_val);
+ /* math_no_italic_compensation = cur_val; */
+ } else if (scan_keyword("nocharitalic")) {
+ scan_int();
+ word_define(int_base+math_no_char_italic_code, cur_val);
+ /* math_no_char_italic = cur_val; */
+ } else if (scan_keyword("useoldfractionscaling")) {
+ scan_int();
+ word_define(int_base+math_use_old_fraction_scaling_code, cur_val);
+ } else {
+ normal_warning("mathoption","unknown key",false,false);
+ }
+ break;
+ default:
+ /* harmless */
+ break;
+ }
+}
@ For mode-independent commands, the following macro is useful.
@@ -657,12 +764,14 @@ static void init_main_control (void) {
jump_table[hmode + spacer_cmd] = run_app_space;
jump_table[hmode + ex_space_cmd] = run_app_space;
jump_table[mmode + ex_space_cmd] = run_app_space;
+ jump_table[hmode + boundary_cmd] = run_boundary;
jump_table[hmode + no_boundary_cmd] = run_no_boundary;
jump_table[hmode + char_ghost_cmd] = run_char_ghost;
jump_table[mmode + char_ghost_cmd] = run_char_ghost;
any_mode(relax_cmd, run_relax);
jump_table[vmode + spacer_cmd] = run_relax;
jump_table[mmode + spacer_cmd] = run_relax;
+ jump_table[mmode + boundary_cmd] = run_relax;
jump_table[mmode + no_boundary_cmd] = run_relax;
any_mode(ignore_spaces_cmd,run_ignore_spaces);
jump_table[vmode + stop_cmd] = run_stop;
@@ -705,9 +814,13 @@ static void init_main_control (void) {
jump_table[mmode + un_vbox_cmd] = insert_dollar_sign;
jump_table[mmode + valign_cmd] = insert_dollar_sign;
jump_table[mmode + hrule_cmd] = insert_dollar_sign;
+ jump_table[mmode + no_hrule_cmd] = insert_dollar_sign;
jump_table[vmode + hrule_cmd] = run_rule;
+ jump_table[vmode + no_hrule_cmd] = run_rule;
jump_table[hmode + vrule_cmd] = run_rule;
+ jump_table[hmode + no_vrule_cmd] = run_rule;
jump_table[mmode + vrule_cmd] = run_rule;
+ jump_table[mmode + no_vrule_cmd] = run_rule;
jump_table[vmode + vskip_cmd] = append_glue;
jump_table[hmode + hskip_cmd] = append_glue;
jump_table[mmode + hskip_cmd] = append_glue;
@@ -736,17 +849,20 @@ static void init_main_control (void) {
jump_table[vmode + math_shift_cs_cmd] = run_new_graf;
jump_table[vmode + un_hbox_cmd] = run_new_graf;
jump_table[vmode + vrule_cmd] = run_new_graf;
+ jump_table[vmode + no_vrule_cmd] = run_new_graf;
jump_table[vmode + accent_cmd] = run_new_graf;
jump_table[vmode + discretionary_cmd] = run_new_graf;
jump_table[vmode + hskip_cmd] = run_new_graf;
jump_table[vmode + valign_cmd] = run_new_graf;
jump_table[vmode + ex_space_cmd] = run_new_graf;
+ jump_table[vmode + boundary_cmd] = run_new_graf;
jump_table[vmode + no_boundary_cmd] = run_new_graf;
jump_table[vmode + par_end_cmd] = run_par_end_vmode;
jump_table[hmode + par_end_cmd] = run_par_end_hmode;
jump_table[hmode + stop_cmd] = head_for_vmode;
jump_table[hmode + vskip_cmd] = head_for_vmode;
jump_table[hmode + hrule_cmd] = head_for_vmode;
+ jump_table[hmode + no_hrule_cmd] = head_for_vmode;
jump_table[hmode + un_vbox_cmd] = head_for_vmode;
jump_table[hmode + halign_cmd] = head_for_vmode;
any_mode(insert_cmd,begin_insert_or_adjust);
@@ -828,7 +944,8 @@ static void init_main_control (void) {
any_mode(set_font_cmd, prefixed_command);
any_mode(def_font_cmd, prefixed_command);
any_mode(letterspace_font_cmd, prefixed_command);
- any_mode(pdf_copy_font_cmd, prefixed_command);
+ any_mode(copy_font_cmd, prefixed_command);
+ any_mode(set_font_id_cmd, prefixed_command);
any_mode(register_cmd, prefixed_command);
any_mode(advance_cmd, prefixed_command);
any_mode(multiply_cmd, prefixed_command);
@@ -847,7 +964,9 @@ static void init_main_control (void) {
any_mode(message_cmd,issue_message);
any_mode(case_shift_cmd, shift_case);
any_mode(xray_cmd, show_whatever);
+ any_mode(normal_cmd, run_normal);
any_mode(extension_cmd, run_extension);
+ any_mode(option_cmd, run_option);
}
@ And here is |main_control| itself. It is quite short nowadays.
@@ -1331,7 +1450,7 @@ void box_end(int box_context)
append_list(pre_adjust_head, pre_adjust_tail);
pre_adjust_tail = null;
}
- append_to_vlist(cur_box);
+ append_to_vlist(cur_box,lua_key_index(box));
if (adjust_tail != null) {
if (adjust_head != adjust_tail)
append_list(adjust_head, adjust_tail);
@@ -1400,8 +1519,9 @@ void scan_box(int box_context)
if (cur_cmd == make_box_cmd) {
begin_box(box_context);
- } else if ((box_context >= leader_flag)
- && ((cur_cmd == hrule_cmd) || (cur_cmd == vrule_cmd))) {
+ } else if ((box_context >= leader_flag) &&
+ ((cur_cmd == hrule_cmd) || (cur_cmd == vrule_cmd) ||
+ (cur_cmd == no_hrule_cmd) || (cur_cmd == no_vrule_cmd))) {
cur_box = scan_rule_spec();
box_end(box_context);
} else {
@@ -1432,7 +1552,7 @@ void new_graf(boolean indented)
p = new_null_box();
box_dir(p) = par_direction;
width(p) = par_indent;
- subtype(p) = HLIST_SUBTYPE_INDENT;
+ subtype(p) = indent_list;
q = tail;
tail_append(p);
} else {
@@ -1768,6 +1888,10 @@ void append_discretionary(void)
disc_penalty(tail) = int_par(ex_hyphen_penalty_code);
} else {
/* \discretionary */
+ if (scan_keyword("penalty")) {
+ scan_int();
+ disc_penalty(tail) = cur_val;
+ }
incr(save_ptr);
set_saved_record(-1, saved_disc, 0, 0);
new_save_level(disc_group);
@@ -2703,9 +2827,14 @@ void prefixed_command(void)
case letterspace_font_cmd:
new_letterspaced_font((small_number) a);
break;
- case pdf_copy_font_cmd:
+ case copy_font_cmd:
make_font_copy((small_number) a);
break;
+ case set_font_id_cmd:
+ scan_int();
+ if (is_valid_font(cur_val))
+ zset_cur_font(cur_val);
+ break ;
case set_interaction_cmd:
new_interaction();
break;
@@ -2744,7 +2873,7 @@ void fixup_directions(void)
/* DIR: Add local dir node */
tail_append(new_dir(text_direction));
- dir_dir(tail) = temporary_dir - 64;
+ dir_dir(tail) = temporary_dir - dir_swap;
}
if (temp_no_whatsits != 0) {
/* LOCAL: Add local paragraph node */
@@ -2832,14 +2961,6 @@ void assign_internal_value(int a, halfword p, int val)
word_define(p, val);
}
break;
- case pdf_compress_level_code:
- static_pdf->compress_level = val;
- word_define(p, val);
- break;
- case pdf_objcompresslevel_code:
- static_pdf->objcompresslevel = val;
- word_define(p, val);
- break;
case language_code:
if (val < 0) {
word_define(int_base + cur_lang_code, -1);
@@ -3494,9 +3615,8 @@ void initialize(void)
format_ident = 0;
format_name = get_nullstr();
- for (k = 0; k <= 17; k++)
- write_open[k] = false;
initialize_directions();
+ initialize_write_files();
seconds_and_micros(epochseconds, microseconds);
init_start_time(static_pdf);
@@ -3597,20 +3717,8 @@ void initialize(void)
cs_text(frozen_primitive) = maketexstring("primitive");
create_null_font();
font_bytes = 0;
- pdf_h_origin = one_inch;
- pdf_v_origin = one_inch;
- pdf_compress_level = 9;
- pdf_objcompresslevel = 0;
- pdf_decimal_digits = 3;
- pdf_image_resolution = 72;
- pdf_minor_version = 4;
- pdf_gamma = 1000;
- pdf_image_gamma = 2200;
- pdf_image_hicolor = 1;
- pdf_image_apply_gamma = 0;
- pdf_px_dimen = one_bp;
- pdf_draftmode = 0;
- math_eqno_gap_step = 1000 ;
+ px_dimen = one_bp;
+ math_eqno_gap_step = 1000 ;
cs_text(frozen_protection) = maketexstring("inaccessible");
format_ident = maketexstring(" (INITEX)");
cs_text(end_write) = maketexstring("endwrite");
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.h b/Build/source/texk/web2c/luatexdir/tex/mlist.h
index 487282ca0c7..1f6551cea69 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.h
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.h
@@ -1,5 +1,5 @@
/* mlist.h
-
+
Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
@@ -24,6 +24,9 @@
extern int cur_size;
+/* extern int math_no_italic_compensation ; */ /* $$\int\limits_{|}^{|}$$ */
+/* extern int math_no_char_italic ; */ /* catcode"1D443=12 $$P( PP$$ \catcode"1D443=11 $$P( PP$$ */
+
extern void run_mlist_to_hlist(halfword, int, boolean);
extern void fixup_math_parameters(int fam_id, int size_id, int f, int lvl);
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w
index be0cf552378..ccb882b521c 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w
@@ -17,13 +17,52 @@
% You should have received a copy of the GNU General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
-/* hh-ls: by using couple_nodes instead of vlink we make sure that we can backtrack as well as have valid prev links */
+% (HH / 0.82+):
+@ In traditional \TeX\ the italic correction is added to the width of the glyph. This
+is part of the engine design and related font design. In opentype math this is
+different. There the italic correction had more explicit usage. The 1.7 spec
+says:
-\def\LuaTeX{Lua\TeX}
+italic correction:
+
+ When a run of slanted characters is followed by a straight character (such as
+ an operator or a delimiter), the italics correction of the last glyph is added
+ to its advance width.
+
+ When positioning limits on an N-ary operator (e.g., integral sign), the horizontal
+ position of the upper limit is moved to the right by ½ of the italics correction,
+ while the position of the lower limit is moved to the left by the same distance.
+
+ When positioning superscripts and subscripts, their default horizontal positions are
+ also different by the amount of the italics correction of the preceding glyph.
+
+math kerning:
+
+ Set the default horizontal position for the superscript as shifted relative to the
+ position of the subscript by the italics correction of the base glyph.
+
+Before this was specified we had to gamble a bit and assume that cambria was the font
+benchmark and trust our eyes (and msword) for the logic. I must admit that I have been
+fighting these italics in fonts (and the heuristics that Lua\TeX\ provided) right from
+the start (e.g. using Lua based postprocessing) but by now we know more and have more
+fonts to test with. More fonts are handy because not all fonts are alike when it comes
+to italics. Axis are another area of concern, as it looks like opentype math fonts often
+already apply that shift.
@ @c
+#define math_old int_par(math_old_code)
+#define math_no_italic_compensation int_par(math_no_italic_compensation_code)
+#define math_no_char_italic int_par(math_no_char_italic_code)
+#define math_use_old_fraction_scaling int_par(math_use_old_fraction_scaling_code)
+#define is_new_mathfont(A) ((font_math_params(A) >0) && (math_old == 0))
+#define is_old_mathfont(A,B) ((font_math_params(A)==0) && (font_params(A)>=(B)))
+
+@
+\def\LuaTeX{Lua\TeX}
+
+@ @c
#include "ptexlib.h"
#include "lua/luatex-api.h"
@@ -37,48 +76,42 @@
#define script_space dimen_par(script_space_code)
#define disable_lig int_par(disable_lig_code)
#define disable_kern int_par(disable_kern_code)
+#define scripts_mode int_par(math_scripts_mode_code)
#define nDEBUG
-#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)); \
- } \
+#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)); \
+ } \
} while (0)
-
-#define DEFINE_MATH_PARAMETERS(A,B,C,D) do { \
- if (B==text_size) { \
- def_math_param(A, text_style, (C),D); \
- def_math_param(A, cramped_text_style, (C),D); \
- } else if (B==script_size) { \
- def_math_param(A, script_style, (C),D); \
- def_math_param(A, cramped_script_style, (C),D); \
- } else if (B==script_script_size) { \
- def_math_param(A, script_script_style, (C),D); \
- def_math_param(A, cramped_script_script_style, (C),D); \
- } \
+#define DEFINE_MATH_PARAMETERS(A,B,C,D) do { \
+ if (B==text_size) { \
+ def_math_param(A, text_style, (C),D); \
+ def_math_param(A, cramped_text_style, (C),D); \
+ } else if (B==script_size) { \
+ def_math_param(A, script_style, (C),D); \
+ def_math_param(A, cramped_script_style, (C),D); \
+ } else if (B==script_script_size) { \
+ def_math_param(A, script_script_style, (C),D); \
+ def_math_param(A, cramped_script_script_style, (C),D); \
+ } \
} 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 is_new_mathfont(A) (font_math_params(A)>0)
-#define is_old_mathfont(A,B) (font_math_params(A)==0 && font_params(A)>=(B))
-
-
#define font_MATH_par(a,b) \
(font_math_params(a)>=b ? font_math_param(a,b) : undefined_math_parameter)
-
@ here are the math parameters that are font-dependant
@ Before an mlist is converted to an hlist, \TeX\ makes sure that
@@ -95,24 +128,24 @@ following macros, which take a size code as their parameter; for example,
#define total_mathex_params 13
#define mathsy(A,B) font_param(fam_fnt(2,A),B)
-#define math_x_height(A) mathsy(A,5) /* height of `\.x' */
-#define math_quad(A) mathsy(A,6) /* \.{18mu} */
-#define num1(A) mathsy(A,8) /* numerator shift-up in display styles */
-#define num2(A) mathsy(A,9) /* numerator shift-up in non-display, non-\.{\\atop} */
-#define num3(A) mathsy(A,10) /* numerator shift-up in non-display \.{\\atop} */
-#define denom1(A) mathsy(A,11) /* denominator shift-down in display styles */
-#define denom2(A) mathsy(A,12) /* denominator shift-down in non-display styles */
-#define sup1(A) mathsy(A,13) /* superscript shift-up in uncramped display style */
-#define sup2(A) mathsy(A,14) /* superscript shift-up in uncramped non-display */
-#define sup3(A) mathsy(A,15) /* superscript shift-up in cramped styles */
-#define sub1(A) mathsy(A,16) /* subscript shift-down if superscript is absent */
-#define sub2(A) mathsy(A,17) /* subscript shift-down if superscript is present */
-#define sup_drop(A) mathsy(A,18) /* superscript baseline below top of large box */
-#define sub_drop(A) mathsy(A,19) /* subscript baseline below bottom of large box */
-#define delim1(A) mathsy(A,20) /* size of \.{\\atopwithdelims} delimiters in display styles */
-#define delim2(A) mathsy(A,21) /* size of \.{\\atopwithdelims} delimiters in non-displays */
-#define axis_height(A) mathsy(A,22) /* height of fraction lines above the baseline */
+#define math_x_height(A) mathsy(A,5) /* height of `\.x' */
+#define math_quad(A) mathsy(A,6) /* \.{18mu} */
+#define num1(A) mathsy(A,8) /* numerator shift-up in display styles */
+#define num2(A) mathsy(A,9) /* numerator shift-up in non-display, non-\.{\\atop} */
+#define num3(A) mathsy(A,10) /* numerator shift-up in non-display \.{\\atop} */
+#define denom1(A) mathsy(A,11) /* denominator shift-down in display styles */
+#define denom2(A) mathsy(A,12) /* denominator shift-down in non-display styles */
+#define sup1(A) mathsy(A,13) /* superscript shift-up in uncramped display style */
+#define sup2(A) mathsy(A,14) /* superscript shift-up in uncramped non-display */
+#define sup3(A) mathsy(A,15) /* superscript shift-up in cramped styles */
+#define sub1(A) mathsy(A,16) /* subscript shift-down if superscript is absent */
+#define sub2(A) mathsy(A,17) /* subscript shift-down if superscript is present */
+#define sup_drop(A) mathsy(A,18) /* superscript baseline below top of large box */
+#define sub_drop(A) mathsy(A,19) /* subscript baseline below bottom of large box */
+#define delim1(A) mathsy(A,20) /* size of \.{\\atopwithdelims} delimiters in display styles */
+#define delim2(A) mathsy(A,21) /* size of \.{\\atopwithdelims} delimiters in non-displays */
+#define axis_height(A) mathsy(A,22) /* height of fraction lines above the baseline */
@ The math-extension parameters have similar macros, but the size code is
omitted (since it is always |cur_size| when we refer to such parameters).
@@ -150,13 +183,7 @@ FlattenedAccentBaseHeight:
needs support for MathTopAccentAttachment table to be
implemented first
-SkewedFractionHorizontalGap,
-SkewedFractionVerticalGap:
- I am not sure it makes sense implementing skewed fractions,
- so I would like to see an example first
-
Also still TODO for OpenType Math:
- * extensible large operators
* prescripts
@ this is not really a math parameter at all
@@ -181,7 +208,6 @@ static void math_param_error(const char *param, int style)
return;
}
-
@ @c
static scaled accent_base_height(int f)
{
@@ -210,7 +236,7 @@ scaled get_math_quad(int var)
}
@ this parameter is different because it is called with a size
- specifier instead of a style specifier.
+specifier instead of a style specifier.
@c
static scaled math_axis(int b)
@@ -244,7 +270,6 @@ static scaled get_math_quad_size(int b)
return get_math_param(math_param_quad, var);
}
-
@ @c
static scaled minimum_operator_size(int var)
{
@@ -253,7 +278,7 @@ static scaled minimum_operator_size(int var)
}
@ Old-style fonts do not define the |radical_rule|. This allows |make_radical| to select
- the backward compatibility code, and it means that we can't raise an error here.
+the backward compatibility code, and it means that we can't raise an error here.
@c
static scaled radical_rule(int var)
@@ -277,6 +302,30 @@ static scaled do_get_math_param_or_error(int var, int param, const char *name)
return a;
}
+@ A variant on a suggestion on the list based on analysis by UV.
+
+@c
+static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) {
+ scaled delta, delta1, delta2;
+ if (axis) {
+ delta2 = max_d + math_axis(cur_size);
+ } else {
+ delta2 = max_d;
+ }
+ delta1 = max_h + max_d - delta2;
+ if (delta2 > delta1) {
+ /* |delta1| is max distance from axis */
+ delta1 = delta2;
+ }
+ delta = (delta1 / 500) * delimiter_factor;
+ delta2 = delta1 + delta1 - delimiter_shortfall;
+ if (delta < delta2) {
+ return delta2;
+ } else {
+ return delta;
+ }
+}
+
@ @c
#define radical_degree_before(a) get_math_param_or_error(a, radical_degree_before)
#define radical_degree_after(a) get_math_param_or_error(a, radical_degree_after)
@@ -310,7 +359,11 @@ static scaled do_get_math_param_or_error(int var, int param, const char *name)
#define fraction_denom_vgap(a) get_math_param_or_error(a, fraction_denom_vgap)
#define fraction_num_up(a) get_math_param_or_error(a, fraction_num_up)
#define fraction_denom_down(a) get_math_param_or_error(a, fraction_denom_down)
-#define fraction_del_size(a) get_math_param_or_error(a, fraction_del_size)
+#define fraction_del_size_new(a) get_math_param_or_error(a, fraction_del_size)
+#define fraction_del_size_old(a) get_math_param(a, math_param_fraction_del_size)
+
+#define skewed_fraction_hgap(a) get_math_param_or_error(a, skewed_fraction_hgap)
+#define skewed_fraction_vgap(a) get_math_param_or_error(a, skewed_fraction_vgap)
#define limit_above_vgap(a) get_math_param_or_error(a, limit_above_vgap)
#define limit_above_bgap(a) get_math_param_or_error(a, limit_above_bgap)
@@ -337,494 +390,482 @@ void fixup_math_parameters(int fam_id, int size_id, int f, int lvl)
{
if (is_new_mathfont(f)) { /* fix all known parameters */
- DEFINE_MATH_PARAMETERS(math_param_quad, size_id, font_size(f), lvl);
- DEFINE_DMATH_PARAMETERS(math_param_quad, size_id, font_size(f), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_quad, size_id,
+ font_size(f), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_quad, size_id,
+ font_size(f), lvl);
DEFINE_MATH_PARAMETERS(math_param_axis, size_id,
- font_MATH_par(f, AxisHeight), lvl);
+ font_MATH_par(f, AxisHeight), lvl);
DEFINE_DMATH_PARAMETERS(math_param_axis, size_id,
- font_MATH_par(f, AxisHeight), lvl);
+ font_MATH_par(f, AxisHeight), lvl);
DEFINE_MATH_PARAMETERS(math_param_overbar_kern, size_id,
- font_MATH_par(f, OverbarExtraAscender), lvl);
+ font_MATH_par(f, OverbarExtraAscender), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_kern, size_id,
- font_MATH_par(f, OverbarExtraAscender), lvl);
+ font_MATH_par(f, OverbarExtraAscender), lvl);
DEFINE_MATH_PARAMETERS(math_param_overbar_rule, size_id,
- font_MATH_par(f, OverbarRuleThickness), lvl);
+ font_MATH_par(f, OverbarRuleThickness), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_rule, size_id,
- font_MATH_par(f, OverbarRuleThickness), lvl);
+ font_MATH_par(f, OverbarRuleThickness), lvl);
DEFINE_MATH_PARAMETERS(math_param_overbar_vgap, size_id,
- font_MATH_par(f, OverbarVerticalGap), lvl);
+ font_MATH_par(f, OverbarVerticalGap), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_vgap, size_id,
- font_MATH_par(f, OverbarVerticalGap), lvl);
+ font_MATH_par(f, OverbarVerticalGap), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_kern, size_id,
- font_MATH_par(f, UnderbarExtraDescender), lvl);
+ font_MATH_par(f, UnderbarExtraDescender), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_kern, size_id,
- font_MATH_par(f, UnderbarExtraDescender), lvl);
+ font_MATH_par(f, UnderbarExtraDescender), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_rule, size_id,
- font_MATH_par(f, UnderbarRuleThickness), lvl);
+ font_MATH_par(f, UnderbarRuleThickness), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_rule, size_id,
- font_MATH_par(f, UnderbarRuleThickness), lvl);
+ font_MATH_par(f, UnderbarRuleThickness), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_vgap, size_id,
- font_MATH_par(f, UnderbarVerticalGap), lvl);
+ font_MATH_par(f, UnderbarVerticalGap), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_vgap, size_id,
- font_MATH_par(f, UnderbarVerticalGap), lvl);
+ font_MATH_par(f, UnderbarVerticalGap), lvl);
DEFINE_MATH_PARAMETERS(math_param_under_delimiter_vgap, size_id,
- font_MATH_par(f, StretchStackGapAboveMin), lvl);
+ font_MATH_par(f, StretchStackGapAboveMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_under_delimiter_vgap, size_id,
- font_MATH_par(f, StretchStackGapAboveMin), lvl);
+ font_MATH_par(f, StretchStackGapAboveMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_under_delimiter_bgap, size_id,
- font_MATH_par(f, StretchStackBottomShiftDown),
- lvl);
+ font_MATH_par(f, StretchStackBottomShiftDown), lvl);
DEFINE_DMATH_PARAMETERS(math_param_under_delimiter_bgap, size_id,
- font_MATH_par(f, StretchStackBottomShiftDown),
- lvl);
+ font_MATH_par(f, StretchStackBottomShiftDown), lvl);
DEFINE_MATH_PARAMETERS(math_param_over_delimiter_vgap, size_id,
- font_MATH_par(f, StretchStackGapBelowMin), lvl);
+ font_MATH_par(f, StretchStackGapBelowMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_over_delimiter_vgap, size_id,
- font_MATH_par(f, StretchStackGapBelowMin), lvl);
+ font_MATH_par(f, StretchStackGapBelowMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_over_delimiter_bgap, size_id,
- font_MATH_par(f, StretchStackTopShiftUp), lvl);
+ font_MATH_par(f, StretchStackTopShiftUp), lvl);
DEFINE_DMATH_PARAMETERS(math_param_over_delimiter_bgap, size_id,
- font_MATH_par(f, StretchStackTopShiftUp), lvl);
-
+ font_MATH_par(f, StretchStackTopShiftUp), lvl);
DEFINE_MATH_PARAMETERS(math_param_stack_num_up, size_id,
- font_MATH_par(f, StackTopShiftUp), lvl);
+ font_MATH_par(f, StackTopShiftUp), lvl);
DEFINE_DMATH_PARAMETERS(math_param_stack_num_up, size_id,
- font_MATH_par(f, StackTopDisplayStyleShiftUp),
- lvl);
+ font_MATH_par(f, StackTopDisplayStyleShiftUp), lvl);
DEFINE_MATH_PARAMETERS(math_param_stack_denom_down, size_id,
- font_MATH_par(f, StackBottomShiftDown), lvl);
+ font_MATH_par(f, StackBottomShiftDown), lvl);
DEFINE_DMATH_PARAMETERS(math_param_stack_denom_down, size_id,
- font_MATH_par(f,
- StackBottomDisplayStyleShiftDown),
- lvl);
+ font_MATH_par(f, StackBottomDisplayStyleShiftDown), lvl);
DEFINE_MATH_PARAMETERS(math_param_stack_vgap, size_id,
- font_MATH_par(f, StackGapMin), lvl);
+ font_MATH_par(f, StackGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_stack_vgap, size_id,
- font_MATH_par(f, StackDisplayStyleGapMin), lvl);
+ font_MATH_par(f, StackDisplayStyleGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_kern, size_id,
- font_MATH_par(f, RadicalExtraAscender), lvl);
+ font_MATH_par(f, RadicalExtraAscender), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_kern, size_id,
- font_MATH_par(f, RadicalExtraAscender), lvl);
+ font_MATH_par(f, RadicalExtraAscender), lvl);
DEFINE_DMATH_PARAMETERS(math_param_operator_size, size_id,
- font_MATH_par(f, DisplayOperatorMinHeight),
- lvl);
+ font_MATH_par(f, DisplayOperatorMinHeight), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_rule, size_id,
- font_MATH_par(f, RadicalRuleThickness), lvl);
+ font_MATH_par(f, RadicalRuleThickness), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_rule, size_id,
- font_MATH_par(f, RadicalRuleThickness), lvl);
+ font_MATH_par(f, RadicalRuleThickness), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_vgap, size_id,
- font_MATH_par(f, RadicalVerticalGap), lvl);
+ font_MATH_par(f, RadicalVerticalGap), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_vgap, size_id,
- font_MATH_par(f,
- RadicalDisplayStyleVerticalGap),
- lvl);
+ font_MATH_par(f, RadicalDisplayStyleVerticalGap), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_before, size_id,
- font_MATH_par(f, RadicalKernBeforeDegree), lvl);
+ font_MATH_par(f, RadicalKernBeforeDegree), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_before, size_id,
- font_MATH_par(f, RadicalKernBeforeDegree), lvl);
+ font_MATH_par(f, RadicalKernBeforeDegree), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_after, size_id,
- font_MATH_par(f, RadicalKernAfterDegree), lvl);
+ font_MATH_par(f, RadicalKernAfterDegree), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_after, size_id,
- font_MATH_par(f, RadicalKernAfterDegree), lvl);
+ font_MATH_par(f, RadicalKernAfterDegree), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_raise, size_id,
- font_MATH_par(f,
- RadicalDegreeBottomRaisePercent),
- lvl);
+ font_MATH_par(f, RadicalDegreeBottomRaisePercent), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_raise, size_id,
- font_MATH_par(f,
- RadicalDegreeBottomRaisePercent),
- lvl);
+ font_MATH_par(f, RadicalDegreeBottomRaisePercent), lvl);
+
if (size_id == text_size) {
def_math_param(math_param_sup_shift_up, display_style,
- font_MATH_par(f, SuperscriptShiftUp), lvl);
+ font_MATH_par(f, SuperscriptShiftUp), lvl);
def_math_param(math_param_sup_shift_up, cramped_display_style,
- font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
+ font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
def_math_param(math_param_sup_shift_up, text_style,
- font_MATH_par(f, SuperscriptShiftUp), lvl);
+ font_MATH_par(f, SuperscriptShiftUp), lvl);
def_math_param(math_param_sup_shift_up, cramped_text_style,
- font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
+ font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
} else if (size_id == script_size) {
def_math_param(math_param_sup_shift_up, script_style,
- font_MATH_par(f, SuperscriptShiftUp), lvl);
+ font_MATH_par(f, SuperscriptShiftUp), lvl);
def_math_param(math_param_sup_shift_up, cramped_script_style,
- font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
+ font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
} else if (size_id == script_script_size) {
def_math_param(math_param_sup_shift_up, script_script_style,
- font_MATH_par(f, SuperscriptShiftUp), lvl);
+ font_MATH_par(f, SuperscriptShiftUp), lvl);
def_math_param(math_param_sup_shift_up, cramped_script_script_style,
- font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
+ font_MATH_par(f, SuperscriptShiftUpCramped), lvl);
}
DEFINE_MATH_PARAMETERS(math_param_sub_shift_drop, size_id,
- font_MATH_par(f, SubscriptBaselineDropMin), lvl);
+ font_MATH_par(f, SubscriptBaselineDropMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_shift_drop, size_id,
- font_MATH_par(f, SubscriptBaselineDropMin),
- lvl);
+ font_MATH_par(f, SubscriptBaselineDropMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_sup_shift_drop, size_id,
- font_MATH_par(f, SuperscriptBaselineDropMax),
- lvl);
+ font_MATH_par(f, SuperscriptBaselineDropMax), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sup_shift_drop, size_id,
- font_MATH_par(f, SuperscriptBaselineDropMax),
- lvl);
+ font_MATH_par(f, SuperscriptBaselineDropMax), lvl);
DEFINE_MATH_PARAMETERS(math_param_sub_shift_down, size_id,
- font_MATH_par(f, SubscriptShiftDown), lvl);
+ font_MATH_par(f, SubscriptShiftDown), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_shift_down, size_id,
- font_MATH_par(f, SubscriptShiftDown), lvl);
+ font_MATH_par(f, SubscriptShiftDown), lvl);
- if (font_MATH_par(f, SubscriptShiftDownWithSuperscript) !=
- undefined_math_parameter) {
+ if (font_MATH_par(f, SubscriptShiftDownWithSuperscript) != undefined_math_parameter) {
DEFINE_MATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- font_MATH_par(f,
- SubscriptShiftDownWithSuperscript),
- lvl);
+ font_MATH_par(f, SubscriptShiftDownWithSuperscript), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- font_MATH_par(f,
- SubscriptShiftDownWithSuperscript),
- lvl);
+ font_MATH_par(f, SubscriptShiftDownWithSuperscript), lvl);
} else {
DEFINE_MATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- font_MATH_par(f, SubscriptShiftDown), lvl);
+ font_MATH_par(f, SubscriptShiftDown), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- font_MATH_par(f, SubscriptShiftDown), lvl);
+ font_MATH_par(f, SubscriptShiftDown), lvl);
}
DEFINE_MATH_PARAMETERS(math_param_sub_top_max, size_id,
- font_MATH_par(f, SubscriptTopMax), lvl);
+ font_MATH_par(f, SubscriptTopMax), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_top_max, size_id,
- font_MATH_par(f, SubscriptTopMax), lvl);
+ font_MATH_par(f, SubscriptTopMax), lvl);
DEFINE_MATH_PARAMETERS(math_param_sup_bottom_min, size_id,
- font_MATH_par(f, SuperscriptBottomMin), lvl);
+ font_MATH_par(f, SuperscriptBottomMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sup_bottom_min, size_id,
- font_MATH_par(f, SuperscriptBottomMin), lvl);
+ font_MATH_par(f, SuperscriptBottomMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_sup_sub_bottom_max, size_id,
- font_MATH_par(f,
- SuperscriptBottomMaxWithSubscript),
- lvl);
+ font_MATH_par(f, SuperscriptBottomMaxWithSubscript), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sup_sub_bottom_max, size_id,
- font_MATH_par(f,
- SuperscriptBottomMaxWithSubscript),
- lvl);
+ font_MATH_par(f, SuperscriptBottomMaxWithSubscript), lvl);
DEFINE_MATH_PARAMETERS(math_param_subsup_vgap, size_id,
- font_MATH_par(f, SubSuperscriptGapMin), lvl);
+ font_MATH_par(f, SubSuperscriptGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_subsup_vgap, size_id,
- font_MATH_par(f, SubSuperscriptGapMin), lvl);
+ font_MATH_par(f, SubSuperscriptGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_above_vgap, size_id,
- font_MATH_par(f, UpperLimitGapMin), lvl);
+ font_MATH_par(f, UpperLimitGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_above_vgap, size_id,
- font_MATH_par(f, UpperLimitGapMin), lvl);
+ font_MATH_par(f, UpperLimitGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_above_bgap, size_id,
- font_MATH_par(f, UpperLimitBaselineRiseMin),
- lvl);
+ font_MATH_par(f, UpperLimitBaselineRiseMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_above_bgap, size_id,
- font_MATH_par(f, UpperLimitBaselineRiseMin),
- lvl);
- DEFINE_MATH_PARAMETERS(math_param_limit_above_kern, size_id, 0, lvl);
- DEFINE_DMATH_PARAMETERS(math_param_limit_above_kern, size_id, 0, lvl);
+ font_MATH_par(f, UpperLimitBaselineRiseMin), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_limit_above_kern, size_id,
+ 0, lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_limit_above_kern, size_id,
+ 0, lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_below_vgap, size_id,
- font_MATH_par(f, LowerLimitGapMin), lvl);
+ font_MATH_par(f, LowerLimitGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_below_vgap, size_id,
- font_MATH_par(f, LowerLimitGapMin), lvl);
+ font_MATH_par(f, LowerLimitGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_below_bgap, size_id,
- font_MATH_par(f, LowerLimitBaselineDropMin),
- lvl);
+ font_MATH_par(f, LowerLimitBaselineDropMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_below_bgap, size_id,
- font_MATH_par(f, LowerLimitBaselineDropMin),
- lvl);
- DEFINE_MATH_PARAMETERS(math_param_limit_below_kern, size_id, 0, lvl);
- DEFINE_DMATH_PARAMETERS(math_param_limit_below_kern, size_id, 0, lvl);
+ font_MATH_par(f, LowerLimitBaselineDropMin), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_limit_below_kern, size_id,
+ 0, lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_limit_below_kern, size_id,
+ 0, lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_rule, size_id,
- font_MATH_par(f, FractionRuleThickness), lvl);
+ font_MATH_par(f, FractionRuleThickness), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_rule, size_id,
- font_MATH_par(f, FractionRuleThickness), lvl);
+ font_MATH_par(f, FractionRuleThickness), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_num_vgap, size_id,
- font_MATH_par(f, FractionNumeratorGapMin), lvl);
+ font_MATH_par(f, FractionNumeratorGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_num_vgap, size_id,
- font_MATH_par(f,
- FractionNumeratorDisplayStyleGapMin),
- lvl);
+ font_MATH_par(f, FractionNumeratorDisplayStyleGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_num_up, size_id,
- font_MATH_par(f, FractionNumeratorShiftUp), lvl);
+ font_MATH_par(f, FractionNumeratorShiftUp), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_num_up, size_id,
- font_MATH_par(f,
- FractionNumeratorDisplayStyleShiftUp),
- lvl);
+ font_MATH_par(f, FractionNumeratorDisplayStyleShiftUp), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_denom_vgap, size_id,
- font_MATH_par(f, FractionDenominatorGapMin),
- lvl);
+ font_MATH_par(f, FractionDenominatorGapMin), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_denom_vgap, size_id,
- font_MATH_par(f,
- FractionDenominatorDisplayStyleGapMin),
- lvl);
+ font_MATH_par(f,FractionDenominatorDisplayStyleGapMin), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_denom_down, size_id,
- font_MATH_par(f, FractionDenominatorShiftDown),
- lvl);
+ font_MATH_par(f, FractionDenominatorShiftDown), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_denom_down, size_id,
- font_MATH_par(f,
- FractionDenominatorDisplayStyleShiftDown),
- lvl);
+ font_MATH_par(f, FractionDenominatorDisplayStyleShiftDown), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_del_size, size_id,
- font_MATH_par(f, FractionDelimiterSize), lvl);
+ font_MATH_par(f, FractionDelimiterSize), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_del_size, size_id,
- font_MATH_par(f,
- FractionDelimiterDisplayStyleSize),
- lvl);
+ font_MATH_par(f, FractionDelimiterDisplayStyleSize), lvl);
+
+ DEFINE_MATH_PARAMETERS(math_param_skewed_fraction_hgap, size_id,
+ font_MATH_par(f, SkewedFractionHorizontalGap), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_skewed_fraction_hgap, size_id,
+ font_MATH_par(f, SkewedFractionHorizontalGap), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_skewed_fraction_vgap, size_id,
+ font_MATH_par(f, SkewedFractionVerticalGap), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_skewed_fraction_vgap, size_id,
+ font_MATH_par(f, SkewedFractionVerticalGap), lvl);
DEFINE_MATH_PARAMETERS(math_param_space_after_script, size_id,
- font_MATH_par(f, SpaceAfterScript), lvl);
+ font_MATH_par(f, SpaceAfterScript), lvl);
DEFINE_DMATH_PARAMETERS(math_param_space_after_script, size_id,
- font_MATH_par(f, SpaceAfterScript), lvl);
+ font_MATH_par(f, SpaceAfterScript), lvl);
DEFINE_MATH_PARAMETERS(math_param_connector_overlap_min, size_id,
- font_MATH_par(f, MinConnectorOverlap), lvl);
+ font_MATH_par(f, MinConnectorOverlap), lvl);
DEFINE_DMATH_PARAMETERS(math_param_connector_overlap_min, size_id,
- font_MATH_par(f, MinConnectorOverlap), lvl);
-
+ font_MATH_par(f, MinConnectorOverlap), lvl);
} else if (fam_id == 2 && is_old_mathfont(f, total_mathsy_params)) {
+
/* fix old-style |sy| parameters */
- DEFINE_MATH_PARAMETERS(math_param_quad, size_id, math_quad(size_id),
- lvl);
- DEFINE_DMATH_PARAMETERS(math_param_quad, size_id, math_quad(size_id),
- lvl);
- DEFINE_MATH_PARAMETERS(math_param_axis, size_id, axis_height(size_id),
- lvl);
- DEFINE_DMATH_PARAMETERS(math_param_axis, size_id, axis_height(size_id),
- lvl);
- DEFINE_MATH_PARAMETERS(math_param_stack_num_up, size_id, num3(size_id),
- lvl);
- DEFINE_DMATH_PARAMETERS(math_param_stack_num_up, size_id, num1(size_id),
- lvl);
+
+ DEFINE_MATH_PARAMETERS(math_param_quad, size_id,
+ math_quad(size_id), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_quad, size_id,
+ math_quad(size_id), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_axis, size_id,
+ axis_height(size_id), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_axis, size_id,
+ axis_height(size_id), lvl);
+ DEFINE_MATH_PARAMETERS(math_param_stack_num_up, size_id,
+ num3(size_id), lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_stack_num_up, size_id,
+ num1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_stack_denom_down, size_id,
- denom2(size_id), lvl);
+ denom2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_stack_denom_down, size_id,
- denom1(size_id), lvl);
+ denom1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_num_up, size_id,
- num2(size_id), lvl);
+ num2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_num_up, size_id,
- num1(size_id), lvl);
+ num1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_denom_down, size_id,
- denom2(size_id), lvl);
+ denom2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_denom_down, size_id,
- denom1(size_id), lvl);
+ denom1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_del_size, size_id,
- delim2(size_id), lvl);
+ delim2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_del_size, size_id,
- delim1(size_id), lvl);
+ delim1(size_id), lvl);
+
+ DEFINE_MATH_PARAMETERS(math_param_skewed_fraction_hgap, size_id,
+ 0, lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_skewed_fraction_hgap, size_id,
+ 0, lvl);
+ DEFINE_MATH_PARAMETERS(math_param_skewed_fraction_vgap, size_id,
+ 0, lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_skewed_fraction_vgap, size_id,
+ 0, lvl);
+
if (size_id == text_size) {
def_math_param(math_param_sup_shift_up, display_style,
- sup1(size_id), lvl);
+ sup1(size_id), lvl);
def_math_param(math_param_sup_shift_up, cramped_display_style,
- sup3(size_id), lvl);
- def_math_param(math_param_sup_shift_up, text_style, sup2(size_id),
- lvl);
+ sup3(size_id), lvl);
+ def_math_param(math_param_sup_shift_up, text_style,
+ sup2(size_id), lvl);
def_math_param(math_param_sup_shift_up, cramped_text_style,
- sup3(size_id), lvl);
+ sup3(size_id), lvl);
} else if (size_id == script_size) {
def_math_param(math_param_sub_shift_drop, display_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop, cramped_display_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop, text_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop, cramped_text_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, display_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, cramped_display_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, text_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, cramped_text_style,
- sup_drop(size_id), lvl);
- def_math_param(math_param_sup_shift_up, script_style, sup2(size_id),
- lvl);
+ sup_drop(size_id), lvl);
+ def_math_param(math_param_sup_shift_up, script_style,
+ sup2(size_id), lvl);
def_math_param(math_param_sup_shift_up, cramped_script_style,
- sup3(size_id), lvl);
+ sup3(size_id), lvl);
} else if (size_id == script_script_size) {
def_math_param(math_param_sub_shift_drop, script_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop, cramped_script_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop, script_script_style,
- sub_drop(size_id), lvl);
+ sub_drop(size_id), lvl);
def_math_param(math_param_sub_shift_drop,
- cramped_script_script_style, sub_drop(size_id), lvl);
+ cramped_script_script_style, sub_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, script_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, cramped_script_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop, script_script_style,
- sup_drop(size_id), lvl);
+ sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_drop,
- cramped_script_script_style, sup_drop(size_id), lvl);
+ cramped_script_script_style, sup_drop(size_id), lvl);
def_math_param(math_param_sup_shift_up, script_script_style,
- sup2(size_id), lvl);
+ sup2(size_id), lvl);
def_math_param(math_param_sup_shift_up, cramped_script_script_style,
- sup3(size_id), lvl);
+ sup3(size_id), lvl);
}
+
DEFINE_MATH_PARAMETERS(math_param_sub_shift_down, size_id,
- sub1(size_id), lvl);
+ sub1(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_shift_down, size_id,
- sub1(size_id), lvl);
+ sub1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- sub2(size_id), lvl);
+ sub2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_sup_shift_down, size_id,
- sub2(size_id), lvl);
+ sub2(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_sub_top_max, size_id,
- (abs(math_x_height(size_id) * 4) / 5), lvl);
+ (abs(math_x_height(size_id) * 4) / 5), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sub_top_max, size_id,
- (abs(math_x_height(size_id) * 4) / 5), lvl);
+ (abs(math_x_height(size_id) * 4) / 5), lvl);
DEFINE_MATH_PARAMETERS(math_param_sup_bottom_min, size_id,
- (abs(math_x_height(size_id)) / 4), lvl);
+ (abs(math_x_height(size_id)) / 4), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sup_bottom_min, size_id,
- (abs(math_x_height(size_id)) / 4), lvl);
+ (abs(math_x_height(size_id)) / 4), lvl);
DEFINE_MATH_PARAMETERS(math_param_sup_sub_bottom_max, size_id,
- (abs(math_x_height(size_id) * 4) / 5), lvl);
+ (abs(math_x_height(size_id) * 4) / 5), lvl);
DEFINE_DMATH_PARAMETERS(math_param_sup_sub_bottom_max, size_id,
- (abs(math_x_height(size_id) * 4) / 5), lvl);
+ (abs(math_x_height(size_id) * 4) / 5), lvl);
- /* The display-size |radical_vgap| is done twice because it needs
- values from both the sy and the ex font. */
- DEFINE_DMATH_PARAMETERS(math_param_radical_vgap, size_id,
- (default_rule_thickness(size_id) +
- (abs(math_x_height(size_id)) / 4)), lvl);
+ /*
+ The display-size |radical_vgap| is done twice because it needs
+ values from both the sy and the ex font.
+ */
+ DEFINE_DMATH_PARAMETERS(math_param_radical_vgap, size_id,
+ (default_rule_thickness(size_id) + (abs(math_x_height(size_id)) / 4)), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_raise, size_id,
- 60, lvl);
+ 60, lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_raise, size_id,
- 60, lvl);
+ 60, lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_before, size_id,
- xn_over_d(get_math_quad_size(size_id), 5, 18),
- lvl);
+ xn_over_d(get_math_quad_size(size_id), 5, 18), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_before, size_id,
- xn_over_d(get_math_quad_size(size_id), 5, 18),
- lvl);
+ xn_over_d(get_math_quad_size(size_id), 5, 18), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_degree_after, size_id,
- (-xn_over_d
- (get_math_quad_size(size_id), 10, 18)), lvl);
+ (-xn_over_d (get_math_quad_size(size_id), 10, 18)), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_degree_after, size_id,
- (-xn_over_d
- (get_math_quad_size(size_id), 10, 18)), lvl);
+ (-xn_over_d (get_math_quad_size(size_id), 10, 18)), lvl);
} else if (fam_id == 3 && is_old_mathfont(f, total_mathex_params)) {
+
/* fix old-style |ex| parameters */
+
DEFINE_MATH_PARAMETERS(math_param_overbar_kern, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_overbar_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_overbar_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_kern, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_overbar_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_kern, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_underbar_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_kern, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_underbar_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_kern, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_radical_kern, size_id,
- default_rule_thickness(size_id), lvl);
-
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_radical_vgap, size_id,
- (default_rule_thickness(size_id) +
- (abs(default_rule_thickness(size_id)) / 4)),
- lvl);
-
+ (default_rule_thickness(size_id) + (abs(default_rule_thickness(size_id)) / 4)), lvl);
DEFINE_MATH_PARAMETERS(math_param_stack_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_stack_vgap, size_id,
- 7 * default_rule_thickness(size_id), lvl);
+ 7 * default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_rule, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_num_vgap, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_num_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_fraction_denom_vgap, size_id,
- default_rule_thickness(size_id), lvl);
+ default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_fraction_denom_vgap, size_id,
- 3 * default_rule_thickness(size_id), lvl);
+ 3 * default_rule_thickness(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_above_vgap, size_id,
- big_op_spacing1(size_id), lvl);
+ big_op_spacing1(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_above_vgap, size_id,
- big_op_spacing1(size_id), lvl);
+ big_op_spacing1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_above_bgap, size_id,
- big_op_spacing3(size_id), lvl);
+ big_op_spacing3(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_above_bgap, size_id,
- big_op_spacing3(size_id), lvl);
+ big_op_spacing3(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_above_kern, size_id,
- big_op_spacing5(size_id), lvl);
+ big_op_spacing5(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_above_kern, size_id,
- big_op_spacing5(size_id), lvl);
+ big_op_spacing5(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_below_vgap, size_id,
- big_op_spacing2(size_id), lvl);
+ big_op_spacing2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_below_vgap, size_id,
- big_op_spacing2(size_id), lvl);
+ big_op_spacing2(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_below_bgap, size_id,
- big_op_spacing4(size_id), lvl);
+ big_op_spacing4(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_below_bgap, size_id,
- big_op_spacing4(size_id), lvl);
+ big_op_spacing4(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_limit_below_kern, size_id,
- big_op_spacing5(size_id), lvl);
+ big_op_spacing5(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_limit_below_kern, size_id,
- big_op_spacing5(size_id), lvl);
+ big_op_spacing5(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_subsup_vgap, size_id,
- 4 * default_rule_thickness(size_id), lvl);
+ 4 * default_rule_thickness(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_subsup_vgap, size_id,
- 4 * default_rule_thickness(size_id), lvl);
- /* All of the |space_after_script|s are done in |finalize_math_parameters| because the
- \.{\\scriptspace} may have been altered by the user
- */
- DEFINE_MATH_PARAMETERS(math_param_connector_overlap_min, size_id, 0,
- lvl);
- DEFINE_DMATH_PARAMETERS(math_param_connector_overlap_min, size_id, 0,
- lvl);
+ 4 * default_rule_thickness(size_id), lvl);
+
+ /*
+ All of the |space_after_script|s are done in |finalize_math_parameters|
+ because the \.{\\scriptspace} may have been altered by the user
+ */
+
+ DEFINE_MATH_PARAMETERS(math_param_connector_overlap_min, size_id,
+ 0, lvl);
+ DEFINE_DMATH_PARAMETERS(math_param_connector_overlap_min, size_id,
+ 0, lvl);
DEFINE_MATH_PARAMETERS(math_param_under_delimiter_vgap, size_id,
- big_op_spacing2(size_id), lvl);
+ big_op_spacing2(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_under_delimiter_vgap, size_id,
- big_op_spacing2(size_id), lvl);
+ big_op_spacing2(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_under_delimiter_bgap, size_id,
- big_op_spacing4(size_id), lvl);
+ big_op_spacing4(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_under_delimiter_bgap, size_id,
- big_op_spacing4(size_id), lvl);
+ big_op_spacing4(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_over_delimiter_vgap, size_id,
- big_op_spacing1(size_id), lvl);
+ big_op_spacing1(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_over_delimiter_vgap, size_id,
- big_op_spacing1(size_id), lvl);
+ big_op_spacing1(size_id), lvl);
DEFINE_MATH_PARAMETERS(math_param_over_delimiter_bgap, size_id,
- big_op_spacing3(size_id), lvl);
+ big_op_spacing3(size_id), lvl);
DEFINE_DMATH_PARAMETERS(math_param_over_delimiter_bgap, size_id,
- big_op_spacing3(size_id), lvl);
+ big_op_spacing3(size_id), lvl);
+
+ /*
+ The display-size |radical_vgap| is done twice because it needs
+ values from both the sy and the ex font.
+ */
- /* The display-size |radical_vgap| is done twice because it needs
- values from both the sy and the ex font. */
DEFINE_DMATH_PARAMETERS(math_param_radical_vgap, size_id,
- (default_rule_thickness(size_id) +
- (abs(math_x_height(size_id)) / 4)), lvl);
+ (default_rule_thickness(size_id) + (abs(math_x_height(size_id)) / 4)), lvl);
+
}
}
@@ -836,30 +877,27 @@ static void finalize_math_parameters(void)
{
int saved_trace = int_par(tracing_assigns_code);
int_par(tracing_assigns_code) = 0;
- if (get_math_param(math_param_space_after_script, display_style) ==
- undefined_math_parameter) {
+ if (get_math_param(math_param_space_after_script, display_style) == undefined_math_parameter) {
def_math_param(math_param_space_after_script, display_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, text_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, script_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, script_script_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, cramped_display_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, cramped_text_style,
- script_space, level_one);
+ script_space, level_one);
def_math_param(math_param_space_after_script, cramped_script_style,
- script_space, level_one);
- def_math_param(math_param_space_after_script,
- cramped_script_script_style, script_space, level_one);
+ script_space, level_one);
+ def_math_param(math_param_space_after_script, cramped_script_script_style,
+ script_space, level_one);
}
int_par(tracing_assigns_code) = saved_trace;
-
}
-
@ In order to convert mlists to hlists, i.e., noads to nodes, we need several
subroutines that are conveniently dealt with now.
@@ -884,14 +922,14 @@ static const char *math_size_string(int s)
information:
@c
-#define setup_cur_size(a) do { \
- if (a==script_style || \
- a==cramped_script_style) \
- cur_size=script_size; \
- else if (a==script_script_style || \
- a==cramped_script_script_style) \
- cur_size=script_script_size; \
- else cur_size=text_size; \
+#define setup_cur_size(a) do { \
+ if (a==script_style || \
+ a==cramped_script_style) \
+ cur_size=script_size; \
+ else if (a==script_script_style || \
+ a==cramped_script_script_style) \
+ cur_size=script_script_size; \
+ else cur_size=text_size; \
} while (0)
@@ -913,9 +951,6 @@ static pointer math_clone(pointer q)
return x;
}
-
-
-
@ Here is a function that returns a pointer to a rule node having a given
thickness |t|. The rule will extend horizontally to the boundary of the vlist
that eventually contains it.
@@ -924,7 +959,7 @@ static pointer math_clone(pointer q)
static pointer do_fraction_rule(scaled t, pointer att)
{
pointer p; /* the new node */
- p = new_rule();
+ p = new_rule(normal_rule);
rule_dir(p) = math_direction;
height(p) = t;
depth(p) = 0;
@@ -932,8 +967,7 @@ static pointer do_fraction_rule(scaled t, pointer att)
return p;
}
-
-@ The |overbar| function returns a pointer to a vlist box that consists of
+@ The |overbar| function returns a pointer to a vlist box that consists of
a given box |b|, above which has been placed a kern of height |k| under a
fraction rule of thickness |t| under additional space of height |ht|.
@@ -942,8 +976,8 @@ static pointer overbar(pointer b, scaled k, scaled t, scaled ht, pointer att)
{
pointer p, q; /* nodes being constructed */
p = new_kern(k);
- couple_nodes(p,b);
reset_attributes(p, att);
+ couple_nodes(p,b);
q = do_fraction_rule(t, att);
couple_nodes(q,p);
p = new_kern(ht);
@@ -955,17 +989,20 @@ static pointer overbar(pointer b, scaled k, scaled t, scaled ht, pointer att)
}
@ Here is a subroutine that creates a new box, whose list contains a
- single character, and whose width includes the italic correction for
- that character. The height or depth of the box will be negative, if
- the height or depth of the character is negative; thus, this routine
- may deliver a slightly different result than |hpack| would produce.
+single character, and whose width includes the italic correction for
+that character. The height or depth of the box will be negative, if
+the height or depth of the character is negative; thus, this routine
+may deliver a slightly different result than |hpack| would produce.
@c
static pointer char_box(internal_font_number f, int c, pointer bb)
{
- pointer b, p; /* the new box and its character node */
+ pointer b, p; /* the new box and its character node */
b = new_null_box();
- width(b) = char_width(f, c) + char_italic(f, c);
+ if (is_new_mathfont(f))
+ width(b) = char_width(f, c);
+ else
+ width(b) = char_width(f, c) + char_italic(f, c);
height(b) = char_height(f, c);
depth(b) = char_depth(f, c);
reset_attributes(b, bb);
@@ -976,7 +1013,7 @@ static pointer char_box(internal_font_number f, int c, pointer bb)
}
@ Another handy subroutine computes the height plus depth of
- a given character:
+ a given character:
@c
static scaled height_plus_depth(internal_font_number f, int c)
@@ -984,19 +1021,17 @@ static scaled height_plus_depth(internal_font_number f, int c)
return (char_height(f, c) + char_depth(f, c));
}
-
-@ When we build an extensible character, it's handy to have the
+@ When we build an extensible character, it's handy to have the
following subroutine, which puts a given character on top
of the characters already in box |b|:
@c
static scaled stack_into_box(pointer b, internal_font_number f, int c)
{
- pointer p, q; /* new node placed into |b| */
- p = char_box(f, c, node_attr(b));
+ pointer p, q; /* new node placed into |b| */
+ p = char_box(f, c, node_attr(b)); /* italic gets added to width */
if (type(b) == vlist_node) {
-// vlink(p) = list_ptr(b);
-try_couple_nodes(p,list_ptr(b));
+ try_couple_nodes(p,list_ptr(b));
list_ptr(b) = p;
height(b) = height(p);
if (width(b) < width(p))
@@ -1019,7 +1054,6 @@ try_couple_nodes(p,list_ptr(b));
}
}
-
static void stack_glue_into_box(pointer b, scaled min, scaled max) {
pointer p, q; /* new node placed into |b| */
q = new_spec(zero_glue);
@@ -1059,11 +1093,11 @@ static void stack_glue_into_box(pointer b, scaled min, scaled max) {
@^recursion@>
@c
-int cur_size; /* size code corresponding to |cur_style| */
+int cur_size; /* size code corresponding to |cur_style| */
@ @c
-static pointer get_delim_box(extinfo * ext, internal_font_number f, scaled v,
- pointer att, int boxtype, int cur_style)
+static pointer get_delim_box(pointer q, extinfo * ext, internal_font_number f, scaled v,
+ pointer att, int cur_style, int boxtype)
{
pointer b; /* new box */
scaled b_max; /* natural (maximum) size of the stack */
@@ -1131,28 +1165,31 @@ static pointer get_delim_box(extinfo * ext, internal_font_number f, scaled v,
num_normal = 1;
num_extenders--;
}
- /* |ext| holds a linked list of numerous items that may or may not be
- repeatable. For the total height, we have to figure out how many items
- are needed to create a stack of at least |v|.
- The next |while| loop does that. It has two goals: it finds out
- the natural height |b_max| of the all the parts needed to reach
- at least |v|, and it sets |with_extenders| to the number of times
- each of the repeatable items in |ext| has to be repeated to reach
- that height.
- */
+ /*
+ |ext| holds a linked list of numerous items that may or may not be
+ repeatable. For the total height, we have to figure out how many items
+ are needed to create a stack of at least |v|.
+
+ The next |while| loop does that. It has two goals: it finds out
+ the natural height |b_max| of the all the parts needed to reach
+ at least |v|, and it sets |with_extenders| to the number of times
+ each of the repeatable items in |ext| has to be repeated to reach
+ that height.
+
+ */
cur = ext;
b_max = 0;
while (b_max < v && num_extenders > 0) {
b_max = 0;
- prev_overlap = 0;
+ prev_overlap = 0;
with_extenders++;
for (cur = ext; cur != NULL; cur = cur->next) {
- if (cur->extender == 0) {
- c = cur->start_overlap;
- if (min_overlap < c)
- c = min_overlap;
- if (prev_overlap < c)
- c = prev_overlap;
+ if (cur->extender == 0) {
+ c = cur->start_overlap;
+ if (min_overlap < c)
+ c = min_overlap;
+ if (prev_overlap < c)
+ c = prev_overlap;
a = cur->advance;
if (a == 0) {
/* for tfm fonts */
@@ -1162,16 +1199,16 @@ static pointer get_delim_box(extinfo * ext, internal_font_number f, scaled v,
a = char_width(f, cur->glyph);
assert(a >= 0);
}
- b_max += a - c;
- prev_overlap = cur->end_overlap;
- } else {
- i = with_extenders;
- while (i > 0) {
- c = cur->start_overlap;
- if (min_overlap < c)
- c = min_overlap;
- if (prev_overlap < c)
- c = prev_overlap;
+ b_max += a - c;
+ prev_overlap = cur->end_overlap;
+ } else {
+ i = with_extenders;
+ while (i > 0) {
+ c = cur->start_overlap;
+ if (min_overlap < c)
+ c = min_overlap;
+ if (prev_overlap < c)
+ c = prev_overlap;
a = cur->advance;
if (a == 0) {
/* for tfm fonts */
@@ -1181,57 +1218,60 @@ static pointer get_delim_box(extinfo * ext, internal_font_number f, scaled v,
a = char_width(f, cur->glyph);
assert(a >= 0);
}
- b_max += a - c;
- prev_overlap = cur->end_overlap;
- i--;
- }
- }
- }
+ b_max += a - c;
+ prev_overlap = cur->end_overlap;
+ i--;
+ }
+ }
+ }
}
- /* assemble box using |with_extenders| copies of each extender, with
- appropriate glue wherever an overlap occurs */
+ /*
+ assemble box using |with_extenders| copies of each extender, with
+ appropriate glue wherever an overlap occurs
+ */
prev_overlap = 0;
b_max = 0;
s_max = 0;
for (cur = ext; cur != NULL; cur = cur->next) {
if (cur->extender == 0) {
- c = cur->start_overlap;
- if (prev_overlap < c)
- c = prev_overlap;
- d = c;
- if (min_overlap < c)
- c = min_overlap;
- if (d > 0) {
- stack_glue_into_box(b, -d, -c);
- s_max += (-c) - (-d);
- b_max -= d;
- }
+ c = cur->start_overlap;
+ if (prev_overlap < c)
+ c = prev_overlap;
+ d = c;
+ if (min_overlap < c)
+ c = min_overlap;
+ if (d > 0) {
+ stack_glue_into_box(b, -d, -c);
+ s_max += (-c) - (-d);
+ b_max -= d;
+ }
b_max += stack_into_box(b, f, cur->glyph);
- prev_overlap = cur->end_overlap;
- i--;
- } else {
- i = with_extenders;
- while (i > 0) {
- c = cur->start_overlap;
- if (prev_overlap < c)
- c = prev_overlap;
- d = c;
- if (min_overlap < c)
- c = min_overlap;
- if (d > 0) {
- stack_glue_into_box(b, -d, -c);
- s_max += (-c) - (-d);
- b_max -= d;
- }
+ prev_overlap = cur->end_overlap;
+ i--;
+ } else {
+ i = with_extenders;
+ while (i > 0) {
+ c = cur->start_overlap;
+ if (prev_overlap < c)
+ c = prev_overlap;
+ d = c;
+ if (min_overlap < c)
+ c = min_overlap;
+ if (d > 0) {
+ stack_glue_into_box(b, -d, -c);
+ s_max += (-c) - (-d);
+ b_max -= d;
+ }
b_max += stack_into_box(b, f, cur->glyph);
- prev_overlap = cur->end_overlap;
- i--;
- }
- }
+ prev_overlap = cur->end_overlap;
+ i--;
+ }
+ }
}
/* set glue so as to stretch the connections if needed */
+
d = 0;
if (v > b_max && s_max > 0) {
d = v-b_max;
@@ -1244,29 +1284,16 @@ static pointer get_delim_box(extinfo * ext, internal_font_number f, scaled v,
b_max += d;
}
- if (boxtype == vlist_node)
+ if (boxtype == vlist_node) {
height(b) = b_max;
- else
+ } else {
width(b) = b_max;
+ }
return b;
}
-static pointer get_delim_vbox(extinfo * ext, internal_font_number f, scaled v,
- pointer att, int cur_style)
-{
- return get_delim_box(ext, f, v, att, vlist_node, cur_style);
-}
-
-static pointer get_delim_hbox(extinfo * ext, internal_font_number f, scaled v,
- pointer att, int cur_style)
-{
- return get_delim_box(ext, f, v, att, hlist_node, cur_style);
-}
-
-
-
-@ The |var_delimiter| function, which finds or constructs a sufficiently
+@ The |var_delimiter| function, which finds or constructs a sufficiently
large delimiter, is the most interesting of the auxiliary functions that
currently concern us. Given a pointer |d| to a delimiter field in some noad,
together with a size code |s| and a vertical distance |v|, this function
@@ -1288,7 +1315,7 @@ static void endless_loop_error(internal_font_number g, int y)
const char *hlp[] = {
"You managed to create a seemingly endless charlist chain in the current",
"font. I have counted until 10000 already and still have not escaped, so"
- "I will jump out of the loop all by myself now. Fix your font!",
+ "I will jump out of the loop all by myself now. Fix your font!",
NULL
};
snprintf(s, 256, "Math error: endless loop in charlist (U+%04x in %s)",
@@ -1296,10 +1323,8 @@ static void endless_loop_error(internal_font_number g, int y)
tex_error(s, hlp);
}
-static pointer do_var_delimiter(pointer d, int s, scaled v, scaled * ic,
- boolean flat, int cur_style)
+static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, int cur_style, boolean shift, boolean *stack, scaled *delta)
{
- /* label found,continue; */
pointer b; /* the box that will be constructed */
internal_font_number f, g; /* best-so-far and tentative font codes */
int c, i, x, y; /* best-so-far and tentative character codes */
@@ -1322,9 +1347,11 @@ static pointer do_var_delimiter(pointer d, int s, scaled v, scaled * ic,
x = small_char(d);
i = 0;
while (true) {
- /* The search process is complicated slightly by the facts that some of the
- characters might not be present in some of the fonts, and they might not
- be probed in increasing order of height. */
+ /*
+ The search process is complicated slightly by the facts that some of the
+ characters might not be present in some of the fonts, and they might not
+ be probed in increasing order of height.
+ */
if ((z != 0) || (x != 0)) {
g = fam_fnt(z, s);
if (g != null_font) {
@@ -1362,7 +1389,7 @@ static pointer do_var_delimiter(pointer d, int s, scaled v, scaled * ic,
}
}
if (large_attempt)
- goto FOUND; /* there were none large enough */
+ goto FOUND; /* there were none large enough */
large_attempt = true;
z = large_fam(d);
x = large_char(d);
@@ -1374,60 +1401,65 @@ static pointer do_var_delimiter(pointer d, int s, scaled v, scaled * ic,
flush_node(d);
}
if (f != null_font) {
- /* When the following code is executed, |do_parts| will be true
- if a built-up symbol is supposed to be returned.
- */
+ /*
+ When the following code is executed, |do_parts| will be true
+ if a built-up symbol is supposed to be returned.
+ */
ext = NULL;
- if ((do_parts) &&
- ((!flat
- && (ext = get_charinfo_vert_variants(char_info(f, c))) != NULL)
- || (flat
- && (ext =
- get_charinfo_hor_variants(char_info(f, c))) != NULL))) {
- b = (flat ? get_delim_hbox(ext, f, v, att, cur_style) :
- get_delim_vbox(ext, f, v, att, cur_style));
+ if ((do_parts) && ((!flat && (ext = get_charinfo_vert_variants(char_info(f,c))) != NULL)
+ || ( flat && (ext = get_charinfo_hor_variants (char_info(f,c))) != NULL))) {
+ if (flat) {
+ b = get_delim_box(d, ext, f, v, att, cur_style, hlist_node);
+ } else {
+ b = get_delim_box(d, ext, f, v, att, cur_style, vlist_node);
+ }
+ if (delta != NULL) {
+ if (is_new_mathfont(f)) {
+ *delta = char_vert_italic(f,x);
+ } else {
+ *delta = char_italic(f,x);
+ }
+ }
+ if (stack != NULL)
+ *stack = true ;
} else {
b = char_box(f, c, att);
+ if (!is_new_mathfont(f)) {
+ /* italic gets added to width */
+ width(b) += char_italic(f, c);
+ }
+ if (delta != NULL) {
+ *delta = char_italic(f,x);
+ }
+ if (stack != NULL)
+ *stack = false ;
}
- /* This next test is because for OT MATH fonts, the italic correction of an
- extensible character is only used for the placement of a subscript
- (in negated form), and it is not supposed to be added to the
- width of the character box at all.
-
- This has an effect later on in |make_op| as well, where it has to do
- an extra correction for |make_script|'s addition of yet another italic
- correction.
- */
- if (!is_new_mathfont(f)) {
- width(b) += char_italic(f, c);
- }
- if (ic != NULL)
- *ic = char_italic(f, c);
} else {
b = new_null_box();
reset_attributes(b, att);
- width(b) = (flat ? 0 : null_delimiter_space); /* use this width if no delimiter was found */
- if (ic != NULL)
- *ic = 0;
+ if (flat) {
+ width(b) = 0;
+ } else {
+ /* use this width if no delimiter was found */
+ width(b) = null_delimiter_space;
+ }
+ if (delta != NULL) {
+ *delta = 0;
+ }
+ if (stack != NULL)
+ *stack = false ;
+ }
+ if (!flat) {
+ /* vertical variant */
+ shift_amount(b) = half(height(b) - depth(b));
+ if (shift) {
+ shift_amount(b) -= math_axis(s);
+ }
}
- if (!flat)
- shift_amount(b) = half(height(b) - depth(b)) - math_axis(s);
delete_attribute_ref(att);
return b;
}
-
-static pointer var_delimiter(pointer d, int s, scaled v, scaled * ic,
- int cur_style)
-{
- return do_var_delimiter(d, s, v, ic, false, cur_style);
-}
-
-static pointer flat_delimiter(pointer d, int s, scaled v, int cur_style)
-{
- return do_var_delimiter(d, s, v, NULL, true, cur_style);
-}
-
@ The next subroutine is much simpler; it is used for numerators and
denominators of fractions as well as for displayed operators and
their limits above and below. It takes a given box~|b| and
@@ -1437,7 +1469,6 @@ of the list inside |b|, then packaging the new box; thus, the
actual box might not really be centered, if it already contains
infinite glue.
-
The given box might contain a single character whose italic correction
has been added to the width of the box; in this case a compensating
kern is inserted.
@@ -1495,9 +1526,9 @@ one that is expressed in `\.{mu}', given the value of the math unit.
static pointer math_glue(pointer g, scaled m)
{
- pointer p; /* the new glue specification */
- int n; /* integer part of |m| */
- scaled f; /* fraction part of |m| */
+ pointer p; /* the new glue specification */
+ int n; /* integer part of |m| */
+ scaled f; /* fraction part of |m| */
n = x_over_n(m, unity);
f = tex_remainder;
if (f < 0) {
@@ -1505,7 +1536,7 @@ static pointer math_glue(pointer g, scaled m)
f = f + unity;
}
p = new_node(glue_spec_node, 0);
- width(p) = mu_mult(width(g)); /* convert \.{mu} to \.{pt} */
+ width(p) = mu_mult(width(g)); /* convert \.{mu} to \.{pt} */
stretch_order(p) = stretch_order(g);
if (stretch_order(p) == normal)
stretch(p) = mu_mult(stretch(g));
@@ -1525,8 +1556,8 @@ the value of the math unit.
@c
static void math_kern(pointer p, scaled m)
{
- int n; /* integer part of |m| */
- scaled f; /* fraction part of |m| */
+ int n; /* integer part of |m| */
+ scaled f; /* fraction part of |m| */
if (subtype(p) == mu_glue) {
n = x_over_n(m, unity);
f = tex_remainder;
@@ -1558,17 +1589,19 @@ void run_mlist_to_hlist(halfword p, int mstyle, boolean penalties)
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 */
- if (lua_pcall(L, 3, 1, 0) != 0) { /* 3 args, 1 result */
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
+ nodelist_to_lua(L, p); /* arg 1 */
+ lua_pushstring(L, math_style_names[mstyle]); /* arg 2 */
+ lua_pushboolean(L, penalties); /* arg 3 */
+ 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));
+ errmsg[255]='\0';
lua_settop(L, sfix);
- error();
+ normal_error("mlist to hlist",errmsg); /* to be done */
return;
}
a = nodelist_from_lua(L);
- /* alink(vlink(a)) = null; */ /* hh-ls: not need to null here */
+ /* alink(vlink(a)) = null; */
lua_settop(L, sfix);
vlink(temp_head) = a;
} else if (callback_id == 0) {
@@ -1584,17 +1617,16 @@ math style; |mlist_to_hlist| can call |clean_box|, which can call
|mlist_to_hlist|.
@^recursion@>
-
The box returned by |clean_box| is ``clean'' in the
sense that its |shift_amount| is zero.
@c
static pointer clean_box(pointer p, int s, int cur_style)
{
- pointer q; /* beginning of a list to be boxed */
- pointer x; /* box to be returned */
- pointer r; /* temporary pointer */
- pointer mlist = null; /* beginning of mlist to be translated */
+ pointer q; /* beginning of a list to be boxed */
+ pointer x; /* box to be returned */
+ pointer r; /* temporary pointer */
+ pointer mlist = null; /* beginning of mlist to be translated */
switch (type(p)) {
case math_char_node:
mlist = new_noad();
@@ -1613,14 +1645,13 @@ static pointer clean_box(pointer p, int s, int cur_style)
goto FOUND;
}
mlist_to_hlist_args(mlist, s, false);
- q = vlink(temp_head); /* recursive call */
+ q = vlink(temp_head); /* recursive call */
setup_cur_size(cur_style);
FOUND:
if (is_char_node(q) || (q == null))
x = hpack(q, 0, additional, -1);
- else if ((vlink(q) == null) && (type(q) <= vlist_node)
- && (shift_amount(q) == 0))
- x = q; /* it's already clean */
+ else if ((vlink(q) == null) && (type(q) <= vlist_node) && (shift_amount(q) == 0))
+ x = q; /* it's already clean */
else
x = hpack(q, 0, additional, -1);
if (x != q && q != null)
@@ -1654,11 +1685,13 @@ after |fetch| has acted, and the field will also have been reset to |null|.
The outputs of |fetch| are placed in global variables.
@c
-internal_font_number cur_f; /* the |font| field of a |math_char| */
-int cur_c; /* the |character| field of a |math_char| */
+internal_font_number cur_f; /* the |font| field of a |math_char| */
+int cur_c; /* the |character| field of a |math_char| */
+
+@ Here we unpack the |math_char| field |a|.
-static void fetch(pointer a)
-{ /* unpack the |math_char| field |a| */
+@c static void fetch(pointer a)
+{
cur_c = math_character(a);
cur_f = fam_fnt(math_fam(a), cur_size);
if (cur_f == null_font) {
@@ -1675,14 +1708,11 @@ static void fetch(pointer a)
math_size_string(cur_size), (int) math_fam(a), (int) cur_c);
tex_error(msg, hlp);
free(msg);
- } else {
- if (!(char_exists(cur_f, cur_c))) {
- char_warning(cur_f, cur_c);
- }
+ } else if (!(char_exists(cur_f, cur_c))) {
+ char_warning(cur_f, cur_c);
}
}
-
@ We need to do a lot of different things, so |mlist_to_hlist| makes two
passes over the given mlist.
@@ -1727,20 +1757,17 @@ static void assign_new_hlist(pointer q, pointer r)
@ @c
#define choose_mlist(A) do { p=A(q); A(q)=null; } while (0)
-
@ Most of the actual construction work of |mlist_to_hlist| is done
-by procedures with names
-like |make_fraction|, |make_radical|, etc. To illustrate
-the general setup of such procedures, let's begin with a couple of
-simple ones.
+by procedures with names like |make_fraction|, |make_radical|, etc. To
+illustrate the general setup of such procedures, let's begin with a
+couple of simple ones.
@c
static void make_over(pointer q, int cur_style)
{
pointer p;
p = overbar(clean_box(nucleus(q), cramped_style(cur_style), cur_style),
- overbar_vgap(cur_style),
- overbar_rule(cur_style),
+ overbar_vgap(cur_style), overbar_rule(cur_style),
overbar_kern(cur_style), node_attr(nucleus(q)));
math_list(nucleus(q)) = p;
type(nucleus(q)) = sub_box_node;
@@ -1771,7 +1798,7 @@ static void make_vcenter(pointer q)
scaled delta; /* its height plus depth */
v = math_list(nucleus(q));
if (type(v) != vlist_node)
- confusion("vcenter"); /* this can't happen vcenter */
+ confusion("vcenter");
delta = height(v) + depth(v);
height(v) = math_axis(cur_size) + half(delta);
depth(v) = delta - height(v);
@@ -1787,36 +1814,69 @@ of the nucleus plus a certain minimum clearance~|psi|. The symbol will be
placed so that the actual clearance is |psi| plus half the excess.
@c
+static void make_hextension(pointer q, int cur_style)
+{
+ pointer e, p;
+ halfword w;
+ boolean stack = false;
+ e = do_delimiter(q, left_delimiter(q), cur_size, radicalwidth(q), true, cur_style, true, &stack, NULL);
+ w = width(e);
+ if (!stack&& (radicalwidth(q) != 0) && (radicalwidth(q) != width(e))) {
+ if (radicalmiddle(q)) {
+ p = new_kern(half(radicalwidth(q)-w));
+ reset_attributes(p, node_attr(q));
+ couple_nodes(p,e);
+ e = p;
+ w = radicalwidth(q);
+ } else if (radicalexact(q)) {
+ w = radicalwidth(q);
+ }
+ }
+ e = hpack(e, 0, additional, -1);
+ width(e) = w ;
+ reset_attributes(e, node_attr(q));
+ math_list(nucleus(q)) = e;
+ left_delimiter(q) = null;
+}
+
static void make_radical(pointer q, int cur_style)
{
- pointer x, y, p; /* temporary registers for box construction */
- scaled delta, clr, theta, h; /* dimensions involved in the calculation */
+ pointer x, y, p, l1, l2; /* temporary registers for box construction */
+ scaled delta, clr, theta, h; /* dimensions involved in the calculation */
x = clean_box(nucleus(q), cramped_style(cur_style), cur_style);
clr = radical_vgap(cur_style);
theta = radical_rule(cur_style);
if (theta == undefined_math_parameter) {
+ /* a real radical */
theta = fraction_rule(cur_style);
- y = var_delimiter(left_delimiter(q), cur_size,
- height(x) + depth(x) + clr + theta, NULL, cur_style);
- /* If |y| is a composite then set |theta| to the height of its top
- character, else set it to the height of |y|. */
- if (list_ptr(y) != null
- && type(list_ptr(y)) == hlist_node
- && list_ptr(list_ptr(y)) != null
- && type(list_ptr(list_ptr(y))) == glyph_node) { /* and it should be */
- theta = char_height(font(list_ptr(list_ptr(y))),
- character(list_ptr(list_ptr(y))));
+ y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL);
+ /*
+ If |y| is a composite then set |theta| to the height of its top
+ character, else set it to the height of |y|.
+ */
+ l1 = list_ptr(y);
+ if ((l1 != null) && (type(l1) == hlist_node)) {
+ /* possible composite */
+ l2 = list_ptr(l1);
+ if ((l2 != null) && (type(l2) == glyph_node)) {
+ /* top character */
+ theta = char_height(font(l2), character(l2));
+ } else {
+ theta = height(y);
+ }
} else {
theta = height(y);
}
} else {
- y = var_delimiter(left_delimiter(q), cur_size,
- height(x) + depth(x) + clr + theta, NULL, cur_style);
+ /* not really a radical but we use its node, historical sharing (like in mathml) */
+ y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL);
}
left_delimiter(q) = null;
delta = (depth(y) + height(y) - theta) - (height(x) + depth(x) + clr);
- if (delta > 0)
- clr = clr + half(delta); /* increase the actual clearance */
+ if (delta > 0) {
+ /* increase the actual clearance */
+ clr = clr + half(delta);
+ }
shift_amount(y) = (height(y) - theta) - (height(x) + clr);
h = depth(y) + height(y);
p = overbar(x, clr, theta, radical_kern(cur_style), node_attr(y));
@@ -1845,7 +1905,8 @@ static void make_radical(pointer q, int cur_style)
couple_nodes(x,r);
y = x;
}
- math_list(degree(q)) = null; /* for \.{\\Uroot ..{<list>}{}} */
+ /* for \.{\\Uroot ..{<list>}{}} : */
+ math_list(degree(q)) = null;
flush_node(degree(q));
}
p = hpack(y, 0, additional, -1);
@@ -1854,14 +1915,12 @@ static void make_radical(pointer q, int cur_style)
type(nucleus(q)) = sub_box_node;
}
-
@ Construct a vlist box
+
@c
-static pointer
-wrapup_delimiter(pointer x, pointer y, pointer q,
- scaled shift_up, scaled shift_down)
+static pointer wrapup_over_under_delimiter(pointer x, pointer y, pointer q, scaled shift_up, scaled shift_down)
{
- pointer p; /* temporary register for box construction */
+ pointer p; /* temporary register for box construction */
pointer v = new_null_box();
type(v) = vlist_node;
height(v) = shift_up + height(x);
@@ -1875,26 +1934,72 @@ wrapup_delimiter(pointer x, pointer y, pointer q,
return v;
}
+/* when exact use radicalwidth (y is delimiter) */
+
@ @c
-#define fixup_widths(x,y) do { \
- if (width(y) >= width(x)) { \
- width(x) = width(y); \
- } else { \
- width(y) = width(x); \
- } \
- } while (0)
+
+#define fixup_widths(q,x,y) do { \
+ if (width(y) >= width(x)) { \
+ if (radicalwidth(q) != zero_glue) { \
+ shift_amount(x) += half(width(y)-width(x)) ; \
+ } \
+ width(x) = width(y); \
+ } else { \
+ if (radicalwidth(q) != zero_glue) { \
+ shift_amount(y) += half(width(x)-width(y)) ; \
+ } \
+ width(y) = width(x); \
+ } \
+} while (0)
+
+
+#define check_radical(q,stack,r,t) do { \
+ if (!stack && (width(r) >= width(t)) && (radicalwidth(q) != zero_glue) && (radicalwidth(q) != width(r))) { \
+ if (radicalleft(q)) { \
+ halfword p = new_kern(radicalwidth(q)-width(r)); \
+ reset_attributes(p, node_attr(q)); \
+ couple_nodes(p,r); \
+ r = hpack(p, 0, additional, -1); \
+ width(r) = radicalwidth(q); \
+ reset_attributes(r, node_attr(q)); \
+ } else if (radicalmiddle(q)) { \
+ halfword p = new_kern(half(radicalwidth(q)-width(r))); \
+ reset_attributes(p, node_attr(q)); \
+ couple_nodes(p,r); \
+ r = hpack(p, 0, additional, -1); \
+ width(r) = radicalwidth(q); \
+ reset_attributes(r, node_attr(q)); \
+ } else if (radicalright(q)) { \
+ /* also kind of exact compared to vertical */ \
+ r = hpack(r, 0, additional, -1); \
+ width(r) = radicalwidth(q); \
+ reset_attributes(r, node_attr(q)); \
+ } \
+ } \
+} while (0)
+
+#define check_widths(q,p) do { \
+ if (radicalwidth(q) != zero_glue) { \
+ wd = radicalwidth(q); \
+ } else { \
+ wd = width(p); \
+ } \
+} while (0)
@ this has the |nucleus| box |x| as a limit above an extensible delimiter |y|
@c
static void make_over_delimiter(pointer q, int cur_style)
{
- pointer x, y, v; /* temporary registers for box construction */
- scaled shift_up, shift_down, clr, delta;
+ pointer x, y, v; /* temporary registers for box construction */
+ scaled shift_up, shift_down, clr, delta, wd;
+ boolean stack;
x = clean_box(nucleus(q), sub_style(cur_style), cur_style);
- y = flat_delimiter(left_delimiter(q), cur_size, width(x), cur_style);
+ check_widths(q,x);
+ y = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL);
left_delimiter(q) = null;
- fixup_widths(x, y);
+ check_radical(q,stack,y,x);
+ fixup_widths(q, x, y);
shift_up = over_delimiter_bgap(cur_style);
shift_down = 0;
clr = over_delimiter_vgap(cur_style);
@@ -1902,8 +2007,35 @@ static void make_over_delimiter(pointer q, int cur_style)
if (delta > 0) {
shift_up = shift_up + delta;
}
- v = wrapup_delimiter(x, y, q, shift_up, shift_down);
- width(v) = width(x); /* this also equals |width(y)| */
+ v = wrapup_over_under_delimiter(x, y, q, shift_up, shift_down);
+ width(v) = width(x); /* this also equals |width(y)| */
+ math_list(nucleus(q)) = v;
+ type(nucleus(q)) = sub_box_node;
+}
+
+@ this has the extensible delimiter |x| as a limit below |nucleus| box |y|
+
+@c
+static void make_under_delimiter(pointer q, int cur_style)
+{
+ pointer x, y, v; /* temporary registers for box construction */
+ scaled shift_up, shift_down, clr, delta, wd;
+ boolean stack;
+ y = clean_box(nucleus(q), sup_style(cur_style), cur_style);
+ check_widths(q,y);
+ x = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL);
+ left_delimiter(q) = null;
+ check_radical(q,stack,x,y);
+ fixup_widths(q, x, y);
+ shift_up = 0;
+ shift_down = under_delimiter_bgap(cur_style);
+ clr = under_delimiter_vgap(cur_style);
+ delta = clr - ((shift_up - depth(x)) - (height(y) - shift_down));
+ if (delta > 0) {
+ shift_down = shift_down + delta;
+ }
+ v = wrapup_over_under_delimiter(x, y, q, shift_up, shift_down);
+ width(v) = width(y); /* this also equals |width(y)| */
math_list(nucleus(q)) = v;
type(nucleus(q)) = sub_box_node;
}
@@ -1913,14 +2045,15 @@ static void make_over_delimiter(pointer q, int cur_style)
@c
static void make_delimiter_over(pointer q, int cur_style)
{
- pointer x, y, v; /* temporary registers for box construction */
- scaled shift_up, shift_down, clr, actual;
+ pointer x, y, v; /* temporary registers for box construction */
+ scaled shift_up, shift_down, clr, actual, wd;
+ boolean stack;
y = clean_box(nucleus(q), cur_style, cur_style);
- x = flat_delimiter(left_delimiter(q),
- cur_size + (cur_size == script_script_size ? 0 : 1),
- width(y), cur_style);
+ check_widths(q,y);
+ x = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL);
left_delimiter(q) = null;
- fixup_widths(x, y);
+ check_radical(q,stack,x,y);
+ fixup_widths(q, x, y);
shift_up = over_delimiter_bgap(cur_style)-height(x)-depth(x);
shift_down = 0;
clr = over_delimiter_vgap(cur_style);
@@ -1928,26 +2061,26 @@ static void make_delimiter_over(pointer q, int cur_style)
if (actual < clr) {
shift_up = shift_up + (clr-actual);
}
- v = wrapup_delimiter(x, y, q, shift_up, shift_down);
- width(v) = width(x); /* this also equals |width(y)| */
+ v = wrapup_over_under_delimiter(x, y, q, shift_up, shift_down);
+ width(v) = width(x); /* this also equals |width(y)| */
math_list(nucleus(q)) = v;
type(nucleus(q)) = sub_box_node;
}
-
@ this has the extensible delimiter |y| as a limit below a |nucleus| box |x|
@c
static void make_delimiter_under(pointer q, int cur_style)
{
pointer x, y, v; /* temporary registers for box construction */
- scaled shift_up, shift_down, clr, actual;
+ scaled shift_up, shift_down, clr, actual, wd;
+ boolean stack;
x = clean_box(nucleus(q), cur_style, cur_style);
- y = flat_delimiter(left_delimiter(q),
- cur_size + (cur_size == script_script_size ? 0 : 1),
- width(x), cur_style);
+ check_widths(q,x);
+ y = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL);
left_delimiter(q) = null;
- fixup_widths(x, y);
+ check_radical(q,stack,y,x);
+ fixup_widths(q, x, y);
shift_up = 0;
shift_down = under_delimiter_bgap(cur_style) - height(y)-depth(y);
clr = under_delimiter_vgap(cur_style);
@@ -1955,154 +2088,158 @@ static void make_delimiter_under(pointer q, int cur_style)
if (actual<clr) {
shift_down += (clr-actual);
}
- v = wrapup_delimiter(x, y, q, shift_up, shift_down);
- width(v) = width(y); /* this also equals |width(y)| */
+ v = wrapup_over_under_delimiter(x, y, q, shift_up, shift_down);
+ width(v) = width(y); /* this also equals |width(y)| */
math_list(nucleus(q)) = v;
type(nucleus(q)) = sub_box_node;
-
}
-@ this has the extensible delimiter |x| as a limit below |nucleus| box |y|
-
-@c
-static void make_under_delimiter(pointer q, int cur_style)
-{
- pointer x, y, v; /* temporary registers for box construction */
- scaled shift_up, shift_down, clr, delta;
- y = clean_box(nucleus(q), sup_style(cur_style), cur_style);
- x = flat_delimiter(left_delimiter(q), cur_size, width(y), cur_style);
- left_delimiter(q) = null;
- fixup_widths(x, y);
- shift_up = 0;
- shift_down = under_delimiter_bgap(cur_style);
- clr = under_delimiter_vgap(cur_style);
- delta = clr - ((shift_up - depth(x)) - (height(y) - shift_down));
- if (delta > 0) {
- shift_down = shift_down + delta;
- }
- v = wrapup_delimiter(x, y, q, shift_up, shift_down);
- width(v) = width(y); /* this also equals |width(y)| */
- math_list(nucleus(q)) = v;
- type(nucleus(q)) = sub_box_node;
-
-}
-
-
@ Slants are not considered when placing accents in math mode. The accenter is
centered over the accentee, and the accent width is treated as zero with
respect to the size of the final box.
@c
-#define TOP_CODE 1
-#define BOT_CODE 2
-#define TOP_OR_BOT_MASK ((TOP_CODE) | (BOT_CODE))
-#define STRETCH_ACCENT_CODE 4
+#define TOP_CODE 1
+#define BOT_CODE 2
+#define OVERLAY_CODE 4
+#define STRETCH_ACCENT_CODE 8
-static boolean compute_accent_skew(pointer q, int top_or_bot, scaled *s)
+static boolean compute_accent_skew(pointer q, int flags, scaled *s)
{
- pointer p; /* temporary register for box construction */
- boolean s_is_absolute; /* will be true if a top-accent is placed in |s| */
-
- s_is_absolute = false;
-
+ pointer p; /* temporary register for box construction */
+ boolean s_is_absolute = false; /* will be true if a top-accent is placed in |s| */
if (type(nucleus(q)) == math_char_node) {
fetch(nucleus(q));
if (is_new_mathfont(cur_f)) {
- if (top_or_bot == TOP_CODE) {
- *s = char_top_accent(cur_f, cur_c);
- if (*s != INT_MIN) {
- s_is_absolute = true;
- }
- } else {
- *s = char_bot_accent(cur_f, cur_c);
- if (*s != INT_MIN) {
- s_is_absolute = true;
+ /*
+ there is no bot_accent so let's assume similarity
+
+ if (flags & (TOP_CODE | OVERLAY_CODE)) {
+ *s = char_top_accent(cur_f, cur_c);
+ if (*s != INT_MIN) {
+ s_is_absolute = true;
+ }
+ } else {
+ *s = char_bot_accent(cur_f, cur_c);
+ if (*s != INT_MIN) {
+ s_is_absolute = true;
+ }
}
+ */
+ *s = char_top_accent(cur_f, cur_c);
+ if (*s != INT_MIN) {
+ s_is_absolute = true;
}
} else {
- if (top_or_bot == TOP_CODE) {
+ if (flags & TOP_CODE) {
*s = get_kern(cur_f, cur_c, skew_char(cur_f));
} else {
*s = 0;
}
}
} else if (type(nucleus(q)) == sub_mlist_node) {
- /* if |nucleus(q)| is a |sub_mlist_node| composed of an |accent_noad| we
- * use the positioning of the nucleus of that noad, recursing until
- * the inner most |accent_noad|. This way multiple stacked accents are
- * aligned to the inner most one. */
+ /*
+ if |nucleus(q)| is a |sub_mlist_node| composed of an |accent_noad| we
+
+ * use the positioning of the nucleus of that noad, recursing until
+ * the inner most |accent_noad|. This way multiple stacked accents are
+ * aligned to the inner most one.
+ */
p = math_list(nucleus(q));
if (type(p) == accent_noad) {
- s_is_absolute = compute_accent_skew(p, top_or_bot, s);
+ s_is_absolute = compute_accent_skew(p, flags, s);
}
}
return s_is_absolute;
}
-static void do_make_math_accent(pointer q, internal_font_number f, int c,
- int flags, int cur_style)
+static void do_make_math_accent(pointer q, internal_font_number f, int c, int flags, int cur_style)
{
- pointer p, r, x, y; /* temporary registers for box construction */
- scaled s; /* amount to skew the accent to the right */
- scaled h; /* height of character being accented */
- scaled delta; /* space to remove between accent and accentee */
- scaled w; /* width of the accentee, not including sub/superscripts */
- boolean s_is_absolute; /* will be true if a top-accent is placed in |s| */
+ pointer p, r, x, y; /* temporary registers for box construction */
+ scaled s; /* amount to skew the accent to the right */
+ scaled h; /* height of character being accented */
+ scaled delta; /* space to remove between accent and accentee */
+ scaled w; /* width of the accentee, not including sub/superscripts */
+ boolean s_is_absolute; /* will be true if a top-accent is placed in |s| */
+ scaled fraction ;
+ scaled target ;
extinfo *ext;
pointer attr_p;
- const int top_or_bot = flags & TOP_OR_BOT_MASK;
- attr_p = (top_or_bot == TOP_CODE ? accent_chr(q) : bot_accent_chr(q));
+ attr_p = (flags & TOP_CODE ? top_accent_chr(q) : flags & BOT_CODE ? bot_accent_chr(q) : overlay_accent_chr(q));
+ fraction = accentfraction(q);
c = cur_c;
f = cur_f;
-
- s = 0;
- s_is_absolute = false;
+ s = 1;
+ if (fraction == 0) {
+ fraction = 1000;
+ }
/* Compute the amount of skew, or set |s| to an alignment point */
- s_is_absolute = compute_accent_skew(q, top_or_bot, &s);
-
+ s_is_absolute = compute_accent_skew(q, flags, &s);
x = clean_box(nucleus(q), cramped_style(cur_style), cur_style);
w = width(x);
h = height(x);
if (is_new_mathfont(cur_f) && !s_is_absolute) {
- s = half(w);
- s_is_absolute = true;
+ s = half(w);
+ s_is_absolute = true;
}
/* Switch to a larger accent if available and appropriate */
y = null;
ext = NULL;
+ if (flags & OVERLAY_CODE) {
+ if (fraction > 0) {
+ target = xn_over_d(h,fraction,1000);
+ } else {
+ target = h;
+ }
+ } else {
+ if (fraction > 0) {
+ target = xn_over_d(w,fraction,1000);
+ } else {
+ target = w;
+ }
+ }
if ((flags & STRETCH_ACCENT_CODE) && (char_width(f, c) < w)) {
while (1) {
- if ((char_tag(f, c) == ext_tag) &&
- ((ext = get_charinfo_hor_variants(char_info(f, c))) != NULL)) {
- y = get_delim_hbox(ext, f, w, node_attr(attr_p), cur_style);
+ if ((char_tag(f, c) == ext_tag) && ((ext = get_charinfo_hor_variants(char_info(f, c))) != NULL)) {
+ /* a bit weird for an overlay but anyway, here we don't need a factor as we don't step */
+ y = get_delim_box(q, ext, f, w, node_attr(attr_p), cur_style, hlist_node);
break;
} else if (char_tag(f, c) != list_tag) {
break;
} else {
int yy = char_remainder(f, c);
- if (!char_exists(f, yy))
- break;
- if (char_width(f, yy) > w)
+ if (!char_exists(f, yy)) {
break;
+ } else if (flags & OVERLAY_CODE) {
+ if (char_height(f, yy) > target) {
+ break;
+ }
+ } else {
+ if (char_width(f, yy) > target)
+ break;
+ }
c = yy;
}
}
}
if (y == null) {
- y = char_box(f, c, node_attr(attr_p));
+ y = char_box(f, c, node_attr(attr_p)); /* italic gets added to width */
}
- if (top_or_bot == TOP_CODE) {
- if (h < accent_base_height(f))
+ if (flags & TOP_CODE) {
+ if (h < accent_base_height(f)) {
delta = h;
- else
+ } else {
delta = accent_base_height(f);
+ }
+ } else if (flags & OVERLAY_CODE) {
+ delta = half(height(y) + depth(y) + height(x) + depth(x)); /* center the accent vertically around the accentee */
} else {
- delta = 0; /* hm */
+ delta = 0; /* hm */
}
if ((supscr(q) != null) || (subscr(q) != null)) {
if (type(nucleus(q)) == math_char_node) {
- /* Swap the subscript and superscript into box |x| */
+ /* swap the subscript and superscript into box |x| */
flush_node_list(x);
x = new_noad();
r = math_clone(nucleus(q));
@@ -2118,15 +2255,27 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c,
h = height(x);
}
}
+ /* the top accents of both characters are aligned */
if (s_is_absolute) {
scaled sa;
if (ext != NULL) {
- sa = half(width(y)); /* if the accent is extensible just take the center */
+ /* if the accent is extensible just take the center */
+ sa = half(width(y));
} else {
+ /*
+ there is no bot_accent so let's assume similarity
+
+ if (flags & BOT_CODE) {
+ sa = char_bot_accent(f, c);
+ } else {
+ sa = char_top_accent(f, c);
+ }
+ */
sa = char_top_accent(f, c);
}
if (sa == INT_MIN) {
- sa = half(width(y)); /* just take the center */
+ /* just take the center */
+ sa = half(width(y));
}
if (math_direction == dir_TRT) {
shift_amount(y) = s + sa - width(y);
@@ -2136,26 +2285,19 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c,
} else {
if (width(y)== 0) {
shift_amount(y) = s + w;
+ } else if (math_direction == dir_TRT) {
+ shift_amount(y) = s + width(y); /* ok? */
} else {
- if (math_direction == dir_TRT) {
- shift_amount(y) = s + width(y);
- } else {
- shift_amount(y) = s + half(w - width(y));
- }
+ shift_amount(y) = s + half(w - width(y));
}
}
width(y) = 0;
- if (top_or_bot == TOP_CODE) {
+ if (flags & (TOP_CODE | OVERLAY_CODE)) {
p = new_kern(-delta);
+ reset_attributes(p, node_attr(q));
couple_nodes(p,x);
couple_nodes(y,p);
} else {
-#if 0
- p = new_kern(-delta);
- couple_nodes(x,p);
- couple_nodes(p,y);
- y = x;
-#endif
couple_nodes(x,y);
y = x;
}
@@ -2163,13 +2305,12 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c,
reset_attributes(r, node_attr(q));
width(r) = width(x);
y = r;
- if (top_or_bot == TOP_CODE) {
+ if (flags & (TOP_CODE | OVERLAY_CODE)) {
if (height(y) < h) {
- /* Make the height of box |y| equal to |h| */
+ /* make the height of box |y| equal to |h| */
p = new_kern(h - height(y));
reset_attributes(p, node_attr(q));
-// vlink(p) = list_ptr(y);
-try_couple_nodes(p,list_ptr(y));
+ try_couple_nodes(p,list_ptr(y));
list_ptr(y) = p;
height(y) = h;
}
@@ -2185,13 +2326,13 @@ static void make_math_accent(pointer q, int cur_style)
int topstretch = !(subtype(q) % 2);
int botstretch = !(subtype(q) / 2);
- if (accent_chr(q) != null) {
- fetch(accent_chr(q));
+ if (top_accent_chr(q) != null) {
+ fetch(top_accent_chr(q));
if (char_exists(cur_f, cur_c)) {
do_make_math_accent(q, cur_f, cur_c, TOP_CODE | (topstretch ? STRETCH_ACCENT_CODE : 0), cur_style);
}
- flush_node(accent_chr(q));
- accent_chr(q) = null;
+ flush_node(top_accent_chr(q));
+ top_accent_chr(q) = null;
}
if (bot_accent_chr(q) != null) {
fetch(bot_accent_chr(q));
@@ -2201,6 +2342,14 @@ static void make_math_accent(pointer q, int cur_style)
flush_node(bot_accent_chr(q));
bot_accent_chr(q) = null;
}
+ if (overlay_accent_chr(q) != null) {
+ fetch(overlay_accent_chr(q));
+ if (char_exists(cur_f, cur_c)) {
+ do_make_math_accent(q, cur_f, cur_c, OVERLAY_CODE | STRETCH_ACCENT_CODE, cur_style);
+ }
+ flush_node(overlay_accent_chr(q));
+ overlay_accent_chr(q) = null;
+ }
}
@ The |make_fraction| procedure is a bit different because it sets
@@ -2209,28 +2358,46 @@ static void make_math_accent(pointer q, int cur_style)
@c
static void make_fraction(pointer q, int cur_style)
{
- pointer p, v, x, y, z; /* temporary registers for box construction */
- scaled delta, delta1, delta2, shift_up, shift_down, clr;
+ pointer p, p1, p2, v, x, y, z, l, r, m; /* temporary registers for box construction */
+ scaled delta, delta1, delta2, shift_up, shift_down, clr1, clr2;
/* dimensions for box calculations */
if (thickness(q) == default_code)
thickness(q) = fraction_rule(cur_style);
- /* Create equal-width boxes |x| and |z| for the numerator and denominator,
- and compute the default amounts |shift_up| and |shift_down| by which they
- are displaced from the baseline */
+ /*
+ Create equal-width boxes |x| and |z| for the numerator and denominator,
+ and compute the default amounts |shift_up| and |shift_down| by which they
+ are displaced from the baseline
+ */
+
x = clean_box(numerator(q), num_style(cur_style), cur_style);
z = clean_box(denominator(q), denom_style(cur_style), cur_style);
- if (width(x) < width(z))
- x = rebox(x, width(z));
- else
- z = rebox(z, width(x));
- if (thickness(q) == 0) {
+
+ if (middle_delimiter(q) != null) {
+ delta = 0;
+ m = do_delimiter(q, middle_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
+ middle_delimiter(q) = null;
+ } else {
+ m = null ;
+ if (width(x) < width(z)) {
+ x = rebox(x, width(z));
+ } else {
+ z = rebox(z, width(x));
+ }
+ }
+
+ if (m != null) {
+ shift_up = 0;
+ shift_down = 0;
+ } else if (thickness(q) == 0) {
shift_up = stack_num_up(cur_style);
shift_down = stack_denom_down(cur_style);
- /* The numerator and denominator must be separated by a certain minimum
- clearance, called |clr| in the following program. The difference between
- |clr| and the actual clearance is |2delta|. */
- clr = stack_vgap(cur_style);
- delta = half(clr - ((shift_up - depth(x)) - (height(z) - shift_down)));
+ /*
+ the numerator and denominator must be separated by a certain minimum
+ clearance, called |clr| in the following program. The difference between
+ |clr| and the actual clearance is |2delta|.
+ */
+ clr1 = stack_vgap(cur_style);
+ delta = half(clr1 - ((shift_up - depth(x)) - (height(z) - shift_down)));
if (delta > 0) {
shift_up = shift_up + delta;
shift_down = shift_down + delta;
@@ -2238,58 +2405,157 @@ static void make_fraction(pointer q, int cur_style)
} else {
shift_up = fraction_num_up(cur_style);
shift_down = fraction_denom_down(cur_style);
- /* In the case of a fraction line, the minimum clearance depends on the actual
- thickness of the line. */
+ /*
+ in the case of a fraction line, the minimum clearance depends on the actual
+ thickness of the line.
+ */
+ clr1 = fraction_num_vgap(cur_style);
+ clr2 = fraction_denom_vgap(cur_style);
delta = half(thickness(q));
- clr = fraction_num_vgap(cur_style);
- clr = ext_xn_over_d(clr, thickness(q), fraction_rule(cur_style));
- delta1 = clr - ((shift_up - depth(x)) - (math_axis(cur_size) + delta));
- if (delta1 > 0)
+ if (fractionexact(q)) {
+ delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis(cur_size) + delta));
+ delta2 = clr2 - ((shift_down - height(z)) + (math_axis(cur_size) - delta));
+ } else {
+ delta = half(thickness(q));
+ clr1 = ext_xn_over_d(clr1, thickness(q), fraction_rule(cur_style));
+ clr2 = ext_xn_over_d(clr2, thickness(q), fraction_rule(cur_style));
+ delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis(cur_size) + delta));
+ delta2 = clr2 - ((shift_down - height(z)) + (math_axis(cur_size) - delta));
+ }
+ if (delta1 > 0) {
shift_up = shift_up + delta1;
- clr = fraction_denom_vgap(cur_style);
- clr = ext_xn_over_d(clr, thickness(q), fraction_rule(cur_style));
- delta2 =
- clr - ((math_axis(cur_size) - delta) - (height(z) - shift_down));
- if (delta2 > 0)
+ }
+ if (delta2 > 0) {
shift_down = shift_down + delta2;
+ }
}
- /* Construct a vlist box for the fraction, according to |shift_up| and |shift_down| */
- v = new_null_box();
- type(v) = vlist_node;
- height(v) = shift_up + height(x);
- depth(v) = depth(z) + shift_down;
- width(v) = width(x); /* this also equals |width(z)| */
- reset_attributes(v, node_attr(q));
- if (thickness(q) == 0) {
- p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
- couple_nodes(p,z);
+ if (m != null) {
+ /*
+ construct a hlist box for the fraction, according to |hgap| and |vgap|
+ */
+ shift_up = skewed_fraction_vgap(cur_style);
+
+ if (!fractionnoaxis(q)) {
+ shift_up += half(math_axis(cur_size));
+ }
+
+ shift_down = shift_up;
+ v = new_null_box();
+ reset_attributes(v, node_attr(q));
+ type(v) = hlist_node;
+ list_ptr(v) = x;
+ width(v) = width(x);
+ height(v) = height(x) + shift_up;
+ depth(v) = depth(x);
+ shift_amount(v) = - shift_up;
+ x = v;
+
+ v = new_null_box();
+ reset_attributes(v, node_attr(q));
+ type(v) = hlist_node;
+ list_ptr(v) = z;
+ width(v) = width(z);
+ height(v) = height(z);
+ depth(v) = depth(z) + shift_down;
+ shift_amount(v) = shift_down;
+ z = v;
+
+ v = new_null_box();
+ reset_attributes(v, node_attr(q));
+ type(v) = hlist_node;
+ if (height(x) > height(z)) {
+ height(v) = height(x);
+ } else {
+ height(v) = height(z);
+ }
+ if (depth(x) > depth(z)) {
+ depth(v) = depth(x);
+ } else {
+ depth(v) = depth(z);
+ }
+ if (height(m) > height(v)) {
+ height(v) = height(m);
+ }
+ if (depth(m) > depth(v)) {
+ depth(v) = depth(m);
+ }
+
+ if (fractionexact(q)) {
+ delta1 = -half(skewed_fraction_hgap(cur_style));
+ delta2 = delta1;
+ width(v) = width(x) + width(z) + width(m) - skewed_fraction_hgap(cur_style);
+ } else {
+ delta1 = half(skewed_fraction_hgap(cur_style)-width(m));
+ delta2 = half(skewed_fraction_hgap(cur_style)+width(m));
+ width(v) = width(x) + width(z) + skewed_fraction_hgap(cur_style);
+ width(m) = 0;
+ }
+
+ p1 = new_kern(delta1);
+ reset_attributes(p1, node_attr(q));
+ p2 = new_kern(delta2);
+ reset_attributes(p2, node_attr(q));
+
+ couple_nodes(x,p1);
+ couple_nodes(p1,m);
+ couple_nodes(m,p2);
+ couple_nodes(p2,z);
+
+ list_ptr(v) = x;
} else {
- y = do_fraction_rule(thickness(q), node_attr(q));
- p = new_kern((math_axis(cur_size) - delta) - (height(z) - shift_down));
+ /*
+ construct a vlist box for the fraction, according to |shift_up| and |shift_down|
+ */
+ v = new_null_box();
+ type(v) = vlist_node;
+ height(v) = shift_up + height(x);
+ depth(v) = depth(z) + shift_down;
+ width(v) = width(x); /* this also equals |width(z)| */
+ reset_attributes(v, node_attr(q));
+ if (thickness(q) == 0) {
+ p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
+ couple_nodes(p,z);
+ } else {
+ y = do_fraction_rule(thickness(q), node_attr(q));
+ p = new_kern((math_axis(cur_size) - delta) - (height(z) - shift_down));
+ reset_attributes(p, node_attr(q));
+ couple_nodes(y,p);
+ couple_nodes(p,z);
+ p = new_kern((shift_up - depth(x)) - (math_axis(cur_size) + delta));
+ couple_nodes(p,y);
+ }
reset_attributes(p, node_attr(q));
- couple_nodes(y,p);
- couple_nodes(p,z);
- p = new_kern((shift_up - depth(x)) - (math_axis(cur_size) + delta));
- couple_nodes(p,y);
+ couple_nodes(x,p);
+ list_ptr(v) = x;
}
- reset_attributes(p, node_attr(q));
- couple_nodes(x,p);
- list_ptr(v) = x;
- /* Put the fraction into a box with its delimiters, and make |new_hlist(q)|
- point to it */
- delta = fraction_del_size(cur_style);
- x = var_delimiter(left_delimiter(q), cur_size, delta, NULL, cur_style);
+ /*
+ put the fraction into a box with its delimiters, and make |new_hlist(q)|
+ point to it
+ */
+ if (is_new_mathfont(cur_f)) {
+ if (math_use_old_fraction_scaling) {
+ delta = fraction_del_size_old(cur_style);
+ } else {
+ delta = fraction_del_size_new(cur_style);
+ }
+ if (delta == undefined_math_parameter) {
+ delta = get_delimiter_height(depth(v), height(v), true);
+ }
+ } else {
+ delta = fraction_del_size_old(cur_style);
+ }
+
+ l = do_delimiter(q, left_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
left_delimiter(q) = null;
- couple_nodes(x,v);
- z = var_delimiter(right_delimiter(q), cur_size, delta, NULL, cur_style);
+ r = do_delimiter(q, right_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
right_delimiter(q) = null;
- couple_nodes(v,z);
- y = hpack(x, 0, additional, -1);
+ couple_nodes(l,v);
+ couple_nodes(v,r);
+ y = hpack(l, 0, additional, -1);
reset_attributes(y, node_attr(q));
assign_new_hlist(q, y);
}
-
@ If the nucleus of an |op_noad| is a single character, it is to be
centered vertically with respect to the axis, after first being enlarged
(via a character list in the font) if we are in display style. The normal
@@ -2297,52 +2563,49 @@ convention for placing displayed limits is to put them above and below the
operator in display style.
The italic correction is removed from the character if there is a subscript
-and the limits are not being displayed. The |make_op|
-routine returns the value that should be used as an offset between
-subscript and superscript.
+and the limits are not being displayed. The |make_op| routine returns the
+value that should be used as an offset between subscript and superscript.
After |make_op| has acted, |subtype(q)| will be |limits| if and only if
the limits have been set above and below the operator. In that case,
|new_hlist(q)| will already contain the desired final box.
@c
+static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled supshift, scaled subshift);
+static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style);
+
static scaled make_op(pointer q, int cur_style)
{
- scaled delta; /* offset between subscript and superscript */
- pointer p, v, x, y, z; /* temporary registers for box construction */
- int c; /* register for character examination */
- scaled shift_up, shift_down; /* dimensions for box calculation */
+ scaled delta = 0; /* offset between subscript and superscript */
+ pointer p, v, x, y, z, n; /* temporary registers for box construction */
+ int c; /* register for character examination */
+ scaled shift_up, shift_down; /* dimensions for box calculation */
+ boolean axis_shift = false;
scaled ok_size;
- if ((subtype(q) == op_noad_type_normal) && (cur_style < text_style))
+ if ((subtype(q) == op_noad_type_normal) && (cur_style < text_style)) {
subtype(q) = op_noad_type_limits;
+ }
if (type(nucleus(q)) == math_char_node) {
fetch(nucleus(q));
- if (cur_style < text_style) { /* try to make it larger */
+ if (cur_style < text_style) {
+ /* try to make it larger */
ok_size = minimum_operator_size(cur_style);
if (ok_size != undefined_math_parameter) {
/* creating a temporary delimiter is the cleanest way */
y = new_node(delim_node, 0);
+ reset_attributes(y, node_attr(q));
small_fam(y) = math_fam(nucleus(q));
small_char(y) = math_character(nucleus(q));
- x = var_delimiter(y, text_size, ok_size, &delta, cur_style);
- if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
- width(x) -= delta; /* remove italic correction */
- }
- /* For an OT MATH font, we may have to get rid of yet another italic
- correction because |make_scripts()| will add one.
- This test is somewhat more complicated because |x| can be a null
- delimiter */
- if ((subscr(q) != null || supscr(q) != null)
- && (subtype(q) != op_noad_type_limits)
- && ((list_ptr(x) != null)
- && (type(list_ptr(x)) == glyph_node)
- && is_new_mathfont(font(list_ptr(x))))) {
- width(x) -= delta; /* remove another italic correction */
+ x = do_delimiter(q, y, text_size, ok_size, false, cur_style, true, NULL, &delta);
+ if (is_new_mathfont(cur_f)) {
+ /* we never added italic correction */
+ } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
+ /* remove italic correction */
+ width(x) -= delta;
}
} else {
ok_size = height_plus_depth(cur_f, cur_c) + 1;
- while ((char_tag(cur_f, cur_c) == list_tag) &&
- height_plus_depth(cur_f, cur_c) < ok_size) {
+ while ((char_tag(cur_f, cur_c) == list_tag) && height_plus_depth(cur_f, cur_c) < ok_size) {
c = char_remainder(cur_f, cur_c);
if (!char_exists(cur_f, c))
break;
@@ -2351,43 +2614,55 @@ static scaled make_op(pointer q, int cur_style)
}
delta = char_italic(cur_f, cur_c);
x = clean_box(nucleus(q), cur_style, cur_style);
- if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits))
- width(x) = width(x) - delta; /* remove italic correction */
-
- shift_amount(x) =
- half(height(x) - depth(x)) - math_axis(cur_size);
- /* center vertically */
+ if (delta != null) {
+ if (is_new_mathfont(cur_f)) {
+ /* we never added italic correction */
+ } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
+ /* remove italic correction */
+ width(x) = width(x) - delta;
+ }
+ }
+ axis_shift = true;
}
- type(nucleus(q)) = sub_box_node;
- math_list(nucleus(q)) = x;
-
- } else { /* normal size */
+ } else {
+ /* normal size */
delta = char_italic(cur_f, cur_c);
x = clean_box(nucleus(q), cur_style, cur_style);
- if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits))
- width(x) = width(x) - delta; /* remove italic correction */
-
- /* For an OT MATH font, we may have to get rid of yet another italic
- correction because |make_scripts()| will add one.
- This test is somewhat more complicated because |x| can be a null
- delimiter */
- if ((subscr(q) != null || supscr(q) != null)
- && (subtype(q) != op_noad_type_limits)
- && ((list_ptr(x) != null)
- && (type(list_ptr(x)) == glyph_node)
- && is_new_mathfont(font(list_ptr(x))))) {
- width(x) -= delta; /* remove another italic correction */
- }
-
- shift_amount(x) = half(height(x) - depth(x)) - math_axis(cur_size);
+ if (delta != 0) {
+ if (is_new_mathfont(cur_f)) {
+ /* we never added italic correction */
+ } else if ((subscr(q) != null) && (subtype(q) != op_noad_type_limits)) {
+ /* remove italic correction */
+ width(x) = width(x) - delta;
+ }
+ }
+ axis_shift = true;
+ }
+ if (axis_shift) {
/* center vertically */
- type(nucleus(q)) = sub_box_node;
- math_list(nucleus(q)) = x;
+ shift_amount(x) = half(height(x) - depth(x)) - math_axis(cur_size);
}
- } else {
- delta = 0;
+ type(nucleus(q)) = sub_box_node;
+ math_list(nucleus(q)) = x;
}
- if (subtype(q) == op_noad_type_limits) {
+
+ /* we now handle op_nod_type_no_limits here too */
+
+ if (subtype(q) == op_noad_type_no_limits) {
+ if (is_new_mathfont(cur_f)) {
+ if (delta != 0) {
+ delta = half(delta) ;
+ /* similar code then the caller */
+ p = check_nucleus_complexity(q, 0, cur_style);
+ if ((subscr(q) == null) && (supscr(q) == null)) {
+ assign_new_hlist(q, p);
+ } else {
+ make_scripts(q, p, 0, cur_style, delta, -delta);
+ }
+ delta = 0;
+ }
+ }
+ } else if (subtype(q) == op_noad_type_limits) {
/* The following program builds a vlist box |v| for displayed limits. The
width of the box is not affected by the fact that the limits may be skewed. */
x = clean_box(supscr(q), sup_style(cur_style), cur_style);
@@ -2396,6 +2671,43 @@ static scaled make_op(pointer q, int cur_style)
v = new_null_box();
reset_attributes(v, node_attr(q));
type(v) = vlist_node;
+ if (is_new_mathfont(cur_f)) {
+ n = null;
+ if (! math_no_italic_compensation) {
+ n = nucleus(q);
+ if (n != null) {
+ if ((type(n) == sub_mlist_node) || (type(n) == sub_box_node)) {
+ n = math_list(n);
+ if (n != null) {
+ if (type(n) == hlist_node) {
+ n = list_ptr(n); /* just a not scaled char */
+ while (n != null) {
+ if (type(n) == glyph_node) {
+ delta = char_italic(font(n),character(n));
+ }
+ n = vlink(n);
+ }
+ } else {
+ while (n != null) {
+ if (type(n) == fence_noad) {
+ if (delimiteritalic(n) > delta) {
+ /* we can have dummies, the period ones */
+ delta = delimiteritalic(n);
+ }
+ }
+ n = vlink(n);
+ }
+ }
+ }
+ } else {
+ n = nucleus(q);
+ if (type(n) == math_char_node) {
+ delta = char_italic(fam_fnt(math_fam(n),cur_size),math_character(n));
+ }
+ }
+ }
+ }
+ }
width(v) = width(y);
if (width(x) > width(v))
width(v) = width(x);
@@ -2406,14 +2718,23 @@ static scaled make_op(pointer q, int cur_style)
z = rebox(z, width(v));
shift_amount(x) = half(delta);
shift_amount(z) = -shift_amount(x);
+ /* v is the still empty target */
height(v) = height(y);
depth(v) = depth(y);
- /* Attach the limits to |y| and adjust |height(v)|, |depth(v)| to
- account for their presence */
- /* We use |shift_up| and |shift_down| in the following program for the
- amount of glue between the displayed operator |y| and its limits |x| and
- |z|. The vlist inside box |v| will consist of |x| followed by |y| followed
- by |z|, with kern nodes for the spaces between and around them. */
+ /*
+ attach the limits to |y| and adjust |height(v)|, |depth(v)| to
+ account for their presence
+
+ we use |shift_up| and |shift_down| in the following program for the
+ amount of glue between the displayed operator |y| and its limits |x| and
+ |z|
+
+ the vlist inside box |v| will consist of |x| followed by |y| followed
+ by |z|, with kern nodes for the spaces between and around them
+
+ b: baseline v: minumum gap
+ */
+
if (supscr(q) == null) {
list_ptr(x) = null;
flush_node(x);
@@ -2430,9 +2751,7 @@ static scaled make_op(pointer q, int cur_style)
reset_attributes(p, node_attr(q));
couple_nodes(p,x);
list_ptr(v) = p;
- height(v) =
- height(v) + limit_above_kern(cur_style) + height(x) + depth(x) +
- shift_up;
+ height(v) = height(v) + limit_above_kern(cur_style) + height(x) + depth(x) + shift_up;
}
if (subscr(q) == null) {
list_ptr(z) = null;
@@ -2441,16 +2760,16 @@ static scaled make_op(pointer q, int cur_style)
shift_down = limit_below_bgap(cur_style) - height(z);
if (shift_down < limit_below_vgap(cur_style))
shift_down = limit_below_vgap(cur_style);
- p = new_kern(shift_down);
- reset_attributes(p, node_attr(q));
- couple_nodes(y,p);
- couple_nodes(p,z);
+ if (shift_down > 0) {
+ p = new_kern(shift_down);
+ reset_attributes(p, node_attr(q));
+ couple_nodes(y,p);
+ couple_nodes(p,z);
+ }
p = new_kern(limit_below_kern(cur_style));
reset_attributes(p, node_attr(q));
couple_nodes(z,p);
- depth(v) =
- depth(v) + limit_below_kern(cur_style) + height(z) + depth(z) +
- shift_down;
+ depth(v) = depth(v) + limit_below_kern(cur_style) + height(z) + depth(z) + shift_down;
}
if (subscr(q) != null) {
math_list(subscr(q)) = null;
@@ -2463,6 +2782,9 @@ static scaled make_op(pointer q, int cur_style)
supscr(q) = null;
}
assign_new_hlist(q, v);
+ if (is_new_mathfont(cur_f)) {
+ delta = 0;
+ }
}
return delta;
}
@@ -2478,36 +2800,52 @@ to a math font (i.e., a font with |space=0|).
No boundary characters enter into these ligatures.
@c
+#define simple_char_noad(p) (\
+ (p != null) && \
+ (type(p) == simple_noad) && \
+ (subtype(p) <= punct_noad_type) && \
+ (type(nucleus(p)) == math_char_node) \
+)
+
+#define same_nucleus_fam(p,q) \
+ (math_fam(nucleus(p)) == math_fam(nucleus(q)))
+
static void make_ord(pointer q)
{
- int a; /* the left-side character for lig/kern testing */
- pointer p, r, s; /* temporary registers for list manipulation */
- scaled k; /* a kern */
- liginfo lig; /* a ligature */
+ int a; /* the left-side character for lig/kern testing */
+ pointer p, r, s; /* temporary registers for list manipulation */
+ scaled k; /* a kern */
+ liginfo lig; /* a ligature */
RESTART:
- if (subscr(q) == null &&
- supscr(q) == null && type(nucleus(q)) == math_char_node) {
+ if (subscr(q) == null && supscr(q) == null && type(nucleus(q)) == math_char_node) {
p = vlink(q);
- if ((p != null) &&
- (type(p) == simple_noad) &&
- (subtype(p) <= punct_noad_type) &&
- (type(nucleus(p)) == math_char_node) &&
- (math_fam(nucleus(p)) == math_fam(nucleus(q)))) {
+ if (simple_char_noad(p) && same_nucleus_fam(p,q)) {
type(nucleus(q)) = math_text_char_node;
fetch(nucleus(q));
a = cur_c;
+ /* add italic correction */
+ if (is_new_mathfont(cur_f) && (char_italic(cur_f,math_character(nucleus(q))) != 0)) {
+ p = new_kern(char_italic(cur_f,math_character(nucleus(q))));
+ reset_attributes(p, node_attr(q));
+ couple_nodes(p,vlink(q));
+ couple_nodes(q,p);
+ return;
+ }
+ /* construct ligatures, quite unlikely in new math fonts */
if ((has_kern(cur_f, a)) || (has_lig(cur_f, a))) {
cur_c = math_character(nucleus(p));
- /* If character |a| has a kern with |cur_c|, attach
- the kern after~|q|; or if it has a ligature with |cur_c|, combine
- noads |q| and~|p| appropriately; then |return| if the cursor has
- moved past a noad, or |goto restart| */
+ /*
+ if character |a| has a kern with |cur_c|, attach the kern after~|q|; or if
+ it has a ligature with |cur_c|, combine noads |q| and~|p| appropriately;
+ then |return| if the cursor has moved past a noad, or |goto restart|
- /* Note that a ligature between an |ord_noad| and another kind of noad
- is replaced by an |ord_noad|, when the two noads collapse into one.
- But we could make a parenthesis (say) change shape when it follows
- certain letters. Presumably a font designer will define such
- ligatures only when this convention makes sense. */
+ note that a ligature between an |ord_noad| and another kind of noad
+ is replaced by an |ord_noad|, when the two noads collapse into one
+
+ we could make a parenthesis (say) change shape when it follows
+ certain letters. Presumably a font designer will define such
+ ligatures only when this convention makes sense
+ */
if (disable_lig == 0 && has_lig(cur_f, a)) {
lig = get_ligature(cur_f, a, cur_c);
@@ -2515,17 +2853,24 @@ static void make_ord(pointer q)
check_interrupt(); /* allow a way out of infinite ligature loop */
switch (lig_type(lig)) {
case 1:
+ /* \.{=:\char`\|} */
case 5:
- math_character(nucleus(q)) = lig_replacement(lig); /* \.{=:\char`\|}, \.{=:\char`\|>} */
+ /* \.{=:\char`\|>} */
+ math_character(nucleus(q)) = lig_replacement(lig);
break;
case 2:
+ /* \.{\char`\|=:} */
case 6:
- math_character(nucleus(p)) = lig_replacement(lig); /* \.{\char`\|=:}, \.{\char`\|=:>} */
+ /* \.{\char`\|=:>} */
+ math_character(nucleus(p)) = lig_replacement(lig);
break;
case 3:
+ /* \.{\char`\|=:\char`\|} */
case 7:
+ /* \.{\char`\|=:\char`\|>} */
case 11:
- r = new_noad(); /* \.{\char`\|=:\char`\|}, \.{\char`\|=:\char`\|>}, \.{\char`\|=:\char`\|>>} */
+ /* \.{\char`\|=:\char`\|>>} */
+ r = new_noad();
reset_attributes(r, node_attr(q));
s = new_node(math_char_node, 0);
reset_attributes(s, node_attr(q));
@@ -2537,16 +2882,17 @@ static void make_ord(pointer q)
if (lig_type(lig) < 11)
type(nucleus(r)) = math_char_node;
else
- type(nucleus(r)) = math_text_char_node; /* prevent combination */
+ /* prevent combination */
+ type(nucleus(r)) = math_text_char_node;
break;
default:
try_couple_nodes(q,vlink(p));
- math_character(nucleus(q)) = lig_replacement(lig); /* \.{=:} */
+ math_character(nucleus(q)) = lig_replacement(lig); /* \.{=:} */
s = math_clone(subscr(p));
subscr(q) = s;
s = math_clone(supscr(p));
supscr(q) = s;
- math_reset(subscr(p)); /* just in case */
+ math_reset(subscr(p)); /* just in case */
math_reset(supscr(p));
flush_node(p);
break;
@@ -2558,7 +2904,8 @@ static void make_ord(pointer q)
}
}
if (disable_kern == 0 && has_kern(cur_f, a)) {
- k = get_kern(cur_f, a, cur_c); /* todo: should this use mathkerns? */
+ /* todo: should this use mathkerns? */
+ k = get_kern(cur_f, a, cur_c);
if (k != 0) {
p = new_kern(k);
reset_attributes(p, node_attr(q));
@@ -2580,12 +2927,12 @@ please use old-style italic correction placement
#define MATH_KERN_NOT_FOUND 0x7FFFFFFF
@ This function tries to find the kern needed for proper cut-ins.
- The left side doesn't move, but the right side does, so the first
- order of business is to create a staggered fence line on the
- left side of the right character.
+The left side doesn't move, but the right side does, so the first
+order of business is to create a staggered fence line on the
+left side of the right character.
- The microsoft spec says that there are four quadrants, but the
- actual images say
+The microsoft spec says that there are four quadrants, but the
+actual images say
@c
static scaled math_kern_at(internal_font_number f, int c, int side, int v)
@@ -2593,7 +2940,7 @@ static scaled math_kern_at(internal_font_number f, int c, int side, int v)
int h, k, numkerns;
scaled *kerns_heights;
scaled kern = 0;
- charinfo *co = char_info(f, c); /* known to exist */
+ charinfo *co = char_info(f, c); /* known to exist */
numkerns = get_charinfo_math_kerns(co, side);
#ifdef DEBUG
fprintf(stderr, " entries = %d, height = %d\n", numkerns, v);
@@ -2632,24 +2979,22 @@ static scaled math_kern_at(internal_font_number f, int c, int side, int v)
}
@ @c
-static scaled
-find_math_kern(internal_font_number l_f, int l_c,
- internal_font_number r_f, int r_c, int cmd, scaled shift)
+static scaled find_math_kern(internal_font_number l_f, int l_c,
+ internal_font_number r_f, int r_c,
+ int cmd, scaled shift)
{
scaled corr_height_top = 0, corr_height_bot = 0;
scaled krn_l = 0, krn_r = 0, krn = 0;
- if ((!is_new_mathfont(l_f)) || (!is_new_mathfont(r_f))
- || (!char_exists(l_f, l_c)) || (!char_exists(r_f, r_c)))
+ if ((!is_new_mathfont(l_f)) || (!is_new_mathfont(r_f)) || (!char_exists(l_f, l_c)) || (!char_exists(r_f, r_c)))
return MATH_KERN_NOT_FOUND;
if (cmd == sup_mark_cmd) {
corr_height_top = char_height(l_f, l_c);
- corr_height_bot = -char_depth(r_f, r_c) + shift; /* bottom of superscript */
+ corr_height_bot = -char_depth(r_f, r_c) + shift; /* bottom of superscript */
krn_l = math_kern_at(l_f, l_c, top_right_kern, corr_height_top);
krn_r = math_kern_at(r_f, r_c, bottom_left_kern, corr_height_top);
#ifdef DEBUG
- fprintf(stderr, "SUPER Top LR = %d,%d (shift %d)\n", krn_l, krn_r,
- shift);
+ fprintf(stderr, "SUPER Top LR = %d,%d (shift %d)\n", krn_l, krn_r, shift);
#endif
krn = (krn_l + krn_r);
krn_l = math_kern_at(l_f, l_c, top_right_kern, corr_height_bot);
@@ -2662,7 +3007,7 @@ find_math_kern(internal_font_number l_f, int l_c,
return (krn);
} else if (cmd == sub_mark_cmd) {
- corr_height_top = char_height(r_f, r_c) - shift; /* top of subscript */
+ corr_height_top = char_height(r_f, r_c) - shift; /* top of subscript */
corr_height_bot = -char_depth(l_f, l_c);
krn_l = math_kern_at(l_f, l_c, bottom_right_kern, corr_height_top);
krn_r = math_kern_at(r_f, r_c, top_left_kern, corr_height_top);
@@ -2682,7 +3027,7 @@ find_math_kern(internal_font_number l_f, int l_c,
} else {
confusion("find_math_kern");
}
- return 0; /* not reached */
+ return 0; /* not reached */
}
@ just a small helper
@@ -2691,7 +3036,9 @@ static pointer attach_hkern_to_new_hlist(pointer q, scaled delta2)
{
pointer y;
pointer z = new_kern(delta2);
- if (new_hlist(q) == null) { /* this is somewhat weird */
+ reset_attributes(z, node_attr(q));
+ if (new_hlist(q) == null) {
+ /* this is somewhat weird */
new_hlist(q) = z;
} else {
y = new_hlist(q);
@@ -2730,7 +3077,6 @@ void dump_simple_field(pointer q)
}
}
-
void dump_simple_node(pointer q)
{
printf("node %d, type=%d, vlink=%d\n", q, type(q), vlink(q));
@@ -2794,11 +3140,10 @@ the new fonts so eventualy there will be an option to ignore such corrections.
} \
} while (0)
-
-static void make_scripts(pointer q, pointer p, scaled it, int cur_style)
+static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled supshift, scaled subshift)
{
- pointer x, y, z; /* temporary registers for box construction */
- scaled shift_up, shift_down, clr; /* dimensions in the calculation */
+ pointer x, y, z; /* temporary registers for box construction */
+ scaled shift_up, shift_down, clr; /* dimensions in the calculation */
scaled delta1, delta2;
halfword sub_n, sup_n;
internal_font_number sub_f, sup_f;
@@ -2818,14 +3163,15 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style)
printf("p: node %d, type=%d, subtype=%d\n", p, type(p), subtype(p));
#endif
switch (type(nucleus(q))) {
- case math_char_node:
- case math_text_char_node:
- if ((subscr(q) == null) && (delta1 != 0)) {
- x = new_kern(delta1);
- reset_attributes(x, node_attr(nucleus(q)));
- couple_nodes(p,x);
- delta1 = 0;
- }
+ case math_char_node:
+ case math_text_char_node:
+ if ((subscr(q) == null) && (delta1 != 0)) {
+ /* todo: selective */
+ x = new_kern(delta1); /* italic correction */
+ reset_attributes(x, node_attr(nucleus(q)));
+ couple_nodes(p,x);
+ delta1 = 0;
+ }
}
assign_new_hlist(q, p);
if (is_char_node(p)) {
@@ -2833,8 +3179,8 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style)
shift_down = 0;
} else {
z = hpack(p, 0, additional, -1);
- shift_up = height(z) - sup_shift_drop(cur_style); /* r18 */
- shift_down = depth(z) + sub_shift_drop(cur_style); /* r19 */
+ shift_up = height(z) - sup_shift_drop(cur_style); /* r18 */
+ shift_down = depth(z) + sub_shift_drop(cur_style); /* r19 */
list_ptr(z) = null;
flush_node(z);
}
@@ -2847,103 +3193,194 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style)
}
if (supscr(q) == null) {
+ /*
+ construct a subscript box |x| when there is no superscript
- /* Construct a subscript box |x| when there is no superscript */
- /* When there is a subscript without a superscript, the top of the subscript
- should not exceed the baseline plus four-fifths of the x-height. */
+ when there is a subscript without a superscript, the top of the subscript
+ should not exceed the baseline plus four-fifths of the x-height.
+ */
x = clean_box(subscr(q), sub_style(cur_style), cur_style);
width(x) = width(x) + space_after_script(cur_style);
- if (shift_down < sub_shift_down(cur_style))
- shift_down = sub_shift_down(cur_style);
- clr = height(x) - sub_top_max(cur_style);
- if (shift_down < clr)
- shift_down = clr;
+ switch (scripts_mode) {
+ case 1:
+ shift_down = sub_shift_down(cur_style) ;
+ break;
+ case 2:
+ shift_down = sub_sup_shift_down(cur_style) ;
+ break;
+ case 3:
+ shift_down = sub_sup_shift_down(cur_style) ;
+ break;
+ case 4:
+ shift_down = sub_shift_down(cur_style) + half(sub_sup_shift_down(cur_style)-sub_shift_down(cur_style)) ;
+ break;
+ case 5:
+ shift_down = sub_shift_down(cur_style) ;
+ break;
+ default:
+ if (shift_down < sub_shift_down(cur_style))
+ shift_down = sub_shift_down(cur_style);
+ clr = height(x) - sub_top_max(cur_style);
+ if (shift_down < clr)
+ shift_down = clr;
+ break;
+ }
shift_amount(x) = shift_down;
/* now find and correct for horizontal shift */
if (sub_n != null) {
delta2 = find_math_kern(font(p), character(p),sub_f,sub_c,sub_mark_cmd, shift_down);
- if (delta2 != MATH_KERN_NOT_FOUND && delta2 != 0) {
- p = attach_hkern_to_new_hlist(q, delta2);
+ if (delta2 == MATH_KERN_NOT_FOUND) {
+ delta2 = subshift ;
+ } else {
+ delta2 = delta2 + subshift ;
}
+ } else {
+ delta2 = subshift ;
+ }
+ if (delta2 != 0) {
+ p = attach_hkern_to_new_hlist(q, delta2);
}
} else {
- /* Construct a superscript box |x| */
- /*The bottom of a superscript should never descend below the baseline plus
- one-fourth of the x-height. */
+ /*
+ construct a superscript box |x|
+
+ the bottom of a superscript should never descend below the baseline plus
+ one-fourth of the x-height.
+ */
x = clean_box(supscr(q), sup_style(cur_style), cur_style);
width(x) = width(x) + space_after_script(cur_style);
- clr = sup_shift_up(cur_style);
- if (shift_up < clr)
- shift_up = clr;
- clr = depth(x) + sup_bottom_min(cur_style);
- if (shift_up < clr)
- shift_up = clr;
-
+ switch (scripts_mode) {
+ case 1:
+ shift_up = sup_shift_up(cur_style);
+ break;
+ case 2:
+ shift_up = sup_shift_up(cur_style) ;
+ break;
+ case 3:
+ shift_up = sup_shift_up(cur_style) + sub_sup_shift_down(cur_style) - sub_shift_down(cur_style) ;
+ break;
+ case 4:
+ shift_up = sup_shift_up(cur_style) + half(sub_sup_shift_down(cur_style)-sub_shift_down(cur_style)) ;
+ break;
+ case 5:
+ shift_up = sup_shift_up(cur_style) + sub_sup_shift_down(cur_style)-sub_shift_down(cur_style) ;
+ break;
+ default:
+ clr = sup_shift_up(cur_style);
+ if (shift_up < clr)
+ shift_up = clr;
+ clr = depth(x) + sup_bottom_min(cur_style);
+ if (shift_up < clr)
+ shift_up = clr;
+ break;
+ }
if (subscr(q) == null) {
shift_amount(x) = -shift_up;
/* now find and correct for horizontal shift */
if (sup_n != null) {
clr = find_math_kern(font(p),character(p),sup_f,sup_c,sup_mark_cmd,shift_up);
- if (clr != MATH_KERN_NOT_FOUND && clr != 0) {
- p = attach_hkern_to_new_hlist(q, clr);
+ if (clr == MATH_KERN_NOT_FOUND) {
+ clr = supshift ;
+ } else {
+ clr = clr + supshift ;
}
+ } else {
+ clr = supshift;
+ }
+ if (clr != 0) {
+ p = attach_hkern_to_new_hlist(q, clr);
}
} else {
- /* Construct a sub/superscript combination box |x|, with the
- superscript offset by |delta| */
- /* When both subscript and superscript are present, the subscript must be
- separated from the superscript by at least four times |default_rule_thickness|.
- If this condition would be violated, the subscript moves down, after which
- both subscript and superscript move up so that the bottom of the superscript
- is at least as high as the baseline plus four-fifths of the x-height. */
+ /*
+ construct a sub/superscript combination box |x|, with the superscript offset
+ by |delta|
+
+ when both subscript and superscript are present, the subscript must be
+ separated from the superscript by at least four times |default_rule_thickness|
+ if this condition would be violated, the subscript moves down, after which
+ both subscript and superscript move up so that the bottom of the superscript
+ is at least as high as the baseline plus four-fifths of the x-height
+ */
y = clean_box(subscr(q), sub_style(cur_style), cur_style);
width(y) = width(y) + space_after_script(cur_style);
- if (shift_down < sub_sup_shift_down(cur_style))
- shift_down = sub_sup_shift_down(cur_style);
- clr = subsup_vgap(cur_style) - ((shift_up - depth(x)) - (height(y) - shift_down));
- if (clr > 0) {
- shift_down = shift_down + clr;
- clr = sup_sub_bottom_max(cur_style) - (shift_up - depth(x));
- if (clr > 0) {
- shift_up = shift_up + clr;
- shift_down = shift_down - clr;
- }
+ switch (scripts_mode) {
+ case 1:
+ shift_down = sub_shift_down(cur_style) ;
+ break;
+ case 2:
+ shift_down = sub_sup_shift_down(cur_style) ;
+ break;
+ case 3:
+ shift_down = sub_sup_shift_down(cur_style) ;
+ break;
+ case 4:
+ shift_down = sub_shift_down(cur_style) + half(sub_sup_shift_down(cur_style)-sub_shift_down(cur_style)) ;
+ break;
+ case 5:
+ shift_down = sub_shift_down(cur_style) ;
+ break;
+ default:
+ if (shift_down < sub_sup_shift_down(cur_style))
+ shift_down = sub_sup_shift_down(cur_style);
+ clr = subsup_vgap(cur_style) - ((shift_up - depth(x)) - (height(y) - shift_down));
+ if (clr > 0) {
+ shift_down = shift_down + clr;
+ clr = sup_sub_bottom_max(cur_style) - (shift_up - depth(x));
+ if (clr > 0) {
+ shift_up = shift_up + clr;
+ shift_down = shift_down - clr;
+ }
+ }
+ break;
}
/* now find and correct for horizontal shift */
if (sub_n != null) {
delta2 = find_math_kern(font(p), character(p),sub_f,sub_c,sub_mark_cmd, shift_down);
- if (delta2 != MATH_KERN_NOT_FOUND && delta2 != 0) {
- p = attach_hkern_to_new_hlist(q, delta2);
+ if (delta2 == MATH_KERN_NOT_FOUND) {
+ delta2 = subshift ;
+ } else {
+ delta2 = delta2 + subshift ;
}
+ } else {
+ delta2 = subshift ;
+ }
+ if (delta2 != 0) {
+ p = attach_hkern_to_new_hlist(q, delta2);
}
- /* now the horizontal shift for the superscript. */
- /* the superscript is also to be shifted by |delta1| (the italic correction) */
+ /*
+ now the horizontal shift for the superscript; the superscript is also to be shifted
+ by |delta1| (the italic correction)
+ */
clr = MATH_KERN_NOT_FOUND;
if (sup_n != null) {
clr = find_math_kern(font(p),character(p),sup_f,sup_c,sup_mark_cmd,shift_up);
}
+ /* delta can already have been applied and now be 0 */
if (delta2 == MATH_KERN_NOT_FOUND)
- delta2 = 0;
+ delta2 = - supshift ;
+ else
+ delta2 = delta2 - supshift ;
if (clr != MATH_KERN_NOT_FOUND) {
shift_amount(x) = clr + delta1 - delta2;
} else {
shift_amount(x) = delta1 - delta2;
}
+ /* todo: only if kern != 0 */
p = new_kern((shift_up - depth(x)) - (height(y) - shift_down));
reset_attributes(p, node_attr(q));
couple_nodes(x,p);
couple_nodes(p,y);
+ /* we end up with funny dimensions */
x = vpackage(x, 0, additional, max_dimen, math_direction);
reset_attributes(x, node_attr(q));
shift_amount(x) = shift_down;
}
}
-
if (new_hlist(q) == null) {
new_hlist(q) = x;
} else {
@@ -2962,7 +3399,6 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style)
flush_node(supscr(q));
supscr(q) = null;
}
-
}
@ The |make_left_right| function constructs a left or right delimiter of
@@ -2971,27 +3407,86 @@ the required size and returns the value |open_noad| or |close_noad|. The
so they will have consistent sizes.
@c
-static small_number make_left_right(pointer q, int style, scaled max_d,
- scaled max_hv)
+static small_number make_left_right(pointer q, int style, scaled max_d, scaled max_h)
{
- scaled delta, delta1, delta2; /* dimensions used in the calculation */
- pointer tmp;
+ scaled delta;
+ pointer tmp, lst;
+ scaled hd_asked = 0;
+ scaled ic = 0;
+ boolean stack = false;
+ boolean axis = false;
+ /*
+ scaled hd_done = 0;
+ boolean fitting = true;
+ boolean fence = false;
+ int chr = 0;
+ int cls = 0;
+ */
setup_cur_size(style);
- delta2 = max_d + math_axis(cur_size);
- delta1 = max_hv + max_d - delta2;
- if (delta2 > delta1)
- delta1 = delta2; /* |delta1| is max distance from axis */
- delta = (delta1 / 500) * delimiter_factor;
- delta2 = delta1 + delta1 - delimiter_shortfall;
- if (delta < delta2)
- delta = delta2;
- tmp = var_delimiter(delimiter(q), cur_size, delta, NULL, style);
+
+ if ((delimiterheight(q)!=0) || (delimiterdepth(q)!=0)) {
+
+ hd_asked = delimiterheight(q) + delimiterdepth(q);
+ tmp = do_delimiter(q, delimiter(q), cur_size, hd_asked, false, style, false, &stack, &ic);
+ delimiteritalic(q) = ic;
+
+ /* beware, a stacked delimiter has a shift but no corrected height/depth (yet) */
+
+ if (stack) {
+ shift_amount(tmp) = delimiterdepth(q);
+ }
+
+ /*
+ hd_done = height(tmp) + depth(tmp);
+ fitting = stack || ((hd_done-hd_asked) == 0);
+
+ if (type(delimiter(q)) == delim_node && (small_char(delimiter(q)) != 0)) {
+ chr = small_char(delimiter(q));
+ cls = get_math_code(chr).class_value ;
+ fence = (cls == 4) || (cls == 5) ;
+ }
+
+ printf("delimiter stack %i fence %i fitting %i\n",stack,fence,fitting);
+ */
+
+ if (delimiterexact(q)) {
+ delimiterheight(q) = height(tmp) - shift_amount(tmp);
+ delimiterdepth(q) = depth(tmp) + shift_amount(tmp);
+ }
+ if (delimiteraxis(q)) {
+ delimiterheight(q) += math_axis(cur_size);
+ delimiterdepth(q) -= math_axis(cur_size);
+ shift_amount(tmp) -= math_axis(cur_size);
+ }
+ lst = new_node(hlist_node,0);
+ reset_attributes(lst, node_attr(q));
+ box_dir(lst) = dir_TLT ;
+ height(lst) = delimiterheight(q);
+ depth(lst) = delimiterdepth(q);
+ width(lst) = width(tmp);
+ list_ptr(lst) = tmp;
+ tmp = lst ;
+ } else {
+ axis = ! delimiternoaxis(q);
+ delta = get_delimiter_height(max_d,max_h,axis);
+ tmp = do_delimiter(q, delimiter(q), cur_size, delta, false, style, axis, &stack, &ic);
+ delimiteritalic(q) = ic;
+ }
delimiter(q) = null;
assign_new_hlist(q, tmp);
- if (subtype(q) == left_noad_side)
+ if (delimiterclass(q) >= ord_noad_type) {
+ if (delimiterclass(q) <= inner_noad_type) {
+ return delimiterclass(q);
+ } else {
+ return ord_noad_type;
+ }
+ } else if (subtype(q) == no_noad_side) {
return open_noad_type;
- else
+ } else if (subtype(q) == left_noad_side) {
+ return open_noad_type;
+ } else {
return close_noad_type;
+ }
}
@ @c
@@ -3097,7 +3592,6 @@ void initialize_math_spacing(void)
/* *INDENT-ON* */
}
-
@ @c
#define both_types(A,B) ((A)*16+(B))
@@ -3111,82 +3605,82 @@ static pointer math_spacing_glue(int l_type, int r_type, int mstyle, scaled mmu)
r_type = op_noad_type_normal;
switch (both_types(l_type, r_type)) {
/* *INDENT-OFF* */
- case both_types(ord_noad_type, ord_noad_type ): x = get_math_param(math_param_ord_ord_spacing,mstyle); break;
- case both_types(ord_noad_type, op_noad_type_normal ): x = get_math_param(math_param_ord_op_spacing,mstyle); break;
- case both_types(ord_noad_type, bin_noad_type ): x = get_math_param(math_param_ord_bin_spacing,mstyle); break;
- case both_types(ord_noad_type, rel_noad_type ): x = get_math_param(math_param_ord_rel_spacing,mstyle); break;
- case both_types(ord_noad_type, open_noad_type ): x = get_math_param(math_param_ord_open_spacing,mstyle); break;
- case both_types(ord_noad_type, close_noad_type): x = get_math_param(math_param_ord_close_spacing,mstyle); break;
- case both_types(ord_noad_type, punct_noad_type): x = get_math_param(math_param_ord_punct_spacing,mstyle); break;
- case both_types(ord_noad_type, inner_noad_type): x = get_math_param(math_param_ord_inner_spacing,mstyle); break;
- case both_types(op_noad_type_normal, ord_noad_type ): x = get_math_param(math_param_op_ord_spacing,mstyle); break;
- case both_types(op_noad_type_normal, op_noad_type_normal ): x = get_math_param(math_param_op_op_spacing,mstyle); break;
+ case both_types(ord_noad_type, ord_noad_type ): x = get_math_param(math_param_ord_ord_spacing,mstyle); break;
+ case both_types(ord_noad_type, op_noad_type_normal): x = get_math_param(math_param_ord_op_spacing,mstyle); break;
+ case both_types(ord_noad_type, bin_noad_type ): x = get_math_param(math_param_ord_bin_spacing,mstyle); break;
+ case both_types(ord_noad_type, rel_noad_type ): x = get_math_param(math_param_ord_rel_spacing,mstyle); break;
+ case both_types(ord_noad_type, open_noad_type ): x = get_math_param(math_param_ord_open_spacing,mstyle); break;
+ case both_types(ord_noad_type, close_noad_type ): x = get_math_param(math_param_ord_close_spacing,mstyle); break;
+ case both_types(ord_noad_type, punct_noad_type ): x = get_math_param(math_param_ord_punct_spacing,mstyle); break;
+ case both_types(ord_noad_type, inner_noad_type ): x = get_math_param(math_param_ord_inner_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, ord_noad_type ): x = get_math_param(math_param_op_ord_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, op_noad_type_normal): x = get_math_param(math_param_op_op_spacing,mstyle); break;
#if 0
- case both_types(op_noad_type_normal, bin_noad_type ): x = get_math_param(math_param_op_bin_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, bin_noad_type ): x = get_math_param(math_param_op_bin_spacing,mstyle); break;
#endif
- case both_types(op_noad_type_normal, rel_noad_type ): x = get_math_param(math_param_op_rel_spacing,mstyle); break;
- case both_types(op_noad_type_normal, open_noad_type ): x = get_math_param(math_param_op_open_spacing,mstyle); break;
- case both_types(op_noad_type_normal, close_noad_type): x = get_math_param(math_param_op_close_spacing,mstyle); break;
- case both_types(op_noad_type_normal, punct_noad_type): x = get_math_param(math_param_op_punct_spacing,mstyle); break;
- case both_types(op_noad_type_normal, inner_noad_type): x = get_math_param(math_param_op_inner_spacing,mstyle); break;
- case both_types(bin_noad_type, ord_noad_type ): x = get_math_param(math_param_bin_ord_spacing,mstyle); break;
- case both_types(bin_noad_type, op_noad_type_normal ): x = get_math_param(math_param_bin_op_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, rel_noad_type ): x = get_math_param(math_param_op_rel_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, open_noad_type ): x = get_math_param(math_param_op_open_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, close_noad_type ): x = get_math_param(math_param_op_close_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, punct_noad_type ): x = get_math_param(math_param_op_punct_spacing,mstyle); break;
+ case both_types(op_noad_type_normal, inner_noad_type ): x = get_math_param(math_param_op_inner_spacing,mstyle); break;
+ case both_types(bin_noad_type, ord_noad_type ): x = get_math_param(math_param_bin_ord_spacing,mstyle); break;
+ case both_types(bin_noad_type, op_noad_type_normal): x = get_math_param(math_param_bin_op_spacing,mstyle); break;
#if 0
- case both_types(bin_noad_type, bin_noad_type ): x = get_math_param(math_param_bin_bin_spacing,mstyle); break;
- case both_types(bin_noad_type, rel_noad_type ): x = get_math_param(math_param_bin_rel_spacing,mstyle); break;
+ case both_types(bin_noad_type, bin_noad_type ): x = get_math_param(math_param_bin_bin_spacing,mstyle); break;
+ case both_types(bin_noad_type, rel_noad_type ): x = get_math_param(math_param_bin_rel_spacing,mstyle); break;
#endif
- case both_types(bin_noad_type, open_noad_type ): x = get_math_param(math_param_bin_open_spacing,mstyle); break;
+ case both_types(bin_noad_type, open_noad_type ): x = get_math_param(math_param_bin_open_spacing,mstyle); break;
#if 0
- case both_types(bin_noad_type, close_noad_type): x = get_math_param(math_param_bin_close_spacing,mstyle); break;
- case both_types(bin_noad_type, punct_noad_type): x = get_math_param(math_param_bin_punct_spacing,mstyle); break;
+ case both_types(bin_noad_type, close_noad_type ): x = get_math_param(math_param_bin_close_spacing,mstyle); break;
+ case both_types(bin_noad_type, punct_noad_type ): x = get_math_param(math_param_bin_punct_spacing,mstyle); break;
#endif
- case both_types(bin_noad_type, inner_noad_type): x = get_math_param(math_param_bin_inner_spacing,mstyle); break;
- case both_types(rel_noad_type, ord_noad_type ): x = get_math_param(math_param_rel_ord_spacing,mstyle); break;
- case both_types(rel_noad_type, op_noad_type_normal ): x = get_math_param(math_param_rel_op_spacing,mstyle); break;
+ case both_types(bin_noad_type, inner_noad_type ): x = get_math_param(math_param_bin_inner_spacing,mstyle); break;
+ case both_types(rel_noad_type, ord_noad_type ): x = get_math_param(math_param_rel_ord_spacing,mstyle); break;
+ case both_types(rel_noad_type, op_noad_type_normal): x = get_math_param(math_param_rel_op_spacing,mstyle); break;
#if 0
- case both_types(rel_noad_type, bin_noad_type ): x = get_math_param(math_param_rel_bin_spacing,mstyle); break;
+ case both_types(rel_noad_type, bin_noad_type ): x = get_math_param(math_param_rel_bin_spacing,mstyle); break;
#endif
- case both_types(rel_noad_type, rel_noad_type ): x = get_math_param(math_param_rel_rel_spacing,mstyle); break;
- case both_types(rel_noad_type, open_noad_type ): x = get_math_param(math_param_rel_open_spacing,mstyle); break;
- case both_types(rel_noad_type, close_noad_type): x = get_math_param(math_param_rel_close_spacing,mstyle); break;
- case both_types(rel_noad_type, punct_noad_type): x = get_math_param(math_param_rel_punct_spacing,mstyle); break;
- case both_types(rel_noad_type, inner_noad_type): x = get_math_param(math_param_rel_inner_spacing,mstyle); break;
- case both_types(open_noad_type, ord_noad_type ): x = get_math_param(math_param_open_ord_spacing,mstyle); break;
- case both_types(open_noad_type, op_noad_type_normal ): x = get_math_param(math_param_open_op_spacing,mstyle); break;
+ case both_types(rel_noad_type, rel_noad_type ): x = get_math_param(math_param_rel_rel_spacing,mstyle); break;
+ case both_types(rel_noad_type, open_noad_type ): x = get_math_param(math_param_rel_open_spacing,mstyle); break;
+ case both_types(rel_noad_type, close_noad_type ): x = get_math_param(math_param_rel_close_spacing,mstyle); break;
+ case both_types(rel_noad_type, punct_noad_type ): x = get_math_param(math_param_rel_punct_spacing,mstyle); break;
+ case both_types(rel_noad_type, inner_noad_type ): x = get_math_param(math_param_rel_inner_spacing,mstyle); break;
+ case both_types(open_noad_type, ord_noad_type ): x = get_math_param(math_param_open_ord_spacing,mstyle); break;
+ case both_types(open_noad_type, op_noad_type_normal): x = get_math_param(math_param_open_op_spacing,mstyle); break;
#if 0
- case both_types(open_noad_type, bin_noad_type ): x = get_math_param(math_param_open_bin_spacing,mstyle); break;
+ case both_types(open_noad_type, bin_noad_type ): x = get_math_param(math_param_open_bin_spacing,mstyle); break;
#endif
- case both_types(open_noad_type, rel_noad_type ): x = get_math_param(math_param_open_rel_spacing,mstyle); break;
- case both_types(open_noad_type, open_noad_type ): x = get_math_param(math_param_open_open_spacing,mstyle); break;
- case both_types(open_noad_type, close_noad_type): x = get_math_param(math_param_open_close_spacing,mstyle); break;
- case both_types(open_noad_type, punct_noad_type): x = get_math_param(math_param_open_punct_spacing,mstyle); break;
- case both_types(open_noad_type, inner_noad_type): x = get_math_param(math_param_open_inner_spacing,mstyle); break;
- case both_types(close_noad_type,ord_noad_type ): x = get_math_param(math_param_close_ord_spacing,mstyle); break;
- case both_types(close_noad_type,op_noad_type_normal ): x = get_math_param(math_param_close_op_spacing,mstyle); break;
- case both_types(close_noad_type,bin_noad_type ): x = get_math_param(math_param_close_bin_spacing,mstyle); break;
- case both_types(close_noad_type,rel_noad_type ): x = get_math_param(math_param_close_rel_spacing,mstyle); break;
- case both_types(close_noad_type,open_noad_type ): x = get_math_param(math_param_close_open_spacing,mstyle); break;
- case both_types(close_noad_type,close_noad_type): x = get_math_param(math_param_close_close_spacing,mstyle); break;
- case both_types(close_noad_type,punct_noad_type): x = get_math_param(math_param_close_punct_spacing,mstyle); break;
- case both_types(close_noad_type,inner_noad_type): x = get_math_param(math_param_close_inner_spacing,mstyle); break;
- case both_types(punct_noad_type,ord_noad_type ): x = get_math_param(math_param_punct_ord_spacing,mstyle); break;
- case both_types(punct_noad_type,op_noad_type_normal ): x = get_math_param(math_param_punct_op_spacing,mstyle); break;
+ case both_types(open_noad_type, rel_noad_type ): x = get_math_param(math_param_open_rel_spacing,mstyle); break;
+ case both_types(open_noad_type, open_noad_type ): x = get_math_param(math_param_open_open_spacing,mstyle); break;
+ case both_types(open_noad_type, close_noad_type ): x = get_math_param(math_param_open_close_spacing,mstyle); break;
+ case both_types(open_noad_type, punct_noad_type ): x = get_math_param(math_param_open_punct_spacing,mstyle); break;
+ case both_types(open_noad_type, inner_noad_type ): x = get_math_param(math_param_open_inner_spacing,mstyle); break;
+ case both_types(close_noad_type, ord_noad_type ): x = get_math_param(math_param_close_ord_spacing,mstyle); break;
+ case both_types(close_noad_type, op_noad_type_normal): x = get_math_param(math_param_close_op_spacing,mstyle); break;
+ case both_types(close_noad_type, bin_noad_type ): x = get_math_param(math_param_close_bin_spacing,mstyle); break;
+ case both_types(close_noad_type, rel_noad_type ): x = get_math_param(math_param_close_rel_spacing,mstyle); break;
+ case both_types(close_noad_type, open_noad_type ): x = get_math_param(math_param_close_open_spacing,mstyle); break;
+ case both_types(close_noad_type, close_noad_type ): x = get_math_param(math_param_close_close_spacing,mstyle); break;
+ case both_types(close_noad_type, punct_noad_type ): x = get_math_param(math_param_close_punct_spacing,mstyle); break;
+ case both_types(close_noad_type, inner_noad_type ): x = get_math_param(math_param_close_inner_spacing,mstyle); break;
+ case both_types(punct_noad_type, ord_noad_type ): x = get_math_param(math_param_punct_ord_spacing,mstyle); break;
+ case both_types(punct_noad_type, op_noad_type_normal): x = get_math_param(math_param_punct_op_spacing,mstyle); break;
#if 0
- case both_types(punct_noad_type,bin_noad_type ): x = get_math_param(math_param_punct_bin_spacing,mstyle); break;
+ case both_types(punct_noad_type, bin_noad_type ): x = get_math_param(math_param_punct_bin_spacing,mstyle); break;
#endif
- case both_types(punct_noad_type,rel_noad_type ): x = get_math_param(math_param_punct_rel_spacing,mstyle); break;
- case both_types(punct_noad_type,open_noad_type ): x = get_math_param(math_param_punct_open_spacing,mstyle); break;
- case both_types(punct_noad_type,close_noad_type): x = get_math_param(math_param_punct_close_spacing,mstyle); break;
- case both_types(punct_noad_type,punct_noad_type): x = get_math_param(math_param_punct_punct_spacing,mstyle); break;
- case both_types(punct_noad_type,inner_noad_type): x = get_math_param(math_param_punct_inner_spacing,mstyle); break;
- case both_types(inner_noad_type,ord_noad_type ): x = get_math_param(math_param_inner_ord_spacing,mstyle); break;
- case both_types(inner_noad_type,op_noad_type_normal ): x = get_math_param(math_param_inner_op_spacing,mstyle); break;
- case both_types(inner_noad_type,bin_noad_type ): x = get_math_param(math_param_inner_bin_spacing,mstyle); break;
- case both_types(inner_noad_type,rel_noad_type ): x = get_math_param(math_param_inner_rel_spacing,mstyle); break;
- case both_types(inner_noad_type,open_noad_type ): x = get_math_param(math_param_inner_open_spacing,mstyle); break;
- case both_types(inner_noad_type,close_noad_type): x = get_math_param(math_param_inner_close_spacing,mstyle); break;
- case both_types(inner_noad_type,punct_noad_type): x = get_math_param(math_param_inner_punct_spacing,mstyle); break;
- case both_types(inner_noad_type,inner_noad_type): x = get_math_param(math_param_inner_inner_spacing,mstyle); break;
+ case both_types(punct_noad_type, rel_noad_type ): x = get_math_param(math_param_punct_rel_spacing,mstyle); break;
+ case both_types(punct_noad_type, open_noad_type ): x = get_math_param(math_param_punct_open_spacing,mstyle); break;
+ case both_types(punct_noad_type, close_noad_type ): x = get_math_param(math_param_punct_close_spacing,mstyle); break;
+ case both_types(punct_noad_type, punct_noad_type ): x = get_math_param(math_param_punct_punct_spacing,mstyle); break;
+ case both_types(punct_noad_type, inner_noad_type ): x = get_math_param(math_param_punct_inner_spacing,mstyle); break;
+ case both_types(inner_noad_type, ord_noad_type ): x = get_math_param(math_param_inner_ord_spacing,mstyle); break;
+ case both_types(inner_noad_type, op_noad_type_normal): x = get_math_param(math_param_inner_op_spacing,mstyle); break;
+ case both_types(inner_noad_type, bin_noad_type ): x = get_math_param(math_param_inner_bin_spacing,mstyle); break;
+ case both_types(inner_noad_type, rel_noad_type ): x = get_math_param(math_param_inner_rel_spacing,mstyle); break;
+ case both_types(inner_noad_type, open_noad_type ): x = get_math_param(math_param_inner_open_spacing,mstyle); break;
+ case both_types(inner_noad_type, close_noad_type ): x = get_math_param(math_param_inner_close_spacing,mstyle); break;
+ case both_types(inner_noad_type, punct_noad_type ): x = get_math_param(math_param_inner_punct_spacing,mstyle); break;
+ case both_types(inner_noad_type, inner_noad_type ): x = get_math_param(math_param_inner_inner_spacing,mstyle); break;
/* *INDENT-ON* */
}
if (x < 0) {
@@ -3194,11 +3688,13 @@ static pointer math_spacing_glue(int l_type, int r_type, int mstyle, scaled mmu)
}
if (x != 0) {
pointer y;
- if (x <= thick_mu_skip_code) { /* trap thin/med/thick settings cf. old TeX */
+ 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);
glue_ref_count(y) = null;
- subtype(z) = (quarterword) (x + 1); /* store a symbolic subtype */
+ /* store a symbolic subtype */
+ subtype(z) = (quarterword) (x + 1);
} else {
y = math_glue(x, mmu);
z = new_glue(y);
@@ -3209,8 +3705,7 @@ static pointer math_spacing_glue(int l_type, int r_type, int mstyle, scaled mmu)
}
@ @c
-static pointer check_nucleus_complexity(halfword q, scaled * delta,
- int cur_style)
+static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style)
{
pointer p = null;
switch (type(nucleus(q))) {
@@ -3218,19 +3713,37 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta,
case math_text_char_node:
fetch(nucleus(q));
if (char_exists(cur_f, cur_c)) {
- *delta = char_italic(cur_f, cur_c);
+ /* we could look at neighbours */
+ if (is_new_mathfont(cur_f)) {
+ *delta = 0 ; /* cf spec only the last one */
+ } else {
+ *delta = char_italic(cur_f, cur_c);
+ }
p = new_glyph(cur_f, cur_c);
reset_attributes(p, node_attr(nucleus(q)));
- if ((is_new_mathfont(cur_f) && get_char_cat_code(cur_c) == 11) ||
- (!is_new_mathfont(cur_f) && type(nucleus(q)) == math_text_char_node && space(cur_f)) != 0) {
- *delta = 0; /* no italic correction in mid-word of text font */
- }
+ if (is_new_mathfont(cur_f)) {
+ if (! math_no_char_italic) {
+ /* keep italic, but bad with two successive letters */
+ } else if (get_char_cat_code(cur_c) == 11) {
+ /* no italic correction in mid-word of text font */
+ *delta = 0;
+ }
+ } else {
+ /* no italic correction in mid-word of text font */
+ if (((type(nucleus(q))) == math_text_char_node) && (space(cur_f) != 0)) {
+ *delta = 0;
+ }
+ }
+ /* so we only add italic correction when we have no scripts */
if ((subscr(q) == null) && (supscr(q) == null) && (*delta != 0)) {
pointer x = new_kern(*delta);
reset_attributes(x, node_attr(nucleus(q)));
couple_nodes(p,x);
*delta = 0;
}
+ if (is_new_mathfont(cur_f)) {
+ *delta = char_italic(cur_f, cur_c); /* must be more selective */
+ }
}
break;
case sub_box_node:
@@ -3254,19 +3767,19 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta,
@c
static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
{
- pointer q; /* runs through the mlist */
- pointer r; /* the most recent noad preceding |q| */
+ pointer q; /* runs through the mlist */
+ pointer r; /* the most recent noad preceding |q| */
int style;
- int r_type; /* the |type| of noad |r|, or |op_noad| if |r=null| */
- int r_subtype; /* the |subtype| of noad |r| if |r_type| is |fence_noad| */
- int t; /* the effective |type| of noad |q| during the second pass */
- int t_subtype; /* the effective |subtype| of noad |q| during the second pass */
- pointer p, x, y, z; /* temporary registers for list construction */
- int pen; /* a penalty to be inserted */
- scaled max_hl, max_d; /* maximum height and depth of the list translated so far */
- scaled delta; /* italic correction offset for subscript and superscript */
- scaled cur_mu; /* the math unit width corresponding to |cur_size| */
- style = cur_style; /* tuck global parameter away as local variable */
+ int r_type; /* the |type| of noad |r|, or |op_noad| if |r=null| */
+ int r_subtype; /* the |subtype| of noad |r| if |r_type| is |fence_noad| */
+ int t; /* the effective |type| of noad |q| during the second pass */
+ int t_subtype; /* the effective |subtype| of noad |q| during the second pass */
+ pointer p, x, y, z; /* temporary registers for list construction */
+ int pen; /* a penalty to be inserted */
+ scaled max_hl, max_d; /* maximum height and depth of the list translated so far */
+ scaled delta; /* italic correction offset for subscript and superscript */
+ scaled cur_mu; /* the math unit width corresponding to |cur_size| */
+ style = cur_style; /* tuck global parameter away as local variable */
q = mlist;
r = null;
r_type = simple_noad;
@@ -3278,12 +3791,15 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
setup_cur_size(cur_style);
cur_mu = x_over_n(get_math_quad(cur_size), 18);
while (q != null) {
- /* We use the fact that no character nodes appear in an mlist, hence
- the field |type(q)| is always present. */
+ /*
+ we use the fact that no character nodes appear in an mlist, hence
+ the field |type(q)| is always present.
+
+ one of the things we must do on the first pass is change a |bin_noad| to
+ an |ord_noad| if the |bin_noad| is not in the context of a binary operator
- /* One of the things we must do on the first pass is change a |bin_noad| to
- an |ord_noad| if the |bin_noad| is not in the context of a binary operator.
- The values of |r| and |r_type| make this fairly easy. */
+ the values of |r| and |r_type| make this fairly easy
+ */
RESWITCH:
delta = 0;
switch (type(q)) {
@@ -3307,7 +3823,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
break;
case fence_noad:
if (r_subtype == left_noad_side) {
- subtype(q) = ord_noad_type;
+ subtype(q) = ord_noad_type; /* so these can best be the same size */
goto RESWITCH;
}
break;
@@ -3326,7 +3842,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case close_noad_type:
case punct_noad_type:
if (r_type == simple_noad && r_subtype == bin_noad_type) {
- type(r) = simple_noad;
+ type(r) = simple_noad; /* assumes the same size .. can't this go */
subtype(r) = ord_noad_type;
}
break;
@@ -3334,7 +3850,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case op_noad_type_limits:
case op_noad_type_no_limits:
delta = make_op(q, cur_style);
- if (subtype(q) == op_noad_type_limits)
+ if ((subtype(q) == op_noad_type_limits) || (subtype(q) == op_noad_type_no_limits))
goto CHECK_DIMENSIONS;
break;
case ord_noad_type:
@@ -3348,7 +3864,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case fence_noad:
if (subtype(q) != left_noad_side)
if (r_type == simple_noad && r_subtype == bin_noad_type) {
- type(r) = simple_noad;
+ type(r) = simple_noad; /* assumes the same size */
subtype(r) = ord_noad_type;
}
goto DONE_WITH_NOAD;
@@ -3358,7 +3874,9 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
goto CHECK_DIMENSIONS;
break;
case radical_noad:
- if (subtype(q) == 6)
+ if (subtype(q) == 7)
+ make_hextension(q, cur_style);
+ else if (subtype(q) == 6)
make_delimiter_over(q, cur_style);
else if (subtype(q) == 5)
make_delimiter_under(q, cur_style);
@@ -3375,26 +3893,24 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case style_node:
cur_style = subtype(q);
setup_cur_size(cur_style);
- /* HH-LS: was cur_mu = x_over_n(get_math_quad(cur_size), 18);*/
- /* This is an old bug so the fix can influence outcome */
cur_mu = x_over_n(get_math_quad(cur_style), 18);
goto DONE_WITH_NODE;
break;
case choice_node:
switch (cur_style / 2) {
- case 0:
+ case 0: /* |display_style=0| */
choose_mlist(display_mlist);
- break; /* |display_style=0| */
- case 1:
+ break;
+ case 1: /* |text_style=2| */
choose_mlist(text_mlist);
- break; /* |text_style=2| */
- case 2:
+ break;
+ case 2: /* |script_style=4| */
choose_mlist(script_mlist);
- break; /* |script_style=4| */
- case 3:
+ break;
+ case 3: /* |script_script_style=6| */
choose_mlist(script_script_mlist);
- break; /* |script_script_style=6| */
- } /* there are no other cases */
+ break;
+ }
flush_node_list(display_mlist(q));
flush_node_list(text_mlist(q));
flush_node_list(script_mlist(q));
@@ -3413,6 +3929,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case ins_node:
case mark_node:
case adjust_node:
+ case boundary_node:
case whatsit_node:
case penalty_node:
case disc_node:
@@ -3427,21 +3944,22 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
break;
case glue_node:
/*
- Conditional math glue (`\.{\\nonscript}') results in a |glue_node|
- pointing to |zero_glue|, with |subtype(q)=cond_math_glue|; in such a case
- the node following will be eliminated if it is a glue or kern node and if the
- current size is different from |text_size|. Unconditional math glue
- (`\.{\\muskip}') is converted to normal glue by multiplying the dimensions
- by |cur_mu|.
- */
+ conditional math glue (`\.{\\nonscript}') results in a |glue_node|
+ pointing to |zero_glue|, with |subtype(q)=cond_math_glue|; in such a case
+ the node following will be eliminated if it is a glue or kern node and if the
+ current size is different from |text_size|
+
+ unconditional math glue (`\.{\\muskip}') is converted to normal glue by
+ multiplying the dimensions by |cur_mu|
+
+ */
if (subtype(q) == mu_glue) {
x = glue_ptr(q);
y = math_glue(x, cur_mu);
delete_glue_ref(x);
glue_ptr(q) = y;
subtype(q) = normal;
- } else if ((cur_size != text_size)
- && (subtype(q) == cond_math_glue)) {
+ } 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)) {
@@ -3457,24 +3975,27 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
goto DONE_WITH_NODE;
break;
default:
- confusion("mlist1"); /* this can't happen mlist1 */
- }
- /* When we get to the following part of the program, we have ``fallen through''
- from cases that did not lead to |check_dimensions| or |done_with_noad| or
- |done_with_node|. Thus, |q|~points to a noad whose nucleus may need to be
- converted to an hlist, and whose subscripts and superscripts need to be
- appended if they are present.
-
- If |nucleus(q)| is not a |math_char|, the variable |delta| is the amount
- by which a superscript should be moved right with respect to a subscript
- when both are present.
- */
+ confusion("mlist1");
+ }
+ /*
+ When we get to the following part of the program, we have ``fallen through''
+ from cases that did not lead to |check_dimensions| or |done_with_noad| or
+ |done_with_node|. Thus, |q|~points to a noad whose nucleus may need to be
+ converted to an hlist, and whose subscripts and superscripts need to be
+ appended if they are present.
+
+ If |nucleus(q)| is not a |math_char|, the variable |delta| is the amount
+ by which a superscript should be moved right with respect to a subscript
+ when both are present.
+
+ */
p = check_nucleus_complexity(q, &delta, cur_style);
if ((subscr(q) == null) && (supscr(q) == null)) {
assign_new_hlist(q, p);
} else {
- make_scripts(q, p, delta, cur_style); /* top, bottom */
+ /* top, bottom */
+ make_scripts(q, p, delta, cur_style, 0, 0);
}
CHECK_DIMENSIONS:
z = hpack(new_hlist(q), 0, additional, -1);
@@ -3483,7 +4004,8 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
if (depth(z) > max_d)
max_d = depth(z);
list_ptr(z) = null;
- flush_node(z); /* only drop the \.{\\hbox} */
+ /* only drop the \.{\\hbox} */
+ flush_node(z);
DONE_WITH_NOAD:
r = q;
r_type = type(r);
@@ -3501,15 +4023,16 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
type(r) = simple_noad;
subtype(r) = ord_noad_type;
}
- /* Make a second pass over the mlist, removing all noads and inserting the
- proper spacing and penalties */
-
- /* We have now tied up all the loose ends of the first pass of |mlist_to_hlist|.
- The second pass simply goes through and hooks everything together with the
- proper glue and penalties. It also handles the |fence_noad|s that
- might be present, since |max_hl| and |max_d| are now known. Variable |p| points
- to a node at the current end of the final hlist.
- */
+ /*
+ Make a second pass over the mlist, removing all noads and inserting the
+ proper spacing and penalties.
+
+ We have now tied up all the loose ends of the first pass of |mlist_to_hlist|.
+ The second pass simply goes through and hooks everything together with the
+ proper glue and penalties. It also handles the |fence_noad|s that
+ might be present, since |max_hl| and |max_d| are now known. Variable |p| points
+ to a node at the current end of the final hlist.
+ */
p = temp_head;
vlink(p) = null;
q = mlist;
@@ -3520,13 +4043,16 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
cur_mu = x_over_n(get_math_quad(cur_size), 18);
NEXT_NODE:
while (q != null) {
- /* If node |q| is a style node, change the style and |goto delete_q|;
- otherwise if it is not a noad, put it into the hlist,
- advance |q|, and |goto done|; otherwise set |s| to the size
- of noad |q|, set |t| to the associated type (|ord_noad..
- inner_noad|), and set |pen| to the associated penalty */
- /* Just before doing the big |case| switch in the second pass, the program
- sets up default values so that most of the branches are short. */
+ /*
+ If node |q| is a style node, change the style and |goto delete_q|;
+ otherwise if it is not a noad, put it into the hlist,
+ advance |q|, and |goto done|; otherwise set |s| to the size
+ of noad |q|, set |t| to the associated type (|ord_noad..
+ inner_noad|), and set |pen| to the associated penalty
+
+ Just before doing the big |case| switch in the second pass, the program
+ sets up default values so that most of the branches are short.
+ */
t = simple_noad;
t_subtype = ord_noad_type;
pen = inf_penalty;
@@ -3580,10 +4106,11 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
goto NEXT_NODE;
break;
default:
- confusion("mlist3"); /* this can't happen mlist3 */
+ confusion("mlist3");
}
/* Append inter-element spacing based on |r_type| and |t| */
- if (r_type > 0) { /* not the first noad */
+ if (r_type > 0) {
+ /* not the first noad */
z = math_spacing_glue(r_subtype, t_subtype, cur_style, cur_mu);
if (z != null) {
reset_attributes(z, node_attr(p));
@@ -3591,12 +4118,13 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
p = z;
}
}
+ /*
+ Append any |new_hlist| entries for |q|, and any appropriate penalties
- /* Append any |new_hlist| entries for |q|, and any appropriate penalties */
- /* We insert a penalty node after the hlist entries of noad |q| if |pen|
- is not an ``infinite'' penalty, and if the node immediately following |q|
- is not a penalty node or a |rel_noad| or absent entirely. */
-
+ We insert a penalty node after the hlist entries of noad |q| if |pen|
+ is not an ``infinite'' penalty, and if the node immediately following |q|
+ is not a penalty node or a |rel_noad| or absent entirely.
+ */
if (new_hlist(q) != null) {
couple_nodes(p,new_hlist(q));
do {
@@ -3606,8 +4134,7 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
if (penalties && vlink(q) != null && pen < inf_penalty) {
r_type = type(vlink(q));
r_subtype = subtype(vlink(q));
- if (r_type != penalty_node
- && (r_type != simple_noad || r_subtype != rel_noad_type)) {
+ if (r_type != penalty_node && (r_type != simple_noad || r_subtype != rel_noad_type)) {
z = new_penalty(pen);
reset_attributes(z, node_attr(q));
couple_nodes(p,z);
@@ -3623,15 +4150,16 @@ static void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
DELETE_Q:
r = q;
q = vlink(q);
- /* The m-to-hlist conversion takes place in-place,
- so the various dependant fields may not be freed
- (as would happen if |flush_node| was called).
- A low-level |free_node| is easier than attempting
- to nullify such dependant fields for all possible
- node and noad types.
- */
+ /*
+ The m-to-hlist conversion takes place in-place, so the various dependant
+ fields may not be freed (as would happen if |flush_node| was called).
+
+ 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)))
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 b1e68e8f732..c431ed15396 100644
--- a/Build/source/texk/web2c/luatexdir/tex/packaging.h
+++ b/Build/source/texk/web2c/luatexdir/tex/packaging.h
@@ -1,5 +1,5 @@
/* packaging.h
-
+
Copyright 2009 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -58,7 +58,7 @@ extern halfword new_margin_kern(scaled w, halfword p, int side);
# define update_adjust_list(A) do { \
if (A == null) \
- pdf_error("pre vadjust", "adjust_tail or pre_adjust_tail is null"); \
+ normal_error("pre vadjust", "adjust_tail or pre_adjust_tail is null"); \
vlink(A) = adjust_ptr(p); \
while (vlink(A) != null) \
A = vlink(A); \
@@ -80,7 +80,7 @@ extern halfword filtered_vpackage(halfword p, scaled h, int m, scaled l,
int grp, int d);
extern void finish_vcenter(void);
extern void package(int c);
-extern void append_to_vlist(halfword b);
+extern void append_to_vlist(halfword b, int location);
extern halfword prune_page_top(halfword p, boolean s);
extern scaled active_height[10]; /* distance from first active node to~|cur_p| */
diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.w b/Build/source/texk/web2c/luatexdir/tex/packaging.w
index 731e7e1524a..173b7894cb2 100644
--- a/Build/source/texk/web2c/luatexdir/tex/packaging.w
+++ b/Build/source/texk/web2c/luatexdir/tex/packaging.w
@@ -1,4 +1,4 @@
-% packaging.w
+4% packaging.w
%
% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
%
@@ -220,7 +220,7 @@ halfword last_rightmost_char;
halfword next_char_p; /* pointer to the next char of an implicit kern */
halfword prev_char_p; /* pointer to the previous char of an implicit kern */
-@ This procedure is called repeatedly from inside the line break algorithm.
+@ This procedure is called repeatedly from inside the line break algorithm.
@c
void set_prev_char_p(halfword p)
{
@@ -337,7 +337,7 @@ void do_subst_font(halfword p, int ex_ratio)
if (is_char_node(p)) {
r = p;
} else {
- pdf_error("font expansion", "invalid node type");
+ normal_error("font expansion", "invalid node type");
return;
}
f = font(r);
@@ -387,7 +387,7 @@ halfword new_margin_kern(scaled w, halfword p, int side)
k = new_node(margin_kern_node, side);
width(k) = w;
if (p == null)
- pdf_error("margin kerning", "invalid pointer to marginal char node");
+ normal_error("margin kerning", "invalid pointer to marginal char node");
q = new_char(font(p), character(p));
margin_char(k) = q;
return k;
@@ -541,31 +541,26 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
p = q;
}
break;
- case whatsit_node:
- /* Incorporate a whatsit node into an hbox */
- if (subtype(p) == dir_node) {
- /* DIR: Adjust the dir stack for the |hpack| routine */
- if (dir_dir(p) >= 0) {
- hpack_dir = dir_dir(p);
- push_dir_node(p,dir_ptr1);
- } else {
- pop_dir_node(dir_ptr1);
- if (dir_ptr1 != null)
- hpack_dir = dir_dir(dir_ptr1);
- }
-
+ case dir_node:
+ /* DIR: Adjust the dir stack for the |hpack| routine */
+ if (dir_dir(p) >= 0) {
+ hpack_dir = dir_dir(p);
+ push_dir_node(p,dir_ptr1);
} else {
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node)) {
- x += width(p);
- s = 0;
- if (height(p) - s > h)
- h = height(p) - s;
- if (depth(p) + s > d)
- d = depth(p) + s;
- }
+ pop_dir_node(dir_ptr1);
+ if (dir_ptr1 != null)
+ hpack_dir = dir_dir(dir_ptr1);
}
break;
+ case math_node:
+ /* begin mathskip code */
+ if (glue_ptr(p) == zero_glue) {
+ x += surround(p);
+ break;
+ } else {
+ /* fall through: mathskip */
+ }
+ /* end mathskip code */
case glue_node:
/* Incorporate glue into the horizontal totals */
g = glue_ptr(p);
@@ -623,9 +618,6 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
}
x += width(p);
break;
- case math_node:
- x += surround(p);
- break;
case disc_node:
if (m == subst_ex_font)
do_subst_font(p, font_expand_ratio);
@@ -699,13 +691,30 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
is sufficiently bad */
last_badness = badness(x, total_stretch[normal]);
if (last_badness > int_par(hbadness_code)) {
- print_ln();
- if (last_badness > 100)
- tprint_nl("Underfull \\hbox (badness ");
- else
- tprint_nl("Loose \\hbox (badness ");
- print_int(last_badness);
- goto COMMON_ENDING;
+ int callback_id = callback_defined(hpack_quality_callback);
+ if (callback_id > 0) {
+ halfword rule = null;
+ if (last_badness > 100) {
+ run_callback(callback_id, "SdNdd->N","underfull",last_badness,r,abs(pack_begin_line),line,&rule);
+ } else {
+ run_callback(callback_id, "SdNdd->N","loose",last_badness,r,abs(pack_begin_line),line,&rule);
+ }
+ if (rule != null) {
+ while (vlink(q) != null) {
+ q = vlink(q);
+ }
+ couple_nodes(q,rule);
+ }
+ } else {
+ print_ln();
+ if (last_badness > 100) {
+ tprint_nl("Underfull \\hbox (badness ");
+ } else {
+ tprint_nl("Loose \\hbox (badness ");
+ }
+ print_int(last_badness);
+ goto COMMON_ENDING;
+ }
}
}
}
@@ -738,35 +747,56 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
set_glue_ratio_zero(glue_set(r)); /* there's nothing to shrink */
}
if ((total_shrink[o] < -x) && (o == normal) && (list_ptr(r) != null)) {
+ int overshoot = -x - total_shrink[normal] ;
last_badness = 1000000;
set_glue_ratio_one(glue_set(r)); /* use the maximum shrinkage */
/* Report an overfull hbox and |goto common_ending|, if this box
is sufficiently bad */
- if ((-x - total_shrink[normal] > dimen_par(hfuzz_code))
- || (int_par(hbadness_code) < 100)) {
- if ((dimen_par(overfull_rule_code) > 0)
- && (-x - total_shrink[normal] > dimen_par(hfuzz_code))) {
- while (vlink(q) != null)
+ if ((overshoot > dimen_par(hfuzz_code)) || (int_par(hbadness_code) < 100)) {
+ int callback_id = callback_defined(hpack_quality_callback);
+ halfword rule = null;
+ if (callback_id > 0) {
+ run_callback(callback_id, "SdNdd->N","overfull",overshoot,r,abs(pack_begin_line),line,&rule);
+ } else if (dimen_par(overfull_rule_code) > 0) {
+ rule = new_rule(normal_rule);
+ rule_dir(rule) = box_dir(r);
+ width(rule) = dimen_par(overfull_rule_code);
+ }
+ if (rule != null) {
+ while (vlink(q) != null) {
q = vlink(q);
- vlink(q) = new_rule();
- rule_dir(vlink(q)) = box_dir(r);
- width(vlink(q)) = dimen_par(overfull_rule_code);
+ }
+ couple_nodes(q,rule);
+ }
+ if (callback_id == 0) {
+ print_ln();
+ tprint_nl("Overfull \\hbox (");
+ print_scaled(overshoot);
+ tprint("pt too wide");
+ goto COMMON_ENDING;
}
- print_ln();
- tprint_nl("Overfull \\hbox (");
- print_scaled(-x - total_shrink[normal]);
- tprint("pt too wide");
- goto COMMON_ENDING;
}
} else if (o == normal) {
if (list_ptr(r) != null) {
/* Report a tight hbox and |goto common_ending|, if this box is sufficiently bad */
last_badness = badness(-x, total_shrink[normal]);
if (last_badness > int_par(hbadness_code)) {
- print_ln();
- tprint_nl("Tight \\hbox (badness ");
- print_int(last_badness);
- goto COMMON_ENDING;
+ int callback_id = callback_defined(hpack_quality_callback);
+ if (callback_id > 0) {
+ halfword rule = null;
+ run_callback(callback_id, "SdNdd->N","tight",last_badness,r,abs(pack_begin_line),line,&rule);
+ if (rule != null) {
+ while (vlink(q) != null) {
+ q = vlink(q);
+ }
+ couple_nodes(q,rule);
+ }
+ } else {
+ print_ln();
+ tprint_nl("Tight \\hbox (badness ");
+ print_int(last_badness);
+ goto COMMON_ENDING;
+ }
}
}
}
@@ -779,10 +809,11 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
tprint(") has occurred while \\output is active");
} else {
if (pack_begin_line != 0) {
- if (pack_begin_line > 0)
+ if (pack_begin_line > 0) {
tprint(") in paragraph at lines ");
- else
+ } else {
tprint(") in alignment at lines ");
+ }
print_int(abs(pack_begin_line));
tprint("--");
} else {
@@ -874,17 +905,15 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult,
if (depth(p) + s > siz.dp)
siz.dp = depth(p) + s;
break;
- case whatsit_node:
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node)) {
- siz.wd += width(p);
- s = 0;
- if (height(p) - s > siz.ht)
- siz.ht = height(p) - s;
- if (depth(p) + s > siz.dp)
- siz.dp = depth(p) + s;
+ case math_node:
+ /* begin mathskip code */
+ if (glue_ptr(p) == zero_glue) {
+ siz.wd += surround(p);
+ break;
+ } else {
+ /* fall through: mathskip */
}
- break;
+ /* end mathskip code */
case glue_node:
g = glue_ptr(p);
siz.wd += width(g);
@@ -913,9 +942,6 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult,
case kern_node:
siz.wd += width(p);
break;
- case math_node:
- siz.wd += surround(p);
- break;
case disc_node:
xx = natural_sizes(no_break(p), null, g_mult, g_sign, g_order,
hpack_dir);
@@ -1016,17 +1042,6 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
if (width(p) + s > w)
w = width(p) + s;
break;
- case whatsit_node:
- /* Incorporate a whatsit node into a vbox */
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node)) {
- x += d + height(p);
- d = depth(p);
- s = 0;
- if (width(p) + s > w)
- w = width(p) + s;
- }
- break;
case glue_node:
/* Incorporate glue into the vertical totals */
x += d;
@@ -1102,13 +1117,24 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
is sufficiently bad */
last_badness = badness(x, total_stretch[normal]);
if (last_badness > int_par(vbadness_code)) {
- print_ln();
- if (last_badness > 100)
- tprint_nl("Underfull \\vbox (badness ");
- else
- tprint_nl("Loose \\vbox (badness ");
- print_int(last_badness);
- goto COMMON_ENDING;
+ int callback_id = callback_defined(vpack_quality_callback);
+ if (callback_id > 0) {
+ if (last_badness > 100) {
+ run_callback(callback_id, "SdNdd->","underfull",last_badness,r,abs(pack_begin_line),line);
+ } else {
+ run_callback(callback_id, "SdNdd->","loose",last_badness,r,abs(pack_begin_line),line);
+ }
+ goto EXIT;
+ } else {
+ print_ln();
+ if (last_badness > 100) {
+ tprint_nl("Underfull \\vbox (badness ");
+ } else {
+ tprint_nl("Loose \\vbox (badness ");
+ }
+ print_int(last_badness);
+ goto COMMON_ENDING;
+ }
}
}
}
@@ -1138,26 +1164,38 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
set_glue_ratio_zero(glue_set(r)); /* there's nothing to shrink */
}
if ((total_shrink[o] < -x) && (o == normal) && (list_ptr(r) != null)) {
+ int overshoot = -x - total_shrink[normal];
last_badness = 1000000;
set_glue_ratio_one(glue_set(r)); /* use the maximum shrinkage */
/* Report an overfull vbox and |goto common_ending|, if this box is sufficiently bad */
- if ((-x - total_shrink[normal] > dimen_par(vfuzz_code))
- || (int_par(vbadness_code) < 100)) {
- print_ln();
- tprint_nl("Overfull \\vbox (");
- print_scaled(-x - total_shrink[normal]);
- tprint("pt too high");
- goto COMMON_ENDING;
+ if ((overshoot > dimen_par(vfuzz_code)) || (int_par(vbadness_code) < 100)) {
+ int callback_id = callback_defined(vpack_quality_callback);
+ if (callback_id > 0) {
+ run_callback(callback_id, "SdNdd->","overfull",overshoot,r,abs(pack_begin_line),line);
+ goto EXIT;
+ } else {
+ print_ln();
+ tprint_nl("Overfull \\vbox (");
+ print_scaled(-x - total_shrink[normal]);
+ tprint("pt too high");
+ goto COMMON_ENDING;
+ }
}
} else if (o == normal) {
if (list_ptr(r) != null) {
/* Report a tight vbox and |goto common_ending|, if this box is sufficiently bad */
last_badness = badness(-x, total_shrink[normal]);
if (last_badness > int_par(vbadness_code)) {
- print_ln();
- tprint_nl("Tight \\vbox (badness ");
- print_int(last_badness);
- goto COMMON_ENDING;
+ int callback_id = callback_defined(vpack_quality_callback);
+ if (callback_id > 0) {
+ run_callback(callback_id, "SdNdd->","tight",last_badness,r,abs(pack_begin_line),line);
+ goto EXIT;
+ } else {
+ print_ln();
+ tprint_nl("Tight \\vbox (badness ");
+ print_int(last_badness);
+ goto COMMON_ENDING;
+ }
}
}
}
@@ -1182,6 +1220,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
begin_diagnostic();
show_box(r);
end_diagnostic(true);
+ EXIT:
return r;
}
@@ -1226,7 +1265,7 @@ void package(int c)
cur_box = filtered_hpack(cur_list.head_field,
cur_list.tail_field, saved_value(1),
saved_level(1), grp, saved_level(2));
- subtype(cur_box) = HLIST_SUBTYPE_HBOX;
+ subtype(cur_box) = hbox_list;
} else {
cur_box = filtered_vpackage(vlink(cur_list.head_field),
saved_value(1), saved_level(1), d, grp,
@@ -1265,31 +1304,47 @@ void package(int c)
baselineskip calculation is handled by the |append_to_vlist| routine.
@c
-void append_to_vlist(halfword b)
+void append_to_vlist(halfword b, int location)
{
- scaled d; /* deficiency of space between baselines */
- halfword p; /* a new glue node */
- if (prev_depth > ignore_depth) {
- if ((type(b) == hlist_node) && is_mirrored(box_dir(b))) {
- d = width(glue_par(baseline_skip_code)) - prev_depth - depth(b);
- } else {
- d = width(glue_par(baseline_skip_code)) - prev_depth - height(b);
+ scaled d; /* deficiency of space between baselines */
+ halfword p; /* a new glue node */
+ boolean mirrored = (type(b) == hlist_node) && is_mirrored(box_dir(b)) ;
+ halfword result = null;
+ halfword next_depth = ignore_depth;
+ boolean prev_set = false ;
+ if (lua_appendtovlist_callback(b,location,prev_depth,mirrored,&result,&next_depth,&prev_set)) {
+ while (result != null) {
+ couple_nodes(cur_list.tail_field, result);
+ cur_list.tail_field = result;
+ result = vlink(result);
+ }
+ if (prev_set) {
+ prev_depth = next_depth;
}
- if (d < dimen_par(line_skip_limit_code)) {
- p = new_param_glue(line_skip_code);
+ } else {
+ if (prev_depth > ignore_depth) {
+ if (mirrored) {
+ d = width(glue_par(baseline_skip_code)) - prev_depth - depth(b);
+ } else {
+ d = width(glue_par(baseline_skip_code)) - prev_depth - height(b);
+ }
+ if (d < dimen_par(line_skip_limit_code)) {
+ p = new_param_glue(line_skip_code);
+ } else {
+ p = new_skip_param(baseline_skip_code);
+ width(temp_ptr) = d; /* |temp_ptr=glue_ptr(p)| */
+ }
+ couple_nodes(cur_list.tail_field, p);
+ cur_list.tail_field = p;
+ }
+ couple_nodes(cur_list.tail_field, b);
+ cur_list.tail_field = b;
+ if (mirrored) {
+ prev_depth = height(b);
} else {
- p = new_skip_param(baseline_skip_code);
- width(temp_ptr) = d; /* |temp_ptr=glue_ptr(p)| */
+ prev_depth = depth(b);
}
- couple_nodes(cur_list.tail_field, p);
- cur_list.tail_field = p;
}
- couple_nodes(cur_list.tail_field, b);
- cur_list.tail_field = b;
- if ((type(b) == hlist_node) && is_mirrored(box_dir(b)))
- prev_depth = height(b);
- else
- prev_depth = depth(b);
}
@@ -1344,6 +1399,7 @@ halfword prune_page_top(halfword p, boolean s)
width(temp_ptr) = 0;
p = null;
break;
+ case boundary_node:
case whatsit_node:
case mark_node:
case ins_node:
@@ -1444,13 +1500,8 @@ halfword vert_break(halfword p, scaled h, scaled d)
prev_dp = depth(p);
goto NOT_FOUND;
break;
+ case boundary_node:
case whatsit_node:
- /* Process whatsit |p| in |vert_break| loop, |goto not_found| */
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node)) {
- cur_height = cur_height + prev_dp + height(p);
- prev_dp = depth(p);
- }
goto NOT_FOUND;
break;
case glue_node:
diff --git a/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w b/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w
index 423164ef3d3..873eaf96856 100644
--- a/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w
+++ b/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w
@@ -156,12 +156,39 @@ void ext_post_line_break(int paragraph_dir,
list about to be justified. In the meanwhile |r| will point to the
node we will use to insert end-of-line stuff after. |q==null| means
we use the final position of |r| */
+
+ /* begin mathskip code */
+ if (temp_head != null) {
+ q = temp_head;
+ while(q != null) {
+ if (type(q) == math_node) {
+ surround(q) = 0 ;
+ if (glue_ptr(q) != zero_glue) {
+ delete_glue_ref(glue_ptr(q));
+ glue_ptr(q) = zero_glue;
+ }
+ break;
+ } else if ((type(q) == hlist_node) && (subtype(q) == indent_list)) {
+ /* go on */
+ } else if (is_char_node(q)) {
+ break;
+ } else if (non_discardable(q)) {
+ break;
+ } else if (type(q) == kern_node && subtype(q) != explicit) {
+ break;
+ }
+ q = vlink(q);
+ }
+ }
+ /* end mathskip code */
+
r = cur_break(cur_p);
q = null;
disc_break = false;
post_disc_break = false;
glue_break = false;
+
if (r == null) {
for (r = temp_head; vlink(r) != null; r = vlink(r));
if (r == final_par_glue) {
@@ -172,6 +199,14 @@ void ext_post_line_break(int paragraph_dir,
r = alink(r);
}
/* |r| refers to the node after which the dir nodes should be closed */
+ } else if (type(r) == math_node) {
+ surround(r) = 0;
+ /* begin mathskip code */
+ if (glue_ptr(r) != zero_glue) {
+ delete_glue_ref(glue_ptr(r));
+ glue_ptr(r) = zero_glue;
+ }
+ /* end mathskip code */
} else if (type(r) == glue_node) {
delete_glue_ref(glue_ptr(r));
glue_ptr(r) = right_skip;
@@ -245,8 +280,6 @@ void ext_post_line_break(int paragraph_dir,
disc_break = true;
} else if (type(r) == kern_node) {
width(r) = 0;
- } else if (type(r) == math_node) {
- surround(r) = 0;
}
/* DIR: Adjust the dir stack based on dir nodes in this line; */
@@ -254,15 +287,13 @@ void ext_post_line_break(int paragraph_dir,
if (have_directional) {
halfword e;
halfword p;
- for (e = vlink(temp_head); e != null && e != cur_break(cur_p);
- e = vlink(e)) {
- if (type(e) != whatsit_node || subtype(e) != dir_node)
- continue;
- if (dir_dir(e) >= 0) {
- dir_ptr = do_push_dir_node(dir_ptr, e);
- } else if (dir_ptr != null
- && dir_dir(dir_ptr) == (dir_dir(e) + 64)) {
- dir_ptr = do_pop_dir_node(dir_ptr);
+ for (e = vlink(temp_head); e != null && e != cur_break(cur_p); e = vlink(e)) {
+ if (type(e) == dir_node) {
+ if (dir_dir(e) >= 0) {
+ dir_ptr = do_push_dir_node(dir_ptr, e);
+ } else if (dir_ptr != null && dir_dir(dir_ptr) == (dir_dir(e) + dir_swap)) {
+ dir_ptr = do_pop_dir_node(dir_ptr);
+ }
}
}
assert(e == cur_break(cur_p));
@@ -270,7 +301,7 @@ void ext_post_line_break(int paragraph_dir,
/* DIR: Insert dir nodes at the end of the current line; */
e = vlink(r);
for (p = dir_ptr; p != null; p = vlink(p)) {
- halfword s = new_dir(dir_dir(p) - 64);
+ halfword s = new_dir(dir_dir(p) - dir_swap);
delete_attribute_ref(node_attr(s));
node_attr(s) = node_attr(r);
add_node_attr_ref(node_attr(s));
@@ -383,8 +414,8 @@ void ext_post_line_break(int paragraph_dir,
}
if (left_skip != zero_glue) {
r = new_glue(copy_node(left_skip));
- glue_ref_count(glue_ptr(r)) = null;
- subtype(r) = left_skip_code+1;
+ glue_ref_count(glue_ptr(r)) = null;
+ subtype(r) = left_skip_code+1;
delete_attribute_ref(node_attr(r));
node_attr(r) = node_attr(q);
add_node_attr_ref(node_attr(r));
@@ -416,7 +447,7 @@ void ext_post_line_break(int paragraph_dir,
just_box = hpack(q, cur_width, exactly, paragraph_dir);
}
shift_amount(just_box) = cur_indent;
- subtype(just_box) = HLIST_SUBTYPE_LINE;
+ subtype(just_box) = line_list;
/* /Call the packaging subroutine, setting |just_box| to the justified box; */
if ((vlink(contrib_head) != null))
@@ -428,7 +459,7 @@ void ext_post_line_break(int paragraph_dir,
lua_node_filter_s(buildpage_filter_callback, lua_key_index(pre_adjust));
}
pre_adjust_tail = null;
- append_to_vlist(just_box);
+ append_to_vlist(just_box,lua_key_index(post_linebreak));
if (!output_active)
lua_node_filter_s(buildpage_filter_callback, lua_key_index(box));
if (adjust_head != adjust_tail) {
@@ -510,78 +541,50 @@ void ext_post_line_break(int paragraph_dir,
|break_width| values are computed for non-discretionary
breakpoints. */
r = temp_head;
- if (experimental_code[1]) {
- /* hh-ls: This is a first step to improving symmetry and consistency in the node
- list. This is normally no issue in tex, but in callbacks it matters. */
-
- /* Normally we have a matching math open and math close node but when we cross a line
+ /*
+ Normally we have a matching math open and math close node but when we cross a line
the open node is removed, including any glue or penalties following it. This is however
not that nice for callbacks that rely on symmetry. Of course this only counts for one
liners, as we can still have only a begin or end node on a line. The end_of_math lua
helper is made robust against this although there you should be aware of the fact that
one can end up in the middle of math in callbacks that don't work on whole paragraphs,
but at least this branch makes sure that some proper analysis is possible. (todo: check
- if math glyphs have the subtype marked done). */
-
- halfword m = null ;
- halfword mp, mn, rn ;
- while (1) {
- q = vlink(r);
- if (! q) {
- /* unlikely */
- break;
- } else if (q == cur_break(cur_p)) {
- /* quit */
- break;
- } else if (type(q) == glyph_node) {
- /* quit: is > math_code */
- break;
- } else if (type(q) == math_node) {
- /* we want to keep symmetry */
- surround(q) = 0 ;
- // fprintf(stdout,"KEEP MATH NODE\n");
- m = q ;
- } else if (type(q) == kern_node && subtype(q) != explicit) {
- /* quit: so we keep \kern but also auto kerns */
+ if math glyphs have the subtype marked done).
+
+ Todo: turn math nodes into glues when mathskip otherwise remove them.
+ */
+ while (1) {
+ q = vlink(r);
+ /*
+ if (q == cur_break(cur_p) || is_char_node(q))
+ break;
+ if (!((type(q) == local_par_node))) {
+ if (non_discardable(q) || (type(q) == kern_node && subtype(q) != explicit))
break;
- } if (non_discardable(q)) {
- /* quit: < math_node */
- break;
- } else {
- /* skip: glue, penalty, (font)kern, noads, temp stuff, all kind of left-overs */
- }
- r = q;
}
- if (m != null) {
- if (r == m) {
- /* [a] [b] [m=r] => [a] [b=r] */
- r = alink(m) ;
- } else {
- /* [a] [b] [m] [c] [r] [rn] => [a] [b] [c] [r] [m] [rn] */
- mp = alink(m) ;
- mn = vlink(m) ;
- rn = vlink(r) ;
- vlink(r) = m ;
- alink(m) = r ;
- if (rn) {
- alink(rn) = m ;
- vlink(m) = rn ;
- }
- vlink(mp) = mn ;
- alink(mn) = mp ;
+ */
+ if (type(q) == math_node) {
+ /* begin mathskip code */
+ surround(q) = 0 ;
+ if (glue_ptr(q) != zero_glue) {
+ delete_glue_ref(glue_ptr(q));
+ glue_ptr(q) = zero_glue;
+ add_glue_ref(glue_ptr(q));
}
+ /* end mathskip code */
}
- } else {
- while (1) {
- q = vlink(r);
- if (q == cur_break(cur_p) || is_char_node(q))
- break;
- if (!((type(q) == whatsit_node) && (subtype(q) == local_par_node))) {
- if (non_discardable(q) || (type(q) == kern_node && subtype(q) != explicit))
- break;
- }
- r = q;
+ if (q == cur_break(cur_p)) {
+ break;
+ } else if (is_char_node(q)) {
+ break;
+ } else if (type(q) == local_par_node) {
+ /* weird, in the middle somewhere */
+ } else if (non_discardable(q)) {
+ break;
+ } else if (type(q) == kern_node && subtype(q) != explicit) {
+ break;
}
+ r = q;
}
if (r != temp_head) {
vlink(r) = null;
diff --git a/Build/source/texk/web2c/luatexdir/tex/primitive.h b/Build/source/texk/web2c/luatexdir/tex/primitive.h
index 36df9c9be82..b6b13c74f73 100644
--- a/Build/source/texk/web2c/luatexdir/tex/primitive.h
+++ b/Build/source/texk/web2c/luatexdir/tex/primitive.h
@@ -25,17 +25,16 @@
typedef enum {
/* Can be modified as suggested ?*/
- tex_command = 1, /* 1 */
- etex_command = 2, /* 2 */
- pdftex_command = 16,/* 4 */
- luatex_command = 32,/* 8 */
- core_command = 64, /* 16 */
- no_command = 128, /* 32 */
- umath_command = 256,/* 64 */
+ tex_command = 1, /* 1 */
+ etex_command = 2, /* 2 */
+ pdftex_command = 16, /* 4 */ /* obsolete */
+ luatex_command = 32, /* 8 */
+ core_command = 64, /* 16 */
+ no_command = 128, /* 32 */
+ umath_command = 256, /* 64 */ /* obsolete */
} command_origin;
# define hash_size 65536 /* maximum number of control sequences; it should be at most about |(fix_mem_max-fix_mem_min)/10| */
-
# define hash_prime 55711 /* a prime number equal to about 85\pct! of |hash_size| */
extern two_halves *hash; /* the hash table */
diff --git a/Build/source/texk/web2c/luatexdir/tex/primitive.w b/Build/source/texk/web2c/luatexdir/tex/primitive.w
index 432bde28878..05f3cc1126c 100644
--- a/Build/source/texk/web2c/luatexdir/tex/primitive.w
+++ b/Build/source/texk/web2c/luatexdir/tex/primitive.w
@@ -63,8 +63,8 @@ int cs_count; /* total number of known identifiers */
#define prim_base 1
@ The arrays |prim| and |prim_eqtb| are used for name -> cmd,chr lookups.
-
- The are modelled after |hash| and |eqtb|, except that primitives do not
+
+ The are modelled after |hash| and |eqtb|, except that primitives do not
have an |eq_level|, that field is replaced by |origin|.
@c
@@ -84,7 +84,7 @@ static two_halves prim[(prim_size + 1)]; /* the primitives table */
static memory_word prim_eqtb[(prim_size + 1)];
@ The array |prim_data| works the other way around, it is used for
- cmd,chr -> name lookups.
+ cmd,chr -> name lookups.
@c
typedef struct prim_info {
@@ -95,7 +95,7 @@ typedef struct prim_info {
static prim_info prim_data[(last_cmd + 1)];
-@ initialize the memory arrays
+@ initialize the memory arrays
@c
void init_primitives(void)
{
@@ -134,7 +134,7 @@ static halfword compute_hash(const char *j, unsigned int l,
}
-@ Here is the subroutine that searches the primitive table for an identifier
+@ Here is the subroutine that searches the primitive table for an identifier
@c
pointer prim_lookup(str_number s)
{
@@ -182,7 +182,7 @@ pointer prim_lookup(str_number s)
return p;
}
-@ how to test a csname for primitive-ness
+@ how to test a csname for primitive-ness
@c
boolean is_primitive(str_number csname)
{
@@ -198,7 +198,7 @@ boolean is_primitive(str_number csname)
}
-@ a few simple accessors
+@ a few simple accessors
@c
quarterword get_prim_eq_type(int p)
{
@@ -221,7 +221,7 @@ str_number get_prim_text(int p)
}
-@ dumping and undumping
+@ dumping and undumping
@c
void dump_primitives(void)
{
@@ -270,7 +270,7 @@ void undump_primitives(void)
@ Because the definitions of the actual user-accessible name of a
primitive can be postponed until runtime, the function |primitive_def|
- is needed that does nothing except creating the control sequence name.
+ is needed that does nothing except creating the control sequence name.
@c
void primitive_def(const char *s, size_t l, quarterword c, halfword o)
@@ -323,7 +323,7 @@ store_primitive_name(str_number s, quarterword c, halfword o, halfword offset)
prim_data[c].names[idx] = s;
}
-@ Compared to tex82, |primitive| has two extra parameters. The |off| is an offset
+@ Compared to tex82, |primitive| has two extra parameters. The |off| is an offset
that will be passed on to |store_primitive_name|, the |cmd_origin| is the bit
that is used to group primitives by originator.
@@ -363,7 +363,7 @@ static halfword insert_id(halfword p, const unsigned char *j, unsigned int l)
if (cs_text(p) > 0) {
if (hash_high < hash_extra) {
incr(hash_high);
- /* can't use |eqtb_top| here (perhaps because that is not finalized
+ /* can't use |eqtb_top| here (perhaps because that is not finalized
yet when called from |primitive|?) */
cs_next(p) = hash_high + eqtb_size;
p = cs_next(p);
@@ -473,9 +473,9 @@ pointer string_lookup(const char *s, size_t l)
The body of |print_cmd_chr| use to be a rather tedious listing of print
commands, and most of it was essentially an inverse to the |primitive|
- routine that enters a \TeX\ primitive into |eqtb|.
+ routine that enters a \TeX\ primitive into |eqtb|.
- Thanks to |prim_data|, there is no need for all that tediousness. What
+ Thanks to |prim_data|, there is no need for all that tediousness. What
is left of |primt_cnd_chr| are just the exceptions to the general rule
that the |cmd,chr_code| pair represents in a single primitive command.
@@ -591,17 +591,6 @@ void print_cmd_chr(quarterword cmd, halfword chr_code)
tprint(" ");
tprint("macro");
break;
- case extension_cmd:
- if (chr_code < prim_data[cmd].subids &&
- prim_data[cmd].names[chr_code] != 0) {
- prim_cmd_chr(cmd, chr_code);
- } else {
- tprint("[unknown extension! (");
- print_int(chr_code);
- tprint(")]");
-
- }
- break;
case assign_glue_cmd:
case assign_mu_glue_cmd:
if (chr_code < skip_base) {
@@ -642,6 +631,25 @@ void print_cmd_chr(quarterword cmd, halfword chr_code)
print_int(chr_code - scaled_base);
}
break;
+ case normal_cmd:
+ if (chr_code < prim_data[cmd].subids && prim_data[cmd].names[chr_code] != 0) {
+ prim_cmd_chr(cmd, chr_code);
+ } else {
+ tprint("[unknown command! (");
+ print_int(chr_code);
+ tprint(")]");
+ }
+ break;
+ case extension_cmd:
+ if (chr_code < prim_data[cmd].subids && prim_data[cmd].names[chr_code] != 0) {
+ prim_cmd_chr(cmd, chr_code);
+ } else {
+ tprint("[unknown extension! (");
+ print_int(chr_code);
+ tprint(")]");
+
+ }
+ break;
default:
/* these are most commands, actually */
prim_cmd_chr(cmd, chr_code);
diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.h b/Build/source/texk/web2c/luatexdir/tex/printing.h
index 04109cdf8a4..838e87e5bde 100644
--- a/Build/source/texk/web2c/luatexdir/tex/printing.h
+++ b/Build/source/texk/web2c/luatexdir/tex/printing.h
@@ -1,5 +1,5 @@
/* printing.h
-
+
Copyright 2009 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -17,22 +17,29 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-
#ifndef PRINTING_H
# define PRINTING_H
+#define last_file_selector 127 /* was 15 */
+
+/*
+ Nicer will be to start these with 0 and then use an offset for the write
+ registers internally.
+*/
+
typedef enum {
- no_print = 16, /* |selector| setting that makes data disappear */
- term_only = 17, /* printing is destined for the terminal only */
- log_only = 18, /* printing is destined for the transcript file only */
- term_and_log = 19, /* normal |selector| setting */
- pseudo = 20, /* special |selector| setting for |show_context| */
- new_string = 21, /* printing is deflected to the string pool */
+ no_print = last_file_selector + 1, /* 16 */ /* |selector| setting that makes data disappear */
+ term_only = last_file_selector + 2, /* 17 */ /* printing is destined for the terminal only */
+ log_only = last_file_selector + 3, /* 18 */ /* printing is destined for the transcript file only */
+ term_and_log = last_file_selector + 4, /* 19 */ /* normal |selector| setting */
+ pseudo = last_file_selector + 5, /* 20 */ /* special |selector| setting for |show_context| */
+ new_string = last_file_selector + 6, /* 21 */ /* printing is deflected to the string pool */
} selector_settings;
+extern int new_string_line;
+
# define ssup_error_line 255
-# define max_selector new_string
- /* highest selector setting */
+# define max_selector new_string /* highest selector setting */
extern alpha_file log_file;
extern int selector;
@@ -46,11 +53,11 @@ extern int first_count;
extern boolean inhibit_par_tokens;
/*
-Macro abbreviations for output to the terminal and to the log file are
-defined here for convenience. Some systems need special conventions
-for terminal output, and it is possible to adhere to those conventions
-by changing |wterm|, |wterm_ln|, and |wterm_cr| in this section.
-@^system dependencies@>
+ Macro abbreviations for output to the terminal and to the log file are
+ defined here for convenience. Some systems need special conventions
+ for terminal output, and it is possible to adhere to those conventions
+ by changing |wterm|, |wterm_ln|, and |wterm_cr| in this section.
+ @^system dependencies@>
*/
# define wterm_cr() fprintf(term_out,"\n")
@@ -83,34 +90,33 @@ extern void tprint_esc(const char *s);
extern void prompt_input(const char *s);
-
-# define single_letter(A) \
- ((str_length(A)==1)|| \
- ((str_length(A)==4)&&*(str_string((A)))>=0xF0)|| \
- ((str_length(A)==3)&&*(str_string((A)))>=0xE0)|| \
+# define single_letter(A) \
+ ((str_length(A)==1)|| \
+ ((str_length(A)==4)&&*(str_string((A)))>=0xF0)|| \
+ ((str_length(A)==3)&&*(str_string((A)))>=0xE0)|| \
((str_length(A)==2)&&*(str_string((A)))>=0xC0))
-# define is_active_cs(a) (a && str_length(a)>3 && \
- (*str_string(a) == 0xEF) && \
- (*(str_string(a)+1) == 0xBF) && \
- (*(str_string(a)+2) == 0xBF))
-
+# define is_active_cs(a) \
+ (a && str_length(a)>3 && \
+ ( *str_string(a) == 0xEF) && \
+ (*(str_string(a)+1) == 0xBF) && \
+ (*(str_string(a)+2) == 0xBF))
# define active_cs_value(A) pool_to_unichar((str_string((A))+3))
-extern void print_glue(scaled d, int order, const char *s); /* prints a glue component */
-extern void print_spec(int p, const char *s); /* prints a glue specification */
+extern void print_glue(scaled d, int order, const char *s); /* prints a glue component */
+extern void print_spec(int p, const char *s); /* prints a glue specification */
-extern int font_in_short_display; /* an internal font number */
+extern int font_in_short_display; /* an internal font number */
extern void print_font_identifier(internal_font_number f);
-extern void short_display(int p); /* prints highlights of list |p| */
-extern void print_font_and_char(int p); /* prints |char_node| data */
-extern void print_mark(int p); /* prints token list data in braces */
-extern void print_rule_dimen(scaled d); /* prints dimension in rule node */
-extern int depth_threshold; /* maximum nesting depth in box displays */
-extern int breadth_max; /* maximum number of items shown at the same list level */
+extern void short_display(int p); /* prints highlights of list |p| */
+extern void print_font_and_char(int p); /* prints |char_node| data */
+extern void print_mark(int p); /* prints token list data in braces */
+extern void print_rule_dimen(scaled d); /* prints dimension in rule node */
+extern int depth_threshold; /* maximum nesting depth in box displays */
+extern int breadth_max; /* maximum number of items shown at the same list level */
extern void show_box(halfword p);
-extern void short_display_n(int p, int m); /* prints highlights of list |p| */
+extern void short_display_n(int p, int m); /* prints highlights of list |p| */
extern void print_csnames(int hstart, int hfinish);
extern void print_file_line(void);
@@ -119,5 +125,4 @@ extern void begin_diagnostic(void);
extern void end_diagnostic(boolean blank_line);
extern int global_old_setting;
-
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.w b/Build/source/texk/web2c/luatexdir/tex/printing.w
index b2ca7c9a94e..6cab2dd0060 100644
--- a/Build/source/texk/web2c/luatexdir/tex/printing.w
+++ b/Build/source/texk/web2c/luatexdir/tex/printing.w
@@ -29,6 +29,7 @@
#define wlog(A) fputc(A,log_file)
#define wterm(A) fputc(A,term_out)
+int new_string_line = 0;
@ Messages that are sent to a user's terminal and to the transcript-log file
are produced by several `|print|' procedures. These procedures will
@@ -101,8 +102,12 @@ void print_ln(void)
term_offset = 0;
break;
case no_print:
+ break;
case pseudo:
+ break;
case new_string:
+ if (new_string_line > 0)
+ print_char(new_string_line);
break;
default:
fprintf(write_file[selector], "\n");
@@ -218,7 +223,7 @@ The first 256 entries above the 17th unicode plane are used for a
special trick: when \TeX\ has to print items in that range, it will
instead print the character that results from substracting 0x110000
from that value. This allows byte-oriented output to things like
-\.{\\specials} and \.{\\pdfliterals}. Todo: Perhaps it would be useful
+\.{\\specials} and \.{\\pdfextension literals}. Todo: Perhaps it would be useful
to do the same substraction while typesetting.
@c
@@ -260,8 +265,7 @@ void print(int s)
} else if (s >= 0x110000) {
int c = s - 0x110000;
if (c >= 256) {
- pdf_warning("print", "bad raw byte to print (c=",
- true, false);
+ normal_warning("print", "bad raw byte to print (c=", true, false);
print_int(c);
tprint("), skipped.");
print_ln();
@@ -309,9 +313,12 @@ string appears at the beginning of a new line.
@c
void print_nlp(void)
{ /* move to beginning of a line */
- if (((term_offset > 0) && (odd(selector))) ||
- ((file_offset > 0) && (selector >= log_only)))
+ if (new_string_line > 0) {
+ print_char(new_string_line);
+ } else if (((term_offset > 0) && (odd(selector))) ||
+ ((file_offset > 0) && (selector >= log_only))) {
print_ln();
+ }
}
void print_nl(str_number s)
@@ -419,9 +426,9 @@ void tprint(const char *sss)
term_offset=0;
}
if (s != newlinechar) {
- if ((s>=0x20)||(s==0x0A)||(s==0x0D)||(s==0x09)) {
+ if ((s>=0x20)||(s==0x0A)||(s==0x0D)||(s==0x09)) {
buffer[i++] = s;
- } else {
+ } else {
buffer[i++] = '^';
buffer[i++] = '^';
buffer[i++] = s+64;
@@ -474,7 +481,7 @@ void print_banner(const char *v, int ver)
wterm(' ');
fprintf(term_out,"Number of bits used by the hash function (" my_name "): %d",LUAI_HASHLIMIT);
print_ln();
- }
+ }
if (shellenabledp) {
wterm(' ');
if (restrictedshell)
@@ -499,7 +506,7 @@ void log_banner(const char *v, int ver)
if (ver < 0)
fprintf(log_file, "This is " MyName ", Version %s ", v);
else
- fprintf(log_file, "This is " MyName ", Version %s%s (rev %d) ", v,
+ fprintf(log_file, "This is " MyName ", Version %s%s (rev %d) ", v,
WEB2CVERSION, ver);
print(format_ident);
print_char(' ');
@@ -834,7 +841,7 @@ void print_font_identifier(internal_font_number f)
tprint_esc("FONT");
print_int(f);
}
- if (int_par(pdf_tracing_fonts_code) > 0) {
+ if (int_par(tracing_fonts_code) > 0) {
tprint(" (");
print_font_name(f);
if (font_size(f) != font_dsize(f)) {
diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.w b/Build/source/texk/web2c/luatexdir/tex/scanning.w
index 1adeb5770fa..06b89cd585c 100644
--- a/Build/source/texk/web2c/luatexdir/tex/scanning.w
+++ b/Build/source/texk/web2c/luatexdir/tex/scanning.w
@@ -193,7 +193,7 @@ static void negate_cur_val(boolean delete_glue)
@ Some of the internal items can be fetched both routines,
and these have been split off into the next routine, that
-returns true if the command code was understood
+returns true if the command code was understood
@c
static boolean short_scan_something_internal(int cmd, int chr, int level,
@@ -315,7 +315,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
cur_chr = chr;
/* Fetch an item in the current node, if appropriate */
/* Here is where \.{\\lastpenalty}, \.{\\lastkern}, and \.{\\lastskip} are
- implemented. The reference count for \.{\\lastskip} will be updated later.
+ implemented. The reference count for \.{\\lastskip} will be updated later.
We also handle \.{\\inputlineno} and \.{\\badness} here, because they are
legal in similar contexts. */
@@ -344,7 +344,7 @@ 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.
+ already increased the reference count of a glue specification.
*/
while (cur_val_level > level) {
downgrade_cur_val(true);
@@ -424,39 +424,24 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
case luatex_version_code:
cur_val = get_luatexversion();
break;
- case pdf_last_obj_code:
- cur_val = pdf_last_obj;
+ case last_saved_box_resource_index_code:
+ cur_val = last_saved_box_index;
break;
- case pdf_last_xform_code:
- cur_val = pdf_last_xform;
+ case last_saved_image_resource_index_code:
+ cur_val = last_saved_image_index;
break;
- case pdf_last_ximage_code:
- cur_val = pdf_last_ximage;
- break;
- case pdf_last_ximage_pages_code:
- cur_val = pdf_last_ximage_pages;
- break;
- case pdf_last_annot_code:
- cur_val = pdf_last_annot;
+ case last_saved_image_resource_pages_code:
+ cur_val = last_saved_image_pages;
break;
case last_x_pos_code:
- cur_val = pdf_last_pos.h;
+ cur_val = last_position.h;
break;
case last_y_pos_code:
- cur_val = pdf_last_pos.v;
- break;
- case pdf_retval_code:
- cur_val = pdf_retval;
- break;
- case pdf_last_ximage_colordepth_code:
- cur_val = pdf_last_ximage_colordepth;
+ cur_val = last_position.v;
break;
case random_seed_code:
cur_val = random_seed;
break;
- case pdf_last_link_code:
- cur_val = pdf_last_link;
- break;
case eTeX_version_code:
cur_val = eTeX_version;
break;
@@ -503,7 +488,6 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
cur_val = shrink_order(q);
delete_glue_ref(q);
break;
-
} /* there are no other cases */
cur_val_level = int_val_level;
}
@@ -588,7 +572,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
@ First, here is a short routine that is called from lua code. All
the real work is delegated to |short_scan_something_internal| that
-is shared between this routine and |scan_something_internal|.
+is shared between this routine and |scan_something_internal|.
@c
void scan_something_simple(halfword cmd, halfword subitem)
@@ -661,7 +645,7 @@ void scan_something_internal(int level, boolean negative)
case set_font_cmd:
case def_font_cmd:
case letterspace_font_cmd:
- case pdf_copy_font_cmd:
+ case copy_font_cmd:
/* Fetch a token list or font identifier, provided that |level=tok_val| */
if (level != tok_val_level) {
print_err("Missing number, treated as zero");
@@ -680,6 +664,10 @@ void scan_something_internal(int level, boolean negative)
scanned_result(font_id_base + cur_val, ident_val_level);
}
break;
+ case set_font_id_cmd:
+ scan_int();
+ scanned_result(font_id_base + cur_val, ident_val_level);
+ break;
case def_family_cmd:
/* Fetch a math font identifier */
scan_char_num();
@@ -852,9 +840,9 @@ void scan_something_internal(int level, boolean negative)
|scan_eight_bit_int| is superceded by |scan_register_num| and
|scan_mark_num|. It may become split up even further in the future.
-Many of the |restricted classes| routines are the essentially
+Many of the |restricted classes| routines are the essentially
the same except for the upper limit and the error message, so it makes
-sense to combine these all into one function.
+sense to combine these all into one function.
@c
void scan_limited_int(int max, const char *name)
@@ -1263,7 +1251,7 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut)
/* Scan for (f)\.{fil} units; |goto attach_fraction| if found */
/* In traditional TeX, a specification like `\.{filllll}' or `\.{fill L L
L}' will lead to two error messages (one for each additional keyword
- \.{"l"}).
+ \.{"l"}).
Not so for luatex, it just parses the construct in reverse. */
if (scan_keyword("filll")) {
cur_order = filll;
@@ -1309,7 +1297,7 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut)
} else if (scan_keyword("ex")) {
v = (x_height(get_cur_font()));
} else if (scan_keyword("px")) {
- v = dimen_par(pdf_px_dimen_code);
+ v = dimen_par(px_dimen_code);
} else {
goto NOT_FOUND;
}
@@ -1498,7 +1486,7 @@ void scan_glue(int level)
cur_val = q;
}
-@ This is an omega routine
+@ This is an omega routine
@c
void scan_scaled(void)
{ /* sets |cur_val| to a scaled value */
@@ -1798,8 +1786,17 @@ found (in any order).
@c
halfword scan_rule_spec(void)
{
- halfword q; /* the rule node being created */
- q = new_rule(); /* |width|, |depth|, and |height| all equal |null_flag| now */
+ /* |width|, |depth|, and |height| all equal |null_flag| now */
+ halfword q;
+ if (cur_cmd == no_vrule_cmd) {
+ q = new_rule(empty_rule);
+ cur_cmd = vrule_cmd;
+ } else if (cur_cmd == no_hrule_cmd) {
+ q = new_rule(empty_rule);
+ cur_cmd = hrule_cmd;
+ } else {
+ q = new_rule(normal_rule);
+ }
if (cur_cmd == vrule_cmd) {
width(q) = default_rule;
rule_dir(q) = body_direction;
@@ -1840,8 +1837,7 @@ void scan_font_ident(void)
get_x_token();
} while (cur_cmd == spacer_cmd);
- if ((cur_cmd == def_font_cmd) || (cur_cmd == letterspace_font_cmd)
- || (cur_cmd == pdf_copy_font_cmd)) {
+ if ((cur_cmd == def_font_cmd) || (cur_cmd == letterspace_font_cmd) || (cur_cmd == copy_font_cmd)) {
f = get_cur_font();
} else if (cur_cmd == set_font_cmd) {
f = cur_chr;
@@ -1862,7 +1858,7 @@ void scan_font_ident(void)
}
@ The |scan_general_text| procedure is much like |scan_toks(false,false)|,
-but will be invoked via |expand|, i.e., recursively.
+but will be invoked via |expand|, i.e., recursively.
The token list (balanced text) created by |scan_general_text| begins
at |link(temp_token_head)| and ends at |cur_val|. (If |cur_val=temp_token_head|,
@@ -2038,7 +2034,7 @@ halfword scan_toks(boolean macro_def, boolean xpand)
/* Here we insert an entire token list created by |the_toks| without
expanding it further. */
while (1) {
- get_token_lua();
+ get_next(); /* get_token_lua(); */
if (cur_cmd >= call_cmd) {
if (token_info(token_link(cur_chr)) == protected_token) {
cur_cmd = relax_cmd;
@@ -2140,8 +2136,8 @@ typedef enum {
($2^{31}-1$) in absolute value, dimensions must not exceed |max_dimen|
($2^{30}-1$). We avoid the absolute value of an integer, because this
might fail for the value $-2^{31}$ using 32-bit arithmetic.
-
-@ clear a number or dimension and set |arith_error|
+
+@ clear a number or dimension and set |arith_error|
@c
#define num_error(A) do { \
@@ -2149,8 +2145,8 @@ typedef enum {
A=0; \
} while (0)
-
-@ clear a glue spec and set |arith_error|
+
+@ clear a glue spec and set |arith_error|
@c
#define glue_error(A) do { \
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.h b/Build/source/texk/web2c/luatexdir/tex/texmath.h
index 72b83de6143..90ae5f20a1d 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.h
@@ -1,5 +1,5 @@
/* texmath.h
-
+
Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
@@ -160,6 +160,8 @@ typedef enum {
math_param_fraction_denom_vgap,
math_param_fraction_denom_down,
math_param_fraction_del_size,
+ math_param_skewed_fraction_hgap,
+ math_param_skewed_fraction_vgap,
math_param_limit_above_vgap,
math_param_limit_above_bgap,
math_param_limit_above_kern,
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w
index 04152ff2999..77c6161f475 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w
@@ -35,6 +35,23 @@
#define cur_fam int_par(cur_fam_code)
#define text_direction int_par(text_direction_code)
+/*
+
+ \mathdisplayskipmode
+
+ tex normally always inserts before and only after when larger than zero
+
+ 0 = normal tex
+ 1 = always
+ 2 = non-zero
+ 3 = ignore
+
+*/
+
+#define display_skip_mode int_par(math_display_skip_mode_code)
+
+#define math_skip glue_par(math_skip_code)
+
#define var_code 7
@ TODO: not sure if this is the right order
@@ -48,18 +65,19 @@
@ @c
int scan_math(pointer, int);
+int scan_math_style(pointer, int);
pointer fin_mlist(pointer);
#define pre_display_size dimen_par(pre_display_size_code)
-#define hsize dimen_par(hsize_code)
-#define display_width dimen_par(display_width_code)
-#define display_indent dimen_par(display_indent_code)
-#define math_surround dimen_par(math_surround_code)
-#define hang_indent dimen_par(hang_indent_code)
-#define hang_after int_par(hang_after_code)
-#define every_math equiv(every_math_loc)
-#define every_display equiv(every_display_loc)
-#define par_shape_ptr equiv(par_shape_loc)
+#define hsize dimen_par(hsize_code)
+#define display_width dimen_par(display_width_code)
+#define display_indent dimen_par(display_indent_code)
+#define math_surround dimen_par(math_surround_code)
+#define hang_indent dimen_par(hang_indent_code)
+#define hang_after int_par(hang_after_code)
+#define every_math equiv(every_math_loc)
+#define every_display equiv(every_display_loc)
+#define par_shape_ptr equiv(par_shape_loc)
#define math_eqno_gap_step int_par(math_eqno_gap_step_code)
@@ -151,7 +169,6 @@ static void unsave_math(void)
text_dir_ptr = saved_value(0);
}
-
@ Sometimes it is necessary to destroy an mlist. The following
subroutine empties the current list, assuming that |abs(mode)=mmode|.
@@ -229,8 +246,6 @@ static void unsave_math_fam_data(int gl)
}
}
-
-
@ and parameters
@c
@@ -263,7 +278,6 @@ scaled get_math_param(int param_id, int style_id)
return (scaled) get_sa_item(math_param_head, n);
}
-
@ @c
static void unsave_math_param_data(int gl)
{
@@ -295,7 +309,6 @@ static void unsave_math_param_data(int gl)
}
}
-
@ saving and unsaving of both
@c
@@ -335,8 +348,6 @@ void initialize_math(void)
return;
}
-
-
@ Each portion of a formula is classified as Ord, Op, Bin, Rel, Ope,
Clo, Pun, or Inn, for purposes of spacing and line breaking. An
|ord_noad|, |op_noad|, |bin_noad|, |rel_noad|, |open_noad|, |close_noad|,
@@ -381,8 +392,6 @@ be placed at the left and right of the fraction. In this way, a
\.{\\atop}, \.{\\above}, \.{\\overwithdelims}, \.{\\atopwithdelims}, and
\.{\\abovewithdelims}.
-
-
@ The |new_noad| function creates an |ord_noad| that is completely null
@c
@@ -405,7 +414,6 @@ pointer new_sub_box(pointer curbox)
return p;
}
-
@ A few more kinds of noads will complete the set: An |under_noad| has its
nucleus underlined; an |over_noad| has it overlined. An |accent_noad| places
an accent over its nucleus; the accent character appears as
@@ -424,8 +432,6 @@ with subtype |right_noad_side| never appears in an mlist
except as the last element; furthermore, we either have both a |left_noad_side|
and a |right_noad_side|, or neither one is present.
-
-
@ Math formulas can also contain instructions like \.{\\textstyle} that
override \TeX's normal style rules. A |style_node| is inserted into the
data structure to record such instructions; it is three words long, so it
@@ -507,7 +513,6 @@ static pointer new_choice(void)
return new_node(choice_node, 0); /* the |subtype| is not used */
}
-
@ Let's consider now the previously unwritten part of |show_node_list|
that displays the things that can only be present in mlists; this
program illustrates how to access the data structures just defined.
@@ -566,7 +571,6 @@ void show_math_node(pointer p)
}
}
-
@ Here are some simple routines used in the display of noads.
@c
@@ -582,6 +586,31 @@ static void print_fam_and_char(pointer p)
static void print_delimiter(pointer p)
{
int a;
+ if (delimiteroptionset(p)) {
+ tprint(" [ ");
+ if (delimiteraxis(p))
+ tprint("axis ");
+ if (delimiternoaxis(p))
+ tprint("noaxis ");
+ if (delimiterexact(p))
+ tprint("exact ");
+ tprint("]");
+ }
+ if (delimiterheight(p)) {
+ tprint("height=");
+ print_scaled(delimiterheight(p));
+ tprint(" ");
+ }
+ if (delimiterdepth(p)) {
+ tprint("depth=");
+ print_scaled(delimiterdepth(p));
+ tprint(" ");
+ }
+ if (delimiterclass(p)) {
+ tprint("class=");
+ print_int(delimiterclass(p));
+ tprint(" ");
+ }
if (small_fam(p) < 0) {
print_int(-1); /* this should never happen */
} else if (small_fam(p) < 16 && large_fam(p) < 16 &&
@@ -598,7 +627,6 @@ static void print_delimiter(pointer p)
}
}
-
@ The next subroutine will descend to another level of recursion when a
subsidiary mlist needs to be displayed. The parameter |c| indicates what
character is to become part of the recursion history. An empty mlist is
@@ -689,8 +717,7 @@ void display_normal_noad(pointer p)
break;
}
break;
-
- case radical_noad:
+ case radical_noad:
if (subtype(p) == 6)
tprint_esc("Udelimiterover");
else if (subtype(p) == 5)
@@ -707,64 +734,90 @@ void display_normal_noad(pointer p)
if (degree(p) != null) {
print_subsidiary_data(degree(p), '/');
}
+ if (radicalwidth(p)) {
+ tprint("width=");
+ print_scaled(radicalwidth(p));
+ tprint(" ");
+ }
+ if (radicaloptionset(p)) {
+ tprint(" [ ");
+ if (radicalexact(p))
+ tprint("exact ");
+ if (radicalleft(p))
+ tprint("left ");
+ if (radicalmiddle(p))
+ tprint("middle ");
+ if (radicalright(p))
+ tprint("right ");
+ tprint("]");
+ }
break;
case accent_noad:
- if (accent_chr(p) != null) {
+ if (top_accent_chr(p) != null) {
if (bot_accent_chr(p) != null) {
tprint_esc("Umathaccent both");
} else {
tprint_esc("Umathaccent");
}
- } else {
- tprint_esc("Umathaccent bottom");
- }
- switch (subtype(p)) {
- case 0:
- if (accent_chr(p) != null) {
- if (bot_accent_chr(p) != null) {
- print_fam_and_char(accent_chr(p));
- print_fam_and_char(bot_accent_chr(p));
- } else {
- print_fam_and_char(accent_chr(p));
- }
+ } else if (bot_accent_chr(p) != null) {
+ tprint_esc("Umathaccent bottom");
} else {
- print_fam_and_char(bot_accent_chr(p));
+ tprint_esc("Umathaccent overlay");
}
- break;
- case 1:
- if (accent_chr(p) != null) {
- tprint(" fixed ");
- print_fam_and_char(accent_chr(p));
- if (bot_accent_chr(p) != null) {
- print_fam_and_char(bot_accent_chr(p));
- }
- } else {
- confusion("display_accent_noad");
+ if (accentfraction(p)) {
+ tprint(" fraction=");
+ print_int(accentfraction(p));
+ tprint(" ");
}
- break;
- case 2:
- if (bot_accent_chr(p) != null) {
- if (accent_chr(p) != null) {
- print_fam_and_char(accent_chr(p));
+ switch (subtype(p)) {
+ case 0:
+ if (top_accent_chr(p) != null) {
+ if (bot_accent_chr(p) != null) {
+ print_fam_and_char(top_accent_chr(p));
+ print_fam_and_char(bot_accent_chr(p));
+ } else {
+ print_fam_and_char(top_accent_chr(p));
+ }
+ } else if (bot_accent_chr(p) != null) {
+ print_fam_and_char(bot_accent_chr(p));
+ } else {
+ print_fam_and_char(overlay_accent_chr(p));
+ }
+ break;
+ case 1:
+ if (top_accent_chr(p) != null) {
+ tprint(" fixed ");
+ print_fam_and_char(top_accent_chr(p));
+ if (bot_accent_chr(p) != null) {
+ print_fam_and_char(bot_accent_chr(p));
+ }
+ } else {
+ confusion("display_accent_noad");
+ }
+ break;
+ case 2:
+ if (bot_accent_chr(p) != null) {
+ if (top_accent_chr(p) != null) {
+ print_fam_and_char(top_accent_chr(p));
+ }
+ tprint(" fixed ");
+ print_fam_and_char(bot_accent_chr(p));
+ } else{
+ confusion("display_accent_noad");
+ }
+ break;
+ case 3:
+ if (top_accent_chr(p) != null && bot_accent_chr(p) != null) {
+ tprint(" fixed ");
+ print_fam_and_char(top_accent_chr(p));
+ tprint(" fixed ");
+ print_fam_and_char(bot_accent_chr(p));
+ } else {
+ confusion("display_accent_noad");
+ }
+ break;
}
- tprint(" fixed ");
- print_fam_and_char(bot_accent_chr(p));
- } else{
- confusion("display_accent_noad");
- }
break;
- case 3:
- if (accent_chr(p) != null && bot_accent_chr(p) != null) {
- tprint(" fixed ");
- print_fam_and_char(accent_chr(p));
- tprint(" fixed ");
- print_fam_and_char(bot_accent_chr(p));
- } else {
- confusion("display_accent_noad");
- }
- break;
- }
- break;
}
print_subsidiary_data(nucleus(p), '.');
print_subsidiary_data(supscr(p), '^');
@@ -811,7 +864,6 @@ void display_fraction_noad(pointer p)
print_subsidiary_data(denominator(p), '/');
}
-
@ The routines that \TeX\ uses to create mlists are similar to those we have
just seen for the generation of hlists and vlists. But it is necessary to
make ``noads'' as well as nodes, so the reader should review the
@@ -882,12 +934,10 @@ void init_math(void)
}
}
-
@ We get into ordinary math mode from display math mode when `\.{\\eqno}' or
`\.{\\leqno}' appears. In such cases |cur_chr| will be 0 or~1, respectively;
the value of |cur_chr| is placed onto |save_stack| for safe keeping.
-
@ When \TeX\ is in display math mode, |cur_group=math_shift_group|,
so it is not necessary for the |start_eq_no| procedure to test for
this condition.
@@ -953,10 +1003,6 @@ static boolean math_and_text_reversed_p(void)
return false;
}
-
-
-
-
@ When we enter display math mode, we need to call |line_break| to
process the partial paragraph that has just been interrupted by the
display. Then we can set the proper values of |display_width| and
@@ -972,8 +1018,7 @@ void enter_display_math(void)
int n; /* scope of paragraph shape specification */
if (head == tail || /* `\.{\\noindent\$\$}' or `\.{\$\${ }\$\$}' */
(vlink(head) == tail && /* the 2nd of \.{\$\${ }\$\$} \.{\$\${ }\$\$} */
- type(tail) == whatsit_node &&
- subtype(tail) == local_par_node && vlink(tail) == null)) {
+ type(tail) == local_par_node && vlink(tail) == null)) {
if (vlink(head) == tail) {
/* bug \#270: |resume_after_display| inserts a |local_par_node|, but if
there is another display immediately following, we have to get rid
@@ -1202,7 +1247,6 @@ void scan_extdef_math_code(int level, int extcode)
d.family_value, d.character_value, (quarterword) (level));
}
-
@ this reads in a delcode when actually a mathcode is needed
@c
mathcodeval scan_delimiter_as_mathchar(int extcode)
@@ -1248,6 +1292,16 @@ that subformula into a given word of |mem|.
@c
#define get_next_nb_nr() do { get_x_token(); } while (cur_cmd==spacer_cmd||cur_cmd==relax_cmd)
+int scan_math_style(pointer p, int mstyle)
+{
+ get_next_nb_nr();
+ back_input();
+ scan_left_brace();
+ set_saved_record(0, saved_math, 0, p);
+ incr(save_ptr);
+ push_math(math_group, mstyle);
+ return 1;
+}
int scan_math(pointer p, int mstyle)
{
@@ -1321,8 +1375,6 @@ int scan_math(pointer p, int mstyle)
return 0;
}
-
-
@ The |set_math_char| procedure creates a new noad appropriate to a given
math code, and appends it to the current mlist. However, if the math code
is sufficiently large, the |cur_chr| is treated as an active character and
@@ -1368,8 +1420,6 @@ void set_math_char(mathcodeval mval)
}
}
-
-
@ The |math_char_in_text| procedure creates a new node representing a math char
in text code, and appends it to the current list. However, if the math code
is sufficiently large, the |cur_chr| is treated as an active character and
@@ -1387,14 +1437,12 @@ void math_char_in_text(mathcodeval mval)
x_token();
back_input();
} else {
- p = new_char(fam_fnt(mval.family_value, text_size),
- mval.character_value);
+ p = new_char(fam_fnt(mval.family_value, text_size), mval.character_value);
vlink(tail) = p;
tail = p;
}
}
-
@ @c
void math_math_comp(void)
{
@@ -1409,7 +1457,6 @@ void math_math_comp(void)
(void) scan_math(nucleus(tail), m_style);
}
-
@ @c
void math_limit_switch(void)
{
@@ -1429,7 +1476,6 @@ void math_limit_switch(void)
tex_error("Limit controls must follow a math operator", hlp);
}
-
@ Delimiter fields of noads are filled in by the |scan_delimiter| routine.
The first parameter of this procedure is the |mem| address where the
delimiter is to be placed; the second tells if this delimiter follows
@@ -1491,15 +1537,30 @@ static void scan_delimiter(pointer p, int r)
return;
}
-
@ @c
void math_radical(void)
{
halfword q;
int chr_code = cur_chr;
+ halfword options = 0;
tail_append(new_node(radical_noad, chr_code));
q = new_node(delim_node, 0);
left_delimiter(tail) = q;
+ while (1) {
+ if (scan_keyword("width")) {
+ scan_dimen(false,false,false);
+ radicalwidth(tail) = cur_val ;
+ } else if (scan_keyword("left")) {
+ options = options | noad_option_left ;
+ } else if (scan_keyword("middle")) {
+ options = options | noad_option_middle ;
+ } else if (scan_keyword("right")) {
+ options = options | noad_option_right ;
+ } else {
+ break;
+ }
+ }
+ radicaloptions(tail) = options;
if (chr_code == 0) /* \.{\\radical} */
scan_delimiter(left_delimiter(tail), tex_mathcode);
else if (chr_code == 1) /* \.{\\Uradical} */
@@ -1514,9 +1575,15 @@ void math_radical(void)
scan_delimiter(left_delimiter(tail), umath_mathcode);
else if (chr_code == 6) /* \.{\\Udelimiterover} */
scan_delimiter(left_delimiter(tail), umath_mathcode);
+ else if (chr_code == 7) /* \.{\\Uhextensible} */
+ scan_delimiter(left_delimiter(tail), umath_mathcode);
else
confusion("math_radical");
- if (chr_code == 2) {
+ if (chr_code == 7) {
+ q = new_node(sub_box_node, 0); /* type will change */
+ nucleus(tail) = q;
+ return;
+ } else if (chr_code == 2) {
/* the trick with the |vlink(q)| is used by |scan_math|
to decide whether it needs to go on */
q = new_node(math_char_node, 0);
@@ -1539,8 +1606,9 @@ void math_radical(void)
void math_ac(void)
{
halfword q;
- mathcodeval t = { 0, 0, 0, 0 }, b = {
- 0, 0, 0, 0};
+ mathcodeval t = { 0, 0, 0, 0 };
+ mathcodeval b = { 0, 0, 0, 0 };
+ mathcodeval o = { 0, 0, 0, 0 };
if (cur_cmd == accent_cmd) {
const char *hlp[] = {
"I'm changing \\accent to \\mathaccent here; wish me luck.",
@@ -1553,37 +1621,57 @@ void math_ac(void)
if (cur_chr == 0) { /* \.{\\mathaccent} */
t = scan_mathchar(tex_mathcode);
} else if (cur_chr == 1) { /* \.{\\Umathaccent} */
- if (scan_keyword("fixed")) {
- subtype(tail) = 1;
- t = scan_mathchar(umath_mathcode);
- } else if (scan_keyword("both")) {
- if (scan_keyword("fixed")) {
- subtype(tail) = 1;
- }
- t = scan_mathchar(umath_mathcode);
- if (scan_keyword("fixed")) {
- subtype(tail) += 2;
- }
- b = scan_mathchar(umath_mathcode);
- } else if (scan_keyword("bottom")) {
- if (scan_keyword("fixed")) {
- subtype(tail) = 2;
- }
- b = scan_mathchar(umath_mathcode);
- } else {
- t = scan_mathchar(umath_mathcode);
- }
+ if (scan_keyword("fixed")) {
+ /* top */
+ subtype(tail) = 1;
+ t = scan_mathchar(umath_mathcode);
+ } else if (scan_keyword("both")) {
+ /* top bottom */
+ if (scan_keyword("fixed")) {
+ subtype(tail) = 1;
+ }
+ t = scan_mathchar(umath_mathcode);
+ if (scan_keyword("fixed")) {
+ subtype(tail) += 2;
+ }
+ b = scan_mathchar(umath_mathcode);
+ } else if (scan_keyword("bottom")) {
+ /* bottom */
+ if (scan_keyword("fixed")) {
+ subtype(tail) = 2;
+ }
+ b = scan_mathchar(umath_mathcode);
+ } else if (scan_keyword("top")) {
+ /* top */
+ if (scan_keyword("fixed")) {
+ subtype(tail) = 1;
+ }
+ t = scan_mathchar(umath_mathcode);
+ } else if (scan_keyword("overlay")) {
+ /* overlay */
+ if (scan_keyword("fixed")) {
+ subtype(tail) = 1;
+ }
+ o = scan_mathchar(umath_mathcode);
+ } else {
+ /* top */
+ t = scan_mathchar(umath_mathcode);
+ }
+ if (scan_keyword("fraction")) {
+ scan_int();
+ accentfraction(tail) = cur_val;
+ }
} else {
- confusion("math_ac");
+ confusion("mathaccent");
}
if (!(t.character_value == 0 && t.family_value == 0)) {
q = new_node(math_char_node, 0);
- accent_chr(tail) = q;
- math_character(accent_chr(tail)) = t.character_value;
+ top_accent_chr(tail) = q;
+ math_character(top_accent_chr(tail)) = t.character_value;
if ((t.class_value == var_code) && fam_in_range)
- math_fam(accent_chr(tail)) = cur_fam;
+ math_fam(top_accent_chr(tail)) = cur_fam;
else
- math_fam(accent_chr(tail)) = t.family_value;
+ math_fam(top_accent_chr(tail)) = t.family_value;
}
if (!(b.character_value == 0 && b.family_value == 0)) {
q = new_node(math_char_node, 0);
@@ -1594,6 +1682,15 @@ void math_ac(void)
else
math_fam(bot_accent_chr(tail)) = b.family_value;
}
+ if (!(o.character_value == 0 && o.family_value == 0)) {
+ q = new_node(math_char_node, 0);
+ overlay_accent_chr(tail) = q;
+ math_character(overlay_accent_chr(tail)) = o.character_value;
+ if ((o.class_value == var_code) && fam_in_range)
+ math_fam(overlay_accent_chr(tail)) = cur_fam;
+ else
+ math_fam(overlay_accent_chr(tail)) = o.family_value;
+ }
q = new_node(math_char_node, 0);
nucleus(tail) = q;
(void) scan_math(nucleus(tail), cramped_style(m_style));
@@ -1611,7 +1708,6 @@ pointer math_vcenter_group(pointer p)
return q;
}
-
@ The routine that scans the four mlists of a \.{\\mathchoice} is very
much like the routine that builds discretionary nodes.
@@ -1655,7 +1751,6 @@ void build_choices(void)
scan_left_brace();
}
-
@ Subscripts and superscripts are attached to the previous nucleus by the
action procedure called |sub_sup|.
@@ -1697,7 +1792,6 @@ void sub_sup(void)
}
}
-
@ An operation like `\.{\\over}' causes the current mlist to go into a
state of suspended animation: |incompleat_noad| points to a |fraction_noad|
that contains the mlist-so-far as its numerator, while the denominator
@@ -1711,6 +1805,7 @@ void math_fraction(void)
{
halfword c; /* the type of generalized fraction we are scanning */
pointer q;
+ halfword options = 0;
c = cur_chr;
if (incompleat_noad != null) {
const char *hlp[] = {
@@ -1734,6 +1829,11 @@ void math_fraction(void)
tail = head;
m_style = cramped_style(m_style);
+ if ((c % delimited_code) == skewed_code) {
+ q = new_node(delim_node, 0);
+ middle_delimiter(incompleat_noad) = q;
+ scan_delimiter(middle_delimiter(incompleat_noad), no_mathcode);
+ }
if (c >= delimited_code) {
q = new_node(delim_node, 0);
left_delimiter(incompleat_noad) = q;
@@ -1743,22 +1843,41 @@ void math_fraction(void)
scan_delimiter(right_delimiter(incompleat_noad), no_mathcode);
}
switch (c % delimited_code) {
- case above_code:
- scan_normal_dimen();
- thickness(incompleat_noad) = cur_val;
- break;
- case over_code:
- thickness(incompleat_noad) = default_code;
- break;
- case atop_code:
- thickness(incompleat_noad) = 0;
- break;
- } /* there are no other cases */
+ case above_code:
+ while (1) {
+ if (scan_keyword("exact")) {
+ options = options | noad_option_exact ;
+ } else {
+ break;
+ }
+ }
+ fractionoptions(incompleat_noad) = options;
+ scan_normal_dimen();
+ thickness(incompleat_noad) = cur_val;
+ break;
+ case over_code:
+ thickness(incompleat_noad) = default_code;
+ break;
+ case atop_code:
+ thickness(incompleat_noad) = 0;
+ break;
+ case skewed_code:
+ while (1) {
+ if (scan_keyword("exact")) {
+ options = options | noad_option_exact ;
+ } else if (scan_keyword("noaxis")) {
+ options = options | noad_option_no_axis ;
+ } else {
+ break;
+ }
+ }
+ fractionoptions(incompleat_noad) = options;
+ thickness(incompleat_noad) = 0;
+ break;
+ }
}
}
-
-
@ At the end of a math formula or subformula, the |fin_mlist| routine is
called upon to return a pointer to the newly completed mlist, and to
pop the nest back to the enclosing semantic level. The parameter to
@@ -1796,7 +1915,6 @@ pointer fin_mlist(pointer p)
return q;
}
-
@ Now at last we're ready to see what happens when a right brace occurs
in a math formula. Two special cases are simplified here: Braces are effectively
removed when they surround a single Ord without sub/superscripts, or when they
@@ -1863,7 +1981,6 @@ void close_math_group(pointer p)
}
}
-
@ We have dealt with all constructions of math mode except `\.{\\left}' and
`\.{\\right}', so the picture is completed by the following sections of
the program. The |middle| feature of eTeX allows one ore several \.{\\middle}
@@ -1872,12 +1989,42 @@ delimiters to appear between \.{\\left} and \.{\\right}.
@c
void math_left_right(void)
{
- halfword t; /* |left_noad_side| .. |right_noad_side| */
- pointer p; /* new noad */
- pointer q; /* resulting mlist */
- pointer r; /* temporary */
+ halfword t; /* |left_noad_side| .. |right_noad_side| */
+ pointer p; /* new noad */
+ pointer q; /* resulting mlist */
+ pointer r; /* temporary */
+ halfword ht = 0;
+ halfword dp = 0;
+ halfword options = 0;
+ halfword type = -1 ;
t = cur_chr;
- if ((t != left_noad_side) && (cur_group != math_left_group)) {
+
+ if (t > 10) {
+ /* we have \Uleft \Uright \Umiddle */
+ t = t - 10;
+ while (1) {
+ if (scan_keyword("height")) {
+ scan_dimen(false,false,false);
+ ht = cur_val ;
+ } else if (scan_keyword("depth")) {
+ scan_dimen(false,false,false);
+ dp = cur_val ;
+ } else if (scan_keyword("axis")) {
+ options = options | noad_option_axis ;
+ } else if (scan_keyword("noaxis")) {
+ options = options | noad_option_no_axis ;
+ } else if (scan_keyword("exact")) {
+ options = options | noad_option_exact ;
+ } else if (scan_keyword("class")) {
+ scan_int();
+ type = cur_val ;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if ((t != no_noad_side) && (t != left_noad_side) && (cur_group != math_left_group)) {
if (cur_group == math_shift_group) {
scan_delimiter(null, no_mathcode);
if (t == middle_noad_side) {
@@ -1902,7 +2049,24 @@ void math_left_right(void)
subtype(p) = (quarterword) t;
r = new_node(delim_node, 0);
delimiter(p) = r;
+
+ delimiterheight(p) = ht;
+ delimiterdepth(p) = dp;
+ delimiteroptions(p) = options;
+ delimiterclass(p) = type;
+ delimiteritalic(p) = 0;
+
scan_delimiter(delimiter(p), no_mathcode);
+
+ if (t == no_noad_side) {
+ tail_append(new_noad());
+ subtype(tail) = inner_noad_type;
+ r = new_node(sub_mlist_node, 0);
+ nucleus(tail) = r;
+ math_list(nucleus(tail)) = p;
+ return ;
+ }
+
if (t == left_noad_side) {
q = p;
} else {
@@ -1924,7 +2088,6 @@ void math_left_right(void)
}
}
-
@ \TeX\ gets to the following part of the program when
the first `\.\$' ending a display has been scanned.
@@ -1985,18 +2148,15 @@ static void resume_after_display(void)
}
}
-
@ The fussiest part of math mode processing occurs when a displayed formula is
being centered and placed with an optional equation number.
-
At this time we are in vertical mode (or internal vertical mode).
|p| points to the mlist for the formula.
|a| is either |null| or it points to a box containing the equation number.
|l| is true if there was an \.{\\leqno}/ (so |a| is a horizontal box).
-
@c
static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
{
@@ -2019,6 +2179,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
adjust_tail = adjust_head;
pre_adjust_tail = pre_adjust_head;
eq_box = hpack(p, 0, additional, -1);
+ subtype(eq_box) = equation_list; /* new */
+ build_attribute_list(eq_box);
p = list_ptr(eq_box);
t = adjust_tail;
adjust_tail = null;
@@ -2034,25 +2196,31 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
} else {
eqno_w = width(eqno_box);
eqno_width = eqno_w;
- eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad(text_size), 1000);
- }
+ eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad(text_size), 1000);
+ subtype(eqno_box) = equation_number_list; /* new */
+ /* build_attribute_list(eqno_box); */ /* probably already set */
+ }
if (eq_w + eqno_w2 > line_w) {
/* The user can force the equation number to go on a separate line
by causing its width to be zero. */
- if ((eqno_w != 0)
- && ((eq_w - total_shrink[normal] + eqno_w2 <= line_w)
- || (total_shrink[sfi] != 0) || (total_shrink[fil] != 0)
+ if ((eqno_w != 0) && ((eq_w - total_shrink[normal] + eqno_w2 <= line_w)
+ || (total_shrink[sfi] != 0)
+ || (total_shrink[fil] != 0)
|| (total_shrink[fill] != 0)
|| (total_shrink[filll] != 0))) {
list_ptr(eq_box) = null;
flush_node(eq_box);
eq_box = hpack(p, line_w - eqno_w2, exactly, -1);
+ subtype(eq_box) = equation_list; /* new */
+ build_attribute_list(eq_box);
} else {
eqno_w = 0;
if (eq_w > line_w) {
list_ptr(eq_box) = null;
flush_node(eq_box);
eq_box = hpack(p, line_w, exactly, -1);
+ subtype(eq_box) = equation_list; /* new */
+ build_attribute_list(eq_box);
}
}
eq_w = width(eq_box);
@@ -2092,18 +2260,29 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
/* \.{\\leqno} on a forced single line due to |width=0| */
/* it follows that |type(a)=hlist_node| */
- if (eqno_box && l && (eqno_w == 0)) {
-/* if (math_direction==dir_TLT) { */
- shift_amount(eqno_box) = 0;
-/* } else { */
-/* } */
- append_to_vlist(eqno_box);
- tail_append(new_penalty(inf_penalty));
- } else {
-
- tail_append(new_param_glue(g1));
-
+ if (eqno_box && l && (eqno_w == 0)) {
+ /* if (math_direction==dir_TLT) { */
+ shift_amount(eqno_box) = 0;
+ /* } else { */
+ /* } */
+ append_to_vlist(eqno_box,lua_key_index(equation_number));
+ tail_append(new_penalty(inf_penalty));
+ } else {
+ switch (display_skip_mode) {
+ case 0 : /* normal tex */
+ tail_append(new_param_glue(g1));
+ break;
+ case 1 : /* always */
+ tail_append(new_param_glue(g1));
+ break;
+ case 2 : /* non-zero */
+ if (g1 != 0)
+ tail_append(new_param_glue(g1));
+ break;
+ case 3: /* ignore */
+ break;
}
+ }
if (eqno_w != 0) {
r = new_kern(line_w - eq_w - eqno_w - d);
@@ -2181,38 +2360,53 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
}
}
eq_box = hpack(eq_box, 0, additional, -1);
+ subtype(eq_box) = equation_list; /* new */
+ build_attribute_list(eq_box);
shift_amount(eq_box) = line_s;
} else {
shift_amount(eq_box) = line_s + d;
}
/* check for prev: */
- append_to_vlist(eq_box);
+ append_to_vlist(eq_box,lua_key_index(equation));
if ((eqno_box != null) && (eqno_w == 0) && !l) {
tail_append(new_penalty(inf_penalty));
-/* if (math_direction==dir_TLT) { */
+ /* if (math_direction==dir_TLT) { */
shift_amount(eqno_box) = line_s + line_w - eqno_width ;
-/* } else { */
-/* } */
-/* check for prev: */
- append_to_vlist(eqno_box);
+ /* } else { */
+ /* } */
+ append_to_vlist(eqno_box,lua_key_index(equation_number));
g2 = 0;
}
if (t != adjust_head) { /* migrating material comes after equation number */
vlink(tail) = vlink(adjust_head);
-/* needs testing */
-alink(adjust_tail) = alink(tail);
+ /* needs testing */
+ alink(adjust_tail) = alink(tail);
tail = t;
}
if (pre_t != pre_adjust_head) {
vlink(tail) = vlink(pre_adjust_head);
-/* needs testing */
-alink(pre_adjust_tail) = alink(tail);
+ /* needs testing */
+ alink(pre_adjust_tail) = alink(tail);
tail = pre_t;
}
tail_append(new_penalty(int_par(post_display_penalty_code)));
- if (g2 > 0)
- tail_append(new_param_glue(g2));
+
+ switch (display_skip_mode) {
+ case 0 : /* normal tex */
+ if (g2 > 0)
+ tail_append(new_param_glue(g2));
+ break;
+ case 1 : /* always */
+ tail_append(new_param_glue(g2));
+ break;
+ case 2 : /* non-zero */
+ if (g2 != 0)
+ tail_append(new_param_glue(g2));
+ break;
+ case 3: /* ignore */
+ break;
+ }
resume_after_display();
}
@@ -2238,6 +2432,7 @@ void after_math(void)
}
run_mlist_to_hlist(p, text_style, false);
a = hpack(vlink(temp_head), 0, additional, -1);
+ build_attribute_list(a);
unsave_math();
decr(save_ptr); /* now |cur_group=math_shift_group| */
assert(saved_type(0) == saved_eqno);
@@ -2245,6 +2440,7 @@ void after_math(void)
l = true;
m = mode;
p = fin_mlist(null);
+
}
if (m < 0) {
/* The |unsave| is done after everything else here; hence an appearance of
@@ -2257,6 +2453,12 @@ void after_math(void)
check_inline_math_end();
}
tail_append(new_math(math_surround, before));
+ /* begin mathskip code */
+ if (math_skip != zero_glue) {
+ glue_ptr(tail) = math_skip;
+ add_glue_ref(math_skip);
+ }
+ /* end mathskip code */
if (dir_math_save) {
tail_append(new_dir(math_direction));
}
@@ -2265,10 +2467,16 @@ void after_math(void)
while (vlink(tail) != null)
tail = vlink(tail);
if (dir_math_save) {
- tail_append(new_dir(math_direction - 64));
+ tail_append(new_dir(math_direction - dir_swap));
}
dir_math_save = false;
tail_append(new_math(math_surround, after));
+ /* begin mathskip code */
+ if (math_skip != zero_glue) {
+ glue_ptr(tail) = math_skip;
+ add_glue_ref(math_skip);
+ }
+ /* end mathskip code */
space_factor = 1000;
unsave_math();
} else {
@@ -2284,7 +2492,6 @@ void after_math(void)
}
}
-
@ When \.{\\halign} appears in a display, the alignment routines operate
essentially as they do in vertical mode. Then the following program is
activated, with |p| and |q| pointing to the beginning and end of the
@@ -2320,10 +2527,9 @@ void setup_math_style(void)
tail_append(new_noad());
q = new_node(math_char_node, 0);
nucleus(tail) = q;
- (void) scan_math(nucleus(tail), num_style(m_style));
+ (void) scan_math_style(nucleus(tail), num_style(m_style));
}
-
@ @c
void print_math_style(void)
{
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
index 3b74f77ea29..ae6a38929c9 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -29,17 +29,15 @@
# define get_vlink(a) vlink(a)
# define get_character(a) character(a)
-extern halfword insert_discretionary(halfword t, halfword pre, halfword post,
- halfword replace, int penalty);
+extern halfword insert_discretionary(halfword t, halfword pre, halfword post, halfword replace, int penalty);
extern halfword insert_syllable_discretionary(halfword t, lang_variables * lan);
extern halfword insert_word_discretionary(halfword t, lang_variables * lan);
-extern halfword insert_complex_discretionary(halfword t, lang_variables * lan,
- halfword pre, halfword post,
- halfword replace);
+extern halfword insert_complex_discretionary(halfword t, lang_variables * lan, halfword pre, halfword post, halfword replace);
extern halfword insert_character(halfword t, int n);
extern void set_disc_field(halfword f, halfword t);
# define varmemcast(a) (memory_word *)(a)
+
extern memory_word *volatile varmem;
extern halfword var_mem_max;
@@ -49,29 +47,26 @@ extern void init_node_mem(int s);
extern void dump_node_mem(void);
extern void undump_node_mem(void);
-
# define max_halfword 0x3FFFFFFF
# define max_dimen 0x3FFFFFFF
# ifndef null
-# define null 0
+# define null 0
# endif
# define null_flag -0x40000000
-# define zero_glue 0
-# define normal 0
+# define zero_glue 0
+# define normal 0
-# define vinfo(a) varmem[(a)].hh.v.LH
-# define vlink(a) varmem[(a)].hh.v.RH
-# define type(a) varmem[(a)].hh.u.B0
-# define subtype(a) varmem[(a)].hh.u.B1
-# define node_attr(a) vinfo((a)+1)
-# define alink(a) vlink((a)+1)
+# define vinfo(a) varmem[(a)].hh.v.LH
+# define vlink(a) varmem[(a)].hh.v.RH
+# define type(a) varmem[(a)].hh.u.B0
+# define subtype(a) varmem[(a)].hh.u.B1
+# define node_attr(a) vinfo((a)+1)
+# define alink(a) vlink((a)+1)
-# define node_size(a) varmem[(a)].hh.v.LH
+# define node_size(a) varmem[(a)].hh.v.LH
-# define rlink(a) vlink((a)+1)
- /* aka alink() */
-# define llink(a) vinfo((a)+1)
- /* overlaps with node_attr() */
+# define rlink(a) vlink((a)+1) /* aka alink() */
+# define llink(a) vinfo((a)+1) /* overlaps with node_attr() */
# define add_glue_ref(a) glue_ref_count(a)++ /* new reference to a glue spec */
@@ -88,27 +83,29 @@ extern void undump_node_mem(void);
*/
# define attribute_node_size 2
+# define cache_disabled max_halfword
-
-# define attr_list_ref(a) vinfo((a)+1)
- /* the reference count */
-# define assign_attribute_ref(n,p) do { node_attr(n) = p;attr_list_ref(p)++;} while (0)
+# define attr_list_ref(a) vinfo((a)+1) /* the reference count */
# define attribute_id(a) vinfo((a)+1)
# define attribute_value(a) vlink((a)+1)
-# define cache_disabled max_halfword
-# define add_node_attr_ref(a) { if (a!=null) attr_list_ref((a))++; }
+# define assign_attribute_ref(n,p) do { \
+ node_attr(n) = p;attr_list_ref(p)++; \
+} while (0)
-# define replace_attribute_list(a,b) do { \
- delete_attribute_ref(node_attr(a)); \
- node_attr(a)=b; \
- } while (0)
+# define add_node_attr_ref(a) do { \
+ if (a!=null) attr_list_ref((a))++; \
+} while (0)
+
+# define replace_attribute_list(a,b) do { \
+ delete_attribute_ref(node_attr(a)); \
+ node_attr(a)=b; \
+} while (0)
extern void update_attribute_cache(void);
extern halfword copy_attribute_list(halfword n);
extern halfword do_set_attribute(halfword p, int i, int val);
-
/* a glue spec */
# define glue_spec_size 4
# define stretch(a) vlink((a)+1)
@@ -130,28 +127,27 @@ typedef enum {
c_leaders, /* |subtype| for centered leaders */
x_leaders, /* |subtype| for expanded leaders */
g_leaders /* |subtype| for global (page) leaders */
-} glue_subtype_codes;
+} glue_subtypes;
/* normal nodes */
-# define inf_bad 10000 /* infinitely bad value */
-# define inf_penalty inf_bad /*``infinite'' penalty value */
-# define eject_penalty -(inf_penalty) /*``negatively infinite'' penalty value */
+# define inf_bad 10000 /* infinitely bad value */
+# define inf_penalty inf_bad /* ``infinite'' penalty value */
+# define eject_penalty -(inf_penalty) /* ``negatively infinite'' penalty value */
-# define penalty_node_size 3
-# define penalty(a) vlink((a)+2)
+# define penalty_node_size 3
+# define penalty(a) vlink((a)+2)
-# define glue_node_size 4
-# define glue_ptr(a) vinfo((a)+2)
-# define leader_ptr(a) vlink((a)+2)
+# define glue_node_size 4
+# define glue_ptr(a) vinfo((a)+2)
+# define leader_ptr(a) vlink((a)+2)
# 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
- pointers are not really needed (8 instead of 10).
- */
-
-# define disc_node_size 11
+/*
+ disc nodes could eventually be smaller, because the indirect
+ pointers are not really needed (8 instead of 10).
+*/
typedef enum {
discretionary_disc = 0,
@@ -160,16 +156,17 @@ typedef enum {
syllable_disc,
init_disc, /* first of a duo of syllable_discs */
select_disc, /* second of a duo of syllable_discs */
-} discretionary_types;
+} discretionary_subtypes;
+# define disc_node_size 11
# define pre_break_head(a) ((a)+5)
# define post_break_head(a) ((a)+7)
# define no_break_head(a) ((a)+9)
-# define disc_penalty(a) vlink((a)+2)
-# define pre_break(a) vinfo((a)+3)
-# define post_break(a) vlink((a)+3)
-# define no_break(a) vlink((a)+4)
+# define disc_penalty(a) vlink((a)+2)
+# define pre_break(a) vinfo((a)+3)
+# define post_break(a) vlink((a)+3)
+# define no_break(a) vlink((a)+4)
# define tlink llink
# define vlink_pre_break(a) vlink(pre_break_head(a))
@@ -180,21 +177,27 @@ typedef enum {
# define tlink_post_break(a) tlink(post_break_head(a))
# define tlink_no_break(a) tlink(no_break_head(a))
-# define kern_node_size 5
-# define explicit 1 /*|subtype| of kern nodes from \.{\\kern} and \.{\\/} */
-# define acc_kern 2 /*|subtype| of kern nodes from accents */
-# define synctex_tag_kern(a) vinfo((a)+3)
-# define synctex_line_kern(a) vlink((a)+3)
-# define ex_kern(a) vinfo((a)+4) /* expansion factor (hz) */
+# define kern_node_size 5
+# define explicit 1 /* |subtype| of kern nodes from \.{\\kern} and \.{\\/} */
+# define acc_kern 2 /* |subtype| of kern nodes from accents */
+# define ex_kern(a) vinfo((a)+3) /* expansion factor (hz) */
+# define synctex_tag_kern(a) vinfo((a)+4)
+# define synctex_line_kern(a) vlink((a)+4)
# define box_node_size 9
-# define HLIST_SUBTYPE_UNKNOWN 0
-# define HLIST_SUBTYPE_LINE 1 /* paragraph lines */
-# define HLIST_SUBTYPE_HBOX 2 /* \.{\\hbox} */
-# define HLIST_SUBTYPE_INDENT 3 /* indentation box */
-# define HLIST_SUBTYPE_ALIGNROW 4 /* row from a \.{\\halign} or \.{\\valign} */
-# define HLIST_SUBTYPE_ALIGNCELL 5 /* cell from a \.{\\halign} or \.{\\valign} */
+/* todo, make an enum of this */
+
+typedef enum {
+ unknown_list = 0,
+ line_list = 1, /* paragraph lines */
+ hbox_list = 2, /* \.{\\hbox} */
+ indent_list = 3, /* indentation box */
+ align_row_list = 4, /* row from a \.{\\halign} or \.{\\valign} */
+ align_cell_list = 5, /* cell from a \.{\\halign} or \.{\\valign} */
+ equation_list = 6, /* display equation */
+ equation_number_list = 7, /* display equation number */
+} list_subtypes ;
# define width(a) varmem[(a)+2].cint
# define depth(a) varmem[(a)+3].cint
@@ -208,18 +211,27 @@ typedef enum {
# define synctex_tag_box(a) vinfo((a)+8)
# define synctex_line_box(a) vlink((a)+8)
-
/* unset nodes */
+
# define glue_stretch(a) varmem[(a)+7].cint
# define glue_shrink shift_amount
# define span_count subtype
-# define rule_node_size 7
-# define rule_dir(a) vlink((a)+5)
-# define synctex_tag_rule(a) vinfo((a)+6)
-# define synctex_line_rule(a) vlink((a)+6)
-
-# define mark_node_size 3
+typedef enum {
+ normal_rule = 0,
+ box_rule,
+ image_rule,
+ empty_rule,
+} rule_subtypes;
+
+# define rule_node_size 8
+# define rule_dir(a) vlink((a)+5)
+# define rule_index(a) vinfo((a)+6)
+# define rule_transform(a) vlink((a)+6)
+# define synctex_tag_rule(a) vinfo((a)+7)
+# define synctex_line_rule(a) vlink((a)+7)
+
+# define mark_node_size 3
# define mark_ptr(a) vlink((a)+2)
# define mark_class(a) vinfo((a)+2)
@@ -228,7 +240,6 @@ typedef enum {
# define adjust_ptr(a) vlink(a+2)
# define glyph_node_size 6
-
# define character(a) vinfo((a)+2)
# define font(a) vlink((a)+2)
# define lang_data(a) vinfo((a)+3)
@@ -236,17 +247,18 @@ 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 is_char_node(a) (a!=null && type(a)==glyph_node)
+
+# define is_char_node(a) (a!=null && type(a)==glyph_node)
# define char_lang(a) ((const int)(signed short)(((signed int)((unsigned)lang_data(a)&0x7FFF0000)<<1)>>17))
# define char_lhmin(a) ((const int)(((unsigned)lang_data(a) & 0x0000FF00)>>8))
# define char_rhmin(a) ((const int)(((unsigned)lang_data(a) & 0x000000FF)))
# define char_uchyph(a) ((const int)(((unsigned)lang_data(a) & 0x80000000)>>31))
-# define make_lang_data(a,b,c,d) (a>0 ? (1<<31): 0)+ \
+# define make_lang_data(a,b,c,d) (a>0 ? (1<<31): 0)+ \
(b<<16)+ (((c>0 && c<256) ? c : 255)<<8)+(((d>0 && d<256) ? d : 255))
-# define init_lang_data(a) lang_data(a)=256+1
+# define init_lang_data(a) lang_data(a)=256+1
# define set_char_lang(a,b) lang_data(a)=make_lang_data(char_uchyph(a),b,char_lhmin(a),char_rhmin(a))
# define set_char_lhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),b,char_rhmin(a))
@@ -254,61 +266,53 @@ typedef enum {
# define set_char_uchyph(a,b) lang_data(a)=make_lang_data(b,char_lang(a),char_lhmin(a),char_rhmin(a))
# define margin_kern_node_size 4
-# define margin_char(a) vlink((a)+3)
+# define margin_char(a) vlink((a)+3)
/*@# {|subtype| of marginal kerns}*/
-# define left_side 0
+
+# define left_side 0
# define right_side 1
-# define math_node_size 4
-# define surround(a) vlink((a)+2)
-# define before 0 /*|subtype| for math node that introduces a formula */
-# define after 1 /*|subtype| for math node that winds up a formula */
+# define before 0 /* |subtype| for math node that introduces a formula */
+# define after 1 /* |subtype| for math node that winds up a formula */
+
+# define math_node_size 4
+# define surround(a) vlink((a)+2)
+/* also: glue_ptr(a) vinfo((a)+2) */
# define synctex_tag_math(a) vinfo((a)+3)
# define synctex_line_math(a) vlink((a)+3)
-# define ins_node_size 6
+# define ins_node_size 6
# define float_cost(a) varmem[(a)+2].cint
# define ins_ptr(a) vinfo((a)+5)
# define split_top_ptr(a) vlink((a)+5)
-
# define page_ins_node_size 5
/* height = 4 */
typedef enum {
hlist_node = 0,
- vlist_node = 1,
+ vlist_node,
rule_node,
ins_node,
mark_node,
adjust_node,
- /* 6 used to be ligatures */
- disc_node = 7,
+ boundary_node,
+ disc_node,
whatsit_node,
math_node,
- glue_node, /* 10 */
+ glue_node,
kern_node,
penalty_node,
unset_node,
style_node,
- choice_node, /* 15 */
+ choice_node,
simple_noad,
- old_op_noad,
- old_bin_noad,
- old_rel_noad,
- old_open_noad, /* 20 */
- old_close_noad,
- old_punct_noad,
- old_inner_noad,
radical_noad,
- fraction_noad, /* 25 */
- old_under_noad,
- old_over_noad,
+ fraction_noad,
accent_noad,
- old_vcenter_noad,
- fence_noad, /* 30 */
+ fence_noad,
math_char_node, /* kernel fields */
sub_box_node,
sub_mlist_node,
@@ -318,175 +322,221 @@ typedef enum {
glyph_node,
align_record_node,
pseudo_file_node,
- pseudo_line_node, /* 40 */
+ pseudo_line_node,
inserting_node,
split_up_node,
expr_node,
nesting_node,
- span_node, /* 45 */
+ span_node,
attribute_node,
glue_spec_node,
attribute_list_node,
- action_node,
- temp_node, /* 50 */
+ temp_node,
align_stack_node,
movement_node,
if_node,
unhyphenated_node,
- hyphenated_node, /* 55 */
+ hyphenated_node,
delta_node,
passive_node,
shape_node,
+ dir_node,
+ local_par_node,
} node_types;
-# define MAX_NODE_TYPE 58
+# define MAX_NODE_TYPE 60
# define last_known_node temp_node /* used by \lastnodetype */
-# define movement_node_size 3
-# define expr_node_size 3
-# define if_node_size 2
+# define movement_node_size 3
+# define expr_node_size 3
+# define if_node_size 2
# define align_stack_node_size 6
-# define nesting_node_size 2
+# define nesting_node_size 2
-# define span_node_size 3
-# define span_span(a) vlink((a)+1)
-# define span_link(a) vinfo((a)+1)
+# define span_node_size 3
+# define span_span(a) vlink((a)+1)
+# define span_link(a) vinfo((a)+1)
# define pseudo_file_node_size 2
-# define pseudo_lines(a) vlink((a)+1)
+# define pseudo_lines(a) vlink((a)+1)
# define nodetype_has_attributes(t) (((t)<=glyph_node) && ((t)!=unset_node))
-# define nodetype_has_subtype(t) ((t)!=action_node && (t)!=attribute_list_node && (t)!=attribute_node && (t)!=glue_spec_node)
-# define nodetype_has_prev(t) nodetype_has_subtype((t))
+# define nodetype_has_subtype(t) ((t)!=attribute_list_node && (t)!=attribute_node && (t)!=glue_spec_node)
+# define nodetype_has_prev(t) nodetype_has_subtype((t))
+
+/*
+ style and choice nodes; style nodes can be smaller, the information is encoded in
+ |subtype|, but choice nodes are on-the-spot converted to style nodes
+*/
-/* style and choice nodes */
-/* style nodes can be smaller, the information is encoded in |subtype|,
- but choice nodes are on-the-spot converted to style nodes */
+# define style_node_size 4
+# define display_mlist(a) vinfo((a)+2) /* mlist to be used in display style */
+# define text_mlist(a) vlink((a)+2) /* mlist to be used in text style */
+# define script_mlist(a) vinfo((a)+3) /* mlist to be used in script style */
+# define script_script_mlist(a) vlink((a)+3) /* mlist to be used in scriptscript style */
-# define style_node_size 4 /* number of words in a style node */
+/*
+ because noad types get changed when processing we need to make sure some if the node
+ sizes match and that we don't share slots with different properties
-# define display_mlist(a) vinfo((a)+2) /* mlist to be used in display style */
-# define text_mlist(a) vlink((a)+2) /* mlist to be used in text style */
-# define script_mlist(a) vinfo((a)+3) /* mlist to be used in script style */
-# define script_script_mlist(a) vlink((a)+3) /* mlist to be used in scriptscript style */
+ once it's sorted out we can go smaller and also adapt the flush etc code to it
+*/
/* regular noads */
-# define noad_size 4 /* number of words in a normal noad */
-# define new_hlist(a) vlink((a)+2) /* the translation of an mlist */
-# define nucleus(a) vinfo((a)+2) /* the |nucleus| field of a noad */
-# define supscr(a) vlink((a)+3) /* the |supscr| field of a noad */
-# define subscr(a) vinfo((a)+3) /* the |subscr| field of a noad */
+# define noad_size 8
+# define new_hlist(a) vlink((a)+2) /* the translation of an mlist */
+# define nucleus(a) vinfo((a)+2) /* the |nucleus| field of a noad */
+# define supscr(a) vlink((a)+3) /* the |supscr| field of a noad */
+# define subscr(a) vinfo((a)+3) /* the |subscr| field of a noad */
+# define noaditalic(a) vlink((a)+4)
+# define noadwidth(a) vinfo((a)+4)
+# define noadheight(a) vlink((a)+5)
+# define noaddepth(a) vinfo((a)+5)
+# define noadextra1(a) vlink((a)+6) /* we need to match delimiter (saves copy) */
+# define noadextra2(a) vinfo((a)+6)
+# define noadextra3(a) vlink((a)+7) /* see (!) below */
+# define noadextra4(a) vinfo((a)+7)
/* accent noads */
-/* like a regular noad, but with two extra fields. */
-# define accent_noad_size 5 /*number of |mem| words in an accent noad */
-# define accent_chr(a) vinfo((a)+4) /* the |accent_chr| field of an accent noad */
-# define bot_accent_chr(a) vlink((a)+4) /* the |bot_accent_chr| field of an accent noad */
+# define accent_noad_size 8
+# define top_accent_chr(a) vinfo((a)+6) /* the |top_accent_chr| field of an accent noad */
+# define bot_accent_chr(a) vlink((a)+6) /* the |bot_accent_chr| field of an accent noad */
+# define overlay_accent_chr(a) vinfo((a)+7) /* the |overlay_accent_chr| field of an accent noad */
+# define accentfraction(a) vlink((a)+7)
/* left and right noads */
-# define fence_noad_size 3
-# define delimiter(a) vlink((a)+2) /* |delimiter| field in left and right noads */
+# define fence_noad_size 8 /* needs to match noad size */
+# define delimiteritalic(a) vlink((a)+4)
+/* define delimiterwidth(a) vinfo((a)+4) */
+# define delimiterheight(a) vlink((a)+5)
+# define delimiterdepth(a) vinfo((a)+5)
+# define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
+# define delimiteroptions(a) vinfo((a)+6)
+# define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
+# define delimiterextra1(a) vinfo((a)+7) /* not used */
+
+/* when dimensions then axis else noaxis */
+
+typedef enum {
+ noad_option_set = 0x08,
+ noad_option_unused_1 = 0x00 + 0x08,
+ noad_option_unused_2 = 0x01 + 0x08,
+ noad_option_axis = 0x02 + 0x08,
+ noad_option_no_axis = 0x04 + 0x08,
+ noad_option_exact = 0x10 + 0x08,
+ noad_option_left = 0x11 + 0x08,
+ noad_option_middle = 0x12 + 0x08,
+ noad_option_right = 0x14 + 0x08,
+} delimiter_options ;
+
+# define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
+# define delimiteraxis(a) ((delimiteroptions(a) & noad_option_axis ) == noad_option_axis )
+# define delimiternoaxis(a) ((delimiteroptions(a) & noad_option_no_axis) == noad_option_no_axis)
+# define delimiterexact(a) ((delimiteroptions(a) & noad_option_exact ) == noad_option_exact )
/* subtype of fence noads */
-# define left_noad_side 1
+# define left_noad_side 1
# define middle_noad_side 2
-# define right_noad_side 3
+# define right_noad_side 3
+# define no_noad_side 4
/* fraction noads */
-# define fraction_noad_size 5 /*number of |mem| words in a fraction noad */
-# define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */
-# define numerator(a) vlink((a)+3) /*|numerator| field in a fraction noad */
-# define denominator(a) vinfo((a)+3) /*|denominator| field in a fraction noad */
-# define left_delimiter(a) vlink((a)+4) /* first delimiter field of a noad */
-# define right_delimiter(a) vinfo((a)+4) /* second delimiter field of a fraction noad */
+# define fraction_noad_size 7
+# define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */
+# define numerator(a) vlink((a)+3) /* |numerator| field in a fraction noad */
+# define denominator(a) vinfo((a)+3) /* |denominator| field in a fraction noad */
+# define left_delimiter(a) vlink((a)+5) /* first delimiter field of a noad */
+# define right_delimiter(a) vinfo((a)+5) /* second delimiter field of a fraction noad */
+# define middle_delimiter(a) vlink((a)+6)
+# define fractionoptions(a) vinfo((a)+6)
+
+# define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set )
+# define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact )
+# define fractionnoaxis(a) ((fractionoptions(a) & noad_option_no_axis) == noad_option_no_axis)
/* radical noads */
/* this is like a fraction, but it only stores a |left_delimiter| */
-# define radical_noad_size 5 /*number of |mem| words in a radical noad */
-# define degree(a) vinfo((a)+4) /* the root degree in a radical noad */
+# define radical_noad_size 7
+# define radicalwidth(a) vinfo((a)+4)
+# define degree(a) vlink((a)+6) /* the root degree in a radical noad */
+# define radicaloptions(a) vinfo((a)+6)
-# define math_kernel_node_size 3
+# define radicaloptionset(a) ((radicaloptions(a) & noad_option_set ) == noad_option_set)
+# define radicalexact(a) ((radicaloptions(a) & noad_option_exact ) == noad_option_exact)
+# define radicalleft(a) ((radicaloptions(a) & noad_option_left ) == noad_option_left)
+# define radicalmiddle(a) ((radicaloptions(a) & noad_option_middle) == noad_option_middle)
+# define radicalright(a) ((radicaloptions(a) & noad_option_right ) == noad_option_right)
/* accessors for the |nucleus|-style node fields */
-# define math_fam(a) vinfo((a)+2)
-# define math_character(a) vlink((a)+2)
-# define math_list(a) vlink((a)+2)
+
+# define math_kernel_node_size 3
+# define math_fam(a) vinfo((a)+2)
+# define math_character(a) vlink((a)+2)
+# define math_list(a) vlink((a)+2)
/* accessors for the |delimiter|-style two-word subnode fields */
-# define math_shield_node_size 4
- /* not used yet */
+# define math_shield_node_size 4 /* not used yet */
-# define small_fam(A) vinfo((A)+2) /* |fam| for ``small'' delimiter */
-# define small_char(A) vlink((A)+2) /* |character| for ``small'' delimiter */
-# define large_fam(A) vinfo((A)+3) /* |fam| for ``large'' delimiter */
-# define large_char(A) vlink((A)+3) /* |character| for ``large'' delimiter */
+# define small_fam(A) vinfo((A)+2) /* |fam| for ``small'' delimiter */
+# define small_char(A) vlink((A)+2) /* |character| for ``small'' delimiter */
+# define large_fam(A) vinfo((A)+3) /* |fam| for ``large'' delimiter */
+# define large_char(A) vlink((A)+3) /* |character| for ``large'' delimiter */
+/* we should have the codes in a separate enum: extension_codes */
/* be careful: must be in sync with whatsit_node_data[] ! (at least) */
+
typedef enum {
+ /* core */
open_node = 0,
write_node,
close_node,
special_node,
- /*language_node, OBSOLETE*/
- /*set_language_code, OBSOLETE*/
- local_par_node=6,
- dir_node,
- pdf_literal_node,
- pdf_obj_code,
- pdf_refobj_node, /* 10 */
- pdf_xform_code,
- pdf_refxform_node,
- pdf_ximage_code,
- pdf_refximage_node,
+ use_box_resource_node,
+ use_image_resource_node,
+ save_pos_node,
+ late_lua_node,
+ user_defined_node,
+ /* dvi backend */
+ dvi_literal_node = 15,
+ /* pdf backend */
+ pdf_literal_node = 16,
+ pdf_refobj_node,
pdf_annot_node,
pdf_start_link_node,
pdf_end_link_node,
- pdf_outline_code,
pdf_dest_node,
- pdf_thread_node, /* 20 */
+ pdf_action_node,
+ pdf_thread_node,
pdf_start_thread_node,
pdf_end_thread_node,
- save_pos_node,
pdf_thread_data_node,
pdf_link_data_node,
- pdf_names_code,
- pdf_font_attr_code,
- pdf_include_chars_code,
- pdf_map_file_code,
- pdf_map_line_code, /* 30 */
- pdf_trailer_code,
- font_expand_code,
- set_random_seed_code,
- pdf_glyph_to_unicode_code,
- late_lua_node, /* 35 */
- save_cat_code_table_code =37,
- init_cat_code_table_code,
pdf_colorstack_node,
- pdf_setmatrix_node, /*40 */
+ pdf_setmatrix_node,
pdf_save_node,
pdf_restore_node,
- cancel_boundary_node,
- user_defined_node /* 44 */
} whatsit_types;
-# define MAX_WHATSIT_TYPE 44
+# define backend_first_dvi_whatsit 15
+# define backend_last_dvi_whatsit 15
+# define backend_first_pdf_whatsit 16
+# define backend_last_pdf_whatsit 31
-# define get_node_size(i,j) (i!=whatsit_node ? node_data[i].size : whatsit_node_data[j].size)
-# define get_node_name(i,j) (i!=whatsit_node ? node_data[i].name : whatsit_node_data[j].name)
+# define MAX_WHATSIT_TYPE 32
-
-# define pdf_info_code pdf_thread_data_node
-# define pdf_catalog_code pdf_link_data_node
+# define get_node_size(i,j) (i!=whatsit_node ? node_data[i].size : whatsit_node_data[j].size)
+# define get_node_name(i,j) (i!=whatsit_node ? node_data[i].name : whatsit_node_data[j].name)
+# define get_etex_code(i) (node_data[i].etex)
# define GLYPH_CHARACTER (1 << 0)
# define GLYPH_LIGATURE (1 << 1)
@@ -500,10 +550,11 @@ typedef enum {
# define is_simple_character(p) (is_character(p) && !is_ligature(p) && !is_ghost(p))
-# define is_leftboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_LEFT ))
+# define is_leftboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_LEFT ))
# define is_rightboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_RIGHT ))
-# define is_leftghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_LEFT ))
-# define is_rightghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_RIGHT ))
+# define is_leftghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_LEFT ))
+# define is_rightghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_RIGHT ))
+
# define set_is_glyph(p) subtype(p) = (quarterword) (subtype(p) & ~GLYPH_CHARACTER)
# define set_is_character(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_CHARACTER)
@@ -520,6 +571,13 @@ typedef enum {
# define set_is_leftghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_LEFT; }
# define set_is_rightghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_RIGHT; }
+typedef enum {
+ cancel_boundary = 0,
+ user_boundary
+} boundary_subtypes ;
+
+# define boundary_size 3
+# define boundary_value(a) vinfo((a)+2)
# define special_node_size 3
@@ -551,7 +609,6 @@ typedef enum {
# define save_pos_node_size 3
-
# define local_par_size 6
# define local_pen_inter(a) vinfo((a)+2)
@@ -562,9 +619,11 @@ typedef enum {
# define local_box_right_width(a) vinfo((a)+4)
# define local_par_dir(a) vinfo((a)+5)
-
/* type of literal data */
-# define lua_refid_literal 1 /* not a |normal| string */
+
+# define lua_refid_literal 1 /* not a |normal| string */
+
+/* begin of pdf backend nodes */
/* literal ctm types */
@@ -575,44 +634,39 @@ typedef enum {
scan_special,
} ctm_transform_modes;
-
# define pdf_refobj_node_size 3
-# define pdf_obj_objnum(a) vinfo((a) + 2)
+# define pdf_obj_objnum(a) vinfo((a) + 2)
-# define pdf_refxform_node_size 6
-# define pdf_refximage_node_size 6
# define pdf_annot_node_size 8
# define pdf_dest_node_size 8
# define pdf_thread_node_size 8
/*
-when a whatsit node representing annotation is created, words |1..3| are
-width, height and depth of this annotation; after shipping out words |1..4|
-are rectangle specification of annotation. For whatsit node representing
-destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinations
+ when a whatsit node representing annotation is created, words |1..3| are
+ width, height and depth of this annotation; after shipping out words |1..4|
+ are rectangle specification of annotation. For whatsit node representing
+ destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinations
*/
-/* coordinates of destinations/threads/annotations (in whatsit node) */
-# define pdf_ann_left(a) varmem[(a) + 2].cint
-# define pdf_ann_top(a) varmem[(a) + 3].cint
-# define pdf_ann_right(a) varmem[(a) + 4].cint
-# define pdf_ann_bottom(a) varmem[(a) + 5].cint
+/*
+ coordinates of destinations/threads/annotations (in whatsit node)
+*/
-# define pdf_literal_data(a) vlink((a)+2)
-# define pdf_literal_mode(a) type((a)+2)
-# define pdf_literal_type(a) subtype((a)+2)
+# define pdf_ann_left(a) varmem[(a) + 2].cint
+# define pdf_ann_top(a) varmem[(a) + 3].cint
+# define pdf_ann_right(a) varmem[(a) + 4].cint
+# define pdf_ann_bottom(a) varmem[(a) + 5].cint
-# define pdf_ximage_index(a) vinfo((a) + 5) /* /Im* number and image index in array */
-# define pdf_ximage_transform(a) vlink((a) + 5)
-# define pdf_xform_objnum(a) vinfo((a) + 5)
-# define pdf_xform_transform(a) vlink((a) + 5)
+# define pdf_literal_data(a) vlink((a)+2)
+# define pdf_literal_mode(a) type((a)+2)
+# define pdf_literal_type(a) subtype((a)+2)
-# define pdf_annot_data(a) vinfo((a) + 6)
-# define pdf_link_attr(a) vinfo((a) + 6)
-# define pdf_link_action(a) vlink((a) + 6)
-# define pdf_annot_objnum(a) varmem[(a) + 7].cint
-# define pdf_link_objnum(a) varmem[(a) + 7].cint
+# define pdf_annot_data(a) vinfo((a) + 6)
+# define pdf_link_attr(a) vinfo((a) + 6)
+# define pdf_link_action(a) vlink((a) + 6)
+# define pdf_annot_objnum(a) varmem[(a) + 7].cint
+# define pdf_link_objnum(a) varmem[(a) + 7].cint
# define pdf_dest_type(a) type((a) + 6)
# define pdf_dest_named_id(a) subtype((a) + 6)
@@ -624,19 +678,41 @@ destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinat
# define pdf_thread_id(a) vlink((a) + 6)
# define pdf_thread_attr(a) vinfo((a) + 7)
-# define pdf_end_link_node_size 3
-# define pdf_end_thread_node_size 3
+# define pdf_end_link_node_size 3
+# define pdf_end_thread_node_size 3
-# define pdf_colorstack_node_size 4
-# define pdf_setmatrix_node_size 3
+# define pdf_setmatrix_node_size 3
+# define pdf_save_node_size 3
+# define pdf_restore_node_size 3
-# define pdf_colorstack_stack(a) vlink((a)+2)
-# define pdf_colorstack_cmd(a) vinfo((a)+2)
-# define pdf_colorstack_data(a) vlink((a)+3)
-# define pdf_setmatrix_data(a) vlink((a)+2)
+# define pdf_colorstack_node_size 4
+# define pdf_colorstack_stack(a) vlink((a)+2)
+# define pdf_colorstack_cmd(a) vinfo((a)+2)
+# define pdf_colorstack_data(a) vlink((a)+3)
+# define pdf_setmatrix_data(a) vlink((a)+2)
-# define pdf_save_node_size 3
-# define pdf_restore_node_size 3
+typedef enum {
+ pdf_action_page = 0,
+ pdf_action_goto,
+ pdf_action_thread,
+ pdf_action_user
+} pdf_action_type;
+
+typedef enum {
+ pdf_window_notset,
+ pdf_window_new,
+ pdf_window_nonew,
+} pdf_window_type;
+
+# define pdf_action_size 6
+
+# define pdf_action_type(a) vlink((a)+2) /* enum pdf_action_type */
+# define pdf_action_named_id(a) vinfo((a)+2) /* boolean */
+# define pdf_action_id(a) vlink((a)+3) /* number or toks */
+# define pdf_action_file(a) vinfo((a)+3) /* toks */
+# define pdf_action_new_window(a) vlink((a)+4) /* enum pdf_window_type */
+# define pdf_action_tokens(a) vinfo((a)+4) /* toks */
+# define pdf_action_refcount(a) vlink((a)+5) /* number */
typedef enum {
colorstack_set = 0,
@@ -645,22 +721,26 @@ typedef enum {
colorstack_current
} colorstack_commands;
-# define colorstack_data colorstack_push /* last value where data field is set */
+# define colorstack_data colorstack_push /* last value where data field is set */
+
+/* end of pdf backend nodes */
+
+/* user defined nodes */
# define user_defined_node_size 4
# define user_node_type(a) vinfo((a)+2)
# define user_node_id(a) vlink((a)+2)
# define user_node_value(a) vinfo((a)+3)
-# define cancel_boundary_size 3
+/* node sused in the parbuilder */
-# define active_node_size 4 /*number of words in extended active nodes */
-# define fitness subtype /*|very_loose_fit..tight_fit| on final line for this break */
-# define break_node(a) vlink((a)+1) /*pointer to the corresponding passive node */
-# define line_number(a) vinfo((a)+1) /*line that begins at this breakpoint */
+# define active_node_size 4 /*number of words in extended active nodes */
+# define fitness subtype /*|very_loose_fit..tight_fit| on final line for this break */
+# define break_node(a) vlink((a)+1) /*pointer to the corresponding passive node */
+# define line_number(a) vinfo((a)+1) /*line that begins at this breakpoint */
# define total_demerits(a) varmem[(a)+2].cint /* the quantity that \TeX\ minimizes */
-# define active_short(a) vinfo(a+3) /* |shortfall| of this line */
-# define active_glue(a) vlink(a+3) /*corresponding glue stretch or shrink */
+# define active_short(a) vinfo(a+3) /* |shortfall| of this line */
+# define active_glue(a) vlink(a+3) /*corresponding glue stretch or shrink */
# define passive_node_size 7
# define cur_break(a) vlink((a)+1) /*in passive node, points to position of this breakpoint */
@@ -675,7 +755,9 @@ typedef enum {
# define passive_right_box_width(a) vinfo((a)+5)
# define serial(a) vlink((a)+6) /* serial number for symbolic identification */
-# define delta_node_size 10 /* 8 fields, stored in a+1..9 */
+# define delta_node_size 10 /* 8 fields, stored in a+1..9 */
+
+/* helpers */
# define couple_nodes(a,b) {assert(b!=null);vlink(a)=b;alink(b)=a;}
# define try_couple_nodes(a,b) if (b==null) vlink(a)=b; else {couple_nodes(a,b);}
@@ -684,8 +766,8 @@ typedef enum {
# define cache_disabled max_halfword
extern void delete_attribute_ref(halfword b);
+extern void reset_node_properties(halfword b);
extern void reassign_attribute(halfword n,halfword new);
-extern void delete_attribute_ref(halfword b);
extern void build_attribute_list(halfword b);
extern halfword current_attribute_list(void);
@@ -693,19 +775,30 @@ extern int unset_attribute(halfword n, int c, int w);
extern void set_attribute(halfword n, int c, int w);
extern int has_attribute(halfword n, int c, int w);
-
extern halfword new_span_node(halfword n, int c, scaled w);
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
+ quite the same as in tex82
+*/
+
+/*
+
+# define precedes_break(a) \
+# (type((a))<math_node && (type(a)!=whatsit_node || (subtype(a)!=dir_node && subtype(a)!=local_par_node)))
+
+*/
-/* TH: these two defines still need checking. The node ordering in luatex is not
- quite the same as in tex82 */
+/*
+ so what comes before math (as we have put dir_node and local_par_node to the end)
+*/
+
+# define precedes_break(a) (type((a))<math_node)
-# define precedes_break(a) (type((a))<math_node && \
- (type(a)!=whatsit_node || (subtype(a)!=dir_node && subtype(a)!=local_par_node)))
# define non_discardable(a) (type((a))<math_node)
/* from luanode.c */
@@ -715,10 +808,31 @@ typedef struct _node_info {
int size;
const char **fields;
const char *name;
+ int etex;
} node_info;
extern node_info node_data[];
extern node_info whatsit_node_data[];
+
+extern const char *node_subtypes_glue[];
+extern const char *node_subtypes_leader[];
+extern const char *node_subtypes_fill[];
+extern const char *node_subtypes_penalty[];
+extern const char *node_subtypes_kern[];
+extern const char *node_subtypes_rule[];
+extern const char *node_subtypes_glyph[];
+extern const char *node_subtypes_disc[];
+extern const char *node_subtypes_marginkern[];
+extern const char *node_subtypes_list[];
+extern const char *node_subtypes_math[];
+extern const char *node_subtypes_noad[];
+extern const char *node_subtypes_radical[];
+extern const char *node_subtypes_accent[];
+extern const char *node_subtypes_fence[];
+
+extern const char *node_subtypes_pdf_destination[];
+extern const char *node_subtypes_pdf_literal[];
+
extern halfword new_node(int i, int j);
extern void flush_node_list(halfword);
extern void flush_node(halfword);
@@ -734,6 +848,15 @@ extern halfword raw_glyph_node(void);
extern halfword new_glyph_node(void);
extern int valid_node(halfword);
+extern void flush_node_wrapup_dvi(halfword);
+extern void flush_node_wrapup_pdf(halfword);
+extern void copy_node_wrapup_dvi(halfword, halfword); /* original target */
+extern void copy_node_wrapup_pdf(halfword, halfword); /* original target */
+extern void check_node_wrapup_dvi(halfword);
+extern void check_node_wrapup_pdf(halfword);
+extern void show_node_wrapup_dvi(halfword);
+extern void show_node_wrapup_pdf(halfword);
+
typedef enum {
normal_g = 0,
sfi,
@@ -742,24 +865,24 @@ typedef enum {
filll
} glue_orders;
-# define zero_glue 0
-# define sfi_glue zero_glue+glue_spec_size
-# define fil_glue sfi_glue+glue_spec_size
-# define fill_glue fil_glue+glue_spec_size
-# 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
-# define hold_head temp_head+temp_node_size
-# define adjust_head hold_head+temp_node_size
-# define pre_adjust_head adjust_head+temp_node_size
-# define active pre_adjust_head+temp_node_size
-# define align_head active+active_node_size
-# define end_span align_head+temp_node_size
-# define begin_point end_span+span_node_size
-# define end_point begin_point+glyph_node_size
+# define zero_glue 0
+# define sfi_glue zero_glue+glue_spec_size
+# define fil_glue sfi_glue+glue_spec_size
+# define fill_glue fil_glue+glue_spec_size
+# 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
+# define hold_head temp_head+temp_node_size
+# define adjust_head hold_head+temp_node_size
+# define pre_adjust_head adjust_head+temp_node_size
+# define active pre_adjust_head+temp_node_size
+# define align_head active+active_node_size
+# define end_span align_head+temp_node_size
+# define begin_point end_span+span_node_size
+# define end_point begin_point+glyph_node_size
# define var_mem_stat_max (end_point+glyph_node_size-1)
# define stretching 1
@@ -779,7 +902,7 @@ extern int max_used_attr;
extern halfword attr_list_cache;
extern halfword new_null_box(void);
-extern halfword new_rule(void);
+extern halfword new_rule(int s);
extern halfword new_glyph(int f, int c);
extern quarterword norm_min(int h);
extern halfword new_char(int f, int c);
@@ -799,5 +922,13 @@ extern int lua_properties_enabled ;
extern int lua_properties_level ;
extern int lua_properties_use_metatable ;
+#define local_inter_line_penalty int_par(local_inter_line_penalty_code)
+#define local_broken_penalty int_par(local_broken_penalty_code)
+#define local_left_box equiv(local_left_box_base)
+#define local_right_box equiv(local_right_box_base)
+#define par_direction int_par(par_direction_code)
+
+extern halfword make_local_par_node(void);
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
index d7f03865d1a..5dac909c7b9 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
@@ -17,6 +17,8 @@
% You should have received a copy of the GNU General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
+% hh: Here the backend nodes are still interwoven .. when I'm in the mood...
+
@ @c
@@ -68,269 +70,358 @@ int copy_error(halfword p); /* define below */
#define variable_node_size 2
-const char *node_fields_list[] =
- { "attr", "width", "depth", "height", "dir", "shift",
- "glue_order", "glue_sign", "glue_set", "head", NULL
-};
-const char *node_fields_rule[] =
- { "attr", "width", "depth", "height", "dir", NULL };
-const char *node_fields_insert[] =
- { "attr", "cost", "depth", "height", "spec", "head", NULL };
-const char *node_fields_mark[] = { "attr", "class", "mark", NULL };
-const char *node_fields_adjust[] = { "attr", "head", NULL };
-const char *node_fields_disc[] = { "attr", "pre", "post", "replace", "penalty", NULL };
-const char *node_fields_math[] = { "attr", "surround", NULL };
-const char *node_fields_glue[] = { "attr", "spec", "leader", NULL };
-const char *node_fields_kern[] = { "attr", "kern", "expansion_factor", NULL };
-const char *node_fields_penalty[] = { "attr", "penalty", NULL };
-
-const char *node_fields_unset[] =
- { "attr", "width", "depth", "height", "dir", "shrink",
- "glue_order", "glue_sign", "stretch", "span", "head", NULL
-};
-const char *node_fields_margin_kern[] = { "attr", "width", "glyph", NULL };
-
-const char *node_fields_glyph[] =
- { "attr", "char", "font", "lang", "left", "right", "uchyph",
- "components", "xoffset", "yoffset", "width", "height", "depth", "expansion_factor", NULL
-};
-const char *node_fields_style[] = { "attr", "style", NULL };
-const char *node_fields_choice[] =
- { "attr", "display", "text", "script", "scriptscript", NULL };
-const char *node_fields_ord[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_op[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_bin[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_rel[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_open[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_close[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_punct[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_inner[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_under[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_over[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_vcenter[] = { "attr", "nucleus", "sub", "sup", NULL };
-const char *node_fields_radical[] =
- { "attr", "nucleus", "sub", "sup", "left", "degree", NULL };
-const char *node_fields_fraction[] =
- { "attr", "width", "num", "denom", "left", "right", NULL };
-const char *node_fields_accent[] =
- { "attr", "nucleus", "sub", "sup", "accent", "bot_accent", NULL };
-const char *node_fields_fence[] = { "attr", "delim", NULL };
-const char *node_fields_math_char[] = { "attr", "fam", "char", NULL };
-const char *node_fields_sub_box[] = { "attr", "head", NULL };
-const char *node_fields_sub_mlist[] = { "attr", "head", NULL };
-const char *node_fields_math_text_char[] = { "attr", "fam", "char", NULL };
-const char *node_fields_delim[] =
- { "attr", "small_fam", "small_char", "large_fam", "large_char", NULL };
-
-const char *node_fields_inserting[] =
- { "height", "last_ins_ptr", "best_ins_ptr", NULL };
-
-const char *node_fields_splitup[] = { "height", "last_ins_ptr", "best_ins_ptr",
- "broken_ptr", "broken_ins", NULL
-};
-
-const char *node_fields_action[] = { "action_type", "named_id", "action_id",
- "file", "new_window", "data", "ref_count", NULL
-};
-const char *node_fields_attribute[] = { "number", "value", NULL };
-
-const char *node_fields_glue_spec[] = { "width", "stretch", "shrink",
- "stretch_order", "shrink_order", "ref_count", "writable", NULL
-};
-const char *node_fields_attribute_list[] = { NULL };
-
-const char *node_fields_whatsit_open[] =
- { "attr", "stream", "name", "area", "ext", NULL };
-const char *node_fields_whatsit_write[] = { "attr", "stream", "data", NULL };
-const char *node_fields_whatsit_close[] = { "attr", "stream", NULL };
-const char *node_fields_whatsit_special[] = { "attr", "data", NULL };
-
-const char *node_fields_whatsit_local_par[] =
- { "attr", "pen_inter", "pen_broken", "dir",
- "box_left", "box_left_width", "box_right", "box_right_width", NULL
-};
-const char *node_fields_whatsit_dir[] =
- { "attr", "dir", "level", "dvi_ptr", "dvi_h", NULL };
-
-const char *node_fields_whatsit_pdf_literal[] =
- { "attr", "mode", "data", NULL };
-const char *node_fields_whatsit_pdf_refobj[] = { "attr", "objnum", NULL };
-const char *node_fields_whatsit_pdf_refxform[] =
- { "attr", "width", "depth", "height", "objnum", NULL };
-const char *node_fields_whatsit_pdf_refximage[] =
- { "attr", "width", "depth", "height", "transform", "index", NULL };
-const char *node_fields_whatsit_pdf_annot[] =
- { "attr", "width", "depth", "height", "objnum", "data", NULL };
-const char *node_fields_whatsit_pdf_start_link[] =
- { "attr", "width", "depth", "height",
- "objnum", "link_attr", "action", NULL
-};
-const char *node_fields_whatsit_pdf_end_link[] = { "attr", NULL };
-
-const char *node_fields_whatsit_pdf_dest[] =
- { "attr", "width", "depth", "height",
- "named_id", "dest_id", "dest_type", "xyz_zoom", "objnum", NULL
-};
-
-const char *node_fields_whatsit_pdf_thread[] =
- { "attr", "width", "depth", "height",
- "named_id", "thread_id", "thread_attr", NULL
-};
-
-const char *node_fields_whatsit_pdf_start_thread[] =
- { "attr", "width", "depth", "height",
- "named_id", "thread_id", "thread_attr", NULL
-};
-const char *node_fields_whatsit_pdf_end_thread[] = { "attr", NULL };
-const char *node_fields_whatsit_save_pos[] = { "attr", NULL };
-const char *node_fields_whatsit_late_lua[] =
- { "attr", "reg", "data", "name", "string", NULL };
-const char *node_fields_whatsit_pdf_colorstack[] =
- { "attr", "stack", "cmd", "data", NULL };
-const char *node_fields_whatsit_pdf_setmatrix[] = { "attr", "data", NULL };
-const char *node_fields_whatsit_pdf_save[] = { "attr", NULL };
-const char *node_fields_whatsit_pdf_restore[] = { "attr", NULL };
-const char *node_fields_whatsit_cancel_boundary[] = { "attr", NULL };
-const char *node_fields_whatsit_user_defined[] =
- { "attr", "user_id", "type", "value", NULL };
-
-node_info node_data[] = {
- {hlist_node, box_node_size, node_fields_list, "hlist"},
- {vlist_node, box_node_size, node_fields_list, "vlist"},
- {rule_node, rule_node_size, node_fields_rule, "rule"},
- {ins_node, ins_node_size, node_fields_insert, "ins"},
- {mark_node, mark_node_size, node_fields_mark, "mark"},
- {adjust_node, adjust_node_size, node_fields_adjust, "adjust"},
- {fake_node, fake_node_size, NULL, fake_node_name}, /* don't touch this! */
- {disc_node, disc_node_size, node_fields_disc, "disc"},
- {whatsit_node, -1, NULL, "whatsit"},
- {math_node, math_node_size, node_fields_math, "math"},
- {glue_node, glue_node_size, node_fields_glue, "glue"},
- {kern_node, kern_node_size, node_fields_kern, "kern"},
- {penalty_node, penalty_node_size, node_fields_penalty, "penalty"},
- {unset_node, box_node_size, node_fields_unset, "unset"},
- {style_node, style_node_size, node_fields_style, "style"},
- {choice_node, style_node_size, node_fields_choice, "choice"},
- {simple_noad, noad_size, node_fields_ord, "noad"},
- {old_op_noad, noad_size, node_fields_op, "op"},
- {old_bin_noad, noad_size, node_fields_bin, "bin"},
- {old_rel_noad, noad_size, node_fields_rel, "rel"},
- {old_open_noad, noad_size, node_fields_open, "open"},
- {old_close_noad, noad_size, node_fields_close, "close"},
- {old_punct_noad, noad_size, node_fields_punct, "punct"},
- {old_inner_noad, noad_size, node_fields_inner, "inner"},
- {radical_noad, radical_noad_size, node_fields_radical, "radical"},
- {fraction_noad, fraction_noad_size, node_fields_fraction, "fraction"},
- {old_under_noad, noad_size, node_fields_under, "under"},
- {old_over_noad, noad_size, node_fields_over, "over"},
- {accent_noad, accent_noad_size, node_fields_accent, "accent"},
- {old_vcenter_noad, noad_size, node_fields_vcenter, "vcenter"},
- {fence_noad, fence_noad_size, node_fields_fence, "fence"},
- {math_char_node, math_kernel_node_size, node_fields_math_char, "math_char"},
- {sub_box_node, math_kernel_node_size, node_fields_sub_box, "sub_box"},
- {sub_mlist_node, math_kernel_node_size, node_fields_sub_mlist, "sub_mlist"},
- {math_text_char_node, math_kernel_node_size, node_fields_math_text_char, "math_text_char"},
- {delim_node, math_shield_node_size, node_fields_delim, "delim"},
- {margin_kern_node, margin_kern_node_size, node_fields_margin_kern, "margin_kern"},
- {glyph_node, glyph_node_size, node_fields_glyph, "glyph"},
- {align_record_node, box_node_size, NULL, "align_record"},
- {pseudo_file_node, pseudo_file_node_size, NULL, "pseudo_file"},
- {pseudo_line_node, variable_node_size, NULL, "pseudo_line"},
- {inserting_node, page_ins_node_size, node_fields_inserting, "page_insert"},
- {split_up_node, page_ins_node_size, node_fields_splitup, "split_insert"},
- {expr_node, expr_node_size, NULL, "expr_stack"},
- {nesting_node, nesting_node_size, NULL, "nested_list"},
- {span_node, span_node_size, NULL, "span"},
- {attribute_node, attribute_node_size, node_fields_attribute, "attribute"},
- {glue_spec_node, glue_spec_size, node_fields_glue_spec, "glue_spec"},
- {attribute_list_node, attribute_node_size, node_fields_attribute_list, "attribute_list"},
- {action_node, pdf_action_size, node_fields_action, "action"},
- {temp_node, temp_node_size, NULL, "temp"},
- {align_stack_node, align_stack_node_size, NULL, "align_stack"},
- {movement_node, movement_node_size, NULL, "movement_stack"},
- {if_node, if_node_size, NULL, "if_stack"},
- {unhyphenated_node, active_node_size, NULL, "unhyphenated"},
- {hyphenated_node, active_node_size, NULL, "hyphenated"},
- {delta_node, delta_node_size, NULL, "delta"},
- {passive_node, passive_node_size, NULL, "passive"},
- {shape_node, variable_node_size, NULL, "shape"},
- {-1, -1, NULL, NULL}
-};
-
-#define last_normal_node shape_node
+/* core nodes */
+
+const char *node_fields_list[] = {
+ "attr", "width", "depth", "height", "dir", "shift", "glue_order", "glue_sign",
+ "glue_set", "head", NULL
+};
+const char *node_fields_rule[] = {
+ "attr", "width", "depth", "height", "dir", "index", NULL
+};
+const char *node_fields_insert[] = {
+ "attr", "cost", "depth", "height", "spec", "head", NULL
+};
+const char *node_fields_mark[] = {
+ "attr", "class", "mark", NULL
+};
+const char *node_fields_adjust[] = {
+ "attr", "head", NULL
+};
+const char *node_fields_disc[] = {
+ "attr", "pre", "post", "replace", "penalty", NULL
+};
+const char *node_fields_math[] = {
+ "attr", "surround", NULL
+};
+const char *node_fields_glue[] = {
+ "attr", "spec", "leader", NULL
+};
+const char *node_fields_kern[] = {
+ "attr", "kern", "expansion_factor", NULL
+};
+const char *node_fields_penalty[] = {
+ "attr", "penalty", NULL
+};
+const char *node_fields_unset[] = {
+ "attr", "width", "depth", "height", "dir", "shrink", "glue_order",
+ "glue_sign", "stretch", "span", "head", NULL
+};
+const char *node_fields_margin_kern[] = {
+ "attr", "width", "glyph", NULL
+};
+const char *node_fields_glyph[] = {
+ "attr", "char", "font", "lang", "left", "right", "uchyph", "components",
+ "xoffset", "yoffset", "width", "height", "depth", "expansion_factor", NULL
+};
+const char *node_fields_inserting[] = {
+ "height", "last_ins_ptr", "best_ins_ptr", NULL
+};
+const char *node_fields_splitup[] = {
+ "height", "last_ins_ptr", "best_ins_ptr", "broken_ptr", "broken_ins", NULL
+};
+const char *node_fields_attribute[] = {
+ "number", "value", NULL
+};
+const char *node_fields_glue_spec[] = {
+ "width", "stretch", "shrink", "stretch_order", "shrink_order", "ref_count",
+ "writable", NULL
+};
+const char *node_fields_attribute_list[] = {
+ NULL
+};
+const char *node_fields_local_par[] = {
+ "attr", "pen_inter", "pen_broken", "dir", "box_left", "box_left_width",
+ "box_right", "box_right_width", NULL
+};
+const char *node_fields_dir[] = {
+ "attr", "dir", "level", "dvi_ptr", "dvi_h", NULL
+};
+const char *node_fields_boundary[] = {
+ "attr", "value", NULL
+};
+
+/* math nodes */
+
+const char *node_fields_noad[] = {
+ "attr", "nucleus", "sub", "sup", NULL
+};
+
+#define node_fields_ord node_fields_noad
+#define node_fields_op node_fields_noad
+#define node_fields_bin node_fields_noad
+#define node_fields_rel node_fields_noad
+#define node_fields_open node_fields_noad
+#define node_fields_close node_fields_noad
+#define node_fields_punct node_fields_noad
+#define node_fields_inner node_fields_noad
+#define node_fields_under node_fields_noad
+#define node_fields_over node_fields_noad
+#define node_fields_vcenter node_fields_noad
+
+const char *node_fields_style[] = {
+ "attr", "style", NULL
+};
+const char *node_fields_choice[] = {
+ "attr", "display", "text", "script", "scriptscript", NULL
+};
+const char *node_fields_radical[] = {
+ "attr", "nucleus", "sub", "sup", "left", "degree", NULL
+};
+const char *node_fields_fraction[] = {
+ "attr", "width", "num", "denom", "left", "right", NULL
+};
+const char *node_fields_accent[] = {
+ "attr", "nucleus", "sub", "sup", "accent", "bot_accent", "top_accent",
+ "overlay_accent", NULL
+};
+const char *node_fields_fence[] = {
+ "attr", "delim", NULL
+};
+const char *node_fields_math_char[] = {
+ "attr", "fam", "char", NULL
+};
+const char *node_fields_sub_box[] = {
+ "attr", "head", NULL
+};
+const char *node_fields_sub_mlist[] = {
+ "attr", "head", NULL
+};
+const char *node_fields_math_text_char[] = {
+ "attr", "fam", "char", NULL
+};
+const char *node_fields_delim[] = {
+ "attr", "small_fam", "small_char", "large_fam", "large_char", NULL
+};
+
+/* whatsit nodes */
+
+const char *node_fields_whatsit_open[] = {
+ "attr", "stream", "name", "area", "ext", NULL
+};
+const char *node_fields_whatsit_write[] = {
+ "attr", "stream", "data", NULL
+};
+const char *node_fields_whatsit_close[] = {
+ "attr", "stream", NULL
+};
+const char *node_fields_whatsit_special[] = {
+ "attr", "data", NULL
+};
+const char *node_fields_whatsit_save_pos[] = {
+ "attr", NULL
+};
+const char *node_fields_whatsit_late_lua[] = {
+ "attr", "reg", "data", "name", "string", NULL
+};
+const char *node_fields_whatsit_user_defined[] = {
+ "attr", "user_id", "type", "value", NULL
+};
+
+/* pdf backend whatsit nodes */
+
+const char *node_fields_whatsit_pdf_literal[] = {
+ "attr", "mode", "data", NULL
+};
+const char *node_fields_whatsit_pdf_refobj[] = {
+ "attr", "objnum", NULL
+};
+const char *node_fields_whatsit_pdf_annot[] = {
+ "attr", "width", "depth", "height", "objnum", "data", NULL
+};
+const char *node_fields_whatsit_pdf_start_link[] = {
+ "attr", "width", "depth", "height", "objnum", "link_attr", "action", NULL
+};
+const char *node_fields_whatsit_pdf_end_link[] = {
+ "attr", NULL
+};
+const char *node_fields_whatsit_pdf_dest[] = {
+ "attr", "width", "depth", "height", "named_id", "dest_id", "dest_type",
+ "xyz_zoom", "objnum", NULL
+};
+const char *node_fields_whatsit_pdf_action[] = {
+ "action_type", "named_id", "action_id", "file", "new_window", "data",
+ "ref_count", NULL
+};
+const char *node_fields_whatsit_pdf_thread[] = {
+ "attr", "width", "depth", "height", "named_id", "thread_id", "thread_attr", NULL
+};
+const char *node_fields_whatsit_pdf_start_thread[] = {
+ "attr", "width", "depth", "height", "named_id", "thread_id", "thread_attr", NULL
+};
+const char *node_fields_whatsit_pdf_end_thread[] = {
+ "attr", NULL
+};
+const char *node_fields_whatsit_pdf_colorstack[] = {
+ "attr", "stack", "cmd", "data", NULL
+};
+const char *node_fields_whatsit_pdf_setmatrix[] = {
+ "attr", "data", NULL
+};
+const char *node_fields_whatsit_pdf_save[] = {
+ "attr", NULL
+};
+const char *node_fields_whatsit_pdf_restore[] = {
+ "attr", NULL
+};
+
+/* subtypes */
+
+const char *node_subtypes_glue[] = {
+ "userskip", "lineskip", "baselineskip", "parskip", "abovedisplayskip", "belowdisplayskip",
+ "abovedisplayshortskip", "belowdisplayshortskip", "leftskip", "rightskip", "topskip",
+ "splittopskip", "tabskip", "spaceskip", "xspaceskip", "parfillskip", "thinmuskip",
+ "medmuskip", "thickmuskip", "mathskip", NULL
+};
+const char *node_subtypes_leader[] = { /* 100+ */
+ "leaders", "cleaders", "xleaders", "gleaders", NULL
+};
+const char *node_subtypes_fill[] = {
+ "stretch", "fi", "fil", "fill", "filll", NULL
+};
+const char *node_subtypes_penalty[] = {
+ "userpenalty", NULL
+};
+const char *node_subtypes_kern[] = {
+ "fontkern", "userkern", "accentkern", NULL
+};
+const char *node_subtypes_rule[] = {
+ "normal", "box", "image", "empty", NULL
+};
+const char *node_subtypes_glyph[] = {
+ "character", "glyph", "ligature", "ghost", "left", "right", NULL
+};
+const char *node_subtypes_disc[] = {
+ "discretionary", "explicit", "automatic", "regular", "first", "second", NULL
+};
+const char *node_subtypes_marginkern[] = {
+ "left", "right", NULL
+};
+const char *node_subtypes_list[] = {
+ "unknown", "line", "box", "indent", "alignment", "cell", "equation", "equationnumber", NULL
+};
+const char *node_subtypes_math[] = {
+ "beginmath", "endmath", NULL
+};
+const char *node_subtypes_noad[] = {
+ "ord", "opdisplaylimits", "oplimits", "opnolimits", "bin", "rel", "open", "close",
+ "punct", "inner", "under", "over", "vcenter", NULL
+};
+const char *node_subtypes_radical[] = {
+ "radical", "uradical", "uroot", "uunderdelimiter", "uoverdelimiter", "udelimiterunder",
+ "udelimiterover", NULL
+};
+const char *node_subtypes_accent[] = {
+ "bothflexible", "fixedtop", "fixedbottom", "fixedboth", NULL,
+};
+const char *node_subtypes_fence[] = {
+ "unset", "left", "middle", "right", NULL
+};
+
+node_info node_data[] = { /* the last entry in a row is the etex number */
+ { hlist_node, box_node_size, node_fields_list, "hlist", 1 },
+ { vlist_node, box_node_size, node_fields_list, "vlist", 2 },
+ { rule_node, rule_node_size, node_fields_rule, "rule", 3 },
+ { ins_node, ins_node_size, node_fields_insert, "ins", 4 },
+ { mark_node, mark_node_size, node_fields_mark, "mark", 5 },
+ { adjust_node, adjust_node_size, node_fields_adjust, "adjust", 6 },
+ { boundary_node, boundary_size, node_fields_boundary, "boundary", -1 },
+ { disc_node, disc_node_size, node_fields_disc, "disc", 8 },
+ { whatsit_node, -1, NULL, "whatsit", 9 },
+ { math_node, math_node_size, node_fields_math, "math", 10 },
+ { glue_node, glue_node_size, node_fields_glue, "glue", 11 },
+ { kern_node, kern_node_size, node_fields_kern, "kern", 12 },
+ { penalty_node, penalty_node_size, node_fields_penalty, "penalty", 13 },
+ { unset_node, box_node_size, node_fields_unset, "unset", 14 },
+ { style_node, style_node_size, node_fields_style, "style", 15 },
+ { choice_node, style_node_size, node_fields_choice, "choice", 15 },
+ { simple_noad, noad_size, node_fields_ord, "noad", 15 },
+ { radical_noad, radical_noad_size, node_fields_radical, "radical", 15 },
+ { fraction_noad, fraction_noad_size, node_fields_fraction, "fraction", 15 },
+ { accent_noad, accent_noad_size, node_fields_accent, "accent", 15 },
+ { fence_noad, fence_noad_size, node_fields_fence, "fence", 15 },
+ { math_char_node, math_kernel_node_size, node_fields_math_char, "math_char", 15 },
+ { sub_box_node, math_kernel_node_size, node_fields_sub_box, "sub_box", 15 },
+ { sub_mlist_node, math_kernel_node_size, node_fields_sub_mlist, "sub_mlist", 15 },
+ { math_text_char_node, math_kernel_node_size, node_fields_math_text_char, "math_text_char", 15 },
+ { delim_node, math_shield_node_size, node_fields_delim, "delim", 15 },
+ { margin_kern_node, margin_kern_node_size, node_fields_margin_kern, "margin_kern", -1 },
+ { glyph_node, glyph_node_size, node_fields_glyph, "glyph", 0 },
+ { align_record_node, box_node_size, NULL, "align_record", -1 },
+ { pseudo_file_node, pseudo_file_node_size, NULL, "pseudo_file", -1 },
+ { pseudo_line_node, variable_node_size, NULL, "pseudo_line", -1 },
+ { inserting_node, page_ins_node_size, node_fields_inserting, "page_insert", -1 },
+ { split_up_node, page_ins_node_size, node_fields_splitup, "split_insert", -1 },
+ { expr_node, expr_node_size, NULL, "expr_stack", -1 },
+ { nesting_node, nesting_node_size, NULL, "nested_list", -1 },
+ { span_node, span_node_size, NULL, "span", -1 },
+ { attribute_node, attribute_node_size, node_fields_attribute, "attribute", -1 },
+ { glue_spec_node, glue_spec_size, node_fields_glue_spec, "glue_spec", -1 },
+ { attribute_list_node, attribute_node_size, node_fields_attribute_list, "attribute_list", -1 },
+ { temp_node, temp_node_size, NULL, "temp", -1 },
+ { align_stack_node, align_stack_node_size, NULL, "align_stack", -1 },
+ { movement_node, movement_node_size, NULL, "movement_stack", -1 },
+ { if_node, if_node_size, NULL, "if_stack", -1 },
+ { unhyphenated_node, active_node_size, NULL, "unhyphenated", -1 },
+ { hyphenated_node, active_node_size, NULL, "hyphenated", -1 },
+ { delta_node, delta_node_size, NULL, "delta", -1 },
+ { passive_node, passive_node_size, NULL, "passive", -1 },
+ { shape_node, variable_node_size, NULL, "shape", -1 },
+ { dir_node, dir_node_size, node_fields_dir, "dir", -1 },
+ { local_par_node, local_par_size, node_fields_local_par, "local_par", -1 },
+ { -1, -1, NULL, NULL, -1 },
+};
+
+#define last_normal_node local_par_node
+
+const char *node_subtypes_pdf_destination[] = {
+ "xyz", "fit", "fith", "fitv", "fitb", "fitbh", "fitbv", "fitr", NULL
+};
+const char *node_subtypes_pdf_literal[] = {
+ "origin", "page", "direct", NULL
+};
node_info whatsit_node_data[] = {
- {open_node, open_node_size, node_fields_whatsit_open, "open"},
- {write_node, write_node_size, node_fields_whatsit_write, "write"},
- {close_node, close_node_size, node_fields_whatsit_close, "close"},
- {special_node, special_node_size, node_fields_whatsit_special, "special"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {local_par_node, local_par_size, node_fields_whatsit_local_par,
- "local_par"},
- {dir_node, dir_node_size, node_fields_whatsit_dir, "dir"},
- {pdf_literal_node, write_node_size, node_fields_whatsit_pdf_literal,
- "pdf_literal"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {pdf_refobj_node, pdf_refobj_node_size, node_fields_whatsit_pdf_refobj,
- "pdf_refobj"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {pdf_refxform_node, pdf_refxform_node_size,
- node_fields_whatsit_pdf_refxform, "pdf_refxform"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {pdf_refximage_node, pdf_refximage_node_size,
- node_fields_whatsit_pdf_refximage, "pdf_refximage"},
- {pdf_annot_node, pdf_annot_node_size, node_fields_whatsit_pdf_annot,
- "pdf_annot"},
- {pdf_start_link_node, pdf_annot_node_size,
- node_fields_whatsit_pdf_start_link, "pdf_start_link"},
- {pdf_end_link_node, pdf_end_link_node_size,
- node_fields_whatsit_pdf_end_link, "pdf_end_link"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {pdf_dest_node, pdf_dest_node_size, node_fields_whatsit_pdf_dest,
- "pdf_dest"},
- {pdf_thread_node, pdf_thread_node_size, node_fields_whatsit_pdf_thread,
- "pdf_thread"},
- {pdf_start_thread_node, pdf_thread_node_size,
- node_fields_whatsit_pdf_start_thread, "pdf_start_thread"},
- {pdf_end_thread_node, pdf_end_thread_node_size,
- node_fields_whatsit_pdf_end_thread, "pdf_end_thread"},
- {save_pos_node, save_pos_node_size,
- node_fields_whatsit_save_pos, "save_pos"},
- {pdf_thread_data_node, pdf_thread_node_size, NULL, "pdf_thread_data"},
- {pdf_link_data_node, pdf_annot_node_size, NULL, "pdf_link_data"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {late_lua_node, late_lua_node_size, node_fields_whatsit_late_lua,
- "late_lua"},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {fake_node, fake_node_size, NULL, fake_node_name},
- {pdf_colorstack_node, pdf_colorstack_node_size,
- node_fields_whatsit_pdf_colorstack, "pdf_colorstack"},
- {pdf_setmatrix_node, pdf_setmatrix_node_size,
- node_fields_whatsit_pdf_setmatrix, "pdf_setmatrix"},
- {pdf_save_node, pdf_save_node_size, node_fields_whatsit_pdf_save,
- "pdf_save"},
- {pdf_restore_node, pdf_restore_node_size, node_fields_whatsit_pdf_restore,
- "pdf_restore"},
- {cancel_boundary_node, cancel_boundary_size,
- node_fields_whatsit_cancel_boundary, "cancel_boundary"},
- {user_defined_node, user_defined_node_size,
- node_fields_whatsit_user_defined, "user_defined"},
- {-1, -1, NULL, NULL}
-};
-
-#define last_whatsit_node user_defined_node
-
-/* hh: experiment */
+ { open_node, open_node_size, node_fields_whatsit_open, "open", -1 },
+ { write_node, write_node_size, node_fields_whatsit_write, "write", -1 },
+ { close_node, close_node_size, node_fields_whatsit_close, "close", -1 },
+ { special_node, special_node_size, node_fields_whatsit_special, "special", -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { save_pos_node, save_pos_node_size, node_fields_whatsit_save_pos, "save_pos", -1 },
+ { late_lua_node, late_lua_node_size, node_fields_whatsit_late_lua, "late_lua", -1 },
+ { user_defined_node, user_defined_node_size, node_fields_whatsit_user_defined, "user_defined", -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ { fake_node, fake_node_size, NULL, fake_node_name, -1 },
+ /* here starts the dvi backend section, todo: a separate list */
+ /* nothing for dvi */
+ /* here starts the pdf backend section, todo: a separate list */
+ { pdf_literal_node, write_node_size, node_fields_whatsit_pdf_literal, "pdf_literal", -1 },
+ { pdf_refobj_node, pdf_refobj_node_size, node_fields_whatsit_pdf_refobj, "pdf_refobj", -1 },
+ { pdf_annot_node, pdf_annot_node_size, node_fields_whatsit_pdf_annot, "pdf_annot", -1 },
+ { pdf_start_link_node, pdf_annot_node_size, node_fields_whatsit_pdf_start_link, "pdf_start_link", -1 },
+ { pdf_end_link_node, pdf_end_link_node_size, node_fields_whatsit_pdf_end_link, "pdf_end_link", -1 },
+ { pdf_dest_node, pdf_dest_node_size, node_fields_whatsit_pdf_dest, "pdf_dest", -1 },
+ { pdf_action_node, pdf_action_size, node_fields_whatsit_pdf_action, "pdf_action", -1 },
+ { pdf_thread_node, pdf_thread_node_size, node_fields_whatsit_pdf_thread, "pdf_thread", -1 },
+ { pdf_start_thread_node, pdf_thread_node_size, node_fields_whatsit_pdf_start_thread, "pdf_start_thread", -1 },
+ { pdf_end_thread_node, pdf_end_thread_node_size, node_fields_whatsit_pdf_end_thread, "pdf_end_thread", -1 },
+ { pdf_thread_data_node, pdf_thread_node_size, NULL, "pdf_thread_data", -1 },
+ { pdf_link_data_node, pdf_annot_node_size, NULL, "pdf_link_data", -1 },
+ { pdf_colorstack_node, pdf_colorstack_node_size, node_fields_whatsit_pdf_colorstack, "pdf_colorstack", -1 },
+ { pdf_setmatrix_node, pdf_setmatrix_node_size, node_fields_whatsit_pdf_setmatrix, "pdf_setmatrix", -1 },
+ { pdf_save_node, pdf_save_node_size, node_fields_whatsit_pdf_save, "pdf_save", -1 },
+ { pdf_restore_node, pdf_restore_node_size, node_fields_whatsit_pdf_restore, "pdf_restore", -1 },
+ /* done */
+ { -1, -1, NULL, NULL, -1 },
+};
+
+#define last_whatsit_node pdf_restore_node
/*
@@ -540,6 +631,8 @@ halfword new_node(int i, int j)
depth(n) = null_flag;
height(n) = null_flag;
rule_dir(n) = -1;
+ rule_index(n) = 0;
+ rule_transform(n) = 0;
/* fall through */
case unset_node:
width(n) = null_flag;
@@ -560,32 +653,34 @@ halfword new_node(int i, int j)
default:
break;
}
- /* handle synctex extension */
- switch (i) {
- case math_node:
- synctex_tag_math(n) = cur_input.synctex_tag_field;
- synctex_line_math(n) = line;
- break;
- case glue_node:
- synctex_tag_glue(n) = cur_input.synctex_tag_field;
- synctex_line_glue(n) = line;
- break;
- case kern_node:
- if (j != 0) {
- synctex_tag_kern(n) = cur_input.synctex_tag_field;
- synctex_line_kern(n) = line;
+ if (int_par(synctex_code)) {
+ /* handle synctex extension */
+ switch (i) {
+ case math_node:
+ synctex_tag_math(n) = cur_input.synctex_tag_field;
+ synctex_line_math(n) = line;
+ break;
+ case glue_node:
+ synctex_tag_glue(n) = cur_input.synctex_tag_field;
+ synctex_line_glue(n) = line;
+ break;
+ case kern_node:
+ if (j != 0) {
+ synctex_tag_kern(n) = cur_input.synctex_tag_field;
+ synctex_line_kern(n) = line;
+ }
+ break;
+ case hlist_node:
+ case vlist_node:
+ case unset_node:
+ synctex_tag_box(n) = cur_input.synctex_tag_field;
+ synctex_line_box(n) = line;
+ break;
+ case rule_node:
+ synctex_tag_rule(n) = cur_input.synctex_tag_field;
+ synctex_line_rule(n) = line;
+ break;
}
- break;
- case hlist_node:
- case vlist_node:
- case unset_node:
- synctex_tag_box(n) = cur_input.synctex_tag_field;
- synctex_line_box(n) = line;
- break;
- case rule_node:
- synctex_tag_rule(n) = cur_input.synctex_tag_field;
- synctex_line_rule(n) = line;
- break;
}
/* take care of attributes */
if (nodetype_has_attributes(i)) {
@@ -699,10 +794,98 @@ halfword copy_node_list(halfword p)
} while (0)
@ make a dupe of a single node
+
@c
+
+/*
+ at some point we can use function pointers as in the backend itself:
+
+ typedef void (*copy_function) ();
+ copy_function *copy_functions;
+ xmalloc((MAX_WHATSIT_TYPE + 1) * sizeof(copy_function));
+*/
+
+static void copy_node_wrapup_core(halfword p, halfword r)
+{
+ halfword s ;
+ switch (subtype(p)) {
+ case write_node:
+ case special_node:
+ add_token_ref(write_tokens(p));
+ break;
+ case late_lua_node:
+ copy_late_lua(r, p);
+ break;
+ case user_defined_node:
+ switch (user_node_type(p)) {
+ case 'a':
+ add_node_attr_ref(user_node_value(p));
+ break;
+ case 'l':
+ copy_user_lua(r, p);
+ break;
+ case 'n':
+ s = copy_node_list(user_node_value(p));
+ user_node_value(r) = s;
+ break;
+ case 's':
+ /* |add_string_ref(user_node_value(p));| *//* if this was mpost .. */
+ break;
+ case 't':
+ add_token_ref(user_node_value(p));
+ break;
+ }
+ break;
+ default:
+ break ;
+ }
+}
+
+void copy_node_wrapup_dvi(halfword p, halfword r)
+{
+}
+
+void copy_node_wrapup_pdf(halfword p, halfword r)
+{
+ switch(subtype(p)) {
+ case pdf_literal_node:
+ copy_pdf_literal(r, p);
+ break;
+ case pdf_colorstack_node:
+ if (pdf_colorstack_cmd(p) <= colorstack_data)
+ add_token_ref(pdf_colorstack_data(p));
+ break;
+ case pdf_setmatrix_node:
+ add_token_ref(pdf_setmatrix_data(p));
+ break;
+ case pdf_annot_node:
+ add_token_ref(pdf_annot_data(p));
+ break;
+ case pdf_start_link_node:
+ if (pdf_link_attr(r) != null)
+ add_token_ref(pdf_link_attr(r));
+ add_action_ref(pdf_link_action(r));
+ break;
+ case pdf_dest_node:
+ if (pdf_dest_named_id(p) > 0)
+ add_token_ref(pdf_dest_id(p));
+ break;
+ case pdf_thread_node:
+ case pdf_start_thread_node:
+ if (pdf_thread_named_id(p) > 0)
+ add_token_ref(pdf_thread_id(p));
+ if (pdf_thread_attr(p) != null)
+ add_token_ref(pdf_thread_attr(p));
+ break;
+ default:
+ break;
+ }
+}
+
halfword copy_node(const halfword p)
{
halfword r; /* current node being fabricated for new list */
+ halfword w ; /* whatsit subtype */
register halfword s; /* a helper variable for copying into variable mem */
register int i;
if (copy_error(p)) {
@@ -715,16 +898,18 @@ halfword copy_node(const halfword p)
(void) memcpy((void *) (varmem + r), (void *) (varmem + p),
(sizeof(memory_word) * (unsigned) i));
- /* handle synctex extension */
- switch (type(p)) {
- case math_node:
- synctex_tag_math(r) = cur_input.synctex_tag_field;
- synctex_line_math(r) = line;
- break;
- case kern_node:
- synctex_tag_kern(r) = cur_input.synctex_tag_field;
- synctex_line_kern(r) = line;
- break;
+ if (int_par(synctex_code)) {
+ /* handle synctex extension */
+ switch (type(p)) {
+ case math_node:
+ synctex_tag_math(r) = cur_input.synctex_tag_field;
+ synctex_line_math(r) = line;
+ break;
+ case kern_node:
+ synctex_tag_kern(r) = cur_input.synctex_tag_field;
+ synctex_line_kern(r) = line;
+ break;
+ }
}
if (nodetype_has_attributes(type(p))) {
add_node_attr_ref(node_attr(p));
@@ -775,6 +960,11 @@ halfword copy_node(const halfword p)
assert(tlink_no_break(r) == null);
}
break;
+ case math_node:
+ if (glue_ptr(p) != zero_glue) {
+ add_glue_ref(glue_ptr(p));
+ }
+ break;
case ins_node:
add_glue_ref(split_top_ptr(p));
copy_sub_list(ins_ptr(r),ins_ptr(p)) ;
@@ -795,18 +985,24 @@ halfword copy_node(const halfword p)
copy_sub_list(script_script_mlist(r),script_script_mlist(p)) ;
break;
case simple_noad:
+ copy_sub_list(nucleus(r),nucleus(p)) ;
+ copy_sub_list(subscr(r),subscr(p)) ;
+ copy_sub_list(supscr(r),supscr(p)) ;
+ break;
case radical_noad:
+ copy_sub_list(nucleus(r),nucleus(p)) ;
+ copy_sub_list(subscr(r),subscr(p)) ;
+ copy_sub_list(supscr(r),supscr(p)) ;
+ copy_sub_node(left_delimiter(r),left_delimiter(p)) ;
+ copy_sub_list(degree(r),degree(p)) ;
+ break;
case accent_noad:
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) {
- 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) {
- copy_sub_node(left_delimiter(r),left_delimiter(p)) ;
- copy_sub_list(degree(r),degree(p)) ;
- }
+ copy_sub_list(top_accent_chr(r),top_accent_chr(p)) ;
+ copy_sub_list(bot_accent_chr(r),bot_accent_chr(p)) ;
+ copy_sub_list(overlay_accent_chr(r),overlay_accent_chr(p)) ;
break;
case fence_noad:
copy_sub_node(delimiter(r),delimiter(p)) ;
@@ -824,77 +1020,18 @@ halfword copy_node(const halfword p)
case glue_spec_node:
glue_ref_count(r) = null;
break;
- case whatsit_node:
- switch (subtype(p)) {
- case dir_node:
- case local_par_node:
- break;
- case write_node:
- case special_node:
- add_token_ref(write_tokens(p));
- break;
- case pdf_literal_node:
- copy_pdf_literal(r, p);
- break;
- case pdf_colorstack_node:
- if (pdf_colorstack_cmd(p) <= colorstack_data)
- add_token_ref(pdf_colorstack_data(p));
- break;
- case pdf_setmatrix_node:
- add_token_ref(pdf_setmatrix_data(p));
- break;
- case late_lua_node:
- copy_late_lua(r, p);
- break;
- case pdf_annot_node:
- add_token_ref(pdf_annot_data(p));
- break;
- case pdf_start_link_node:
- if (pdf_link_attr(r) != null)
- add_token_ref(pdf_link_attr(r));
- add_action_ref(pdf_link_action(r));
- break;
- case pdf_dest_node:
- if (pdf_dest_named_id(p) > 0)
- add_token_ref(pdf_dest_id(p));
- break;
- case pdf_thread_node:
- case pdf_start_thread_node:
- if (pdf_thread_named_id(p) > 0)
- add_token_ref(pdf_thread_id(p));
- if (pdf_thread_attr(p) != null)
- add_token_ref(pdf_thread_attr(p));
- break;
- case user_defined_node:
- switch (user_node_type(p)) {
- case 'a':
- add_node_attr_ref(user_node_value(p));
- break;
- case 'l':
- copy_user_lua(r, p);
- break;
- case 'n':
- s = copy_node_list(user_node_value(p));
- user_node_value(r) = s;
- break;
- case 's':
- /* |add_string_ref(user_node_value(p));| *//* if this was mpost .. */
- break;
- case 't':
- add_token_ref(user_node_value(p));
- break;
- }
- break;
-#if 0
- case style_node:
- case delim_node:
- case math_char_node:
- case math_text_char_node:
+ case dir_node:
+ case local_par_node:
+ case boundary_node:
break;
-#else
- default:
-#endif
- break;
+ case whatsit_node:
+ w = subtype(p) ;
+ if (w >= backend_first_pdf_whatsit) {
+ copy_node_wrapup_pdf(p,r);
+ } else if (w >= backend_first_dvi_whatsit) {
+ copy_node_wrapup_dvi(p,r);
+ } else {
+ copy_node_wrapup_core(p,r);
}
break;
}
@@ -1097,9 +1234,118 @@ int copy_error(halfword p)
} while (0)
@ @c
-void flush_node(halfword p)
+
+static void flush_node_wrapup_core(halfword p)
+{
+ switch (subtype(p)) {
+ case open_node:
+ case write_node:
+ case close_node:
+ case save_pos_node:
+ break;
+ case special_node:
+ delete_token_ref(write_tokens(p));
+ break;
+ case late_lua_node:
+ free_late_lua(p);
+ break;
+ case user_defined_node:
+ switch (user_node_type(p)) {
+ case 'a':
+ delete_attribute_ref(user_node_value(p));
+ break;
+ case 'd':
+ break;
+ case 'n':
+ flush_node_list(user_node_value(p));
+ break;
+ case 's':
+ /* |delete_string_ref(user_node_value(p));| *//* if this was mpost .. */
+ break;
+ case 't':
+ delete_token_ref(user_node_value(p));
+ break;
+ default:
+ {
+ const char *hlp[] = {
+ "The type of the value in a user defined whatsit node should be one",
+ "of 'a' (attribute list), 'd' (number), 'n' (node list), 's' (string),",
+ "or 't' (tokenlist). Yours has an unknown type, and therefore I don't",
+ "know how to free the node's value. A memory leak may result.",
+ NULL
+ };
+ tex_error("Unidentified user defined whatsit", hlp);
+ }
+ break;
+ }
+ break;
+ }
+}
+
+void flush_node_wrapup_dvi(halfword p)
{
+}
+void flush_node_wrapup_pdf(halfword p)
+{
+ switch(subtype(p)) {
+ case pdf_save_node:
+ case pdf_restore_node:
+ case pdf_refobj_node:
+ case pdf_end_link_node:
+ case pdf_end_thread_node:
+ break;
+ case pdf_literal_node:
+ free_pdf_literal(p);
+ break;
+ case pdf_colorstack_node:
+ if (pdf_colorstack_cmd(p) <= colorstack_data)
+ delete_token_ref(pdf_colorstack_data(p));
+ break;
+ case pdf_setmatrix_node:
+ delete_token_ref(pdf_setmatrix_data(p));
+ break;
+ case pdf_annot_node:
+ delete_token_ref(pdf_annot_data(p));
+ break;
+ case pdf_link_data_node:
+ break;
+ case pdf_start_link_node:
+ if (pdf_link_attr(p) != null)
+ delete_token_ref(pdf_link_attr(p));
+ delete_action_ref(pdf_link_action(p));
+ break;
+ case pdf_dest_node:
+ if (pdf_dest_named_id(p) > 0)
+ delete_token_ref(pdf_dest_id(p));
+ break;
+ case pdf_action_node:
+ if (pdf_action_type(p) == pdf_action_user) {
+ delete_token_ref(pdf_action_tokens(p));
+ } else {
+ if (pdf_action_file(p) != null)
+ delete_token_ref(pdf_action_file(p));
+ if (pdf_action_type(p) == pdf_action_page)
+ delete_token_ref(pdf_action_tokens(p));
+ else if (pdf_action_named_id(p) > 0)
+ delete_token_ref(pdf_action_id(p));
+ }
+ break;
+ case pdf_thread_data_node:
+ break;
+ case pdf_thread_node:
+ case pdf_start_thread_node:
+ if (pdf_thread_named_id(p) > 0)
+ delete_token_ref(pdf_thread_id(p));
+ if (pdf_thread_attr(p) != null)
+ delete_token_ref(pdf_thread_attr(p));
+ break;
+ }
+}
+
+void flush_node(halfword p)
+{
+ halfword w;
if (p == null) /* legal, but no-op */
return;
@@ -1124,18 +1370,22 @@ void flush_node(halfword p)
free_sub_list(list_ptr(p));
break;
case disc_node:
+ /* watch the start at temp node hack */
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 math_node:
+ /* begin mathskip code */
+ if (glue_ptr(p) != zero_glue) {
+ delete_glue_ref(glue_ptr(p));
+ }
+ /* end mathskip code */
+ break;
case glue_spec_node:
/* this allows free-ing of lua-allocated glue specs */
if (valid_node(p)) {
@@ -1147,104 +1397,18 @@ void flush_node(halfword p)
}
return ;
break ;
+ case dir_node:
+ case local_par_node:
+ case boundary_node:
+ break;
case whatsit_node:
- switch (subtype(p)) {
-
- case dir_node:
- break;
- case open_node:
- case write_node:
- case close_node:
- case pdf_save_node:
- case pdf_restore_node:
- case cancel_boundary_node:
- case pdf_refobj_node:
- case pdf_refxform_node:
- case pdf_refximage_node:
- case pdf_end_link_node:
- case pdf_end_thread_node:
- case save_pos_node:
- case local_par_node:
- break;
-
- case special_node:
- delete_token_ref(write_tokens(p));
- break;
- case pdf_literal_node:
- free_pdf_literal(p);
- break;
- case pdf_colorstack_node:
- if (pdf_colorstack_cmd(p) <= colorstack_data)
- delete_token_ref(pdf_colorstack_data(p));
- break;
- case pdf_setmatrix_node:
- delete_token_ref(pdf_setmatrix_data(p));
- break;
- case late_lua_node:
- free_late_lua(p);
- break;
- case pdf_annot_node:
- delete_token_ref(pdf_annot_data(p));
- break;
-
- case pdf_link_data_node:
- break;
-
- case pdf_start_link_node:
- if (pdf_link_attr(p) != null)
- delete_token_ref(pdf_link_attr(p));
- delete_action_ref(pdf_link_action(p));
- break;
- case pdf_dest_node:
- if (pdf_dest_named_id(p) > 0)
- delete_token_ref(pdf_dest_id(p));
- break;
-
- case pdf_thread_data_node:
- break;
-
- case pdf_thread_node:
- case pdf_start_thread_node:
- if (pdf_thread_named_id(p) > 0)
- delete_token_ref(pdf_thread_id(p));
- if (pdf_thread_attr(p) != null)
- delete_token_ref(pdf_thread_attr(p));
- break;
- case user_defined_node:
- switch (user_node_type(p)) {
- case 'a':
- delete_attribute_ref(user_node_value(p));
- break;
- case 'd':
- break;
- case 'n':
- flush_node_list(user_node_value(p));
- break;
- case 's':
- /* |delete_string_ref(user_node_value(p));| *//* if this was mpost .. */
- break;
- case 't':
- delete_token_ref(user_node_value(p));
- break;
- default:
- {
- const char *hlp[] = {
- "The type of the value in a user defined whatsit node should be one",
- "of 'a' (attribute list), 'd' (number), 'n' (node list), 's' (string),",
- "or 't' (tokenlist). Yours has an unknown type, and therefore I don't",
- "know how to free the node's value. A memory leak may result.",
- NULL
- };
- tex_error("Unidentified user defined whatsit", hlp);
- }
- break;
- }
- break;
-
- default:
- confusion("ext3");
- return;
-
+ w = subtype(p) ;
+ if (w >= backend_first_pdf_whatsit) {
+ flush_node_wrapup_pdf(p);
+ } else if (w >= backend_first_dvi_whatsit) {
+ flush_node_wrapup_dvi(p);
+ } else {
+ flush_node_wrapup_core(p);
}
break;
case ins_node:
@@ -1269,18 +1433,24 @@ void flush_node(halfword p)
free_sub_list(script_script_mlist(p));
break;
case simple_noad:
+ free_sub_list(nucleus(p));
+ free_sub_list(subscr(p));
+ free_sub_list(supscr(p));
+ break;
case radical_noad:
+ free_sub_list(nucleus(p));
+ free_sub_list(subscr(p));
+ free_sub_list(supscr(p));
+ free_sub_node(left_delimiter(p));
+ free_sub_list(degree(p));
+ break;
case accent_noad:
free_sub_list(nucleus(p));
free_sub_list(subscr(p));
free_sub_list(supscr(p));
- if (type(p) == accent_noad) {
- free_sub_list(accent_chr(p));
- free_sub_list(bot_accent_chr(p));
- } else if (type(p) == radical_noad) {
- free_sub_node(left_delimiter(p));
- free_sub_list(degree(p));
- }
+ free_sub_list(top_accent_chr(p));
+ free_sub_list(bot_accent_chr(p));
+ free_sub_list(overlay_accent_chr(p));
break;
case fence_noad:
free_sub_list(delimiter(p));
@@ -1316,7 +1486,6 @@ void flush_node(halfword p)
case hyphenated_node:
case delta_node:
case passive_node:
- case action_node:
case inserting_node:
case split_up_node:
case expr_node:
@@ -1377,32 +1546,48 @@ static int test_count = 1;
#define check_attribute_ref(a) { dorangetest(p,a,var_mem_max); }
#define check_token_ref(a) assert(1)
-void check_node(halfword p)
+static void check_node_wrapup_core(halfword p)
{
-
- switch (type(p)) {
- case glyph_node:
- dorangetest(p, lig_ptr(p), var_mem_max);
- break;
- case glue_node:
- check_glue_ref(glue_ptr(p));
- dorangetest(p, leader_ptr(p), var_mem_max);
- break;
- case hlist_node:
- case vlist_node:
- case unset_node:
- case align_record_node:
- dorangetest(p, list_ptr(p), var_mem_max);
- break;
- case ins_node:
- dorangetest(p, ins_ptr(p), var_mem_max);
- check_glue_ref(split_top_ptr(p));
- break;
- case whatsit_node:
- switch (subtype(p)) {
+ switch (subtype(p)) {
+ /* frontend code */
case special_node:
check_token_ref(write_tokens(p));
break;
+ case user_defined_node:
+ switch (user_node_type(p)) {
+ case 'a':
+ check_attribute_ref(user_node_value(p));
+ break;
+ case 't':
+ check_token_ref(user_node_value(p));
+ break;
+ case 'n':
+ dorangetest(p, user_node_value(p), var_mem_max);
+ break;
+ case 's':
+ case 'd':
+ break;
+ default:
+ confusion("extuser");
+ break;
+ }
+ break;
+ case open_node:
+ case write_node:
+ case close_node:
+ case save_pos_node:
+ confusion("ext3"); /* why */
+ break;
+ }
+}
+
+void check_node_wrapup_dvi(halfword p)
+{
+}
+
+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));
@@ -1439,47 +1624,59 @@ void check_node(halfword p)
if (pdf_thread_attr(p) != null)
check_token_ref(pdf_thread_attr(p));
break;
- case user_defined_node:
- switch (user_node_type(p)) {
- case 'a':
- check_attribute_ref(user_node_value(p));
- break;
- case 't':
- check_token_ref(user_node_value(p));
- break;
- case 'n':
- dorangetest(p, user_node_value(p), var_mem_max);
- break;
- case 's':
- case 'd':
- break;
- default:
- confusion("extuser");
- break;
- }
- break;
- case dir_node:
- case open_node:
- case write_node:
- case close_node:
case pdf_save_node:
case pdf_restore_node:
- case cancel_boundary_node:
case pdf_refobj_node:
- case pdf_refxform_node:
- case pdf_refximage_node:
case pdf_end_link_node:
case pdf_end_thread_node:
- case save_pos_node:
- case local_par_node:
break;
default:
confusion("ext3");
+ break;
+ }
+}
+
+void check_node(halfword p)
+{
+ halfword w ;
+ switch (type(p)) {
+ case glyph_node:
+ dorangetest(p, lig_ptr(p), var_mem_max);
+ break;
+ case glue_node:
+ check_glue_ref(glue_ptr(p));
+ dorangetest(p, leader_ptr(p), var_mem_max);
+ break;
+ case hlist_node:
+ case vlist_node:
+ case unset_node:
+ case align_record_node:
+ dorangetest(p, list_ptr(p), var_mem_max);
+ break;
+ case ins_node:
+ dorangetest(p, ins_ptr(p), var_mem_max);
+ check_glue_ref(split_top_ptr(p));
+ break;
+ case whatsit_node:
+ w = subtype(p) ;
+ if (w >= backend_first_pdf_whatsit) {
+ check_node_wrapup_pdf(p);
+ } else if (w >= backend_first_dvi_whatsit) {
+ check_node_wrapup_dvi(p);
+ } else {
+ check_node_wrapup_core(p);
}
break;
case margin_kern_node:
check_node(margin_char(p));
break;
+ case math_node:
+ /* begin mathskip code */
+ if (glue_ptr(p) != zero_glue) {
+ check_glue_ref(glue_ptr(p));
+ }
+ /* end mathskip code */
+ break;
case disc_node:
dorangetest(p, vlink(pre_break(p)), var_mem_max);
dorangetest(p, vlink(post_break(p)), var_mem_max);
@@ -1522,15 +1719,15 @@ void check_node(halfword p)
dorangetest(p, nucleus(p), var_mem_max);
dorangetest(p, subscr(p), var_mem_max);
dorangetest(p, supscr(p), var_mem_max);
- dorangetest(p, accent_chr(p), var_mem_max);
+ dorangetest(p, top_accent_chr(p), var_mem_max);
dorangetest(p, bot_accent_chr(p), var_mem_max);
+ dorangetest(p, overlay_accent_chr(p), var_mem_max);
break;
case fence_noad:
dorangetest(p, delimiter(p), var_mem_max);
break;
case rule_node:
case kern_node:
- case math_node:
case penalty_node:
case mark_node:
case style_node:
@@ -1548,6 +1745,9 @@ void check_node(halfword p)
case delta_node:
case passive_node:
case expr_node:
+ case dir_node:
+ case boundary_node:
+ case local_par_node:
break;
default:
fprintf(stdout, "check_node: type is %d\n", type(p));
@@ -2265,6 +2465,13 @@ void delete_attribute_ref(halfword b)
}
}
+void reset_node_properties(halfword b)
+{
+ if (b != null) {
+ lua_properties_reset(b);
+ }
+}
+
@ |p| is an attr list head, or zero
@c
halfword do_set_attribute(halfword p, int i, int val)
@@ -2522,312 +2729,258 @@ static void print_write_whatsit(const char *s, pointer p)
@ @c
-static void show_whatsit_node(int p)
+
+static void show_node_wrapup_core(int p)
{
switch (subtype(p)) {
- case open_node:
- print_write_whatsit("openout", p);
- print_char('=');
- print_file_name(open_name(p), open_area(p), open_ext(p));
- break;
- case write_node:
- print_write_whatsit("write", p);
- print_mark(write_tokens(p));
- break;
- case close_node:
- print_write_whatsit("closeout", p);
- break;
- case special_node:
- tprint_esc("special");
- print_mark(write_tokens(p));
- break;
- case dir_node:
- if (dir_dir(p) < 0) {
- tprint_esc("enddir");
- print_char(' ');
- print_dir(dir_dir(p) + 64);
- } else {
- tprint_esc("begindir");
- print_char(' ');
- print_dir(dir_dir(p));
- }
- break;
- case local_par_node:
- tprint_esc("whatsit");
- append_char('.');
- print_ln();
- print_current_string();
- tprint_esc("localinterlinepenalty");
- print_char('=');
- print_int(local_pen_inter(p));
- print_ln();
- print_current_string();
- tprint_esc("localbrokenpenalty");
- print_char('=');
- print_int(local_pen_broken(p));
- print_ln();
- print_current_string();
- tprint_esc("localleftbox");
- if (local_box_left(p) == null) {
- tprint("=null");
- } else {
- append_char('.');
- show_node_list(local_box_left(p));
- decr(cur_length);
- }
- print_ln();
- print_current_string();
- tprint_esc("localrightbox");
- if (local_box_right(p) == null) {
- tprint("=null");
- } else {
- append_char('.');
- show_node_list(local_box_right(p));
- decr(cur_length);
- }
- decr(cur_length);
- break;
- case pdf_literal_node:
- show_pdf_literal(p);
- break;
- case pdf_colorstack_node:
- tprint_esc("pdfcolorstack ");
- print_int(pdf_colorstack_stack(p));
- switch (pdf_colorstack_cmd(p)) {
- case colorstack_set:
- tprint(" set ");
- break;
- case colorstack_push:
- tprint(" push ");
+ case open_node:
+ print_write_whatsit("openout", p);
+ print_char('=');
+ print_file_name(open_name(p), open_area(p), open_ext(p));
break;
- case colorstack_pop:
- tprint(" pop");
+ case write_node:
+ print_write_whatsit("write", p);
+ print_mark(write_tokens(p));
break;
- case colorstack_current:
- tprint(" current");
+ case close_node:
+ print_write_whatsit("closeout", p);
break;
- default:
- confusion("pdfcolorstack");
+ case special_node:
+ tprint_esc("special");
+ print_mark(write_tokens(p));
break;
- }
- if (pdf_colorstack_cmd(p) <= colorstack_data)
- print_mark(pdf_colorstack_data(p));
- break;
- case pdf_setmatrix_node:
- tprint_esc("pdfsetmatrix");
- print_mark(pdf_setmatrix_data(p));
- break;
- case pdf_save_node:
- tprint_esc("pdfsave");
- break;
- case pdf_restore_node:
- tprint_esc("pdfrestore");
- break;
- case cancel_boundary_node:
- tprint_esc("noboundary");
- break;
- case late_lua_node:
- show_late_lua(p);
- break;
- case pdf_refobj_node:
- tprint_esc("pdfrefobj");
- if (obj_obj_is_stream(static_pdf, pdf_obj_objnum(p))) {
- if (obj_obj_stream_attr(static_pdf, pdf_obj_objnum(p)) != LUA_NOREF) {
- tprint(" attr");
- lua_rawgeti(Luas, LUA_REGISTRYINDEX,
- obj_obj_stream_attr(static_pdf, pdf_obj_objnum(p)));
- print_char(' ');
- tprint((const char *) lua_tostring(Luas, -1));
- lua_pop(Luas, 1);
- }
- tprint(" stream");
- }
- if (obj_obj_is_file(static_pdf, pdf_obj_objnum(p)))
- tprint(" file");
- if (obj_obj_data(static_pdf, pdf_obj_objnum(p)) != LUA_NOREF) {
- lua_rawgeti(Luas, LUA_REGISTRYINDEX,
- obj_obj_data(static_pdf, pdf_obj_objnum(p)));
- print_char(' ');
- tprint((const char *) lua_tostring(Luas, -1));
- lua_pop(Luas, 1);
- }
- break;
- case pdf_refxform_node:
- case pdf_refximage_node:
- if (subtype(p) == pdf_refxform_node)
- tprint_esc("pdfrefxform");
- else
- tprint_esc("pdfrefximage");
- tprint("(");
- print_scaled(height(p));
- print_char('+');
- print_scaled(depth(p));
- tprint(")x");
- print_scaled(width(p));
- break;
- case pdf_annot_node:
- tprint_esc("pdfannot");
- show_pdftex_whatsit_rule_spec(p);
- print_mark(pdf_annot_data(p));
- break;
- case pdf_start_link_node:
- tprint_esc("pdfstartlink");
- show_pdftex_whatsit_rule_spec(p);
- if (pdf_link_attr(p) != null) {
- tprint(" attr");
- print_mark(pdf_link_attr(p));
- }
- tprint(" action");
- if (pdf_action_type(pdf_link_action(p)) == pdf_action_user) {
- tprint(" user");
- print_mark(pdf_action_tokens(pdf_link_action(p)));
- return;
- }
- if (pdf_action_file(pdf_link_action(p)) != null) {
- tprint(" file");
- print_mark(pdf_action_file(pdf_link_action(p)));
- }
- switch (pdf_action_type(pdf_link_action(p))) {
- case pdf_action_goto:
- if (pdf_action_named_id(pdf_link_action(p)) > 0) {
- tprint(" goto name");
- print_mark(pdf_action_id(pdf_link_action(p)));
- } else {
- tprint(" goto num");
- print_int(pdf_action_id(pdf_link_action(p)));
- }
+ case late_lua_node:
+ show_late_lua(p);
break;
- case pdf_action_page:
- tprint(" page");
- print_int(pdf_action_id(pdf_link_action(p)));
- print_mark(pdf_action_tokens(pdf_link_action(p)));
+ case save_pos_node:
+ tprint_esc("savepos");
break;
- case pdf_action_thread:
- if (pdf_action_named_id(pdf_link_action(p)) > 0) {
- tprint(" thread name");
- print_mark(pdf_action_id(pdf_link_action(p)));
- } else {
- tprint(" thread num");
- print_int(pdf_action_id(pdf_link_action(p)));
+ case user_defined_node:
+ tprint_esc("whatsit");
+ print_int(user_node_id(p));
+ print_char('=');
+ switch (user_node_type(p)) {
+ case 'a':
+ tprint("<>");
+ break;
+ case 'n':
+ tprint("[");
+ show_node_list(user_node_value(p));
+ tprint("]");
+ break;
+ case 's':
+ print_char('"');
+ print(user_node_value(p));
+ print_char('"');
+ break;
+ case 't':
+ print_mark(user_node_value(p));
+ break;
+ default: /* only 'd' */
+ print_int(user_node_value(p));
+ break;
}
break;
- default:
- pdf_error("displaying", "unknown action type");
+ }
+}
+
+void show_node_wrapup_dvi(int p)
+{
+}
+
+void show_node_wrapup_pdf(int p)
+{
+ switch (subtype(p)) {
+ case pdf_literal_node:
+ show_pdf_literal(p);
break;
- }
- break;
- case pdf_end_link_node:
- tprint_esc("pdfendlink");
- break;
- case pdf_dest_node:
- tprint_esc("pdfdest");
- if (pdf_dest_named_id(p) > 0) {
- tprint(" name");
- print_mark(pdf_dest_id(p));
- } else {
- tprint(" num");
- print_int(pdf_dest_id(p));
- }
- print_char(' ');
- switch (pdf_dest_type(p)) {
- case pdf_dest_xyz:
- tprint("xyz");
- if (pdf_dest_xyz_zoom(p) != null) {
- tprint(" zoom");
- print_int(pdf_dest_xyz_zoom(p));
+ case pdf_colorstack_node:
+ tprint_esc("pdfcolorstack ");
+ print_int(pdf_colorstack_stack(p));
+ switch (pdf_colorstack_cmd(p)) {
+ case colorstack_set:
+ tprint(" set ");
+ break;
+ case colorstack_push:
+ tprint(" push ");
+ break;
+ case colorstack_pop:
+ tprint(" pop");
+ break;
+ case colorstack_current:
+ tprint(" current");
+ break;
+ default:
+ confusion("pdfcolorstack");
+ break;
}
+ if (pdf_colorstack_cmd(p) <= colorstack_data)
+ print_mark(pdf_colorstack_data(p));
break;
- case pdf_dest_fitbh:
- tprint("fitbh");
- break;
- case pdf_dest_fitbv:
- tprint("fitbv");
+ case pdf_setmatrix_node:
+ tprint_esc("pdfsetmatrix");
+ print_mark(pdf_setmatrix_data(p));
break;
- case pdf_dest_fitb:
- tprint("fitb");
+ case pdf_save_node:
+ tprint_esc("pdfsave");
break;
- case pdf_dest_fith:
- tprint("fith");
+ case pdf_restore_node:
+ tprint_esc("pdfrestore");
break;
- case pdf_dest_fitv:
- tprint("fitv");
+ case pdf_refobj_node:
+ tprint_esc("pdfrefobj");
+ if (obj_obj_is_stream(static_pdf, pdf_obj_objnum(p))) {
+ if (obj_obj_stream_attr(static_pdf, pdf_obj_objnum(p)) != LUA_NOREF) {
+ tprint(" attr");
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX,
+ obj_obj_stream_attr(static_pdf, pdf_obj_objnum(p)));
+ print_char(' ');
+ tprint((const char *) lua_tostring(Luas, -1));
+ lua_pop(Luas, 1);
+ }
+ tprint(" stream");
+ }
+ if (obj_obj_is_file(static_pdf, pdf_obj_objnum(p)))
+ tprint(" file");
+ if (obj_obj_data(static_pdf, pdf_obj_objnum(p)) != LUA_NOREF) {
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX,
+ obj_obj_data(static_pdf, pdf_obj_objnum(p)));
+ print_char(' ');
+ tprint((const char *) lua_tostring(Luas, -1));
+ lua_pop(Luas, 1);
+ }
break;
- case pdf_dest_fitr:
- tprint("fitr");
+ case pdf_annot_node:
+ tprint_esc("pdfannot");
show_pdftex_whatsit_rule_spec(p);
+ print_mark(pdf_annot_data(p));
break;
- case pdf_dest_fit:
- tprint("fit");
- break;
- default:
- tprint("unknown!");
+ case pdf_start_link_node:
+ tprint_esc("pdfstartlink");
+ show_pdftex_whatsit_rule_spec(p);
+ if (pdf_link_attr(p) != null) {
+ tprint(" attr");
+ print_mark(pdf_link_attr(p));
+ }
+ tprint(" action");
+ if (pdf_action_type(pdf_link_action(p)) == pdf_action_user) {
+ tprint(" user");
+ print_mark(pdf_action_tokens(pdf_link_action(p)));
+ return;
+ }
+ if (pdf_action_file(pdf_link_action(p)) != null) {
+ tprint(" file");
+ print_mark(pdf_action_file(pdf_link_action(p)));
+ }
+ switch (pdf_action_type(pdf_link_action(p))) {
+ case pdf_action_goto:
+ if (pdf_action_named_id(pdf_link_action(p)) > 0) {
+ tprint(" goto name");
+ print_mark(pdf_action_id(pdf_link_action(p)));
+ } else {
+ tprint(" goto num");
+ print_int(pdf_action_id(pdf_link_action(p)));
+ }
+ break;
+ case pdf_action_page:
+ tprint(" page");
+ print_int(pdf_action_id(pdf_link_action(p)));
+ print_mark(pdf_action_tokens(pdf_link_action(p)));
+ break;
+ case pdf_action_thread:
+ if (pdf_action_named_id(pdf_link_action(p)) > 0) {
+ tprint(" thread name");
+ print_mark(pdf_action_id(pdf_link_action(p)));
+ } else {
+ tprint(" thread num");
+ print_int(pdf_action_id(pdf_link_action(p)));
+ }
+ break;
+ default:
+ normal_error("pdf backend", "unknown action type for link");
+ break;
+ }
break;
- }
- break;
- case pdf_thread_node:
- case pdf_start_thread_node:
- if (subtype(p) == pdf_thread_node)
- tprint_esc("pdfthread");
- else
- tprint_esc("pdfstartthread");
- tprint("(");
- print_rule_dimen(height(p));
- print_char('+');
- print_rule_dimen(depth(p));
- tprint(")x");
- print_rule_dimen(width(p));
- if (pdf_thread_attr(p) != null) {
- tprint(" attr");
- print_mark(pdf_thread_attr(p));
- }
- if (pdf_thread_named_id(p) > 0) {
- tprint(" name");
- print_mark(pdf_thread_id(p));
- } else {
- tprint(" num");
- print_int(pdf_thread_id(p));
- }
- break;
- case pdf_end_thread_node:
- tprint_esc("pdfendthread");
- break;
- case save_pos_node:
- tprint_esc("savepos");
- break;
- case user_defined_node:
- tprint_esc("whatsit");
- print_int(user_node_id(p));
- print_char('=');
- switch (user_node_type(p)) {
- case 'a':
- tprint("<>");
+ case pdf_end_link_node:
+ tprint_esc("pdfendlink");
break;
- case 'n':
- tprint("[");
- show_node_list(user_node_value(p));
- tprint("]");
+ case pdf_dest_node:
+ tprint_esc("pdfdest");
+ if (pdf_dest_named_id(p) > 0) {
+ tprint(" name");
+ print_mark(pdf_dest_id(p));
+ } else {
+ tprint(" num");
+ print_int(pdf_dest_id(p));
+ }
+ print_char(' ');
+ switch (pdf_dest_type(p)) {
+ case pdf_dest_xyz:
+ tprint("xyz");
+ if (pdf_dest_xyz_zoom(p) != null) {
+ tprint(" zoom");
+ print_int(pdf_dest_xyz_zoom(p));
+ }
+ break;
+ case pdf_dest_fitbh:
+ tprint("fitbh");
+ break;
+ case pdf_dest_fitbv:
+ tprint("fitbv");
+ break;
+ case pdf_dest_fitb:
+ tprint("fitb");
+ break;
+ case pdf_dest_fith:
+ tprint("fith");
+ break;
+ case pdf_dest_fitv:
+ tprint("fitv");
+ break;
+ case pdf_dest_fitr:
+ tprint("fitr");
+ show_pdftex_whatsit_rule_spec(p);
+ break;
+ case pdf_dest_fit:
+ tprint("fit");
+ break;
+ default:
+ tprint("unknown!");
+ break;
+ }
break;
- case 's':
- print_char('"');
- print(user_node_value(p));
- print_char('"');
+ case pdf_thread_node:
+ case pdf_start_thread_node:
+ if (subtype(p) == pdf_thread_node)
+ tprint_esc("pdfthread");
+ else
+ tprint_esc("pdfstartthread");
+ tprint("(");
+ print_rule_dimen(height(p));
+ print_char('+');
+ print_rule_dimen(depth(p));
+ tprint(")x");
+ print_rule_dimen(width(p));
+ if (pdf_thread_attr(p) != null) {
+ tprint(" attr");
+ print_mark(pdf_thread_attr(p));
+ }
+ if (pdf_thread_named_id(p) > 0) {
+ tprint(" name");
+ print_mark(pdf_thread_id(p));
+ } else {
+ tprint(" num");
+ print_int(pdf_thread_id(p));
+ }
break;
- case 't':
- print_mark(user_node_value(p));
+ case pdf_end_thread_node:
+ tprint_esc("pdfendthread");
break;
- default: /* only 'd' */
- print_int(user_node_value(p));
+ default:
break;
- }
- break;
- default:
- tprint("whatsit?");
- break;
}
}
-
-
@ Now we are ready for |show_node_list| itself. This procedure has been
written to be ``extra robust'' in the sense that it should not crash or get
into a loop even if the data structures have been messed up by bugs in
@@ -2853,6 +3006,7 @@ static void show_whatsit_node(int p)
void show_node_list(int p)
{ /* prints a node list symbolically */
int n; /* the number of items already printed at this level */
+ halfword w;
real g; /* a glue ratio, as a floating point number */
if ((int) cur_length > depth_threshold) {
if (p > null)
@@ -2955,7 +3109,13 @@ void show_node_list(int p)
break;
case rule_node:
/* Display rule |p|; */
- tprint_esc("rule(");
+ if (subtype(p) == normal_rule) {
+ tprint_esc("rule(");
+ } else if (subtype(p) == box_rule) {
+ tprint_esc("box(");
+ } else if (subtype(p) == image_rule) {
+ tprint_esc("image(");
+ }
print_rule_dimen(height(p));
print_char('+');
print_rule_dimen(depth(p));
@@ -2976,8 +3136,72 @@ void show_node_list(int p)
print_int(float_cost(p));
node_list_display(ins_ptr(p)); /* recursive call */
break;
+ case dir_node:
+ if (dir_dir(p) < 0) {
+ tprint_esc("enddir");
+ print_char(' ');
+ print_dir(dir_dir(p) + dir_swap);
+ } else {
+ tprint_esc("begindir");
+ print_char(' ');
+ print_dir(dir_dir(p));
+ }
+ break;
+ case local_par_node:
+ tprint_esc("localpar");
+ append_char('.');
+ print_ln();
+ print_current_string();
+ tprint_esc("localinterlinepenalty");
+ print_char('=');
+ print_int(local_pen_inter(p));
+ print_ln();
+ print_current_string();
+ tprint_esc("localbrokenpenalty");
+ print_char('=');
+ print_int(local_pen_broken(p));
+ print_ln();
+ print_current_string();
+ tprint_esc("localleftbox");
+ if (local_box_left(p) == null) {
+ tprint("=null");
+ } else {
+ append_char('.');
+ show_node_list(local_box_left(p));
+ decr(cur_length);
+ }
+ print_ln();
+ print_current_string();
+ tprint_esc("localrightbox");
+ if (local_box_right(p) == null) {
+ tprint("=null");
+ } else {
+ append_char('.');
+ show_node_list(local_box_right(p));
+ decr(cur_length);
+ }
+ decr(cur_length);
+ break;
+ case boundary_node:
+ if (subtype(p)==0) {
+ tprint_esc("noboundary");
+ } else{
+ tprint_esc("boundary");
+ print_char('=');
+ print_int(subtype(p));
+ print_char(':');
+ print_int(boundary_value(p));
+ }
+ break;
case whatsit_node:
- show_whatsit_node(p);
+ w = subtype(p) ;
+ if (w >= backend_first_pdf_whatsit) {
+ show_node_wrapup_pdf(p);
+ } else if (w >= backend_first_dvi_whatsit) {
+ show_node_wrapup_dvi(p);
+ } else {
+ show_node_wrapup_core(p);
+ }
break;
case glue_node:
/* Display glue |p|; */
@@ -3148,8 +3372,14 @@ pointer actual_box_width(pointer r, scaled base_width)
d = width(p);
break;
case math_node:
- d = surround(p);
- break;
+ /* begin mathskip code */
+ if (glue_ptr(p) == zero_glue) {
+ d = surround(p);
+ break;
+ } else {
+ /* fall through */
+ }
+ /* end mathskip code */
case glue_node:
/* We need to be careful that |w|, |v|, and |d| do not depend on any |glue_set|
values, since such values are subject to system-dependent rounding.
@@ -3171,13 +3401,6 @@ pointer actual_box_width(pointer r, scaled base_width)
if (subtype(p) >= a_leaders)
goto found;
break;
- case whatsit_node:
- if ((subtype(p) == pdf_refxform_node)
- || (subtype(p) == pdf_refximage_node))
- d = width(p);
- else
- d = 0;
- break;
default:
d = 0;
break;
@@ -3307,10 +3530,10 @@ makes all the dimensions ``running,'' so you have to change the
ones that are not allowed to run.
@c
-halfword new_rule(void)
+halfword new_rule(int s)
{
halfword p; /* the new node */
- p = new_node(rule_node, 0); /* the |subtype| is not used */
+ p = new_node(rule_node,s);
return p;
}
@@ -3684,3 +3907,27 @@ However, other references to the nodes are made symbolically in terms of
the \.{WEB} macro definitions above, so that format changes will leave
\TeX's other algorithms intact.
@^system dependencies@>
+
+@ @c
+halfword make_local_par_node(void)
+/* This function creates a |local_paragraph| node */
+{
+ halfword p, q;
+ p = new_node(local_par_node,0);
+ local_pen_inter(p) = local_inter_line_penalty;
+ local_pen_broken(p) = local_broken_penalty;
+ if (local_left_box != null) {
+ q = copy_node_list(local_left_box);
+ local_box_left(p) = q;
+ local_box_left_width(p) = width(local_left_box);
+ }
+ if (local_right_box != null) {
+ q = copy_node_list(local_right_box);
+ local_box_right(p) = q;
+ local_box_right_width(p) = width(local_right_box);
+ }
+ local_par_dir(p) = par_direction;
+ return p;
+}
+
+
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h
index c2a96b33b40..321799551f5 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.h
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h
@@ -1,5 +1,5 @@
/* textoken.h
-
+
Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -27,9 +27,7 @@
# define left_brace_token 0x200000 /* $2^{21}\cdot|left_brace|$ */
# define right_brace_token 0x400000 /* $2^{21}\cdot|right_brace|$ */
-# define left_brace_token 0x200000 /* $2^{21}\cdot|left_brace|$ */
# define left_brace_limit 0x400000 /* $2^{21}\cdot(|left_brace|+1)$ */
-# define right_brace_token 0x400000 /* $2^{21}\cdot|right_brace|$ */
# define right_brace_limit 0x600000 /* $2^{21}\cdot(|right_brace|+1)$ */
# define math_shift_token 0x600000 /* $2^{21}\cdot|math_shift|$ */
# define tab_token 0x800000 /* $2^{21}\cdot|tab_mark|$ */
@@ -140,7 +138,7 @@ extern int get_char_cat_code(int);
# 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))
+# define end_line_char_inactive ((end_line_char < 0) || (end_line_char > 127))
extern halfword par_loc;
extern halfword par_token;
@@ -151,14 +149,26 @@ extern void firm_up_the_line(void);
extern void get_token(void);
extern halfword str_toks(lstring b);
+extern halfword str_scan_toks(int c, lstring b);
extern void ins_the_toks(void);
extern int scan_lua_state(void);
+
extern void conv_toks(void);
+extern str_number the_convert_string(halfword c, int i);
+extern int conv_toks_dvi(halfword c); /* plugin */
+extern int conv_toks_pdf(halfword c); /* plugin */
+
+extern int conv_var_dvi(halfword c); /* plugin */
+extern int conv_var_pdf(halfword c); /* plugin */
+
+extern int the_convert_string_dvi(halfword c, int i); /* plugin */
+extern int the_convert_string_pdf(halfword c, int i); /* plugin */
+
+extern halfword lua_str_toks(lstring b);
extern boolean in_lua_escape;
extern boolean is_convert(halfword c);
-extern str_number the_convert_string(halfword c, int i);
# define closed 2 /* not open, or at end of file */
# define just_open 1 /* newly opened, first line not yet read */
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w
index 06fffee9c38..b22f3cdd62e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
@ @c
@@ -351,7 +350,7 @@ void show_token_list(int p, int q, int l)
print(c);
break;
case mac_param_cmd:
- if (!in_lua_escape)
+ if (!in_lua_escape && (is_in_csname==0))
print(c);
print(c);
break;
@@ -482,7 +481,7 @@ boolean scan_keyword(const char *s)
int saved_align_state = align_state;
if (strlen(s) == 0) /* was assert (strlen(s) > 1); */
return false ; /* but not with newtokenlib zero keyword simply doesn't match */
- p = backup_head;
+ p = backup_head;
token_link(p) = null;
k = s;
while (*k) {
@@ -1001,7 +1000,8 @@ static boolean process_sup_mark(void)
if (cur_chr == buffer[iloc]) {
int c, cc;
if (iloc < ilimit) {
- if ((cur_chr == buffer[iloc + 1]) && (cur_chr == buffer[iloc + 2])
+ if ( (cur_chr == buffer[iloc + 1])
+ && (cur_chr == buffer[iloc + 2])
&& (cur_chr == buffer[iloc + 3])
&& (cur_chr == buffer[iloc + 4])
&& ((iloc + 10) <= ilimit)) {
@@ -1020,8 +1020,10 @@ static boolean process_sup_mark(void)
return true;
}
}
- if ((cur_chr == buffer[iloc + 1]) && (cur_chr == buffer[iloc + 2])
- && (cur_chr == buffer[iloc + 3]) && ((iloc + 8) <= ilimit)) {
+ if ( (cur_chr == buffer[iloc + 1])
+ && (cur_chr == buffer[iloc + 2])
+ && (cur_chr == buffer[iloc + 3])
+ && ((iloc + 8) <= ilimit)) {
int ccc, cccc, ccccc; /* constituents of a possible expanded code */
c = buffer[iloc + 4];
cc = buffer[iloc + 5];
@@ -1035,7 +1037,8 @@ static boolean process_sup_mark(void)
return true;
}
}
- if ((cur_chr == buffer[iloc + 1]) && (cur_chr == buffer[iloc + 2])
+ if ( (cur_chr == buffer[iloc + 1])
+ && (cur_chr == buffer[iloc + 2])
&& ((iloc + 6) <= ilimit)) {
int ccc, cccc; /* constituents of a possible expanded code */
c = buffer[iloc + 3];
@@ -1468,7 +1471,7 @@ No new control sequences will be defined except during a call of
void get_token(void)
{ /* sets |cur_cmd|, |cur_chr|, |cur_tok| */
no_new_control_sequence = false;
- get_token_lua();
+ get_next(); /* get_token_lua(); */
no_new_control_sequence = true;
if (cur_cs == 0)
cur_tok = token_val(cur_cmd, cur_chr);
@@ -1532,7 +1535,7 @@ at the value |p| that is returned. (If |p=temp_token_head|, the list is empty.)
symbols that |lua| considers special while scanning a literal string
@c
-static halfword lua_str_toks(lstring b)
+halfword lua_str_toks(lstring b)
{ /* changes the string |str_pool[b..pool_ptr]| to a token list */
halfword p; /* tail of the token list */
halfword q; /* new node being added to the token list via |store_new_token| */
@@ -1547,8 +1550,7 @@ static halfword lua_str_toks(lstring b)
if (t == ' ') {
t = space_token;
} else {
- if ((t == '\\') || (t == '"') || (t == '\'') || (t == 10)
- || (t == 13))
+ if ((t == '\\') || (t == '"') || (t == '\'') || (t == 10) || (t == 13))
fast_store_new_token(other_token + '\\');
if (t == 10)
t = 'n';
@@ -1588,6 +1590,77 @@ halfword str_toks(lstring s)
return p;
}
+/*
+ hh: most of the converter is similar to the one i made for macro so at some point i
+ can make a helper; also todo: there is no need to go through the pool
+
+*/
+
+halfword str_scan_toks(int ct, lstring s)
+{ /* changes the string |str_pool[b..pool_ptr]| to a token list */
+ halfword p; /* tail of the token list */
+ halfword q; /* new node being added to the token list via |store_new_token| */
+ halfword t; /* token being appended */
+ unsigned char *k, *l; /* index into string */
+ int cc;
+ p = temp_token_head;
+ set_token_link(p, null);
+ k = s.s;
+ l = k + s.l;
+ while (k < l) {
+ t = pool_to_unichar(k);
+ k += utf8_size(t);
+ cc = get_cat_code(ct,t);
+ if (cc == 0) {
+ /* we have a potential control sequence so we check for it */
+ int _lname = 0 ;
+ int _s = 0 ;
+ int _c = 0 ;
+ halfword _cs = null ;
+ unsigned char *_name = k ;
+ while (k < l) {
+ t = (halfword) str2uni((const unsigned char *) k);
+ _s = utf8_size(t);
+ _c = get_cat_code(ct,t);
+ if (_c == 11) {
+ k += _s ;
+ _lname = _lname + _s ;
+ } else if (_c == 10) {
+ /* we ignore a trailing space like normal scanning does */
+ k += _s ;
+ break ;
+ } else {
+ break ;
+ }
+ }
+ if (_s > 0) {
+ /* we have a potential \cs */
+ _cs = string_lookup((const char *) _name, _lname);
+ if (_cs == undefined_control_sequence) {
+ /* let's play safe and backtrack */
+ t = cc * (1<<21) + t ;
+ k = _name ;
+ } else {
+ t = cs_token_flag + _cs;
+ }
+ } else {
+ /* just a character with some meaning, so \unknown becomes effectively */
+ /* \\unknown assuming that \\ has some useful meaning of course */
+ t = cc * (1<<21) + t ;
+ k = _name ;
+ }
+
+ } else {
+ /* whatever token, so for instance $x^2$ just works given a tex */
+ /* catcode regime */
+ t = cc * (1<<21) + t ;
+ }
+ fast_store_new_token(t);
+
+ }
+ return p;
+}
+
@ Here's part of the |expand| subroutine that we are now ready to complete:
@c
void ins_the_toks(void)
@@ -1623,88 +1696,6 @@ static void print_job_name(void)
the code |c|. The function exists because lua code and tex code can
both call it to convert something.
-@c
-static boolean print_convert_string(halfword c, int i)
-{
- int ff; /* for use with |set_ff| */
- boolean ret = true;
- switch (c) {
- case number_code:
- print_int(i);
- break;
- case uchar_code:
- print(i);
- break;
- case roman_numeral_code:
- print_roman_int(i);
- break;
- case etex_code:
- tprint(eTeX_version_string);
- break;
- case luatex_revision_code:
- print(get_luatexrevision());
- break;
- case luatex_date_code:
- print_int(get_luatex_date_info());
- break;
- case luatex_banner_code:
- tprint(luatex_banner);
- break;
- case uniform_deviate_code:
- print_int(unif_rand(i));
- break;
- case normal_deviate_code:
- print_int(norm_rand());
- break;
- case format_name_code:
- print(format_name);
- break;
- case job_name_code:
- print_job_name();
- break;
- case font_name_code:
- append_string((unsigned char *) font_name(i),
- (unsigned) strlen(font_name(i)));
- if (font_size(i) != font_dsize(i)) {
- tprint(" at ");
- print_scaled(font_size(i));
- tprint("pt");
- }
- break;
- case font_id_code:
- print_int(i);
- break;
- case math_style_code:
- print_math_style();
- break;
- case pdf_font_name_code:
- case pdf_font_objnum_code:
- set_ff(i);
- if (c == pdf_font_name_code)
- print_int(obj_info(static_pdf, pdf_font_num(ff)));
- else
- print_int(pdf_font_num(ff));
- break;
- case pdf_font_size_code:
- print_scaled(font_size(i));
- tprint("pt");
- break;
- case pdf_page_ref_code:
- print_int(pdf_get_obj(static_pdf, obj_type_page, i, false));
- break;
- case pdf_xform_name_code:
- print_int(obj_info(static_pdf, i));
- break;
- case eTeX_revision_code:
- tprint(eTeX_revision);
- break;
- default:
- ret = false;
- break;
- }
- return ret;
-}
-
@ @c
int scan_lua_state(void) /* hh-ls: optional name or number (not optional name optional number) */
{
@@ -1728,8 +1719,6 @@ int scan_lua_state(void) /* hh-ls: optional name or number (not optional name op
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}'.
@@ -1739,6 +1728,262 @@ any pending string in its output. In order to save such a pending string,
we have to create a temporary string that is destroyed immediately after.
@c
+#define push_selector { \
+ old_setting = selector; \
+ selector = new_string; \
+}
+
+#define pop_selector { \
+ selector = old_setting; \
+}
+
+int conv_var_dvi(halfword c)
+{
+ return 0;
+}
+
+#define backend_dimen(A) eqtb[scaled_base+(A)].hh.rh
+#define backend_count(A) eqtb[count_base+(A)].hh.rh
+
+#define get_backend_count(cur_cs,name,index,default) { \
+ no_new_control_sequence = false; \
+ cur_cs = string_lookup(name,strlen(name)); \
+ no_new_control_sequence = true; \
+ if (eq_type(cur_cs) == undefined_cs_cmd) { \
+ assert(index < backend_int_last); \
+ primitive_tex(name, assign_int_cmd, int_base + index, int_base); \
+ backend_count(cur_cs) = default ; \
+ } \
+ cur_tok = cur_cs + cs_token_flag; \
+ back_input(); \
+}
+
+#define get_backend_dimen(cur_cs,name,index,default) { \
+ no_new_control_sequence = false; \
+ cur_cs = string_lookup(name,strlen(name)); \
+ no_new_control_sequence = true; \
+ if (eq_type(cur_cs) == undefined_cs_cmd) { \
+ assert(index < backend_dimen_last); \
+ primitive_tex(name, assign_dimen_cmd, dimen_base + index, dimen_base); \
+ backend_dimen(cur_cs) = default ; \
+ } \
+ cur_tok = cur_cs + cs_token_flag; \
+ back_input(); \
+}
+
+#define get_backend_toks(cur_cs,name,index) { \
+ no_new_control_sequence = false; \
+ cur_cs = string_lookup(name,strlen(name)); \
+ no_new_control_sequence = true; \
+ if (eq_type(cur_cs) == undefined_cs_cmd) { \
+ assert(index < backend_toks_last); \
+ primitive_tex(name, assign_toks_cmd, index, local_base); \
+ } \
+ cur_tok = cur_cs + cs_token_flag; \
+ back_input(); \
+}
+
+int conv_var_pdf(halfword c)
+{
+ /* todo: optimize order, but hardly any access */
+
+ if (scan_keyword("compresslevel")) { get_backend_count(cur_cs,"pdf_compresslevel", backend_int_base + 1, 9); }
+ else if (scan_keyword("decimaldigits")) { get_backend_count(cur_cs,"pdf_decimaldigits", backend_int_base + 2, 3); }
+ else if (scan_keyword("imageresolution")) { get_backend_count(cur_cs,"pdf_imageresolution", backend_int_base + 3, 72); }
+ else if (scan_keyword("pkresolution")) { get_backend_count(cur_cs,"pdf_pkresolution", backend_int_base + 4, 72); }
+ else if (scan_keyword("uniqueresname")) { get_backend_count(cur_cs,"pdf_uniqueresname", backend_int_base + 5, 0); }
+ else if (scan_keyword("minorversion")) { get_backend_count(cur_cs,"pdf_minorversion", backend_int_base + 6, 4); }
+ else if (scan_keyword("pagebox")) { get_backend_count(cur_cs,"pdf_pagebox", backend_int_base + 7, 0); }
+ else if (scan_keyword("inclusionerrorlevel")) { get_backend_count(cur_cs,"pdf_inclusionerrorlevel", backend_int_base + 8, 0); }
+ else if (scan_keyword("gamma")) { get_backend_count(cur_cs,"pdf_gamma", backend_int_base + 9, 1000); }
+ else if (scan_keyword("imageapplygamma")) { get_backend_count(cur_cs,"pdf_imageapplygamma", backend_int_base + 10, 0); }
+ else if (scan_keyword("imagegamma")) { get_backend_count(cur_cs,"pdf_imagegamma", backend_int_base + 11, 2200); }
+ else if (scan_keyword("imagehicolor")) { get_backend_count(cur_cs,"pdf_imagehicolor", backend_int_base + 12, 1); }
+ else if (scan_keyword("imageaddfilename")) { get_backend_count(cur_cs,"pdf_imageaddfilename", backend_int_base + 12, 1); }
+ else if (scan_keyword("objcompresslevel")) { get_backend_count(cur_cs,"pdf_objcompresslevel", backend_int_base + 13, 0); }
+ else if (scan_keyword("inclusioncopyfonts")) { get_backend_count(cur_cs,"pdf_inclusioncopyfonts", backend_int_base + 14, 0); }
+ else if (scan_keyword("gentounicode")) { get_backend_count(cur_cs,"pdf_gentounicode", backend_int_base + 15, 0); }
+ else if (scan_keyword("replacefont")) { get_backend_count(cur_cs,"pdf_replacefont", backend_int_base + 16, 0); }
+
+ else if (scan_keyword("horigin")) { get_backend_dimen(cur_cs,"pdf_horigin", backend_dimen_base + 1, one_inch); }
+ else if (scan_keyword("vorigin")) { get_backend_dimen(cur_cs,"pdf_vorigin", backend_dimen_base + 2, one_inch); }
+ else if (scan_keyword("threadmargin")) { get_backend_dimen(cur_cs,"pdf_threadmargin", backend_dimen_base + 3, 0); }
+ else if (scan_keyword("destmargin")) { get_backend_dimen(cur_cs,"pdf_destmargin", backend_dimen_base + 4, 0); }
+ else if (scan_keyword("linkmargin")) { get_backend_dimen(cur_cs,"pdf_linkmargin", backend_dimen_base + 5, 0); }
+
+ else if (scan_keyword("pageattr")) { get_backend_toks (cur_cs,"pdf_pageattr", backend_toks_base + 1); }
+ else if (scan_keyword("pageresources")) { get_backend_toks (cur_cs,"pdf_pageresources", backend_toks_base + 2); }
+ else if (scan_keyword("pagesattr")) { get_backend_toks (cur_cs,"pdf_pagesattr", backend_toks_base + 3); }
+ else if (scan_keyword("xformattr")) { get_backend_toks (cur_cs,"pdf_xformattr", backend_toks_base + 4); }
+ else if (scan_keyword("xformresources")) { get_backend_toks (cur_cs,"pdf_xformresources", backend_toks_base + 5); }
+ else if (scan_keyword("pkmode")) { get_backend_toks (cur_cs,"pdf_pkmode", backend_toks_base + 6); }
+
+ else
+ return 0;
+ return 1;
+}
+
+int conv_toks_dvi(halfword c)
+{
+ return 0;
+}
+
+/* codes not really needed but cleaner when testing */
+
+#define pdftex_version 40 /* these values will not change any more */
+#define pdftex_revision "0" /* these values will not change any more */
+
+int conv_toks_pdf(halfword c)
+{
+ int old_setting; /* holds |selector| setting */
+ int save_scanner_status; /* |scanner_status| upon entry */
+ halfword save_def_ref; /* |def_ref| upon entry, important if inside `\.{\\message}' */
+ halfword save_warning_index;
+ boolean bool; /* temp boolean */
+ str_number s; /* first temp string */
+ int ff; /* for use with |set_ff| */
+ str_number u = 0; /* third temp string, will become non-nil if a string is already being built */
+ char *str; /* color stack init str */
+
+ if (scan_keyword("lastlink")) c = pdf_last_link_code;
+ else if (scan_keyword("retval")) c = pdf_retval_code;
+ else if (scan_keyword("lastobj")) c = pdf_last_obj_code;
+ else if (scan_keyword("lastannot")) c = pdf_last_annot_code;
+ else if (scan_keyword("xformname")) c = pdf_xform_name_code;
+ else if (scan_keyword("creationdate")) c = pdf_creation_date_code;
+ else if (scan_keyword("fontname")) c = pdf_font_name_code;
+ else if (scan_keyword("fontobjnum")) c = pdf_font_objnum_code;
+ else if (scan_keyword("fontsize")) c = pdf_font_size_code;
+ else if (scan_keyword("pageref")) c = pdf_page_ref_code;
+ else if (scan_keyword("colorstackinit")) c = pdf_colorstack_init_code;
+ else if (scan_keyword("version")) c = pdf_version_code;
+ else if (scan_keyword("revision")) c = pdf_revision_code;
+
+ switch (c) {
+ case pdf_last_link_code:
+ push_selector;
+ print_int(pdf_last_link);
+ pop_selector;
+ break;
+ case pdf_retval_code:
+ push_selector;
+ print_int(pdf_retval);
+ pop_selector;
+ break;
+ case pdf_last_obj_code:
+ push_selector;
+ print_int(pdf_last_obj);
+ pop_selector;
+ break;
+ case pdf_last_annot_code:
+ push_selector;
+ print_int(pdf_last_annot);
+ pop_selector;
+ break;
+ case pdf_xform_name_code:
+ scan_int();
+ check_obj_type(static_pdf, obj_type_xform, cur_val);
+ push_selector;
+ print_int(obj_info(static_pdf, cur_val));
+ pop_selector;
+ break;
+ case pdf_creation_date_code:
+ ins_list(string_to_toks(getcreationdate(static_pdf)));
+ /* no further action */
+ return 2;
+ break;
+ case pdf_font_name_code:
+ scan_font_ident();
+ if (cur_val == null_font)
+ normal_error("pdf backend", "invalid font identifier when asking 'fontname'");
+ pdf_check_vf(cur_val);
+ if (!font_used(cur_val))
+ pdf_init_font(static_pdf, cur_val);
+ push_selector;
+ set_ff(cur_val);
+ print_int(obj_info(static_pdf, pdf_font_num(ff)));
+ pop_selector;
+ break;
+ case pdf_font_objnum_code:
+ scan_font_ident();
+ if (cur_val == null_font)
+ normal_error("pdf backend", "invalid font identifier when asking 'objnum'");
+ pdf_check_vf(cur_val);
+ if (!font_used(cur_val))
+ pdf_init_font(static_pdf, cur_val);
+ push_selector;
+ set_ff(cur_val);
+ print_int(pdf_font_num(ff));
+ pop_selector;
+ break;
+ case pdf_font_size_code:
+ scan_font_ident();
+ if (cur_val == null_font)
+ normal_error("pdf backend", "invalid font identifier when asking 'fontsize'");
+ push_selector;
+ print_scaled(font_size(cur_val));
+ tprint("pt");
+ pop_selector;
+ break;
+ case pdf_page_ref_code:
+ scan_int();
+ if (cur_val <= 0)
+ normal_error("pdf backend", "invalid page number when asking 'pageref'");
+ push_selector;
+ print_int(pdf_get_obj(static_pdf, obj_type_page, cur_val, false));
+ pop_selector;
+ break;
+ case pdf_colorstack_init_code:
+ bool = scan_keyword("page");
+ if (scan_keyword("direct"))
+ cur_val = direct_always;
+ else if (scan_keyword("page"))
+ cur_val = direct_page;
+ else
+ cur_val = set_origin;
+ save_scanner_status = scanner_status;
+ save_warning_index = warning_index;
+ save_def_ref = def_ref;
+ u = save_cur_string();
+ 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;
+ warning_index = save_warning_index;
+ scanner_status = save_scanner_status;
+ str = makecstring(s);
+ cur_val = newcolorstack(str, cur_val, bool);
+ free(str);
+ flush_str(s);
+ cur_val_level = int_val_level;
+ if (cur_val < 0) {
+ print_err("Too many color stacks");
+ help2("The number of color stacks is limited to 32768.",
+ "I'll use the default color stack 0 here.");
+ error();
+ cur_val = 0;
+ restore_cur_string(u);
+ }
+ push_selector;
+ print_int(cur_val);
+ pop_selector;
+ break;
+ case pdf_version_code:
+ push_selector;
+ print_int(pdftex_version);
+ pop_selector;
+ break;
+ case pdf_revision_code:
+ ins_list(string_to_toks(pdftex_revision));
+ return 2;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ return 1;
+}
+
void conv_toks(void)
{
int old_setting; /* holds |selector| setting */
@@ -1750,106 +1995,166 @@ void conv_toks(void)
str_number s; /* first temp string */
int sn; /* lua chunk name */
str_number u = 0; /* third temp string, will become non-nil if a string is already being built */
- int i = 0; /* first temp integer */
- int j = 0; /* second temp integer */
int c = cur_chr; /* desired type of conversion */
str_number str;
+ int done = 1;
+ int i = 0;
/* Scan the argument for command |c| */
switch (c) {
case uchar_code:
scan_char_num();
+ push_selector;
+ print(cur_val);
+ pop_selector;
break;
case number_code:
+ scan_int();
+ push_selector;
+ print_int(cur_val);
+ pop_selector;
+ break;
case roman_numeral_code:
scan_int();
+ push_selector;
+ print_roman_int(cur_val);
+ pop_selector;
break;
case string_code:
+ save_scanner_status = scanner_status;
+ scanner_status = normal;
+ get_token();
+ scanner_status = save_scanner_status;
+ push_selector;
+ if (cur_cs != 0)
+ sprint_cs(cur_cs);
+ else
+ print(cur_chr);
+ pop_selector;
+ break;
case meaning_code:
save_scanner_status = scanner_status;
scanner_status = normal;
get_token();
scanner_status = save_scanner_status;
+ push_selector;
+ print_meaning();
+ pop_selector;
break;
case etex_code:
+ push_selector;
+ tprint(eTeX_version_string);
+ pop_selector;
break;
case font_name_code:
+ scan_font_ident();
+ push_selector;
+ append_string((unsigned char *) font_name(cur_val),(unsigned) strlen(font_name(cur_val)));
+ if (font_size(cur_val) != font_dsize(cur_val)) {
+ tprint(" at ");
+ print_scaled(font_size(cur_val));
+ tprint("pt");
+ }
+ pop_selector;
+ break;
case font_id_code:
scan_font_ident();
+ push_selector;
+ print_int(cur_val);
+ pop_selector;
break;
case luatex_revision_code:
- case luatex_date_code:
- case luatex_banner_code:
+ push_selector;
+ print(get_luatexrevision());
+ pop_selector;
break;
- case pdf_font_name_code:
- case pdf_font_objnum_code:
- case pdf_font_size_code:
- scan_font_ident();
- if (cur_val == null_font)
- pdf_error("font", "invalid font identifier");
- if (c != pdf_font_size_code) {
- pdf_check_vf(cur_val);
- if (!font_used(cur_val))
- pdf_init_font(static_pdf, cur_val);
- }
+ case luatex_date_code:
+ push_selector;
+ print_int(get_luatex_date_info());
+ pop_selector;
break;
- case pdf_page_ref_code:
- scan_int();
- if (cur_val <= 0)
- pdf_error("pageref", "invalid page number");
+ case luatex_banner_code:
+ push_selector;
+ tprint(luatex_banner);
+ pop_selector;
break;
case left_margin_kern_code:
- case right_margin_kern_code:
scan_int();
if ((box(cur_val) == null) || (type(box(cur_val)) != hlist_node))
- pdf_error("marginkern", "a non-empty hbox expected");
+ normal_error("marginkern", "a non-empty hbox expected");
+ push_selector;
+ p = list_ptr(box(cur_val));
+ while ((p != null) && (type(p) == glue_node)) {
+ p = vlink(p);
+ }
+ if ((p != null) && (type(p) == margin_kern_node) && (subtype(p) == left_side))
+ print_scaled(width(p));
+ else
+ print_char('0');
+ tprint("pt");
+ pop_selector;
break;
- case pdf_xform_name_code:
+ case right_margin_kern_code:
scan_int();
- check_obj_type(static_pdf, obj_type_xform, cur_val);
- break;
- case pdf_creation_date_code:
- ins_list(string_to_toks(getcreationdate(static_pdf)));
- return;
+ if ((box(cur_val) == null) || (type(box(cur_val)) != hlist_node))
+ normal_error("marginkern", "a non-empty hbox expected");
+ push_selector;
+ p = list_ptr(box(cur_val));
+ if (p != null) {
+ p = tail_of_list(p);
+ /*
+ there can be a leftskip, rightskip, penalty and yes, also a disc node with a nesting
+ node that points to glue spec ... and we don't want to analyze that messy lot
+ */
+ while ((p != null) && (type(p) == glue_node)) {
+ p = alink(p);
+ }
+ if ((p != null) && ! ((type(p) == margin_kern_node) && (subtype(p) == right_side))) {
+ if (type(p) == disc_node) {
+ q = alink(p);
+ if ((q != null) && ((type(q) == margin_kern_node) && (subtype(q) == right_side))) {
+ p = q;
+ } else {
+ /*
+ officially we should look in the replace but currently protrusion doesn't
+ work anyway with "foo\discretionary{}{}{bar-} " (no following char) so we
+ don't need it now
+ */
+ }
+ }
+ }
+ }
+ if ((p != null) && (type(p) == margin_kern_node) && (subtype(p) == right_side))
+ print_scaled(width(p));
+ else
+ print_char('0');
+ tprint("pt");
+ pop_selector;
break;
case format_name_code:
- case job_name_code:
if (job_name == 0)
open_log_file();
+ push_selector;
+ print(format_name);
+ pop_selector;
break;
- case pdf_colorstack_init_code:
- bool = scan_keyword("page");
- if (scan_keyword("direct"))
- cur_val = direct_always;
- else if (scan_keyword("page"))
- cur_val = direct_page;
- else
- cur_val = set_origin;
- save_scanner_status = scanner_status;
- save_warning_index = warning_index;
- save_def_ref = def_ref;
- u = save_cur_string();
- 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;
- warning_index = save_warning_index;
- scanner_status = save_scanner_status;
- cur_val = newcolorstack(s, cur_val, bool);
- flush_str(s);
- cur_val_level = int_val_level;
- if (cur_val < 0) {
- print_err("Too many color stacks");
- help2("The number of color stacks is limited to 32768.",
- "I'll use the default color stack 0 here.");
- error();
- cur_val = 0;
- restore_cur_string(u);
- }
+ case job_name_code:
+ if (job_name == 0)
+ open_log_file();
+ push_selector;
+ print_job_name();
+ pop_selector;
break;
case uniform_deviate_code:
scan_int();
+ push_selector;
+ print_int(unif_rand(cur_val));
+ pop_selector;
break;
case normal_deviate_code:
+ scan_int();
+ push_selector;
+ print_int(norm_rand());
+ pop_selector;
break;
case lua_escape_string_code:
{
@@ -1873,8 +2178,42 @@ void conv_toks(void)
free(escstr.s);
return;
}
+ /* no further action */
break;
case math_style_code:
+ push_selector;
+ print_math_style();
+ pop_selector;
+ break;
+ case math_char_class_code:
+ {
+ mathcodeval mval;
+ scan_int();
+ mval = get_math_code(cur_val);
+ push_selector;
+ print_int(mval.class_value);
+ pop_selector;
+ }
+ break;
+ case math_char_fam_code:
+ {
+ mathcodeval mval;
+ scan_int();
+ mval = get_math_code(cur_val);
+ push_selector;
+ print_int(mval.family_value);
+ pop_selector;
+ }
+ break;
+ case math_char_slot_code:
+ {
+ mathcodeval mval;
+ scan_int();
+ mval = get_math_code(cur_val);
+ push_selector;
+ print_int(mval.character_value);
+ pop_selector;
+ }
break;
case expanded_code:
save_scanner_status = scanner_status;
@@ -1887,6 +2226,7 @@ void conv_toks(void)
ins_list(token_link(def_ref));
def_ref = save_def_ref;
restore_cur_string(u);
+ /* no further action */
return;
break;
case lua_code:
@@ -1906,12 +2246,13 @@ void conv_toks(void)
restore_cur_string(u); /* TODO: check this, was different */
if (luacstrings > 0)
lua_string_start();
+ /* no further action */
return;
break;
case lua_function_code:
scan_int();
if (cur_val <= 0) {
- pdf_error("luafunction", "invalid number");
+ normal_error("luafunction", "invalid number");
} else {
u = save_cur_string();
luacstrings = 0;
@@ -1920,119 +2261,65 @@ void conv_toks(void)
if (luacstrings > 0)
lua_string_start();
}
+ /* no further action */
return;
break;
- case pdf_insert_ht_code:
+ case eTeX_revision_code:
+ push_selector;
+ tprint(eTeX_revision);
+ pop_selector;
+ break;
+ case insert_ht_code:
scan_register_num();
+ push_selector;
+ i = cur_val;
+ p = page_ins_head;
+ while (i >= subtype(vlink(p)))
+ p = vlink(p);
+ if (subtype(p) == i)
+ print_scaled(height(p));
+ else
+ print_char('0');
+ tprint("pt");
+ pop_selector;
break;
- case pdf_ximage_bbox_code:
- scan_int();
- check_obj_type(static_pdf, obj_type_ximage, cur_val);
- i = obj_data_ptr(static_pdf, cur_val);
- scan_int();
- j = cur_val;
- if ((j < 1) || (j > 4))
- pdf_error("pdfximagebbox", "invalid parameter");
+ case dvi_variable_code:
+ done = conv_var_dvi(c);
+ if (done==0)
+ confusion("dvi variable");
+ return;
break;
- /* Cases of 'Scan the argument for command |c|' */
- case eTeX_revision_code:
+ case pdf_variable_code:
+ done = conv_var_pdf(c);
+ if (done==0)
+ confusion("pdf variable");
+ return;
+ break;
+ case dvi_feedback_code:
+ if (get_o_mode() == OMODE_DVI)
+ done = conv_toks_dvi(c);
+ else
+ done = 0;
+ if (done==0)
+ confusion("dvi feedback");
+ else if (done==2)
+ return;
+ break;
+ case pdf_feedback_code:
+ if (get_o_mode() == OMODE_PDF)
+ done = conv_toks_pdf(c);
+ else
+ done = 0;
+ if (done==0)
+ confusion("pdf feedback");
+ else if (done==2)
+ return;
break;
default:
confusion("convert");
break;
}
- old_setting = selector;
- selector = new_string;
-
- /* Print the result of command |c| */
- if (!print_convert_string(c, cur_val)) {
- switch (c) {
- case string_code:
- if (cur_cs != 0)
- sprint_cs(cur_cs);
- else
- print(cur_chr);
- break;
- case meaning_code:
- print_meaning();
- break;
- case left_margin_kern_code:
- p = list_ptr(box(cur_val));
- if ((p != null) && (!is_char_node(p)) &&
- (type(p) == glue_node) && (subtype(p) == left_skip_code + 1))
- p = vlink(p);
- if ((p != null) && (!is_char_node(p)) &&
- (type(p) == margin_kern_node) && (subtype(p) == left_side))
- print_scaled(width(p));
- else
- print_char('0');
- tprint("pt");
- break;
- case right_margin_kern_code:
- q = list_ptr(box(cur_val));
- p = null;
- if (q != null) {
- p = prev_rightmost(q, null);
- if ((p != null) && (!is_char_node(p)) && (type(p) == glue_node)
- && (subtype(p) == right_skip_code + 1))
- p = prev_rightmost(q, p);
- }
- if ((p != null) && (!is_char_node(p)) &&
- (type(p) == margin_kern_node) && (subtype(p) == right_side))
- print_scaled(width(p));
- else
- print_char('0');
- tprint("pt");
- break;
- case pdf_colorstack_init_code:
- print_int(cur_val);
- break;
- case pdf_insert_ht_code:
- i = cur_val;
- p = page_ins_head;
- while (i >= subtype(vlink(p)))
- p = vlink(p);
- if (subtype(p) == i)
- print_scaled(height(p));
- else
- print_char('0');
- tprint("pt");
- break;
- case pdf_ximage_bbox_code:
- if (is_pdf_image(i)) {
- switch (j) {
- case 1:
- print_scaled(epdf_orig_x(i));
- break;
- case 2:
- print_scaled(epdf_orig_y(i));
- break;
- case 3:
- print_scaled(epdf_orig_x(i) + epdf_xsize(i));
- break;
- case 4:
- print_scaled(epdf_orig_y(i) + epdf_ysize(i));
- break;
- }
- } else {
- print_scaled(0);
- }
- tprint("pt");
- break;
- case pdf_creation_date_code:
- case lua_escape_string_code:
- case lua_code:
- case lua_function_code:
- case expanded_code:
- break;
- default:
- confusion("convert");
- break;
- }
- }
-
- selector = old_setting;
str = make_string();
(void) str_toks(str_lstring(str));
flush_str(str);
@@ -2050,18 +2337,144 @@ boolean is_convert(halfword c)
return (c == convert_cmd);
}
+int the_convert_string_dvi(halfword c, int i)
+{
+ return 0;
+}
+
+int the_convert_string_pdf(halfword c, int i)
+{
+ int ff;
+
+ if (scan_keyword("lastlink")) c = pdf_last_link_code;
+ else if (scan_keyword("retval")) c = pdf_retval_code;
+ else if (scan_keyword("lastobj")) c = pdf_last_obj_code;
+ else if (scan_keyword("lastannot")) c = pdf_last_annot_code;
+ else if (scan_keyword("xformname")) c = pdf_xform_name_code;
+ /* else if (scan_keyword("creationdate")) c = pdf_creation_date_code; */
+ else if (scan_keyword("fontname")) c = pdf_font_name_code;
+ else if (scan_keyword("fontobjnum")) c = pdf_font_objnum_code;
+ else if (scan_keyword("fontsize")) c = pdf_font_size_code;
+ else if (scan_keyword("pageref")) c = pdf_page_ref_code;
+ /* else if (scan_keyword("colorstackinit")) c = pdf_colorstack_init_code; */
+
+ switch(c) {
+ case pdf_last_link_code:
+ print_int(pdf_last_link);
+ break;
+ case pdf_retval_code:
+ print_int(pdf_retval);
+ break;
+ case pdf_last_obj_code:
+ print_int(pdf_last_obj);
+ break;
+ case pdf_last_annot_code:
+ print_int(pdf_last_annot);
+ break;
+ case pdf_font_name_code:
+ set_ff(i);
+ print_int(obj_info(static_pdf, pdf_font_num(ff)));
+ break;
+ case pdf_font_objnum_code:
+ set_ff(i);
+ print_int(pdf_font_num(ff));
+ break;
+ case pdf_font_size_code:
+ print_scaled(font_size(i));
+ tprint("pt");
+ break;
+ case pdf_page_ref_code:
+ print_int(pdf_get_obj(static_pdf, obj_type_page, i, false));
+ break;
+ case pdf_xform_name_code:
+ print_int(obj_info(static_pdf, i));
+ break;
+ default:
+ return 0;
+ break;
+ }
+ return 1;
+}
+
str_number the_convert_string(halfword c, int i)
{
int old_setting; /* saved |selector| setting */
str_number ret = 0;
+ boolean done = true ;
old_setting = selector;
selector = new_string;
- if (print_convert_string(c, i)) {
- ret = make_string();
- } else if (c == font_identifier_code) {
- print_font_identifier(i);
- ret = make_string();
+ switch (c) {
+ case number_code:
+ print_int(i);
+ break;
+ case uchar_code:
+ print(i);
+ break;
+ case roman_numeral_code:
+ print_roman_int(i);
+ break;
+ case etex_code:
+ tprint(eTeX_version_string);
+ break;
+ case luatex_revision_code:
+ print(get_luatexrevision());
+ break;
+ case luatex_date_code:
+ print_int(get_luatex_date_info());
+ break;
+ case luatex_banner_code:
+ tprint(luatex_banner);
+ break;
+ case uniform_deviate_code:
+ print_int(unif_rand(i));
+ break;
+ case normal_deviate_code:
+ print_int(norm_rand());
+ break;
+ case format_name_code:
+ print(format_name);
+ break;
+ case job_name_code:
+ print_job_name();
+ break;
+ case font_name_code:
+ append_string((unsigned char *) font_name(i),(unsigned) strlen(font_name(i)));
+ if (font_size(i) != font_dsize(i)) {
+ tprint(" at ");
+ print_scaled(font_size(i));
+ tprint("pt");
+ }
+ break;
+ case font_id_code:
+ print_int(i);
+ break;
+ case math_style_code:
+ print_math_style();
+ break;
+ case eTeX_revision_code:
+ tprint(eTeX_revision);
+ break;
+ case font_identifier_code:
+ print_font_identifier(i);
+ break;
+ case dvi_feedback_code:
+ if (get_o_mode() == OMODE_DVI)
+ done = the_convert_string_dvi(c,i);
+ else
+ done = false;
+ break;
+ case pdf_feedback_code:
+ if (get_o_mode() == OMODE_PDF)
+ done = the_convert_string_pdf(c,i);
+ else
+ done = false;
+ break;
+ default:
+ done = false;
+ break;
}
+ if (done)
+ ret = make_string();
selector = old_setting;
return ret;
}
@@ -2202,11 +2615,10 @@ void read_toks(int n, halfword r, halfword j)
@ @c
str_number tokens_to_string(halfword p)
-{ /* return a string from tokens list */
+{ /* return a string from tokens list */
int old_setting;
if (selector == new_string)
- pdf_error("tokens",
- "tokens_to_string() called while selector = new_string");
+ normal_error("tokens","tokens_to_string() called while selector = new_string");
old_setting = selector;
selector = new_string;
show_token_list(token_link(p), null, -1);
@@ -2352,7 +2764,7 @@ char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz)
Print_uchar(c);
break;
case mac_param_cmd:
- if (!in_lua_escape)
+ if (!in_lua_escape && (is_in_csname==0))
Print_uchar(c);
Print_uchar(c);
break;
diff --git a/Build/source/texk/web2c/luatexdir/utils/utils.w b/Build/source/texk/web2c/luatexdir/utils/utils.w
index 131ee3b6bc2..75bd143ef44 100644
--- a/Build/source/texk/web2c/luatexdir/utils/utils.w
+++ b/Build/source/texk/web2c/luatexdir/utils/utils.w
@@ -135,7 +135,7 @@ void tex_printf(const char *fmt, ...)
current implementation it appears that error messages are misleading,
possibly because pool overflows are detected too late.
- The output format of this fuction must be the same as |pdf_error| in
+ The output format of this fuction must be the same as |normal_error| in
pdftex.web!
@c
@@ -166,7 +166,7 @@ void luatex_fail(const char *fmt, ...)
}
}
-@ The output format of this fuction must be the same as |pdf_warn| in
+@ The output format of this fuction must be the same as |normal_warn| in
pdftex.web!
@c
__attribute__ ((format(printf, 1, 2)))
@@ -177,7 +177,7 @@ void luatex_warn(const char *fmt, ...)
va_start(args, fmt);
selector = term_and_log;
print_ln();
- tex_printf("LuaTeX warning");
+ tex_printf("warning");
if (cur_file_name)
tex_printf(" (file %s)", cur_file_name);
tex_printf(": ");
@@ -239,7 +239,7 @@ scaled ext_xn_over_d(scaled x, scaled n, scaled d)
else
r -= 0.5;
if (r >= (double) max_integer || r <= -(double) max_integer)
- luatex_warn("arithmetic: number too big");
+ luatex_warn("arithmetic number too big");
return (scaled) r;
}
@@ -373,9 +373,9 @@ scaled divide_scaled(scaled s, scaled m, int dd)
m = -m;
}
if (m == 0) {
- pdf_error("arithmetic", "divided by zero");
+ normal_error("arithmetic", "divided by zero");
} else if (m >= (max_integer / 10)) {
- pdf_error("arithmetic", "number too big");
+ normal_error("arithmetic", "number too big");
}
q = s / m;
r = s % m;