1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v2: minor fixes

This commit is contained in:
Alexander Medvednikov
2020-03-27 08:46:54 +01:00
parent 883a105aca
commit db59c621e8
8 changed files with 91 additions and 74 deletions

View File

@ -86,10 +86,7 @@ fn parse_flags(flag string, f mut flag.Instance, prefs mut flag.MainCmdPreferenc
exit(1)
}
else {
if flag in list_of_flags_that_allow_duplicates {
f.allow_duplicate()
}
prefs.unknown_flag = '-$flag'
prefs.unknown_flag = '-$flag'
if !(flag in list_of_flags_with_param) {
return
}

View File

@ -22,8 +22,6 @@ fn parse_c_options(flag string, f mut flag.Instance, prefs mut pref.Preferences)
exit(1)
}
prefs.ccompiler = tmp
// needed to enable CI compiling of -live examples.
f.allow_duplicate()
}
'cg', 'cdebug' {
f.is_equivalent_to(['cg', 'cdebug', 'g', 'debug'])
@ -60,7 +58,6 @@ fn parse_c_options(flag string, f mut flag.Instance, prefs mut pref.Preferences)
prefs.sanitize = f.bool()
}
'cf', 'cflags' {
f.allow_duplicate()
cflag := f.string() or {
println('V error: Expected argument after `-$flag`.')
exit(1)

View File

@ -90,7 +90,6 @@ fn parse_options(flag string, f mut flag.Instance, prefs mut pref.Preferences) {
prefs.out_name = tmp
}
'd', 'define' {
f.allow_duplicate()
define := f.string() or {
println('V error: Expected argument for `-$flag`.')
exit(1)
@ -105,7 +104,6 @@ fn parse_options(flag string, f mut flag.Instance, prefs mut pref.Preferences) {
}
}
'e', 'experiments' {
f.allow_duplicate()
to_enable := f.string() or {
println('V error: Expected argument for `-$flag`.')
exit(1)

View File

@ -44,11 +44,6 @@ fn (p mut Instance) parse_impl(args []string, value voidptr, callback void_cb) ?
p.equal_val = ''
flag_name = next[1..]
}
if p.encountered[flag_name] {
// Duplicate flags are opt-in
// This can be prevented with p.allow_duplicate()
return error('Duplicate flag: -$flag_name')
}
p.encountered[flag_name] = true
p.current_flag = flag_name
callback(flag_name, p, value)
@ -115,10 +110,6 @@ pub fn (p mut Instance) bool() bool {
return true
}
pub fn (p mut Instance) allow_duplicate() {
p.encountered[p.current_flag] = false
}
pub fn (p mut Instance) is_equivalent_to(flags []string) {
for v in flags {
p.encountered[v] = true