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

From: Date: Thu, 10 Oct 2002 22:05:16 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: Zend / zend.c zend_execute_API.c zend_globals.h
References: 1 2  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-494@lists.php.net to get a copy of this message
On October 10, 2002 05:25 pm, Andi Gutmans wrote: > I know but this does mean that the round trip wouldn't work. For example, > eval('$a = print $b;'); would yield a parse error because you'd get $a = > 1,3; Maybe we need to fix the echo command. I think things should be > consistent. Actually that would not be a parse error, the value of $a would become 1 because the parser will stop at 1st unknown character which would be ',' and only convert '1' to int. But, you are correct eval() condition is not covered by this situation. There are 2 solutions that I can see to this, 1st is that we always use '.' as a decimal point no matter what the locale settings tell us, this may however break BC for people who expect to see 1,2 when they export LC_NUMERIC. The other solution is to allow Zend Engine to handle ',' as a decimal point, which would allow parsing of things like 1,2 if that is what the locale supports. Ilia > > Andi > > At 02:30 PM 10/10/2002 -0400, Ilia A. wrote: > >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: û' > > > >îÛçl¯ÙUU8j=http://www.php.net/unsub.php

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