From 61a5284a07d9a9342d192ae6fb4e8e567a3811a9 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 15 Jun 2017 01:38:02 +1000 Subject: src/lstrlib.js: Fix islower+isupper Old islower considered the null byte to be lower case. The new implementations are simpler too --- src/lstrlib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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)); -- cgit v1.2.3-54-g00ecf