Skip to content

Commit 83d3916

Browse files
committed
require Zig 0.15.x or later
1 parent ab5cf5f commit 83d3916

File tree

4 files changed

+5
-61
lines changed

4 files changed

+5
-61
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,14 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
zig-version: [master]
1615
os: [ubuntu-latest, macos-latest, windows-latest]
17-
include:
18-
- zig-version: "0.14.1"
19-
os: ubuntu-latest
2016
runs-on: ${{ matrix.os }}
2117
steps:
2218
- name: Checkout
2319
uses: actions/checkout@v4
2420

2521
- name: Setup Zig
2622
uses: mlugg/setup-zig@v2
27-
with:
28-
version: master
2923

3024
- name: Run zig fmt
3125
if: matrix.os == 'ubuntu-latest'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn getPath(allocator: std.mem.Allocator, folder: KnownFolder) Error!?[]const
4747
## Installation
4848

4949
> [!NOTE]
50-
> The minimum supported Zig version is `0.14.0`.
50+
> The supported Zig version is `0.15.x`.
5151
5252
Initialize a `zig build` project if you haven't already.
5353

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.{
22
.name = .known_folders,
33
.version = "0.0.0",
4-
.minimum_zig_version = "0.14.0",
4+
.minimum_zig_version = "0.15.2",
55
.dependencies = .{},
66
.paths = .{
77
"build.zig",

known-folders.zig

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,7 @@ const TestingSystem = struct {
344344
if (std.mem.eql(u8, key, kv.key)) return kv.value;
345345
}
346346
system.deinit();
347-
if (@hasDecl(std.zig, "fmtString")) {
348-
std.debug.panic("the result of `getenv(\"{f}\")` must explicitly specified in the TestingSystem", .{std.zig.fmtString(key)});
349-
} else {
350-
std.debug.panic("the result of `getenv(\"{}\")` must explicitly specified in the TestingSystem", .{std.zig.fmtEscapes(key)});
351-
}
347+
std.debug.panic("the result of `getenv(\"{f}\")` must explicitly specified in the TestingSystem", .{std.zig.fmtString(key)});
352348
}
353349

354350
/// Asserts that the file is specified in `TestingSystem.files`.
@@ -360,11 +356,7 @@ const TestingSystem = struct {
360356
if (std.mem.eql(u8, file_path, kv.path)) break kv;
361357
} else {
362358
system.deinit();
363-
if (@hasDecl(std.zig, "fmtString")) {
364-
std.debug.panic("`openFile(\"{0f}\", \"{1f}\")` has been called on an unexpected file", .{ std.zig.fmtString(dir_path), std.zig.fmtString(sub_path) });
365-
} else {
366-
std.debug.panic("`openFile(\"{0}\", \"{1}\")` has been called on an unexpected file", .{ std.zig.fmtEscapes(dir_path), std.zig.fmtEscapes(sub_path) });
367-
}
359+
std.debug.panic("`openFile(\"{0f}\", \"{1f}\")` has been called on an unexpected file", .{ std.zig.fmtString(dir_path), std.zig.fmtString(sub_path) });
368360
};
369361

370362
const data = kv.data orelse return error.FileNotFound;
@@ -451,7 +443,7 @@ fn xdgUserDirLookup(
451443
defer file.close();
452444

453445
var buffer: [xdg_user_dir_lookup_line_buffer_size + 1]u8 = undefined;
454-
var line_it: if (@hasDecl(std.fs.File, "stdin")) LineIterator else OldLineIterator = .init(file);
446+
var line_it: LineIterator = .init(file);
455447

456448
var user_dir: ?[]u8 = null;
457449
while (try line_it.next(&buffer)) |line_capture| {
@@ -536,48 +528,6 @@ fn xdgUserDirLookup(
536528
return user_dir;
537529
}
538530

539-
const OldLineIterator = struct {
540-
fbr: std.io.BufferedReader(4096, std.fs.File.Reader),
541-
542-
fn init(file: std.fs.File) OldLineIterator {
543-
return .{
544-
.fbr = std.io.bufferedReader(file.reader()),
545-
};
546-
}
547-
548-
fn next(it: *OldLineIterator, buffer: []u8) std.posix.ReadError!?[:0]const u8 {
549-
const reader = it.fbr.reader();
550-
551-
// Similar to `readUntilDelimiterOrEof` but also writes a null-terminator
552-
for (buffer, 0..) |*out, index| {
553-
const byte = reader.readByte() catch |err| switch (err) {
554-
error.EndOfStream => if (index == 0) return null else '\n',
555-
else => |e| return e,
556-
};
557-
if (byte == '\n') {
558-
out.* = 0;
559-
return buffer[0..index :0];
560-
}
561-
out.* = byte;
562-
} else {
563-
// This happens when the line is longer than 511 characters
564-
// There are four possible ways to handle this:
565-
// - use dynamic allocation to acquire enough storage
566-
// - return an error
567-
// - skip the line
568-
// - truncate the line
569-
//
570-
// The xdg-user-dir implementation chooses to trunacte the line.
571-
// See "getPath - user-dirs.dirs - very long line" test
572-
573-
try reader.skipUntilDelimiterOrEof('\n');
574-
575-
buffer[buffer.len - 1] = 0;
576-
return buffer[0 .. buffer.len - 1 :0];
577-
}
578-
}
579-
};
580-
581531
const LineIterator = struct {
582532
file_reader: std.fs.File.Reader,
583533
keep_reading: bool,

0 commit comments

Comments
 (0)