diff options
author | Hans Bolinder <[email protected]> | 2013-03-19 13:05:49 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2013-03-19 13:05:49 +0100 |
commit | 692fa53631d5c977cc5e7635ce1df4e39d224116 (patch) | |
tree | cfa871edd7a69c0004608cb8eaf97b375bcae201 /lib/stdlib/src/escript.erl | |
parent | 395e5870020df6807c6e73462e75d594a07e40a8 (diff) | |
parent | f247d246725d76412242e547e7c212bf947542f8 (diff) | |
download | otp-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.erl | 8 |
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}, |