summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/todo.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/todo.c b/src/todo.c
index 8d6334f..bb38b62 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -75,7 +75,8 @@ void todo_list(void) {
static const char *regular_text = "\e[0m";
char *line = NULL;
- size_t line_len = 0;
+ size_t line_buff_size = 0;
+ ssize_t line_len = 0;
errno = 0;
todo_file = fopen("TODO", "r");
@@ -89,9 +90,10 @@ void todo_list(void) {
}
}
- for (size_t i = 0; getline(&line, &line_len, todo_file) >= 0; i++) {
+ for (size_t i = 0;
+ (line_len = getline(&line, &line_buff_size, todo_file)) >= 0; i++) {
// Remove trailing newline by setting it to NULL char.
- line[strcspn(line, "\n")] = '\0';
+ line[line_len - 1] = '\0';
if (line_len > 5) {
// Print the index in bold
@@ -104,9 +106,8 @@ void todo_list(void) {
puts_strikethrough(line + 4);
}
}
-
- free(line);
}
+ free(line);
fclose(todo_file);
}
@@ -171,14 +172,9 @@ void todo_done(int argc, char **argv) {
apply_func_to_line(done, done_index);
}
-void todo_raw(int argc, char **argv) {
- /*open_todo_file();*/
- puts("raw");
- fclose(todo_file);
-}
+void todo_raw(int argc, char **argv) { fclose(todo_file); }
void todo_sort(void) {
- /*open_todo_file();*/
puts("sort");
fclose(todo_file);
}