summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-09-22 13:23:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-09-22 13:23:02 -0700
commit24d450b011d80df3d57bbf47731d1fbfa15043dd (patch)
treec3cf36c1cf5d28a71027e212744de2a535875f5b /match.c
parentd15d57f1e2edfb5cd556fcf8f32b6c3dcfadcfff (diff)
downloadtxr-24d450b011d80df3d57bbf47731d1fbfa15043dd.tar.gz
txr-24d450b011d80df3d57bbf47731d1fbfa15043dd.tar.bz2
txr-24d450b011d80df3d57bbf47731d1fbfa15043dd.zip
Useful second argument in skip directive for skipping
a minimum number of lines. * match.c (match_files): New behavior in skip_s case. * txr.1: Documented.
Diffstat (limited to 'match.c')
-rw-r--r--match.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/match.c b/match.c
index ce981a4e..b75c0766 100644
--- a/match.c
+++ b/match.c
@@ -924,8 +924,9 @@ repeat_spec_same_data:
if (sym == skip_s) {
val max = first(rest(first_spec));
+ val min = second(rest(first_spec));
cnum cmax = nump(max) ? c_num(max) : 0;
- cnum reps = 0;
+ cnum cmin = nump(min) ? c_num(min) : 0;
if (rest(specline))
sem_error(spec_linenum,
@@ -935,9 +936,22 @@ repeat_spec_same_data:
break;
{
+ cnum reps_max = 0, reps_min = 0;
+ cnum old_lineno = data_lineno;
uw_block_begin(nil, result);
- while (data && (!max || reps++ < cmax)) {
+ while (data && min && reps_min++ < cmin) {
+ data = rest(data);
+ data_lineno++;
+ }
+
+ if (min) {
+ debuglf(spec_linenum, lit("skipped ~a lines to ~a:~a"),
+ num(data_lineno - old_lineno), first(files),
+ num(data_lineno), nao);
+ }
+
+ while (data && (!max || reps_max++ < cmax)) {
result = match_files(spec, files, bindings,
data, num(data_lineno));