summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-04 06:52:33 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-04 06:52:33 +0000
commit05bc47773ab5be6ce461c8180e2d4b7cb727f76f (patch)
tree9314305570284fa85e8bbb9cd8c96889b8915697 /string.c
parentc294ed5824f3e42e1bfb0c71b571f4992a8eb6e4 (diff)
* string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly.
* string.c (rb_str_dump): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/string.c b/string.c
index 2003a075bb..46658e0a12 100644
--- a/string.c
+++ b/string.c
@@ -2976,7 +2976,9 @@ rb_str_succ(VALUE orig)
break;
}
}
- if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
+ l = rb_enc_precise_mbclen(s, e, enc);
+ if (!ONIGENC_MBCLEN_CHARFOUND_P(l)) continue;
+ l = ONIGENC_MBCLEN_CHARFOUND_LEN(l);
neighbor = enc_succ_alnum_char(s, l, enc, carry);
switch (neighbor) {
case NEIGHBOR_NOT_CHAR:
@@ -2995,7 +2997,9 @@ rb_str_succ(VALUE orig)
s = e;
while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) {
enum neighbor_char neighbor;
- if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
+ l = rb_enc_precise_mbclen(s, e, enc);
+ if (!ONIGENC_MBCLEN_CHARFOUND_P(l)) continue;
+ l = ONIGENC_MBCLEN_CHARFOUND_LEN(l);
neighbor = enc_succ_char(s, l, enc);
if (neighbor == NEIGHBOR_FOUND)
return str;
@@ -4618,9 +4622,9 @@ rb_str_dump(VALUE str)
len++;
}
else {
- if (u8) { /* \u{NN} */
+ if (u8 && c > 0x7F) { /* \u{NN} */
int n = rb_enc_precise_mbclen(p-1, pend, enc);
- if (MBCLEN_CHARFOUND_P(n-1)) {
+ if (MBCLEN_CHARFOUND_P(n)) {
unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
while (cc >>= 4) len++;
len += 5;