summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-18 12:53:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-18 12:53:31 +0000
commite8665a6bc271654de993e8cfca08164717236cd1 (patch)
tree396cdbb30140e9b188728b4eb916233a4b1953bb
parent713e99cec284a7bfdfdc6b598102028e0f844b8f (diff)
* pack.c (pack_unpack): call PACK_ITEM_ADJUST for 'Q'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--pack.c3
-rw-r--r--test/ruby/test_pack.rb7
3 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 90e6a5ed02..76cd12847a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Feb 18 21:50:00 2010 Tanaka Akira <akr@fsij.org>
+
+ * pack.c (pack_unpack): call PACK_ITEM_ADJUST for 'Q'.
+
Thu Feb 18 02:14:26 2010 Yusuke Endoh <mame@tsg.ne.jp>
* io.c (io_fread, io_getpartial, io_read, io_sysread): by using lock,
diff --git a/pack.c b/pack.c
index 80b6ab5137..cec5e46b9f 100644
--- a/pack.c
+++ b/pack.c
@@ -1605,6 +1605,7 @@ pack_unpack(VALUE str, VALUE fmt)
}
PACK_ITEM_ADJUST();
break;
+
case 'L':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
@@ -1625,6 +1626,7 @@ pack_unpack(VALUE str, VALUE fmt)
}
PACK_ITEM_ADJUST();
break;
+
case 'Q':
PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
while (len-- > 0) {
@@ -1632,6 +1634,7 @@ pack_unpack(VALUE str, VALUE fmt)
s += QUAD_SIZE;
UNPACK_PUSH(rb_quad_unpack(tmp, 0));
}
+ PACK_ITEM_ADJUST();
break;
case 'n':
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 6101a30219..7cc3f0089e 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -491,4 +491,11 @@ class TestPack < Test::Unit::TestCase
def test_length_too_big
assert_raise(RangeError) { [].pack("C100000000000000000000") }
end
+
+ def test_short_string
+ %w[n N v V s S l L q Q].each {|fmt|
+ str = [1].pack(fmt)
+ assert_equal([1,nil], str.unpack("#{fmt}2"))
+ }
+ end
end