diff options
author | Ariadna Vigo <arivigodr@gmail.com> | 2020-08-09 19:51:48 +0200 |
---|---|---|
committer | Ariadna Vigo <arivigodr@gmail.com> | 2020-08-09 19:51:48 +0200 |
commit | 8dad42e7d4f17ee1a1449c4aab775d61b4544458 (patch) | |
tree | 93322e54212d3df5d17c59c0d51069f926448612 | |
parent | ea391d8c8f0a8dcc2ff2220ee24c6cba4884c5aa (diff) |
stdin input chomped in a better way
-rw-r--r-- | cras.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -93,7 +93,6 @@ print_task(Task task, int i) printf("%s\n", task.tdesc); } - static void print_short_output(TaskLst list) { @@ -176,7 +175,10 @@ store_input(TaskLst *list, FILE *fp) if (fgets(linebuf, TASK_LST_DESC_MAX_SIZE, fp) == NULL) break; - linebuf[strlen(linebuf) - 1] = '\0'; /* Chomp '\n' */ + /* Chomp '\n' */ + if (linebuf[strlen(linebuf) - 1] == '\n') + linebuf[strlen(linebuf) - 1] = '\0'; + if (task_lst_add_task(list, TASK_TODO, linebuf) < 0) return -1; } |