Skip to content

Commit

Permalink
- Fix builtin gets() emulation (hopefully).
Browse files Browse the repository at this point in the history
  • Loading branch information
mfn committed Jun 11, 2002
1 parent 137a290 commit 17b3ef4
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions main/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,13 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML
return NULL;
} else {
/* unbuffered fgets - poor performance ! */
size_t n = 1;
char *c = buf;

/* TODO: look at error returns? */

while(n < maxlen && stream->ops->read(stream, c, 1 TSRMLS_CC) > 0) {
n++;
if (*c == '\n') {
c++;
break;
}
c++;
}
*c = 0;
return buf;
while (--maxlen > 0 && stream->ops->read(stream, buf, 1 TSRMLS_CC) == 1 && *buf++ != '\n');
*buf = '\0';
return c == buf && maxlen > 0 ? NULL : c;
}
}

Expand Down

0 comments on commit 17b3ef4

Please sign in to comment.