summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-19 08:25:45 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-19 08:25:45 +0000
commitd7f27048486999f5d8c81223c0f10e3243487bbb (patch)
treec89446613ce6588d723b25ed5d64bd849206a0e8
parent52b49b399e0b119e63cc3f918485ece23c097de6 (diff)
merge revision(s) 20580:
* pack.c (pack_pack): fixed length for odd length string. [ruby-dev:37283] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@22444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--pack.c4
-rw-r--r--test/ruby/test_pack.rb40
-rw-r--r--version.h8
4 files changed, 51 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 91be64de8d..355fddd1f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Feb 19 17:24:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * pack.c (pack_pack): fixed length for odd length string.
+ [ruby-dev:37283]
+
Wed Feb 18 22:27:11 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_isatty): check whether fd is valid.
diff --git a/pack.c b/pack.c
index 97c52e433e..13c282af9a 100644
--- a/pack.c
+++ b/pack.c
@@ -610,7 +610,7 @@ pack_pack(ary, fmt)
long i, j = 0;
if (len > plen) {
- j = (len - plen + 1)/2;
+ j = (len + 1) / 2 - (plen + 1) / 2;
len = plen;
}
for (i=0; i++ < len; ptr++) {
@@ -641,7 +641,7 @@ pack_pack(ary, fmt)
long i, j = 0;
if (len > plen) {
- j = (len - plen + 1)/2;
+ j = (len + 1) / 2 - (plen + 1) / 2;
len = plen;
}
for (i=0; i++ < len; ptr++) {
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index e67465b33a..a8f0176879 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -57,4 +57,44 @@ class TestPack < Test::Unit::TestCase
assert_raises(RangeError) { [0x80000000].pack("U") }
assert_raises(RangeError) { [0x100000000].pack("U") }
end
+
+ def test_pack_unpack_hH
+ assert_equal("\x01\xfe", ["10ef"].pack("h*"))
+ assert_equal("", ["10ef"].pack("h0"))
+ assert_equal("\x01\x0e", ["10ef"].pack("h3"))
+ assert_equal("\x01\xfe\x0", ["10ef"].pack("h5"))
+ assert_equal("\xff\x0f", ["fff"].pack("h3"))
+ assert_equal("\xff\x0f", ["fff"].pack("h4"))
+ assert_equal("\xff\x0f\0", ["fff"].pack("h5"))
+ assert_equal("\xff\x0f\0", ["fff"].pack("h6"))
+ assert_equal("\xff\x0f\0\0", ["fff"].pack("h7"))
+ assert_equal("\xff\x0f\0\0", ["fff"].pack("h8"))
+
+ assert_equal("\x10\xef", ["10ef"].pack("H*"))
+ assert_equal("", ["10ef"].pack("H0"))
+ assert_equal("\x10\xe0", ["10ef"].pack("H3"))
+ assert_equal("\x10\xef\x0", ["10ef"].pack("H5"))
+ assert_equal("\xff\xf0", ["fff"].pack("H3"))
+ assert_equal("\xff\xf0", ["fff"].pack("H4"))
+ assert_equal("\xff\xf0\0", ["fff"].pack("H5"))
+ assert_equal("\xff\xf0\0", ["fff"].pack("H6"))
+ assert_equal("\xff\xf0\0\0", ["fff"].pack("H7"))
+ assert_equal("\xff\xf0\0\0", ["fff"].pack("H8"))
+
+ assert_equal(["10ef"], "\x01\xfe".unpack("h*"))
+ assert_equal([""], "\x01\xfe".unpack("h0"))
+ assert_equal(["1"], "\x01\xfe".unpack("h1"))
+ assert_equal(["10"], "\x01\xfe".unpack("h2"))
+ assert_equal(["10e"], "\x01\xfe".unpack("h3"))
+ assert_equal(["10ef"], "\x01\xfe".unpack("h4"))
+ assert_equal(["10ef"], "\x01\xfe".unpack("h5"))
+
+ assert_equal(["10ef"], "\x10\xef".unpack("H*"))
+ assert_equal([""], "\x10\xef".unpack("H0"))
+ assert_equal(["1"], "\x10\xef".unpack("H1"))
+ assert_equal(["10"], "\x10\xef".unpack("H2"))
+ assert_equal(["10e"], "\x10\xef".unpack("H3"))
+ assert_equal(["10ef"], "\x10\xef".unpack("H4"))
+ assert_equal(["10ef"], "\x10\xef".unpack("H5"))
+ end
end
diff --git a/version.h b/version.h
index 2a3d4584a1..b17b5919a6 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.6"
-#define RUBY_RELEASE_DATE "2009-02-18"
+#define RUBY_RELEASE_DATE "2009-02-19"
#define RUBY_VERSION_CODE 186
-#define RUBY_RELEASE_CODE 20090218
-#define RUBY_PATCHLEVEL 341
+#define RUBY_RELEASE_CODE 20090219
+#define RUBY_PATCHLEVEL 342
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 18
+#define RUBY_RELEASE_DAY 19
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];