diff options
Diffstat (limited to '')
-rw-r--r-- | linked_list.h | 15 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | parse.cpp | 27 | ||||
-rw-r--r-- | vcal.cpp | 2 | ||||
-rw-r--r-- | vcal.h | 3 |
5 files changed, 28 insertions, 21 deletions
diff --git a/linked_list.h b/linked_list.h index 7ed4c6c4..75096a93 100644 --- a/linked_list.h +++ b/linked_list.h @@ -39,6 +39,8 @@ struct llist { int size () { return length; } bool empty () { return length == 0; } + + void reset (); }; template <typename T> @@ -72,6 +74,19 @@ void llist<T>::push(T* val) { this->__cur = l; } +template <typename T> +void llist<T>::reset () { + llink<T> *link = this->first, *next; + + while (link != this->tail) { + next = link->after; + delete link; + link = next; + } + + this->__cur = this->head; +} + // template <typename T> // std::ostream& std::operator<<(std::ostream&, llist<T>); @@ -23,7 +23,7 @@ int arg_shift (arg* a) { } int main (int argc, char** argv) { - arg args = { .argc = argc, .argv = argv }; + arg args = { argc, argv }; if (arg_shift(&args) == 0) { ERR("Please give vdir or a vcalendar file as first argument"); @@ -64,7 +64,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { } } - /* Escaped new_line */ + /* Escaped newline */ if (esc == 'n' || esc == 'N') { target = '\n'; @@ -78,7 +78,6 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { } /* save escapade character as a normal character */ - // strbuf_append(&ctx.str, target); ctx.str += target; ++ctx.column; @@ -87,20 +86,10 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { /* Border between param {key, value} */ } else if (p_ctx == p_param_name && c == '=') { - // LLIST(param_set)* params = CLINE_CUR_PARAMS(&cline); - /* - std::list<param_set>* params = cline.val.val; - - // NEW(param_set, ps); - auto ps = new param_set; - // TODO make sure this is a deep copy - ps->first = ctx.str; - ps->first.cap(); + strbuf cpy = ctx.str; + cpy.cap(); ctx.str.soft_reset(); - params += ps; - // PUSH(LLIST(param_set))(params, ps); - * - */ + cline.push_param_key (cpy); p_ctx = p_param_value; @@ -116,7 +105,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { if (p_ctx == p_param_value) { /* push kv pair */ - auto s = new strbuf(ctx.str);; + auto s = new strbuf(ctx.str); s->cap(); ctx.str.soft_reset(); @@ -124,10 +113,11 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { } if (p_ctx == p_key) { - // cline.first = ctx.str; - // cline.first.cap(); + cline.key = ctx.str; + cline.key.cap(); ctx.str.soft_reset(); + // TODO? // content_set* p = new content_set; // cline.second.push(p); } @@ -190,6 +180,7 @@ int handle_kv ( *s = *type; ctx->key_stack.push(s); + cline->values.reset(); // TODO ompty cline->second here; // RESET(LLIST(content_set))(&cline->val); @@ -8,7 +8,7 @@ vcomponent::vcomponent( const std::string& filename) : type(type) , filename(filename) -{ }; +{ } std::ostream& operator<<(std::ostream& o, vcomponent* self) { for (int i = 0; i < 40; i++) o << '_'; @@ -40,7 +40,8 @@ struct content_line { this->values.cur()->params.push(p); } - inline void push_param_value (strbuf* value) { this->values.cur()->params.cur()->values.push(value); } + inline void push_param_value (strbuf* value) + { this->values.cur()->params.cur()->values.push(value); } inline strbuf* value() { return &this->values.cur()->value; } |