From 5418385336e7eeab79166e7ddccefa6bdea8c759 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 8 Jun 2009 18:27:40 -0400 Subject: Optimise use of gettext, and avoid ugly warnings if Locale::gettext is not available. The test suite was emitting a lot of ugly gettext warnings; setting LC_ALL didn't solve the problem for all locale setups (since ikiwiki remaps it to LANG, and ikiwiki didn't know about the C locale). People also seem generally annoyed by the messages when Locale::Gettext is not installed, and I suspect will be generally happier if it just silently doesn't localize. The optimisation came about when I noticed that the gettext sub was doing rather a lot of work each call just to see if localisation is needed. We can avoid that work by caching, and the best thing to cache is a version of the gettext sub that does exactly the right thing. This was slightly complicated by the locale setting, which might need to override the original locale (or lack thereof) after gettext has been called. So it needs to invalidate the cache in that case. It used to do it via a global variable, which I am happy to have also gotten rid of. --- t/basewiki_brokenlinks.t | 2 +- t/permalink.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/basewiki_brokenlinks.t b/t/basewiki_brokenlinks.t index 2871b1dd2..fd0037492 100755 --- a/t/basewiki_brokenlinks.t +++ b/t/basewiki_brokenlinks.t @@ -8,7 +8,7 @@ ok(! system("make -s ikiwiki.out")); ok(! system("make extra_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null")); foreach my $plugin ("", "listdirectives") { - ok(! system("LC_ALL=C perl -I. ./ikiwiki.out -rebuild -plugin brokenlinks ". + ok(! system("perl -I. ./ikiwiki.out -rebuild -plugin brokenlinks ". # always enabled because pages link to it conditionally, # which brokenlinks cannot handle properly "-plugin smiley ". diff --git a/t/permalink.t b/t/permalink.t index c326e8d27..b49b98338 100755 --- a/t/permalink.t +++ b/t/permalink.t @@ -5,7 +5,7 @@ use Test::More 'no_plan'; ok(! system("mkdir t/tmp")); ok(! system("make -s ikiwiki.out")); -ok(! system("LC_ALL=C perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -templatedir=templates t/tinyblog t/tmp/out")); +ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -templatedir=templates t/tinyblog t/tmp/out")); # This guid should never, ever change, for any reason whatsoever! my $guid="http://example.com/post/"; ok(length `grep '$guid' t/tmp/out/index.rss`); -- cgit v1.2.3