441 | 441 |
to_type(float, Arg) ->
|
442 | 442 |
list_to_float(Arg);
|
443 | 443 |
to_type(boolean, Arg) ->
|
444 | |
LowerArg = string:to_lower(Arg),
|
|
444 |
LowerArg = lowercase(Arg),
|
445 | 445 |
case is_arg_true(LowerArg) of
|
446 | 446 |
true ->
|
447 | 447 |
true;
|
|
499 | 499 |
|
500 | 500 |
-spec is_boolean_arg(string()) -> boolean().
|
501 | 501 |
is_boolean_arg(Arg) ->
|
502 | |
LowerArg = string:to_lower(Arg),
|
|
502 |
LowerArg = lowercase(Arg),
|
503 | 503 |
is_arg_true(LowerArg) orelse is_arg_false(LowerArg).
|
504 | 504 |
|
505 | 505 |
|
|
618 | 618 |
%% already wrapped according to the maximum MaxLineLength.
|
619 | 619 |
-spec usage_cmd_line_options(MaxLineLength :: non_neg_integer(), [option_spec()], CmdLineTail :: string()) -> iolist().
|
620 | 620 |
usage_cmd_line_options(MaxLineLength, OptSpecList, CmdLineTail) ->
|
621 | |
usage_cmd_line_options(MaxLineLength, OptSpecList ++ string:tokens(CmdLineTail, " "), [], 0, []).
|
|
621 |
usage_cmd_line_options(MaxLineLength, OptSpecList ++ lexemes(CmdLineTail, " "), [], 0, []).
|
622 | 622 |
|
623 | 623 |
usage_cmd_line_options(MaxLineLength, [OptSpec | Tail], LineAcc, LineAccLength, Acc) ->
|
624 | 624 |
Option = [$\s | lists:flatten(usage_cmd_line_option(OptSpec))],
|
|
789 | 789 |
%% Look for the first whitespace character in the current (reversed) line
|
790 | 790 |
%% buffer to get a wrapped line. If there is no whitespace just cut the
|
791 | 791 |
%% line at the position corresponding to the maximum length.
|
792 | |
{NextLineAcc, WrappedLine} = case string:cspan(CurrentLineAcc, " \t") of
|
|
792 |
{NextLineAcc, WrappedLine} = case cspan(CurrentLineAcc, " \t") of
|
793 | 793 |
WhitespacePos when WhitespacePos < Count ->
|
794 | 794 |
lists:split(WhitespacePos, CurrentLineAcc);
|
795 | 795 |
_ ->
|
|
932 | 932 |
atom_to_list(Atom);
|
933 | 933 |
to_string(Value) ->
|
934 | 934 |
io_lib:format("~p", [Value]).
|
|
935 |
|
|
936 |
%% OTP-20/21 conversion to unicode string module
|
|
937 |
-ifdef(unicode_str).
|
|
938 |
lowercase(Str) -> string:lowercase(Str).
|
|
939 |
lexemes(Str, Separators) -> string:lexemes(Str, Separators).
|
|
940 |
cspan(Str, Chars) -> length(element(1,string:take(Str, Chars, true))).
|
|
941 |
-else.
|
|
942 |
lowercase(Str) -> string:to_lower(Str).
|
|
943 |
lexemes(Str, Separators) -> string:tokens(Str, Separators).
|
|
944 |
cspan(Str, Chars) -> string:cspan(Str, Chars).
|
|
945 |
-endif.
|
|
946 |
|