Skip to content

Commit 44dfda8

Browse files
committed
Additional negative numbers and multiflag bugfix
1 parent 0949391 commit 44dfda8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/argsparsing.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function _split_multiflag(s::AbstractString)::Vector{String}
1212
max_i::Int = length(s) + 1
1313
i::Int = 2 # First character should always be '-'
1414
while i < max_i
15-
if s[i] == '-' # Ignore
15+
if s[i] == '-' && (i == max_i - 1 || (!isdigit(s[i+1]) && s[i+1] !== '.')) # Ignore
1616
i += 1
17-
elseif isdigit(s[i]) # Allow numbers inside group of flags with no space or =
17+
elseif isdigit(s[i]) || s[i] === '-' || s[i] === '.' # Allow numbers inside group of flags with no space or =
1818
nextletter::Int = something(findnext((c -> isletter(c) || c == '-'), s, i + 1), max_i)
1919
push!(splitflags, s[i:nextletter - 1])
2020
i = nextletter
@@ -38,7 +38,8 @@ function _split_arguments(args::Vector{String})::Vector{String}
3838
arg_split = split(arg, '=', limit=2)::Vector{SubString{String}}
3939

4040
# Handle chained flags or flags with Int values like "-xzfv" or "-O3"
41-
if length(arg_split[1]) > 2 && arg_split[1][2] != '-'
41+
# But do not mess up negative numbers
42+
if length(arg_split[1]) > 2 && arg_split[1][2] !== '-' && arg_split[1][2] !== '.' && !isdigit(arg_split[1][2])
4243
append!(splitargs, _split_multiflag(arg_split[1]))
4344

4445
if length(arg_split) == 2

0 commit comments

Comments
 (0)