summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clap.zig4
-rw-r--r--clap/args.zig10
-rw-r--r--clap/comptime.zig2
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 {
337 /// `parse`, `parseEx` does not wrap the allocator so the heap allocator can be 337 /// `parse`, `parseEx` does not wrap the allocator so the heap allocator can be
338 /// quite expensive. (TODO: Can we pick a better default? For `parse`, this allocator 338 /// quite expensive. (TODO: Can we pick a better default? For `parse`, this allocator
339 /// is fine, as it wraps it in an arena) 339 /// is fine, as it wraps it in an arena)
340 allocator: *mem.Allocator = heap.page_allocator, 340 allocator: mem.Allocator = heap.page_allocator,
341 diagnostic: ?*Diagnostic = null, 341 diagnostic: ?*Diagnostic = null,
342}; 342};
343 343
@@ -350,7 +350,7 @@ pub fn parse(
350 var iter = try args.OsIterator.init(opt.allocator); 350 var iter = try args.OsIterator.init(opt.allocator);
351 const clap = try parseEx(Id, params, &iter, .{ 351 const clap = try parseEx(Id, params, &iter, .{
352 // Let's reuse the arena from the `OSIterator` since we already have it. 352 // Let's reuse the arena from the `OSIterator` since we already have it.
353 .allocator = &iter.arena.allocator, 353 .allocator = iter.arena.allocator(),
354 .diagnostic = opt.diagnostic, 354 .diagnostic = opt.diagnostic,
355 }); 355 });
356 356
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 {
57 /// return an error when we have no exe. 57 /// return an error when we have no exe.
58 exe_arg: ?[:0]const u8, 58 exe_arg: ?[:0]const u8,
59 59
60 pub fn init(allocator: *mem.Allocator) Error!OsIterator { 60 pub fn init(allocator: mem.Allocator) Error!OsIterator {
61 var res = OsIterator{ 61 var res = OsIterator{
62 .arena = heap.ArenaAllocator.init(allocator), 62 .arena = heap.ArenaAllocator.init(allocator),
63 .args = process.args(), 63 .args = process.args(),
@@ -73,7 +73,7 @@ pub const OsIterator = struct {
73 73
74 pub fn next(iter: *OsIterator) Error!?[:0]const u8 { 74 pub fn next(iter: *OsIterator) Error!?[:0]const u8 {
75 if (builtin.os.tag == .windows) { 75 if (builtin.os.tag == .windows) {
76 return try iter.args.next(&iter.arena.allocator) orelse return null; 76 return try iter.args.next(iter.arena.allocator()) orelse return null;
77 } else { 77 } else {
78 return iter.args.nextPosix(); 78 return iter.args.nextPosix();
79 } 79 }
@@ -91,7 +91,7 @@ pub const ShellIterator = struct {
91 arena: heap.ArenaAllocator, 91 arena: heap.ArenaAllocator,
92 str: []const u8, 92 str: []const u8,
93 93
94 pub fn init(allocator: *mem.Allocator, str: []const u8) ShellIterator { 94 pub fn init(allocator: mem.Allocator, str: []const u8) ShellIterator {
95 return .{ 95 return .{
96 .arena = heap.ArenaAllocator.init(allocator), 96 .arena = heap.ArenaAllocator.init(allocator),
97 .str = str, 97 .str = str,
@@ -106,7 +106,7 @@ pub const ShellIterator = struct {
106 // Whenever possible, this iterator will return slices into `str` instead of 106 // Whenever possible, this iterator will return slices into `str` instead of
107 // allocating. Sometimes this is not possible, for example, escaped characters 107 // allocating. Sometimes this is not possible, for example, escaped characters
108 // have be be unescape, so we need to allocate in this case. 108 // have be be unescape, so we need to allocate in this case.
109 var list = std.ArrayList(u8).init(&iter.arena.allocator); 109 var list = std.ArrayList(u8).init(iter.arena.allocator());
110 var start: usize = 0; 110 var start: usize = 0;
111 var state: enum { 111 var state: enum {
112 skip_whitespace, 112 skip_whitespace,
@@ -274,7 +274,7 @@ pub const ShellIterator = struct {
274 274
275fn testShellIteratorOk(str: []const u8, allocations: usize, expect: []const []const u8) !void { 275fn testShellIteratorOk(str: []const u8, allocations: usize, expect: []const []const u8) !void {
276 var allocator = testing.FailingAllocator.init(testing.allocator, allocations); 276 var allocator = testing.FailingAllocator.init(testing.allocator, allocations);
277 var it = ShellIterator.init(&allocator.allocator, str); 277 var it = ShellIterator.init(allocator.allocator(), str);
278 defer it.deinit(); 278 defer it.deinit();
279 279
280 for (expect) |e| { 280 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(
41 single_options_is_set: std.PackedIntArray(u1, single_options), 41 single_options_is_set: std.PackedIntArray(u1, single_options),
42 flags: std.PackedIntArray(u1, flags), 42 flags: std.PackedIntArray(u1, flags),
43 pos: []const []const u8, 43 pos: []const []const u8,
44 allocator: *mem.Allocator, 44 allocator: mem.Allocator,
45 45
46 pub fn parse(iter: anytype, opt: clap.ParseOptions) !@This() { 46 pub fn parse(iter: anytype, opt: clap.ParseOptions) !@This() {
47 const allocator = opt.allocator; 47 const allocator = opt.allocator;