Krolyxon
Commit e8ed491

Branches

Refs →

nsxive8ed491

Fixed empty lines in readline()

Author
Bert
Date
2011-02-15 15:30 +0100
Parent
cfed65d
Commit
e8ed491ba9f2fe6df8f071e7c59e0174bb307a1b

+5 −5

3 files changed

  1. M Makefile +1 −1
  2. M main.c +1 −1
  3. M util.c +3 −3
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION=git-20110214
3+VERSION=git-20110215
44
55 CC?=gcc
66 PREFIX?=/usr/local
M main.c View
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
9191
9292 if (options->from_stdin) {
9393 while ((filename = readline(stdin))) {
94− if (!check_append(filename))
94+ if (!*filename || !check_append(filename))
9595 free((void*) filename);
9696 }
9797 } else {
M util.c View
@@ -102,11 +102,11 @@ char* readline(FILE *stream) {
102102 }
103103 } while (!end && !feof(stream) && !ferror(stream));
104104
105− if (!ferror(stream) && *buf) {
105+ if (ferror(stream)) {
106+ s = NULL;
107+ } else {
106108 s = (char*) s_malloc((strlen(buf) + 1) * sizeof(char));
107109 strcpy(s, buf);
108− } else {
109− s = NULL;
110110 }
111111
112112 free(buf);