summaryrefslogtreecommitdiff
path: root/src/locations.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-21 14:35:15 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commitbc3d18d27f9fc1155db7fac3946c4d38774f9e65 (patch)
tree9178ce95952797f8a78b16c2b805e53368efb35a /src/locations.zig
parent1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2 (diff)
downloadpardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.tar.gz
pardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.zip
Build with Zig 0.17
ghostty, libvaxis and uucode move to ghostty's 0.17 pins, cloud9 to its 0.17 main, SDL to castholm's release-3.4.x (3.4.18), zstbi and tree-sitter to forks with 0.17 build files (see build.zig.zon). A bare zig build copies the binaries into ~/.local/bin (-Dhome-install=false leaves it out): 0.17 keeps the prefix from build scripts. A terminal's edited copy goes when the program clears the screen. tinywin.snap is gone; perf baselines are re-recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/locations.zig')
-rw-r--r--src/locations.zig24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/locations.zig b/src/locations.zig
index 745393e5..2828566d 100644
--- a/src/locations.zig
+++ b/src/locations.zig
@@ -587,12 +587,13 @@ pub const Config = struct {
const key = token[0..colon];
const value = token[colon + 1 ..];
var found = false;
- inline for (@typeInfo(Config).@"struct".fields) |field| {
- if (std.mem.eql(u8, key, field.name)) {
- @field(result, field.name) = switch (@typeInfo(field.type)) {
+ const info = @typeInfo(Config).@"struct";
+ inline for (info.field_names, info.field_types) |name, T| {
+ if (std.mem.eql(u8, key, name)) {
+ @field(result, name) = switch (@typeInfo(T)) {
.bool => if (std.mem.eql(u8, value, "on")) true else if (std.mem.eql(u8, value, "off")) false else return error.ExpectedOnOrOff,
- .int => std.fmt.parseInt(field.type, value, 10) catch return error.InvalidContext,
- .@"enum" => std.meta.stringToEnum(field.type, value) orelse return error.InvalidLayout,
+ .int => std.fmt.parseInt(T, value, 10) catch return error.InvalidContext,
+ .@"enum" => std.meta.stringToEnum(T, value) orelse return error.InvalidLayout,
else => @compileError("unsupported location setting type"),
};
found = true;
@@ -604,11 +605,12 @@ pub const Config = struct {
}
pub fn write(config: Config, writer: *std.Io.Writer) !void {
- inline for (@typeInfo(Config).@"struct".fields, 0..) |field, index| {
+ const info = @typeInfo(Config).@"struct";
+ inline for (info.field_names, info.field_types, 0..) |name, T, index| {
if (index > 0) try writer.writeByte(' ');
- try writer.writeAll(field.name ++ ":");
- const value = @field(config, field.name);
- switch (@typeInfo(field.type)) {
+ try writer.writeAll(name ++ ":");
+ const value = @field(config, name);
+ switch (@typeInfo(T)) {
.bool => try writer.writeAll(if (value) "on" else "off"),
.int => try writer.print("{d}", .{value}),
.@"enum" => try writer.writeAll(@tagName(value)),
@@ -809,11 +811,11 @@ test "locations cache bounds memory and entries and evicts least recently used"
try std.testing.expectEqual(@as(usize, 2), cache.len);
try std.testing.expect(cache.bytes <= 40);
try std.testing.expectEqualStrings("b.unknown", cache.entries[0].path);
- try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.unknown", "x" ** 41, false, false, 40));
+ try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.unknown", &@as([41]u8, @splat('x')), false, false, 40));
try std.testing.expectEqual(@as(usize, 2), cache.len);
if (syntax.supportsPath("large.zig")) {
const before = cache.analyses;
- try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.zig", "x" ** 25, true, true, 40));
+ try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.zig", &@as([25]u8, @splat('x')), true, true, 40));
try std.testing.expectEqual(before, cache.analyses);
}
cache.deinit(gpa);