aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-12-22 12:50:46 +0100
committerAlex Rønne Petersen <alex@alexrp.com>2025-12-22 12:50:46 +0100
commitaa0249d74e573742db3567f589fc6e4a00e1fff8 (patch)
treecce61cb7f02072d205a12ae451922f0bf09c13ce /lib/std/Build/Step
parent6b9125cbe662d530160e0732c856aa0da86894c0 (diff)
parent02c5f05e2f0e8e786f0530014e35c1520efd0084 (diff)
downloadzig-aa0249d74e573742db3567f589fc6e4a00e1fff8.tar.gz
zig-aa0249d74e573742db3567f589fc6e4a00e1fff8.zip
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>
Diffstat (limited to 'lib/std/Build/Step')
-rw-r--r--lib/std/Build/Step/CheckFile.zig2
-rw-r--r--lib/std/Build/Step/CheckObject.zig6
-rw-r--r--lib/std/Build/Step/Compile.zig6
-rw-r--r--lib/std/Build/Step/ConfigHeader.zig10
-rw-r--r--lib/std/Build/Step/Run.zig4
5 files changed, 14 insertions, 14 deletions
diff --git a/lib/std/Build/Step/CheckFile.zig b/lib/std/Build/Step/CheckFile.zig
index 5e664b3bc3..efeedc8b80 100644
--- a/lib/std/Build/Step/CheckFile.zig
+++ b/lib/std/Build/Step/CheckFile.zig
@@ -60,7 +60,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
};
for (check_file.expected_matches) |expected_match| {
- if (mem.indexOf(u8, contents, expected_match) == null) {
+ if (mem.find(u8, contents, expected_match) == null) {
return step.fail(
\\
\\========= expected to find: ===================
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig
index 4d5071d2c7..c6c11ce2b9 100644
--- a/lib/std/Build/Step/CheckObject.zig
+++ b/lib/std/Build/Step/CheckObject.zig
@@ -88,7 +88,7 @@ const Action = struct {
while (needle_it.next()) |needle_tok| {
const hay_tok = hay_it.next() orelse break;
if (mem.startsWith(u8, needle_tok, "{")) {
- const closing_brace = mem.indexOf(u8, needle_tok, "}") orelse return error.MissingClosingBrace;
+ const closing_brace = mem.find(u8, needle_tok, "}") orelse return error.MissingClosingBrace;
if (closing_brace != needle_tok.len - 1) return error.ClosingBraceNotLast;
const name = needle_tok[1..closing_brace];
@@ -133,7 +133,7 @@ const Action = struct {
assert(act.tag == .contains);
const hay = mem.trim(u8, haystack, " ");
const phrase = mem.trim(u8, act.phrase.resolve(b, step), " ");
- return mem.indexOf(u8, hay, phrase) != null;
+ return mem.find(u8, hay, phrase) != null;
}
/// Returns true if the `phrase` does not exist within the haystack.
@@ -1662,7 +1662,7 @@ const MachODumper = struct {
.dump_section => {
const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0);
- const sep_index = mem.indexOfScalar(u8, name, ',') orelse
+ const sep_index = mem.findScalar(u8, name, ',') orelse
return step.fail("invalid section name: {s}", .{name});
const segname = name[0..sep_index];
const sectname = name[sep_index + 1 ..];
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index 7be41ebbea..c57c7750be 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -369,7 +369,7 @@ pub const TestRunner = struct {
pub fn create(owner: *std.Build, options: Options) *Compile {
const name = owner.dupe(options.name);
- if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
+ if (mem.find(u8, name, "/") != null or mem.find(u8, name, "\\") != null) {
panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
}
@@ -716,7 +716,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
// Prefixed "lib" or suffixed ".0".
for (pkgs) |pkg| {
- if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| {
+ if (std.ascii.findIgnoreCase(pkg.name, lib_name)) |pos| {
const prefix = pkg.name[0..pos];
const suffix = pkg.name[pos + lib_name.len ..];
if (prefix.len > 0 and !mem.eql(u8, prefix, "lib")) continue;
@@ -1996,7 +1996,7 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool {
// We scan for /?/ in expected line and if there is a match, we match everything
// up to and after /?/.
const expected_trim = mem.trim(u8, expected, " ");
- if (mem.indexOf(u8, expected_trim, "/?/")) |index| {
+ if (mem.find(u8, expected_trim, "/?/")) |index| {
const actual_trim = mem.trim(u8, actual, " ");
const lhs = expected_trim[0..index];
const rhs = expected_trim[index + "/?/".len ..];
diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig
index 8c0d3032da..df2419764d 100644
--- a/lib/std/Build/Step/ConfigHeader.zig
+++ b/lib/std/Build/Step/ConfigHeader.zig
@@ -578,12 +578,12 @@ fn expand_variables_autoconf_at(
var source_offset: usize = 0;
while (curr < contents.len) : (curr += 1) {
if (contents[curr] != '@') continue;
- if (std.mem.indexOfScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
+ if (std.mem.findScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
if (close_pos == curr + 1) {
// closed immediately, preserve as a literal
continue;
}
- const valid_varname_end = std.mem.indexOfNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
+ const valid_varname_end = std.mem.findNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
if (valid_varname_end != close_pos) {
// contains invalid characters, preserve as a literal
continue;
@@ -635,12 +635,12 @@ fn expand_variables_cmake(
loop: while (curr < contents.len) : (curr += 1) {
switch (contents[curr]) {
'@' => blk: {
- if (std.mem.indexOfScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
+ if (std.mem.findScalarPos(u8, contents, curr + 1, '@')) |close_pos| {
if (close_pos == curr + 1) {
// closed immediately, preserve as a literal
break :blk;
}
- const valid_varname_end = std.mem.indexOfNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
+ const valid_varname_end = std.mem.findNonePos(u8, contents, curr + 1, valid_varname_chars) orelse 0;
if (valid_varname_end != close_pos) {
// contains invalid characters, preserve as a literal
break :blk;
@@ -731,7 +731,7 @@ fn expand_variables_cmake(
else => {},
}
- if (var_stack.items.len > 0 and std.mem.indexOfScalar(u8, valid_varname_chars, contents[curr]) == null) {
+ if (var_stack.items.len > 0 and std.mem.findScalar(u8, valid_varname_chars, contents[curr]) == null) {
return error.InvalidCharacter;
}
}
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
index ff65aa42a7..28c09e1faf 100644
--- a/lib/std/Build/Step/Run.zig
+++ b/lib/std/Build/Step/Run.zig
@@ -1505,7 +1505,7 @@ fn runCommand(
}
},
.expect_stderr_match => |match| {
- if (mem.indexOf(u8, generic_result.stderr.?, match) == null) {
+ if (mem.find(u8, generic_result.stderr.?, match) == null) {
return step.fail(
\\========= expected to find in stderr: =========
\\{s}
@@ -1531,7 +1531,7 @@ fn runCommand(
}
},
.expect_stdout_match => |match| {
- if (mem.indexOf(u8, generic_result.stdout.?, match) == null) {
+ if (mem.find(u8, generic_result.stdout.?, match) == null) {
return step.fail(
\\========= expected to find in stdout: =========
\\{s}