Bug #3599

Incorrect Regexp inspect for ASCII-8BIT String

Added by Heesob Park almost 5 years ago. Updated almost 4 years ago.

[ruby-core:31431]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 1.9.3dev (2010-07-22 trunk 28707) [i686-linux] Backport:

Description

=begin
irb(main):001:0> a = Regexp.new("\xF1\xF2\xF3".force_encoding('ASCII-8BIT'))
=> /\xF1/
irb(main):002:0> puts a.inspect
/\xF1/
=> nil
irb(main):003:0> "\xF0\xF1".force_encoding('ASCII-8BIT') =~ a
=> nil
irb(main):004:0> a.source
=> "\xF1\xF2\xF3"
irb(main):005:0> "\xF0\xF1\xF2\xF3".force_encoding('ASCII-8BIT') =~ a
=> 1
=end

History

#1 Updated by Heesob Park almost 5 years ago

=begin
Here is a simple patch for this bug.

--- re.c 2010-07-22 16:12:01.536788151 +0900
+++ re.c.new 2010-07-22 16:13:15.229038356 +0900
@@ -373,7 +373,8 @@
int l;
if (resenc) {
unsigned int c = rb_enc_mbc_to_codepoint(p, pend, enc);
- l = rb_str_buf_cat_escaped_char(str, c, unicode_p);
+ rb_str_buf_cat_escaped_char(str, c, unicode_p);
+ l = clen;
}
else {
l = mbclen(p, pend, enc);

=end

#2 Updated by Yui NARUSE almost 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r28715.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF