From 32fee0764e9e5e1a903ef5d16fb94718a86d7a09 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 Jan 2018 14:46:36 +1100 Subject: src/{luaconf,lobject,lstrlib}.js: lua_getlocaledecpoint now returns char code instead of string --- src/lobject.js | 5 ++--- src/lstrlib.js | 2 +- src/luaconf.js | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lobject.js b/src/lobject.js index 1f26b96..9834df7 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -15,7 +15,6 @@ const { LUA_OPSHR, LUA_OPSUB, LUA_OPUNM, - char, constant_types: { LUA_NUMTAGS, LUA_TBOOLEAN, @@ -430,7 +429,7 @@ const MAXSIGDIG = 30; */ const lua_strx2number = function(s) { let i = 0; - let dot = char[lua_getlocaledecpoint()]; + let dot = lua_getlocaledecpoint(); let r = 0.0; /* result (accumulator) */ let sigdig = 0; /* number of significant digits */ let nosigdig = 0; /* number of non-significant digits */ @@ -597,7 +596,7 @@ const luaO_tostring = function(L, obj) { let str = lua_number2str(obj.value); // Assume no LUA_COMPAT_FLOATSTRING if (/^[-0123456789]+$/.test(str)) { /* looks like an int? */ - str += lua_getlocaledecpoint() + '0'; /* adds '.0' to result */ + str += String.fromCharCode(lua_getlocaledecpoint()) + '0'; /* adds '.0' to result */ } buff = to_luastring(str); } diff --git a/src/lstrlib.js b/src/lstrlib.js index afed664..9863ba5 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -255,7 +255,7 @@ const addquoted = function(b, s, len) { */ const checkdp = function(buff) { if (luastring_indexOf(buff, '.'.charCodeAt(0)) < 0) { /* no dot? */ - let point = lua_getlocaledecpoint().charCodeAt(0); /* try locale point */ + let point = lua_getlocaledecpoint(); /* try locale point */ let ppoint = luastring_indexOf(buff, point); if (ppoint) buff[ppoint] = '.'; /* change it to a dot */ } diff --git a/src/luaconf.js b/src/luaconf.js index c2a7781..533e316 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -38,7 +38,7 @@ const LUA_INTEGER_FMT = `%${LUA_INTEGER_FRMLEN}d`; const LUA_NUMBER_FMT = "%.14g"; const lua_getlocaledecpoint = function() { - return (1.1).toLocaleString().substring(1, 2); + return (1.1).toLocaleString().charCodeAt(1); }; const luai_apicheck = function(l, e) { -- cgit v1.2.3-70-g09d2