summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-08 08:09:02 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-08 08:09:02 +0000
commit04bc7dbc8b4d35aeee043214effe3cf664fa4d00 (patch)
tree055a9fd50033d456cd7a5a241e8ff6644fefc1e3
parentee72d1c46ce80e0eb1bf4744c44a7cf6cdf46417 (diff)
merges r29622 from trunk into ruby_1_9_2.
-- * string.c (rb_str_dump): fix expected length. [ruby-core:32935] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--string.c9
-rw-r--r--test/ruby/test_stringchar.rb15
-rw-r--r--version.h2
4 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index acf70d9bf8..362dae5877 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Oct 29 03:04:16 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_dump): fix expected length. [ruby-core:32935]
+
Thu Oct 21 15:42:01 2010 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/telnet.rb (Net::Telnet#close): added.
diff --git a/string.c b/string.c
index da3242f254..c9110e8516 100644
--- a/string.c
+++ b/string.c
@@ -4263,12 +4263,11 @@ rb_str_dump(VALUE str)
}
else {
if (u8) { /* \u{NN} */
- char buf[32];
int n = rb_enc_precise_mbclen(p-1, pend, enc);
- if (MBCLEN_CHARFOUND_P(n)) {
- int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
- sprintf(buf, "%x", cc);
- len += strlen(buf)+4;
+ if (MBCLEN_CHARFOUND_P(n-1)) {
+ unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
+ while (cc >>= 4) len++;
+ len += 5;
p += MBCLEN_CHARFOUND_LEN(n)-1;
break;
}
diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb
index b70f171c84..44c8634c02 100644
--- a/test/ruby/test_stringchar.rb
+++ b/test/ruby/test_stringchar.rb
@@ -163,4 +163,19 @@ EOS
s.delete!("a-z")
assert_equal("BB", s)
end
+
+ def test_dump
+ bug3996 = '[ruby-core:32935]'
+ Encoding.list.find_all {|enc| enc.ascii_compatible?}.each do |enc|
+ (0..256).map do |c|
+ begin
+ s = c.chr(enc)
+ rescue RangeError, ArgumentError
+ break
+ else
+ assert_not_match(/\0/, s.dump, bug3996)
+ end
+ end
+ end
+ end
end
diff --git a/version.h b/version.h
index b25547578c..d655cfd117 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 83
+#define RUBY_PATCHLEVEL 84
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1