aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2012-07-18 11:04:02 +0200
committerHenrik Nord <[email protected]>2012-07-18 11:04:02 +0200
commit154c00482d134260190127040ac6b4efb9f85a8f (patch)
tree9c09386fda97663f98a4bb5a5840df3d58f0b05f /lib/stdlib/src
parentf82a553307c865440a01ff38e9b9d6482fe55550 (diff)
parent7875e98fcac4a45607a99ba08a421206a7cf1586 (diff)
downloadotp-154c00482d134260190127040ac6b4efb9f85a8f.tar.gz
otp-154c00482d134260190127040ac6b4efb9f85a8f.tar.bz2
otp-154c00482d134260190127040ac6b4efb9f85a8f.zip
Merge branch 'ta/prim_archive-reloading' into maint
* ta/prim_archive-reloading: escript_SUITE: remove gratuitous space [erts,kernel,stdlib] fix escript/primary archive reloading Conflicts: erts/preloaded/src/erl_prim_loader.erl OTP-10151
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/escript.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl
index 27e70ac4d4..498d850df3 100644
--- a/lib/stdlib/src/escript.erl
+++ b/lib/stdlib/src/escript.erl
@@ -22,7 +22,7 @@
-export([script_name/0, create/2, extract/2]).
%% Internal API.
--export([start/0, start/1]).
+-export([start/0, start/1, parse_file/1]).
%%-----------------------------------------------------------------------
@@ -346,7 +346,8 @@ parse_and_run(File, Args, Options) ->
case Source of
archive ->
{ok, FileInfo} = file:read_file_info(File),
- case code:set_primary_archive(File, FormsOrBin, FileInfo) of
+ case code:set_primary_archive(File, FormsOrBin, FileInfo,
+ fun escript:parse_file/1) of
ok when CheckOnly ->
case code:load_file(Module) of
{module, _} ->
@@ -396,6 +397,19 @@ parse_and_run(File, Args, Options) ->
%% Parse script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Only used as callback by erl_prim_loader
+parse_file(File) ->
+ try parse_file(File, false) of
+ {_Source, _Module, FormsOrBin, _HasRecs, _Mode}
+ when is_binary(FormsOrBin) ->
+ {ok, FormsOrBin};
+ _ ->
+ {error, no_archive_bin}
+ catch
+ throw:Reason ->
+ {error, Reason}
+ end.
+
parse_file(File, CheckOnly) ->
{HeaderSz, NextLineNo, Fd, Sections} =
parse_header(File, false),