authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-10-16 16:58:46+02:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-09 21:57:17+01:00
log6b7d9b34e8fcefa731800cef883c2400f9f39de5
tree695fc1d564a2bc590d9c87bca57f825d4027716e
parentf7fea080b25f932b352d38f126e0a179c5163f68

api(std.ascii): remove deprecated decls


7 files changed, 14 insertions(+), 115 deletions(-)

lib/std/SemanticVersion.zig+2-2
......@@ -114,7 +114,7 @@ pub fn parse(text: []const u8) !Version {
114114 if (id.len == 0) return error.InvalidVersion;
115115
116116 // Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].
117 for (id) |c| if (!std.ascii.isAlNum(c) and c != '-') return error.InvalidVersion;
117 for (id) |c| if (!std.ascii.isAlphanumeric(c) and c != '-') return error.InvalidVersion;
118118
119119 // Numeric identifiers MUST NOT include leading zeroes.
120120 const is_num = for (id) |c| {
......@@ -133,7 +133,7 @@ pub fn parse(text: []const u8) !Version {
133133 if (id.len == 0) return error.InvalidVersion;
134134
135135 // Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].
136 for (id) |c| if (!std.ascii.isAlNum(c) and c != '-') return error.InvalidVersion;
136 for (id) |c| if (!std.ascii.isAlphanumeric(c) and c != '-') return error.InvalidVersion;
137137 }
138138 }
139139
lib/std/ascii.zig+3-104
......@@ -10,83 +10,10 @@
1010
1111const std = @import("std");
1212
13// TODO: remove all decls marked as DEPRECATED after 0.10.0's release
14
1513/// The C0 control codes of the ASCII encoding.
1614///
1715/// See also: https://en.wikipedia.org/wiki/C0_and_C1_control_codes and `isControl`.
1816pub const control_code = struct {
19 // DEPRECATED: use the lowercase variant
20 pub const NUL = 0x00;
21 // DEPRECATED: use the lowercase variant
22 pub const SOH = 0x01;
23 // DEPRECATED: use the lowercase variant
24 pub const STX = 0x02;
25 // DEPRECATED: use the lowercase variant
26 pub const ETX = 0x03;
27 // DEPRECATED: use the lowercase variant
28 pub const EOT = 0x04;
29 // DEPRECATED: use the lowercase variant
30 pub const ENQ = 0x05;
31 // DEPRECATED: use the lowercase variant
32 pub const ACK = 0x06;
33 // DEPRECATED: use the lowercase variant
34 pub const BEL = 0x07;
35 // DEPRECATED: use the lowercase variant
36 pub const BS = 0x08;
37 // DEPRECATED: use `ht`
38 pub const TAB = 0x09;
39 // DEPRECATED: use the lowercase variant
40 pub const LF = 0x0A;
41 // DEPRECATED: use the lowercase variant
42 pub const VT = 0x0B;
43 // DEPRECATED: use the lowercase variant
44 pub const FF = 0x0C;
45 // DEPRECATED: use the lowercase variant
46 pub const CR = 0x0D;
47 // DEPRECATED: use the lowercase variant
48 pub const SO = 0x0E;
49 // DEPRECATED: use the lowercase variant
50 pub const SI = 0x0F;
51 // DEPRECATED: use the lowercase variant
52 pub const DLE = 0x10;
53 // DEPRECATED: use the lowercase variant
54 pub const DC1 = 0x11;
55 // DEPRECATED: use the lowercase variant
56 pub const DC2 = 0x12;
57 // DEPRECATED: use the lowercase variant
58 pub const DC3 = 0x13;
59 // DEPRECATED: use the lowercase variant
60 pub const DC4 = 0x14;
61 // DEPRECATED: use the lowercase variant
62 pub const NAK = 0x15;
63 // DEPRECATED: use the lowercase variant
64 pub const SYN = 0x16;
65 // DEPRECATED: use the lowercase variant
66 pub const ETB = 0x17;
67 // DEPRECATED: use the lowercase variant
68 pub const CAN = 0x18;
69 // DEPRECATED: use the lowercase variant
70 pub const EM = 0x19;
71 // DEPRECATED: use the lowercase variant
72 pub const SUB = 0x1A;
73 // DEPRECATED: use the lowercase variant
74 pub const ESC = 0x1B;
75 // DEPRECATED: use the lowercase variant
76 pub const FS = 0x1C;
77 // DEPRECATED: use the lowercase variant
78 pub const GS = 0x1D;
79 // DEPRECATED: use the lowercase variant
80 pub const RS = 0x1E;
81 // DEPRECATED: use the lowercase variant
82 pub const US = 0x1F;
83 // DEPRECATED: use the lowercase variant
84 pub const DEL = 0x7F;
85 // DEPRECATED: use the lowercase variant
86 pub const XON = 0x11;
87 // DEPRECATED: use the lowercase variant
88 pub const XOFF = 0x13;
89
9017 /// Null.
9118 pub const nul = 0x00;
9219 /// Start of Heading.
......@@ -298,19 +225,6 @@ fn inTable(c: u8, t: tIndex) bool {
298225 return (combinedTable[c] & (@as(u8, 1) << @enumToInt(t))) != 0;
299226}
300227
301/// DEPRECATED: use `isAlphanumeric`
302pub const isAlNum = isAlphanumeric;
303/// DEPRECATED: use `isAlphabetic`
304pub const isAlpha = isAlphabetic;
305/// DEPRECATED: use `isControl`
306pub const isCntrl = isControl;
307/// DEPRECATED: use `isWhitespace`.
308pub const isSpace = isWhitespace;
309/// DEPRECATED: use `whitespace`.
310pub const spaces = whitespace;
311/// DEPRECATED: use `isHex`.
312pub const isXDigit = isHex;
313
314228/// Returns whether the character is alphanumeric.
315229pub fn isAlphanumeric(c: u8) bool {
316230 return (combinedTable[c] & ((@as(u8, 1) << @enumToInt(tIndex.Alpha)) |
......@@ -335,11 +249,6 @@ pub fn isDigit(c: u8) bool {
335249 return inTable(c, tIndex.Digit);
336250}
337251
338/// DEPRECATED: use `isPrint(c) and c != ' '` instead
339pub fn isGraph(c: u8) bool {
340 return inTable(c, tIndex.Graph);
341}
342
343252/// Returns whether the character is a lowercased letter.
344253pub fn isLower(c: u8) bool {
345254 return inTable(c, tIndex.Lower);
......@@ -352,11 +261,6 @@ pub fn isPrint(c: u8) bool {
352261 return inTable(c, tIndex.Graph) or c == ' ';
353262}
354263
355/// DEPRECATED: create your own function based on your needs and what you want to do.
356pub fn isPunct(c: u8) bool {
357 return inTable(c, tIndex.Punct);
358}
359
360264/// Returns whether this character is included in `whitespace`.
361265pub fn isWhitespace(c: u8) bool {
362266 return inTable(c, tIndex.Space);
......@@ -392,11 +296,6 @@ pub fn isASCII(c: u8) bool {
392296 return c < 128;
393297}
394298
395/// DEPRECATED: use `c == ' ' or c == '\t'` or try `isWhitespace`
396pub fn isBlank(c: u8) bool {
397 return (c == ' ') or (c == '\x09');
398}
399
400299/// Uppercases the character and returns it as-is if it's already uppercased or not a letter.
401300pub fn toUpper(c: u8) u8 {
402301 if (isLower(c)) {
......@@ -440,9 +339,9 @@ test "ascii character classes" {
440339 try testing.expect(isAlphanumeric('5'));
441340 try testing.expect(!isAlphanumeric('!'));
442341
443 try testing.expect(!isAlpha('5'));
444 try testing.expect(isAlpha('c'));
445 try testing.expect(!isAlpha('5'));
342 try testing.expect(!isAlphabetic('5'));
343 try testing.expect(isAlphabetic('c'));
344 try testing.expect(!isAlphabetic('5'));
446345
447346 try testing.expect(isWhitespace(' '));
448347 try testing.expect(isWhitespace('\t'));
lib/std/net.zig+1-1
......@@ -1192,7 +1192,7 @@ pub fn isValidHostName(hostname: []const u8) bool {
11921192 if (hostname.len >= 254) return false;
11931193 if (!std.unicode.utf8ValidateSlice(hostname)) return false;
11941194 for (hostname) |byte| {
1195 if (byte >= 0x80 or byte == '.' or byte == '-' or std.ascii.isAlNum(byte)) {
1195 if (!std.ascii.isASCII(byte) or byte == '.' or byte == '-' or std.ascii.isAlphanumeric(byte)) {
11961196 continue;
11971197 }
11981198 return false;
lib/std/zig/parse.zig+2-2
......@@ -1531,7 +1531,7 @@ const Parser = struct {
15311531 // without types we don't know if '&&' was intended as 'bitwise_and address_of', or a c-style logical_and
15321532 // The best the parser can do is recommend changing it to 'and' or ' & &'
15331533 try p.warnMsg(.{ .tag = .invalid_ampersand_ampersand, .token = oper_token });
1534 } else if (std.ascii.isSpace(char_before) != std.ascii.isSpace(char_after)) {
1534 } else if (std.ascii.isWhitespace(char_before) != std.ascii.isWhitespace(char_after)) {
15351535 try p.warnMsg(.{ .tag = .mismatched_binary_op_whitespace, .token = oper_token });
15361536 }
15371537 }
......@@ -1728,7 +1728,7 @@ const Parser = struct {
17281728 var sentinel: Node.Index = 0;
17291729 if (p.eatToken(.identifier)) |ident| {
17301730 const ident_slice = p.source[p.token_starts[ident]..p.token_starts[ident + 1]];
1731 if (!std.mem.eql(u8, std.mem.trimRight(u8, ident_slice, &std.ascii.spaces), "c")) {
1731 if (!std.mem.eql(u8, std.mem.trimRight(u8, ident_slice, &std.ascii.whitespace), "c")) {
17321732 p.tok_i -= 1;
17331733 }
17341734 } else if (p.eatToken(.colon)) |_| {
lib/std/zig/render.zig+4-4
......@@ -2648,7 +2648,7 @@ fn renderComments(ais: *Ais, tree: Ast, start: usize, end: usize) Error!bool {
26482648 const newline = if (newline_index) |i| comment_start + i else null;
26492649
26502650 const untrimmed_comment = tree.source[comment_start .. newline orelse tree.source.len];
2651 const trimmed_comment = mem.trimRight(u8, untrimmed_comment, &std.ascii.spaces);
2651 const trimmed_comment = mem.trimRight(u8, untrimmed_comment, &std.ascii.whitespace);
26522652
26532653 // Don't leave any whitespace at the start of the file
26542654 if (index != 0) {
......@@ -2669,7 +2669,7 @@ fn renderComments(ais: *Ais, tree: Ast, start: usize, end: usize) Error!bool {
26692669
26702670 index = 1 + (newline orelse end - 1);
26712671
2672 const comment_content = mem.trimLeft(u8, trimmed_comment["//".len..], &std.ascii.spaces);
2672 const comment_content = mem.trimLeft(u8, trimmed_comment["//".len..], &std.ascii.whitespace);
26732673 if (ais.disabled_offset != null and mem.eql(u8, comment_content, "zig fmt: on")) {
26742674 // Write the source for which formatting was disabled directly
26752675 // to the underlying writer, fixing up invaild whitespace.
......@@ -2716,7 +2716,7 @@ fn renderExtraNewlineToken(ais: *Ais, tree: Ast, token_index: Ast.TokenIndex) Er
27162716 // non-whitespace character is encountered or two newlines have been found.
27172717 var i = token_start - 1;
27182718 var newlines: u2 = 0;
2719 while (std.ascii.isSpace(tree.source[i])) : (i -= 1) {
2719 while (std.ascii.isWhitespace(tree.source[i])) : (i -= 1) {
27202720 if (tree.source[i] == '\n') newlines += 1;
27212721 if (newlines == 2) return ais.insertNewline();
27222722 if (i == prev_token_end) break;
......@@ -2778,7 +2778,7 @@ fn tokenSliceForRender(tree: Ast, token_index: Ast.TokenIndex) []const u8 {
27782778 ret.len -= 1;
27792779 },
27802780 .container_doc_comment, .doc_comment => {
2781 ret = mem.trimRight(u8, ret, &std.ascii.spaces);
2781 ret = mem.trimRight(u8, ret, &std.ascii.whitespace);
27822782 },
27832783 else => {},
27842784 }
lib/std/zig/tokenizer.zig+1-1
......@@ -1232,7 +1232,7 @@ pub const Tokenizer = struct {
12321232 fn getInvalidCharacterLength(self: *Tokenizer) u3 {
12331233 const c0 = self.buffer[self.index];
12341234 if (std.ascii.isASCII(c0)) {
1235 if (std.ascii.isCntrl(c0)) {
1235 if (std.ascii.isControl(c0)) {
12361236 // ascii control codes are never allowed
12371237 // (note that \n was checked before we got here)
12381238 return 1;
src/translate_c.zig+1-1
......@@ -5738,7 +5738,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node {
57385738 if (mem.indexOfScalar(u8, lit_bytes, '.')) |dot_index| {
57395739 if (dot_index == 2) {
57405740 lit_bytes = try std.fmt.allocPrint(c.arena, "0x0{s}", .{lit_bytes[2..]});
5741 } else if (dot_index + 1 == lit_bytes.len or !std.ascii.isXDigit(lit_bytes[dot_index + 1])) {
5741 } else if (dot_index + 1 == lit_bytes.len or !std.ascii.isHex(lit_bytes[dot_index + 1])) {
57425742 // If the literal lacks a digit after the `.`, we need to
57435743 // add one since `0x1.p10` would be invalid syntax in Zig.
57445744 lit_bytes = try std.fmt.allocPrint(c.arena, "0x{s}0{s}", .{