Skip Menu |

This queue is for tickets about the Lingua-EN-Sentence CPAN distribution.

Report information
The Basics
Id: 97681
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Lingua-EN-Sentence

People
Owner: kimryan [...] cpan.org
Requestors: fraserbn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.27



Subject: [PATCH] Handle systems without setlocale()
Some systems (Android, WinCE) are bundled with little or no locale support. In Android, for example, setlocale() just thows an unimplemented warning, as does LC_ALL. So in those systems, just wrap the calls to setlocale() in an eval {}, which sidesteps the issue and makes the module install cleanly.
Subject: 0001-Handle-systems-without-setlocale.patch
From 396a5ea9b0041c4dcfd89668cbef0b9777f1531f Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Fri, 1 Aug 2014 00:57:15 +0200 Subject: [PATCH] Handle systems without setlocale() --- lib/Lingua/EN/Sentence.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Lingua/EN/Sentence.pm b/lib/Lingua/EN/Sentence.pm index 62213ec..6234c04 100644 --- a/lib/Lingua/EN/Sentence.pm +++ b/lib/Lingua/EN/Sentence.pm @@ -145,7 +145,7 @@ use Carp qw/cluck/; $VERSION = '0.25'; # LC_CTYPE now in locale "French, Canada, codeset ISO 8859-1" -$LOC=setlocale(LC_CTYPE, "fr_CA.ISO8859-1"); +$LOC=eval { setlocale(LC_CTYPE, "fr_CA.ISO8859-1") }; use locale; @ISA = qw( Exporter ); @@ -279,7 +279,7 @@ sub set_locale { cluck "Won't set locale to undefined value!\n"; return undef; } - $LOC = setlocale(LC_CTYPE, $new_locale); + $LOC = eval { setlocale(LC_CTYPE, $new_locale) }; return $LOC; } -- 1.7.12.4 (Apple Git-37)
Hi, I have recently taken over maintenance of this module. The use of 'eval' is often discouraged so I'm wondering if there isn't a neater solution to this. Perhaps we could use the $OSNAME environment variable to check if we are on a Windows CE or Android system and then bypass the calls to setlocale? There is also the option of defining POSIX as a prerequisite module in Makefile.PL. But that may stop this from installing on Windows CE etc which is probably not what you want. Regards, Kim On Fri Aug 01 15:51:37 2014, Hugmeir wrote: Show quoted text
> Some systems (Android, WinCE) are bundled with little or no locale > support. In Android, for example, setlocale() just thows an > unimplemented warning, as does LC_ALL. > So in those systems, just wrap the calls to setlocale() in an eval {}, > which sidesteps the issue and makes the module install cleanly.
I now detect the OSNAME vraiable and bypass calls to setlocale if this is 'android'. Not able to detect the Windows CE OS as OSNAME does not distinguish between Windows versions, they all return 'MSwin32 '.