aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/escript.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2013-03-19 13:05:49 +0100
committerHans Bolinder <[email protected]>2013-03-19 13:05:49 +0100
commit692fa53631d5c977cc5e7635ce1df4e39d224116 (patch)
treecfa871edd7a69c0004608cb8eaf97b375bcae201 /lib/stdlib/src/escript.erl
parent395e5870020df6807c6e73462e75d594a07e40a8 (diff)
parentf247d246725d76412242e547e7c212bf947542f8 (diff)
downloadotp-692fa53631d5c977cc5e7635ce1df4e39d224116.tar.gz
otp-692fa53631d5c977cc5e7635ce1df4e39d224116.tar.bz2
otp-692fa53631d5c977cc5e7635ce1df4e39d224116.zip
Merge branch 'hb/stdlib/escript_unicode/OTP-10951' into maint
* hb/stdlib/escript_unicode/OTP-10951: Let escript recognize an encoding comment on the second line
Diffstat (limited to 'lib/stdlib/src/escript.erl')
-rw-r--r--lib/stdlib/src/escript.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl
index 32742e419b..fea718541d 100644
--- a/lib/stdlib/src/escript.erl
+++ b/lib/stdlib/src/escript.erl
@@ -602,9 +602,15 @@ parse_beam(S, File, HeaderSz, CheckOnly) ->
parse_source(S, File, Fd, StartLine, HeaderSz, CheckOnly) ->
{PreDefMacros, Module} = pre_def_macros(File),
IncludePath = [],
- {ok, _} = file:position(Fd, {bof, HeaderSz}),
+ %% Read the encoding on the second line, if there is any:
+ {ok, _} = file:position(Fd, 0),
+ _ = io:get_line(Fd, ''),
+ Encoding = epp:set_encoding(Fd),
+ {ok, _} = file:position(Fd, HeaderSz),
case epp:open(File, Fd, StartLine, IncludePath, PreDefMacros) of
{ok, Epp} ->
+ _ = [io:setopts(Fd, [{encoding,Encoding}]) ||
+ Encoding =/= none],
{ok, FileForm} = epp:parse_erl_form(Epp),
OptModRes = epp:parse_erl_form(Epp),
S2 = S#state{source = text, module = Module},