avoid warning
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 4 Jun 2008 03:58:19 +0000 (23:58 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 4 Jun 2008 03:58:19 +0000 (23:58 -0400)
"substr outside of string"

IkiWiki/Plugin/search.pm

index 679321ce55065e237a7102c0dc81bca3dc4f2a13..0218987d0f7c51d8dbf2c506f042033bbd16751e 100644 (file)
@@ -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;