authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-22 12:50:46+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-22 12:50:46+01:00
logaa0249d74e573742db3567f589fc6e4a00e1fff8
treecce61cb7f02072d205a12ae451922f0bf09c13ce
parent6b9125cbe662d530160e0732c856aa0da86894c0
parent02c5f05e2f0e8e786f0530014e35c1520efd0084

Merge pull request 'std.ascii: rename indexOf functions to find' (#30101) from adria/zig:indexof-find into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101 Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org> Reviewed-by: mlugg <mlugg@noreply.codeberg.org>

57 files changed, 215 insertions(+), 206 deletions(-)

lib/std/Build/Step/CheckFile.zig+1-1
...@@ -60,7 +60,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -60,7 +60,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
60 };60 };
6161
62 for (check_file.expected_matches) |expected_match| {62 for (check_file.expected_matches) |expected_match| {
63 if (mem.indexOf(u8, contents, expected_match) == null) {63 if (mem.find(u8, contents, expected_match) == null) {
64 return step.fail(64 return step.fail(
65 \\65 \\
66 \\========= expected to find: ===================66 \\========= expected to find: ===================
lib/std/Build/Step/CheckObject.zig+3-3
...@@ -88,7 +88,7 @@ const Action = struct {...@@ -88,7 +88,7 @@ const Action = struct {
88 while (needle_it.next()) |needle_tok| {88 while (needle_it.next()) |needle_tok| {
89 const hay_tok = hay_it.next() orelse break;89 const hay_tok = hay_it.next() orelse break;
90 if (mem.startsWith(u8, needle_tok, "{")) {90 if (mem.startsWith(u8, needle_tok, "{")) {
91 const closing_brace = mem.indexOf(u8, needle_tok, "}") orelse return error.MissingClosingBrace;91 const closing_brace = mem.find(u8, needle_tok, "}") orelse return error.MissingClosingBrace;
92 if (closing_brace != needle_tok.len - 1) return error.ClosingBraceNotLast;92 if (closing_brace != needle_tok.len - 1) return error.ClosingBraceNotLast;
9393
94 const name = needle_tok[1..closing_brace];94 const name = needle_tok[1..closing_brace];
...@@ -133,7 +133,7 @@ const Action = struct {...@@ -133,7 +133,7 @@ const Action = struct {
133 assert(act.tag == .contains);133 assert(act.tag == .contains);
134 const hay = mem.trim(u8, haystack, " ");134 const hay = mem.trim(u8, haystack, " ");
135 const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");135 const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");
136 return mem.indexOf(u8, hay, phrase) != null;136 return mem.find(u8, hay, phrase) != null;
137 }137 }
138138
139 /// Returns true if the `phrase` does not exist within the haystack.139 /// Returns true if the `phrase` does not exist within the haystack.
...@@ -1662,7 +1662,7 @@ const MachODumper = struct {...@@ -1662,7 +1662,7 @@ const MachODumper = struct {
16621662
1663 .dump_section => {1663 .dump_section => {
1664 const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0);1664 const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0);
1665 const sep_index = mem.indexOfScalar(u8, name, ',') orelse1665 const sep_index = mem.findScalar(u8, name, ',') orelse
1666 return step.fail("invalid section name: {s}", .{name});1666 return step.fail("invalid section name: {s}", .{name});
1667 const segname = name[0..sep_index];1667 const segname = name[0..sep_index];
1668 const sectname = name[sep_index + 1 ..];1668 const sectname = name[sep_index + 1 ..];
lib/std/Build/Step/Compile.zig+3-3
...@@ -369,7 +369,7 @@ pub const TestRunner = struct {...@@ -369,7 +369,7 @@ pub const TestRunner = struct {
369369
370pub fn create(owner: *std.Build, options: Options) *Compile {370pub fn create(owner: *std.Build, options: Options) *Compile {
371 const name = owner.dupe(options.name);371 const name = owner.dupe(options.name);
372 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {372 if (mem.find(u8, name, "/") != null or mem.find(u8, name, "\\") != null) {
373 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});373 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
374 }374 }
375375
...@@ -716,7 +716,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {...@@ -716,7 +716,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
716716
717 // Prefixed "lib" or suffixed ".0".717 // Prefixed "lib" or suffixed ".0".
718 for (pkgs) |pkg| {718 for (pkgs) |pkg| {
719 if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| {719 if (std.ascii.findIgnoreCase(pkg.name, lib_name)) |pos| {
720 const prefix = pkg.name[0..pos];720 const prefix = pkg.name[0..pos];
721 const suffix = pkg.name[pos + lib_name.len ..];721 const suffix = pkg.name[pos + lib_name.len ..];
722 if (prefix.len > 0 and !mem.eql(u8, prefix, "lib")) continue;722 if (prefix.len > 0 and !mem.eql(u8, prefix, "lib")) continue;
...@@ -1996,7 +1996,7 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool {...@@ -1996,7 +1996,7 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool {
1996 // We scan for /?/ in expected line and if there is a match, we match everything1996 // We scan for /?/ in expected line and if there is a match, we match everything
1997 // up to and after /?/.1997 // up to and after /?/.
1998 const expected_trim = mem.trim(u8, expected, " ");1998 const expected_trim = mem.trim(u8, expected, " ");
1999 if (mem.indexOf(u8, expected_trim, "/?/")) |index| {1999 if (mem.find(u8, expected_trim, "/?/")) |index| {
2000 const actual_trim = mem.trim(u8, actual, " ");2000 const actual_trim = mem.trim(u8, actual, " ");
2001 const lhs = expected_trim[0..index];2001 const lhs = expected_trim[0..index];
2002 const rhs = expected_trim[index + "/?/".len ..];2002 const rhs = expected_trim[index + "/?/".len ..];
lib/std/Build/Step/ConfigHeader.zig+5-5
...@@ -578,12 +578,12 @@ fn expand_variables_autoconf_at(...@@ -578,12 +578,12 @@ fn expand_variables_autoconf_at(
578 var source_offset: usize = 0;578 var source_offset: usize = 0;
579 while (curr < contents.len) : (curr += 1) {579 while (curr < contents.len) : (curr += 1) {
580 if (contents[curr] != '@') continue;580 if (contents[curr] != '@') continue;
581 if (std.mem.indexOfScalarPos(u8, contents, curr + 1, '@')) |close_pos| {581 if (std.mem.findScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
582 if (close_pos == curr + 1) {582 if (close_pos == curr + 1) {
583 // closed immediately, preserve as a literal583 // closed immediately, preserve as a literal
584 continue;584 continue;
585 }585 }
586 const valid_varname_end = std.mem.indexOfNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;586 const valid_varname_end = std.mem.findNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
587 if (valid_varname_end != close_pos) {587 if (valid_varname_end != close_pos) {
588 // contains invalid characters, preserve as a literal588 // contains invalid characters, preserve as a literal
589 continue;589 continue;
...@@ -635,12 +635,12 @@ fn expand_variables_cmake(...@@ -635,12 +635,12 @@ fn expand_variables_cmake(
635 loop: while (curr < contents.len) : (curr += 1) {635 loop: while (curr < contents.len) : (curr += 1) {
636 switch (contents[curr]) {636 switch (contents[curr]) {
637 '@' => blk: {637 '@' => blk: {
638 if (std.mem.indexOfScalarPos(u8, contents, curr + 1, '@')) |close_pos| {638 if (std.mem.findScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
639 if (close_pos == curr + 1) {639 if (close_pos == curr + 1) {
640 // closed immediately, preserve as a literal640 // closed immediately, preserve as a literal
641 break :blk;641 break :blk;
642 }642 }
643 const valid_varname_end = std.mem.indexOfNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;643 const valid_varname_end = std.mem.findNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
644 if (valid_varname_end != close_pos) {644 if (valid_varname_end != close_pos) {
645 // contains invalid characters, preserve as a literal645 // contains invalid characters, preserve as a literal
646 break :blk;646 break :blk;
...@@ -731,7 +731,7 @@ fn expand_variables_cmake(...@@ -731,7 +731,7 @@ fn expand_variables_cmake(
731 else => {},731 else => {},
732 }732 }
733733
734 if (var_stack.items.len > 0 and std.mem.indexOfScalar(u8, valid_varname_chars, contents[curr]) == null) {734 if (var_stack.items.len > 0 and std.mem.findScalar(u8, valid_varname_chars, contents[curr]) == null) {
735 return error.InvalidCharacter;735 return error.InvalidCharacter;
736 }736 }
737 }737 }
lib/std/Build/Step/Run.zig+2-2
...@@ -1505,7 +1505,7 @@ fn runCommand(...@@ -1505,7 +1505,7 @@ fn runCommand(
1505 }1505 }
1506 },1506 },
1507 .expect_stderr_match => |match| {1507 .expect_stderr_match => |match| {
1508 if (mem.indexOf(u8, generic_result.stderr.?, match) == null) {1508 if (mem.find(u8, generic_result.stderr.?, match) == null) {
1509 return step.fail(1509 return step.fail(
1510 \\========= expected to find in stderr: =========1510 \\========= expected to find in stderr: =========
1511 \\{s}1511 \\{s}
...@@ -1531,7 +1531,7 @@ fn runCommand(...@@ -1531,7 +1531,7 @@ fn runCommand(
1531 }1531 }
1532 },1532 },
1533 .expect_stdout_match => |match| {1533 .expect_stdout_match => |match| {
1534 if (mem.indexOf(u8, generic_result.stdout.?, match) == null) {1534 if (mem.find(u8, generic_result.stdout.?, match) == null) {
1535 return step.fail(1535 return step.fail(
1536 \\========= expected to find in stdout: =========1536 \\========= expected to find in stdout: =========
1537 \\{s}1537 \\{s}
lib/std/Io/Reader.zig+2-2
...@@ -993,7 +993,7 @@ pub fn streamDelimiterLimit(...@@ -993,7 +993,7 @@ pub fn streamDelimiterLimit(
993 error.ReadFailed => return error.ReadFailed,993 error.ReadFailed => return error.ReadFailed,
994 error.EndOfStream => return @intFromEnum(limit) - remaining,994 error.EndOfStream => return @intFromEnum(limit) - remaining,
995 });995 });
996 if (std.mem.indexOfScalar(u8, available, delimiter)) |delimiter_index| {996 if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
997 try w.writeAll(available[0..delimiter_index]);997 try w.writeAll(available[0..delimiter_index]);
998 r.toss(delimiter_index);998 r.toss(delimiter_index);
999 remaining -= delimiter_index;999 remaining -= delimiter_index;
...@@ -1064,7 +1064,7 @@ pub fn discardDelimiterLimit(r: *Reader, delimiter: u8, limit: Limit) DiscardDel...@@ -1064,7 +1064,7 @@ pub fn discardDelimiterLimit(r: *Reader, delimiter: u8, limit: Limit) DiscardDel
1064 error.ReadFailed => return error.ReadFailed,1064 error.ReadFailed => return error.ReadFailed,
1065 error.EndOfStream => return @intFromEnum(limit) - remaining,1065 error.EndOfStream => return @intFromEnum(limit) - remaining,
1066 });1066 });
1067 if (std.mem.indexOfScalar(u8, available, delimiter)) |delimiter_index| {1067 if (std.mem.findScalar(u8, available, delimiter)) |delimiter_index| {
1068 r.toss(delimiter_index);1068 r.toss(delimiter_index);
1069 remaining -= delimiter_index;1069 remaining -= delimiter_index;
1070 return @intFromEnum(limit) - remaining;1070 return @intFromEnum(limit) - remaining;
lib/std/Progress.zig+2-2
...@@ -257,7 +257,7 @@ pub const Node = struct {...@@ -257,7 +257,7 @@ pub const Node = struct {
257 const index = n.index.unwrap() orelse return;257 const index = n.index.unwrap() orelse return;
258 const storage = storageByIndex(index);258 const storage = storageByIndex(index);
259259
260 const name_len = @min(max_name_len, std.mem.indexOfScalar(u8, new_name, 0) orelse new_name.len);260 const name_len = @min(max_name_len, std.mem.findScalar(u8, new_name, 0) orelse new_name.len);
261261
262 copyAtomicStore(storage.name[0..name_len], new_name[0..name_len]);262 copyAtomicStore(storage.name[0..name_len], new_name[0..name_len]);
263 if (name_len < storage.name.len)263 if (name_len < storage.name.len)
...@@ -1347,7 +1347,7 @@ fn computeNode(...@@ -1347,7 +1347,7 @@ fn computeNode(
1347 const storage = &serialized.storage[@intFromEnum(node_index)];1347 const storage = &serialized.storage[@intFromEnum(node_index)];
1348 const estimated_total = storage.estimated_total_count;1348 const estimated_total = storage.estimated_total_count;
1349 const completed_items = storage.completed_count;1349 const completed_items = storage.completed_count;
1350 const name = if (std.mem.indexOfScalar(u8, &storage.name, 0)) |end| storage.name[0..end] else &storage.name;1350 const name = if (std.mem.findScalar(u8, &storage.name, 0)) |end| storage.name[0..end] else &storage.name;
1351 const parent = serialized.parents[@intFromEnum(node_index)];1351 const parent = serialized.parents[@intFromEnum(node_index)];
13521352
1353 if (parent != .none) p: {1353 if (parent != .none) p: {
lib/std/Random/benchmark.zig+4-4
...@@ -180,7 +180,7 @@ pub fn main() !void {...@@ -180,7 +180,7 @@ pub fn main() !void {
180 if (bench_prngs) {180 if (bench_prngs) {
181 if (bench_long) {181 if (bench_long) {
182 inline for (prngs) |R| {182 inline for (prngs) |R| {
183 if (filter == null or std.mem.indexOf(u8, R.name, filter.?) != null) {183 if (filter == null or std.mem.find(u8, R.name, filter.?) != null) {
184 try stdout.print("{s} (long outputs)\n", .{R.name});184 try stdout.print("{s} (long outputs)\n", .{R.name});
185 try stdout.flush();185 try stdout.flush();
186186
...@@ -191,7 +191,7 @@ pub fn main() !void {...@@ -191,7 +191,7 @@ pub fn main() !void {
191 }191 }
192 if (bench_short) {192 if (bench_short) {
193 inline for (prngs) |R| {193 inline for (prngs) |R| {
194 if (filter == null or std.mem.indexOf(u8, R.name, filter.?) != null) {194 if (filter == null or std.mem.find(u8, R.name, filter.?) != null) {
195 try stdout.print("{s} (short outputs)\n", .{R.name});195 try stdout.print("{s} (short outputs)\n", .{R.name});
196 try stdout.flush();196 try stdout.flush();
197197
...@@ -204,7 +204,7 @@ pub fn main() !void {...@@ -204,7 +204,7 @@ pub fn main() !void {
204 if (bench_csprngs) {204 if (bench_csprngs) {
205 if (bench_long) {205 if (bench_long) {
206 inline for (csprngs) |R| {206 inline for (csprngs) |R| {
207 if (filter == null or std.mem.indexOf(u8, R.name, filter.?) != null) {207 if (filter == null or std.mem.find(u8, R.name, filter.?) != null) {
208 try stdout.print("{s} (cryptographic, long outputs)\n", .{R.name});208 try stdout.print("{s} (cryptographic, long outputs)\n", .{R.name});
209 try stdout.flush();209 try stdout.flush();
210210
...@@ -215,7 +215,7 @@ pub fn main() !void {...@@ -215,7 +215,7 @@ pub fn main() !void {
215 }215 }
216 if (bench_short) {216 if (bench_short) {
217 inline for (csprngs) |R| {217 inline for (csprngs) |R| {
218 if (filter == null or std.mem.indexOf(u8, R.name, filter.?) != null) {218 if (filter == null or std.mem.find(u8, R.name, filter.?) != null) {
219 try stdout.print("{s} (cryptographic, short outputs)\n", .{R.name});219 try stdout.print("{s} (cryptographic, short outputs)\n", .{R.name});
220 try stdout.flush();220 try stdout.flush();
221221
lib/std/SemanticVersion.zig+2-2
...@@ -84,7 +84,7 @@ pub fn order(lhs: Version, rhs: Version) std.math.Order {...@@ -84,7 +84,7 @@ pub fn order(lhs: Version, rhs: Version) std.math.Order {
8484
85pub fn parse(text: []const u8) !Version {85pub fn parse(text: []const u8) !Version {
86 // Parse the required major, minor, and patch numbers.86 // Parse the required major, minor, and patch numbers.
87 const extra_index = std.mem.indexOfAny(u8, text, "-+");87 const extra_index = std.mem.findAny(u8, text, "-+");
88 const required = text[0..(extra_index orelse text.len)];88 const required = text[0..(extra_index orelse text.len)];
89 var it = std.mem.splitScalar(u8, required, '.');89 var it = std.mem.splitScalar(u8, required, '.');
90 var ver = Version{90 var ver = Version{
...@@ -98,7 +98,7 @@ pub fn parse(text: []const u8) !Version {...@@ -98,7 +98,7 @@ pub fn parse(text: []const u8) !Version {
98 // Slice optional pre-release or build metadata components.98 // Slice optional pre-release or build metadata components.
99 const extra: []const u8 = text[extra_index.?..text.len];99 const extra: []const u8 = text[extra_index.?..text.len];
100 if (extra[0] == '-') {100 if (extra[0] == '-') {
101 const build_index = std.mem.indexOfScalar(u8, extra, '+');101 const build_index = std.mem.findScalar(u8, extra, '+');
102 ver.pre = extra[1..(build_index orelse extra.len)];102 ver.pre = extra[1..(build_index orelse extra.len)];
103 if (build_index) |idx| ver.build = extra[(idx + 1)..];103 if (build_index) |idx| ver.build = extra[(idx + 1)..];
104 } else {104 } else {
lib/std/Uri.zig+8-8
...@@ -65,7 +65,7 @@ pub const Component = union(enum) {...@@ -65,7 +65,7 @@ pub const Component = union(enum) {
65 pub fn toRaw(component: Component, buffer: []u8) error{NoSpaceLeft}![]const u8 {65 pub fn toRaw(component: Component, buffer: []u8) error{NoSpaceLeft}![]const u8 {
66 return switch (component) {66 return switch (component) {
67 .raw => |raw| raw,67 .raw => |raw| raw,
68 .percent_encoded => |percent_encoded| if (std.mem.indexOfScalar(u8, percent_encoded, '%')) |_|68 .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_|
69 try std.fmt.bufPrint(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)})69 try std.fmt.bufPrint(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)})
70 else70 else
71 percent_encoded,71 percent_encoded,
...@@ -76,7 +76,7 @@ pub const Component = union(enum) {...@@ -76,7 +76,7 @@ pub const Component = union(enum) {
76 pub fn toRawMaybeAlloc(component: Component, arena: Allocator) Allocator.Error![]const u8 {76 pub fn toRawMaybeAlloc(component: Component, arena: Allocator) Allocator.Error![]const u8 {
77 return switch (component) {77 return switch (component) {
78 .raw => |raw| raw,78 .raw => |raw| raw,
79 .percent_encoded => |percent_encoded| if (std.mem.indexOfScalar(u8, percent_encoded, '%')) |_|79 .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_|
80 try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)})80 try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)})
81 else81 else
82 percent_encoded,82 percent_encoded,
...@@ -89,7 +89,7 @@ pub const Component = union(enum) {...@@ -89,7 +89,7 @@ pub const Component = union(enum) {
89 .percent_encoded => |percent_encoded| {89 .percent_encoded => |percent_encoded| {
90 var start: usize = 0;90 var start: usize = 0;
91 var index: usize = 0;91 var index: usize = 0;
92 while (std.mem.indexOfScalarPos(u8, percent_encoded, index, '%')) |percent| {92 while (std.mem.findScalarPos(u8, percent_encoded, index, '%')) |percent| {
93 index = percent + 1;93 index = percent + 1;
94 if (percent_encoded.len - index < 2) continue;94 if (percent_encoded.len - index < 2) continue;
95 const percent_encoded_char =95 const percent_encoded_char =
...@@ -213,7 +213,7 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {...@@ -213,7 +213,7 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {
213 var i: usize = 0;213 var i: usize = 0;
214214
215 if (std.mem.startsWith(u8, text, "//")) a: {215 if (std.mem.startsWith(u8, text, "//")) a: {
216 i = std.mem.indexOfAnyPos(u8, text, 2, &authority_sep) orelse text.len;216 i = std.mem.findAnyPos(u8, text, 2, &authority_sep) orelse text.len;
217 const authority = text[2..i];217 const authority = text[2..i];
218 if (authority.len == 0) {218 if (authority.len == 0) {
219 if (!std.mem.startsWith(u8, text[2..], "/")) return error.InvalidFormat;219 if (!std.mem.startsWith(u8, text[2..], "/")) return error.InvalidFormat;
...@@ -221,11 +221,11 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {...@@ -221,11 +221,11 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {
221 }221 }
222222
223 var start_of_host: usize = 0;223 var start_of_host: usize = 0;
224 if (std.mem.indexOf(u8, authority, "@")) |index| {224 if (std.mem.find(u8, authority, "@")) |index| {
225 start_of_host = index + 1;225 start_of_host = index + 1;
226 const user_info = authority[0..index];226 const user_info = authority[0..index];
227227
228 if (std.mem.indexOf(u8, user_info, ":")) |idx| {228 if (std.mem.find(u8, user_info, ":")) |idx| {
229 uri.user = .{ .percent_encoded = user_info[0..idx] };229 uri.user = .{ .percent_encoded = user_info[0..idx] };
230 if (idx < user_info.len - 1) { // empty password is also "no password"230 if (idx < user_info.len - 1) { // empty password is also "no password"
231 uri.password = .{ .percent_encoded = user_info[idx + 1 ..] };231 uri.password = .{ .percent_encoded = user_info[idx + 1 ..] };
...@@ -268,12 +268,12 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {...@@ -268,12 +268,12 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {
268 }268 }
269269
270 const path_start = i;270 const path_start = i;
271 i = std.mem.indexOfAnyPos(u8, text, path_start, &path_sep) orelse text.len;271 i = std.mem.findAnyPos(u8, text, path_start, &path_sep) orelse text.len;
272 uri.path = .{ .percent_encoded = text[path_start..i] };272 uri.path = .{ .percent_encoded = text[path_start..i] };
273273
274 if (std.mem.startsWith(u8, text[i..], "?")) {274 if (std.mem.startsWith(u8, text[i..], "?")) {
275 const query_start = i + 1;275 const query_start = i + 1;
276 i = std.mem.indexOfScalarPos(u8, text, query_start, '#') orelse text.len;276 i = std.mem.findScalarPos(u8, text, query_start, '#') orelse text.len;
277 uri.query = .{ .percent_encoded = text[query_start..i] };277 uri.query = .{ .percent_encoded = text[query_start..i] };
278 }278 }
279279
lib/std/ascii.zig+25-16
...@@ -156,7 +156,7 @@ test whitespace {...@@ -156,7 +156,7 @@ test whitespace {
156156
157 var i: u8 = 0;157 var i: u8 = 0;
158 while (isAscii(i)) : (i += 1) {158 while (isAscii(i)) : (i += 1) {
159 if (isWhitespace(i)) try std.testing.expect(std.mem.indexOfScalar(u8, &whitespace, i) != null);159 if (isWhitespace(i)) try std.testing.expect(std.mem.findScalar(u8, &whitespace, i) != null);
160 }160 }
161}161}
162162
...@@ -357,19 +357,25 @@ test endsWithIgnoreCase {...@@ -357,19 +357,25 @@ test endsWithIgnoreCase {
357 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));357 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));
358}358}
359359
360/// Deprecated in favor of `findIgnoreCase`.
361pub const indexOfIgnoreCase = findIgnoreCase;
362
360/// Finds `needle` in `haystack`, ignoring case, starting at index 0.363/// Finds `needle` in `haystack`, ignoring case, starting at index 0.
361pub fn indexOfIgnoreCase(haystack: []const u8, needle: []const u8) ?usize {364pub fn findIgnoreCase(haystack: []const u8, needle: []const u8) ?usize {
362 return indexOfIgnoreCasePos(haystack, 0, needle);365 return findIgnoreCasePos(haystack, 0, needle);
363}366}
364367
368/// Deprecated in favor of `findIgnoreCasePos`.
369pub const indexOfIgnoreCasePos = findIgnoreCasePos;
370
365/// Finds `needle` in `haystack`, ignoring case, starting at `start_index`.371/// Finds `needle` in `haystack`, ignoring case, starting at `start_index`.
366/// Uses Boyer-Moore-Horspool algorithm on large inputs; `indexOfIgnoreCasePosLinear` on small inputs.372/// Uses Boyer-Moore-Horspool algorithm on large inputs; `findIgnoreCasePosLinear` on small inputs.
367pub fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {373pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
368 if (needle.len > haystack.len) return null;374 if (needle.len > haystack.len) return null;
369 if (needle.len == 0) return start_index;375 if (needle.len == 0) return start_index;
370376
371 if (haystack.len < 52 or needle.len <= 4)377 if (haystack.len < 52 or needle.len <= 4)
372 return indexOfIgnoreCasePosLinear(haystack, start_index, needle);378 return findIgnoreCasePosLinear(haystack, start_index, needle);
373379
374 var skip_table: [256]usize = undefined;380 var skip_table: [256]usize = undefined;
375 boyerMooreHorspoolPreprocessIgnoreCase(needle, skip_table[0..]);381 boyerMooreHorspoolPreprocessIgnoreCase(needle, skip_table[0..]);
...@@ -383,9 +389,12 @@ pub fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []...@@ -383,9 +389,12 @@ pub fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []
383 return null;389 return null;
384}390}
385391
386/// Consider using `indexOfIgnoreCasePos` instead of this, which will automatically use a392/// Deprecated in favor of `findIgnoreCaseLinear`.
393pub const indexOfIgnoreCasePosLinear = findIgnoreCasePosLinear;
394
395/// Consider using `findIgnoreCasePos` instead of this, which will automatically use a
387/// more sophisticated algorithm on larger inputs.396/// more sophisticated algorithm on larger inputs.
388pub fn indexOfIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {397pub fn findIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
389 var i: usize = start_index;398 var i: usize = start_index;
390 const end = haystack.len - needle.len;399 const end = haystack.len - needle.len;
391 while (i <= end) : (i += 1) {400 while (i <= end) : (i += 1) {
...@@ -407,15 +416,15 @@ fn boyerMooreHorspoolPreprocessIgnoreCase(pattern: []const u8, table: *[256]usiz...@@ -407,15 +416,15 @@ fn boyerMooreHorspoolPreprocessIgnoreCase(pattern: []const u8, table: *[256]usiz
407 }416 }
408}417}
409418
410test indexOfIgnoreCase {419test findIgnoreCase {
411 try std.testing.expect(indexOfIgnoreCase("one Two Three Four", "foUr").? == 14);420 try std.testing.expect(findIgnoreCase("one Two Three Four", "foUr").? == 14);
412 try std.testing.expect(indexOfIgnoreCase("one two three FouR", "gOur") == null);421 try std.testing.expect(findIgnoreCase("one two three FouR", "gOur") == null);
413 try std.testing.expect(indexOfIgnoreCase("foO", "Foo").? == 0);422 try std.testing.expect(findIgnoreCase("foO", "Foo").? == 0);
414 try std.testing.expect(indexOfIgnoreCase("foo", "fool") == null);423 try std.testing.expect(findIgnoreCase("foo", "fool") == null);
415 try std.testing.expect(indexOfIgnoreCase("FOO foo", "fOo").? == 0);424 try std.testing.expect(findIgnoreCase("FOO foo", "fOo").? == 0);
416425
417 try std.testing.expect(indexOfIgnoreCase("one two three four five six seven eight nine ten eleven", "ThReE fOUr").? == 8);426 try std.testing.expect(findIgnoreCase("one two three four five six seven eight nine ten eleven", "ThReE fOUr").? == 8);
418 try std.testing.expect(indexOfIgnoreCase("one two three four five six seven eight nine ten eleven", "Two tWo") == null);427 try std.testing.expect(findIgnoreCase("one two three four five six seven eight nine ten eleven", "Two tWo") == null);
419}428}
420429
421/// Returns the lexicographical order of two slices. O(n).430/// Returns the lexicographical order of two slices. O(n).
lib/std/coff.zig+5-5
...@@ -466,13 +466,13 @@ pub const SectionHeader = extern struct {...@@ -466,13 +466,13 @@ pub const SectionHeader = extern struct {
466466
467 pub fn getName(self: *align(1) const SectionHeader) ?[]const u8 {467 pub fn getName(self: *align(1) const SectionHeader) ?[]const u8 {
468 if (self.name[0] == '/') return null;468 if (self.name[0] == '/') return null;
469 const len = std.mem.indexOfScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;469 const len = std.mem.findScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;
470 return self.name[0..len];470 return self.name[0..len];
471 }471 }
472472
473 pub fn getNameOffset(self: SectionHeader) ?u32 {473 pub fn getNameOffset(self: SectionHeader) ?u32 {
474 if (self.name[0] != '/') return null;474 if (self.name[0] != '/') return null;
475 const len = std.mem.indexOfScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;475 const len = std.mem.findScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;
476 const offset = std.fmt.parseInt(u32, self.name[1..len], 10) catch unreachable;476 const offset = std.fmt.parseInt(u32, self.name[1..len], 10) catch unreachable;
477 return offset;477 return offset;
478 }478 }
...@@ -628,7 +628,7 @@ pub const Symbol = struct {...@@ -628,7 +628,7 @@ pub const Symbol = struct {
628628
629 pub fn getName(self: *const Symbol) ?[]const u8 {629 pub fn getName(self: *const Symbol) ?[]const u8 {
630 if (std.mem.eql(u8, self.name[0..4], "\x00\x00\x00\x00")) return null;630 if (std.mem.eql(u8, self.name[0..4], "\x00\x00\x00\x00")) return null;
631 const len = std.mem.indexOfScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;631 const len = std.mem.findScalar(u8, &self.name, @as(u8, 0)) orelse self.name.len;
632 return self.name[0..len];632 return self.name[0..len];
633 }633 }
634634
...@@ -869,7 +869,7 @@ pub const FileDefinition = struct {...@@ -869,7 +869,7 @@ pub const FileDefinition = struct {
869 file_name: [18]u8,869 file_name: [18]u8,
870870
871 pub fn getFileName(self: *const FileDefinition) []const u8 {871 pub fn getFileName(self: *const FileDefinition) []const u8 {
872 const len = std.mem.indexOfScalar(u8, &self.file_name, @as(u8, 0)) orelse self.file_name.len;872 const len = std.mem.findScalar(u8, &self.file_name, @as(u8, 0)) orelse self.file_name.len;
873 return self.file_name[0..len];873 return self.file_name[0..len];
874 }874 }
875};875};
...@@ -1044,7 +1044,7 @@ pub const Coff = struct {...@@ -1044,7 +1044,7 @@ pub const Coff = struct {
10441044
1045 // Finally read the null-terminated string.1045 // Finally read the null-terminated string.
1046 const start = reader.seek;1046 const start = reader.seek;
1047 const len = std.mem.indexOfScalar(u8, self.data[start..], 0) orelse return null;1047 const len = std.mem.findScalar(u8, self.data[start..], 0) orelse return null;
1048 return self.data[start .. start + len];1048 return self.data[start .. start + len];
1049 }1049 }
10501050
lib/std/compress/flate/Compress.zig+1-1
...@@ -598,7 +598,7 @@ fn testFuzzedMatchLen(_: void, input: []const u8) !void {...@@ -598,7 +598,7 @@ fn testFuzzedMatchLen(_: void, input: []const u8) !void {
598 const bytes = w.buffered()[bytes_off..];598 const bytes = w.buffered()[bytes_off..];
599 old = @min(old, bytes.len - 1, token.max_length - 1);599 old = @min(old, bytes.len - 1, token.max_length - 1);
600600
601 const diff_index = mem.indexOfDiff(u8, prev, bytes).?; // unwrap since lengths are not same601 const diff_index = mem.findDiff(u8, prev, bytes).?; // unwrap since lengths are not same
602 const expected_len = @min(diff_index, 258);602 const expected_len = @min(diff_index, 258);
603 errdefer std.debug.print(603 errdefer std.debug.print(
604 \\prev : '{any}'604 \\prev : '{any}'
lib/std/crypto/Certificate.zig+2-2
...@@ -358,10 +358,10 @@ pub const Parsed = struct {...@@ -358,10 +358,10 @@ pub const Parsed = struct {
358 const wildcard_suffix = dns_name[2..];358 const wildcard_suffix = dns_name[2..];
359359
360 // No additional wildcards allowed in the suffix360 // No additional wildcards allowed in the suffix
361 if (mem.indexOf(u8, wildcard_suffix, "*") != null) return false;361 if (mem.find(u8, wildcard_suffix, "*") != null) return false;
362362
363 // Find the first dot in hostname to split first label from rest363 // Find the first dot in hostname to split first label from rest
364 const dot_pos = mem.indexOf(u8, host_name, ".") orelse return false;364 const dot_pos = mem.find(u8, host_name, ".") orelse return false;
365365
366 // Wildcard matches exactly one label, so compare the rest366 // Wildcard matches exactly one label, so compare the rest
367 const host_suffix = host_name[dot_pos + 1 ..];367 const host_suffix = host_name[dot_pos + 1 ..];
lib/std/crypto/Certificate/Bundle.zig+2-2
...@@ -269,9 +269,9 @@ pub fn addCertsFromFile(cb: *Bundle, gpa: Allocator, file_reader: *Io.File.Reade...@@ -269,9 +269,9 @@ pub fn addCertsFromFile(cb: *Bundle, gpa: Allocator, file_reader: *Io.File.Reade
269 const end_marker = "-----END CERTIFICATE-----";269 const end_marker = "-----END CERTIFICATE-----";
270270
271 var start_index: usize = 0;271 var start_index: usize = 0;
272 while (mem.indexOfPos(u8, encoded_bytes, start_index, begin_marker)) |begin_marker_start| {272 while (mem.findPos(u8, encoded_bytes, start_index, begin_marker)) |begin_marker_start| {
273 const cert_start = begin_marker_start + begin_marker.len;273 const cert_start = begin_marker_start + begin_marker.len;
274 const cert_end = mem.indexOfPos(u8, encoded_bytes, cert_start, end_marker) orelse274 const cert_end = mem.findPos(u8, encoded_bytes, cert_start, end_marker) orelse
275 return error.MissingEndCertificateMarker;275 return error.MissingEndCertificateMarker;
276 start_index = cert_end + end_marker.len;276 start_index = cert_end + end_marker.len;
277 const encoded_cert = mem.trim(u8, encoded_bytes[cert_start..cert_end], " \t\r\n");277 const encoded_cert = mem.trim(u8, encoded_bytes[cert_start..cert_end], " \t\r\n");
lib/std/crypto/benchmark.zig+14-14
...@@ -547,7 +547,7 @@ pub fn main() !void {...@@ -547,7 +547,7 @@ pub fn main() !void {
547 }547 }
548548
549 inline for (hashes) |H| {549 inline for (hashes) |H| {
550 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {550 if (filter == null or std.mem.find(u8, H.name, filter.?) != null) {
551 const throughput = try benchmarkHash(H.ty, mode(128 * MiB));551 const throughput = try benchmarkHash(H.ty, mode(128 * MiB));
552 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ H.name, throughput / (1 * MiB) });552 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ H.name, throughput / (1 * MiB) });
553 try stdout.flush();553 try stdout.flush();
...@@ -559,7 +559,7 @@ pub fn main() !void {...@@ -559,7 +559,7 @@ pub fn main() !void {
559 const io = io_threaded.io();559 const io = io_threaded.io();
560560
561 inline for (parallel_hashes) |H| {561 inline for (parallel_hashes) |H| {
562 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {562 if (filter == null or std.mem.find(u8, H.name, filter.?) != null) {
563 const throughput = try benchmarkHashParallel(H.ty, mode(128 * MiB), arena_allocator, io);563 const throughput = try benchmarkHashParallel(H.ty, mode(128 * MiB), arena_allocator, io);
564 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ H.name, throughput / (1 * MiB) });564 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ H.name, throughput / (1 * MiB) });
565 try stdout.flush();565 try stdout.flush();
...@@ -567,7 +567,7 @@ pub fn main() !void {...@@ -567,7 +567,7 @@ pub fn main() !void {
567 }567 }
568568
569 inline for (macs) |M| {569 inline for (macs) |M| {
570 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {570 if (filter == null or std.mem.find(u8, M.name, filter.?) != null) {
571 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));571 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));
572 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ M.name, throughput / (1 * MiB) });572 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ M.name, throughput / (1 * MiB) });
573 try stdout.flush();573 try stdout.flush();
...@@ -575,7 +575,7 @@ pub fn main() !void {...@@ -575,7 +575,7 @@ pub fn main() !void {
575 }575 }
576576
577 inline for (exchanges) |E| {577 inline for (exchanges) |E| {
578 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {578 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
579 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));579 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));
580 try stdout.print("{s:>17}: {:10} exchanges/s\n", .{ E.name, throughput });580 try stdout.print("{s:>17}: {:10} exchanges/s\n", .{ E.name, throughput });
581 try stdout.flush();581 try stdout.flush();
...@@ -583,7 +583,7 @@ pub fn main() !void {...@@ -583,7 +583,7 @@ pub fn main() !void {
583 }583 }
584584
585 inline for (signatures) |E| {585 inline for (signatures) |E| {
586 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {586 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
587 const throughput = try benchmarkSignature(E.ty, mode(1000));587 const throughput = try benchmarkSignature(E.ty, mode(1000));
588 try stdout.print("{s:>17}: {:10} signatures/s\n", .{ E.name, throughput });588 try stdout.print("{s:>17}: {:10} signatures/s\n", .{ E.name, throughput });
589 try stdout.flush();589 try stdout.flush();
...@@ -591,7 +591,7 @@ pub fn main() !void {...@@ -591,7 +591,7 @@ pub fn main() !void {
591 }591 }
592592
593 inline for (signature_verifications) |E| {593 inline for (signature_verifications) |E| {
594 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {594 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
595 const throughput = try benchmarkSignatureVerification(E.ty, mode(1000));595 const throughput = try benchmarkSignatureVerification(E.ty, mode(1000));
596 try stdout.print("{s:>17}: {:10} verifications/s\n", .{ E.name, throughput });596 try stdout.print("{s:>17}: {:10} verifications/s\n", .{ E.name, throughput });
597 try stdout.flush();597 try stdout.flush();
...@@ -599,7 +599,7 @@ pub fn main() !void {...@@ -599,7 +599,7 @@ pub fn main() !void {
599 }599 }
600600
601 inline for (batch_signature_verifications) |E| {601 inline for (batch_signature_verifications) |E| {
602 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {602 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
603 const throughput = try benchmarkBatchSignatureVerification(E.ty, mode(1000));603 const throughput = try benchmarkBatchSignatureVerification(E.ty, mode(1000));
604 try stdout.print("{s:>17}: {:10} verifications/s (batch)\n", .{ E.name, throughput });604 try stdout.print("{s:>17}: {:10} verifications/s (batch)\n", .{ E.name, throughput });
605 try stdout.flush();605 try stdout.flush();
...@@ -607,7 +607,7 @@ pub fn main() !void {...@@ -607,7 +607,7 @@ pub fn main() !void {
607 }607 }
608608
609 inline for (aeads) |E| {609 inline for (aeads) |E| {
610 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {610 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
611 const throughput = try benchmarkAead(E.ty, mode(128 * MiB));611 const throughput = try benchmarkAead(E.ty, mode(128 * MiB));
612 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ E.name, throughput / (1 * MiB) });612 try stdout.print("{s:>17}: {:10} MiB/s\n", .{ E.name, throughput / (1 * MiB) });
613 try stdout.flush();613 try stdout.flush();
...@@ -615,7 +615,7 @@ pub fn main() !void {...@@ -615,7 +615,7 @@ pub fn main() !void {
615 }615 }
616616
617 inline for (aes) |E| {617 inline for (aes) |E| {
618 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {618 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
619 const throughput = try benchmarkAes(E.ty, mode(100000000));619 const throughput = try benchmarkAes(E.ty, mode(100000000));
620 try stdout.print("{s:>17}: {:10} ops/s\n", .{ E.name, throughput });620 try stdout.print("{s:>17}: {:10} ops/s\n", .{ E.name, throughput });
621 try stdout.flush();621 try stdout.flush();
...@@ -623,7 +623,7 @@ pub fn main() !void {...@@ -623,7 +623,7 @@ pub fn main() !void {
623 }623 }
624624
625 inline for (aes8) |E| {625 inline for (aes8) |E| {
626 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {626 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
627 const throughput = try benchmarkAes8(E.ty, mode(10000000));627 const throughput = try benchmarkAes8(E.ty, mode(10000000));
628 try stdout.print("{s:>17}: {:10} ops/s\n", .{ E.name, throughput });628 try stdout.print("{s:>17}: {:10} ops/s\n", .{ E.name, throughput });
629 try stdout.flush();629 try stdout.flush();
...@@ -631,7 +631,7 @@ pub fn main() !void {...@@ -631,7 +631,7 @@ pub fn main() !void {
631 }631 }
632632
633 inline for (pwhashes) |H| {633 inline for (pwhashes) |H| {
634 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {634 if (filter == null or std.mem.find(u8, H.name, filter.?) != null) {
635 const throughput = try benchmarkPwhash(arena_allocator, H.ty, H.params, mode(64), io);635 const throughput = try benchmarkPwhash(arena_allocator, H.ty, H.params, mode(64), io);
636 try stdout.print("{s:>17}: {d:10.3} s/ops\n", .{ H.name, throughput });636 try stdout.print("{s:>17}: {d:10.3} s/ops\n", .{ H.name, throughput });
637 try stdout.flush();637 try stdout.flush();
...@@ -639,7 +639,7 @@ pub fn main() !void {...@@ -639,7 +639,7 @@ pub fn main() !void {
639 }639 }
640640
641 inline for (kems) |E| {641 inline for (kems) |E| {
642 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {642 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
643 const throughput = try benchmarkKem(E.ty, mode(1000));643 const throughput = try benchmarkKem(E.ty, mode(1000));
644 try stdout.print("{s:>17}: {:10} encaps/s\n", .{ E.name, throughput });644 try stdout.print("{s:>17}: {:10} encaps/s\n", .{ E.name, throughput });
645 try stdout.flush();645 try stdout.flush();
...@@ -647,7 +647,7 @@ pub fn main() !void {...@@ -647,7 +647,7 @@ pub fn main() !void {
647 }647 }
648648
649 inline for (kems) |E| {649 inline for (kems) |E| {
650 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {650 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
651 const throughput = try benchmarkKemDecaps(E.ty, mode(25000));651 const throughput = try benchmarkKemDecaps(E.ty, mode(25000));
652 try stdout.print("{s:>17}: {:10} decaps/s\n", .{ E.name, throughput });652 try stdout.print("{s:>17}: {:10} decaps/s\n", .{ E.name, throughput });
653 try stdout.flush();653 try stdout.flush();
...@@ -655,7 +655,7 @@ pub fn main() !void {...@@ -655,7 +655,7 @@ pub fn main() !void {
655 }655 }
656656
657 inline for (kems) |E| {657 inline for (kems) |E| {
658 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {658 if (filter == null or std.mem.find(u8, E.name, filter.?) != null) {
659 const throughput = try benchmarkKemKeyGen(E.ty, mode(25000));659 const throughput = try benchmarkKemKeyGen(E.ty, mode(25000));
660 try stdout.print("{s:>17}: {:10} keygen/s\n", .{ E.name, throughput });660 try stdout.print("{s:>17}: {:10} keygen/s\n", .{ E.name, throughput });
661 try stdout.flush();661 try stdout.flush();
lib/std/crypto/scrypt.zig+1-1
...@@ -358,7 +358,7 @@ const crypt_format = struct {...@@ -358,7 +358,7 @@ const crypt_format = struct {
358 fn intDecode(comptime T: type, src: *const [(@bitSizeOf(T) + 5) / 6]u8) !T {358 fn intDecode(comptime T: type, src: *const [(@bitSizeOf(T) + 5) / 6]u8) !T {
359 var v: T = 0;359 var v: T = 0;
360 for (src, 0..) |x, i| {360 for (src, 0..) |x, i| {
361 const vi = mem.indexOfScalar(u8, &map64, x) orelse return EncodingError.InvalidEncoding;361 const vi = mem.findScalar(u8, &map64, x) orelse return EncodingError.InvalidEncoding;
362 v |= @as(T, @intCast(vi)) << @as(math.Log2Int(T), @intCast(i * 6));362 v |= @as(T, @intCast(vi)) << @as(math.Log2Int(T), @intCast(i * 6));
363 }363 }
364 return v;364 return v;
lib/std/debug.zig+3-3
...@@ -1196,7 +1196,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {...@@ -1196,7 +1196,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {
1196 var next_line: usize = 1;1196 var next_line: usize = 1;
1197 while (next_line != source_location.line) {1197 while (next_line != source_location.line) {
1198 const slice = buf[current_line_start..amt_read];1198 const slice = buf[current_line_start..amt_read];
1199 if (mem.indexOfScalar(u8, slice, '\n')) |pos| {1199 if (mem.findScalar(u8, slice, '\n')) |pos| {
1200 next_line += 1;1200 next_line += 1;
1201 if (pos == slice.len - 1) {1201 if (pos == slice.len - 1) {
1202 amt_read = try f.read(buf[0..]);1202 amt_read = try f.read(buf[0..]);
...@@ -1212,7 +1212,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {...@@ -1212,7 +1212,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {
1212 break :seek current_line_start;1212 break :seek current_line_start;
1213 };1213 };
1214 const slice = buf[line_start..amt_read];1214 const slice = buf[line_start..amt_read];
1215 if (mem.indexOfScalar(u8, slice, '\n')) |pos| {1215 if (mem.findScalar(u8, slice, '\n')) |pos| {
1216 const line = slice[0 .. pos + 1];1216 const line = slice[0 .. pos + 1];
1217 mem.replaceScalar(u8, line, '\t', ' ');1217 mem.replaceScalar(u8, line, '\t', ' ');
1218 return writer.writeAll(line);1218 return writer.writeAll(line);
...@@ -1221,7 +1221,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {...@@ -1221,7 +1221,7 @@ fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void {
1221 try writer.writeAll(slice);1221 try writer.writeAll(slice);
1222 while (amt_read == buf.len) {1222 while (amt_read == buf.len) {
1223 amt_read = try f.read(buf[0..]);1223 amt_read = try f.read(buf[0..]);
1224 if (mem.indexOfScalar(u8, buf[0..amt_read], '\n')) |pos| {1224 if (mem.findScalar(u8, buf[0..amt_read], '\n')) |pos| {
1225 const line = buf[0 .. pos + 1];1225 const line = buf[0 .. pos + 1];
1226 mem.replaceScalar(u8, line, '\t', ' ');1226 mem.replaceScalar(u8, line, '\t', ' ');
1227 return writer.writeAll(line);1227 return writer.writeAll(line);
lib/std/debug/Dwarf.zig+2-2
...@@ -437,7 +437,7 @@ fn scanAllFunctions(di: *Dwarf, gpa: Allocator, endian: Endian) ScanError!void {...@@ -437,7 +437,7 @@ fn scanAllFunctions(di: *Dwarf, gpa: Allocator, endian: Endian) ScanError!void {
437 };437 };
438438
439 while (true) {439 while (true) {
440 fr.seek = std.mem.indexOfNonePos(u8, fr.buffer, fr.seek, &.{440 fr.seek = std.mem.findNonePos(u8, fr.buffer, fr.seek, &.{
441 zig_padding_abbrev_code, 0,441 zig_padding_abbrev_code, 0,
442 }) orelse fr.buffer.len;442 }) orelse fr.buffer.len;
443 if (fr.seek >= next_unit_pos) break;443 if (fr.seek >= next_unit_pos) break;
...@@ -1539,7 +1539,7 @@ fn getStringGeneric(opt_str: ?[]const u8, offset: u64) ![:0]const u8 {...@@ -1539,7 +1539,7 @@ fn getStringGeneric(opt_str: ?[]const u8, offset: u64) ![:0]const u8 {
1539 if (offset > str.len) return bad();1539 if (offset > str.len) return bad();
1540 const casted_offset = cast(usize, offset) orelse return bad();1540 const casted_offset = cast(usize, offset) orelse return bad();
1541 // Valid strings always have a terminating zero byte1541 // Valid strings always have a terminating zero byte
1542 const last = std.mem.indexOfScalarPos(u8, str, casted_offset, 0) orelse return bad();1542 const last = std.mem.findScalarPos(u8, str, casted_offset, 0) orelse return bad();
1543 return str[casted_offset..last :0];1543 return str[casted_offset..last :0];
1544}1544}
15451545
lib/std/dynamic_library.zig+1-1
...@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {...@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
197 // - /etc/ld.so.cache is not read197 // - /etc/ld.so.cache is not read
198 fn resolveFromName(path_or_name: []const u8) !posix.fd_t {198 fn resolveFromName(path_or_name: []const u8) !posix.fd_t {
199 // If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname199 // If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname
200 if (std.mem.indexOfScalarPos(u8, path_or_name, 0, '/')) |_| {200 if (std.mem.findScalarPos(u8, path_or_name, 0, '/')) |_| {
201 return posix.open(path_or_name, .{ .ACCMODE = .RDONLY, .CLOEXEC = true }, 0);201 return posix.open(path_or_name, .{ .ACCMODE = .RDONLY, .CLOEXEC = true }, 0);
202 }202 }
203203
lib/std/elf.zig+1-1
...@@ -3039,7 +3039,7 @@ pub const ar_hdr = extern struct {...@@ -3039,7 +3039,7 @@ pub const ar_hdr = extern struct {
3039 pub fn name(self: *const ar_hdr) ?[]const u8 {3039 pub fn name(self: *const ar_hdr) ?[]const u8 {
3040 const value = &self.ar_name;3040 const value = &self.ar_name;
3041 if (value[0] == '/') return null;3041 if (value[0] == '/') return null;
3042 const sentinel = mem.indexOfScalar(u8, value, '/') orelse value.len;3042 const sentinel = mem.findScalar(u8, value, '/') orelse value.len;
3043 return value[0..sentinel];3043 return value[0..sentinel];
3044 }3044 }
30453045
lib/std/fmt.zig+1-1
...@@ -182,7 +182,7 @@ pub const Parser = struct {...@@ -182,7 +182,7 @@ pub const Parser = struct {
182182
183 pub fn until(self: *@This(), delimiter: u8) []const u8 {183 pub fn until(self: *@This(), delimiter: u8) []const u8 {
184 const start = self.i;184 const start = self.i;
185 self.i = std.mem.indexOfScalarPos(u8, self.bytes, self.i, delimiter) orelse self.bytes.len;185 self.i = std.mem.findScalarPos(u8, self.bytes, self.i, delimiter) orelse self.bytes.len;
186 return self.bytes[start..self.i];186 return self.bytes[start..self.i];
187 }187 }
188188
lib/std/fs.zig+1-1
...@@ -469,7 +469,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -469,7 +469,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
469 return error.FileNotFound;469 return error.FileNotFound;
470470
471 const argv0 = mem.span(std.os.argv[0]);471 const argv0 = mem.span(std.os.argv[0]);
472 if (mem.indexOf(u8, argv0, "/") != null) {472 if (mem.find(u8, argv0, "/") != null) {
473 // argv[0] is a path (relative or absolute): use realpath(3) directly473 // argv[0] is a path (relative or absolute): use realpath(3) directly
474 var real_path_buf: [max_path_bytes]u8 = undefined;474 var real_path_buf: [max_path_bytes]u8 = undefined;
475 const real_path = posix.realpathZ(std.os.argv[0], &real_path_buf) catch |err| switch (err) {475 const real_path = posix.realpathZ(std.os.argv[0], &real_path_buf) catch |err| switch (err) {
lib/std/fs/File.zig+1-1
...@@ -179,7 +179,7 @@ pub fn isCygwinPty(file: File) bool {...@@ -179,7 +179,7 @@ pub fn isCygwinPty(file: File) bool {
179 // The name we get from NtQueryInformationFile will be prefixed with a '\', e.g. \msys-1888ae32e00d56aa-pty0-to-master179 // The name we get from NtQueryInformationFile will be prefixed with a '\', e.g. \msys-1888ae32e00d56aa-pty0-to-master
180 return (std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'm', 's', 'y', 's', '-' }) or180 return (std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'm', 's', 'y', 's', '-' }) or
181 std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'c', 'y', 'g', 'w', 'i', 'n', '-' })) and181 std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'c', 'y', 'g', 'w', 'i', 'n', '-' })) and
182 std.mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;182 std.mem.find(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
183}183}
184184
185/// Returns whether or not ANSI escape codes will be treated as such,185/// Returns whether or not ANSI escape codes will be treated as such,
lib/std/fs/path.zig+3-3
...@@ -402,9 +402,9 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {...@@ -402,9 +402,9 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
402402
403 if (path.len >= 2 and PathType.windows.isSep(u8, path[0]) and PathType.windows.isSep(u8, path[1])) {403 if (path.len >= 2 and PathType.windows.isSep(u8, path[0]) and PathType.windows.isSep(u8, path[1])) {
404 const root_end = root_end: {404 const root_end = root_end: {
405 var server_end = mem.indexOfAnyPos(u8, path, 2, "/\\") orelse break :root_end path.len;405 var server_end = mem.findAnyPos(u8, path, 2, "/\\") orelse break :root_end path.len;
406 while (server_end < path.len and PathType.windows.isSep(u8, path[server_end])) server_end += 1;406 while (server_end < path.len and PathType.windows.isSep(u8, path[server_end])) server_end += 1;
407 break :root_end mem.indexOfAnyPos(u8, path, server_end, "/\\") orelse path.len;407 break :root_end mem.findAnyPos(u8, path, server_end, "/\\") orelse path.len;
408 };408 };
409 return WindowsPath{409 return WindowsPath{
410 .is_abs = true,410 .is_abs = true,
...@@ -722,7 +722,7 @@ fn parseUNC(comptime T: type, path: []const T) WindowsUNC(T) {...@@ -722,7 +722,7 @@ fn parseUNC(comptime T: type, path: []const T) WindowsUNC(T) {
722 // For the server, the first path separator after the initial two is always722 // For the server, the first path separator after the initial two is always
723 // the terminator of the server name, even if that means the server name is723 // the terminator of the server name, even if that means the server name is
724 // zero-length.724 // zero-length.
725 const server_end = mem.indexOfAnyPos(T, path, 2, any_sep) orelse return .{725 const server_end = mem.findAnyPos(T, path, 2, any_sep) orelse return .{
726 .server = path[2..path.len],726 .server = path[2..path.len],
727 .sep_after_server = false,727 .sep_after_server = false,
728 .share = path[path.len..path.len],728 .share = path[path.len..path.len],
lib/std/hash/benchmark.zig+1-1
...@@ -443,7 +443,7 @@ pub fn main() !void {...@@ -443,7 +443,7 @@ pub fn main() !void {
443 const allocator = gpa.allocator();443 const allocator = gpa.allocator();
444444
445 inline for (hashes) |H| {445 inline for (hashes) |H| {
446 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) hash: {446 if (filter == null or std.mem.find(u8, H.name, filter.?) != null) hash: {
447 if (!test_iterative_only or H.has_iterative_api) {447 if (!test_iterative_only or H.has_iterative_api) {
448 try stdout.print("{s}\n", .{H.name});448 try stdout.print("{s}\n", .{H.name});
449 try stdout.flush();449 try stdout.flush();
lib/std/hash_map.zig+1-1
...@@ -110,7 +110,7 @@ pub const StringIndexAdapter = struct {...@@ -110,7 +110,7 @@ pub const StringIndexAdapter = struct {
110 }110 }
111111
112 pub fn hash(_: @This(), adapted_key: []const u8) u64 {112 pub fn hash(_: @This(), adapted_key: []const u8) u64 {
113 assert(mem.indexOfScalar(u8, adapted_key, 0) == null);113 assert(mem.findScalar(u8, adapted_key, 0) == null);
114 return hashString(adapted_key);114 return hashString(adapted_key);
115 }115 }
116};116};
lib/std/http/Client.zig+5-5
...@@ -1674,14 +1674,14 @@ pub fn request(...@@ -1674,14 +1674,14 @@ pub fn request(
1674 if (std.debug.runtime_safety) {1674 if (std.debug.runtime_safety) {
1675 for (options.extra_headers) |header| {1675 for (options.extra_headers) |header| {
1676 assert(header.name.len != 0);1676 assert(header.name.len != 0);
1677 assert(std.mem.indexOfScalar(u8, header.name, ':') == null);1677 assert(std.mem.findScalar(u8, header.name, ':') == null);
1678 assert(std.mem.indexOfPosLinear(u8, header.name, 0, "\r\n") == null);1678 assert(std.mem.findPosLinear(u8, header.name, 0, "\r\n") == null);
1679 assert(std.mem.indexOfPosLinear(u8, header.value, 0, "\r\n") == null);1679 assert(std.mem.findPosLinear(u8, header.value, 0, "\r\n") == null);
1680 }1680 }
1681 for (options.privileged_headers) |header| {1681 for (options.privileged_headers) |header| {
1682 assert(header.name.len != 0);1682 assert(header.name.len != 0);
1683 assert(std.mem.indexOfPosLinear(u8, header.name, 0, "\r\n") == null);1683 assert(std.mem.findPosLinear(u8, header.name, 0, "\r\n") == null);
1684 assert(std.mem.indexOfPosLinear(u8, header.value, 0, "\r\n") == null);1684 assert(std.mem.findPosLinear(u8, header.value, 0, "\r\n") == null);
1685 }1685 }
1686 }1686 }
16871687
lib/std/http/HeaderIterator.zig+3-3
...@@ -5,17 +5,17 @@ is_trailer: bool,...@@ -5,17 +5,17 @@ is_trailer: bool,
5pub fn init(bytes: []const u8) HeaderIterator {5pub fn init(bytes: []const u8) HeaderIterator {
6 return .{6 return .{
7 .bytes = bytes,7 .bytes = bytes,
8 .index = std.mem.indexOfPosLinear(u8, bytes, 0, "\r\n").? + 2,8 .index = std.mem.findPosLinear(u8, bytes, 0, "\r\n").? + 2,
9 .is_trailer = false,9 .is_trailer = false,
10 };10 };
11}11}
1212
13pub fn next(it: *HeaderIterator) ?std.http.Header {13pub fn next(it: *HeaderIterator) ?std.http.Header {
14 const end = std.mem.indexOfPosLinear(u8, it.bytes, it.index, "\r\n").?;14 const end = std.mem.findPosLinear(u8, it.bytes, it.index, "\r\n").?;
15 if (it.index == end) { // found the trailer boundary (\r\n\r\n)15 if (it.index == end) { // found the trailer boundary (\r\n\r\n)
16 if (it.is_trailer) return null;16 if (it.is_trailer) return null;
1717
18 const next_end = std.mem.indexOfPosLinear(u8, it.bytes, end + 2, "\r\n") orelse18 const next_end = std.mem.findPosLinear(u8, it.bytes, end + 2, "\r\n") orelse
19 return null;19 return null;
2020
21 var kv_it = std.mem.splitScalar(u8, it.bytes[end + 2 .. next_end], ':');21 var kv_it = std.mem.splitScalar(u8, it.bytes[end + 2 .. next_end], ':');
lib/std/http/Server.zig+4-4
...@@ -96,7 +96,7 @@ pub const Request = struct {...@@ -96,7 +96,7 @@ pub const Request = struct {
96 if (first_line.len < 10)96 if (first_line.len < 10)
97 return error.HttpHeadersInvalid;97 return error.HttpHeadersInvalid;
9898
99 const method_end = mem.indexOfScalar(u8, first_line, ' ') orelse99 const method_end = mem.findScalar(u8, first_line, ' ') orelse
100 return error.HttpHeadersInvalid;100 return error.HttpHeadersInvalid;
101101
102 const method = std.meta.stringToEnum(http.Method, first_line[0..method_end]) orelse102 const method = std.meta.stringToEnum(http.Method, first_line[0..method_end]) orelse
...@@ -338,9 +338,9 @@ pub const Request = struct {...@@ -338,9 +338,9 @@ pub const Request = struct {
338 if (std.debug.runtime_safety) {338 if (std.debug.runtime_safety) {
339 for (options.extra_headers) |header| {339 for (options.extra_headers) |header| {
340 assert(header.name.len != 0);340 assert(header.name.len != 0);
341 assert(std.mem.indexOfScalar(u8, header.name, ':') == null);341 assert(std.mem.findScalar(u8, header.name, ':') == null);
342 assert(std.mem.indexOfPosLinear(u8, header.name, 0, "\r\n") == null);342 assert(std.mem.findPosLinear(u8, header.name, 0, "\r\n") == null);
343 assert(std.mem.indexOfPosLinear(u8, header.value, 0, "\r\n") == null);343 assert(std.mem.findPosLinear(u8, header.value, 0, "\r\n") == null);
344 }344 }
345 }345 }
346 try writeExpectContinue(request);346 try writeExpectContinue(request);
lib/std/http/test.zig+1-1
...@@ -447,7 +447,7 @@ test "general client/server API coverage" {...@@ -447,7 +447,7 @@ test "general client/server API coverage" {
447447
448 if (mem.startsWith(u8, target, "/get")) {448 if (mem.startsWith(u8, target, "/get")) {
449 var response = try request.respondStreaming(&.{}, .{449 var response = try request.respondStreaming(&.{}, .{
450 .content_length = if (mem.indexOf(u8, target, "?chunked") == null)450 .content_length = if (mem.find(u8, target, "?chunked") == null)
451 14451 14
452 else452 else
453 null,453 null,
lib/std/json/Scanner.zig+1-1
...@@ -1758,7 +1758,7 @@ fn appendSlice(list: *std.array_list.Managed(u8), buf: []const u8, max_value_len...@@ -1758,7 +1758,7 @@ fn appendSlice(list: *std.array_list.Managed(u8), buf: []const u8, max_value_len
1758/// This function will not give meaningful results on non-numeric input.1758/// This function will not give meaningful results on non-numeric input.
1759pub fn isNumberFormattedLikeAnInteger(value: []const u8) bool {1759pub fn isNumberFormattedLikeAnInteger(value: []const u8) bool {
1760 if (std.mem.eql(u8, value, "-0")) return false;1760 if (std.mem.eql(u8, value, "-0")) return false;
1761 return std.mem.indexOfAny(u8, value, ".eE") == null;1761 return std.mem.findAny(u8, value, ".eE") == null;
1762}1762}
17631763
1764test {1764test {
lib/std/macho.zig+1-1
...@@ -825,7 +825,7 @@ pub const section_64 = extern struct {...@@ -825,7 +825,7 @@ pub const section_64 = extern struct {
825};825};
826826
827fn parseName(name: *const [16]u8) []const u8 {827fn parseName(name: *const [16]u8) []const u8 {
828 const len = mem.indexOfScalar(u8, name, @as(u8, 0)) orelse name.len;828 const len = mem.findScalar(u8, name, @as(u8, 0)) orelse name.len;
829 return name[0..len];829 return name[0..len];
830}830}
831831
lib/std/math/big/int.zig+2-2
...@@ -1694,8 +1694,8 @@ pub const Mutable = struct {...@@ -1694,8 +1694,8 @@ pub const Mutable = struct {
1694 // Handle trailing zero-words of divisor/dividend. These are not handled in the following1694 // Handle trailing zero-words of divisor/dividend. These are not handled in the following
1695 // algorithms.1695 // algorithms.
1696 // Note, there must be a non-zero limb for either.1696 // Note, there must be a non-zero limb for either.
1697 // const x_trailing = std.mem.indexOfScalar(Limb, x.limbs[0..x.len], 0).?;1697 // const x_trailing = std.mem.findScalar(Limb, x.limbs[0..x.len], 0).?;
1698 // const y_trailing = std.mem.indexOfScalar(Limb, y.limbs[0..y.len], 0).?;1698 // const y_trailing = std.mem.findScalar(Limb, y.limbs[0..y.len], 0).?;
16991699
1700 const x_trailing = for (x.limbs[0..x.len], 0..) |xi, i| {1700 const x_trailing = for (x.limbs[0..x.len], 0..) |xi, i| {
1701 if (xi != 0) break i;1701 if (xi != 0) break i;
lib/std/mem.zig+44-44
...@@ -998,7 +998,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {...@@ -998,7 +998,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
998 .array => |array_info| {998 .array => |array_info| {
999 if (array_info.sentinel()) |s| {999 if (array_info.sentinel()) |s| {
1000 if (s == end) {1000 if (s == end) {
1001 return indexOfSentinel(array_info.child, end, ptr);1001 return findSentinel(array_info.child, end, ptr);
1002 }1002 }
1003 }1003 }
1004 return findScalar(array_info.child, ptr, end) orelse array_info.len;1004 return findScalar(array_info.child, ptr, end) orelse array_info.len;
...@@ -1007,7 +1007,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {...@@ -1007,7 +1007,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
1007 },1007 },
1008 .many => if (ptr_info.sentinel()) |s| {1008 .many => if (ptr_info.sentinel()) |s| {
1009 if (s == end) {1009 if (s == end) {
1010 return indexOfSentinel(ptr_info.child, end, ptr);1010 return findSentinel(ptr_info.child, end, ptr);
1011 }1011 }
1012 // We're looking for something other than the sentinel,1012 // We're looking for something other than the sentinel,
1013 // but iterating past the sentinel would be a bug so we need1013 // but iterating past the sentinel would be a bug so we need
...@@ -1018,12 +1018,12 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {...@@ -1018,12 +1018,12 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
1018 },1018 },
1019 .c => {1019 .c => {
1020 assert(ptr != null);1020 assert(ptr != null);
1021 return indexOfSentinel(ptr_info.child, end, ptr);1021 return findSentinel(ptr_info.child, end, ptr);
1022 },1022 },
1023 .slice => {1023 .slice => {
1024 if (ptr_info.sentinel()) |s| {1024 if (ptr_info.sentinel()) |s| {
1025 if (s == end) {1025 if (s == end) {
1026 return indexOfSentinel(ptr_info.child, s, ptr);1026 return findSentinel(ptr_info.child, s, ptr);
1027 }1027 }
1028 }1028 }
1029 return findScalar(ptr_info.child, ptr, end) orelse ptr.len;1029 return findScalar(ptr_info.child, ptr, end) orelse ptr.len;
...@@ -1076,11 +1076,11 @@ pub fn len(value: anytype) usize {...@@ -1076,11 +1076,11 @@ pub fn len(value: anytype) usize {
1076 .many => {1076 .many => {
1077 const sentinel = info.sentinel() orelse1077 const sentinel = info.sentinel() orelse
1078 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));1078 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
1079 return indexOfSentinel(info.child, sentinel, value);1079 return findSentinel(info.child, sentinel, value);
1080 },1080 },
1081 .c => {1081 .c => {
1082 assert(value != null);1082 assert(value != null);
1083 return indexOfSentinel(info.child, 0, value);1083 return findSentinel(info.child, 0, value);
1084 },1084 },
1085 else => @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))),1085 else => @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))),
1086 },1086 },
...@@ -1166,7 +1166,7 @@ pub fn findSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]const...@@ -1166,7 +1166,7 @@ pub fn findSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]const
1166 return i;1166 return i;
1167}1167}
11681168
1169test "indexOfSentinel vector paths" {1169test "findSentinel vector paths" {
1170 const Types = [_]type{ u8, u16, u32, u64 };1170 const Types = [_]type{ u8, u16, u32, u64 };
1171 const allocator = std.testing.allocator;1171 const allocator = std.testing.allocator;
1172 const page_size = std.heap.page_size_min;1172 const page_size = std.heap.page_size_min;
...@@ -1189,7 +1189,7 @@ test "indexOfSentinel vector paths" {...@@ -1189,7 +1189,7 @@ test "indexOfSentinel vector paths" {
1189 const search_len = page_size / @sizeOf(T);1189 const search_len = page_size / @sizeOf(T);
1190 memory[start + search_len] = 0;1190 memory[start + search_len] = 0;
1191 for (0..block_len) |offset| {1191 for (0..block_len) |offset| {
1192 try testing.expectEqual(search_len - offset, indexOfSentinel(T, 0, @ptrCast(&memory[start + offset])));1192 try testing.expectEqual(search_len - offset, findSentinel(T, 0, @ptrCast(&memory[start + offset])));
1193 }1193 }
1194 memory[start + search_len] = 0xaa;1194 memory[start + search_len] = 0xaa;
11951195
...@@ -1197,7 +1197,7 @@ test "indexOfSentinel vector paths" {...@@ -1197,7 +1197,7 @@ test "indexOfSentinel vector paths" {
1197 const start_page_boundary = start + (page_size / @sizeOf(T));1197 const start_page_boundary = start + (page_size / @sizeOf(T));
1198 memory[start_page_boundary + block_len] = 0;1198 memory[start_page_boundary + block_len] = 0;
1199 for (0..block_len) |offset| {1199 for (0..block_len) |offset| {
1200 try testing.expectEqual(2 * block_len - offset, indexOfSentinel(T, 0, @ptrCast(&memory[start_page_boundary - block_len + offset])));1200 try testing.expectEqual(2 * block_len - offset, findSentinel(T, 0, @ptrCast(&memory[start_page_boundary - block_len + offset])));
1201 }1201 }
1202 }1202 }
1203}1203}
...@@ -1251,7 +1251,7 @@ pub const indexOfScalar = findScalar;...@@ -1251,7 +1251,7 @@ pub const indexOfScalar = findScalar;
12511251
1252/// Linear search for the index of a scalar value inside a slice.1252/// Linear search for the index of a scalar value inside a slice.
1253pub fn findScalar(comptime T: type, slice: []const T, value: T) ?usize {1253pub fn findScalar(comptime T: type, slice: []const T, value: T) ?usize {
1254 return indexOfScalarPos(T, slice, 0, value);1254 return findScalarPos(T, slice, 0, value);
1255}1255}
12561256
1257/// Deprecated in favor of `findScalarLast`.1257/// Deprecated in favor of `findScalarLast`.
...@@ -1334,7 +1334,7 @@ pub fn findScalarPos(comptime T: type, slice: []const T, start_index: usize, val...@@ -1334,7 +1334,7 @@ pub fn findScalarPos(comptime T: type, slice: []const T, start_index: usize, val
1334 return null;1334 return null;
1335}1335}
13361336
1337test indexOfScalarPos {1337test findScalarPos {
1338 const Types = [_]type{ u8, u16, u32, u64 };1338 const Types = [_]type{ u8, u16, u32, u64 };
13391339
1340 inline for (Types) |T| {1340 inline for (Types) |T| {
...@@ -1343,7 +1343,7 @@ test indexOfScalarPos {...@@ -1343,7 +1343,7 @@ test indexOfScalarPos {
1343 memory[memory.len - 1] = 0;1343 memory[memory.len - 1] = 0;
13441344
1345 for (0..memory.len) |i| {1345 for (0..memory.len) |i| {
1346 try testing.expectEqual(memory.len - i - 1, indexOfScalarPos(T, memory[i..], 0, 0).?);1346 try testing.expectEqual(memory.len - i - 1, findScalarPos(T, memory[i..], 0, 0).?);
1347 }1347 }
1348 }1348 }
1349}1349}
...@@ -1354,7 +1354,7 @@ pub const indexOfAny = findAny;...@@ -1354,7 +1354,7 @@ pub const indexOfAny = findAny;
1354/// Linear search for the index of any value in the provided list inside a slice.1354/// Linear search for the index of any value in the provided list inside a slice.
1355/// Returns null if no values are found.1355/// Returns null if no values are found.
1356pub fn findAny(comptime T: type, slice: []const T, values: []const T) ?usize {1356pub fn findAny(comptime T: type, slice: []const T, values: []const T) ?usize {
1357 return indexOfAnyPos(T, slice, 0, values);1357 return findAnyPos(T, slice, 0, values);
1358}1358}
13591359
1360/// Deprecated in favor of `findLastAny`.1360/// Deprecated in favor of `findLastAny`.
...@@ -1395,7 +1395,7 @@ pub const indexOfNone = findNone;...@@ -1395,7 +1395,7 @@ pub const indexOfNone = findNone;
1395///1395///
1396/// Comparable to `strspn` in the C standard library.1396/// Comparable to `strspn` in the C standard library.
1397pub fn findNone(comptime T: type, slice: []const T, values: []const T) ?usize {1397pub fn findNone(comptime T: type, slice: []const T, values: []const T) ?usize {
1398 return indexOfNonePos(T, slice, 0, values);1398 return findNonePos(T, slice, 0, values);
1399}1399}
14001400
1401test findNone {1401test findNone {
...@@ -1406,7 +1406,7 @@ test findNone {...@@ -1406,7 +1406,7 @@ test findNone {
1406 try testing.expect(findNone(u8, "123123", "123") == null);1406 try testing.expect(findNone(u8, "123123", "123") == null);
1407 try testing.expect(findNone(u8, "333333", "123") == null);1407 try testing.expect(findNone(u8, "333333", "123") == null);
14081408
1409 try testing.expect(indexOfNonePos(u8, "abc123", 3, "321") == null);1409 try testing.expect(findNonePos(u8, "abc123", 3, "321") == null);
1410}1410}
14111411
1412/// Deprecated in favor of `findLastNone`.1412/// Deprecated in favor of `findLastNone`.
...@@ -1451,7 +1451,7 @@ pub const indexOf = find;...@@ -1451,7 +1451,7 @@ pub const indexOf = find;
1451/// Uses Boyer-Moore-Horspool algorithm on large inputs; linear search on small inputs.1451/// Uses Boyer-Moore-Horspool algorithm on large inputs; linear search on small inputs.
1452/// Returns null if needle is not found.1452/// Returns null if needle is not found.
1453pub fn find(comptime T: type, haystack: []const T, needle: []const T) ?usize {1453pub fn find(comptime T: type, haystack: []const T, needle: []const T) ?usize {
1454 return indexOfPos(T, haystack, 0, needle);1454 return findPos(T, haystack, 0, needle);
1455}1455}
14561456
1457/// Deprecated in favor of `findLastLinear`.1457/// Deprecated in favor of `findLastLinear`.
...@@ -1472,7 +1472,7 @@ pub fn findLastLinear(comptime T: type, haystack: []const T, needle: []const T)...@@ -1472,7 +1472,7 @@ pub fn findLastLinear(comptime T: type, haystack: []const T, needle: []const T)
14721472
1473pub const indexOfPosLinear = findPosLinear;1473pub const indexOfPosLinear = findPosLinear;
14741474
1475/// Consider using `indexOfPos` instead of this, which will automatically use a1475/// Consider using `findPos` instead of this, which will automatically use a
1476/// more sophisticated algorithm on larger inputs.1476/// more sophisticated algorithm on larger inputs.
1477pub fn findPosLinear(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize {1477pub fn findPosLinear(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize {
1478 if (needle.len > haystack.len) return null;1478 if (needle.len > haystack.len) return null;
...@@ -1566,17 +1566,17 @@ pub fn findLast(comptime T: type, haystack: []const T, needle: []const T) ?usize...@@ -1566,17 +1566,17 @@ pub fn findLast(comptime T: type, haystack: []const T, needle: []const T) ?usize
1566/// Deprecated in favor of `findPos`.1566/// Deprecated in favor of `findPos`.
1567pub const indexOfPos = findPos;1567pub const indexOfPos = findPos;
15681568
1569/// Uses Boyer-Moore-Horspool algorithm on large inputs; `indexOfPosLinear` on small inputs.1569/// Uses Boyer-Moore-Horspool algorithm on large inputs; `findPosLinear` on small inputs.
1570pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize {1570pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize {
1571 if (needle.len > haystack.len) return null;1571 if (needle.len > haystack.len) return null;
1572 if (needle.len < 2) {1572 if (needle.len < 2) {
1573 if (needle.len == 0) return start_index;1573 if (needle.len == 0) return start_index;
1574 // indexOfScalarPos is significantly faster than indexOfPosLinear1574 // findScalarPos is significantly faster than findPosLinear
1575 return indexOfScalarPos(T, haystack, start_index, needle[0]);1575 return findScalarPos(T, haystack, start_index, needle[0]);
1576 }1576 }
15771577
1578 if (!std.meta.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4)1578 if (!std.meta.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4)
1579 return indexOfPosLinear(T, haystack, start_index, needle);1579 return findPosLinear(T, haystack, start_index, needle);
15801580
1581 const haystack_bytes = sliceAsBytes(haystack);1581 const haystack_bytes = sliceAsBytes(haystack);
1582 const needle_bytes = sliceAsBytes(needle);1582 const needle_bytes = sliceAsBytes(needle);
...@@ -1595,43 +1595,43 @@ pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle...@@ -1595,43 +1595,43 @@ pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle
1595 return null;1595 return null;
1596}1596}
15971597
1598test indexOf {1598test find {
1599 try testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);1599 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
1600 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);1600 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
1601 try testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);1601 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
1602 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);1602 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
16031603
1604 try testing.expect(indexOf(u8, "one two three four five six seven eight nine ten", "").? == 0);1604 try testing.expect(find(u8, "one two three four five six seven eight nine ten", "").? == 0);
1605 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48);1605 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48);
16061606
1607 try testing.expect(indexOf(u8, "one two three four", "four").? == 14);1607 try testing.expect(find(u8, "one two three four", "four").? == 14);
1608 try testing.expect(lastIndexOf(u8, "one two three two four", "two").? == 14);1608 try testing.expect(lastIndexOf(u8, "one two three two four", "two").? == 14);
1609 try testing.expect(indexOf(u8, "one two three four", "gour") == null);1609 try testing.expect(find(u8, "one two three four", "gour") == null);
1610 try testing.expect(lastIndexOf(u8, "one two three four", "gour") == null);1610 try testing.expect(lastIndexOf(u8, "one two three four", "gour") == null);
1611 try testing.expect(indexOf(u8, "foo", "foo").? == 0);1611 try testing.expect(find(u8, "foo", "foo").? == 0);
1612 try testing.expect(lastIndexOf(u8, "foo", "foo").? == 0);1612 try testing.expect(lastIndexOf(u8, "foo", "foo").? == 0);
1613 try testing.expect(indexOf(u8, "foo", "fool") == null);1613 try testing.expect(find(u8, "foo", "fool") == null);
1614 try testing.expect(lastIndexOf(u8, "foo", "lfoo") == null);1614 try testing.expect(lastIndexOf(u8, "foo", "lfoo") == null);
1615 try testing.expect(lastIndexOf(u8, "foo", "fool") == null);1615 try testing.expect(lastIndexOf(u8, "foo", "fool") == null);
16161616
1617 try testing.expect(indexOf(u8, "foo foo", "foo").? == 0);1617 try testing.expect(find(u8, "foo foo", "foo").? == 0);
1618 try testing.expect(lastIndexOf(u8, "foo foo", "foo").? == 4);1618 try testing.expect(lastIndexOf(u8, "foo foo", "foo").? == 4);
1619 try testing.expect(lastIndexOfAny(u8, "boo, cat", "abo").? == 6);1619 try testing.expect(lastIndexOfAny(u8, "boo, cat", "abo").? == 6);
1620 try testing.expect(findScalarLast(u8, "boo", 'o').? == 2);1620 try testing.expect(findScalarLast(u8, "boo", 'o').? == 2);
1621}1621}
16221622
1623test "indexOf multibyte" {1623test "find multibyte" {
1624 {1624 {
1625 // make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm1625 // make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
1626 const haystack = [1]u16{0} ** 100 ++ [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff };1626 const haystack = [1]u16{0} ** 100 ++ [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff };
1627 const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };1627 const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
1628 try testing.expectEqual(indexOfPos(u16, &haystack, 0, &needle), 100);1628 try testing.expectEqual(findPos(u16, &haystack, 0, &needle), 100);
16291629
1630 // check for misaligned false positives (little and big endian)1630 // check for misaligned false positives (little and big endian)
1631 const needleLE = [_]u16{ 0xbbbb, 0xcccc, 0xdddd, 0xeeee, 0xffff };1631 const needleLE = [_]u16{ 0xbbbb, 0xcccc, 0xdddd, 0xeeee, 0xffff };
1632 try testing.expectEqual(indexOfPos(u16, &haystack, 0, &needleLE), null);1632 try testing.expectEqual(findPos(u16, &haystack, 0, &needleLE), null);
1633 const needleBE = [_]u16{ 0xaacc, 0xbbdd, 0xccee, 0xddff, 0xee00 };1633 const needleBE = [_]u16{ 0xaacc, 0xbbdd, 0xccee, 0xddff, 0xee00 };
1634 try testing.expectEqual(indexOfPos(u16, &haystack, 0, &needleBE), null);1634 try testing.expectEqual(findPos(u16, &haystack, 0, &needleBE), null);
1635 }1635 }
16361636
1637 {1637 {
...@@ -1648,8 +1648,8 @@ test "indexOf multibyte" {...@@ -1648,8 +1648,8 @@ test "indexOf multibyte" {
1648 }1648 }
1649}1649}
16501650
1651test "indexOfPos empty needle" {1651test "findPos empty needle" {
1652 try testing.expectEqual(indexOfPos(u8, "abracadabra", 5, ""), 5);1652 try testing.expectEqual(findPos(u8, "abracadabra", 5, ""), 5);
1653}1653}
16541654
1655/// Returns the number of needles inside the haystack1655/// Returns the number of needles inside the haystack
...@@ -1661,7 +1661,7 @@ pub fn count(comptime T: type, haystack: []const T, needle: []const T) usize {...@@ -1661,7 +1661,7 @@ pub fn count(comptime T: type, haystack: []const T, needle: []const T) usize {
1661 var i: usize = 0;1661 var i: usize = 0;
1662 var found: usize = 0;1662 var found: usize = 0;
16631663
1664 while (indexOfPos(T, haystack, i, needle)) |idx| {1664 while (findPos(T, haystack, i, needle)) |idx| {
1665 i = idx + needle.len;1665 i = idx + needle.len;
1666 found += 1;1666 found += 1;
1667 }1667 }
...@@ -1731,7 +1731,7 @@ pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: us...@@ -1731,7 +1731,7 @@ pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: us
1731 var i: usize = 0;1731 var i: usize = 0;
1732 var found: usize = 0;1732 var found: usize = 0;
17331733
1734 while (indexOfPos(T, haystack, i, needle)) |idx| {1734 while (findPos(T, haystack, i, needle)) |idx| {
1735 i = idx + needle.len;1735 i = idx + needle.len;
1736 found += 1;1736 found += 1;
1737 if (found == expected_count) return true;1737 if (found == expected_count) return true;
...@@ -3356,9 +3356,9 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -3356,9 +3356,9 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
3356 pub fn next(self: *Self) ?[]const T {3356 pub fn next(self: *Self) ?[]const T {
3357 const start = self.index orelse return null;3357 const start = self.index orelse return null;
3358 const end = if (switch (delimiter_type) {3358 const end = if (switch (delimiter_type) {
3359 .sequence => indexOfPos(T, self.buffer, start, self.delimiter),3359 .sequence => findPos(T, self.buffer, start, self.delimiter),
3360 .any => indexOfAnyPos(T, self.buffer, start, self.delimiter),3360 .any => findAnyPos(T, self.buffer, start, self.delimiter),
3361 .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),3361 .scalar => findScalarPos(T, self.buffer, start, self.delimiter),
3362 }) |delim_start| blk: {3362 }) |delim_start| blk: {
3363 self.index = delim_start + switch (delimiter_type) {3363 self.index = delim_start + switch (delimiter_type) {
3364 .sequence => self.delimiter.len,3364 .sequence => self.delimiter.len,
...@@ -3377,9 +3377,9 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -3377,9 +3377,9 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
3377 pub fn peek(self: *Self) ?[]const T {3377 pub fn peek(self: *Self) ?[]const T {
3378 const start = self.index orelse return null;3378 const start = self.index orelse return null;
3379 const end = if (switch (delimiter_type) {3379 const end = if (switch (delimiter_type) {
3380 .sequence => indexOfPos(T, self.buffer, start, self.delimiter),3380 .sequence => findPos(T, self.buffer, start, self.delimiter),
3381 .any => indexOfAnyPos(T, self.buffer, start, self.delimiter),3381 .any => findAnyPos(T, self.buffer, start, self.delimiter),
3382 .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),3382 .scalar => findScalarPos(T, self.buffer, start, self.delimiter),
3383 }) |delim_start| delim_start else self.buffer.len;3383 }) |delim_start| delim_start else self.buffer.len;
3384 return self.buffer[start..end];3384 return self.buffer[start..end];
3385 }3385 }
lib/std/os.zig+4-4
...@@ -113,7 +113,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix....@@ -113,7 +113,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.
113 // errno values to expect when command is F.GETPATH...113 // errno values to expect when command is F.GETPATH...
114 else => |err| return posix.unexpectedErrno(err),114 else => |err| return posix.unexpectedErrno(err),
115 }115 }
116 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;116 const len = mem.findScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
117 return out_buffer[0..len];117 return out_buffer[0..len];
118 },118 },
119 .linux, .serenity => {119 .linux, .serenity => {
...@@ -150,7 +150,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix....@@ -150,7 +150,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.
150 .BADF => return error.FileNotFound,150 .BADF => return error.FileNotFound,
151 else => |err| return posix.unexpectedErrno(err),151 else => |err| return posix.unexpectedErrno(err),
152 }152 }
153 const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes;153 const len = mem.findScalar(u8, &kfile.path, 0) orelse max_path_bytes;
154 if (len == 0) return error.NameTooLong;154 if (len == 0) return error.NameTooLong;
155 const result = out_buffer[0..len];155 const result = out_buffer[0..len];
156 @memcpy(result, kfile.path[0..len]);156 @memcpy(result, kfile.path[0..len]);
...@@ -164,7 +164,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix....@@ -164,7 +164,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.
164 .RANGE => return error.NameTooLong,164 .RANGE => return error.NameTooLong,
165 else => |err| return posix.unexpectedErrno(err),165 else => |err| return posix.unexpectedErrno(err),
166 }166 }
167 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;167 const len = mem.findScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
168 return out_buffer[0..len];168 return out_buffer[0..len];
169 },169 },
170 .netbsd => {170 .netbsd => {
...@@ -178,7 +178,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix....@@ -178,7 +178,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.
178 .RANGE => return error.NameTooLong,178 .RANGE => return error.NameTooLong,
179 else => |err| return posix.unexpectedErrno(err),179 else => |err| return posix.unexpectedErrno(err),
180 }180 }
181 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;181 const len = mem.findScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
182 return out_buffer[0..len];182 return out_buffer[0..len];
183 },183 },
184 else => unreachable, // made unreachable by isGetFdPathSupportedOnTarget above184 else => unreachable, // made unreachable by isGetFdPathSupportedOnTarget above
lib/std/os/linux/IoUring.zig+1-1
...@@ -4092,7 +4092,7 @@ inline fn skipKernelLessThan(required: std.SemanticVersion) !void {...@@ -4092,7 +4092,7 @@ inline fn skipKernelLessThan(required: std.SemanticVersion) !void {
40924092
4093 const release = mem.sliceTo(&uts.release, 0);4093 const release = mem.sliceTo(&uts.release, 0);
4094 // Strips potential extra, as kernel version might not be semver compliant, example "6.8.9-300.fc40.x86_64"4094 // Strips potential extra, as kernel version might not be semver compliant, example "6.8.9-300.fc40.x86_64"
4095 const extra_index = std.mem.indexOfAny(u8, release, "-+");4095 const extra_index = std.mem.findAny(u8, release, "-+");
4096 const stripped = release[0..(extra_index orelse release.len)];4096 const stripped = release[0..(extra_index orelse release.len)];
4097 // Make sure the input don't rely on the extra we just stripped4097 // Make sure the input don't rely on the extra we just stripped
4098 try testing.expect(required.pre == null and required.build == null);4098 try testing.expect(required.pre == null and required.build == null);
lib/std/os/windows.zig+3-3
...@@ -3661,7 +3661,7 @@ pub fn GetFinalPathNameByHandle(...@@ -3661,7 +3661,7 @@ pub fn GetFinalPathNameByHandle(
3661 };3661 };
3662 }3662 }
36633663
3664 const file_path_begin_index = mem.indexOfPos(u16, final_path, device_prefix.len, &[_]u16{'\\'}) orelse unreachable;3664 const file_path_begin_index = mem.findPos(u16, final_path, device_prefix.len, &[_]u16{'\\'}) orelse unreachable;
3665 const volume_name_u16 = final_path[0..file_path_begin_index];3665 const volume_name_u16 = final_path[0..file_path_begin_index];
3666 const device_name_u16 = volume_name_u16[device_prefix.len..];3666 const device_name_u16 = volume_name_u16[device_prefix.len..];
3667 const file_name_u16 = final_path[file_path_begin_index..];3667 const file_name_u16 = final_path[file_path_begin_index..];
...@@ -3746,7 +3746,7 @@ pub fn GetFinalPathNameByHandle(...@@ -3746,7 +3746,7 @@ pub fn GetFinalPathNameByHandle(
3746 const total_len = drive_letter.len + file_name_u16.len;3746 const total_len = drive_letter.len + file_name_u16.len;
37473747
3748 // Validate that DOS does not contain any spurious nul bytes.3748 // Validate that DOS does not contain any spurious nul bytes.
3749 if (mem.indexOfScalar(u16, out_buffer[0..total_len], 0)) |_| {3749 if (mem.findScalar(u16, out_buffer[0..total_len], 0)) |_| {
3750 return error.BadPathName;3750 return error.BadPathName;
3751 }3751 }
37523752
...@@ -3798,7 +3798,7 @@ pub fn GetFinalPathNameByHandle(...@@ -3798,7 +3798,7 @@ pub fn GetFinalPathNameByHandle(
3798 const total_len = volume_path.len + file_name_u16.len;3798 const total_len = volume_path.len + file_name_u16.len;
37993799
3800 // Validate that DOS does not contain any spurious nul bytes.3800 // Validate that DOS does not contain any spurious nul bytes.
3801 if (mem.indexOfScalar(u16, out_buffer[0..total_len], 0)) |_| {3801 if (mem.findScalar(u16, out_buffer[0..total_len], 0)) |_| {
3802 return error.BadPathName;3802 return error.BadPathName;
3803 }3803 }
38043804
lib/std/posix.zig+3-3
...@@ -1788,7 +1788,7 @@ pub fn execvpeZ_expandArg0(...@@ -1788,7 +1788,7 @@ pub fn execvpeZ_expandArg0(
1788 envp: [*:null]const ?[*:0]const u8,1788 envp: [*:null]const ?[*:0]const u8,
1789) ExecveError {1789) ExecveError {
1790 const file_slice = mem.sliceTo(file, 0);1790 const file_slice = mem.sliceTo(file, 0);
1791 if (mem.indexOfScalar(u8, file_slice, '/') != null) return execveZ(file, child_argv, envp);1791 if (mem.findScalar(u8, file_slice, '/') != null) return execveZ(file, child_argv, envp);
17921792
1793 const PATH = getenvZ("PATH") orelse "/usr/local/bin:/bin/:/usr/bin";1793 const PATH = getenvZ("PATH") orelse "/usr/local/bin:/bin/:/usr/bin";
1794 // Use of PATH_MAX here is valid as the path_buf will be passed1794 // Use of PATH_MAX here is valid as the path_buf will be passed
...@@ -1844,7 +1844,7 @@ pub fn getenv(key: []const u8) ?[:0]const u8 {...@@ -1844,7 +1844,7 @@ pub fn getenv(key: []const u8) ?[:0]const u8 {
1844 if (native_os == .windows) {1844 if (native_os == .windows) {
1845 @compileError("std.posix.getenv is unavailable for Windows because environment strings are in WTF-16 format. See std.process.getEnvVarOwned for a cross-platform API or std.process.getenvW for a Windows-specific API.");1845 @compileError("std.posix.getenv is unavailable for Windows because environment strings are in WTF-16 format. See std.process.getEnvVarOwned for a cross-platform API or std.process.getenvW for a Windows-specific API.");
1846 }1846 }
1847 if (mem.indexOfScalar(u8, key, '=') != null) {1847 if (mem.findScalar(u8, key, '=') != null) {
1848 return null;1848 return null;
1849 }1849 }
1850 if (builtin.link_libc) {1850 if (builtin.link_libc) {
...@@ -6676,7 +6676,7 @@ pub fn unexpectedErrno(err: E) UnexpectedError {...@@ -6676,7 +6676,7 @@ pub fn unexpectedErrno(err: E) UnexpectedError {
66766676
6677/// Used to convert a slice to a null terminated slice on the stack.6677/// Used to convert a slice to a null terminated slice on the stack.
6678pub fn toPosixPath(file_path: []const u8) error{NameTooLong}![PATH_MAX - 1:0]u8 {6678pub fn toPosixPath(file_path: []const u8) error{NameTooLong}![PATH_MAX - 1:0]u8 {
6679 if (std.debug.runtime_safety) assert(mem.indexOfScalar(u8, file_path, 0) == null);6679 if (std.debug.runtime_safety) assert(mem.findScalar(u8, file_path, 0) == null);
6680 var path_with_null: [PATH_MAX - 1:0]u8 = undefined;6680 var path_with_null: [PATH_MAX - 1:0]u8 = undefined;
6681 // >= rather than > to make room for the null byte6681 // >= rather than > to make room for the null byte
6682 if (file_path.len >= PATH_MAX) return error.NameTooLong;6682 if (file_path.len >= PATH_MAX) return error.NameTooLong;
lib/std/priority_queue.zig+1-1
...@@ -619,7 +619,7 @@ test "siftUp in remove" {...@@ -619,7 +619,7 @@ test "siftUp in remove" {
619619
620 try queue.addSlice(&.{ 0, 1, 100, 2, 3, 101, 102, 4, 5, 6, 7, 103, 104, 105, 106, 8 });620 try queue.addSlice(&.{ 0, 1, 100, 2, 3, 101, 102, 4, 5, 6, 7, 103, 104, 105, 106, 8 });
621621
622 _ = queue.removeIndex(std.mem.indexOfScalar(u32, queue.items[0..queue.count()], 102).?);622 _ = queue.removeIndex(std.mem.findScalar(u32, queue.items[0..queue.count()], 102).?);
623623
624 const sorted_items = [_]u32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 100, 101, 103, 104, 105, 106 };624 const sorted_items = [_]u32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 100, 101, 103, 104, 105, 106 };
625 for (sorted_items) |e| {625 for (sorted_items) |e| {
lib/std/process.zig+2-2
...@@ -546,7 +546,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {...@@ -546,7 +546,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {
546 }546 }
547 const key_slice = mem.sliceTo(key, 0);547 const key_slice = mem.sliceTo(key, 0);
548 // '=' anywhere but the start makes this an invalid environment variable name548 // '=' anywhere but the start makes this an invalid environment variable name
549 if (key_slice.len > 0 and std.mem.indexOfScalar(u16, key_slice[1..], '=') != null) {549 if (key_slice.len > 0 and std.mem.findScalar(u16, key_slice[1..], '=') != null) {
550 return null;550 return null;
551 }551 }
552 const ptr = windows.peb().ProcessParameters.Environment;552 const ptr = windows.peb().ProcessParameters.Environment;
...@@ -559,7 +559,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {...@@ -559,7 +559,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {
559 // if it's the first character.559 // if it's the first character.
560 // https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133560 // https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133
561 const equal_search_start: usize = if (key_value[0] == '=') 1 else 0;561 const equal_search_start: usize = if (key_value[0] == '=') 1 else 0;
562 const equal_index = std.mem.indexOfScalarPos(u16, key_value, equal_search_start, '=') orelse {562 const equal_index = std.mem.findScalarPos(u16, key_value, equal_search_start, '=') orelse {
563 // This is enforced by CreateProcess.563 // This is enforced by CreateProcess.
564 // If violated, CreateProcess will fail with INVALID_PARAMETER.564 // If violated, CreateProcess will fail with INVALID_PARAMETER.
565 unreachable; // must contain a =565 unreachable; // must contain a =
lib/std/process/Child.zig+2-2
...@@ -1812,7 +1812,7 @@ fn argvToScriptCommandLineWindows(...@@ -1812,7 +1812,7 @@ fn argvToScriptCommandLineWindows(
1812 //1812 //
1813 // If the script path does not have a path separator, then we know its relative to CWD and1813 // If the script path does not have a path separator, then we know its relative to CWD and
1814 // we can just put `.\` in the front.1814 // we can just put `.\` in the front.
1815 if (mem.indexOfAny(u16, script_path, &[_]u16{ mem.nativeToLittle(u16, '\\'), mem.nativeToLittle(u16, '/') }) == null) {1815 if (mem.findAny(u16, script_path, &[_]u16{ mem.nativeToLittle(u16, '\\'), mem.nativeToLittle(u16, '/') }) == null) {
1816 try buf.appendSlice(".\\");1816 try buf.appendSlice(".\\");
1817 }1817 }
1818 // Note that we don't do any escaping/mitigations for this argument, since the relevant1818 // Note that we don't do any escaping/mitigations for this argument, since the relevant
...@@ -1827,7 +1827,7 @@ fn argvToScriptCommandLineWindows(...@@ -1827,7 +1827,7 @@ fn argvToScriptCommandLineWindows(
1827 // always a mistake to include these characters in argv, so it's1827 // always a mistake to include these characters in argv, so it's
1828 // an error condition in order to ensure that the return of this1828 // an error condition in order to ensure that the return of this
1829 // function can always roundtrip through cmd.exe.1829 // function can always roundtrip through cmd.exe.
1830 if (std.mem.indexOfAny(u8, arg, "\x00\r\n") != null) {1830 if (std.mem.findAny(u8, arg, "\x00\r\n") != null) {
1831 return error.InvalidBatchScriptArg;1831 return error.InvalidBatchScriptArg;
1832 }1832 }
18331833
lib/std/tar.zig+3-3
...@@ -71,7 +71,7 @@ pub const Diagnostics = struct {...@@ -71,7 +71,7 @@ pub const Diagnostics = struct {
71 const start_index: usize = if (path[0] == '/') 1 else 0;71 const start_index: usize = if (path[0] == '/') 1 else 0;
72 const end_index: usize = if (path[path.len - 1] == '/') path.len - 1 else path.len;72 const end_index: usize = if (path[path.len - 1] == '/') path.len - 1 else path.len;
73 const buf = path[start_index..end_index];73 const buf = path[start_index..end_index];
74 if (std.mem.indexOfScalarPos(u8, buf, 0, '/')) |idx| {74 if (std.mem.findScalarPos(u8, buf, 0, '/')) |idx| {
75 return buf[0..idx];75 return buf[0..idx];
76 }76 }
7777
...@@ -569,7 +569,7 @@ pub const PaxIterator = struct {...@@ -569,7 +569,7 @@ pub const PaxIterator = struct {
569 }569 }
570570
571 fn hasNull(str: []const u8) bool {571 fn hasNull(str: []const u8) bool {
572 return (std.mem.indexOfScalar(u8, str, 0)) != null;572 return (std.mem.findScalar(u8, str, 0)) != null;
573 }573 }
574574
575 // Checks that each record ends with new line.575 // Checks that each record ends with new line.
...@@ -667,7 +667,7 @@ fn stripComponents(path: []const u8, count: u32) []const u8 {...@@ -667,7 +667,7 @@ fn stripComponents(path: []const u8, count: u32) []const u8 {
667 var i: usize = 0;667 var i: usize = 0;
668 var c = count;668 var c = count;
669 while (c > 0) : (c -= 1) {669 while (c > 0) : (c -= 1) {
670 if (std.mem.indexOfScalarPos(u8, path, i, '/')) |pos| {670 if (std.mem.findScalarPos(u8, path, i, '/')) |pos| {
671 i = pos + 1;671 i = pos + 1;
672 } else {672 } else {
673 i = path.len;673 i = path.len;
lib/std/testing.zig+3-3
...@@ -643,7 +643,7 @@ pub fn tmpDir(opts: std.fs.Dir.OpenOptions) TmpDir {...@@ -643,7 +643,7 @@ pub fn tmpDir(opts: std.fs.Dir.OpenOptions) TmpDir {
643}643}
644644
645pub fn expectEqualStrings(expected: []const u8, actual: []const u8) !void {645pub fn expectEqualStrings(expected: []const u8, actual: []const u8) !void {
646 if (std.mem.indexOfDiff(u8, actual, expected)) |diff_index| {646 if (std.mem.findDiff(u8, actual, expected)) |diff_index| {
647 if (@inComptime()) {647 if (@inComptime()) {
648 @compileError(std.fmt.comptimePrint("\nexpected:\n{s}\nfound:\n{s}\ndifference starts at index {d}", .{648 @compileError(std.fmt.comptimePrint("\nexpected:\n{s}\nfound:\n{s}\ndifference starts at index {d}", .{
649 expected, actual, diff_index,649 expected, actual, diff_index,
...@@ -992,7 +992,7 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void {...@@ -992,7 +992,7 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void {
992 line_begin + 1992 line_begin + 1
993 else993 else
994 0;994 0;
995 const line_end_index = if (std.mem.indexOfScalar(u8, source[indicator_index..], '\n')) |line_end|995 const line_end_index = if (std.mem.findScalar(u8, source[indicator_index..], '\n')) |line_end|
996 (indicator_index + line_end)996 (indicator_index + line_end)
997 else997 else
998 source.len;998 source.len;
...@@ -1008,7 +1008,7 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void {...@@ -1008,7 +1008,7 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void {
10081008
1009fn printWithVisibleNewlines(source: []const u8) void {1009fn printWithVisibleNewlines(source: []const u8) void {
1010 var i: usize = 0;1010 var i: usize = 0;
1011 while (std.mem.indexOfScalar(u8, source[i..], '\n')) |nl| : (i += nl + 1) {1011 while (std.mem.findScalar(u8, source[i..], '\n')) |nl| : (i += nl + 1) {
1012 printLine(source[i..][0..nl]);1012 printLine(source[i..][0..nl]);
1013 }1013 }
1014 print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX)1014 print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX)
lib/std/zig/Ast.zig+2-2
...@@ -234,7 +234,7 @@ pub fn tokenLocation(self: Ast, start_offset: ByteOffset, token_index: TokenInde...@@ -234,7 +234,7 @@ pub fn tokenLocation(self: Ast, start_offset: ByteOffset, token_index: TokenInde
234 const token_start = self.tokenStart(token_index);234 const token_start = self.tokenStart(token_index);
235235
236 // Scan to by line until we go past the token start236 // Scan to by line until we go past the token start
237 while (std.mem.indexOfScalarPos(u8, self.source, loc.line_start, '\n')) |i| {237 while (std.mem.findScalarPos(u8, self.source, loc.line_start, '\n')) |i| {
238 if (i >= token_start) {238 if (i >= token_start) {
239 break; // Went past239 break; // Went past
240 }240 }
...@@ -1309,7 +1309,7 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {...@@ -1309,7 +1309,7 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
13091309
1310pub fn tokensOnSameLine(tree: Ast, token1: TokenIndex, token2: TokenIndex) bool {1310pub fn tokensOnSameLine(tree: Ast, token1: TokenIndex, token2: TokenIndex) bool {
1311 const source = tree.source[tree.tokenStart(token1)..tree.tokenStart(token2)];1311 const source = tree.source[tree.tokenStart(token1)..tree.tokenStart(token2)];
1312 return mem.indexOfScalar(u8, source, '\n') == null;1312 return mem.findScalar(u8, source, '\n') == null;
1313}1313}
13141314
1315pub fn getNodeSource(tree: Ast, node: Node.Index) []const u8 {1315pub fn getNodeSource(tree: Ast, node: Node.Index) []const u8 {
lib/std/zig/Ast/Render.zig+9-9
...@@ -1417,7 +1417,7 @@ fn renderFor(r: *Render, for_node: Ast.full.For, space: Space) Error!void {...@@ -1417,7 +1417,7 @@ fn renderFor(r: *Render, for_node: Ast.full.For, space: Space) Error!void {
1417 try renderParamList(r, lparen, for_node.ast.inputs, .space);1417 try renderParamList(r, lparen, for_node.ast.inputs, .space);
14181418
1419 var cur = for_node.payload_token;1419 var cur = for_node.payload_token;
1420 const pipe = std.mem.indexOfScalarPos(std.zig.Token.Tag, token_tags, cur, .pipe).?;1420 const pipe = std.mem.findScalarPos(std.zig.Token.Tag, token_tags, cur, .pipe).?;
1421 if (tree.tokenTag(@intCast(pipe - 1)) == .comma) {1421 if (tree.tokenTag(@intCast(pipe - 1)) == .comma) {
1422 try ais.pushIndent(.normal);1422 try ais.pushIndent(.normal);
1423 try renderToken(r, cur - 1, .newline); // |1423 try renderToken(r, cur - 1, .newline); // |
...@@ -2194,7 +2194,7 @@ fn renderArrayInit(...@@ -2194,7 +2194,7 @@ fn renderArrayInit(
2194 try renderExpression(&sub_render, expr, .none);2194 try renderExpression(&sub_render, expr, .none);
2195 const written = sub_expr_buffer.written();2195 const written = sub_expr_buffer.written();
2196 const width = written.len - start;2196 const width = written.len - start;
2197 const this_contains_newline = mem.indexOfScalar(u8, written[start..], '\n') != null;2197 const this_contains_newline = mem.findScalar(u8, written[start..], '\n') != null;
2198 contains_newline = contains_newline or this_contains_newline;2198 contains_newline = contains_newline or this_contains_newline;
2199 expr_widths[i] = width;2199 expr_widths[i] = width;
2200 expr_newlines[i] = this_contains_newline;2200 expr_newlines[i] = this_contains_newline;
...@@ -2218,7 +2218,7 @@ fn renderArrayInit(...@@ -2218,7 +2218,7 @@ fn renderArrayInit(
22182218
2219 const written = sub_expr_buffer.written();2219 const written = sub_expr_buffer.written();
2220 const width = written.len - start - 2;2220 const width = written.len - start - 2;
2221 const this_contains_newline = mem.indexOfScalar(u8, written[start .. written.len - 1], '\n') != null;2221 const this_contains_newline = mem.findScalar(u8, written[start .. written.len - 1], '\n') != null;
2222 contains_newline = contains_newline or this_contains_newline;2222 contains_newline = contains_newline or this_contains_newline;
2223 expr_widths[i] = width;2223 expr_widths[i] = width;
2224 expr_newlines[i] = contains_newline;2224 expr_newlines[i] = contains_newline;
...@@ -2910,7 +2910,7 @@ fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex)...@@ -2910,7 +2910,7 @@ fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex)
2910 const token: Ast.TokenIndex = @intCast(i);2910 const token: Ast.TokenIndex = @intCast(i);
2911 const start = tree.tokenStart(token) + tree.tokenSlice(token).len;2911 const start = tree.tokenStart(token) + tree.tokenSlice(token).len;
2912 const end = tree.tokenStart(token + 1);2912 const end = tree.tokenStart(token + 1);
2913 if (mem.indexOf(u8, tree.source[start..end], "//") != null) return true;2913 if (mem.find(u8, tree.source[start..end], "//") != null) return true;
2914 }2914 }
29152915
2916 return false;2916 return false;
...@@ -2919,7 +2919,7 @@ fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex)...@@ -2919,7 +2919,7 @@ fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex)
2919/// Returns true if there exists a multiline string literal between the start2919/// Returns true if there exists a multiline string literal between the start
2920/// of token `start_token` and the start of token `end_token`.2920/// of token `start_token` and the start of token `end_token`.
2921fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {2921fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
2922 return std.mem.indexOfScalar(2922 return std.mem.findScalar(
2923 Token.Tag,2923 Token.Tag,
2924 tree.tokens.items(.tag)[start_token..end_token],2924 tree.tokens.items(.tag)[start_token..end_token],
2925 .multiline_string_literal_line,2925 .multiline_string_literal_line,
...@@ -2933,11 +2933,11 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {...@@ -2933,11 +2933,11 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {
2933 const ais = r.ais;2933 const ais = r.ais;
29342934
2935 var index: usize = start;2935 var index: usize = start;
2936 while (mem.indexOf(u8, tree.source[index..end], "//")) |offset| {2936 while (mem.find(u8, tree.source[index..end], "//")) |offset| {
2937 const comment_start = index + offset;2937 const comment_start = index + offset;
29382938
2939 // If there is no newline, the comment ends with EOF2939 // If there is no newline, the comment ends with EOF
2940 const newline_index = mem.indexOfScalar(u8, tree.source[comment_start..end], '\n');2940 const newline_index = mem.findScalar(u8, tree.source[comment_start..end], '\n');
2941 const newline = if (newline_index) |i| comment_start + i else null;2941 const newline = if (newline_index) |i| comment_start + i else null;
29422942
2943 const untrimmed_comment = tree.source[comment_start .. newline orelse tree.source.len];2943 const untrimmed_comment = tree.source[comment_start .. newline orelse tree.source.len];
...@@ -2949,7 +2949,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {...@@ -2949,7 +2949,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {
2949 // Leave up to one empty line before the first comment2949 // Leave up to one empty line before the first comment
2950 try ais.insertNewline();2950 try ais.insertNewline();
2951 try ais.insertNewline();2951 try ais.insertNewline();
2952 } else if (mem.indexOfScalar(u8, tree.source[index..comment_start], '\n') != null) {2952 } else if (mem.findScalar(u8, tree.source[index..comment_start], '\n') != null) {
2953 // Respect the newline directly before the comment.2953 // Respect the newline directly before the comment.
2954 // Note: This allows an empty line between comments2954 // Note: This allows an empty line between comments
2955 try ais.insertNewline();2955 try ais.insertNewline();
...@@ -3008,7 +3008,7 @@ fn renderExtraNewlineToken(r: *Render, token_index: Ast.TokenIndex) Error!void {...@@ -3008,7 +3008,7 @@ fn renderExtraNewlineToken(r: *Render, token_index: Ast.TokenIndex) Error!void {
30083008
3009 // If there is a immediately preceding comment or doc_comment,3009 // If there is a immediately preceding comment or doc_comment,
3010 // skip it because required extra newline has already been rendered.3010 // skip it because required extra newline has already been rendered.
3011 if (mem.indexOf(u8, tree.source[prev_token_end..token_start], "//") != null) return;3011 if (mem.find(u8, tree.source[prev_token_end..token_start], "//") != null) return;
3012 if (tree.isTokenPrecededByTags(token_index, &.{.doc_comment})) return;3012 if (tree.isTokenPrecededByTags(token_index, &.{.doc_comment})) return;
30133013
3014 // Iterate backwards to the end of the previous token, stopping if a3014 // Iterate backwards to the end of the previous token, stopping if a
lib/std/zig/AstGen.zig+8-8
...@@ -4124,7 +4124,7 @@ fn fnDecl(...@@ -4124,7 +4124,7 @@ fn fnDecl(
4124 const lib_name = if (fn_proto.lib_name) |lib_name_token| blk: {4124 const lib_name = if (fn_proto.lib_name) |lib_name_token| blk: {
4125 const lib_name_str = try astgen.strLitAsString(lib_name_token);4125 const lib_name_str = try astgen.strLitAsString(lib_name_token);
4126 const lib_name_slice = astgen.string_bytes.items[@intFromEnum(lib_name_str.index)..][0..lib_name_str.len];4126 const lib_name_slice = astgen.string_bytes.items[@intFromEnum(lib_name_str.index)..][0..lib_name_str.len];
4127 if (mem.indexOfScalar(u8, lib_name_slice, 0) != null) {4127 if (mem.findScalar(u8, lib_name_slice, 0) != null) {
4128 return astgen.failTok(lib_name_token, "library name cannot contain null bytes", .{});4128 return astgen.failTok(lib_name_token, "library name cannot contain null bytes", .{});
4129 } else if (lib_name_str.len == 0) {4129 } else if (lib_name_str.len == 0) {
4130 return astgen.failTok(lib_name_token, "library name cannot be empty", .{});4130 return astgen.failTok(lib_name_token, "library name cannot be empty", .{});
...@@ -4540,7 +4540,7 @@ fn globalVarDecl(...@@ -4540,7 +4540,7 @@ fn globalVarDecl(
4540 const lib_name = if (var_decl.lib_name) |lib_name_token| blk: {4540 const lib_name = if (var_decl.lib_name) |lib_name_token| blk: {
4541 const lib_name_str = try astgen.strLitAsString(lib_name_token);4541 const lib_name_str = try astgen.strLitAsString(lib_name_token);
4542 const lib_name_slice = astgen.string_bytes.items[@intFromEnum(lib_name_str.index)..][0..lib_name_str.len];4542 const lib_name_slice = astgen.string_bytes.items[@intFromEnum(lib_name_str.index)..][0..lib_name_str.len];
4543 if (mem.indexOfScalar(u8, lib_name_slice, 0) != null) {4543 if (mem.findScalar(u8, lib_name_slice, 0) != null) {
4544 return astgen.failTok(lib_name_token, "library name cannot contain null bytes", .{});4544 return astgen.failTok(lib_name_token, "library name cannot contain null bytes", .{});
4545 } else if (lib_name_str.len == 0) {4545 } else if (lib_name_str.len == 0) {
4546 return astgen.failTok(lib_name_token, "library name cannot be empty", .{});4546 return astgen.failTok(lib_name_token, "library name cannot be empty", .{});
...@@ -4762,7 +4762,7 @@ fn testDecl(...@@ -4762,7 +4762,7 @@ fn testDecl(
4762 .string_literal => name: {4762 .string_literal => name: {
4763 const name = try astgen.strLitAsString(test_name_token);4763 const name = try astgen.strLitAsString(test_name_token);
4764 const slice = astgen.string_bytes.items[@intFromEnum(name.index)..][0..name.len];4764 const slice = astgen.string_bytes.items[@intFromEnum(name.index)..][0..name.len];
4765 if (mem.indexOfScalar(u8, slice, 0) != null) {4765 if (mem.findScalar(u8, slice, 0) != null) {
4766 return astgen.failTok(test_name_token, "test name cannot contain null bytes", .{});4766 return astgen.failTok(test_name_token, "test name cannot contain null bytes", .{});
4767 } else if (slice.len == 0) {4767 } else if (slice.len == 0) {
4768 return astgen.failTok(test_name_token, "empty test name must be omitted", .{});4768 return astgen.failTok(test_name_token, "empty test name must be omitted", .{});
...@@ -8772,7 +8772,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:...@@ -8772,7 +8772,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
8772}8772}
87738773
8774fn failWithNumberError(astgen: *AstGen, err: std.zig.number_literal.Error, token: Ast.TokenIndex, bytes: []const u8) InnerError {8774fn failWithNumberError(astgen: *AstGen, err: std.zig.number_literal.Error, token: Ast.TokenIndex, bytes: []const u8) InnerError {
8775 const is_float = std.mem.indexOfScalar(u8, bytes, '.') != null;8775 const is_float = std.mem.findScalar(u8, bytes, '.') != null;
8776 switch (err) {8776 switch (err) {
8777 .leading_zero => if (is_float) {8777 .leading_zero => if (is_float) {
8778 return astgen.failTok(token, "number '{s}' has leading zero", .{bytes});8778 return astgen.failTok(token, "number '{s}' has leading zero", .{bytes});
...@@ -9265,7 +9265,7 @@ fn builtinCall(...@@ -9265,7 +9265,7 @@ fn builtinCall(
9265 const str_lit_token = tree.nodeMainToken(operand_node);9265 const str_lit_token = tree.nodeMainToken(operand_node);
9266 const str = try astgen.strLitAsString(str_lit_token);9266 const str = try astgen.strLitAsString(str_lit_token);
9267 const str_slice = astgen.string_bytes.items[@intFromEnum(str.index)..][0..str.len];9267 const str_slice = astgen.string_bytes.items[@intFromEnum(str.index)..][0..str.len];
9268 if (mem.indexOfScalar(u8, str_slice, 0) != null) {9268 if (mem.findScalar(u8, str_slice, 0) != null) {
9269 return astgen.failTok(str_lit_token, "import path cannot contain null bytes", .{});9269 return astgen.failTok(str_lit_token, "import path cannot contain null bytes", .{});
9270 } else if (str.len == 0) {9270 } else if (str.len == 0) {
9271 return astgen.failTok(str_lit_token, "import path cannot be empty", .{});9271 return astgen.failTok(str_lit_token, "import path cannot be empty", .{});
...@@ -11408,7 +11408,7 @@ fn identifierTokenString(astgen: *AstGen, token: Ast.TokenIndex) InnerError![]co...@@ -11408,7 +11408,7 @@ fn identifierTokenString(astgen: *AstGen, token: Ast.TokenIndex) InnerError![]co
11408 var buf: ArrayList(u8) = .empty;11408 var buf: ArrayList(u8) = .empty;
11409 defer buf.deinit(astgen.gpa);11409 defer buf.deinit(astgen.gpa);
11410 try astgen.parseStrLit(token, &buf, ident_name, 1);11410 try astgen.parseStrLit(token, &buf, ident_name, 1);
11411 if (mem.indexOfScalar(u8, buf.items, 0) != null) {11411 if (mem.findScalar(u8, buf.items, 0) != null) {
11412 return astgen.failTok(token, "identifier cannot contain null bytes", .{});11412 return astgen.failTok(token, "identifier cannot contain null bytes", .{});
11413 } else if (buf.items.len == 0) {11413 } else if (buf.items.len == 0) {
11414 return astgen.failTok(token, "identifier cannot be empty", .{});11414 return astgen.failTok(token, "identifier cannot be empty", .{});
...@@ -11434,7 +11434,7 @@ fn appendIdentStr(...@@ -11434,7 +11434,7 @@ fn appendIdentStr(
11434 const start = buf.items.len;11434 const start = buf.items.len;
11435 try astgen.parseStrLit(token, buf, ident_name, 1);11435 try astgen.parseStrLit(token, buf, ident_name, 1);
11436 const slice = buf.items[start..];11436 const slice = buf.items[start..];
11437 if (mem.indexOfScalar(u8, slice, 0) != null) {11437 if (mem.findScalar(u8, slice, 0) != null) {
11438 return astgen.failTok(token, "identifier cannot contain null bytes", .{});11438 return astgen.failTok(token, "identifier cannot contain null bytes", .{});
11439 } else if (slice.len == 0) {11439 } else if (slice.len == 0) {
11440 return astgen.failTok(token, "identifier cannot be empty", .{});11440 return astgen.failTok(token, "identifier cannot be empty", .{});
...@@ -11691,7 +11691,7 @@ fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {...@@ -11691,7 +11691,7 @@ fn strLitAsString(astgen: *AstGen, str_lit_token: Ast.TokenIndex) !IndexSlice {
11691 const token_bytes = astgen.tree.tokenSlice(str_lit_token);11691 const token_bytes = astgen.tree.tokenSlice(str_lit_token);
11692 try astgen.parseStrLit(str_lit_token, string_bytes, token_bytes, 0);11692 try astgen.parseStrLit(str_lit_token, string_bytes, token_bytes, 0);
11693 const key: []const u8 = string_bytes.items[str_index..];11693 const key: []const u8 = string_bytes.items[str_index..];
11694 if (std.mem.indexOfScalar(u8, key, 0)) |_| return .{11694 if (std.mem.findScalar(u8, key, 0)) |_| return .{
11695 .index = @enumFromInt(str_index),11695 .index = @enumFromInt(str_index),
11696 .len = @intCast(key.len),11696 .len = @intCast(key.len),
11697 };11697 };
lib/std/zig/Parse.zig+1-1
...@@ -3660,7 +3660,7 @@ fn eatDocComments(p: *Parse) Allocator.Error!?TokenIndex {...@@ -3660,7 +3660,7 @@ fn eatDocComments(p: *Parse) Allocator.Error!?TokenIndex {
3660}3660}
36613661
3662fn tokensOnSameLine(p: *Parse, token1: TokenIndex, token2: TokenIndex) bool {3662fn tokensOnSameLine(p: *Parse, token1: TokenIndex, token2: TokenIndex) bool {
3663 return std.mem.indexOfScalar(u8, p.source[p.tokenStart(token1)..p.tokenStart(token2)], '\n') == null;3663 return std.mem.findScalar(u8, p.source[p.tokenStart(token1)..p.tokenStart(token2)], '\n') == null;
3664}3664}
36653665
3666fn eatToken(p: *Parse, tag: Token.Tag) ?TokenIndex {3666fn eatToken(p: *Parse, tag: Token.Tag) ?TokenIndex {
lib/std/zig/WindowsSdk.zig+1-1
...@@ -109,7 +109,7 @@ fn iterateAndFilterByVersion(...@@ -109,7 +109,7 @@ fn iterateAndFilterByVersion(
109 .build = "",109 .build = "",
110 };110 };
111 const suffix = entry.name[prefix.len..];111 const suffix = entry.name[prefix.len..];
112 const underscore = std.mem.indexOfScalar(u8, entry.name, '_');112 const underscore = std.mem.findScalar(u8, entry.name, '_');
113 var num_it = std.mem.splitScalar(u8, suffix[0 .. underscore orelse suffix.len], '.');113 var num_it = std.mem.splitScalar(u8, suffix[0 .. underscore orelse suffix.len], '.');
114 version.nums[0] = Version.parseNum(num_it.first()) orelse continue;114 version.nums[0] = Version.parseNum(num_it.first()) orelse continue;
115 for (version.nums[1..]) |*num|115 for (version.nums[1..]) |*num|
lib/std/zig/Zir.zig+1-1
...@@ -120,7 +120,7 @@ pub const NullTerminatedString = enum(u32) {...@@ -120,7 +120,7 @@ pub const NullTerminatedString = enum(u32) {
120/// Given an index into `string_bytes` returns the null-terminated string found there.120/// Given an index into `string_bytes` returns the null-terminated string found there.
121pub fn nullTerminatedString(code: Zir, index: NullTerminatedString) [:0]const u8 {121pub fn nullTerminatedString(code: Zir, index: NullTerminatedString) [:0]const u8 {
122 const slice = code.string_bytes[@intFromEnum(index)..];122 const slice = code.string_bytes[@intFromEnum(index)..];
123 return slice[0..std.mem.indexOfScalar(u8, slice, 0).? :0];123 return slice[0..std.mem.findScalar(u8, slice, 0).? :0];
124}124}
125125
126pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {126pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {
lib/std/zig/Zoir.zig+1-1
...@@ -221,7 +221,7 @@ pub const Node = union(enum) {...@@ -221,7 +221,7 @@ pub const Node = union(enum) {
221pub const NullTerminatedString = enum(u32) {221pub const NullTerminatedString = enum(u32) {
222 _,222 _,
223 pub fn get(nts: NullTerminatedString, zoir: Zoir) [:0]const u8 {223 pub fn get(nts: NullTerminatedString, zoir: Zoir) [:0]const u8 {
224 const idx = std.mem.indexOfScalar(u8, zoir.string_bytes[@intFromEnum(nts)..], 0).?;224 const idx = std.mem.findScalar(u8, zoir.string_bytes[@intFromEnum(nts)..], 0).?;
225 return zoir.string_bytes[@intFromEnum(nts)..][0..idx :0];225 return zoir.string_bytes[@intFromEnum(nts)..][0..idx :0];
226 }226 }
227};227};
lib/std/zig/ZonGen.zig+3-3
...@@ -487,7 +487,7 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,...@@ -487,7 +487,7 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,
487 }487 }
488488
489 const slice = zg.string_bytes.items[start..];489 const slice = zg.string_bytes.items[start..];
490 if (mem.indexOfScalar(u8, slice, 0) != null) {490 if (mem.findScalar(u8, slice, 0) != null) {
491 try zg.addErrorTok(ident_token, "identifier cannot contain null bytes", .{});491 try zg.addErrorTok(ident_token, "identifier cannot contain null bytes", .{});
492 return error.BadString;492 return error.BadString;
493 } else if (slice.len == 0) {493 } else if (slice.len == 0) {
...@@ -586,7 +586,7 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad...@@ -586,7 +586,7 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad
586 },586 },
587 }587 }
588 const key: []const u8 = string_bytes.items[str_index..];588 const key: []const u8 = string_bytes.items[str_index..];
589 if (std.mem.indexOfScalar(u8, key, 0) != null) return .{ .slice = .{589 if (std.mem.findScalar(u8, key, 0) != null) return .{ .slice = .{
590 .start = str_index,590 .start = str_index,
591 .len = @intCast(key.len),591 .len = @intCast(key.len),
592 } };592 } };
...@@ -785,7 +785,7 @@ fn lowerStrLitError(...@@ -785,7 +785,7 @@ fn lowerStrLitError(
785}785}
786786
787fn lowerNumberError(zg: *ZonGen, err: std.zig.number_literal.Error, token: Ast.TokenIndex, bytes: []const u8) Allocator.Error!void {787fn lowerNumberError(zg: *ZonGen, err: std.zig.number_literal.Error, token: Ast.TokenIndex, bytes: []const u8) Allocator.Error!void {
788 const is_float = std.mem.indexOfScalar(u8, bytes, '.') != null;788 const is_float = std.mem.findScalar(u8, bytes, '.') != null;
789 switch (err) {789 switch (err) {
790 .leading_zero => if (is_float) {790 .leading_zero => if (is_float) {
791 try zg.addErrorTok(token, "number '{s}' has leading zero", .{bytes});791 try zg.addErrorTok(token, "number '{s}' has leading zero", .{bytes});
lib/std/zig/c_translation/helpers.zig+1-1
...@@ -115,7 +115,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt...@@ -115,7 +115,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt
115 else115 else
116 &signed_oct_hex;116 &signed_oct_hex;
117117
118 var pos = std.mem.indexOfScalar(type, list, SuffixType).?;118 var pos = std.mem.findScalar(type, list, SuffixType).?;
119 while (pos < list.len) : (pos += 1) {119 while (pos < list.len) : (pos += 1) {
120 if (number >= std.math.minInt(list[pos]) and number <= std.math.maxInt(list[pos])) {120 if (number >= std.math.minInt(list[pos]) and number <= std.math.maxInt(list[pos])) {
121 return list[pos];121 return list[pos];
lib/std/zig/llvm/bitcode_writer.zig+1-1
...@@ -26,7 +26,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -26,7 +26,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
26 widths: [types.len]u16,26 widths: [types.len]u16,
2727
28 pub fn getTypeWidth(self: BcWriter, comptime Type: type) u16 {28 pub fn getTypeWidth(self: BcWriter, comptime Type: type) u16 {
29 return self.widths[comptime std.mem.indexOfScalar(type, types, Type).?];29 return self.widths[comptime std.mem.findScalar(type, types, Type).?];
30 }30 }
3131
32 pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter {32 pub fn init(allocator: std.mem.Allocator, widths: [types.len]u16) BcWriter {
lib/std/zig/system.zig+1-1
...@@ -1076,7 +1076,7 @@ fn detectAbiAndDynamicLinker(io: Io, cpu: Target.Cpu, os: Target.Os, query: Targ...@@ -1076,7 +1076,7 @@ fn detectAbiAndDynamicLinker(io: Io, cpu: Target.Cpu, os: Target.Os, query: Targ
1076 const path_maybe_args = mem.trimEnd(u8, trimmed_line, "\n");1076 const path_maybe_args = mem.trimEnd(u8, trimmed_line, "\n");
10771077
1078 // Separate path and args.1078 // Separate path and args.
1079 const path_end = mem.indexOfAny(u8, path_maybe_args, &.{ ' ', '\t', 0 }) orelse path_maybe_args.len;1079 const path_end = mem.findAny(u8, path_maybe_args, &.{ ' ', '\t', 0 }) orelse path_maybe_args.len;
1080 const unvalidated_path = path_maybe_args[0..path_end];1080 const unvalidated_path = path_maybe_args[0..path_end];
1081 file_name = if (fs.path.isAbsolute(unvalidated_path)) unvalidated_path else return error.RelativeShebang;1081 file_name = if (fs.path.isAbsolute(unvalidated_path)) unvalidated_path else return error.RelativeShebang;
1082 continue;1082 continue;
lib/std/zig/system/linux.zig+4-4
...@@ -35,7 +35,7 @@ const SparcCpuinfoImpl = struct {...@@ -35,7 +35,7 @@ const SparcCpuinfoImpl = struct {
35 fn line_hook(self: *SparcCpuinfoImpl, key: []const u8, value: []const u8) !bool {35 fn line_hook(self: *SparcCpuinfoImpl, key: []const u8, value: []const u8) !bool {
36 if (mem.eql(u8, key, "cpu")) {36 if (mem.eql(u8, key, "cpu")) {
37 inline for (cpu_names) |pair| {37 inline for (cpu_names) |pair| {
38 if (mem.indexOfPos(u8, value, 0, pair[0]) != null) {38 if (mem.findPos(u8, value, 0, pair[0]) != null) {
39 self.model = pair[1];39 self.model = pair[1];
40 break;40 break;
41 }41 }
...@@ -147,7 +147,7 @@ const PowerpcCpuinfoImpl = struct {...@@ -147,7 +147,7 @@ const PowerpcCpuinfoImpl = struct {
147 // The model name is often followed by a comma or space and extra147 // The model name is often followed by a comma or space and extra
148 // info.148 // info.
149 inline for (cpu_names) |pair| {149 inline for (cpu_names) |pair| {
150 const end_index = mem.indexOfAny(u8, value, ", ") orelse value.len;150 const end_index = mem.findAny(u8, value, ", ") orelse value.len;
151 if (mem.eql(u8, value[0..end_index], pair[0])) {151 if (mem.eql(u8, value[0..end_index], pair[0])) {
152 self.model = pair[1];152 self.model = pair[1];
153 break;153 break;
...@@ -318,7 +318,7 @@ const ArmCpuinfoImpl = struct {...@@ -318,7 +318,7 @@ const ArmCpuinfoImpl = struct {
318 self.have_fields += 1;318 self.have_fields += 1;
319 } else if (mem.eql(u8, key, "model name")) {319 } else if (mem.eql(u8, key, "model name")) {
320 // ARMv6 cores report "CPU architecture" equal to 7.320 // ARMv6 cores report "CPU architecture" equal to 7.
321 if (mem.indexOf(u8, value, "(v6l)")) |_| {321 if (mem.find(u8, value, "(v6l)")) |_| {
322 info.is_really_v6 = true;322 info.is_really_v6 = true;
323 }323 }
324 } else if (mem.eql(u8, key, "CPU revision")) {324 } else if (mem.eql(u8, key, "CPU revision")) {
...@@ -427,7 +427,7 @@ fn CpuinfoParser(comptime impl: anytype) type {...@@ -427,7 +427,7 @@ fn CpuinfoParser(comptime impl: anytype) type {
427 fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu {427 fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu {
428 var obj: impl = .{};428 var obj: impl = .{};
429 while (try reader.takeDelimiter('\n')) |line| {429 while (try reader.takeDelimiter('\n')) |line| {
430 const colon_pos = mem.indexOfScalar(u8, line, ':') orelse continue;430 const colon_pos = mem.findScalar(u8, line, ':') orelse continue;
431 const key = mem.trimEnd(u8, line[0..colon_pos], " \t");431 const key = mem.trimEnd(u8, line[0..colon_pos], " \t");
432 const value = mem.trimStart(u8, line[colon_pos + 1 ..], " \t");432 const value = mem.trimStart(u8, line[colon_pos + 1 ..], " \t");
433 if (!try obj.line_hook(key, value)) break;433 if (!try obj.line_hook(key, value)) break;
lib/std/zip.zig+2-2
...@@ -539,7 +539,7 @@ pub const Iterator = struct {...@@ -539,7 +539,7 @@ pub const Iterator = struct {
539 if (options.allow_backslashes) {539 if (options.allow_backslashes) {
540 std.mem.replaceScalar(u8, filename, '\\', '/');540 std.mem.replaceScalar(u8, filename, '\\', '/');
541 } else {541 } else {
542 if (std.mem.indexOfScalar(u8, filename, '\\')) |_|542 if (std.mem.findScalar(u8, filename, '\\')) |_|
543 return error.ZipFilenameHasBackslash;543 return error.ZipFilenameHasBackslash;
544 }544 }
545545
...@@ -626,7 +626,7 @@ pub const Diagnostics = struct {...@@ -626,7 +626,7 @@ pub const Diagnostics = struct {
626 if (!self.saw_first_file) {626 if (!self.saw_first_file) {
627 self.saw_first_file = true;627 self.saw_first_file = true;
628 std.debug.assert(self.root_dir.len == 0);628 std.debug.assert(self.root_dir.len == 0);
629 const root_len = std.mem.indexOfScalar(u8, name, '/') orelse return;629 const root_len = std.mem.findScalar(u8, name, '/') orelse return;
630 std.debug.assert(root_len > 0);630 std.debug.assert(root_len > 0);
631 self.root_dir = try self.allocator.dupe(u8, name[0..root_len]);631 self.root_dir = try self.allocator.dupe(u8, name[0..root_len]);
632 } else if (self.root_dir.len > 0) {632 } else if (self.root_dir.len > 0) {