aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-10 01:05:15 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-10 01:05:15 +0100
commit226e98b5fb330449996801dcbaa1a7b044d711ae (patch)
tree4054d5c7bb4918245b063d6bc1c168b20ee07e02
parentAdd attr_helper to graph output. (diff)
downloadcalp-226e98b5fb330449996801dcbaa1a7b044d711ae.tar.gz
calp-226e98b5fb330449996801dcbaa1a7b044d711ae.tar.xz
Minor general cleanup.
-rw-r--r--parse.c15
-rw-r--r--parse.h7
-rw-r--r--vcal.c4
-rw-r--r--vcal.h10
4 files changed, 15 insertions, 21 deletions
diff --git a/parse.c b/parse.c
index 77c3f8db..e10e8b23 100644
--- a/parse.c
+++ b/parse.c
@@ -13,6 +13,9 @@
#include "linked_list.inc.h"
#undef TYPE
+/*
+ * name *(";" param) ":" value CRLF
+ */
int parse_file(char* filename, FILE* f, vcomponent* root) {
int segments = 1;
SNEW(strbuf, str, segments * SEGSIZE);
@@ -81,6 +84,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) {
}
strbuf_copy(cline.vals.cur->value, &str);
+
/* TODO when do I actualy cap? */
// strbuf_cap(cline.vals.cur->value);
@@ -132,26 +136,31 @@ int parse_file(char* filename, FILE* f, vcomponent* root) {
vallen = str.ptr + 1;
strbuf_realloc(cline.vals.cur->value, vallen);
}
+
strbuf_copy(cline.vals.cur->value, &str);
strbuf_cap(cline.vals.cur->value);
handle_kv(&cline, line, &ctx);
+
}
+
FREE(strbuf)(&str);
FREE(content_line)(&cline);
// FREE(strbuf)(ctx.skip_to);
+
assert(POP(LLIST(vcomponent))(&ctx.comp_stack) == root);
assert(EMPTY(LLIST(strbuf))(&ctx.key_stack));
assert(EMPTY(LLIST(vcomponent))(&ctx.comp_stack));
+
FREE(LLIST(strbuf))(&ctx.key_stack);
FREE(LLIST(vcomponent))(&ctx.comp_stack);
free(ctx.filename);
+ FREE(strbuf)(&kv.key);
+ FREE(strbuf)(&kv.val);
+
return 0;
}
-/*
- * TODO Extend this to handle properties
- */
int handle_kv (
content_line* cline,
int line,
diff --git a/parse.h b/parse.h
index ad1cebc2..c02c07c8 100644
--- a/parse.h
+++ b/parse.h
@@ -20,17 +20,12 @@
*/
#define SEGSIZE 75
-#define LINE(nr, key, value) fprintf(stderr, "(%i) %i: [%s] := [%s]\n", __LINE__, nr, key, value);
+// #define LINE(nr, key, value) fprintf(stderr, "(%i) %i: [%s] := [%s]\n", __LINE__, nr, key, value);
typedef enum {
p_key, p_value, p_param_name, p_param_value
} part_context;
-typedef enum {
- s_none = 1, s_calendar, s_event,
- s_skip
-} scope_context;
-
typedef struct {
char* filename;
LLIST(strbuf) key_stack;
diff --git a/vcal.c b/vcal.c
index b54a0370..369e1016 100644
--- a/vcal.c
+++ b/vcal.c
@@ -45,8 +45,8 @@ INIT_F(vcomponent, char* type, char* filename) {
}
content_line* RESOLVE(content_line)
- (content_line* dest, content_line* new) {
-
+ (content_line* dest, content_line* new)
+{
if (dest == NULL) return new;
if (strbuf_cmp(&dest->key, &new->key) != 0) {
diff --git a/vcal.h b/vcal.h
index dc639232..a27bd648 100644
--- a/vcal.h
+++ b/vcal.h
@@ -10,16 +10,6 @@
// #include "trie.h"
#undef TYPE
-/*
-typedef struct {
- strbuf key;
- strbuf value;
-
- strbuf* vals;
- int val_count;
-} parameter;
-*/
-
typedef struct {
strbuf key;
strbuf val;