From 6338f21da9f7ac2d08ed274dad5fdeaa0a419959 Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Thu, 24 Jun 2021 17:36:12 +0200 Subject: Build buildscript with latest version of zig --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 5cbc731..f3f9804 100644 --- a/build.zig +++ b/build.zig @@ -53,7 +53,7 @@ pub fn build(b: *Builder) void { fn readMeStep(b: *Builder) *std.build.Step { const s = b.allocator.create(std.build.Step) catch unreachable; - s.* = std.build.Step.init(.Custom, "ReadMeStep", b.allocator, struct { + s.* = std.build.Step.init(.custom, "ReadMeStep", b.allocator, struct { fn make(step: *std.build.Step) anyerror!void { @setEvalBranchQuota(10000); const file = try std.fs.cwd().createFile("README.md", .{}); -- cgit v1.2.3 From e7822aaf172704c557ad063468b2229131ce2aef Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Thu, 24 Jun 2021 17:36:35 +0200 Subject: Fix all new compiler errors from zig master --- build.zig | 1 + clap.zig | 2 +- clap/args.zig | 1 + clap/comptime.zig | 8 ++++---- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index f3f9804..69fdcdb 100644 --- a/build.zig +++ b/build.zig @@ -56,6 +56,7 @@ fn readMeStep(b: *Builder) *std.build.Step { s.* = std.build.Step.init(.custom, "ReadMeStep", b.allocator, struct { fn make(step: *std.build.Step) anyerror!void { @setEvalBranchQuota(10000); + _ = step; const file = try std.fs.cwd().createFile("README.md", .{}); const stream = file.writer(); try stream.print(@embedFile("example/README.md.template"), .{ diff --git a/clap.zig b/clap.zig index ee2dad8..5bb3542 100644 --- a/clap.zig +++ b/clap.zig @@ -110,7 +110,7 @@ pub fn parseParam(line: []const u8) !Param(Help) { } else null; var res = parseParamRest(it.rest()); - res.names.long = param_str[2..]; + res.names.long = long_name; res.names.short = short_name; return res; } diff --git a/clap/args.zig b/clap/args.zig index d848eb7..1d93189 100644 --- a/clap/args.zig +++ b/clap/args.zig @@ -12,6 +12,7 @@ pub const ExampleArgIterator = struct { const Error = error{}; pub fn next(iter: *ExampleArgIterator) Error!?[]const u8 { + _ = iter; return "2"; } }; diff --git a/clap/comptime.zig b/clap/comptime.zig index cbc872e..0328997 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig @@ -11,10 +11,10 @@ pub fn ComptimeClap( comptime Id: type, comptime params: []const clap.Param(Id), ) type { - var flags: usize = 0; - var single_options: usize = 0; - var multi_options: usize = 0; - var converted_params: []const clap.Param(usize) = &.{}; + comptime var flags: usize = 0; + comptime var single_options: usize = 0; + comptime var multi_options: usize = 0; + comptime var converted_params: []const clap.Param(usize) = &.{}; for (params) |param| { var index: usize = 0; if (param.names.long != null or param.names.short != null) { -- cgit v1.2.3 From 8b51a3d857c2714c46a3d2aaef6c47239575047d Mon Sep 17 00:00:00 2001 From: Sirius902 Date: Sat, 24 Jul 2021 16:44:30 -0700 Subject: Discard unused variable --- clap/comptime.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clap/comptime.zig b/clap/comptime.zig index a0f57ad..1050861 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig @@ -195,7 +195,7 @@ fn testErr( ) !void { var diag = clap.Diagnostic{}; var iter = clap.args.SliceIterator{ .args = args_strings }; - var args = clap.parseEx(u8, params, &iter, .{ + _ = clap.parseEx(u8, params, &iter, .{ .allocator = testing.allocator, .diagnostic = &diag, }) catch |err| { -- cgit v1.2.3 From ed90e560d9b1144a27562ef62ff7686eb3af029a Mon Sep 17 00:00:00 2001 From: Sirius902 Date: Sat, 24 Jul 2021 16:44:54 -0700 Subject: Update CI to zig master --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fde407..40fe612 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: submodules: recursive - uses: goto-bus-stop/setup-zig@v1.3.0 with: - version: 0.8.0 + version: master - run: zig build lint: runs-on: ubuntu-latest @@ -20,5 +20,5 @@ jobs: - uses: actions/checkout@v2.3.4 - uses: goto-bus-stop/setup-zig@v1.3.0 with: - version: 0.8.0 + version: master - run: zig fmt --check . -- cgit v1.2.3 From c5fb22823a9a4a699acaefc1e9febfee0b8e506c Mon Sep 17 00:00:00 2001 From: Stephen Gregoratto Date: Wed, 11 Aug 2021 10:06:28 +1000 Subject: Update calls to tokenizer The tokenize function was made generic, so we have to pass the type as the first parameter. --- clap.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clap.zig b/clap.zig index 5bb3542..0bc711b 100644 --- a/clap.zig +++ b/clap.zig @@ -74,7 +74,7 @@ pub fn parseParam(line: []const u8) !Param(Help) { @setEvalBranchQuota(std.math.maxInt(u32)); var found_comma = false; - var it = mem.tokenize(line, " \t"); + var it = mem.tokenize(u8, line, " \t"); var param_str = it.next() orelse return error.NoParamFound; const short_name = if (!mem.startsWith(u8, param_str, "--") and -- cgit v1.2.3 From 27899f951e94a67bf68d6dfebbf4ab9cf182d896 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Sun, 5 Sep 2021 13:35:09 -0700 Subject: Update mem.split call for latest zig master --- clap.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clap.zig b/clap.zig index e108c9b..69be5bd 100644 --- a/clap.zig +++ b/clap.zig @@ -409,7 +409,7 @@ pub fn helpFull( try printParam(cs.writer(), Id, param, Error, context, valueText); try stream.writeByteNTimes(' ', max_spacing - @intCast(usize, cs.bytes_written)); const help_text = try helpText(context, param); - var help_text_line_it = mem.split(help_text, "\n"); + var help_text_line_it = mem.split(u8, help_text, "\n"); var indent_line = false; while (help_text_line_it.next()) |line| : (indent_line = true) { if (indent_line) { -- cgit v1.2.3 From 7fe9b7c18c6810bdfb1448a19a8c08a6a1c5f557 Mon Sep 17 00:00:00 2001 From: Asherah Connor Date: Mon, 11 Oct 2021 14:54:59 +1100 Subject: zig master updates --- build.zig | 1 + clap/args.zig | 1 + clap/comptime.zig | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 9b1c0ce..19204c7 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const Builder = std.build.Builder; diff --git a/clap/args.zig b/clap/args.zig index a6be833..dd97d24 100644 --- a/clap/args.zig +++ b/clap/args.zig @@ -1,5 +1,6 @@ const builtin = @import("builtin"); const std = @import("std"); +const builtin = @import("builtin"); const debug = std.debug; const heap = std.heap; diff --git a/clap/comptime.zig b/clap/comptime.zig index 1050861..bc6907a 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig @@ -82,8 +82,8 @@ pub fn ComptimeClap( if (multis.len != 0) try multis[param.id].append(arg.value.?); } else { - debug.assert(res.flags.len() != 0); - if (res.flags.len() != 0) + debug.assert(res.flags.len != 0); + if (res.flags.len != 0) res.flags.set(param.id, 1); } } -- cgit v1.2.3 From 844c9370bcecf063daff697f296d6ae979190649 Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Mon, 11 Oct 2021 09:16:56 +0200 Subject: Fix regression in last commit The importing of builtin was already fixed, so the latest commit applied this fix again, which caused problems --- build.zig | 1 - clap/args.zig | 1 - 2 files changed, 2 deletions(-) diff --git a/build.zig b/build.zig index 19204c7..9b1c0ce 100644 --- a/build.zig +++ b/build.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const Builder = std.build.Builder; diff --git a/clap/args.zig b/clap/args.zig index dd97d24..a6be833 100644 --- a/clap/args.zig +++ b/clap/args.zig @@ -1,6 +1,5 @@ const builtin = @import("builtin"); const std = @import("std"); -const builtin = @import("builtin"); const debug = std.debug; const heap = std.heap; -- cgit v1.2.3 From cf8a34d11f0520bdf2afc08eda88862597a88b23 Mon Sep 17 00:00:00 2001 From: Asherah Connor Date: Mon, 6 Dec 2021 20:18:55 +1100 Subject: zig master updates: allocator changes (#60) --- clap.zig | 4 ++-- clap/args.zig | 10 +++++----- clap/comptime.zig | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clap.zig b/clap.zig index 69be5bd..8b2357b 100644 --- a/clap.zig +++ b/clap.zig @@ -337,7 +337,7 @@ pub const ParseOptions = struct { /// `parse`, `parseEx` does not wrap the allocator so the heap allocator can be /// quite expensive. (TODO: Can we pick a better default? For `parse`, this allocator /// is fine, as it wraps it in an arena) - allocator: *mem.Allocator = heap.page_allocator, + allocator: mem.Allocator = heap.page_allocator, diagnostic: ?*Diagnostic = null, }; @@ -350,7 +350,7 @@ pub fn parse( var iter = try args.OsIterator.init(opt.allocator); const clap = try parseEx(Id, params, &iter, .{ // Let's reuse the arena from the `OSIterator` since we already have it. - .allocator = &iter.arena.allocator, + .allocator = iter.arena.allocator(), .diagnostic = opt.diagnostic, }); diff --git a/clap/args.zig b/clap/args.zig index a6be833..16299c8 100644 --- a/clap/args.zig +++ b/clap/args.zig @@ -57,7 +57,7 @@ pub const OsIterator = struct { /// return an error when we have no exe. exe_arg: ?[:0]const u8, - pub fn init(allocator: *mem.Allocator) Error!OsIterator { + pub fn init(allocator: mem.Allocator) Error!OsIterator { var res = OsIterator{ .arena = heap.ArenaAllocator.init(allocator), .args = process.args(), @@ -73,7 +73,7 @@ pub const OsIterator = struct { pub fn next(iter: *OsIterator) Error!?[:0]const u8 { if (builtin.os.tag == .windows) { - return try iter.args.next(&iter.arena.allocator) orelse return null; + return try iter.args.next(iter.arena.allocator()) orelse return null; } else { return iter.args.nextPosix(); } @@ -91,7 +91,7 @@ pub const ShellIterator = struct { arena: heap.ArenaAllocator, str: []const u8, - pub fn init(allocator: *mem.Allocator, str: []const u8) ShellIterator { + pub fn init(allocator: mem.Allocator, str: []const u8) ShellIterator { return .{ .arena = heap.ArenaAllocator.init(allocator), .str = str, @@ -106,7 +106,7 @@ pub const ShellIterator = struct { // Whenever possible, this iterator will return slices into `str` instead of // allocating. Sometimes this is not possible, for example, escaped characters // have be be unescape, so we need to allocate in this case. - var list = std.ArrayList(u8).init(&iter.arena.allocator); + var list = std.ArrayList(u8).init(iter.arena.allocator()); var start: usize = 0; var state: enum { skip_whitespace, @@ -274,7 +274,7 @@ pub const ShellIterator = struct { fn testShellIteratorOk(str: []const u8, allocations: usize, expect: []const []const u8) !void { var allocator = testing.FailingAllocator.init(testing.allocator, allocations); - var it = ShellIterator.init(&allocator.allocator, str); + var it = ShellIterator.init(allocator.allocator(), str); defer it.deinit(); for (expect) |e| { diff --git a/clap/comptime.zig b/clap/comptime.zig index bc6907a..b440004 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig @@ -41,7 +41,7 @@ pub fn ComptimeClap( single_options_is_set: std.PackedIntArray(u1, single_options), flags: std.PackedIntArray(u1, flags), pos: []const []const u8, - allocator: *mem.Allocator, + allocator: mem.Allocator, pub fn parse(iter: anytype, opt: clap.ParseOptions) !@This() { const allocator = opt.allocator; -- cgit v1.2.3