Add compile-time switch for OTP-20 string funcs
Allows support for Unicode data, and prevents compile warnings that will start with OTP-20.
This commit is contained in:
parent
fa1ec76a9b
commit
f8f72b7cc5
4 changed files with 28 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
||||||
{platform_define, "^R1[4|5]", deprecated_crypto},
|
{platform_define, "^R1[4|5]", deprecated_crypto},
|
||||||
{platform_define, "^1[8|9]", rand_module},
|
{platform_define, "^1[8|9]", rand_module},
|
||||||
{platform_define, "^2", rand_module},
|
{platform_define, "^2", rand_module},
|
||||||
|
{platform_define, "^2", unicode_str},
|
||||||
debug_info,
|
debug_info,
|
||||||
warnings_as_errors]}.
|
warnings_as_errors]}.
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ parse(Date, Now) ->
|
||||||
do_parse(Date, Now, []).
|
do_parse(Date, Now, []).
|
||||||
|
|
||||||
do_parse(Date, Now, Opts) ->
|
do_parse(Date, Now, Opts) ->
|
||||||
case filter_hints(parse(tokenise(string:to_upper(Date), []), Now, Opts)) of
|
case filter_hints(parse(tokenise(uppercase(Date), []), Now, Opts)) of
|
||||||
{error, bad_date} ->
|
{error, bad_date} ->
|
||||||
erlang:throw({?MODULE, {bad_date, Date}});
|
erlang:throw({?MODULE, {bad_date, Date}});
|
||||||
{D1, T1} = {{Y, M, D}, {H, M1, S}}
|
{D1, T1} = {{Y, M, D}, {H, M1, S}}
|
||||||
|
@ -728,6 +728,12 @@ pad6(X) when is_integer(X) ->
|
||||||
ltoi(X) ->
|
ltoi(X) ->
|
||||||
list_to_integer(X).
|
list_to_integer(X).
|
||||||
|
|
||||||
|
-ifdef(unicode_str).
|
||||||
|
uppercase(Str) -> string:uppercase(Str).
|
||||||
|
-else.
|
||||||
|
uppercase(Str) -> string:to_upper(Str).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Tests
|
%%% Tests
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
|
@ -88,7 +88,16 @@ get_patch_count(RawRef) ->
|
||||||
parse_tags(Pattern) ->
|
parse_tags(Pattern) ->
|
||||||
Cmd = io_lib:format("git describe --abbrev=0 --match \"~s*\"", [Pattern]),
|
Cmd = io_lib:format("git describe --abbrev=0 --match \"~s*\"", [Pattern]),
|
||||||
Tag = os:cmd(Cmd),
|
Tag = os:cmd(Cmd),
|
||||||
Vsn = string:substr(Tag, string:len(Pattern) + 1),
|
Vsn = slice(Tag, len(Pattern) + 1),
|
||||||
Vsn1 = string:strip(Vsn, left, $v),
|
Vsn1 = trim(Vsn, left, $v),
|
||||||
{Tag, Vsn1}.
|
{Tag, Vsn1}.
|
||||||
|
|
||||||
|
-ifdef(unicode_str).
|
||||||
|
len(Str) -> string:length(Str).
|
||||||
|
trim(Str, Dir, Chars) -> string:trim(Str, Dir, Chars).
|
||||||
|
slice(Str, Len) -> string:slice(Str, Len).
|
||||||
|
-else.
|
||||||
|
len(Str) -> string:len(Str).
|
||||||
|
trim(Str, Dir, Chars) -> string:strip(Str, Dir, Chars).
|
||||||
|
slice(Str, Len) -> string:substr(Str, Len).
|
||||||
|
-endif.
|
||||||
|
|
|
@ -127,7 +127,7 @@ ask_convert(Prompt, TransFun, Type, Default) ->
|
||||||
Default ->
|
Default ->
|
||||||
[" (", io_lib:format("~p", [Default]) , ")"]
|
[" (", io_lib:format("~p", [Default]) , ")"]
|
||||||
end, "> "])),
|
end, "> "])),
|
||||||
Data = string:strip(string:strip(io:get_line(NewPrompt)), both, $\n),
|
Data = trim(trim(io:get_line(NewPrompt)), both, $\n),
|
||||||
Ret = TransFun(Data),
|
Ret = TransFun(Data),
|
||||||
case Ret of
|
case Ret of
|
||||||
no_data ->
|
no_data ->
|
||||||
|
@ -197,6 +197,14 @@ get_string(String) ->
|
||||||
no_clue
|
no_clue
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-ifdef(unicode_str).
|
||||||
|
trim(Str) -> string:trim(Str).
|
||||||
|
trim(Str, Dir, Chars) -> string:trim(Str, Dir, Chars).
|
||||||
|
-else.
|
||||||
|
trim(Str) -> string:strip(Str).
|
||||||
|
trim(Str, Dir, Chars) -> string:strip(Str, Dir, Chars).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%%%====================================================================
|
%%%====================================================================
|
||||||
%%% tests
|
%%% tests
|
||||||
%%%====================================================================
|
%%%====================================================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue