From b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 22 Jan 2019 14:58:07 +0100 Subject: Clean up a number of comments, and remove TODO's. --- hash.inc | 2 -- main.c | 3 --- parse.c | 35 +++++++++++------------------------ parse.h | 2 ++ strbuf.c | 3 --- vcal.c | 6 ------ 6 files changed, 13 insertions(+), 38 deletions(-) diff --git a/hash.inc b/hash.inc index 34766b54..81da6218 100644 --- a/hash.inc +++ b/hash.inc @@ -9,8 +9,6 @@ int HASH_PUT(TYPE) ( TABLE(TYPE)* table, TYPE* value) { unsigned long h = hash(value->key.mem) % table->size; TYPE* mem = table->values[h]; - // fprintf(stderr, "INFO: %i: [%s] := [%s]\n", table->item_count, value->key.mem, value->val.mem); - /* TODO conflict resolution */ if (mem != NULL) ERR("Hash collision"); mem = value; diff --git a/main.c b/main.c index ee6dfa89..475f9ddc 100644 --- a/main.c +++ b/main.c @@ -61,9 +61,6 @@ int main (int argc, char* argv[argc]) { printf("\nParsed calendar file containing [%lu] events\n", cal.n_events); for (size_t i = 0; i < cal.n_events; i++) { - // printf("%3lu. %s\n", i + 1, cal.events[i].summary.mem); - // TODO this segfaults - // apparently get_property returns 0 in some cases printf("%3lu. %s\n", i + 1, get_property(cal.events[i], "SUMMARY")->val.mem); } diff --git a/parse.c b/parse.c index 66d35a15..2850a51c 100644 --- a/parse.c +++ b/parse.c @@ -1,19 +1,10 @@ #include "parse.h" -#include "macro.h" - - -/* - * TODO currently not all pointers inside strbufs are reset correctly, - * leading to old garbage data being read way to much. - * - * A better ERR macro would solve most problems, - * along with the introduction of a MSG macro. - */ - #include #include +#include "macro.h" + int parse_file(FILE* f, vcalendar* cal) { int segments = 1; SNEW(strbuf, str, segments * SEGSIZE); @@ -26,7 +17,6 @@ int parse_file(FILE* f, vcalendar* cal) { int line = 0; - // TODO these are never freed. NEW(vevent, ev); SNEW(content_line, cline, keylen, vallen); @@ -47,24 +37,21 @@ int parse_file(FILE* f, vcalendar* cal) { if (s[0] != '\n') { ERR("expected newline after CR", line); } else if (s[1] == ' ' || s[1] == '\t') { - /* - * Folded line, increase size of key and continue. - */ + /* Folded line, increase size of key and continue. */ - // TODO check return value - // TODO segments is always incremented here, meaning - // that segment grows larger for every multi line - // encountered. - if (strbuf_realloc(&str, ++segments * SEGSIZE) != 0) { /* TODO signal error */ + /* TODO segments is always incremented here, meaning + * that segment grows larger for every multi line + * encountered. + */ + if (strbuf_realloc(&str, ++segments * SEGSIZE) != 0) { ERR("Failed to realloc strbuf", line); exit (1); } continue; } else { - /* - * Actuall end of line, handle values. - */ - if (ungetc(s[1], f) != s[1]) { /* TODO signal error */ + /* Actuall end of line, handle values. */ + if (ungetc(s[1], f) != s[1]) { + ERR("Failed to put character back on FILE", line); exit (2); } diff --git a/parse.h b/parse.h index 424e88bf..76611599 100644 --- a/parse.h +++ b/parse.h @@ -11,6 +11,8 @@ * Max length of a line. * TODO update this to allow longer lines, in case someone doesn't * follow the standard. + * (I currently only realloc memmory at end of lines, not when my + * buffer is full). */ #define SEGSIZE 75 diff --git a/strbuf.c b/strbuf.c index b37bb77a..4490ed4a 100644 --- a/strbuf.c +++ b/strbuf.c @@ -23,9 +23,6 @@ int CONSTRUCTOR_DECL(strbuf, size_t len) { return 0; } -/* - * TODO check if this is the problem. - */ int strbuf_realloc(strbuf* str, size_t len) { #ifdef SAFE_STR if (str->mem == NULL || str->alloc == 0) { diff --git a/vcal.c b/vcal.c index cb7adec3..65caaa26 100644 --- a/vcal.c +++ b/vcal.c @@ -13,12 +13,10 @@ int CONSTRUCTOR_DECL(vevent) { } content_line* get_property (vevent* ev, char* key) { - // return HASH_GET(content_line)(&ev->clines, key); return TRIE_GET(content_line)(&ev->clines, key); } int add_content_line (vevent* ev, content_line* c) { - // return HASH_PUT(content_line)(&ev->clines, c); // TODO memmory safety on strbuf? return TRIE_PUT(content_line)(&ev->clines, c->key.mem, c); } @@ -41,18 +39,14 @@ int CONSTRUCTOR_DECL(content_line, int keylen, int vallen) { int content_line_copy (content_line* dest, content_line* src) { strbuf_init_copy(&dest->key, &src->key); strbuf_init_copy(&dest->val, &src->val); - // TODO remaining fields - return 0; } int FREE_DECL(content_line) { FREE(strbuf)(&this->key); FREE(strbuf)(&this->val); - // TODO remaining fields - return 0; } -- cgit v1.2.3