From 81dac06e17f6cef9217fafa28285a65f6d093014 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 18 Oct 2011 12:55:15 -0400 Subject: Task #11425 * match.c (v_block): New function. (match_files): Block directive moved to function. --- ChangeLog | 8 ++++++++ match.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4439db4..e5573ec5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-10-18 Kaz Kylheku + + 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 Task #11425 diff --git a/match.c b/match.c index 682469bd..48beb1ed 100644 --- a/match.c +++ b/match.c @@ -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) -- cgit v1.2.3