summaryrefslogtreecommitdiff
path: root/tool/ruby_vm/helpers/c_escape.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/ruby_vm/helpers/c_escape.rb')
-rw-r--r--tool/ruby_vm/helpers/c_escape.rb5
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.