Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support strong/basic_validation options in yaws_compile
Because these options don't generate binary code, the corresponding '<erl>'
block is ignored. So, in the result of yaws_compile:compile/2, following spec

    {mod, Line, Script, NumChars,  Mod, Fun}

will be replaced by

    {skip, NumChars}
  • Loading branch information
capflam committed Sep 20, 2016
1 parent ed1820f commit 8b297f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/yaws_compile.erl
Expand Up @@ -397,6 +397,9 @@ compile_erl(N, Bin, Comp, Spec) ->
numchars = 0,
erlcode = undefined},
case handle_erlang_block(Comp) of
skip ->
S = {skip, Comp#comp.numchars+N},
compile_file(Bin, NewComp, html, [S|Spec]);
{ok, Mod, Fun} ->
{Line, _, _, _} = Comp#comp.erlcode,
S = {mod, Line, Comp#comp.script, Comp#comp.numchars+N, Mod, Fun},
Expand Down Expand Up @@ -590,14 +593,20 @@ compile_and_load_erlang_block(File, Comp) ->

compile_erlang_block(File, Comp) ->
case compile:file(File, Comp#comp.comp_opts) of
{ok, Module, Binary} ->
{ok, Module} ->
{ok, Module, <<>>, []};
{ok, Module, Binary} when is_binary(Binary) ->
{ok, Module, Binary, []};
{ok, Module, Warnings} ->
{ok, Module, <<>>, Warnings};
{ok, Module, Binary, Warnings} ->
{ok, Module, Binary, Warnings};
{error, Errors, Warnings} ->
{error, Errors, Warnings}
end.

load_erlang_block(_Mod, <<>>, _Comp) ->
skip;
load_erlang_block(Mod, Bin, Comp) ->
{Line, _, _, _} = Comp#comp.erlcode,
case code:load_binary(Mod, "", Bin) of
Expand Down

0 comments on commit 8b297f2

Please sign in to comment.