diff options
| author | 2021-06-24 17:20:00 +0200 | |
|---|---|---|
| committer | 2021-06-24 17:20:00 +0200 | |
| commit | 6406e5af893e2a5acdcb346e47d89454d0300b8a (patch) | |
| tree | ddbf8c835fd0bc426edbce247818e4a20668d63d | |
| parent | Tag `0.4.0` (diff) | |
| download | zig-clap-6406e5af893e2a5acdcb346e47d89454d0300b8a.tar.gz zig-clap-6406e5af893e2a5acdcb346e47d89454d0300b8a.tar.xz zig-clap-6406e5af893e2a5acdcb346e47d89454d0300b8a.zip | |
parse: Copy in arena after using it in parseEx
fixes #43
| -rw-r--r-- | clap.zig | 20 |
1 files changed, 9 insertions, 11 deletions
| @@ -293,19 +293,17 @@ pub fn parse( | |||
| 293 | opt: ParseOptions, | 293 | opt: ParseOptions, |
| 294 | ) !Args(Id, params) { | 294 | ) !Args(Id, params) { |
| 295 | var iter = try args.OsIterator.init(opt.allocator); | 295 | var iter = try args.OsIterator.init(opt.allocator); |
| 296 | var res = Args(Id, params){ | 296 | const clap = try parseEx(Id, params, &iter, .{ |
| 297 | .arena = iter.arena, | 297 | // Let's reuse the arena from the `OSIterator` since we already have it. |
| 298 | .exe_arg = iter.exe_arg, | 298 | .allocator = &iter.arena.allocator, |
| 299 | .clap = undefined, | ||
| 300 | }; | ||
| 301 | |||
| 302 | // Let's reuse the arena from the `OSIterator` since we already have | ||
| 303 | // it. | ||
| 304 | res.clap = try parseEx(Id, params, &iter, .{ | ||
| 305 | .allocator = &res.arena.allocator, | ||
| 306 | .diagnostic = opt.diagnostic, | 299 | .diagnostic = opt.diagnostic, |
| 307 | }); | 300 | }); |
| 308 | return res; | 301 | |
| 302 | return Args(Id, params){ | ||
| 303 | .exe_arg = iter.exe_arg, | ||
| 304 | .arena = iter.arena, | ||
| 305 | .clap = clap, | ||
| 306 | }; | ||
| 309 | } | 307 | } |
| 310 | 308 | ||
| 311 | /// Parses the command line arguments passed into the program based on an | 309 | /// Parses the command line arguments passed into the program based on an |