From 003354680ebca5d4a52fb725a0bfeb2cc1ae93bd Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Sat, 16 Nov 2024 05:12:21 +0100 Subject: [PATCH] fix: Fix sources for the new V compiler --- src/analyse.v | 16 ++++++++-------- src/parse.v | 6 +++--- src/parse_test.v | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/analyse.v b/src/analyse.v index 9e990d2..9e856c9 100644 --- a/src/analyse.v +++ b/src/analyse.v @@ -25,7 +25,7 @@ fn analyse_usage(text string, anywhere bool, no_negative bool) []Opt { break } if re_def.matches_string(line) { - cargs.d.log('option matched: "%s"', line) + d.log('option matched: "%s"', line) grp_opt := re_def.get_group_list() mut opt := Opt{} if grp_opt[0].start >= 0 { @@ -40,25 +40,25 @@ fn analyse_usage(text string, anywhere bool, no_negative bool) []Opt { if !no_negative && opt.long.starts_with('no-') { orig_name := opt.long opt.long = opt.long[3..] - cargs.d.log('option short: "%s", long: "%s" (originally "%s"), value: "%s"', + d.log('option short: "%s", long: "%s" (originally "%s"), value: "%s"', opt.short, opt.long, orig_name, opt.val) } else { - cargs.d.log('option short: "%s", long: "%s", value: "%s"', opt.short, - opt.long, opt.val) + d.log('option short: "%s", long: "%s", value: "%s"', opt.short, opt.long, + opt.val) } opts << opt } else { - cargs.d.log('option not matched: "%s"', line) + d.log('option not matched: "%s"', line) } } else if line.contains('Options:') { in_opts = true } } - if cargs.d.is_enabled() { + if d.is_enabled() { if opts.len == 0 { - cargs.d.log_str('no options detected') + d.log_str('no options detected') } else { - cargs.d.log('%d options detected', opts.len) + d.log('%d options detected', opts.len) } } return opts diff --git a/src/parse.v b/src/parse.v index b50f44a..ed5fbe5 100644 --- a/src/parse.v +++ b/src/parse.v @@ -31,7 +31,7 @@ const re_opt = unsafe { &RegEx(nil) } fn init() { unsafe { - cargs.re_opt = pcre_compile(r'^-(?:([^\-])|-([^ =]+))(?:\s*=(.+))?$', 0) or { panic(err) } + re_opt = pcre_compile(r'^-(?:([^\-])|-([^ =]+))(?:\s*=(.+))?$', 0) or { panic(err) } } } @@ -89,7 +89,7 @@ pub fn parse_scanned_to[T](scanned &Scanned, input &Input, mut cfg T) ![]string else {} } - m := cargs.re_opt.exec(arg, 0) or { + m := re_opt.exec(arg, 0) or { if err is NoMatch { return error('invalid argument "${arg}"') } @@ -210,7 +210,7 @@ fn get_arg(scanned &Scanned, opt &Opt) !string { } if arg.len > 1 && arg[0] == `-` { - m := cargs.re_opt.exec(arg, 0) or { + m := re_opt.exec(arg, 0) or { if err is NoMatch { return error('invalid argument "${arg}"') } diff --git a/src/parse_test.v b/src/parse_test.v index bb6c754..22003c6 100644 --- a/src/parse_test.v +++ b/src/parse_test.v @@ -282,7 +282,7 @@ fn test_positives() { Options: -B ', Input{ - args: ['-B'] + args: ['-B'] disable_short_negative: true })! assert opts.b == true @@ -338,7 +338,7 @@ fn test_no_overflow() { Options: --u8 ', Input{ - args: ['--u8=1234'] + args: ['--u8=1234'] ignore_number_overflow: true })! assert opts.u8 == u8(210)