From c9de9a30bd682bd3d36f87e47f4b1dd9d5854dd9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 27 Sep 2011 19:34:49 -0700 Subject: * match.c (match_files): One more fix to this, argh. The test for !data should be done after matching, before incrementing to the next line. Then it is a true bottom of the loop test. This commit allows @(skip) @first_line @(skip nil 3) @(eof) to correctly match the first line of the input, not the fourth one from the bottom, since the second skip has an unbounded range. --- ChangeLog | 14 ++++++++++++++ match.c | 16 ++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84ca8d90..25868383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-09-27 Kaz Kylheku + + * match.c (match_files): One more fix to this, argh. + The test for !data should be done after matching, + before incrementing to the next line. Then it is a true + bottom of the loop test. This commit allows + @(skip) + @first_line + @(skip nil 3) + @(eof) + to correctly match the first line of the input, not + the fourth one from the bottom, since the + second skip has an unbounded range. + 2011-09-27 Kaz Kylheku * match.c (match_files): Another bugfix to skip. diff --git a/match.c b/match.c index ab0cd9ae..a00064ca 100644 --- a/match.c +++ b/match.c @@ -978,24 +978,24 @@ repeat_spec_same_data: { cnum reps_max = 0, reps_min = 0; - cnum old_lineno = data_lineno; uw_block_begin(nil, result); - while (data && min && reps_min++ < cmin) { + while (data && min && reps_min < cmin) { data = rest(data); data_lineno++; + reps_min++; } if (min) { if (reps_min != cmin) { - debuglf(spec_linenum, lit("skipped ~a/~a lines to ~a:~a"), - num(data_lineno - old_lineno), num(cmin), + debuglf(spec_linenum, lit("skipped only ~a/~a lines to ~a:~a"), + num(reps_min), num(cmin), first(files), num(data_lineno), nao); uw_block_return(nil, nil); } debuglf(spec_linenum, lit("skipped ~a lines to ~a:~a"), - num(data_lineno - old_lineno), first(files), + num(reps_min), first(files), num(data_lineno), nao); } @@ -1009,13 +1009,13 @@ repeat_spec_same_data: break; } + if (!data) + break; + debuglf(spec_linenum, lit("skip didn't match ~a:~a"), first(files), num(data_lineno), nao); data = rest(data); data_lineno++; - - if (!data) - break; } uw_block_end; -- cgit v1.2.3