summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 08:00:06 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 08:00:06 +0000
commit9d502cf9a44d3934742d076f184574ef5b89702a (patch)
tree717b45068fbb9b78a09d283b9f5ed71605b53f97
parentba57632186d408bf32abc18b2b334f2ac1b09fca (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_3@54384 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 9261a445ee..b8d9059447 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 29 16:54: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]
+
Tue Mar 29 16:45:58 2016 Victor Nawothnig <Victor.Nawothnig@gmail.com>
* parse.y (parse_numvar): NTH_REF must be less than a half of
diff --git a/string.c b/string.c
index f4519ea425..5bb60593e3 100644
--- a/string.c
+++ b/string.c
@@ -3475,6 +3475,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;
@@ -3484,11 +3488,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 3a45f1f028..f0a6b4c95b 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1682,4 +1682,9 @@ class TestM17N < Test::Unit::TestCase
end
assert_equal(e("[\"\xB4\xC1\xBB\xFA\"]"), s, bug11787)
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 ba8a795ebf..f0f33594ac 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.0"
#define RUBY_RELEASE_DATE "2016-03-29"
-#define RUBY_PATCHLEVEL 40
+#define RUBY_PATCHLEVEL 41
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 3