diff options
| author | Teddy Wing | 2021-08-19 21:57:59 +0200 |
|---|---|---|
| committer | Teddy Wing | 2021-08-19 21:57:59 +0200 |
| commit | 016240388e39c58b2d0bba118e4c1a1a52011cee (patch) | |
| tree | 5a1d66648259ace1179df0dae0ee97c123c4be18 /incdec.pm | |
| parent | 463490a1857274ebf5b488c38e1a280a4d9b7669 (diff) | |
| download | readline-incdec-016240388e39c58b2d0bba118e4c1a1a52011cee.tar.bz2 | |
incdec: Add increment step argument
A new subrouting argument that defines by how much the number should be
incremented, or decremented if a negative step value is given.
Add a few new tests to verify the decrementing behaviour. The final test
where point is in the middle of the number fails.
Diffstat (limited to 'incdec.pm')
| -rw-r--r-- | incdec.pm | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -4,7 +4,7 @@ use warnings; package incdec; sub incdec { - my ($line, $point_position, $is_backward) = @_; + my ($line, $increment_by, $point_position, $is_backward) = @_; $point_position ||= 0; $is_backward ||= 0; @@ -38,7 +38,7 @@ sub incdec { } pos($line) = $start_position; - $line =~ s/\G([^\d]*)(\d+)/$1 . ($2 + 1)/e; + $line =~ s/\G([^\d]*)(\d+)/$1 . ($2 + $increment_by)/e; return $line; } |
