zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 02b3d5b58adc58f85f213b580e60f4a07ae9b140 (tree)
parent e4447c54eaae4d416cb3027d9cefad11196f9f6d
Author: Michael Bradshaw <github@mjb.io>
Date:   Fri, 28 Jun 2024 08:10:55 -0700

Rename isASCII to isAscii

Diffstat:
Mlib/compiler/aro/aro/Parser.zig | 2+-
Mlib/std/ascii.zig | 9++++++---
Mlib/std/net.zig | 2+-
Mlib/std/zig/tokenizer.zig | 2+-
4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/compiler/aro/aro/Parser.zig b/lib/compiler/aro/aro/Parser.zig @@ -8011,7 +8011,7 @@ fn charLiteral(p: *Parser) Error!Result { const slice = char_kind.contentSlice(p.tokSlice(p.tok_i)); var is_multichar = false; - if (slice.len == 1 and std.ascii.isASCII(slice[0])) { + if (slice.len == 1 and std.ascii.isAscii(slice[0])) { // fast path: single unescaped ASCII char val = slice[0]; } else { diff --git a/lib/std/ascii.zig b/lib/std/ascii.zig @@ -130,7 +130,7 @@ pub fn isLower(c: u8) bool { /// Returns whether the character is printable and has some graphical representation, /// including the space character. pub fn isPrint(c: u8) bool { - return isASCII(c) and !isControl(c); + return isAscii(c) and !isControl(c); } /// Returns whether this character is included in `whitespace`. @@ -151,7 +151,7 @@ test whitespace { for (whitespace) |char| try std.testing.expect(isWhitespace(char)); var i: u8 = 0; - while (isASCII(i)) : (i += 1) { + while (isAscii(i)) : (i += 1) { if (isWhitespace(i)) try std.testing.expect(std.mem.indexOfScalar(u8, &whitespace, i) != null); } } @@ -173,10 +173,13 @@ pub fn isHex(c: u8) bool { } /// Returns whether the character is a 7-bit ASCII character. -pub fn isASCII(c: u8) bool { +pub fn isAscii(c: u8) bool { return c < 128; } +/// /// Deprecated: use `isAscii` +pub const isASCII = isAscii; + /// Uppercases the character and returns it as-is if already uppercase or not a letter. pub fn toUpper(c: u8) u8 { if (isLower(c)) { diff --git a/lib/std/net.zig b/lib/std/net.zig @@ -1363,7 +1363,7 @@ pub fn isValidHostName(hostname: []const u8) bool { if (hostname.len >= 254) return false; if (!std.unicode.utf8ValidateSlice(hostname)) return false; for (hostname) |byte| { - if (!std.ascii.isASCII(byte) or byte == '.' or byte == '-' or std.ascii.isAlphanumeric(byte)) { + if (!std.ascii.isAscii(byte) or byte == '.' or byte == '-' or std.ascii.isAlphanumeric(byte)) { continue; } return false; diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig @@ -1270,7 +1270,7 @@ pub const Tokenizer = struct { fn getInvalidCharacterLength(self: *Tokenizer) u3 { const c0 = self.buffer[self.index]; - if (std.ascii.isASCII(c0)) { + if (std.ascii.isAscii(c0)) { if (c0 == '\r') { if (self.index + 1 < self.buffer.len and self.buffer[self.index + 1] == '\n') { // Carriage returns are *only* allowed just before a linefeed as part of a CRLF pair, otherwise