Hi Andreas,
[Andreas Gruenbacher]
> Calling setlocale with a value that is possibly wrong doesn't appeal
> to me. I'd prefer this:
>
> BEGIN {
> if (eval { require Locale::gettext }) {
> import Locale::gettext;
> require POSIX;
> import POSIX, qw(setlocale LC_MESSAGES);
> } else {
I am reluctant to explicitely importing LC_MESSAGES here, as perl 5.6.x
doesn't know about it. We did not import it explicitely at first and it
was working, so I don't see why it would now be needed. As a matter of
fact, it works fine for me without it.
So, here is my latest proposal:
--- scripts/remove-trailing-ws.in 18 Jul 2005 22:15:26 -0000 1.2
+++ scripts/remove-trailing-ws.in 23 Jul 2005 20:43:47 -0000
@@ -8,10 +8,25 @@
use strict;
use FileHandle;
use File::Temp qw( :mktemp );
-use POSIX qw(setlocale);
-use Locale::gettext;
use Getopt::Std;
use vars qw($opt_p $opt_n);
+
+# This trick lets the script work even if gettext support is missing.
+BEGIN {
+ if (eval { require Locale::gettext }) {
+ import Locale::gettext;
+ require POSIX;
+ import POSIX, qw(setlocale);
+ } else {
+ eval '
+ use constant LC_MESSAGES => 0;
+ sub setlocale($$) { }
+ sub bindtextdomain($$) { }
+ sub textdomain($) { }
+ sub gettext($) { shift }
+ '
+ }
+}
setlocale(LC_MESSAGES, "");
bindtextdomain("quilt", "@LOCALEDIR@");
Thanks,
--
Jean Delvare
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev