diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-16 04:51:14 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-16 04:51:14 +0100 |
commit | 893c0d1c41440bf2a233e5fb69b0aa76c221e876 (patch) | |
tree | 56b912fa88fe3b623c6462ac623e6d5239e3c8e5 /src/mds-kbdc | |
parent | mds-kbdc: fix let without array (diff) | |
download | mds-893c0d1c41440bf2a233e5fb69b0aa76c221e876.tar.gz mds-893c0d1c41440bf2a233e5fb69b0aa76c221e876.tar.bz2 mds-893c0d1c41440bf2a233e5fb69b0aa76c221e876.tar.xz |
mds-kbdc: fix array elements: allow functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc')
-rw-r--r-- | src/mds-kbdc/make-tree.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c index d32f222..7aff73e 100644 --- a/src/mds-kbdc/make-tree.c +++ b/src/mds-kbdc/make-tree.c @@ -210,6 +210,16 @@ /** + * Suppress the next `line += strlen(line)` + */ +#define NO_JUMP \ + *end = prev_end_char; \ + end = line; \ + prev_end_char = *end; \ + *end = '\0' + + +/** * Take next parameter, which should be a string or numeral, * and store it in the current node * @@ -518,18 +528,16 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_tree_t** restrict resu in_array = 0; break; } - end = strchrnul(line, ' '); - prev_end_char = *end; - *end = '\0'; { #define node subnode NEW_NODE(string, STRING); - fail_if ((node->string = strdup(line)) == NULL); + NO_JUMP; + CHARS(string); LEAF; + *end = prev_end_char; + line = end; #undef node } - *end = prev_end_char; - line = end; } if (*line == '\0') continue; @@ -676,9 +684,7 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_tree_t** restrict resu { #define node subnode NEW_NODE(string, STRING); - end = line; - prev_end_char = *end; - *end = '\0'; + NO_JUMP; CHARS(string); #undef node node->value = (mds_kbdc_tree_t*)subnode; |