From ebc05132095766ab0c1406f4c859f4dc0e9913df Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 23 Jan 2016 21:18:03 +0100 Subject: [PATCH] fix match drawing if match group doesn't start at the beginning Also display an error message if a regex doesn't contain a match group. --- bin/fcscs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/fcscs b/bin/fcscs index 0033af8..abe9712 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -385,8 +385,11 @@ sub get_regex_matches { my @matches; while ($input->{string} =~ /$regex/g) { + my $offset = $-[1]; + die "Match group required in regex '$regex'" if not defined $offset; + my ($x, $y) = input_match_offset_to_coordinates($input->{width}, - $-[0]); + $offset); push @matches, { x => $x, y => $y, string => $1 }; } return @matches; -- 2.45.2