ruby-changes:44258
From: nagachika <ko1@a...>
Date: Tue, 4 Oct 2016 02:26:21 +0900 (JST)
Subject: [ruby-changes:44258] nagachika:r56331 (ruby_2_3): merge revision(s) 56281, 56282:
nagachika 2016-10-04 02:26:16 +0900 (Tue, 04 Oct 2016) New Revision: 56331 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56331 Log: merge revision(s) 56281,56282: strscan.c: use S_RESTLEN * ext/strscan/strscan.c (strscan_getch, strscan_peek), (strscan_rest_size, inspect2): use S_RESTLEN consistently. Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ext/strscan/strscan.c branches/ruby_2_3/version.h Index: ruby_2_3/ext/strscan/strscan.c =================================================================== --- ruby_2_3/ext/strscan/strscan.c (revision 56330) +++ ruby_2_3/ext/strscan/strscan.c (revision 56331) @@ -64,6 +64,7 @@ struct strscanner https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L64 Function Prototypes ======================================================================= */ +static inline long minl _((const long n, const long x)); static VALUE infect _((VALUE str, struct strscanner *p)); static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i)); static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len)); @@ -140,12 +141,17 @@ str_new(struct strscanner *p, const char https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L141 return str; } +static inline long +minl(const long x, const long y) +{ + return (x < y) ? x : y; +} + static VALUE extract_range(struct strscanner *p, long beg_i, long end_i) { if (beg_i > S_LEN(p)) return Qnil; - if (end_i > S_LEN(p)) - end_i = S_LEN(p); + end_i = minl(end_i, S_LEN(p)); return infect(str_new(p, S_PBEG(p) + beg_i, end_i - beg_i), p); } @@ -153,8 +159,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L159 extract_beg_len(struct strscanner *p, long beg_i, long len) { if (beg_i > S_LEN(p)) return Qnil; - if (beg_i + len > S_LEN(p)) - len = S_LEN(p) - beg_i; + len = minl(len, S_LEN(p) - beg_i); return infect(str_new(p, S_PBEG(p) + beg_i, len), p); } @@ -728,9 +733,7 @@ strscan_getch(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L733 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; - } + len = minl(len, S_RESTLEN(p)); p->prev = p->curr; p->curr += len; MATCHED(p); @@ -807,8 +810,7 @@ strscan_peek(VALUE self, VALUE vlen) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L810 if (EOS_P(p)) return infect(str_new(p, "", 0), p); - if (p->curr + len > S_LEN(p)) - len = S_LEN(p) - p->curr; + len = minl(len, S_RESTLEN(p)); return extract_beg_len(p, p->curr, len); } @@ -1116,7 +1118,7 @@ strscan_rest_size(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L1118 if (EOS_P(p)) { return INT2FIX(0); } - i = S_LEN(p) - p->curr; + i = S_RESTLEN(p); return INT2FIX(i); } @@ -1202,7 +1204,7 @@ inspect2(struct strscanner *p) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/strscan/strscan.c#L1204 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, "..."); Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 56330) +++ ruby_2_3/version.h (revision 56331) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.2" -#define RUBY_RELEASE_DATE "2016-09-26" -#define RUBY_PATCHLEVEL 192 +#define RUBY_RELEASE_DATE "2016-10-04" +#define RUBY_PATCHLEVEL 193 #define RUBY_RELEASE_YEAR 2016 -#define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_MONTH 10 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r56281-56282 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/