From 6d5a32fc3bf707bafc19e239dd60371bece90fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 4 Oct 2019 00:05:46 +0200 Subject: General cleanup in parse. --- src/parse.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/parse.c b/src/parse.c index 996c0a92..fbfb2387 100644 --- a/src/parse.c +++ b/src/parse.c @@ -73,6 +73,9 @@ int parse_file(char* filename, FILE* f, SCM root) { SCM attr_key; /* string */ SCM line_key = scm_from_utf8_string(""); /* string */ + SCM scm_filename = scm_from_utf8_stringn(filename, strlen(filename)); + SCM filename_key = scm_from_utf8_string("X-HNH-FILENAME"); + char c; while ( (c = fgetc(f)) != EOF) { /* We have a linebreak */ @@ -91,15 +94,11 @@ 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_from_utf8_stringn(filename, strlen(filename))); - scm_add_line_x(child, scm_from_utf8_string("X-HNH-FILENAME"), - templine); + scm_add_line_x(child, filename_key, scm_make_vline(scm_filename)); component = child; } else if (string_eq(line_key, scm_from_utf8_string("END"))) { - // TODO make current component be parent of current component? component = scm_component_parent(component); /* @@ -153,12 +152,6 @@ int parse_file(char* filename, FILE* f, SCM root) { * parameters. */ if (p_ctx == p_key) { - - // TRANSFER(&cline_key, &ctx.str); - - // NEW(content_set, p); - // PUSH(LLIST(content_set))(&cline, p); - // attr_key line_key = scm_from_strbuf(&str); strbuf_soft_reset (&str); } -- cgit v1.2.3