File 1130-Encode-generated-dependency-files-in-UTF-8.patch of Package erlang
From 4b6006a289b03bf4dd3db6888ad887477cf56fa0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 19 Feb 2021 09:44:39 +0100
Subject: [PATCH] Encode generated dependency files in UTF-8
If the dependency output (generated when the compiler is invoked
with the `makedep` option) contained non-latin1 characters,
the compiler would crash.
To avoid the crash, encode the output in UTF-8.
---
lib/compiler/doc/src/compile.xml | 1 +
lib/compiler/src/compile.erl | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml
index e41967ca35..fb24ce60d3 100644
--- a/lib/compiler/doc/src/compile.xml
+++ b/lib/compiler/doc/src/compile.xml
@@ -237,6 +237,7 @@
<c>binary</c> is set, nothing is written and the rule is
returned in <c>Binary</c>.
</p>
+ <p>The output will be encoded in UTF-8.</p>
<p>For example, if you have the following module:
</p>
<code>
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 5078818646..d375553fcb 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -1111,7 +1111,7 @@ makedep(#compile{code=Code,options=Opts}=St) ->
true -> MainRule ++ PhonyRules;
_ -> MainRule
end,
- {ok,St#compile{code=iolist_to_binary([Makefile,"\n"])}}.
+ {ok,St#compile{code=unicode:characters_to_binary([Makefile,"\n"])}}.
makedep_add_headers(Ifile, [{attribute,_,file,{File,_}}|Rest],
Included, LineLen, MainTarget, Phony, Opts) ->
--
2.26.2