diff options
| author | Teddy Wing | 2022-05-25 01:32:20 +0200 |
|---|---|---|
| committer | Teddy Wing | 2022-05-25 01:32:20 +0200 |
| commit | 1c7000e9e25aba7406a09d3530e756cfc8e52386 (patch) | |
| tree | 62c3274e8b0f8917348ed20ebaaf6405c1521219 | |
| parent | ea3cd1980b86d647fb4a1d771489c93ebd1d77e0 (diff) | |
| download | readline-incdec-1c7000e9e25aba7406a09d3530e756cfc8e52386.tar.bz2 | |
incdec.pm: Fix leading-zero handling for single-digit "0"
Incrementing or decrementing "0" didn't work with the leading-zero idea
I had.
| -rw-r--r-- | incdec.pm | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -30,7 +30,7 @@ sub incdec { my $start_position = 0; my $previous_match_start = 0; my $i = 0; - while ($line =~ /(-?[1-9]\d*)/g) { + while ($line =~ /(-?([1-9]\d*|\d))/g) { if ($is_backward) { # Set start position to the current match start. This gives us the # correct start position when incrementing the last number in a @@ -64,7 +64,7 @@ sub incdec { } pos($line) = $start_position; - $line =~ s/\G(-?[1-9]\d*)/$1 + $increment_by/e; + $line =~ s/\G(-?([1-9]\d*|\d))/$1 + $increment_by/e; return ($line, $start_position); } |
