aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-30 09:33:52 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-30 09:33:52 +0100
commitae9d65b8a3f4a35bc01c8225f226e6420dfebe48 (patch)
tree6dbe7b9c35e196448f9d7db66f1f32277babe309 /src/mds-kbdc
parentpreparing for include processing (diff)
downloadmds-ae9d65b8a3f4a35bc01c8225f226e6420dfebe48.tar.gz
mds-ae9d65b8a3f4a35bc01c8225f226e6420dfebe48.tar.bz2
mds-ae9d65b8a3f4a35bc01c8225f226e6420dfebe48.tar.xz
mds-kbdc: add support for empty files
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc')
-rw-r--r--src/mds-kbdc/make-tree.c8
-rw-r--r--src/mds-kbdc/mds-kbdc.c5
-rw-r--r--src/mds-kbdc/raw-data.c3
3 files changed, 13 insertions, 3 deletions
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c
index cdfae40..fab402b 100644
--- a/src/mds-kbdc/make-tree.c
+++ b/src/mds-kbdc/make-tree.c
@@ -1027,6 +1027,14 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
}
}
+ /* Warn about empty files. */
+ if (result->tree == NULL)
+ {
+ char* line = NULL;
+ char* end = NULL;
+ NEW_ERROR(0, WARNING, "file is empty");
+ }
+
free(keyword_stack);
free(tree_stack);
return 0;
diff --git a/src/mds-kbdc/mds-kbdc.c b/src/mds-kbdc/mds-kbdc.c
index a2b5b70..318fc3c 100644
--- a/src/mds-kbdc/mds-kbdc.c
+++ b/src/mds-kbdc/mds-kbdc.c
@@ -20,6 +20,7 @@
#include "globals.h"
#include "make-tree.h"
#include "simplify-tree.h"
+#include "process-includes.h"
#include <libmdsserver/macros.h>
@@ -52,8 +53,8 @@ int main(int argc_, char** argv_)
mds_kbdc_parsed_initialise(&result);
process (parse_to_tree(argv[1], &result));
- //process (simplify_tree(&result));
- //process (process_includes(&result));
+ process (simplify_tree(&result));
+ process (process_includes(&result));
/* TODO process (validate_tree(&result)); */
/* TODO process (eliminate_dead_code(&result)); */
/* TODO process (compile_layout(&result)); */
diff --git a/src/mds-kbdc/raw-data.c b/src/mds-kbdc/raw-data.c
index a1f8ec3..b0985fe 100644
--- a/src/mds-kbdc/raw-data.c
+++ b/src/mds-kbdc/raw-data.c
@@ -115,7 +115,8 @@ static char* read_file(const char* restrict pathname, size_t* restrict size)
}
/* Shrink the buffer so it is not excessively large. */
- fail_if (xxrealloc(old, content, buf_ptr, char));
+ if (buf_ptr) /* Simplest way to handle empty files: let the have the initial allocation size. */
+ fail_if (xxrealloc(old, content, buf_ptr, char));
/* Close file decriptor for the file. */
close(fd);