Skip to content

Commit b313f31

Browse files
committed
Reuse some functions and fix a bug
1 parent 9857151 commit b313f31

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/std/ascii.zig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ fn isControlNaive(char: u8) bool {
6767
return char <= control.US or char == control.DEL;
6868
}
6969
fn isAlphabeticNaive(char: u8) bool {
70-
return (char >= 'a' and char <= 'z') or (char >= 'Z' and char <= 'Z');
70+
return isLower(char) or isUpper(char);
7171
}
7272
fn isHexadecimalNaive(char: u8) bool {
73-
return (char >= '0' and char <= '9') or
73+
return isDigit(char) or
7474
(char >= 'a' and char <= 'f') or
7575
(char >= 'A' and char <= 'F');
7676
}
7777
fn isAlphanumericNaive(char: u8) bool {
78-
return (char >= '0' and char <= '9') or
79-
(char >= 'a' and char <= 'z') or
80-
(char >= 'A' and char <= 'Z');
78+
return isDigit(char) or isAlphabeticNaive(char);
8179
}
8280
fn isWhitespaceNaive(char: u8) bool {
8381
@setEvalBranchQuota(4000);
@@ -246,7 +244,7 @@ test "ascii character classes" {
246244
try testing.expect('\xab' == toUpper('\xab'));
247245
try testing.expect(!isUpper('z'));
248246

249-
try testing.expect('c' == toLower('c'));
247+
try testing.expect('c' == toLower('C'));
250248
try testing.expect(':' == toLower(':'));
251249
try testing.expect('\xab' == toLower('\xab'));
252250
try testing.expect(!isLower('Z'));

0 commit comments

Comments
 (0)