summaryrefslogtreecommitdiff
path: root/src/lstrlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-15 01:38:02 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-15 01:38:02 +1000
commit61a5284a07d9a9342d192ae6fb4e8e567a3811a9 (patch)
tree45c136554109078a6940754a52ab20f64bd30f4b /src/lstrlib.js
parent5fb9e658f0e9a1604ae4314ba531179e1cfbd8bb (diff)
downloadfengari-61a5284a07d9a9342d192ae6fb4e8e567a3811a9.tar.gz
fengari-61a5284a07d9a9342d192ae6fb4e8e567a3811a9.tar.bz2
fengari-61a5284a07d9a9342d192ae6fb4e8e567a3811a9.zip
src/lstrlib.js: Fix islower+isupper
Old islower considered the null byte to be lower case. The new implementations are simpler too
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r--src/lstrlib.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 70b9e5f..d3373a4 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -165,8 +165,8 @@ const isalpha = e => ('a'.charCodeAt(0) <= e && e <= 'z'.charCodeAt(0)) || (e >=
const isdigit = e => '0'.charCodeAt(0) <= e && e <= '9'.charCodeAt(0);
const iscntrl = e => (0x00 <= e && e <= 0x1f) || e === 0x7f;
const isgraph = e => e > 32 && e < 127; // TODO: Will only work for ASCII
-const islower = e => /^(?![A-Z]).*$/.test(String.fromCharCode(e));
-const isupper = e => /^(?![a-z]).*$/.test(String.fromCharCode(e));
+const islower = e => /^[a-z]$/.test(String.fromCharCode(e));
+const isupper = e => /^[A-Z]$/.test(String.fromCharCode(e));
const isalnum = e => /^[a-zA-Z0-9]$/.test(String.fromCharCode(e));
const ispunct = e => isgraph(e) && !isalnum(e);
const isspace = e => /^\s$/.test(String.fromCharCode(e));