From d67f84b6d54cd163aece37838f3278b11d597440 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 28 Nov 2021 20:21:25 +0100 Subject: Fix handling zero matches. Don't try to compute log(0). --- reselect | 6 ++++-- 1 file 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; -- cgit v1.2.3