Skip to content

Commit

Permalink
fix: Fix sources for the new V compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Nov 16, 2024
1 parent 412960f commit 0033546
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/analyse.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/parse.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down Expand Up @@ -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}"')
}
Expand Down Expand Up @@ -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}"')
}
Expand Down
4 changes: 2 additions & 2 deletions src/parse_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn test_positives() {
Options:
-B
', Input{
args: ['-B']
args: ['-B']
disable_short_negative: true
})!
assert opts.b == true
Expand Down Expand Up @@ -338,7 +338,7 @@ fn test_no_overflow() {
Options:
--u8 <num>
', Input{
args: ['--u8=1234']
args: ['--u8=1234']
ignore_number_overflow: true
})!
assert opts.u8 == u8(210)
Expand Down

0 comments on commit 0033546

Please sign in to comment.