diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | match.c | 38 |
2 files changed, 31 insertions, 15 deletions
@@ -2,6 +2,14 @@ Task #11425 + * match.c (v_block): New function. + (match_files): Block directive moved to function. + (dir_tables_init): v_block entered into table. + +2011-10-18 Kaz Kylheku <kaz@kylheku.com> + + Task #11425 + * match.c (spec_bind): New macro. (v_freeform): New function. (match_files): Freeform logic moved to function. @@ -1466,6 +1466,28 @@ static val v_freeform(match_files_ctx c, match_files_ctx *cout) return next_spec_k; } +static val v_block(match_files_ctx c, match_files_ctx *cout) +{ + spec_bind (specline, spec_linenum, first_spec, c.spec); + + val name = first(rest(first_spec)); + + if (rest(specline)) + sem_error(spec_linenum, + lit("unexpected material after block directive"), nao); + + if (rest(c.spec)) + { + uw_block_begin(name, result); + result = match_files(c); + uw_block_end; + return result; + } + + *cout = c; + return next_spec_k; +} + static val match_files(match_files_ctx c) { gc_hint(c.data); @@ -1534,21 +1556,6 @@ repeat_spec_same_data: } else { return result; } - } - - if (sym == block_s) { - val name = first(rest(first_spec)); - if (rest(specline)) - sem_error(spec_linenum, - lit("unexpected material after block directive"), nao); - if ((c.spec = rest(c.spec)) == nil) - break; - { - uw_block_begin(name, result); - result = match_files(c); - uw_block_end; - return result; - } } else if (sym == fail_s || sym == accept_s) { val target = first(rest(first_spec)); @@ -2472,6 +2479,7 @@ static void dir_tables_init(void) sethash(v_directive_table, skip_s, cptr((mem_t *) v_skip)); sethash(v_directive_table, trailer_s, cptr((mem_t *) v_trailer)); sethash(v_directive_table, freeform_s, cptr((mem_t *) v_freeform)); + sethash(v_directive_table, block_s, cptr((mem_t *) v_block)); } void match_init(void) |