From ab548fd2c4577d5ca89cc6c5e5e540682fc2d3c2 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 Jan 2018 22:20:39 +1100 Subject: src/lstrlib.js: Hardcode toupper implementation --- src/lstrlib.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lstrlib.js b/src/lstrlib.js index e744853..bf12f2e 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -191,10 +191,13 @@ const num2straux = function(x) { const lua_number2strx = function(L, fmt, x) { let buff = num2straux(x); - if (fmt[SIZELENMOD] === 'A'.charCodeAt(0)) { - for (let i = 0; i < buff.length; i++) - buff[i] = String.fromCharCode(buff[i]).toUpperCase().charCodeAt(0); - } else if (fmt[SIZELENMOD] !== 'a'.charCodeAt(0)) + if (fmt[SIZELENMOD] === 65 /* 'A'.charCodeAt(0) */) { + for (let i = 0; i < buff.length; i++) { + let c = buff[i]; + if (c >= 97) /* toupper */ + buff[i] = c & 0xdf; + } + } else if (fmt[SIZELENMOD] !== 97 /* 'a'.charCodeAt(0) */) luaL_error(L, to_luastring("modifiers for format '%%a'/'%%A' not implemented")); return buff; }; -- cgit v1.2.3-70-g09d2