aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-10-03 23:56:59 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-10-03 23:56:59 +0200
commit60d51e5700a55bc3ae17e34f9f3da1d4653a3026 (patch)
tree7ae258360215ce63c591204f5ba8ec7080305f1e
parentFix problem with no end date. (diff)
downloadcalp-60d51e5700a55bc3ae17e34f9f3da1d4653a3026.tar.gz
calp-60d51e5700a55bc3ae17e34f9f3da1d4653a3026.tar.xz
Everything seems to parse now.
-rw-r--r--module/vcomponent/base.scm2
-rw-r--r--module/vcomponent/recurrence/generate.scm19
-rw-r--r--src/calendar.c6
-rw-r--r--src/parse.c9
-rw-r--r--src/struct.h2
-rw-r--r--src/struct.scm.c13
6 files changed, 31 insertions, 20 deletions
diff --git a/module/vcomponent/base.scm b/module/vcomponent/base.scm
index 986037f5..38034a81 100644
--- a/module/vcomponent/base.scm
+++ b/module/vcomponent/base.scm
@@ -41,7 +41,7 @@
(format #t "map = ~a~%" (struct-ref component 3))
(let ((return (hash-set! (struct-ref component 3)
(as-string attr)
- value)))
+ (make-vline value))))
(format #t "Return = ~a~%" return)
return
diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm
index 435d3009..a274ecfa 100644
--- a/module/vcomponent/recurrence/generate.scm
+++ b/module/vcomponent/recurrence/generate.scm
@@ -73,6 +73,8 @@
(date->time-utc d))
(when (attr e 'DTEND)
+ (format #t "file = ~a~%dtstart = ~a~%duration = ~a~%"
+ (attr e 'X-HNH-FILENAME) (attr e 'DTSTART) (attr e 'DURATION))
(set! (attr e 'DTEND)
(add-duration (attr e 'DTSTART) (attr e 'DURATION))))
@@ -124,12 +126,21 @@
(if (not (attr event 'RRULE))
(stream event)
(begin
+ (format #t "!!! DURATION = ~a~%" (attr event 'DURATION))
(when (and (attr event 'DTEND)
(not (attr event 'DURATION)))
- (set! (attr event "DURATION")
- (time-difference
- (attr event "DTEND")
- (attr event "DTSTART"))))
+ (let ((dt (time-difference (attr event "DTEND") (attr event "DTSTART") )))
+ (format #t "duration = ~a~%start = ~a, end = ~a~%diff = ~a~%"
+ (attr event "DURATION")
+ (attr event "DTSTART") (attr event "DTEND")
+ dt)
+ (set! (attr event "DURATION")
+ dt
+ #;
+ (time-difference
+ (attr event "DTEND")
+ (attr event "DTSTART")))))
+ (format #t "||| DURATION = ~a~%" (attr* event "DURATION"))
(if (attr event "RRULE")
(recur-event-stream event (parse-recurrence-rule (attr event "RRULE")))
;; TODO some events STANDARD and DAYLIGT doesn't have RRULE's, but rather
diff --git a/src/calendar.c b/src/calendar.c
index a90dfe44..7d8d598e 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -47,8 +47,7 @@ int handle_file(SCM cal, char* path) {
/* NAME is the `fancy' name of the calendar. */
// vcomponent_push_val(cal, "NAME", basename(path));
// vcomponent_push_val(cal, "X-HNH-SOURCETYPE", "file");
- SCM line = scm_make_vline();
- scm_struct_set_x(line, vline_value, scm_from_utf8_string("file"));
+ SCM line = scm_make_vline(scm_from_utf8_string("file"));
scm_add_line_x(cal, scm_from_utf8_string("X-HNH-SOURCETYPE"), line);
char* resolved_path = realpath(path, NULL);
open_ics (resolved_path, cal);
@@ -73,8 +72,7 @@ int handle_dir(SCM cal, char* path) {
/* NAME is the `fancy' name of the calendar. */
// vcomponent_push_val(cal, "NAME", basename(path));
- SCM line = scm_make_vline();
- scm_struct_set_x(line, vline_value, scm_from_utf8_string("vdir"));
+ SCM line = scm_make_vline(scm_from_utf8_string("vdir"));
scm_add_line_x(cal, scm_from_utf8_string("X-HNH-SOURCETYPE"), line);
struct dirent* d;
diff --git a/src/parse.c b/src/parse.c
index 48b58b95..8c370958 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -69,7 +69,7 @@ int parse_file(char* filename, FILE* f, SCM root) {
SNEW(strbuf, str);
SCM component = root;
- SCM line = scm_make_vline();
+ SCM line = scm_make_vline(SCM_UNDEFINED);
SCM attr_key; /* string */
SCM line_key = scm_from_utf8_string(""); /* string */
@@ -98,9 +98,8 @@ int parse_file(char* filename, FILE* f, SCM root) {
/* TODO it should be possible to create this object once
at the top of this function
*/
- SCM templine = scm_make_vline();
- scm_struct_set_x(templine, vline_value,
- scm_from_utf8_stringn(filename, strlen(filename)));
+ SCM templine =
+ scm_make_vline(scm_from_utf8_stringn(filename, strlen(filename)));
scm_add_line_x(child, scm_from_utf8_string("X-HNH-FILENAME"),
templine);
@@ -120,7 +119,7 @@ int parse_file(char* filename, FILE* f, SCM root) {
INFO_F("Adding attribute [%s]", str.mem);
scm_struct_set_x(line, vline_value, scm_from_strbuf(&str));
scm_add_line_x(component, line_key, line);
- line = scm_make_vline();
+ line = scm_make_vline(SCM_UNDEFINED);
}
strbuf_soft_reset (&str);
diff --git a/src/struct.h b/src/struct.h
index d39cf471..a66dc201 100644
--- a/src/struct.h
+++ b/src/struct.h
@@ -17,7 +17,7 @@
SCM scm_make_vcomponent(SCM);
SCM scm_add_line_x (SCM, SCM, SCM);
SCM scm_add_child_x (SCM, SCM);
-SCM scm_make_vline ();
+SCM scm_make_vline (SCM);
SCM scm_add_attribute_x (SCM, SCM, SCM);
#endif /* STRUCT_H */
diff --git a/src/struct.scm.c b/src/struct.scm.c
index 9b11696d..a8e7b3c6 100644
--- a/src/struct.scm.c
+++ b/src/struct.scm.c
@@ -28,7 +28,7 @@ SCM_DEFINE(scm_parse_cal_path, "parse-cal-path", 1, 0, 0,
(SCM path),
"")
{
- SCM root = scm_make_vcomponent(SCM_UNSPECIFIED);
+ SCM root = scm_make_vcomponent(SCM_UNDEFINED);
char* p = scm_to_utf8_stringn(path, NULL);
read_vcalendar(root, p);
@@ -58,12 +58,15 @@ SCM_DEFINE(scm_add_child_x, "add-child!", 2, 0, 0,
}
-SCM_DEFINE(scm_make_vline, "make-vline", 0, 0, 0,
- (), "")
+SCM_DEFINE(scm_make_vline, "make-vline", 0, 1, 0,
+ (SCM value), "")
{
+
+ if (SCM_UNBNDP (value)) value = SCM_BOOL_F;
+
return scm_make_struct_no_tail
- (vline_vtable,
- scm_list_2(SCM_BOOL_F, scm_make_hash_table(scm_from_int(0x10))));
+ (vline_vtable,
+ scm_list_2(value, scm_make_hash_table(scm_from_int(0x10))));
}