diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-24 19:10:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-24 21:12:51 +0900 |
commit | 5ec1fc52c1640c75899972ad99734ff22a90694a (patch) | |
tree | 47f86bd44a1a0881c9ffde5b54a0b66d50035b69 /template/prelude.c.tmpl | |
parent | 554b370b7273b0aab70c302aee7491ba32f63794 (diff) | |
download | ruby-5ec1fc52c1640c75899972ad99734ff22a90694a.tar.gz |
Escape non-ascii characters in prelude C comments
Non-ASCII code are often warned by localized compilers.
Diffstat (limited to 'template/prelude.c.tmpl')
-rw-r--r-- | template/prelude.c.tmpl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl index aa8b0c1fef..74f6c08da7 100644 --- a/template/prelude.c.tmpl +++ b/template/prelude.c.tmpl @@ -43,7 +43,10 @@ class Prelude lineno = 0 result = [@preludes.size, @vpath.strip(filename), lines, sub] @vpath.foreach(filename) do |line| - line.force_encoding("ASCII-8BIT") if line.respond_to?(:force_encoding) + if line.respond_to?(:force_encoding) + enc = line.encoding + line.force_encoding("ASCII-8BIT") + end line.rstrip! lineno += 1 @preludes[filename] ||= result @@ -71,6 +74,7 @@ class Prelude orig end end + comment.force_encoding(enc) if enc and comment lines << [line, comment] end result << (start_line || 1) |