From: Joey Hess Date: Wed, 4 Jun 2008 03:58:19 +0000 (-0400) Subject: avoid warning X-Git-Tag: 2.49~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9c717d087340fa2c9db1e02fbc07ba0ef05775de;p=ikiwiki.git avoid warning "substr outside of string" --- 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;