string.format changed in LuaTeX / grph-downsample
Ahoi, since i recently updated my ConTeXt beta, Lua function string.format behaves differently, i.e. type checks are stricter. I guess it’s due to switching to Lua 5.3 in LuaTeX? E.g. this: if tonumber(string.format('%d', value)) == value then ... throws bad argument #2 to 'format' (number has no integer representation) Since I just need to check if the number is integer, this works: if tonumber(value) == math.floor(value) then ... This also affects Peter Münster’s grph-downsample module; please find a fixed version attached. (Decimal pixel sizes make no sense anyway, so I just "floored" them.) Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD
On 3/23/2018 9:46 AM, Henning Hraban Ramm wrote:
Ahoi, since i recently updated my ConTeXt beta, Lua function string.format behaves differently, i.e. type checks are stricter. I guess it’s due to switching to Lua 5.3 in LuaTeX?
This is indeed one of the changes in 5.3 (more about that at the ctx meeting). Anyway, format is a bit unstable over time anyway, which is why in context we have string.formatters with some more options (cld manual): print(string.formatter("%r",1)) print(string.formatter("%r",1.1)) print(string.formatter("%p",1)) print(string.formatter("%p",1.1)) etc. On the average its also faster than string.format. It means that we could make the transition to 5.3 without too much hassle (very little had to be adapted and luigi and i are running context with 5.3 for quite a while now).
E.g. this:
if tonumber(string.format('%d', value)) == value then ...
throws
bad argument #2 to 'format' (number has no integer representation)
Since I just need to check if the number is integer, this works:
if tonumber(value) == math.floor(value) then ...
This also affects Peter Münster’s grph-downsample module; please find a fixed version attached. (Decimal pixel sizes make no sense anyway, so I just "floored" them.)
better round them
Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Henning Hraban Ramm