summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-28 05:11:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-28 05:11:20 +0000
commit604ae2e1519259b1dcede91c0a5126d1a9d400e0 (patch)
treedcb9970eb82ae91ae3595b4b070121671b5d974d /ext
parent6c8fc79f95a109dc6eff3be02d98154a3c6323db (diff)
strscan.c: use S_RESTLEN
* ext/strscan/strscan.c (strscan_getch, strscan_peek), (strscan_rest_size, inspect2): use S_RESTLEN consistently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/strscan/strscan.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index e75bf6639c6..d5221eaeb2d 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -728,8 +728,8 @@ strscan_getch(VALUE self)
return Qnil;
len = rb_enc_mbclen(CURPTR(p), S_PEND(p), rb_enc_get(p->str));
- if (p->curr + len > S_LEN(p)) {
- len = S_LEN(p) - p->curr;
+ if (len > S_RESTLEN(p)) {
+ len = S_RESTLEN(p);
}
p->prev = p->curr;
p->curr += len;
@@ -807,8 +807,8 @@ strscan_peek(VALUE self, VALUE vlen)
if (EOS_P(p))
return infect(str_new(p, "", 0), p);
- if (p->curr + len > S_LEN(p))
- len = S_LEN(p) - p->curr;
+ if (len > S_RESTLEN(p))
+ len = S_RESTLEN(p);
return extract_beg_len(p, p->curr, len);
}
@@ -1116,7 +1116,7 @@ strscan_rest_size(VALUE self)
if (EOS_P(p)) {
return INT2FIX(0);
}
- i = S_LEN(p) - p->curr;
+ i = S_RESTLEN(p);
return INT2FIX(i);
}
@@ -1202,7 +1202,7 @@ inspect2(struct strscanner *p)
long len;
if (EOS_P(p)) return rb_str_new2("");
- len = S_LEN(p) - p->curr;
+ len = S_RESTLEN(p);
if (len > INSPECT_LENGTH) {
str = rb_str_new(CURPTR(p), INSPECT_LENGTH);
rb_str_cat2(str, "...");