X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/17b2afe721d5b8fd2468fca56e91fe83bf49be64..94268a46cd30fc72b51714e42e9db741eb29cc73:/IkiWiki/Plugin/smiley.pm

diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm
index 1697a37c1..6f4f49d18 100644
--- a/IkiWiki/Plugin/smiley.pm
+++ b/IkiWiki/Plugin/smiley.pm
@@ -25,7 +25,14 @@ sub getsetup () {
 }
 
 sub build_regexp () {
-	my $list=readfile(srcfile("smileys.mdwn"));
+	my $srcfile = srcfile("smileys.mdwn", 1);
+	if (! defined $srcfile) {
+		print STDERR sprintf(gettext("smiley plugin will not work without %s"),
+			"smileys.mdwn")."\n";
+		$smiley_regexp='';
+		return;
+	}
+	my $list=readfile($srcfile);
 	while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
 		my $smiley=$1;
 		my $file=$2;
@@ -87,10 +94,10 @@ MATCH:	while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) {
 		}
 		else {
 			# Replace the smiley with its expanded value.
-			substr($_, $spos, length($smiley))=
-				htmllink($params{page}, $params{destpage},
+			my $link=htmllink($params{page}, $params{destpage},
 				         $smileys{$smiley}, linktext => $smiley);
-			pos=$epos+1;
+			substr($_, $spos, length($smiley))=$link;
+			pos=$epos+length($link);
 		}
 	}