From 8aebe008eba3152b37858822df4fdb4f0b51e0b9 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 1 Aug 2011 20:50:22 +0200 Subject: leex: honour -Werror passed from erlc --- lib/parsetools/src/leex.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index 942e9928b1..e3e10eb204 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -73,12 +73,15 @@ %%% Interface to erl_compile. compile(Input0, Output0, - #options{warning = WarnLevel, verbose=Verbose, includes=Includes}) -> + #options{warning = WarnLevel, verbose=Verbose, includes=Includes, + specific=Specific}) -> Input = assure_extension(shorten_filename(Input0), ".xrl"), Output = assure_extension(shorten_filename(Output0), ".erl"), Includefile = lists:sublist(Includes, 1), + Werr = proplists:get_bool(warnings_as_errors, Specific), Opts = [{scannerfile,Output},{includefile,Includefile},{verbose,Verbose}, - {report_errors,true},{report_warnings,WarnLevel > 0}], + {report_errors,true},{report_warnings,WarnLevel > 0}, + {warnings_as_errors, Werr}], case file(Input, Opts) of {ok, _} -> ok; -- cgit v1.2.3 From 48de2c2182e703c07d67471db3e2f154cc5df99e Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 1 Aug 2011 21:04:49 +0200 Subject: yecc: honour -Werror passed from erlc --- lib/parsetools/src/yecc.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index 72cff3af92..d714420680 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -133,12 +133,15 @@ %%% Interface to erl_compile. compile(Input0, Output0, - #options{warning = WarnLevel, verbose=Verbose, includes=Includes}) -> + #options{warning = WarnLevel, verbose=Verbose, includes=Includes, + specific=Specific}) -> Input = shorten_filename(Input0), Output = shorten_filename(Output0), Includefile = lists:sublist(Includes, 1), + Werr = proplists:get_bool(warnings_as_errors, Specific), Opts = [{parserfile,Output}, {includefile,Includefile}, {verbose,Verbose}, - {report_errors, true}, {report_warnings, WarnLevel > 0}], + {report_errors, true}, {report_warnings, WarnLevel > 0}, + {warnings_as_errors, Werr}], case file(Input, Opts) of {ok, _OutFile} -> ok; -- cgit v1.2.3 From 089df2b89969353229093ac56665f1b52d87ce09 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 2 Aug 2011 16:40:57 +0200 Subject: leex: log warnings as errors if -Werror is enabled --- lib/parsetools/src/leex.erl | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index e3e10eb204..ca010e09f0 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -307,15 +307,24 @@ report_errors(St) -> end, report_errors, St#leex.opts). report_warnings(St) -> - when_opt(fun () -> - foreach(fun({File,{none,Mod,W}}) -> - io:fwrite("~s: Warning: ~s\n", - [File,Mod:format_error(W)]); - ({File,{Line,Mod,W}}) -> - io:fwrite("~s:~w: Warning: ~s\n", - [File,Line,Mod:format_error(W)]) - end, sort(St#leex.warnings)) - end, report_warnings, St#leex.opts). + Werr = member(warnings_as_errors, St#leex.opts), + Prefix = case Werr of + true -> ""; + false -> "Warning: " + end, + ReportWerr = Werr andalso member(report_errors, St#leex.opts), + ShouldReport = member(report_warnings, St#leex.opts) orelse ReportWerr, + when_bool(fun () -> + foreach(fun({File,{none,Mod,W}}) -> + io:fwrite("~s: ~s~s\n", + [File,Prefix, + Mod:format_error(W)]); + ({File,{Line,Mod,W}}) -> + io:fwrite("~s:~w: ~s~s\n", + [File,Line,Prefix, + Mod:format_error(W)]) + end, sort(St#leex.warnings)) + end, ShouldReport). -spec add_error(_, #leex{}) -> no_return(). add_error(E, St) -> @@ -363,6 +372,12 @@ when_opt(Do, Opt, Opts) -> false -> ok end. +when_bool(Do, Bool) -> + case Bool of + true -> Do(); + false -> ok + end. + verbose_print(St, Format, Args) -> when_opt(fun () -> io:fwrite(Format, Args) end, verbose, St#leex.opts). -- cgit v1.2.3 From a6b46d18e04c23cf8f7798ebc4ef34e4e03eb04e Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 2 Aug 2011 16:41:53 +0200 Subject: yecc: log warnings as errors if -Werror is enabled --- lib/parsetools/src/yecc.erl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index d714420680..d03435c441 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -852,14 +852,22 @@ report_errors(St) -> end. report_warnings(St) -> - case member(report_warnings, St#yecc.options) of + Werr = member(warnings_as_errors, St#yecc.options), + Prefix = case Werr of + true -> ""; + false -> "Warning: " + end, + ReportWerr = Werr andalso member(report_errors, St#yecc.options), + case member(report_warnings, St#yecc.options) orelse ReportWerr of true -> foreach(fun({File,{none,Mod,W}}) -> - io:fwrite(<<"~s: Warning: ~s\n">>, - [File,Mod:format_error(W)]); + io:fwrite(<<"~s: ~s~s\n">>, + [File,Prefix, + Mod:format_error(W)]); ({File,{Line,Mod,W}}) -> - io:fwrite(<<"~s:~w: Warning: ~s\n">>, - [File,Line,Mod:format_error(W)]) + io:fwrite(<<"~s:~w: ~s~s\n">>, + [File,Line,Prefix, + Mod:format_error(W)]) end, sort(St#yecc.warnings)); false -> ok -- cgit v1.2.3 From ebb7283730e7ee09a8d7eececd69b4fe2f5438d5 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 19 Aug 2011 15:14:54 +0200 Subject: leex: use more descriptive name: 'werror' --- lib/parsetools/src/leex.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index ca010e09f0..3e226229f8 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -78,10 +78,10 @@ compile(Input0, Output0, Input = assure_extension(shorten_filename(Input0), ".xrl"), Output = assure_extension(shorten_filename(Output0), ".erl"), Includefile = lists:sublist(Includes, 1), - Werr = proplists:get_bool(warnings_as_errors, Specific), + Werror = proplists:get_bool(warnings_as_errors, Specific), Opts = [{scannerfile,Output},{includefile,Includefile},{verbose,Verbose}, {report_errors,true},{report_warnings,WarnLevel > 0}, - {warnings_as_errors, Werr}], + {warnings_as_errors, Werror}], case file(Input, Opts) of {ok, _} -> ok; @@ -110,7 +110,7 @@ file(File, Opts0) -> St = try {ok,REAs,Actions,Code,St2} = parse_file(St1), {DFA,DF} = make_dfa(REAs, St2), - case werr(St2) of + case werror(St2) of false -> St3 = out_file(St2, DFA, DF, Actions, Code), case lists:member(dfa_graph, St3#leex.opts) of @@ -262,9 +262,9 @@ leex_ret(St) -> report_warnings(St), Es = pack_errors(St#leex.errors), Ws = pack_warnings(St#leex.warnings), - Werr = werr(St), + Werror = werror(St), if - Werr -> + Werror -> do_error_return(St, Es, Ws); Es =:= [] -> case member(return_warnings, St#leex.opts) of @@ -281,7 +281,7 @@ do_error_return(St, Es, Ws) -> false -> error end. -werr(St) -> +werror(St) -> member(warnings_as_errors, St#leex.opts) andalso length(St#leex.warnings) > 0. @@ -307,13 +307,13 @@ report_errors(St) -> end, report_errors, St#leex.opts). report_warnings(St) -> - Werr = member(warnings_as_errors, St#leex.opts), - Prefix = case Werr of + Werror = member(warnings_as_errors, St#leex.opts), + Prefix = case Werror of true -> ""; false -> "Warning: " end, - ReportWerr = Werr andalso member(report_errors, St#leex.opts), - ShouldReport = member(report_warnings, St#leex.opts) orelse ReportWerr, + ReportWerror = Werror andalso member(report_errors, St#leex.opts), + ShouldReport = member(report_warnings, St#leex.opts) orelse ReportWerror, when_bool(fun () -> foreach(fun({File,{none,Mod,W}}) -> io:fwrite("~s: ~s~s\n", -- cgit v1.2.3 From 9520bbfc80f5e62ea39c921e8e2fc805857a8ca6 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 19 Aug 2011 15:16:26 +0200 Subject: yecc: use more descriptive name: 'werror' --- lib/parsetools/src/yecc.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index d03435c441..e51de0da2e 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -138,10 +138,10 @@ compile(Input0, Output0, Input = shorten_filename(Input0), Output = shorten_filename(Output0), Includefile = lists:sublist(Includes, 1), - Werr = proplists:get_bool(warnings_as_errors, Specific), + Werror = proplists:get_bool(warnings_as_errors, Specific), Opts = [{parserfile,Output}, {includefile,Includefile}, {verbose,Verbose}, {report_errors, true}, {report_warnings, WarnLevel > 0}, - {warnings_as_errors, Werr}], + {warnings_as_errors, Werror}], case file(Input, Opts) of {ok, _OutFile} -> ok; @@ -414,13 +414,13 @@ infile(Parent, Infilex, Options) -> {error, Reason} -> add_error(St0#yecc.infile, none, {file_error, Reason}, St0) end, - case {St#yecc.errors, werr(St)} of + case {St#yecc.errors, werror(St)} of {[], false} -> ok; _ -> _ = file:delete(St#yecc.outfile) end, Parent ! {self(), yecc_ret(St)}. -werr(St) -> +werror(St) -> member(warnings_as_errors, St#yecc.options) andalso length(St#yecc.warnings) > 0. @@ -786,9 +786,9 @@ yecc_ret(St0) -> report_warnings(St), Es = pack_errors(St#yecc.errors), Ws = pack_warnings(St#yecc.warnings), - Werr = werr(St), + Werror = werror(St), if - Werr -> + Werror -> do_error_return(St, Es, Ws); Es =:= [] -> case member(return_warnings, St#yecc.options) of @@ -852,13 +852,13 @@ report_errors(St) -> end. report_warnings(St) -> - Werr = member(warnings_as_errors, St#yecc.options), - Prefix = case Werr of + Werror = member(warnings_as_errors, St#yecc.options), + Prefix = case Werror of true -> ""; false -> "Warning: " end, - ReportWerr = Werr andalso member(report_errors, St#yecc.options), - case member(report_warnings, St#yecc.options) orelse ReportWerr of + ReportWerror = Werror andalso member(report_errors, St#yecc.options), + case member(report_warnings, St#yecc.options) orelse ReportWerror of true -> foreach(fun({File,{none,Mod,W}}) -> io:fwrite(<<"~s: ~s~s\n">>, -- cgit v1.2.3 From 5d4aadda5f63b6734b98dedf681598f065117b7a Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 19 Aug 2011 17:34:40 +0200 Subject: yecc: optimize werror/1 --- lib/parsetools/src/yecc.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index e51de0da2e..354d56527d 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -421,8 +421,8 @@ infile(Parent, Infilex, Options) -> Parent ! {self(), yecc_ret(St)}. werror(St) -> - member(warnings_as_errors, St#yecc.options) - andalso length(St#yecc.warnings) > 0. + St#yecc.warnings =/= [] + andalso member(warnings_as_errors, St#yecc.options). outfile(St0) -> case file:open(St0#yecc.outfile, [write, delayed_write]) of -- cgit v1.2.3 From 78c109da0a33108a72ea580b8ba4c01aa32dbe2c Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 19 Aug 2011 17:34:48 +0200 Subject: leex: optimize werror/1 --- lib/parsetools/src/leex.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/parsetools/src') diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index 3e226229f8..cdf20461d9 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -282,8 +282,8 @@ do_error_return(St, Es, Ws) -> end. werror(St) -> - member(warnings_as_errors, St#leex.opts) - andalso length(St#leex.warnings) > 0. + St#leex.warnings =/= [] + andalso member(warnings_as_errors, St#leex.opts). pack_errors([{File,_} | _] = Es) -> [{File, flatmap(fun({_,E}) -> [E] end, sort(Es))}]; -- cgit v1.2.3