aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-06-14 12:33:22 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-06-14 12:33:22 -0400
commita126523db70b872795c488f947f8a9315f2d5118 (patch)
tree99d286cb3b11058f73bb3abffbbabd4a8bbbc746
parent6efdaa8ac39129bfd31ec14cae1075075688ab95 (diff)
wsclean sets length to sz-2, so n == 0
-rw-r--r--read.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/read.c b/read.c
index 5d7602d..f1ecea9 100644
--- a/read.c
+++ b/read.c
@@ -42,7 +42,6 @@ static char* getline(size_t* n, FILE* file) {
if (c == '\n') break;
}
out[(*n)] = 0;
- //(*n)++;
return realloc(out, sizeof(char) * (*n+1) );
}
@@ -51,7 +50,7 @@ static char* line(FILE* file, bool nl) { // gets a line from file
char* link = getline(&n, file);
// getline stores a line of len n (size n+1) in link
wsclean(link, &n); // removes trailing whitespace
- if (n == 1) { // "\n" => ""
+ if (n == 0) { // "\n" => ""
free(link);
return empty();
} else { // else return obtained