summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <marcin@zelent.net>2017-08-29 11:59:48 +0200
committermarcinzelent <marcin@zelent.net>2017-08-29 11:59:48 +0200
commit0db653710aa72601c920f10437a9c169d9ca5b36 (patch)
tree81d36c92f71f508641e1cd59da7ae1dc272a4b04
parentb3e980d2133a503b854bf3d4a840ea4cac899d22 (diff)
Fixed reading file where description had spaces.
-rw-r--r--timetracker.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/timetracker.c b/timetracker.c
index 8f9872e..8bb702c 100644
--- a/timetracker.c
+++ b/timetracker.c
@@ -157,6 +157,7 @@ void edit_new_activity()
ch = wgetch(win);
switch(ch)
{
+ /*
case KEY_LEFT:
form_driver(form, REQ_PREV_CHAR);
break;
@@ -169,9 +170,11 @@ void edit_new_activity()
case KEY_DOWN:
form_driver(form, REQ_PREV_LINE);
break;
- case 127:
+ */
+ case 127:
form_driver(form, REQ_PREV_CHAR);
form_driver(form, REQ_DEL_CHAR);
+ new_activity.description[strlen(new_activity.description)-1] = '\0';
break;
case 27:
memset(&new_activity.description[0], 0, sizeof(new_activity.description));
@@ -233,7 +236,7 @@ void load_file(char *filepath)
int i;
fp = fopen(filepath, "r");
- while (EOF != fscanf(fp, "%ld;%ld;%s", &activities_list[i].start_time, &activities_list[i].end_time,
- activities_list[i].description)) i++;
+ while (EOF != fscanf(fp, "%ld;%ld;%[^\n]", &activities_list[i].start_time,
+ &activities_list[i].end_time, activities_list[i].description)) i++;
fclose(fp);
}