Fixed empty lines in readline()
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
|||||||
all: sxiv
|
all: sxiv
|
||||||
|
|
||||||
VERSION=git-20110214
|
VERSION=git-20110215
|
||||||
|
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
PREFIX?=/usr/local
|
PREFIX?=/usr/local
|
||||||
|
2
main.c
2
main.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (options->from_stdin) {
|
if (options->from_stdin) {
|
||||||
while ((filename = readline(stdin))) {
|
while ((filename = readline(stdin))) {
|
||||||
if (!check_append(filename))
|
if (!*filename || !check_append(filename))
|
||||||
free((void*) filename);
|
free((void*) filename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
6
util.c
6
util.c
@@ -102,11 +102,11 @@ char* readline(FILE *stream) {
|
|||||||
}
|
}
|
||||||
} while (!end && !feof(stream) && !ferror(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));
|
s = (char*) s_malloc((strlen(buf) + 1) * sizeof(char));
|
||||||
strcpy(s, buf);
|
strcpy(s, buf);
|
||||||
} else {
|
|
||||||
s = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
Reference in New Issue
Block a user