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>
|
||||
|
||||
* 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 {
|
||||
const char *p, *e;
|
||||
int searchlen;
|
||||
if (fptr->cbuf.len) {
|
||||
p = fptr->cbuf.ptr+fptr->cbuf.off;
|
||||
searchlen = fptr->cbuf.len;
|
||||
if (searchlen = READ_CHAR_PENDING_COUNT(fptr)) {
|
||||
p = READ_CHAR_PENDING_PTR(fptr);
|
||||
if (0 < limit && limit < searchlen)
|
||||
searchlen = (int)limit;
|
||||
e = memchr(p, delim, searchlen);
|
||||
|
@ -3037,7 +3036,7 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
|
|||
if (c == newline) {
|
||||
if (RSTRING_LEN(str) < rslen) continue;
|
||||
s = RSTRING_PTR(str);
|
||||
e = s + RSTRING_LEN(str);
|
||||
e = RSTRING_END(str);
|
||||
p = e - rslen;
|
||||
pp = rb_enc_left_char_head(s, p, e, enc);
|
||||
if (pp != p) continue;
|
||||
|
@ -3046,7 +3045,7 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
|
|||
}
|
||||
if (limit == 0) {
|
||||
s = RSTRING_PTR(str);
|
||||
p = s + RSTRING_LEN(str);
|
||||
p = RSTRING_END(str);
|
||||
pp = rb_enc_left_char_head(s, p-1, p, enc);
|
||||
if (extra_limit &&
|
||||
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 (c != EOF) {
|
||||
swallow(fptr, '\n');
|
||||
}
|
||||
}
|
||||
if (rspara && c != EOF)
|
||||
swallow(fptr, '\n');
|
||||
if (!NIL_P(str))
|
||||
str = io_enc_str(str, fptr);
|
||||
}
|
||||
|
||||
if (!NIL_P(str)) {
|
||||
if (!nolimit) {
|
||||
fptr->lineno++;
|
||||
if (io == ARGF.current_file) {
|
||||
ARGF.lineno++;
|
||||
ARGF.last_lineno = ARGF.lineno;
|
||||
}
|
||||
else {
|
||||
ARGF.last_lineno = fptr->lineno;
|
||||
}
|
||||
if (!NIL_P(str) && !nolimit) {
|
||||
fptr->lineno++;
|
||||
if (io == ARGF.current_file) {
|
||||
ARGF.lineno++;
|
||||
ARGF.last_lineno = ARGF.lineno;
|
||||
}
|
||||
else {
|
||||
ARGF.last_lineno = fptr->lineno;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue