From 1cc9a7b9e5730a9df6ec36646109cef9e8fb0f04 Mon Sep 17 00:00:00 2001 From: foxnne Date: Tue, 20 Oct 2026 15:47:46 -0500 Subject: [PATCH] zig: mem.indexOf calls become mem.find --- backend/winsys/EventQueue.zig | 4 ++-- build/plugins.zig | 2 +- scripts/lint.zig | 2 +- tests/integration.zig | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/winsys/EventQueue.zig b/backend/winsys/EventQueue.zig index e318f11c6..bce2b8340 100644 --- a/backend/winsys/EventQueue.zig +++ b/backend/winsys/EventQueue.zig @@ -848,7 +848,7 @@ test "fuzz: no stuck input, balanced downs and ups, time that only goes forward" const w: usize = if (e.window) |win| win.id - 1 else 0; switch (e.payload) { .key => |k| { - const c = std.mem.indexOfScalar(Event.Code, &codes, k.physical).?; + const c = std.mem.findScalar(Event.Code, &codes, k.physical).?; switch (k.action) { .down => { try std.testing.expect(!m.keys[w][c]); @@ -862,7 +862,7 @@ test "fuzz: no stuck input, balanced downs and ups, time that only goes forward" } }, .pointer => |p| { - const b = std.mem.indexOfScalar(Event.Button, &buttons, p.button).?; + const b = std.mem.findScalar(Event.Button, &buttons, p.button).?; switch (p.kind) { .press => { try std.testing.expect(!m.buttons[w][b]); diff --git a/build/plugins.zig b/build/plugins.zig index 99fef4d02..674541236 100644 --- a/build/plugins.zig +++ b/build/plugins.zig @@ -266,7 +266,7 @@ const Rehome = struct { for (src.c_macros.items) |macro| { // `addCMacro` stores `-Dname=value`. const body = macro["-D".len..]; - const eq = std.mem.indexOfScalar(u8, body, '=') orelse body.len; + const eq = std.mem.findScalar(u8, body, '=') orelse body.len; m.addCMacro(body[0..eq], if (eq < body.len) body[eq + 1 ..] else ""); } for (src.lib_paths.items) |p| m.addLibraryPath(p); diff --git a/scripts/lint.zig b/scripts/lint.zig index b5f8b004b..1f36f2e55 100644 --- a/scripts/lint.zig +++ b/scripts/lint.zig @@ -131,7 +131,7 @@ fn analyze(allocator: std.mem.Allocator, source: [:0]const u8) ![]Finding { const text = std.mem.trim(u8, line[comment + 2 ..], " \t\r"); const prefix = "lint-allow("; if (!std.mem.startsWith(u8, text, prefix)) continue; - const close = std.mem.indexOfScalar(u8, text, ')') orelse text.len; + const close = std.mem.findScalar(u8, text, ')') orelse text.len; const tail = if (close < text.len) std.mem.trim(u8, text[close + 1 ..], " \t\r") else ""; if (tail.len < 2 or tail[0] != ':' or std.mem.trim(u8, tail[1..], " \t\r").len == 0) { try findings.append(allocator, .{ .rule = .@"lint-allow-reason", .line = line_number, .message = "lint-allow requires a reason after ':'" }); diff --git a/tests/integration.zig b/tests/integration.zig index 6661142d2..43e2c82c1 100644 --- a/tests/integration.zig +++ b/tests/integration.zig @@ -11839,9 +11839,9 @@ test "settings: an untouched in-app material is not written; a chosen one is" { var s: Settings = .{}; const plain = try s.serialize(gpa); defer gpa.free(plain); - try std.testing.expect(std.mem.indexOf(u8, plain, "in_app_material") == null); + try std.testing.expect(std.mem.find(u8, plain, "in_app_material") == null); s.in_app_material = .frost; const chosen = try s.serialize(gpa); defer gpa.free(chosen); - try std.testing.expect(std.mem.indexOf(u8, chosen, ".in_app_material = .frost") != null); + try std.testing.expect(std.mem.find(u8, chosen, ".in_app_material = .frost") != null); }