summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-11-17 04:33:03 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-11-17 04:33:03 +0000
commit88544379a8817dd9e6bda685a21ee8229a13df0e (patch)
tree5be1759db610dde4e0ea428139ffbb03ab2ac794 /Build/source
parentcec52b672b7828d5f6d62582f4a0415b51baed58 (diff)
web2c/luatexdir: Sync with the upstream.
git-svn-id: svn://tug.org/texlive/trunk@38879 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writeimg.w23
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c241
2 files changed, 146 insertions, 118 deletions
diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.w b/Build/source/texk/web2c/luatexdir/image/writeimg.w
index a93fb6de642..ff667cfe62e 100644
--- a/Build/source/texk/web2c/luatexdir/image/writeimg.w
+++ b/Build/source/texk/web2c/luatexdir/image/writeimg.w
@@ -309,20 +309,23 @@ void read_img(PDF pdf,
char *filepath = NULL;
int callback_id;
assert(idict != NULL);
- if (img_filename(idict) == NULL)
+ if (img_filename(idict) == NULL) {
luatex_fail("image file name missing");
+ }
callback_id = callback_defined(find_image_file_callback);
if (img_filepath(idict) == NULL) {
- if (callback_id > 0
- && run_callback(callback_id, "S->S", img_filename(idict),
- &filepath)) {
- if (filepath && (strlen(filepath) > 0))
- img_filepath(idict) = strdup(filepath);
- } else
- img_filepath(idict) =
- kpse_find_file(img_filename(idict), kpse_tex_format, true);
- if (img_filepath(idict) == NULL)
+ if (callback_id > 0) {
+ if (run_callback(callback_id, "S->S", img_filename(idict),&filepath)) {
+ if (filepath && (strlen(filepath) > 0)) {
+ img_filepath(idict) = strdup(filepath);
+ }
+ }
+ } else {
+ img_filepath(idict) = kpse_find_file(img_filename(idict), kpse_tex_format, true);
+ }
+ if (img_filepath(idict) == NULL) {
luatex_fail("cannot find image file '%s'", img_filename(idict));
+ }
}
recorder_record_input(img_filename(idict));
/* type checks */
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index e0b37f68fec..2c292afa40a 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -2696,41 +2696,65 @@ 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);
+ if (lua_type(L,1) != LUA_TNUMBER) {
+ lua_pushnil(L);
+ lua_pushnil(L);
+ lua_pushnil(L);
+ lua_pushnil(L);
} 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);
+ index = lua_tonumber(L,1);
+ alt.wd = null_flag;
+ alt.ht = null_flag;
+ alt.dp = null_flag;
+ if (lua_type(L,2) == LUA_TNUMBER) {
+ alt.wd = (scaled) lua_tonumber(L,2);
+ }
+ if (lua_type(L,3) == LUA_TNUMBER) {
+ alt.ht = (scaled) lua_tonumber(L,3);
+ }
+ if (lua_type(L,4) == LUA_TNUMBER) {
+ 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_get_box_resource_dimensions(lua_State * L)
+{
+ int index = 0;
+ if (lua_type(L,1) != LUA_TNUMBER) {
+ lua_pushnil(L);
+ lua_pushnil(L);
+ lua_pushnil(L);
+ } else {
+ index = lua_tonumber(L,1);
+ check_obj_type(static_pdf, obj_type_xform, index);
+ lua_pushnumber(L, (int) obj_xform_width(static_pdf, index));
+ lua_pushnumber(L, (int) obj_xform_height(static_pdf, index));
+ lua_pushnumber(L, (int) obj_xform_depth(static_pdf, index));
+ }
+ return 3;
+}
+
static int tex_build_page(lua_State * L)
{
build_page();
@@ -2750,86 +2774,87 @@ void init_tex_table(lua_State * L)
}
static const struct luaL_Reg texlib[] = {
- {"run", tex_run_main}, /* may be needed */
- {"finish", tex_run_end}, /* may be needed */
- {"write", luacwrite},
- {"print", luacprint},
- {"tprint", luactprint},
- {"error", texerror},
- {"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},
- {"getlist", getlist},
- {"setnest", setnest},
- {"getnest", getnest},
- {"setcatcode", setcatcode},
- {"getcatcode", getcatcode},
- {"setdelcode", setdelcode},
- {"getdelcode", getdelcode},
- {"getdelcodes", getdelcodes},
- {"setlccode", setlccode},
- {"getlccode", getlccode},
- {"setmathcode", setmathcode},
- {"getmathcode", getmathcode},
- {"getmathcodes", getmathcodes},
- {"setsfcode", setsfcode},
- {"getsfcode", getsfcode},
- {"setuccode", setuccode},
- {"getuccode", getuccode},
- {"round", tex_roundnumber},
- {"scale", tex_scaletable},
- {"sp", tex_scaledimen},
- {"fontname", getfontname},
- {"fontidentifier", getfontidentifier},
- {"uniformdeviate", getuniformdeviate},
- {"number", getnumber},
- {"romannumeral", getromannumeral},
- {"definefont", tex_definefont},
- {"hashtokens", tex_hashpairs},
- {"primitives", tex_primitives},
- {"extraprimitives", tex_extraprimitives},
- {"enableprimitives", tex_enableprimitives},
- {"shipout", tex_shipout},
- {"badness", tex_badness},
- {"setmath", tex_setmathparm},
- {"getmath", tex_getmathparm},
- {"linebreak", tex_run_linebreak},
+ { "run", tex_run_main }, /* may be needed */
+ { "finish", tex_run_end }, /* may be needed */
+ { "write", luacwrite },
+ { "print", luacprint },
+ { "tprint", luactprint },
+ { "error", texerror },
+ { "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 },
+ { "getlist", getlist },
+ { "setnest", setnest },
+ { "getnest", getnest },
+ { "setcatcode", setcatcode },
+ { "getcatcode", getcatcode },
+ { "setdelcode", setdelcode },
+ { "getdelcode", getdelcode },
+ { "getdelcodes", getdelcodes },
+ { "setlccode", setlccode },
+ { "getlccode", getlccode },
+ { "setmathcode", setmathcode },
+ { "getmathcode", getmathcode },
+ { "getmathcodes", getmathcodes },
+ { "setsfcode", setsfcode },
+ { "getsfcode", getsfcode },
+ { "setuccode", setuccode },
+ { "getuccode", getuccode },
+ { "round", tex_roundnumber },
+ { "scale", tex_scaletable },
+ { "sp", tex_scaledimen },
+ { "fontname", getfontname },
+ { "fontidentifier", getfontidentifier },
+ { "uniformdeviate", getuniformdeviate },
+ { "number", getnumber },
+ { "romannumeral", getromannumeral },
+ { "definefont", tex_definefont },
+ { "hashtokens", tex_hashpairs },
+ { "primitives", tex_primitives },
+ { "extraprimitives", tex_extraprimitives },
+ { "enableprimitives", tex_enableprimitives },
+ { "shipout", tex_shipout },
+ { "badness", tex_badness },
+ { "setmath", tex_setmathparm },
+ { "getmath", tex_getmathparm },
+ { "linebreak", tex_run_linebreak },
/* tex random generators */
- {"init_rand", tex_init_rand},
- {"uniform_rand",tex_unif_rand},
- {"normal_rand", tex_norm_rand},
- {"lua_math_randomseed", tex_init_rand}, /* syntactic sugar */
- {"lua_math_random", lua_math_random},
- {"show_context", tex_show_context},
- {"saveboxresource", tex_save_box_resource},
- {"useboxresource", tex_use_box_resource},
+ { "init_rand", tex_init_rand },
+ { "uniform_rand",tex_unif_rand },
+ { "normal_rand", tex_norm_rand },
+ { "lua_math_randomseed", tex_init_rand }, /* syntactic sugar */
+ { "lua_math_random", lua_math_random },
+ { "show_context", tex_show_context },
+ { "saveboxresource", tex_save_box_resource },
+ { "useboxresource", tex_use_box_resource },
+ { "getboxresourcedimensions", tex_get_box_resource_dimensions },
/* just for testing: it will probably stay but maybe with options */
- {"triggerbuildpage", tex_build_page},
+ { "triggerbuildpage", tex_build_page },
/* sentinel */
- {NULL, NULL}
+ { NULL, NULL }
};
int luaopen_tex(lua_State * L)