aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-05-01 16:24:04 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-05-01 16:24:04 +0200
commit074e15e1fe706c1511416803ad5b8b28e955115e (patch)
treeea55e4836ac3219aafca4f625c84d93a7013c169
parentChange how attributes are fetched. (diff)
downloadcalp-074e15e1fe706c1511416803ad5b8b28e955115e.tar.gz
calp-074e15e1fe706c1511416803ad5b8b28e955115e.tar.xz
Remove trailintg newline from parsed displayname files.
-rw-r--r--src/calendar.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/calendar.c b/src/calendar.c
index b437d98d..500f0827 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -81,20 +81,29 @@ int handle_dir(vcomponent* cal, char* path) {
buf[path_len] = '\0';
FILE* f;
- char info_buf[0x100];
+ size_t read, size = 0x100;
+ char* info_buf = malloc(size);
if (strcmp (d->d_name, "color") == 0) {
f = fopen(resolved_path, "r");
- fgets(info_buf, 0x100, f);
- if (info_buf[strlen(info_buf) - 1] == '\n')
- info_buf[strlen(info_buf) - 1] = '\0';
+ read = getline(&info_buf, &size, f);
+ if (info_buf[read - 1] == '\n')
+ info_buf[read - 1] = '\0';
fclose(f);
vcomponent_push_val(cal, "COLOR", info_buf);
} else if (strcmp (d->d_name, "displayname") == 0) {
f = fopen(resolved_path, "r");
- fgets(info_buf, 0x100, f);
+ read = getline(&info_buf, &size, f);
+ if (info_buf[read - 1] == '\n')
+ info_buf[read - 1] = '\0';
+
fclose(f);
- // TODO make sure that this replaces
+
+ /* This adds the new list to the set of names, keeping the
+ * filename name.
+ * This works since *currently* values are returned in
+ * reverse order
+ */
vcomponent_push_val(cal, "NAME", info_buf);
} else {
open_ics (resolved_path, cal);