aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parsetools/src/leex.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2013-09-03 08:12:36 +0200
committerHans Bolinder <[email protected]>2013-09-03 08:12:36 +0200
commit75d58c0a75a3e6aaa91a1ecf820cf0ad169db5f5 (patch)
treed277f453abade96d44495a179e1ee0e2efc7d11c /lib/parsetools/src/leex.erl
parent1cbfe6f92b7fbad2352ac9eeba528208f8aa4349 (diff)
parent1de23e3a31b77db4c9dca952644b764bd37e2e8f (diff)
downloadotp-75d58c0a75a3e6aaa91a1ecf820cf0ad169db5f5.tar.gz
otp-75d58c0a75a3e6aaa91a1ecf820cf0ad169db5f5.tar.bz2
otp-75d58c0a75a3e6aaa91a1ecf820cf0ad169db5f5.zip
Merge branch 'maint'
* maint: Fix a Unicode filename bug affecting Leex and Yecc
Diffstat (limited to 'lib/parsetools/src/leex.erl')
-rw-r--r--lib/parsetools/src/leex.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl
index e531b78a5b..7039aea1ae 100644
--- a/lib/parsetools/src/leex.erl
+++ b/lib/parsetools/src/leex.erl
@@ -1645,10 +1645,14 @@ output_encoding_comment(File, #leex{encoding = Encoding}) ->
output_file_directive(File, Filename, Line) ->
io:fwrite(File, <<"-file(~ts, ~w).\n">>,
- [format_filename(Filename), Line]).
+ [format_filename(Filename, File), Line]).
-format_filename(Filename) ->
- io_lib:write_string(filename:flatten(Filename)).
+format_filename(Filename0, File) ->
+ Filename = filename:flatten(Filename0),
+ case lists:keyfind(encoding, 1, io:getopts(File)) of
+ {encoding, unicode} -> io_lib:write_string(Filename);
+ _ -> io_lib:write_string_as_latin1(Filename)
+ end.
quote($^) -> "\\^";
quote($.) -> "\\.";