diff options
| author | 2021-12-06 20:18:55 +1100 | |
|---|---|---|
| committer | 2021-12-06 10:18:55 +0100 | |
| commit | cf8a34d11f0520bdf2afc08eda88862597a88b23 (patch) | |
| tree | 399d4fdb50ff8ee20cb0f8e30ea9d811421abf14 /clap/args.zig | |
| parent | Fix regression in last commit (diff) | |
| download | zig-clap-cf8a34d11f0520bdf2afc08eda88862597a88b23.tar.gz zig-clap-cf8a34d11f0520bdf2afc08eda88862597a88b23.tar.xz zig-clap-cf8a34d11f0520bdf2afc08eda88862597a88b23.zip | |
zig master updates: allocator changes (#60)
Diffstat (limited to 'clap/args.zig')
| -rw-r--r-- | clap/args.zig | 10 |
1 files changed, 5 insertions, 5 deletions
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 | ||
| 275 | fn testShellIteratorOk(str: []const u8, allocations: usize, expect: []const []const u8) !void { | 275 | fn 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| { |