ruby-changes:44208
From: nobu <ko1@a...>
Date: Wed, 28 Sep 2016 14:11:24 +0900 (JST)
Subject: [ruby-changes:44208] nobu:r56281 (trunk): strscan.c: use S_RESTLEN
nobu 2016-09-28 14:11:20 +0900 (Wed, 28 Sep 2016) New Revision: 56281 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56281 Log: strscan.c: use S_RESTLEN * ext/strscan/strscan.c (strscan_getch, strscan_peek), (strscan_rest_size, inspect2): use S_RESTLEN consistently. Modified files: trunk/ext/strscan/strscan.c Index: ext/strscan/strscan.c =================================================================== --- ext/strscan/strscan.c (revision 56280) +++ ext/strscan/strscan.c (revision 56281) @@ -728,8 +728,8 @@ strscan_getch(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L728 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) https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L807 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) https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L1116 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) https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L1202 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, "..."); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/