summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--string.c12
2 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d1275aee40..5a7a3845d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Jul 4 15:51:56 2013 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly.
+
+ * string.c (rb_str_dump): ditto.
+
Thu Jul 4 10:04:11 2013 NARUSE, Yui <naruse@ruby-lang.org>
* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.
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;