mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (appendline): use READ_CHAR_PENDING_XXX macros and
RSTRING_END(). * io.c (rb_io_getline_1): rewrite nested if statement into one statement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b35c6a429e
commit
8ce3f4beea
2 changed files with 22 additions and 20 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Jul 9 12:47:08 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* io.c (appendline): use READ_CHAR_PENDING_XXX macros and
|
||||||
|
RSTRING_END().
|
||||||
|
|
||||||
|
* io.c (rb_io_getline_1): rewrite nested if statement into one
|
||||||
|
statement.
|
||||||
|
|
||||||
Tue Jul 9 11:04:35 2013 NAKAMURA Usaku <usa@ruby-lang.org>
|
Tue Jul 9 11:04:35 2013 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Regstry#check):
|
* ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Regstry#check):
|
||||||
|
|
34
io.c
34
io.c
|
@ -2760,9 +2760,8 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
|
||||||
do {
|
do {
|
||||||
const char *p, *e;
|
const char *p, *e;
|
||||||
int searchlen;
|
int searchlen;
|
||||||
if (fptr->cbuf.len) {
|
if (searchlen = READ_CHAR_PENDING_COUNT(fptr)) {
|
||||||
p = fptr->cbuf.ptr+fptr->cbuf.off;
|
p = READ_CHAR_PENDING_PTR(fptr);
|
||||||
searchlen = fptr->cbuf.len;
|
|
||||||
if (0 < limit && limit < searchlen)
|
if (0 < limit && limit < searchlen)
|
||||||
searchlen = (int)limit;
|
searchlen = (int)limit;
|
||||||
e = memchr(p, delim, searchlen);
|
e = memchr(p, delim, searchlen);
|
||||||
|
@ -3037,7 +3036,7 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
|
||||||
if (c == newline) {
|
if (c == newline) {
|
||||||
if (RSTRING_LEN(str) < rslen) continue;
|
if (RSTRING_LEN(str) < rslen) continue;
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
e = s + RSTRING_LEN(str);
|
e = RSTRING_END(str);
|
||||||
p = e - rslen;
|
p = e - rslen;
|
||||||
pp = rb_enc_left_char_head(s, p, e, enc);
|
pp = rb_enc_left_char_head(s, p, e, enc);
|
||||||
if (pp != p) continue;
|
if (pp != p) continue;
|
||||||
|
@ -3046,7 +3045,7 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
|
||||||
}
|
}
|
||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
p = s + RSTRING_LEN(str);
|
p = RSTRING_END(str);
|
||||||
pp = rb_enc_left_char_head(s, p-1, p, enc);
|
pp = rb_enc_left_char_head(s, p-1, p, enc);
|
||||||
if (extra_limit &&
|
if (extra_limit &&
|
||||||
MBCLEN_NEEDMORE_P(rb_enc_precise_mbclen(pp, p, enc))) {
|
MBCLEN_NEEDMORE_P(rb_enc_precise_mbclen(pp, p, enc))) {
|
||||||
|
@ -3062,25 +3061,20 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspara) {
|
if (rspara && c != EOF)
|
||||||
if (c != EOF) {
|
swallow(fptr, '\n');
|
||||||
swallow(fptr, '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!NIL_P(str))
|
if (!NIL_P(str))
|
||||||
str = io_enc_str(str, fptr);
|
str = io_enc_str(str, fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(str)) {
|
if (!NIL_P(str) && !nolimit) {
|
||||||
if (!nolimit) {
|
fptr->lineno++;
|
||||||
fptr->lineno++;
|
if (io == ARGF.current_file) {
|
||||||
if (io == ARGF.current_file) {
|
ARGF.lineno++;
|
||||||
ARGF.lineno++;
|
ARGF.last_lineno = ARGF.lineno;
|
||||||
ARGF.last_lineno = ARGF.lineno;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
ARGF.last_lineno = fptr->lineno;
|
||||||
ARGF.last_lineno = fptr->lineno;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue