Codebase list erlang-getopt / fe027dc
Merge pull request #37 from ferd/otp-21-unicode Support OTP-21's unicode-only constraints Juan Jose Comellas authored 6 years ago GitHub committed 6 years ago
3 changed file(s) with 20 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
1010 warn_export_vars,
1111 warn_exported_vars,
1212 warn_missing_spec,
13 warn_untyped_record, debug_info]}.
13 warn_untyped_record, debug_info,
14 {platform_define, "^2", unicode_str}
15 ]}.
1416 {xref_checks, [undefined_function_calls]}.
441441 to_type(float, Arg) ->
442442 list_to_float(Arg);
443443 to_type(boolean, Arg) ->
444 LowerArg = string:to_lower(Arg),
444 LowerArg = lowercase(Arg),
445445 case is_arg_true(LowerArg) of
446446 true ->
447447 true;
499499
500500 -spec is_boolean_arg(string()) -> boolean().
501501 is_boolean_arg(Arg) ->
502 LowerArg = string:to_lower(Arg),
502 LowerArg = lowercase(Arg),
503503 is_arg_true(LowerArg) orelse is_arg_false(LowerArg).
504504
505505
618618 %% already wrapped according to the maximum MaxLineLength.
619619 -spec usage_cmd_line_options(MaxLineLength :: non_neg_integer(), [option_spec()], CmdLineTail :: string()) -> iolist().
620620 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, []).
622622
623623 usage_cmd_line_options(MaxLineLength, [OptSpec | Tail], LineAcc, LineAccLength, Acc) ->
624624 Option = [$\s | lists:flatten(usage_cmd_line_option(OptSpec))],
789789 %% Look for the first whitespace character in the current (reversed) line
790790 %% buffer to get a wrapped line. If there is no whitespace just cut the
791791 %% 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
793793 WhitespacePos when WhitespacePos < Count ->
794794 lists:split(WhitespacePos, CurrentLineAcc);
795795 _ ->
932932 atom_to_list(Atom);
933933 to_string(Value) ->
934934 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