aboutsummaryrefslogtreecommitdiffstats
path: root/incdec.pm
diff options
context:
space:
mode:
authorTeddy Wing2021-08-19 20:58:01 +0200
committerTeddy Wing2021-08-19 20:58:01 +0200
commit2d6c93c03ba8a2392ff09b92bfd51fb8afe7a23c (patch)
tree71c088f5c24a650f1f3b0c525e9f1378091e0ec3 /incdec.pm
parentb0d5568c7c9546945471c9b95857f6666411ad87 (diff)
downloadreadline-incdec-2d6c93c03ba8a2392ff09b92bfd51fb8afe7a23c.tar.bz2
incdec: Get backward incrementing working in middle of a number
Diffstat (limited to 'incdec.pm')
-rw-r--r--incdec.pm19
1 files changed, 12 insertions, 7 deletions
diff --git a/incdec.pm b/incdec.pm
index 9569171..b05c547 100644
--- a/incdec.pm
+++ b/incdec.pm
@@ -12,17 +12,22 @@ sub incdec {
my $start_position = 0;
my @points = ();
my $previous_match_start = 0;
+ my $previous_match_end = 0;
while ($line =~ /(\d+)/g) {
if ($is_backward) {
- $previous_match_start = $-[0];
-
+ # print "pos[$point_position] -[$-[0]]- +[$+[0]]+\n";
# if $point_position < $-[0]
# && previous $+[0] <= $point_position
- # if ($point_position >= $-[0]) {
- # $start_position = $-[0];
- #
- # last;
- # }
+ # if ($previous_match_end <= $point_position && $point_position < $-[0]) {
+ if ($-[0] <= $point_position && $point_position < $+[0]) {
+ # print "matched";
+ $start_position = $-[0];
+
+ last;
+ }
+
+ $previous_match_start = $-[0];
+ $previous_match_end = $+[0];
}
else {
if ($point_position < $+[0]) {