From 9c717d087340fa2c9db1e02fbc07ba0ef05775de Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 3 Jun 2008 23:58:19 -0400 Subject: [PATCH] avoid warning "substr outside of string" --- IkiWiki/Plugin/search.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 679321ce5..0218987d0 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -92,10 +92,12 @@ sub filter (@) { #{{{ # if it stopped in the middle of a word. my $size=512; my ($sample)=substr($toindex, 0, $size); - my $next=substr($toindex, $size++, 1); - while (defined $next && $next !~ /\s/) { - $sample.=$next; - $next=substr($toindex, $size++, 1); + if (length($sample) == $size) { + my $next=substr($toindex, $size++, 1); + while (defined $next && $next !~ /\s/) { + $sample.=$next; + $next=substr($toindex, $size++, 1); + } } $sample=~s/\n/ /g; -- 2.26.2