summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-04 03:48:25 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-04 03:48:25 +0000
commit34072faa0d236b4ca5f423c82cc01c79f8276294 (patch)
tree965597bdf2a08e4cbbcff6df8629c8f08659c6ee
parent3cce74dc4c4abfb6840de4ba9bcea4df2f502b15 (diff)
merges r26052 from trunk into ruby_1_9_1.
-- * string.c (rb_str_justify): fixed the case a fill size is a multiple of the length of the padding. [ruby-dev:39856] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c4
-rw-r--r--test/ruby/test_string.rb7
-rw-r--r--version.h2
4 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c6c5584522..2b7247a81b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Dec 9 09:50:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_justify): fixed the case a fill size is a
+ multiple of the length of the padding. [ruby-dev:39856]
+
Sat Oct 31 17:19:28 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/net/http.rb (Net::HTTPResponse#each_response_header):
diff --git a/string.c b/string.c
index 33f1646372..8a8835eca5 100644
--- a/string.c
+++ b/string.c
@@ -6515,7 +6515,7 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
p += llen;
}
else {
- while (llen > fclen) {
+ while (llen >= fclen) {
memcpy(p,f,flen);
p += flen;
llen -= fclen;
@@ -6532,7 +6532,7 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
p += rlen;
}
else {
- while (rlen > fclen) {
+ while (rlen >= fclen) {
memcpy(p,f,flen);
p += flen;
rlen -= fclen;
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 7e9176e507..a14385e4fc 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -320,9 +320,12 @@ class TestString < Test::Unit::TestCase
end
+ Bug2463 = '[ruby-dev:39856]'
def test_center
assert_equal(S("hello"), S("hello").center(4))
assert_equal(S(" hello "), S("hello").center(11))
+ assert_equal(S("ababaababa"), S("").center(10, "ab"), Bug2463)
+ assert_equal(S("ababaababab"), S("").center(11, "ab"), Bug2463)
end
def test_chomp
@@ -779,6 +782,8 @@ class TestString < Test::Unit::TestCase
def test_ljust
assert_equal(S("hello"), S("hello").ljust(4))
assert_equal(S("hello "), S("hello").ljust(11))
+ assert_equal(S("ababababab"), S("").ljust(10, "ab"), Bug2463)
+ assert_equal(S("abababababa"), S("").ljust(11, "ab"), Bug2463)
end
def test_next
@@ -917,6 +922,8 @@ class TestString < Test::Unit::TestCase
def test_rjust
assert_equal(S("hello"), S("hello").rjust(4))
assert_equal(S(" hello"), S("hello").rjust(11))
+ assert_equal(S("ababababab"), S("").rjust(10, "ab"), Bug2463)
+ assert_equal(S("abababababa"), S("").rjust(11, "ab"), Bug2463)
end
def test_scan
diff --git a/version.h b/version.h
index 6fb8758400..af4d5adf40 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 418
+#define RUBY_PATCHLEVEL 419
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1