Skip to content

Commit 1cebe34

Browse files
committed
More fixes for julia 0.7 compatibility
new iterator protocol, isletter, coalesce->something
1 parent 224ce77 commit 1cebe34

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.6
2-
Compat 0.62.0
2+
Compat 0.67.0
33
TextWrap 0.1.4

src/ArgParse.jl

+13-7
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ end
163163
function check_prefix_chars(chars)
164164
result = Set{Char}()
165165
for c in chars
166-
if isalpha(c) || isnumeric(c) || c == '-'
166+
if isletter(c) || isnumeric(c) || c == '-'
167167
throw(ArgParseError("$(c)’ is not allowed as prefix character"))
168168
end
169169
push!(result, c)
@@ -1663,6 +1663,7 @@ function usage_string(settings::ArgParseSettings)
16631663
str_wrapped = wrap(str_nonwrapped, break_long_words = false, break_on_hyphens = false,
16641664
subsequent_indent = min(usage_len, lc_len_limit))
16651665

1666+
16661667
out_str = replace(str_wrapped, nbspc => ' ')
16671668
return out_str
16681669
end
@@ -1938,7 +1939,7 @@ function preparse(c::Channel, state::ParserState, settings::ArgParseSettings)
19381939
popfirst!(args_list)
19391940
continue
19401941
elseif startswith(arg, "--")
1941-
eq = coalesce(findfirst(isequal('='), arg), 0)
1942+
eq = something(findfirst(isequal('='), arg), 0)
19421943
if eq 0
19431944
opt_name = arg[3:prevind(arg,eq)]
19441945
arg_after_eq = arg[nextind(arg,eq):end]
@@ -2237,16 +2238,21 @@ function parse_long_opt(state::ParserState, settings::ArgParseSettings)
22372238
end
22382239
#}}}
22392240

2241+
if VERSION < v"0.7.0-DEV.5126" # TODO: remove after 0.6 support is dropped
2242+
# very crude hack to avoid deprecation warning
2243+
const iterate = next
2244+
end
2245+
22402246
# parse short opts
22412247
#{{{
22422248
function parse_short_opt(state::ParserState, settings::ArgParseSettings)
22432249
shopts_lst = state.token
22442250
rest_as_arg = nothing
2245-
sind = start(shopts_lst)
2246-
while !done(shopts_lst, sind)
2247-
opt_char, next_sind = next(shopts_lst, sind)
2248-
if !done(shopts_lst, next_sind)
2249-
next_opt_char, next2_sind = next(shopts_lst, next_sind)
2251+
sind = firstindex(shopts_lst)
2252+
while sind ncodeunits(shopts_lst)
2253+
opt_char, next_sind = iterate(shopts_lst, sind)
2254+
if next_sind ncodeunits(shopts_lst)
2255+
next_opt_char, next2_sind = iterate(shopts_lst, next_sind)
22502256
if next_opt_char == '='
22512257
next_is_eq = true
22522258
rest_as_arg = shopts_lst[next2_sind:end]

0 commit comments

Comments
 (0)