diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-01-22 14:58:07 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-01-22 14:58:07 +0100 |
commit | b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee (patch) | |
tree | 2c1658de6ef4055395a565fce62aa583d297b85b | |
parent | Makefile now places .o files in subdir. (diff) | |
download | calp-b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee.tar.gz calp-b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee.tar.xz |
Clean up a number of comments, and remove TODO's.
-rw-r--r-- | hash.inc | 2 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | parse.c | 35 | ||||
-rw-r--r-- | parse.h | 2 | ||||
-rw-r--r-- | strbuf.c | 3 | ||||
-rw-r--r-- | vcal.c | 6 |
6 files changed, 13 insertions, 38 deletions
@@ -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; @@ -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); } @@ -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 <errno.h> #include <string.h> +#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); } @@ -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 @@ -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) { @@ -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; } |