aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-21 10:09:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-21 10:09:33 +0000
commit3c2705e96091c296f0a8d65afef7e8c81cfb683c (patch)
tree0f755f70efe087af205e975cb7f4869a07eae984 /string.c
parent6ba4e5da0f748e09b06d6ddf544491ca890e340b (diff)
downloadruby-3c2705e96091c296f0a8d65afef7e8c81cfb683c.tar.gz
string.c: skip invalid char gap
* 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/trunk@54210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/string.c b/string.c
index 2782d28e52..04d849f136 100644
--- a/string.c
+++ b/string.c
@@ -3552,6 +3552,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;
@@ -3561,11 +3565,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;