diff options
author | Hans Bolinder <[email protected]> | 2017-05-30 15:53:09 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-06-09 09:11:14 +0200 |
commit | 6d80a38c876831aa141b58e757fbdf5663026f95 (patch) | |
tree | cd74a21595b5674f3a3749c73713f70deb58b9f3 /lib/dialyzer/src/dialyzer_cl.erl | |
parent | 3e7e60b8de877de014467eec488038b89fe41a9d (diff) | |
download | otp-6d80a38c876831aa141b58e757fbdf5663026f95.tar.gz otp-6d80a38c876831aa141b58e757fbdf5663026f95.tar.bz2 otp-6d80a38c876831aa141b58e757fbdf5663026f95.zip |
dialyzer: Improve handling of Unicode
Diffstat (limited to 'lib/dialyzer/src/dialyzer_cl.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_cl.erl | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/dialyzer/src/dialyzer_cl.erl b/lib/dialyzer/src/dialyzer_cl.erl index 8500c59ebe..d72ae1dc86 100644 --- a/lib/dialyzer/src/dialyzer_cl.erl +++ b/lib/dialyzer/src/dialyzer_cl.erl @@ -77,7 +77,7 @@ init_opts_for_build(Opts) -> [] -> Opts#options{output_plt = get_default_output_plt()}; [Plt] -> Opts#options{init_plts = [], output_plt = Plt}; Plts -> - Msg = io_lib:format("Could not build multiple PLT files: ~s\n", + Msg = io_lib:format("Could not build multiple PLT files: ~ts\n", [format_plts(Plts)]), cl_error(Msg) end; @@ -99,7 +99,7 @@ init_opts_for_add(Opts) -> init_plts = get_default_init_plt()}; [Plt] -> Opts#options{output_plt = Plt}; Plts -> - Msg = io_lib:format("Could not add to multiple PLT files: ~s\n", + Msg = io_lib:format("Could not add to multiple PLT files: ~ts\n", [format_plts(Plts)]), cl_error(Msg) end; @@ -165,7 +165,7 @@ init_opts_for_remove(Opts) -> init_plts = get_default_init_plt()}; [Plt] -> Opts#options{output_plt = Plt}; Plts -> - Msg = io_lib:format("Could not remove from multiple PLT files: ~s\n", + Msg = io_lib:format("Could not remove from multiple PLT files: ~ts\n", [format_plts(Plts)]), cl_error(Msg) end; @@ -212,19 +212,19 @@ plt_common(#options{init_plts = [InitPlt]} = Opts, RemoveFiles, AddFiles) -> do_analysis(AnalFiles, Opts, Plt, {Md5, ModDeps1}) end; {error, no_such_file} -> - Msg = io_lib:format("Could not find the PLT: ~s\n~s", + Msg = io_lib:format("Could not find the PLT: ~ts\n~s", [InitPlt, default_plt_error_msg()]), cl_error(Msg); {error, not_valid} -> - Msg = io_lib:format("The file: ~s is not a valid PLT file\n~s", + Msg = io_lib:format("The file: ~ts is not a valid PLT file\n~s", [InitPlt, default_plt_error_msg()]), cl_error(Msg); {error, read_error} -> - Msg = io_lib:format("Could not read the PLT: ~s\n~s", + Msg = io_lib:format("Could not read the PLT: ~ts\n~s", [InitPlt, default_plt_error_msg()]), cl_error(Msg); {error, {no_file_to_remove, F}} -> - Msg = io_lib:format("Could not remove the file ~s from the PLT: ~s\n", + Msg = io_lib:format("Could not remove the file ~ts from the PLT: ~ts\n", [F, InitPlt]), cl_error(Msg) end. @@ -264,7 +264,7 @@ report_check(#options{report_mode = ReportMode, init_plts = [InitPlt]}) -> case ReportMode of quiet -> ok; _ -> - io:format(" Checking whether the PLT ~s is up-to-date...", [InitPlt]) + io:format(" Checking whether the PLT ~ts is up-to-date...", [InitPlt]) end. report_old_version(#options{report_mode = ReportMode, init_plts = [InitPlt]}) -> @@ -272,7 +272,7 @@ report_old_version(#options{report_mode = ReportMode, init_plts = [InitPlt]}) -> quiet -> ok; _ -> io:put_chars(" no\n"), - io:format(" (the PLT ~s was built with an old version of Dialyzer)\n", + io:format(" (the PLT ~ts was built with an old version of Dialyzer)\n", [InitPlt]) end. @@ -300,19 +300,19 @@ report_analysis_start(#options{analysis_type = Type, plt_add -> [InitPlt] = InitPlts, case InitPlt =:= OutputPlt of - true -> io:format("Adding information to ~s...", [OutputPlt]); - false -> io:format("Adding information from ~s to ~s...", + true -> io:format("Adding information to ~ts...", [OutputPlt]); + false -> io:format("Adding information from ~ts to ~ts...", [InitPlt, OutputPlt]) end; plt_build -> - io:format("Creating PLT ~s ...", [OutputPlt]); + io:format("Creating PLT ~ts ...", [OutputPlt]); plt_check -> - io:format("Rebuilding the information in ~s...", [OutputPlt]); + io:format("Rebuilding the information in ~ts...", [OutputPlt]); plt_remove -> [InitPlt] = InitPlts, case InitPlt =:= OutputPlt of - true -> io:format("Removing information from ~s...", [OutputPlt]); - false -> io:format("Removing information from ~s to ~s...", + true -> io:format("Removing information from ~ts...", [OutputPlt]); + false -> io:format("Removing information from ~ts to ~ts...", [InitPlt, OutputPlt]) end; succ_typings -> io:format("Proceeding with analysis...") @@ -420,7 +420,7 @@ assert_writable(PltFile) -> case check_if_writable(PltFile) of true -> ok; false -> - Msg = io_lib:format(" The PLT file ~s is not writable", [PltFile]), + Msg = io_lib:format(" The PLT file ~ts is not writable", [PltFile]), cl_error(Msg) end. @@ -596,9 +596,11 @@ init_output(State0, #options{output_file = OutFile, false -> case file:open(OutFile, [write]) of {ok, File} -> + %% Warnings and errors can include Unicode characters. + ok = io:setopts(File, [{encoding, unicode}]), State#cl_state{output = File}; {error, Reason} -> - Msg = io_lib:format("Could not open output file ~p, Reason: ~p\n", + Msg = io_lib:format("Could not open output file ~tp, Reason: ~p\n", [OutFile, Reason]), cl_error(State, lists:flatten(Msg)) end @@ -687,7 +689,7 @@ cl_error(Msg) -> cl_error(State, Msg) -> case State#cl_state.output of standard_io -> ok; - Outfile -> io:format(Outfile, "\n~s\n", [Msg]) + Outfile -> io:format(Outfile, "\n~ts\n", [Msg]) end, maybe_close_output_file(State), throw({dialyzer_error, lists:flatten(Msg)}). @@ -792,7 +794,7 @@ print_ext_calls(#cl_state{output = Output, end. do_print_ext_calls(Output, [{M,F,A}|T], Before) -> - io:format(Output, "~s~p:~p/~p\n", [Before,M,F,A]), + io:format(Output, "~s~tp:~tp/~p\n", [Before,M,F,A]), do_print_ext_calls(Output, T, Before); do_print_ext_calls(_, [], _) -> ok. @@ -825,7 +827,7 @@ print_ext_types(#cl_state{output = Output, end. do_print_ext_types(Output, [{M,F,A}|T], Before) -> - io:format(Output, "~s~p:~p/~p\n", [Before,M,F,A]), + io:format(Output, "~s~tp:~tp/~p\n", [Before,M,F,A]), do_print_ext_types(Output, T, Before); do_print_ext_types(_, [], _) -> ok. @@ -844,10 +846,10 @@ print_warnings(#cl_state{output = Output, formatted -> [dialyzer:format_warning(W, FOpt) || W <- PrWarnings]; raw -> - [io_lib:format("~p. \n", + [io_lib:format("~tp. \n", [W]) || W <- set_warning_id(PrWarnings)] end, - io:format(Output, "\n~s", [S]) + io:format(Output, "\n~ts", [S]) end. -spec process_warnings([raw_warning()]) -> [raw_warning()]. |