aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-28 20:21:25 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-28 20:21:25 +0100
commitd67f84b6d54cd163aece37838f3278b11d597440 (patch)
tree62d27f1e7f48f016f2e51170fd0e1085273fb2cb
parente55cfe32b05f8adeae9873ca0b9092a7b5113b38 (diff)
Fix handling zero matches.
Don't try to compute log(0).
-rw-r--r--reselect6
1 files changed, 4 insertions, 2 deletions
diff --git a/reselect b/reselect
index c1cdb7c..e42fd9f 100644
--- a/reselect
+++ b/reselect
@@ -26,9 +26,11 @@ sub hint_iterator {
my ($len) = @_;
# generate fixed-length codes of sufficient length for all matches
- my $code_len = POSIX::ceil(log($len) / log(@hintchars));
- if ($code_len == 0) {
+ my $code_len;
+ if ($len == 0) {
$code_len = 1;
+ } else {
+ $code_len = POSIX::ceil(log($len) / log(@hintchars));
}
my $state = 0;