aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-09 00:50:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-09 00:50:37 +0000
commitc9c095fc7b56c40e4857c1554932a078eb7a316e (patch)
tree2c9a6eb924e6cca3317a2c82cb473bd36b9fda28
parent0f406d278fce4909940ed52df2009b18fee2c22a (diff)
downloadruby-c9c095fc7b56c40e4857c1554932a078eb7a316e.tar.gz
* 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/trunk@26052 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.h4
4 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f6c25edd0..9068c55126 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]
+
Tue Dec 8 23:41:34 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/configure.bat: now recognize --with-*-{dir,include,lib} options
diff --git a/string.c b/string.c
index 804513e4ef..deab22b9e7 100644
--- a/string.c
+++ b/string.c
@@ -6635,7 +6635,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;
@@ -6652,7 +6652,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 27360e76c1..407c6d2ab1 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 83563f3d9e..7b69f122cb 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_RELEASE_DATE "2009-12-08"
+#define RUBY_RELEASE_DATE "2009-12-09"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
@@ -8,7 +8,7 @@
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 9
#include "ruby/version.h"