On October 10, 2002 08:55 pm, Sean R. Bright wrote:
> localeconv is not threadsafe AFAIK, which is why the localeconv_r
> function was introduced.  

I'll make the correction.

Also, does HAVE_SETLOCALE necessarily imply
> HAVE_LOCALECONV?

I believe it is, on all the systems I have access to both functions are 
defined within locale.h

Ilia

> -----Original Message-----
> From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 10, 2002 12:30 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-CVS] cvs: php4 /ext/standard formatted_print.c string.c
>
>
> iliaa         Thu Oct 10 12:29:35 2002 EDT
>
>   Modified files:
>     /php4/ext/standard        string.c formatted_print.c
>   Log:
>   This patch fixes handling of floats on locales where decimal point is
> not a
>   '.'. Problem is best demonstrated by bug #17079.
>
>
>
> Index: php4/ext/standard/string.c
> diff -u php4/ext/standard/string.c:1.319
> php4/ext/standard/string.c:1.320
> --- php4/ext/standard/string.c:1.319  Wed Oct  9 09:50:06 2002
> +++ php4/ext/standard/string.c        Thu Oct 10 12:29:35 2002
> @@ -18,7 +18,7 @@
>
> +----------------------------------------------------------------------+
>   */
>
> -/* $Id: string.c,v 1.319 2002/10/09 13:50:06 andrey Exp $ */
> +/* $Id: string.c,v 1.320 2002/10/10 16:29:35 iliaa Exp $ */
>
>  /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
>
> @@ -3216,6 +3216,19 @@
>
>                       efree(args);
>                       RETVAL_STRING(retval, 1);
> +
> +                     if (cat == LC_NUMERIC || cat == LC_ALL) {
> +                             struct lconv *lc;
> +                             lc = localeconv();
> +
> +                             EG(float_separator)[0] =
> (lc->decimal_point)[0];
> +
> +                             if ((lc->decimal_point)[0] != '.') {
> +                                     /* set locale back to C */
> +                                     setlocale(LC_NUMERIC, "C");
> +                             }
> +                     }
> +
>                       return;
>               }
>
> Index: php4/ext/standard/formatted_print.c
> diff -u php4/ext/standard/formatted_print.c:1.53
> php4/ext/standard/formatted_print.c:1.54
> --- php4/ext/standard/formatted_print.c:1.53  Sat Sep 21 11:08:59 2002
> +++ php4/ext/standard/formatted_print.c       Thu Oct 10 12:29:35 2002
> @@ -16,7 +16,7 @@
>
> +----------------------------------------------------------------------+
>   */
>
> -/* $Id: formatted_print.c,v 1.53 2002/09/21 15:08:59 sas Exp $ */
> +/* $Id: formatted_print.c,v 1.54 2002/10/10 16:29:35 iliaa Exp $ */
>
>  #include <math.h>                            /* modf() */
>  #include "php.h"
> @@ -284,14 +284,7 @@
>       char *cvt;
>       register int i = 0, j = 0;
>       int sign, decpt;
> -     char decimal_point = '.';
> -#ifdef HAVE_LOCALECONV
> -     struct lconv l;
> -
> -     localeconv_r(&l);
> -
> -     decimal_point = l.decimal_point[0];
> -#endif
> +     char decimal_point = EG(float_separator)[0];
>
>       PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c',
> %d, %c)\n",
>                                 *buffer, pos, size, number, width,
> padding, alignment, fmt)); @@ -611,14 +604,13 @@
>                               case 'e':
>                               case 'f':
>                                       /* XXX not done */
> -
> convert_to_double_ex(args[argnum]);
>
> php_sprintf_appenddouble(&result, &outpos, &size,
>
> Z_DVAL_PP(args[argnum]),
>
> width, padding, alignment,
>
> precision, adjusting,
>
> format[inpos], always_sign);
>                                       break;
> -
> +
>                               case 'c':
>
> convert_to_long_ex(args[argnum]);
>                                       php_sprintf_appendchar(&result,
> &outpos, &size,


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to