summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 14:57:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-18 14:57:40 +0000
commitc0087df04443e20ccd09cffe22d75774470f6853 (patch)
treea29dbd64e9f6da9c11c6c48c5642b33ac844884f
parent68a01f9cdfa90dc0195b472c0ac49c8d6d8dfbad (diff)
pack.c: round down too long uuencode width
* pack.c (pack_pack): round down too long uuencode width. folding width in uuencode format cannot be longer than 63 bytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--pack.c2
-rw-r--r--test/ruby/test_pack.rb4
3 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f0c33da37..808bc7e1f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jul 18 23:57:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * pack.c (pack_pack): round down too long uuencode width. folding
+ width in uuencode format cannot be longer than 63 bytes.
+
Wed Jul 18 23:04:18 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/dbm/dbm.c (fdbm_empty_p): fix wrong condtion introduced in r36438.
diff --git a/pack.c b/pack.c
index 895d97c770..5b63c3f242 100644
--- a/pack.c
+++ b/pack.c
@@ -927,6 +927,8 @@ pack_pack(VALUE ary, VALUE fmt)
}
if (len <= 2)
len = 45;
+ else if (len > 63 && type == 'u')
+ len = 63;
else
len = len / 3 * 3;
while (plen > 0) {
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 5ea21d7827..c72035c2e7 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -496,6 +496,10 @@ class TestPack < Test::Unit::TestCase
assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u0"))
assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u1"))
assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u2"))
+ assert_equal(<<EXPECTED, ["a"*80].pack("u68"))
+_86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A
+186%A86%A86%A86%A86%A86$`
+EXPECTED
assert_equal([""], "".unpack("u"))
assert_equal(["a"], "!80``\n".unpack("u"))