summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-14 03:38:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-14 03:38:06 +0000
commitff80e84db969c41e60771981d5236ecb474360b7 (patch)
tree23c47f4be02366831993f9c2cf09c8827022cbde
parentd4beba3f3ef026f56ecae9fc4fed963dd819d620 (diff)
* io.c (appendline): reformed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--io.c23
2 files changed, 12 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 0148cb2bf4..d6b7353f68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-Wed Jan 14 12:35:20 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 14 12:38:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (appendline): reformed.
* io.c (rb_io_s_pipe): reduced nest of rb_ensure of main block.
diff --git a/io.c b/io.c
index 733d978c05..30d44cd11f 100644
--- a/io.c
+++ b/io.c
@@ -2016,7 +2016,7 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
if (NEED_READCONV(fptr)) {
make_readconv(fptr, 0);
- while (1) {
+ do {
const char *p, *e;
int searchlen;
if (fptr->cbuf_len) {
@@ -2050,15 +2050,12 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
return (unsigned char)RSTRING_PTR(str)[RSTRING_LEN(str)-1];
}
}
-
- if (more_char(fptr) == -1) {
- *lp = limit;
- return EOF;
- }
- }
+ } while (more_char(fptr) != -1);
+ *lp = limit;
+ return EOF;
}
- while (1) {
+ do {
long pending = READ_DATA_PENDING_COUNT(fptr);
if (pending > 0) {
const char *p = READ_DATA_PENDING_PTR(fptr);
@@ -2082,15 +2079,13 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
*lp = limit;
if (e) return delim;
if (limit == 0)
- return (unsigned char)RSTRING_PTR(str)[RSTRING_LEN(str)-1];
+ return (unsigned char)RSTRING_PTR(str)[RSTRING_LEN(str)-1];
}
rb_thread_wait_fd(fptr->fd);
rb_io_check_closed(fptr);
- if (io_fillbuf(fptr) < 0) {
- *lp = limit;
- return EOF;
- }
- }
+ } while (io_fillbuf(fptr) >= 0);
+ *lp = limit;
+ return EOF;
}
static inline int