summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c100
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/limglib.c9
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llanglib.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnodelib.c96
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c35
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc18
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c97
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w25
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luanode.w246
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h7
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatoken.w43
12 files changed, 379 insertions, 305 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
index 778fbf18876..5ceb7998d1d 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
@@ -196,20 +196,19 @@ int run_saved_callback(int r, const char *name, const char *values, ...)
{
va_list args;
int ret = 0;
- lua_State *L = Luas;
- int stacktop = lua_gettop(L);
+ int stacktop = lua_gettop(Luas);
va_start(args, values);
- luaL_checkstack(L, 2, "out of stack space");
- lua_rawgeti(L, LUA_REGISTRYINDEX, r);
- lua_pushstring(L, name);
- lua_rawget(L, -2);
- if (lua_isfunction(L, -1)) {
+ luaL_checkstack(Luas, 2, "out of stack space");
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX, r);
+ lua_pushstring(Luas, name);
+ lua_rawget(Luas, -2);
+ if (lua_isfunction(Luas, -1)) {
saved_callback_count++;
callback_count++;
ret = do_run_callback(2, values, args);
}
va_end(args);
- lua_settop(L, stacktop);
+ lua_settop(Luas, stacktop);
return ret;
}
@@ -230,17 +229,16 @@ int run_and_save_callback(int i, const char *values, ...)
{
va_list args;
int ret = 0;
- lua_State *L = Luas;
- int stacktop = lua_gettop(L);
+ int stacktop = lua_gettop(Luas);
va_start(args, values);
- if (get_callback(L, i)) {
+ if (get_callback(Luas, i)) {
ret = do_run_callback(1, values, args);
}
va_end(args);
if (ret > 0) {
- ret = luaL_ref(L, LUA_REGISTRYINDEX);
+ ret = luaL_ref(Luas, LUA_REGISTRYINDEX);
}
- lua_settop(L, stacktop);
+ lua_settop(Luas, stacktop);
return ret;
}
@@ -248,14 +246,13 @@ int run_callback(int i, const char *values, ...)
{
va_list args;
int ret = 0;
- lua_State *L = Luas;
- int stacktop = lua_gettop(L);
+ int stacktop = lua_gettop(Luas);
va_start(args, values);
- if (get_callback(L, i)) {
+ if (get_callback(Luas, i)) {
ret = do_run_callback(0, values, args);
}
va_end(args);
- lua_settop(L, stacktop);
+ lua_settop(Luas, stacktop);
return ret;
}
@@ -270,46 +267,45 @@ int do_run_callback(int special, const char *values, va_list vl)
int *bufloc;
char *ss = NULL;
int retval = 0;
- lua_State *L = Luas;
if (special == 2) { /* copy the enclosing table */
- luaL_checkstack(L, 1, "out of stack space");
- lua_pushvalue(L, -2);
+ luaL_checkstack(Luas, 1, "out of stack space");
+ lua_pushvalue(Luas, -2);
}
ss = strchr(values, '>');
- luaL_checkstack(L, (int) (ss - values + 1), "out of stack space");
+ luaL_checkstack(Luas, (int) (ss - values + 1), "out of stack space");
ss = NULL;
for (narg = 0; *values; narg++) {
switch (*values++) {
case CALLBACK_CHARNUM: /* an ascii char! */
cs = (char) va_arg(vl, int);
- lua_pushlstring(L, &cs, 1);
+ lua_pushlstring(Luas, &cs, 1);
break;
case CALLBACK_STRING: /* C string */
s = va_arg(vl, char *);
- lua_pushstring(L, s);
+ lua_pushstring(Luas, s);
break;
case CALLBACK_LSTRING: /* 'lstring' */
lstr = va_arg(vl, lstring *);
- lua_pushlstring(L, (const char *)lstr->s, lstr->l);
+ lua_pushlstring(Luas, (const char *)lstr->s, lstr->l);
break;
case CALLBACK_INTEGER: /* int */
- lua_pushinteger(L, va_arg(vl, int));
+ lua_pushinteger(Luas, va_arg(vl, int));
break;
case CALLBACK_STRNUMBER: /* TeX string */
s = makeclstring(va_arg(vl, int), &len);
- lua_pushlstring(L, s, len);
+ lua_pushlstring(Luas, s, len);
break;
case CALLBACK_BOOLEAN: /* boolean */
- lua_pushboolean(L, va_arg(vl, int));
+ lua_pushboolean(Luas, 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(Luas, (char *) (buffer + first), (size_t) va_arg(vl, int));
break;
case CALLBACK_NODE:
- lua_nodelib_push_fast(L,va_arg(vl, int));
+ lua_nodelib_push_fast(Luas, va_arg(vl, int));
break;
case CALLBACK_DIR:
- lua_push_dir_par(L,va_arg(vl, int));
+ lua_push_dir_par(Luas, va_arg(vl, int));
break;
case '-':
narg--;
@@ -331,7 +327,7 @@ int do_run_callback(int special, const char *values, va_list vl)
{
int i;
lua_active++;
- i = lua_pcall(L, narg, nres, 0);
+ i = lua_pcall(Luas, narg, nres, 0);
lua_active--;
/* lua_remove(L, base); *//* remove traceback function */
if (i != 0) {
@@ -339,11 +335,11 @@ int do_run_callback(int special, const char *values, va_list vl)
* TeX initialization is complete
*/
if (!log_opened_global) {
- fprintf(stderr, "error in callback: %s\n", lua_tostring(L, -1));
+ fprintf(stderr, "error in callback: %s\n", lua_tostring(Luas, -1));
error();
} else {
- lua_gc(L, LUA_GCCOLLECT, 0);
- luatex_error(L, (i == LUA_ERRRUN ? 0 : 1));
+ lua_gc(Luas, LUA_GCCOLLECT, 0);
+ luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
}
return 0;
}
@@ -355,25 +351,25 @@ int do_run_callback(int special, const char *values, va_list vl)
while (*values) {
int b, t;
halfword p;
- t = lua_type(L, nres);
+ t = lua_type(Luas, nres);
switch (*values++) {
case CALLBACK_BOOLEAN:
if (t == LUA_TNIL) {
b = 0;
} else if (t != LUA_TBOOLEAN) {
- fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(Luas, t));
goto EXIT;
} else {
- b = lua_toboolean(L, nres);
+ b = lua_toboolean(Luas, nres);
}
*va_arg(vl, boolean *) = (boolean) b;
break;
case CALLBACK_INTEGER:
if (t != LUA_TNUMBER) {
- fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
- b = lua_tointeger(L, nres);
+ b = lua_tointeger(Luas, nres);
*va_arg(vl, int *) = b;
break;
case CALLBACK_LINE: /* TeX line ... happens frequently when we have a plug-in */
@@ -381,7 +377,7 @@ int do_run_callback(int special, const char *values, va_list vl)
bufloc = 0;
goto EXIT;
} else if (t == LUA_TSTRING) {
- s = lua_tolstring(L, nres, &len);
+ s = lua_tolstring(Luas, nres, &len);
if (s == NULL) { /* |len| can be zero */
bufloc = 0;
} else if (len == 0) {
@@ -397,16 +393,16 @@ int do_run_callback(int special, const char *values, va_list vl)
(*bufloc)--;
}
} else {
- fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
break;
case CALLBACK_STRNUMBER: /* TeX string */
if (t != LUA_TSTRING) {
- fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
- s = lua_tolstring(L, nres, &len);
+ s = lua_tolstring(Luas, nres, &len);
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
@@ -415,10 +411,10 @@ int do_run_callback(int special, const char *values, va_list vl)
break;
case CALLBACK_STRING: /* C string aka buffer */
if (t != LUA_TSTRING) {
- fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
- s = lua_tolstring(L, nres, &len);
+ s = lua_tolstring(Luas, nres, &len);
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
@@ -431,18 +427,18 @@ int do_run_callback(int special, const char *values, va_list vl)
if (t == LUA_TNIL) {
*va_arg(vl, int *) = 0;
} else if (t == LUA_TBOOLEAN) {
- b = lua_toboolean(L, nres);
+ b = lua_toboolean(Luas, nres);
if (b == 0) {
*va_arg(vl, int *) = 0;
} else {
- fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
} else if (t != LUA_TSTRING) {
- fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t));
goto EXIT;
} else {
- s = lua_tolstring(L, nres, &len);
+ s = lua_tolstring(Luas, nres, &len);
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
@@ -454,10 +450,10 @@ int do_run_callback(int special, const char *values, va_list vl)
break;
case CALLBACK_LSTRING: /* lstring */
if (t != LUA_TSTRING) {
- fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+ fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
goto EXIT;
}
- s = lua_tolstring(L, nres, &len);
+ s = lua_tolstring(Luas, nres, &len);
if (s == NULL) /* |len| can be zero */
*va_arg(vl, int *) = 0;
else {
@@ -472,7 +468,7 @@ int do_run_callback(int special, const char *values, va_list vl)
if (t == LUA_TNIL) {
p = null;
} else {
- p = *check_isnode(L,nres);
+ p = *check_isnode(Luas,nres);
}
*va_arg(vl, int *) = p;
break;
diff --git a/Build/source/texk/web2c/luatexdir/lua/limglib.c b/Build/source/texk/web2c/luatexdir/lua/limglib.c
index 44f1d72bff0..eb9e4145a37 100644
--- a/Build/source/texk/web2c/luatexdir/lua/limglib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/limglib.c
@@ -298,17 +298,16 @@ void vf_out_image(PDF pdf, unsigned i)
{
image *a, **aa;
image_dict *ad;
- lua_State *L = Luas;
- lua_rawgeti(L, LUA_REGISTRYINDEX, (int) i);
- aa = (image **) luaL_checkudata(L, -1, TYPE_IMG);
+ lua_rawgeti(Luas, LUA_REGISTRYINDEX, (int) i);
+ aa = (image **) luaL_checkudata(Luas, -1, TYPE_IMG);
a = *aa;
ad = img_dict(a);
if (ad == NULL) {
- luaL_error(L, "invalid image dictionary");
+ luaL_error(Luas, "invalid image dictionary");
}
setup_image(pdf, a, WR_VF_IMG);
place_img(pdf, ad, img_dimen(a), img_transform(a));
- lua_pop(L, 1);
+ lua_pop(Luas, 1);
}
/* metamethods for image */
diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
index 3356e734189..27f3c84d25e 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
@@ -227,7 +227,7 @@ static int do_lang_clean(lua_State * L)
{
char *cleaned;
if (lua_type(L, 1) == LUA_TSTRING) {
- (void) clean_hyphenation(int_par(cur_lang_code), lua_tostring(L, 1), &cleaned);
+ (void) clean_hyphenation(cur_lang_par, lua_tostring(L, 1), &cleaned);
} else {
struct tex_language **lang_ptr;
lang_ptr = check_islang(L, 1);
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
index 561fef65e66..373f2d98382 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
@@ -63,7 +63,7 @@ typedef struct saved_tex_scanner {
static lua_token *check_istoken(lua_State * L, int ud);
-#define TOKEN_METATABLE "luatex_token"
+#define TOKEN_METATABLE "luatex.token"
#define DEBUG 0
#define DEBUG_OUT stdout
@@ -534,7 +534,7 @@ static int run_build(lua_State * L)
if (lua_type(L, 1) == LUA_TNUMBER) {
int cs = 0;
int chr = (int) lua_tointeger(L, 1);
- int cmd = (int) luaL_optinteger(L, 2, get_cat_code(int_par(cat_code_table_code),chr));
+ int cmd = (int) luaL_optinteger(L, 2, get_cat_code(cat_code_table_par,chr));
if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) {
formatted_warning("token lib","not a good token, catcode %i can not be returned, so 12 will be used",(int) cmd);
cmd = 12;
@@ -821,7 +821,7 @@ static int set_macro(lua_State * L)
if (n > 3)
s = lua_tostring(L, 4);
} else {
- ct = int_par(cat_code_table_code) ;
+ ct = cat_code_table_par;
name = lua_tolstring(L, 1, &lname);
if (n > 1)
str = lua_tolstring(L, 2, &lstr);
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
index 7ff2eb7c3bd..c4706e43331 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -170,7 +170,6 @@ while (vlink(t)!=current && t != null) { \
t = vlink(t); \
}
-#define box(A) eqtb[box_base+(A)].hh.rh
#define direct_check_index_range(j,s) \
if (j<0 || j > 65535) { \
luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); \
@@ -2180,8 +2179,7 @@ static int lua_nodelib_direct_has_attribute(lua_State * L)
static int lua_nodelib_get_attribute(lua_State * L)
{
- halfword p;
- p = *check_isnode(L, 1);
+ halfword p = *check_isnode(L, 1);
if (nodetype_has_attributes(type(p))) {
p = node_attr(p);
if (p != null) {
@@ -2209,6 +2207,43 @@ static int lua_nodelib_get_attribute(lua_State * L)
return 1;
}
+static int lua_nodelib_find_attribute(lua_State * L) /* returns attr value and node */
+{
+ halfword c = *check_isnode(L, 1);
+ halfword p ;
+ int i = lua_tointeger(L, 2);
+ while (c != null) {
+ if (nodetype_has_attributes(type(c))) {
+ p = node_attr(c);
+ if (p != null) {
+ p = vlink(p);
+ while (p != null) {
+ if (attribute_id(p) == i) {
+ int ret = attribute_value(p);
+ if (ret == UNUSED_ATTRIBUTE) {
+ break;
+ } else {
+ lua_pushinteger(L,ret);
+ lua_nodelib_push_fast(L, p);
+ return 2;
+ }
+ } else if (attribute_id(p) > i) {
+ break;
+ }
+ p = vlink(p);
+ }
+ }
+ }
+ c = vlink(c);
+ }
+ /*
+ lua_pushnil(L);
+ lua_pushnil(L);
+ return 2;
+ */
+ return 0;
+}
+
/* node.direct.get_attribute */
static int lua_nodelib_direct_get_attribute(lua_State * L)
@@ -2241,6 +2276,43 @@ static int lua_nodelib_direct_get_attribute(lua_State * L)
return 1;
}
+static int lua_nodelib_direct_find_attribute(lua_State * L) /* returns attr value and node */
+{
+ halfword c = lua_tointeger(L, 1);
+ halfword p ;
+ int i = lua_tointeger(L, 2);
+ while (c != null) {
+ if (nodetype_has_attributes(type(c))) {
+ p = node_attr(c);
+ if (p != null) {
+ p = vlink(p);
+ while (p != null) {
+ if (attribute_id(p) == i) {
+ int ret = attribute_value(p);
+ if (ret == UNUSED_ATTRIBUTE) {
+ break;
+ } else {
+ lua_pushinteger(L,ret);
+ lua_pushinteger(L,p);
+ return 2;
+ }
+ } else if (attribute_id(p) > i) {
+ break;
+ }
+ p = vlink(p);
+ }
+ }
+ }
+ c = vlink(c);
+ }
+ /*
+ lua_pushnil(L);
+ lua_pushnil(L);
+ return 2;
+ */
+ return 0;
+}
+
/* node.set_attribute */
static int lua_nodelib_set_attribute(lua_State * L)
@@ -2392,7 +2464,7 @@ static int lua_nodelib_is_zero_glue(lua_State * L)
{
halfword n = *check_isnode(L, 1);
if ((n != null) && (type(n) == glue_node || type(n) == glue_spec_node)) {
- lua_toboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
+ lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
return 1;
} else {
return luaL_error(L, "glue (spec) expected");
@@ -2403,7 +2475,7 @@ static int lua_nodelib_direct_is_zero_glue(lua_State * L)
{
halfword n = lua_tointeger(L, 1);
if ((n != null) && (type(n) == glue_node || type(n) == glue_spec_node)) {
- lua_toboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
+ lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
return 1;
} else {
return luaL_error(L, "glue (spec) expected");
@@ -3291,7 +3363,7 @@ static int lua_nodelib_fast_getfield(lua_State * L)
lua_pushinteger(L, height(n));
} else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) { /* already mapped */
fast_metatable_or_nil_alink(ins_ptr(n));
- /* glue parameters */
+ /* glue parameters */
} else if (lua_key_eq(s, width)) {
lua_pushinteger(L, width(n));
} else if (lua_key_eq(s, stretch)) {
@@ -3310,7 +3382,7 @@ static int lua_nodelib_fast_getfield(lua_State * L)
lua_pushinteger(L, subtype(n));
} else if (lua_key_eq(s, surround)) {
lua_pushinteger(L, surround(n));
- /* glue parameters */
+ /* glue parameters */
} else if (lua_key_eq(s, width)) {
lua_pushinteger(L, width(n));
} else if (lua_key_eq(s, stretch)) {
@@ -4000,7 +4072,7 @@ static int lua_nodelib_direct_getfield(lua_State * L)
lua_pushinteger(L, height(n));
} else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
nodelib_pushdirect_or_nil_alink(ins_ptr(n));
- /* glue */
+ /* glue */
} else if (lua_key_eq(s, width)) {
lua_pushinteger(L, width(n));
} else if (lua_key_eq(s, stretch)) {
@@ -6495,12 +6567,12 @@ static int lua_nodelib_direct_setbox(lua_State * L)
}
}
- save_global_defs = int_par(global_defs_code);
+ save_global_defs = global_defs_par;
if (isglobal) {
- int_par(global_defs_code) = 1;
+ global_defs_par = 1;
}
err = set_tex_box_register(k, j);
- int_par(global_defs_code) = save_global_defs;
+ global_defs_par = save_global_defs;
if (err) {
luaL_error(L, "incorrect value");
}
@@ -6787,6 +6859,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
{"has_glyph", lua_nodelib_direct_has_glyph},
{"has_attribute", lua_nodelib_direct_has_attribute},
{"get_attribute", lua_nodelib_direct_get_attribute},
+ {"find_attribute", lua_nodelib_direct_find_attribute},
{"has_field", lua_nodelib_direct_has_field},
{"is_char", lua_nodelib_direct_is_char},
{"is_glyph", lua_nodelib_direct_is_glyph},
@@ -6881,6 +6954,7 @@ static const struct luaL_Reg nodelib_f[] = {
{"has_glyph", lua_nodelib_has_glyph},
{"has_attribute", lua_nodelib_has_attribute},
{"get_attribute", lua_nodelib_get_attribute},
+ {"find_attribute", lua_nodelib_find_attribute},
{"has_field", lua_nodelib_has_field},
{"is_char", lua_nodelib_is_char},
{"is_glyph", lua_nodelib_is_glyph},
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index 2161d791108..de82be7479e 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -950,6 +950,20 @@ static int getpdforigin(lua_State * L)
return 2 ;
}
+static int setpdfimageresolution(lua_State * L)
+{
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ set_tex_extension_count_register(c_pdf_image_resolution,lua_tointeger(L, 1));
+ }
+ return 0;
+}
+
+static int getpdfimageresolution(lua_State * L)
+{
+ lua_pushinteger(L,get_tex_extension_count_register(c_pdf_image_resolution));
+ return 1 ;
+}
+
static int setpdfthreadmargin(lua_State * L) {
if (lua_type(L, 1) == LUA_TNUMBER) {
set_tex_extension_dimen_register(d_pdf_thread_margin,lua_tointeger(L, 1));
@@ -1065,6 +1079,24 @@ static int newpdfcolorstack(lua_State * L)
return 1 ;
}
+
+static int l_set_font_attributes(lua_State * L)
+{
+ int f = luaL_checkinteger(L, -2);
+ int i ;
+ /*char *s;*/
+ const char *st;
+ if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) {
+ /* is this dup needed? */
+ /*s = xstrdup(st);*/
+ i = maketexstring(st); /* brrr */
+ set_pdf_font_attr(f, i);
+ /*free(s);*/
+ }
+ return 0;
+}
+
+
static const struct luaL_Reg pdflib[] = {
{ "gethpos", l_gethpos },
{ "getvpos", l_getvpos },
@@ -1081,6 +1113,7 @@ static const struct luaL_Reg pdflib[] = {
{ "objtype", l_objtype },
{ "getmatrix", l_getmatrix },
{ "hasmatrix", l_hasmatrix },
+ { "setfontattributes", l_set_font_attributes },
{ "setcatalog", l_set_catalog },
{ "setinfo", l_set_info },
{ "setnames", l_set_names },
@@ -1126,6 +1159,8 @@ static const struct luaL_Reg pdflib[] = {
{ "newcolorstack", newpdfcolorstack },
{ "setorigin", setpdforigin },
{ "getorigin", getpdforigin },
+ { "setimageresolution", setpdfimageresolution },
+ { "getimageresolution", getpdfimageresolution },
{ "setthreadmargin", setpdfthreadmargin },
{ "setdestmargin", setpdfdestmargin },
{ "setlinkmargin", setpdflinkmargin },
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
index cc311daebee..9ad50c99aeb 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
@@ -105,17 +105,17 @@ static void clear_operand_stack (scannerdata *self, int from);
static Token *_parseToken (scannerdata *self, int c);
static void push_token (lua_State *L, scannerdata *self);
-void *xmalloc (size_t size)
+static void *priv_xmalloc (size_t size)
{
void *new_mem = (void *)malloc(size);
if (new_mem == NULL) {
- fprintf(stderr, "fatal: memory exhausted (xmalloc of %lu bytes).\n", (unsigned long)size);
+ fprintf(stderr, "fatal: memory exhausted (priv_xmalloc of %lu bytes).\n", (unsigned long)size);
exit(1);
}
return new_mem;
}
-void *xrealloc (void *old_ptr, size_t size)
+static void *priv_xrealloc (void *old_ptr, size_t size)
{
void *new_mem = (void *)realloc(old_ptr, size);
if (new_mem == NULL) {
@@ -125,12 +125,12 @@ void *xrealloc (void *old_ptr, size_t size)
return new_mem;
}
-#define xreallocarray(ptr,type,size) ((type*)xrealloc(ptr,(size+1)*sizeof(type)))
+#define xreallocarray(ptr,type,size) ((type*)priv_xrealloc(ptr,(size+1)*sizeof(type)))
#define INITBUFSIZE 64
#define define_buffer(a) \
- char *a = (char *)xmalloc (INITBUFSIZE); \
+ char *a = (char *)priv_xmalloc (INITBUFSIZE); \
int a##_size = INITBUFSIZE; \
int a##index = 0; \
memset (a,0,INITBUFSIZE)
@@ -194,7 +194,7 @@ static void push_operand (scannerdata *self, Token *token)
static Token * new_operand (pdf_token_type c)
{
- Token *token = (Token *)xmalloc(sizeof(Token));
+ Token *token = (Token *)priv_xmalloc(sizeof(Token));
memset (token, 0, sizeof(Token));
token->type = c;
return token;
@@ -586,7 +586,7 @@ static int scanner_scan(lua_State * L)
luaL_checktype(L, 3, LUA_TTABLE);
self = scanner_push(L);
memset(self,0,sizeof(scannerdata));
- self->_operandstack = (Token **)xmalloc (MAXOPERANDS * sizeof (Token));
+ self->_operandstack = (Token **)priv_xmalloc (MAXOPERANDS * sizeof (Token));
memset (self->_operandstack,0,(MAXOPERANDS * sizeof (Token)));
// 4 = self
if (lua_type(L,1)== LUA_TTABLE) {
@@ -598,7 +598,7 @@ static int scanner_scan(lua_State * L)
uin = (udstruct *) luaL_checkudata(L, -1, M_Object);
if (((Object *) uin->d)->isStream()) {
ObjectList *rover = self->_streams;
- ObjectList *item = (ObjectList *)xmalloc (sizeof(ObjectList));
+ ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList));
item->stream = ((Object *) uin->d);
item->next = NULL;
if (!rover) {
@@ -637,7 +637,7 @@ static int scanner_scan(lua_State * L)
arrayref->get(i, val);
if (val->isStream()) {
ObjectList *rover = self->_streams;
- ObjectList *item = (ObjectList *)xmalloc (sizeof(ObjectList));
+ ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList));
item->stream = val;
item->next = NULL;
if (!rover) {
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index aa0e8c7e4b2..0966176b1e2 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -24,14 +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
-#define skip(A) eqtb[skip_base+(A)].hh.rh
-#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh
-#define count(A) eqtb[count_base+(A)].hh.rh
-#define box(A) equiv(box_base+(A))
-
/* tex random generators */
extern int unif_rand(int );
extern int norm_rand(void );
@@ -541,7 +533,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(px_dimen_code);
+ v = px_dimen_par;
} else {
goto NOT_FOUND;
}
@@ -560,11 +552,11 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret)
if (strncmp(s, "true", 4) == 0) {
/* Adjust (f)for the magnification ratio */
s += 4;
- if (output_mode_used == OMODE_DVI) {
+ if (output_mode_used <= OMODE_DVI) {
prepare_mag();
- if (int_par(mag_code) != 1000) {
- cur_val = xn_over_d(cur_val, 1000, int_par(mag_code));
- f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code);
+ if (mag_par != 1000) {
+ cur_val = xn_over_d(cur_val, 1000, mag_par);
+ f = (1000 * f + 0200000 * tex_remainder) / mag_par;
cur_val = cur_val + (f / 0200000);
f = f % 0200000;
}
@@ -749,9 +741,9 @@ static int get_item_index(lua_State * L, int i, int base)
size_t len; \
const char *str; \
int key, err, cs; \
- int save_global_defs = int_par(global_defs_code); \
+ int save_global_defs = global_defs_par; \
if (is_global) { \
- int_par(global_defs_code) = 1; \
+ global_defs_par = 1; \
} \
switch (lua_type(L, where)) { \
case LUA_TSTRING: \
@@ -779,7 +771,7 @@ static int get_item_index(lua_State * L, int i, int base)
} \
break; \
case LUA_TNUMBER: \
- key = luaL_checkinteger(L, where); \
+ key = luaL_checkinteger(L, where); \
if (key>=0 && key <= 65535) { \
err = set_register(key, value); \
if (err) { \
@@ -792,7 +784,7 @@ static int get_item_index(lua_State * L, int i, int base)
default: \
luaL_error(L, "argument of 'set%s' must be a string or a number", what); \
} \
- int_par(global_defs_code) = save_global_defs; \
+ global_defs_par = save_global_defs; \
}
static int gettex(lua_State * L);
@@ -1088,7 +1080,7 @@ static int settoks(lua_State * L)
char *s;
const char *ss;
int is_global = 0;
- int save_global_defs = int_par(global_defs_code);
+ int save_global_defs = global_defs_par;
int n = lua_gettop(L);
if (n == 3 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
@@ -1096,7 +1088,7 @@ static int settoks(lua_State * L)
is_global = 1;
}
if (is_global)
- int_par(global_defs_code) = 1;
+ global_defs_par = 1;
i = lua_gettop(L);
if (lua_type(L,i) != LUA_TSTRING) {
luaL_error(L, "unsupported value type");
@@ -1109,7 +1101,7 @@ static int settoks(lua_State * L)
check_index_range(k, "settoks");
err = set_tex_toks_register(k, str);
xfree(str.s);
- int_par(global_defs_code) = save_global_defs;
+ global_defs_par = save_global_defs;
if (err) {
luaL_error(L, "incorrect value");
}
@@ -1123,7 +1115,7 @@ static int scantoks(lua_State * L)
char *s;
const char *ss;
int is_global = 0;
- int save_global_defs = int_par(global_defs_code);
+ int save_global_defs = global_defs_par;
int n = lua_gettop(L);
if (n == 4 && (lua_type(L,1) == LUA_TSTRING)) {
const char *s = lua_tostring(L, 1);
@@ -1132,7 +1124,7 @@ static int scantoks(lua_State * L)
}
/* action : vsettokscct(L, is_global); */
if (is_global)
- int_par(global_defs_code) = 1;
+ global_defs_par = 1;
i = lua_gettop(L);
if (lua_type(L,i) != LUA_TSTRING) {
luaL_error(L, "unsupported value type");
@@ -1146,7 +1138,7 @@ static int scantoks(lua_State * L)
check_index_range(k, "settoks");
err = scan_tex_toks_register(k, c, str);
xfree(str.s);
- int_par(global_defs_code) = save_global_defs;
+ global_defs_par = save_global_defs;
if (err) {
luaL_error(L, "incorrect value");
}
@@ -1243,9 +1235,9 @@ static int isbox(lua_State * L)
static int vsetbox(lua_State * L, int is_global)
{
int j, k, err;
- int save_global_defs = int_par(global_defs_code);
+ int save_global_defs = global_defs_par;
if (is_global)
- int_par(global_defs_code) = 1;
+ global_defs_par = 1;
k = get_box_id(L, -2, true);
check_index_range(k, "setbox");
if (lua_isboolean(L, -1)) {
@@ -1263,7 +1255,7 @@ static int vsetbox(lua_State * L, int is_global)
}
err = set_tex_box_register(k, j);
- int_par(global_defs_code) = save_global_defs;
+ global_defs_par = save_global_defs;
if (err) {
luaL_error(L, "incorrect value");
}
@@ -1361,7 +1353,7 @@ static int setcatcode(lua_State * L)
int ch;
halfword val;
int level = cur_level;
- int cattable = int_par(cat_code_table_code);
+ int cattable = cat_code_table_par;
int n = lua_gettop(L);
int f = 1;
if (n>1 && lua_type(L,1) == LUA_TTABLE)
@@ -1386,7 +1378,7 @@ static int setcatcode(lua_State * L)
static int getcatcode(lua_State * L)
{
- int cattable = int_par(cat_code_table_code);
+ int cattable = cat_code_table_par;
int ch = luaL_checkinteger(L, -1);
if (lua_gettop(L)>=2 && lua_type(L,-2)==LUA_TNUMBER) {
cattable = luaL_checkinteger(L, -2);
@@ -1860,7 +1852,7 @@ static int getromannumeral(lua_State * L)
static int get_parshape(lua_State * L)
{
- halfword par_shape_ptr = equiv(par_shape_loc);
+ halfword par_shape_ptr = par_shape_par_ptr;
if (par_shape_ptr != 0) {
int m = 1;
int n = vinfo(par_shape_ptr + 1);
@@ -2591,27 +2583,27 @@ static int tex_run_linebreak(lua_State * L)
}
lua_pop(L, 1);
- get_int_par (pretolerance, int_par(pretolerance_code));
- get_int_par (tracingparagraphs, int_par(tracing_paragraphs_code));
- get_int_par (tolerance, int_par(tolerance_code));
- get_int_par (looseness, int_par(looseness_code));
- get_int_par (adjustspacing, int_par(adjust_spacing_code));
- get_int_par (adjdemerits, int_par(adj_demerits_code));
- get_int_par (protrudechars, int_par(protrude_chars_code));
- get_int_par (linepenalty, int_par(line_penalty_code));
- get_int_par (lastlinefit, int_par(last_line_fit_code));
- get_int_par (doublehyphendemerits, int_par(double_hyphen_demerits_code));
- get_int_par (finalhyphendemerits, int_par(final_hyphen_demerits_code));
- get_int_par (hangafter, int_par(hang_after_code));
- get_intx_par (interlinepenalty,int_par(inter_line_penalty_code), interlinepenalties, equiv(inter_line_penalties_loc));
- get_intx_par (clubpenalty, int_par(club_penalty_code), clubpenalties, equiv(club_penalties_loc));
- get_intx_par (widowpenalty, int_par(widow_penalty_code), widowpenalties, equiv(widow_penalties_loc));
- get_int_par (brokenpenalty, int_par(broken_penalty_code));
- get_dimen_par(emergencystretch, dimen_par(emergency_stretch_code));
- get_dimen_par(hangindent, dimen_par(hang_indent_code));
- get_dimen_par(hsize, dimen_par(hsize_code));
- get_glue_par (leftskip, glue_par(left_skip_code));
- get_glue_par (rightskip, glue_par(right_skip_code));
+ get_int_par (pretolerance, pretolerance_par);
+ get_int_par (tracingparagraphs, tracing_paragraphs_par);
+ get_int_par (tolerance, tolerance_par);
+ get_int_par (looseness, looseness_par);
+ get_int_par (adjustspacing, adjust_spacing_par);
+ get_int_par (adjdemerits, adj_demerits_par);
+ get_int_par (protrudechars, protrude_chars_par);
+ get_int_par (linepenalty, line_penalty_par);
+ get_int_par (lastlinefit, last_line_fit_par);
+ get_int_par (doublehyphendemerits, double_hyphen_demerits_par);
+ get_int_par (finalhyphendemerits, final_hyphen_demerits_par);
+ get_int_par (hangafter, hang_after_par);
+ get_intx_par (interlinepenalty,inter_line_penalty_par, interlinepenalties, equiv(inter_line_penalties_loc));
+ get_intx_par (clubpenalty, club_penalty_par, clubpenalties, equiv(club_penalties_loc));
+ get_intx_par (widowpenalty, widow_penalty_par, widowpenalties, equiv(widow_penalties_loc));
+ get_int_par (brokenpenalty, broken_penalty_par);
+ get_dimen_par(emergencystretch, emergency_stretch_par);
+ get_dimen_par(hangindent, hang_indent_par);
+ get_dimen_par(hsize, hsize_par);
+ get_glue_par (leftskip, left_skip_par);
+ get_glue_par (rightskip, right_skip_par);
ext_do_line_break(paragraph_dir,
pretolerance,
tracingparagraphs,
@@ -2827,6 +2819,7 @@ static int tex_save_box_resource(lua_State * L)
int index = null;
int attributes = null;
int resources = null;
+ int type = 0;
boolean immediate = false;
/* box attributes resources */
halfword boxnumber = lua_tointeger(L,1);
@@ -2841,6 +2834,9 @@ static int tex_save_box_resource(lua_State * L)
if (lua_type(L,4) == LUA_TBOOLEAN) {
immediate = lua_toboolean(L, 4);
}
+ if (lua_type(L,5) == LUA_TNUMBER) {
+ type = lua_tointeger(L, 5);
+ }
/* more or less same as scanner variant */
boxdata = box(boxnumber);
if (boxdata == null)
@@ -2856,6 +2852,7 @@ static int tex_save_box_resource(lua_State * L)
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));
+ set_obj_xform_type(static_pdf, index, type);
box(boxnumber) = null;
last_saved_box_index = index;
lua_pushinteger(L, index);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index 4456834206d..6681b4b560c 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -88,6 +88,7 @@ const_string LUATEX_IHELP[] = {
" --[no-]shell-escape disable/enable system commands",
" --shell-restricted restrict system commands to a list of commands given in texmf.cnf",
" --synctex=NUMBER enable synctex",
+ " --utc init time to UTC",
" --version display version and exit",
"",
"Alternate behaviour models can be obtained by special switches",
@@ -183,6 +184,7 @@ char *jithash_hashname = NULL;
int safer_option = 0;
int nosocket_option = 0;
+int utc_option = 0;
@ Reading the options.
@@ -212,6 +214,7 @@ static struct option long_options[] = {
{"jithash", 1, 0, 0},
#endif
{"safer", 0, &safer_option, 1},
+ {"utc", 0, &utc_option, 1},
{"nosocket", 0, &nosocket_option, 1},
{"help", 0, 0, 0},
{"ini", 0, &ini_version, 1},
@@ -573,6 +576,7 @@ static void init_kpse(void)
kpse_set_program_name(argv[0], user_progname);
init_shell_escape(); /* set up 'restrictedshell' */
+ init_start_time();
program_name_set = 1 ;
if (recorderoption) {
recorder_enabled = 1;
@@ -856,6 +860,8 @@ void lua_initialize(int ac, char **av)
char *banner;
int kpse_init;
size_t len;
+ int starttime;
+ int utc;
static char LC_CTYPE_C[] = "LC_CTYPE=C";
static char LC_COLLATE_C[] = "LC_COLLATE=C";
static char LC_NUMERIC_C[] = "LC_NUMERIC=C";
@@ -1032,6 +1038,25 @@ void lua_initialize(int ac, char **av)
}
}
+ starttime = -1 ;
+ get_lua_number("texconfig", "start_time", &starttime);
+ if (starttime < 0) {
+ /*
+ We provide this one for compatibility reasons and therefore also in
+ uppercase.
+ */
+ get_lua_number("texconfig", "SOURCE_DATE_EPOCH", &starttime);
+ }
+ if (starttime >= 0) {
+ set_start_time(starttime);
+ }
+
+ utc = -1 ;
+ get_lua_boolean("texconfig", "use_utc_time", &utc);
+ if (utc >= 0 && utc <= 1) {
+ utc_option = utc;
+ }
+
fix_dumpname();
} else {
if (luainit) {
diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w
index 3325245fcaa..39b68a68614 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luanode.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w
@@ -28,109 +28,57 @@ nodes are removed or inserted, temp nodes don't interfere */
@ @c
void lua_node_filter_s(int filterid, int extrainfo)
{
- lua_State *L = Luas;
int callback_id = callback_defined(filterid);
- int s_top = lua_gettop(L);
+ int s_top = lua_gettop(Luas);
if (callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return;
}
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (!get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return;
}
- lua_push_string_by_index(L,extrainfo); /* arg 1 */
- if (lua_pcall(L, 1, 0, 0) != 0) {
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
+ lua_push_string_by_index(Luas,extrainfo); /* arg 1 */
+ if (lua_pcall(Luas, 1, 0, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return;
}
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return;
}
@ @c
-/*
-void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
-{
- halfword ret;
- int a;
- lua_State *L = Luas;
- int s_top = lua_gettop(L);
- int callback_id = callback_defined(filterid);
- if (head_node == null || vlink(head_node) == null || callback_id <= 0) {
- lua_settop(L, s_top);
- return;
- }
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
- return;
- }
- alink(vlink(head_node)) = null ;
- nodelist_to_lua(L, vlink(head_node));
- lua_push_group_code(L,extrainfo);
- if (lua_pcall(L, 2, 1, 0) != 0) {
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
- error();
- return;
- }
- if (lua_isboolean(L, -1)) {
- if (lua_toboolean(L, -1) != 1) {
- flush_node_list(vlink(head_node));
- vlink(head_node) = null;
- }
- } else {
- a = nodelist_from_lua(L);
- try_couple_nodes(head_node,a);
- }
- lua_pop(L, 2);
- if (fix_node_lists)
- fix_node_list(head_node);
- ret = vlink(head_node);
- if (ret != null) {
- while (vlink(ret) != null)
- ret = vlink(ret);
- *tail_node = ret;
- } else {
- *tail_node = head_node;
- }
- lua_settop(L, s_top);
- return;
-}
-*/
-
void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
{
halfword start_node, start_done, last_node;
- lua_State *L = Luas;
- int s_top = lua_gettop(L);
+ int s_top = lua_gettop(Luas);
int callback_id = callback_defined(filterid);
if (head_node == null || callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return;
}
/* we start after head */
start_node = vlink(head_node);
- if (start_node == null || !get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (start_node == null || !get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return;
}
/* we make sure we have no prev */
alink(start_node) = null ;
/* the action */
- nodelist_to_lua(L, start_node);
- lua_push_group_code(L,extrainfo);
- if (lua_pcall(L, 2, 1, 0) != 0) {
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
+ nodelist_to_lua(Luas, start_node);
+ lua_push_group_code(Luas,extrainfo);
+ if (lua_pcall(Luas, 2, 1, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return;
}
/* the result */
- if (lua_isboolean(L, -1)) {
- if (lua_toboolean(L, -1) != 1) {
+ if (lua_isboolean(Luas, -1)) {
+ if (lua_toboolean(Luas, -1) != 1) {
/* discard */
flush_node_list(start_node);
vlink(head_node) = null;
@@ -139,11 +87,11 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
}
} else {
/* append to old head */
- start_done = nodelist_from_lua(L);
+ start_done = nodelist_from_lua(Luas);
try_couple_nodes(head_node,start_done);
}
/* redundant as we set top anyway */
- lua_pop(L, 2);
+ lua_pop(Luas, 2);
/* find tail in order to update tail */
start_node = vlink(head_node);
if (start_node != null) {
@@ -168,7 +116,7 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
*tail_node = head_node;
}
/* clean up */
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return;
}
@@ -178,33 +126,32 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea
int a;
register halfword *p;
int ret = 0; /* failure */
- lua_State *L = Luas;
- int s_top = lua_gettop(L);
+ int s_top = lua_gettop(Luas);
int callback_id = callback_defined(linebreak_filter_callback);
if (head_node == null || vlink(head_node) == null || callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return ret;
}
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (!get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return ret;
}
alink(vlink(head_node)) = null ; /* hh-ls */
- nodelist_to_lua(L, vlink(head_node)); /* arg 1 */
- lua_pushboolean(L, is_broken); /* arg 2 */
- if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
+ nodelist_to_lua(Luas, vlink(head_node)); /* arg 1 */
+ lua_pushboolean(Luas, is_broken); /* arg 2 */
+ if (lua_pcall(Luas, 2, 1, 0) != 0) { /* no arg, 1 result */
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return ret;
}
- p = lua_touserdata(L, -1);
+ p = lua_touserdata(Luas, -1);
if (p != NULL) {
- a = nodelist_from_lua(L);
+ a = nodelist_from_lua(Luas);
try_couple_nodes(*new_head,a);
ret = 1;
}
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return ret;
}
@@ -212,39 +159,38 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea
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 s_top = lua_gettop(Luas);
int callback_id = callback_defined(append_to_vlist_filter_callback);
if (box == null || callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return 0;
}
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (!get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return 0;
}
- nodelist_to_lua(L, box);
- lua_push_string_by_index(L,location);
- lua_pushinteger(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);
+ nodelist_to_lua(Luas, box);
+ lua_push_string_by_index(Luas,location);
+ lua_pushinteger(Luas, (int) prev_depth);
+ lua_pushboolean(Luas, is_mirrored);
+ if (lua_pcall(Luas, 4, 2, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return 0;
}
- if (lua_type(L,-1) == LUA_TNUMBER) {
- *next_depth = lua_tointeger(L,-1);
+ if (lua_type(Luas,-1) == LUA_TNUMBER) {
+ *next_depth = lua_tointeger(Luas,-1);
*prev_set = true;
- if (lua_type(L, -2) != LUA_TNIL) {
- p = check_isnode(L, -2);
+ if (lua_type(Luas, -2) != LUA_TNIL) {
+ p = check_isnode(Luas, -2);
*result = *p;
}
- } else if (lua_type(L, -1) != LUA_TNIL) {
- p = check_isnode(L, -1);
+ } else if (lua_type(Luas, -1) != LUA_TNIL) {
+ p = check_isnode(Luas, -1);
*result = *p;
}
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return 1;
}
@@ -252,50 +198,49 @@ int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth,
halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction, halfword attr)
{
halfword ret;
- lua_State *L = Luas;
- int s_top = lua_gettop(L);
+ int s_top = lua_gettop(Luas);
int callback_id = callback_defined(hpack_filter_callback);
if (head_node == null || callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return head_node;
}
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (!get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return head_node;
}
alink(head_node) = null ; /* hh-ls */
- nodelist_to_lua(L, head_node);
- lua_push_group_code(L,extrainfo);
- lua_pushinteger(L, size);
- lua_push_pack_type(L,pack_type);
+ nodelist_to_lua(Luas, head_node);
+ lua_push_group_code(Luas,extrainfo);
+ lua_pushinteger(Luas, size);
+ lua_push_pack_type(Luas, pack_type);
if (pack_direction >= 0) {
- lua_push_dir_par(L, pack_direction);
+ lua_push_dir_par(Luas, pack_direction);
} else {
- lua_pushnil(L);
+ lua_pushnil(Luas);
}
if (attr != null) {
- nodelist_to_lua(L, attr);
+ nodelist_to_lua(Luas, attr);
} else {
- lua_pushnil(L);
+ lua_pushnil(Luas);
}
- if (lua_pcall(L, 6, 1, 0) != 0) {
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
+ if (lua_pcall(Luas, 6, 1, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return head_node;
}
ret = head_node;
- if (lua_isboolean(L, -1)) {
- if (lua_toboolean(L, -1) != 1) {
+ if (lua_isboolean(Luas, -1)) {
+ if (lua_toboolean(Luas, -1) != 1) {
flush_node_list(head_node);
ret = null;
}
} else {
- ret = nodelist_from_lua(L);
+ ret = nodelist_from_lua(Luas);
}
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
#if 0
- lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE);
+ lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE);
#endif
if (fix_node_lists)
fix_node_list(ret);
@@ -308,10 +253,9 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled
{
halfword ret;
int callback_id;
- lua_State *L = Luas;
- int s_top = lua_gettop(L);
+ int s_top = lua_gettop(Luas);
if (head_node == null) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return head_node;
}
if (extrainfo == 8) { /* output */
@@ -320,47 +264,47 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled
callback_id = callback_defined(vpack_filter_callback);
}
if (callback_id <= 0) {
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
return head_node;
}
- if (!get_callback(L, callback_id)) {
- lua_settop(L, s_top);
+ if (!get_callback(Luas, callback_id)) {
+ lua_settop(Luas, s_top);
return head_node;
}
alink(head_node) = null ; /* hh-ls */
- nodelist_to_lua(L, head_node);
- lua_push_group_code(L,extrainfo);
- lua_pushinteger(L, size);
- lua_push_pack_type(L,pack_type);
- lua_pushinteger(L, maxd);
+ nodelist_to_lua(Luas, head_node);
+ lua_push_group_code(Luas, extrainfo);
+ lua_pushinteger(Luas, size);
+ lua_push_pack_type(Luas, pack_type);
+ lua_pushinteger(Luas, maxd);
if (pack_direction >= 0) {
- lua_push_dir_par(L, pack_direction);
+ lua_push_dir_par(Luas, pack_direction);
} else {
- lua_pushnil(L);
+ lua_pushnil(Luas);
}
if (attr != null) {
- nodelist_to_lua(L, attr);
+ nodelist_to_lua(Luas, attr);
} else {
- lua_pushnil(L);
+ lua_pushnil(Luas);
}
- if (lua_pcall(L, 7, 1, 0) != 0) {
- fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
- lua_settop(L, s_top);
+ if (lua_pcall(Luas, 7, 1, 0) != 0) {
+ fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+ lua_settop(Luas, s_top);
error();
return head_node;
}
ret = head_node;
- if (lua_isboolean(L, -1)) {
- if (lua_toboolean(L, -1) != 1) {
+ if (lua_isboolean(Luas, -1)) {
+ if (lua_toboolean(Luas, -1) != 1) {
flush_node_list(head_node);
ret = null;
}
} else {
- ret = nodelist_from_lua(L);
+ ret = nodelist_from_lua(Luas);
}
- lua_settop(L, s_top);
+ lua_settop(Luas, s_top);
#if 0
- lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE);
+ lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE);
#endif
if (fix_node_lists)
fix_node_list(ret);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index dddfa9f2209..cf3740101da 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -198,6 +198,7 @@ extern void preset_environment(lua_State * L, const parm_struct * p, const char
extern char *startup_filename;
extern int safer_option;
extern int nosocket_option;
+extern int utc_option;
extern char *last_source_name;
extern int last_lineno;
@@ -824,7 +825,8 @@ make_lua_key(xsize);\
make_lua_key(xyz_zoom);\
make_lua_key(yoffset); \
make_lua_key(yres); \
-make_lua_key(ysize)
+make_lua_key(ysize); \
+make_lua_key(__index)
#define set_init_keys \
init_lua_key(cmdname);init_lua_key(expandable);init_lua_key(protected);\
@@ -1178,10 +1180,12 @@ init_lua_key(xyz_zoom);\
init_lua_key(yoffset);\
init_lua_key(yres);\
init_lua_key(ysize);\
+init_lua_key(__index);\
init_lua_key_alias(empty_string,"");\
init_lua_key_alias(lua_bytecodes_indirect,"lua.bytecodes.indirect");\
init_lua_key_alias(lua_functions,"lua.functions");\
init_lua_key_alias(luatex_node, "luatex.node");\
+init_lua_key_alias(luatex_token, "luatex.token");\
init_lua_key_alias(mLTL,"-LTL");\
init_lua_key_alias(mRTT,"-RTT");\
init_lua_key_alias(mTLT,"-TLT");\
@@ -1599,3 +1603,4 @@ use_lua_key(xyz_zoom);
use_lua_key(yoffset);
use_lua_key(yres);
use_lua_key(ysize);
+use_lua_key(__index);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
index 893519b5925..a567c7f7a2b 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatoken.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
@@ -113,6 +113,7 @@ command_item command_names[] = {
{"assign_mu_glue", assign_mu_glue_cmd, NULL},
{"assign_font_dimen", assign_font_dimen_cmd, NULL},
{"assign_font_int", assign_font_int_cmd, NULL},
+ {"assign_hang_indent", assign_hang_indent_cmd, NULL},
{"set_aux", set_aux_cmd, NULL},
{"set_prev_graf", set_prev_graf_cmd, NULL},
{"set_page_dimen", set_page_dimen_cmd, NULL},
@@ -362,34 +363,33 @@ int tokenlist_from_lua(lua_State * L)
static void do_get_token_lua(int callback_id)
{
- lua_State *L = Luas;
while (1) {
- if (!get_callback(L, callback_id)) {
+ if (!get_callback(Luas, callback_id)) {
get_next();
- lua_pop(L, 2);
+ lua_pop(Luas, 2);
break;
}
- if (lua_pcall(L, 0, 1, 0) != 0) {
- tex_error(lua_tostring(L, -1), NULL);
- lua_pop(L, 2);
+ if (lua_pcall(Luas, 0, 1, 0) != 0) {
+ tex_error(lua_tostring(Luas, -1), NULL);
+ lua_pop(Luas, 2);
break;
}
- if (lua_istable(L, -1)) {
- lua_rawgeti(L, -1, 1);
- if (lua_istable(L, -1)) {
+ if (lua_istable(Luas, -1)) {
+ lua_rawgeti(Luas, -1, 1);
+ if (lua_istable(Luas, -1)) {
int p, q, r;
size_t i, j;
- lua_pop(L, 1);
+ lua_pop(Luas, 1);
r = get_avail();
p = r;
- j = lua_rawlen(L, -1);
+ j = lua_rawlen(Luas, -1);
if (j > 0) {
for (i = 1; i <= j; i++) {
- lua_rawgeti(L, -1, (int) i);
- if (get_cur_cmd(L) || get_cur_cs(L)) {
+ lua_rawgeti(Luas, -1, (int) i);
+ if (get_cur_cmd(Luas) || get_cur_cs(Luas)) {
store_new_token(cur_tok);
}
- lua_pop(L, 1);
+ lua_pop(Luas, 1);
}
}
if (p != r) {
@@ -399,23 +399,22 @@ static void do_get_token_lua(int callback_id)
cur_input.nofilter_field = true;
get_next();
} else {
- tex_error("error: illegal or empty token list returned",
- NULL);
+ tex_error("error: illegal or empty token list returned", NULL);
}
- lua_pop(L, 2);
+ lua_pop(Luas, 2);
break;
} else {
- lua_pop(L, 1);
- if (get_cur_cmd(L) || get_cur_cs(L)) {
- lua_pop(L, 2);
+ lua_pop(Luas, 1);
+ if (get_cur_cmd(Luas) || get_cur_cs(Luas)) {
+ lua_pop(Luas, 2);
break;
} else {
- lua_pop(L, 2);
+ lua_pop(Luas, 2);
continue;
}
}
} else {
- lua_pop(L, 2);
+ lua_pop(Luas, 2);
}
}
return;