diff options
| author | 2021-06-24 17:20:53 +0200 | |
|---|---|---|
| committer | 2021-06-24 17:20:53 +0200 | |
| commit | fb2ee06520e3620b8e711e79d45329ff2dc076a1 (patch) | |
| tree | ec51c6cdfdaf66c08d09b833e9aa08898dbb73f5 | |
| parent | parse: Copy in arena after using it in parseEx (diff) | |
| download | zig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.tar.gz zig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.tar.xz zig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.zip | |
parseParam: Set eval quota to std.math.maxInt(u32)
fixes #42 related #39
| -rw-r--r-- | clap.zig | 10 |
1 files changed, 10 insertions, 0 deletions
| @@ -63,6 +63,16 @@ pub fn Param(comptime Id: type) type { | |||
| 63 | /// Takes a string and parses it to a Param(Help). | 63 | /// Takes a string and parses it to a Param(Help). |
| 64 | /// This is the reverse of 'help' but for at single parameter only. | 64 | /// This is the reverse of 'help' but for at single parameter only. |
| 65 | pub fn parseParam(line: []const u8) !Param(Help) { | 65 | pub fn parseParam(line: []const u8) !Param(Help) { |
| 66 | // This function become a lot less ergonomic to use once you hit the eval branch quota. To | ||
| 67 | // avoid this we pick a sane default. Sadly, the only sane default is the biggest possible | ||
| 68 | // value. If we pick something a lot smaller and a user hits the quota after that, they have | ||
| 69 | // no way of overriding it, since we set it here. | ||
| 70 | // We can recosider this again if: | ||
| 71 | // * We get parseParams: https://github.com/Hejsil/zig-clap/issues/39 | ||
| 72 | // * We get a larger default branch quota in the zig compiler (stage 2). | ||
| 73 | // * Someone points out how this is a really bad idea. | ||
| 74 | @setEvalBranchQuota(std.math.maxInt(u32)); | ||
| 75 | |||
| 66 | var found_comma = false; | 76 | var found_comma = false; |
| 67 | var it = mem.tokenize(line, " \t"); | 77 | var it = mem.tokenize(line, " \t"); |
| 68 | var param_str = it.next() orelse return error.NoParamFound; | 78 | var param_str = it.next() orelse return error.NoParamFound; |