summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadna Vigo <arivigodr@gmail.com>2020-08-09 19:51:48 +0200
committerAriadna Vigo <arivigodr@gmail.com>2020-08-09 19:51:48 +0200
commit8dad42e7d4f17ee1a1449c4aab775d61b4544458 (patch)
tree93322e54212d3df5d17c59c0d51069f926448612
parentea391d8c8f0a8dcc2ff2220ee24c6cba4884c5aa (diff)
stdin input chomped in a better way
-rw-r--r--cras.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/cras.c b/cras.c
index 7e63212..562ae0b 100644
--- a/cras.c
+++ b/cras.c
@@ -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;
}