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 /tool | |
parent | 554b370b7273b0aab70c302aee7491ba32f63794 (diff) |
Escape non-ascii characters in prelude C comments
Non-ASCII code are often warned by localized compilers.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8276
Diffstat (limited to 'tool')
-rw-r--r-- | tool/ruby_vm/helpers/c_escape.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tool/ruby_vm/helpers/c_escape.rb b/tool/ruby_vm/helpers/c_escape.rb index 34fafd1e34..2a99e408da 100644 --- a/tool/ruby_vm/helpers/c_escape.rb +++ b/tool/ruby_vm/helpers/c_escape.rb @@ -17,7 +17,10 @@ module RubyVM::CEscape # generate comment, with escaps. def commentify str - return "/* #{str.b.gsub('*/', '*\\/').gsub('/*', '/\\*')} */" + unless str = str.dump[/\A"\K.*(?="\z)/] + raise Encoding::CompatibilityError, "must be ASCII-compatible (#{str.encoding})" + end + return "/* #{str.gsub('*/', '*\\/').gsub('/*', '/\\*')} */" end # Mimic gensym of CL. |