From: nicos at worldakt dot com
Operating system: FreeBSD
PHP version: 4.3.3
PHP Bug Type: *Languages/Translation
Bug description: setlocale() does not work under FreeBSD

Description:
------------
setlocale() fails under FreeBSD 4.8:

[Fri Oct 31 - 17:56:28 - root /httpd/php-4.3.3]# cat configure.log | grep
locale
checking for locale.h... (cached) yes
checking for setlocale... (cached) yes
checking for localeconv... (cached) yes
[Fri Oct 31 - 17:56:45 - root /httpd/php-4.3.3]#

In fact, setlocale returns FALSE but no E_WARNING or anything.

After looking in ext/standard/string.c it looks like it can happen when
HAVE_SETLOCALE is not defined...

But HAVE_SETLOCALE is defined.

Another solution is that, setlocale() call fails:

retval = setlocale (cat, loc);

We've got an if (retval) { } but no else...
According to freebsd's man, setlocale returns NULL on failure.

I added:
else {
/* setlocale failed */
efree(args);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "setlocale failed!");
RETURN_FALSE;
}

And I get the E_WARNING, so it means setlocale() call failed, but why ?
the same scripts works fine under linux but not under freebsd4.8.

After looking in /usr/share/locale, we have:

/usr/share/locale/fr_FR.ISO8859-1:
LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC
LC_TIME

/usr/share/locale/fr_FR.ISO8859-15:
LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC
LC_TIME

/usr/share/locale/fr_FR.ISO_8859-1:
LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC
LC_TIME

/usr/share/locale/fr_FR.ISO_8859-15:
LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC
LC_TIME

so it should work.

If I have change fr_FR to fr_FR.ISO_8859-1 in the setlocale call, the
script works fine, isn't setlocale() supposed to use default cht which
is ISO_8859-1 ? In any case the doentation does not mention that we
have to add the cht under FreeBSD...

Reproduce code:
---------------
setlocale(LC_TIME, "fr_FR");
echo strftime("%B %Y",$timestamp);


Expected result:
----------------
TRUE
Octobre 2003

Actual result:
--------------
FALSE
October 2003

--
Edit bug report at [url]http://bugs.php.net/?id=26052&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26052&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26052&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26052&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26052&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26052&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26052&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26052&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26052&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26052&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26052&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26052&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26052&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26052&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26052&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26052&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26052&r=float[/url]