Re: [ZEND-ENGINE-CVS] cvs: Zend / zend.c zend_execute_API.c zend_globals.h

From: Date: Thu, 10 Oct 2002 18:30:00 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: Zend / zend.c zend_execute_API.c zend_globals.h
References: 1  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-490@lists.php.net to get a copy of this message
On October 10, 2002 01:08 pm, Andi Gutmans wrote: > I personally don't like this patch. The engine only accepts "." as input in > the PHP scripts so why shouldn't this output with a "."? You are adding an > inconsistency! Not quite. I am not changing what the engine accepts, it still only accepts '.'. However, what it outputs when printing should depend on the locale because a lot of locales, nearly all European locales, specify that the decimal point should be a ','. This is not an inconsistency, but a consistency with the locale specified by the user. Even without the patch some of this behavior already occurs, for example: php -r ' $a = 3; $b = 2; setlocale(LC_NUMERIC, "german"); echo $a/$b; ' will output '1,5' because according to German locale the separator is a ','. My patch in fact allows Zend engine to safely use '.' as the decimal separator internally and ONLY change this when it comes to printing stuff out, where if a user had specified a locale with a different decimal point and expects that, this is what they get. Ilia > Andi > > At 04:27 PM 10/10/2002 +0000, Ilia Alshanetsky wrote: > >iliaa Thu Oct 10 12:27:52 2002 EDT > > > > Modified files: > > /Zend zend.c zend_execute_API.c zend_globals.h > > Log: > > This patch fixes handling of floats on locales where decimal point is > > not a '.'. Problem is best demonstrated by bug #17079. > > > > > >Index: Zend/zend.c > >diff -u Zend/zend.c:1.157 Zend/zend.c:1.158 > >--- Zend/zend.c:1.157 Tue Sep 24 06:58:33 2002 > >+++ Zend/zend.c Thu Oct 10 12:27:51 2002 > >@@ -154,6 +154,19 @@ > > expr_copy->value.str.len = sizeof("Object")-1; > > expr_copy->value.str.val = estrndup("Object", > > expr_copy->value.str.len); > > break; > >+ case IS_DOUBLE: > >+ *expr_copy = *expr; > >+ zval_copy_ctor(expr_copy); > >+ convert_to_string(expr_copy); > >+ > >+ /* locale hanling */ > >+ if (EG(float_separator)[0] != '.') { > >+ char *p = expr_copy->value.str.val; > >+ if ((p = strchr(p, '.'))) { > >+ *p = EG(float_separator)[0]; > >+ } > >+ } > >+ break; > > default: > > *expr_copy = *expr; > > zval_copy_ctor(expr_copy); > >Index: Zend/zend_execute_API.c > >diff -u Zend/zend_execute_API.c:1.154 Zend/zend_execute_API.c:1.155 > >--- Zend/zend_execute_API.c:1.154 Wed Oct 9 10:17:53 2002 > >+++ Zend/zend_execute_API.c Thu Oct 10 12:27:52 2002 > >@@ -166,6 +166,8 @@ > > #ifdef ZEND_WIN32 > > EG(timed_out) = 0; > > #endif > >+ > >+ EG(float_separator)[0] = '.'; > > } > > > > > >Index: Zend/zend_globals.h > >diff -u Zend/zend_globals.h:1.91 Zend/zend_globals.h:1.92 > >--- Zend/zend_globals.h:1.91 Mon Sep 23 08:00:38 2002 > >+++ Zend/zend_globals.h Thu Oct 10 12:27:52 2002 > >@@ -207,6 +207,9 @@ > > > > HashTable *ini_directives; > > > >+ /* locale stuff */ > >+ char float_separator[1]; > >+ > > void *reserved[ZEND_MAX_RESERVED_RESOURCES]; > > }; > > > > > > > > > >-- > >Zend Engine CVS Mailing List (http://cvs.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.zend-engine.cvs (#490) next »