summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-25 09:41:52 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-25 09:41:52 +0000
commite4a39e0e9ecc7f01cb7605c820240c4d18200850 (patch)
tree96c840fc8883b793f00fb85bd846e2b965c8ad94
parentdf557d28ad2cd9bc38891e8f77c5ed45a0612681 (diff)
merge revision(s) 54210: [Backport #12204]
* string.c (enc_succ_alnum_char): try to skip an invalid character gap between GREEK CAPITAL RHO and SIGMA. [ruby-core:74478] [Bug #12204] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@54284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--string.c16
-rw-r--r--test/ruby/test_m17n.rb5
-rw-r--r--version.h2
4 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1dfafa8ff8..4d1a51aa0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Mar 25 18:41:14 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (enc_succ_alnum_char): try to skip an invalid character
+ gap between GREEK CAPITAL RHO and SIGMA.
+ [ruby-core:74478] [Bug #12204]
+
Fri Mar 25 18:38:42 2016 NARUSE, Yui <naruse@ruby-lang.org>
* enc/trans/JIS: update Unicode's notice. [Bug #11844]
diff --git a/string.c b/string.c
index 228725a8e4..3c967f64f1 100644
--- a/string.c
+++ b/string.c
@@ -3179,6 +3179,10 @@ enc_succ_alnum_char(char *p, long len, rb_encoding *enc, char *carry)
int range;
char save[ONIGENC_CODE_TO_MBC_MAXLEN];
+ /* skip 03A2, invalid char between GREEK CAPITAL LETTERS */
+ int try;
+ const int max_gaps = 1;
+
c = rb_enc_mbc_to_codepoint(p, p+len, enc);
if (rb_enc_isctype(c, ONIGENC_CTYPE_DIGIT, enc))
ctype = ONIGENC_CTYPE_DIGIT;
@@ -3188,11 +3192,13 @@ enc_succ_alnum_char(char *p, long len, rb_encoding *enc, char *carry)
return NEIGHBOR_NOT_CHAR;
MEMCPY(save, p, char, len);
- ret = enc_succ_char(p, len, enc);
- if (ret == NEIGHBOR_FOUND) {
- c = rb_enc_mbc_to_codepoint(p, p+len, enc);
- if (rb_enc_isctype(c, ctype, enc))
- return NEIGHBOR_FOUND;
+ for (try = 0; try <= max_gaps; ++try) {
+ ret = enc_succ_char(p, len, enc);
+ if (ret == NEIGHBOR_FOUND) {
+ c = rb_enc_mbc_to_codepoint(p, p+len, enc);
+ if (rb_enc_isctype(c, ctype, enc))
+ return NEIGHBOR_FOUND;
+ }
}
MEMCPY(p, save, char, len);
range = 1;
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index a6e2d3c92a..e933475997 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1613,4 +1613,9 @@ class TestM17N < Test::Unit::TestCase
assert_same(str, str.scrub!)
assert_equal("\uFFFD\uFFFD\uFFFD", str)
end
+
+ def test_greek_capital_gap
+ bug12204 = '[ruby-core:74478] [Bug #12204] GREEK CAPITAL RHO and SIGMA'
+ assert_equal("\u03A3", "\u03A1".succ, bug12204)
+ end
end
diff --git a/version.h b/version.h
index fa57305b75..01116a1fb4 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.9"
#define RUBY_RELEASE_DATE "2016-03-25"
-#define RUBY_PATCHLEVEL 481
+#define RUBY_PATCHLEVEL 482
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 3