aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-15 15:30:37 +0100
committerBert <ber.t@gmx.com>2011-02-15 15:30:37 +0100
commite8ed491ba9f2fe6df8f071e7c59e0174bb307a1b (patch)
treee9f9bece1767f44df2bb83e756b45839f50230e4
parentcfed65d36fbacf6bec47869c86ea94f1cc49bcb5 (diff)
downloadnsxiv-e8ed491ba9f2fe6df8f071e7c59e0174bb307a1b.tar.zst
Fixed empty lines in readline()
-rw-r--r--Makefile2
-rw-r--r--main.c2
-rw-r--r--util.c6
3 files changed, 5 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 9bb2ce0..46eb750 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: sxiv
-VERSION=git-20110214
+VERSION=git-20110215
CC?=gcc
PREFIX?=/usr/local
diff --git a/main.c b/main.c
index 46f2cf6..9e5965b 100644
--- a/main.c
+++ b/main.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
if (options->from_stdin) {
while ((filename = readline(stdin))) {
- if (!check_append(filename))
+ if (!*filename || !check_append(filename))
free((void*) filename);
}
} else {
diff --git a/util.c b/util.c
index 82ab057..5c5737b 100644
--- a/util.c
+++ b/util.c
@@ -102,11 +102,11 @@ char* readline(FILE *stream) {
}
} while (!end && !feof(stream) && !ferror(stream));
- if (!ferror(stream) && *buf) {
+ if (ferror(stream)) {
+ s = NULL;
+ } else {
s = (char*) s_malloc((strlen(buf) + 1) * sizeof(char));
strcpy(s, buf);
- } else {
- s = NULL;
}
free(buf);