summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--match.c38
2 files changed, 31 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index d4439db4..e5573ec5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
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)