diff options
| author | Teddy Wing | 2021-08-15 20:02:42 +0200 |
|---|---|---|
| committer | Teddy Wing | 2021-08-15 20:02:42 +0200 |
| commit | e256e34a9ccd735aca45a8e42d284b297e094b8f (patch) | |
| tree | d11ec132f7b2a79d1a8f94bbd97dfe1145e9fd68 /incdec.pm | |
| parent | df187d692c334fc16653f145f8bb0e6ba0ea268c (diff) | |
| download | readline-incdec-e256e34a9ccd735aca45a8e42d284b297e094b8f.tar.bz2 | |
incdec: Add comments describing the middle-of-number handling loop
Diffstat (limited to 'incdec.pm')
| -rw-r--r-- | incdec.pm | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -17,13 +17,21 @@ sub incdec { my $line_part = $line; while ($point_position < length($line_part)) { $line_part =~ /(\d+)/; + + # If `$point_position` is within the matched number, we can stop. if ($-[0] <= $point_position && $point_position < $+[0]) { last; } + # Continue the loop if point is further right than the end of the match. if ($point_position >= $+[0]) { + # Store the line part that we don't increment so we can include it at the end. $line_start .= substr($line_part, 0, $+[0]); + + # Match starting in the next part of the string next iteration. $line_part = substr($line_part, $+[0]); + + # Adjust point position according to the new line part. $point_position -= $+[0]; next; |
