PCH #include scanner: force string encoding to be UTF-8

If the locale is set to non-UTF-8 when (d)rake is invoked then Ruby will
set the encoding of all strings read from files to US-ASCII. As several
source files do use non-ASCII characters this results in warnings from
Ruby about "invalid byte sequence in US-ASCII".

As all of my source code files are encoded in UTF-8 we can simply
enforce this.

This happens when building the RPMs which sets the locale to C.
This commit is contained in:
Moritz Bunkus 2016-12-10 11:24:40 +01:00
parent c7478ea06b
commit c7e004efa1

View File

@ -383,6 +383,7 @@ PCH status: <%= c?(:USE_PRECOMPILED_HEADERS) ? "enabled" : "disabled" %>
input = indirect ? indirect : user
File.open(input) do |f|
f.each_line do |line|
line.force_encoding("UTF-8")
next if !@scan_include_re.match(line)
@scan_candidates.each do |pair|
(dir,header) = *pair