summaryrefslogtreecommitdiff
path: root/source/luametatex/source/lua/lmttokenlib.c
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2023-02-14 18:21:35 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2023-02-14 18:21:35 +0100
commitcd404631d7079a9af603d173eb015f026731aa01 (patch)
tree588c6c8e860bb26955999dfc8be67eb78cc7ff7f /source/luametatex/source/lua/lmttokenlib.c
parentd643b65f7ab840157f538914b07f8d3cddf94bec (diff)
downloadcontext-cd404631d7079a9af603d173eb015f026731aa01.tar.gz
2023-02-14 17:44:00
Diffstat (limited to 'source/luametatex/source/lua/lmttokenlib.c')
-rw-r--r--source/luametatex/source/lua/lmttokenlib.c5
1 files changed, 4 insertions, 1 deletions
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) {