summaryrefslogtreecommitdiff
path: root/source/luametatex/source/lua
diff options
context:
space:
mode:
Diffstat (limited to 'source/luametatex/source/lua')
-rw-r--r--source/luametatex/source/lua/lmtnodelib.c8
-rw-r--r--source/luametatex/source/lua/lmttokenlib.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c
index 6a07e3454..72b9918e4 100644
--- a/source/luametatex/source/lua/lmtnodelib.c
+++ b/source/luametatex/source/lua/lmtnodelib.c
@@ -5321,15 +5321,19 @@ static int nodelib_direct_patchattributes(lua_State *L)
return 0;
}
+/* firstnode attributeid [nodetype] */
+
static int nodelib_direct_findattribute(lua_State *L) /* returns attr value and node */
{
halfword c = nodelib_valid_direct_from_index(L, 1);
if (c) {
halfword i = lmt_tohalfword(L, 2);
+ halfword t = lmt_optinteger(L, 3, -1);
while (c) {
- if (tex_nodetype_has_attributes(node_type(c))) {
+ if ((t < 0 || node_type(c) == t) && tex_nodetype_has_attributes(node_type(c))) {
halfword p = node_attr(c);
if (p) {
+ /* we could skip if the previous value is the same and didn't match */
p = node_next(p);
while (p) {
if (attribute_index(p) == i) {
@@ -5757,6 +5761,8 @@ static int nodelib_direct_traversechar(lua_State *L)
}
}
+/* maybe a variant that checks for an attribute */
+
static int nodelib_direct_aux_next_glyph(lua_State *L)
{
halfword t;
diff --git a/source/luametatex/source/lua/lmttokenlib.c b/source/luametatex/source/lua/lmttokenlib.c
index dcd17b53e..5259a1478 100644
--- a/source/luametatex/source/lua/lmttokenlib.c
+++ b/source/luametatex/source/lua/lmttokenlib.c
@@ -3797,6 +3797,7 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_integer_code:
{
+ /* expects valid integer, no double */
*value = lua_type(L, -1) == LUA_TNUMBER ? lmt_tohalfword(L, -1) : 0;
if (*value < - max_integer) {
*value = max_integer;
@@ -3807,6 +3808,7 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_cardinal_code:
{
+ /* expects valid integer, no double */
lua_Unsigned u = lua_type(L, -1) == LUA_TNUMBER ? (lua_Unsigned) lua_tointeger(L, -1) : 0;
if (u > max_cardinal) {
u = max_cardinal;
@@ -3820,7 +3822,8 @@ int lmt_function_call_by_category(int slot, int property, halfword *value)
}
case lua_value_dimension_code:
{
- *value = lua_type(L, -1) == LUA_TNUMBER ? lmt_tohalfword(L, -1) : 0;
+ /* accepts double and rounds it */
+ *value = lua_type(L, -1) == LUA_TNUMBER ? lmt_roundnumber(L, -1) : 0;
if (*value < - max_dimen) {
*value = max_dimen;
} else if (*value > max_dimen) {