From 44b3c70a9ee51410aa224dae183fcf9436f01139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 14 Apr 2020 15:13:42 +0200 Subject: Fix encoding issues when generating the makedep file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases the input will be parsed as UTF-8 and converted to "characters" and in others it won't and will be processed as bytes (for example, `erl -oldshell` will do that). This means that encoding-dependent characters such as "é" only need to be converted to binary in the former case. To detect which situation we are in we check what the value of "é" is. If it is [233] then the eval input was parsed as UTF-8 and converted to characters. Otherwise we assume it wasn't. --- core/erlc.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/erlc.mk') diff --git a/core/erlc.mk b/core/erlc.mk index 12f69e2..71ba5b9 100644 --- a/core/erlc.mk +++ b/core/erlc.mk @@ -256,11 +256,16 @@ define makedep.erl string:join(DirSubname ++ [atom_to_list(Target)], "/") end end, - ok = file:write_file("$(1)", unicode:characters_to_binary([ + Output0 = [ "# Generated by Erlang.mk. Edit at your own risk!\n\n", [[F, "::", [[" ", D] || D <- Deps], "; @touch \$$@\n"] || {F, Deps} <- Depend], "\nCOMPILE_FIRST +=", [[" ", TargetPath(CF)] || CF <- CompileFirst], "\n" - ])), + ], + Output = case "é" of + [233] -> unicode:characters_to_binary(Output0); + _ -> Output0 + end, + ok = file:write_file("$(1)", Output), halt() endef -- cgit v1.2.3