aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-01-22 14:58:07 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-01-22 14:58:07 +0100
commitb0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee (patch)
tree2c1658de6ef4055395a565fce62aa583d297b85b
parentMakefile now places .o files in subdir. (diff)
downloadcalp-b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee.tar.gz
calp-b0def51bf3ad5c176e05e9e93fb5b303c9b0d6ee.tar.xz
Clean up a number of comments, and remove TODO's.
-rw-r--r--hash.inc2
-rw-r--r--main.c3
-rw-r--r--parse.c35
-rw-r--r--parse.h2
-rw-r--r--strbuf.c3
-rw-r--r--vcal.c6
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 <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);
}
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;
}