aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-14 15:13:42 +0200
committerLoïc Hoguin <[email protected]>2020-04-14 15:13:42 +0200
commit44b3c70a9ee51410aa224dae183fcf9436f01139 (patch)
tree5b5bf02810aca3553fa6f4fdfd6be75609fef324
parenta187726d5ebce1dd37afdc5f84e609c7401d0965 (diff)
downloaderlang.mk-44b3c70a9ee51410aa224dae183fcf9436f01139.tar.gz
erlang.mk-44b3c70a9ee51410aa224dae183fcf9436f01139.tar.bz2
erlang.mk-44b3c70a9ee51410aa224dae183fcf9436f01139.zip
Fix encoding issues when generating the makedep file
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.
-rw-r--r--core/erlc.mk9
1 files changed, 7 insertions, 2 deletions
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