# HG changeset patch # User jbe # Date 1497747828 -7200 # Node ID b29e082cafb872125684bd162db5a66c41dd4a04 # Parent 42ddff7319e0a144e53fede990919775ff7a1deb Support for non-integer numbers in mondelefant_atom_connector (requires Lua 5.3) diff -r 42ddff7319e0 -r b29e082cafb8 libraries/mondelefant/mondelefant_atom_connector.lua --- a/libraries/mondelefant/mondelefant_atom_connector.lua Sun Jun 18 01:58:25 2017 +0200 +++ b/libraries/mondelefant/mondelefant_atom_connector.lua Sun Jun 18 03:03:48 2017 +0200 @@ -43,17 +43,29 @@ end input_converters["number"] = function(conn, value) - local integer_string = string.format("%i", value) - if tonumber(integer_string) == value then - return integer_string - else - local number_string = tostring(value) - if string.find(number_string, "^[0-9.e+-]+$") then - return number_string + if _VERSION == "Lua 5.2" then + -- TODO: remove following compatibility hack to allow large integers (e.g. 1e14) in Lua 5.2 + local integer_string = string.format("%i", value) + if tonumber(integer_string) == value then + return integer_string else - return "'NaN'" + local number_string = tostring(value) + if string.find(number_string, "^[0-9.e+-]+$") then + return number_string + else + return "'NaN'" + end end end + local integer = math.tointeger(value) + if integer then + return tostring(integer) + end + local str = tostring(value) + if string.find(str, "^[0-9.e+-]+$") then + return str + end + return "'NaN'" end input_converters[atom.fraction] = function(conn, value)