nsxive8ed491
Fixed empty lines in readline()
+5 −5
3 files changed
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | all: sxiv | |
| 2 | 2 | ||
| 3 | − | VERSION=git-20110214 | |
| 3 | + | VERSION=git-20110215 | |
| 4 | 4 | ||
| 5 | 5 | CC?=gcc | |
| 6 | 6 | PREFIX?=/usr/local | |
| @@ -91,7 +91,7 @@ int main(int argc, char **argv) { | |||
| 91 | 91 | ||
| 92 | 92 | if (options->from_stdin) { | |
| 93 | 93 | while ((filename = readline(stdin))) { | |
| 94 | − | if (!check_append(filename)) | |
| 94 | + | if (!*filename || !check_append(filename)) | |
| 95 | 95 | free((void*) filename); | |
| 96 | 96 | } | |
| 97 | 97 | } else { | |
| @@ -102,11 +102,11 @@ char* readline(FILE *stream) { | |||
| 102 | 102 | } | |
| 103 | 103 | } while (!end && !feof(stream) && !ferror(stream)); | |
| 104 | 104 | ||
| 105 | − | if (!ferror(stream) && *buf) { | |
| 105 | + | if (ferror(stream)) { | |
| 106 | + | s = NULL; | |
| 107 | + | } else { | |
| 106 | 108 | s = (char*) s_malloc((strlen(buf) + 1) * sizeof(char)); | |
| 107 | 109 | strcpy(s, buf); | |
| 108 | − | } else { | |
| 109 | − | s = NULL; | |
| 110 | 110 | } | |
| 111 | 111 | ||
| 112 | 112 | free(buf); | |