From 4c194047d210ad9cf571c6019731d00d1e3615a4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 12:14:58 -0300 Subject: idioms #4, string chains are an enum and a switch: main's flags (each exact one a Flag, the prefixed ones as they were), --ps's rows and manage's verb, the daemon's verbs on both ends and its registry's rows, an upgrade record's words, the window driver's mouse kinds and finger names, a frame script's click target and a mount name's reserved words go through std.meta.stringToEnum; with them main asks std.Io for its working directory, its chdir, a directory's access and /proc's comm, not libc Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/fs.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/fs.zig') diff --git a/src/fs.zig b/src/fs.zig index e3976884..97f67061 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -281,8 +281,7 @@ fn osReadWrite(path_z: [:0]const u8, req: Req, attr: Reply.Attr, buf: []u8) OsRe } pub fn validMountName(name: []const u8) bool { - if (name.len == 0 or name.len > name_capacity or std.mem.eql(u8, name, ".") or std.mem.eql(u8, name, "..")) return false; - if (std.mem.eql(u8, name, "os") or std.mem.eql(u8, name, "self")) return false; + if (name.len == 0 or name.len > name_capacity or std.meta.stringToEnum(enum { @".", @"..", os, self }, name) != null) return false; for (name) |c| if (!std.ascii.isAlphanumeric(c) and c != '_' and c != '-' and c != '.') return false; return true; } -- cgit v1.3