summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/io.c b/io.c
index c57e6ee..6d6c328 100644
--- a/io.c
+++ b/io.c
@@ -22,7 +22,10 @@ ssize_t more_getline(struct more_file *mf, size_t lineno)
fgetpos(mf->f, &(mf->tlines[mf->nlines - 1]));
- getline(&(mf->buf), &(mf->nbuf), mf->f);
+ if (getline(&(mf->buf), &(mf->nbuf), mf->f) == -1) {
+ return -1;
+ }
+
if (mf->nlines > 1) {
mf->bytepos[mf->nlines - 1] = mf->bytepos[mf->nlines - 2] + strlen(mf->buf);
} else {
@@ -48,7 +51,7 @@ struct more_file more_open(const char *path)
if (strcmp(path, "-")) {
mf.f = fopen(path, "r");
if (!mf.f) {
- fprintf(stderr, "more: %s: %s\n", path, strerror(errno));
+ fprintf(stderr, "more: %s: %s\r\n", path, strerror(errno));
return mf;
}
}