Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-05-15 Thread Christopher Jones


Are there any tests for this?

Chris

Moriyoshi Koizumi wrote:

moriyoshi   Fri May 15 17:02:35 2009 UTC

  Modified files:  
/php-src/ext/standard	array.c 
  Log:

  * Roll it back then.  I wonder if defaulting it to SORT_REGULAR would work 
well
and I think allowing user-supplied comparator should make more sense when it
comes to objects.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.477r2=1.478diff_format=u

Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.477 php-src/ext/standard/array.c:1.478
--- php-src/ext/standard/array.c:1.477  Fri May 15 16:44:51 2009
+++ php-src/ext/standard/array.cFri May 15 17:02:34 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.477 2009/05/15 16:44:51 sixd Exp $ */

+/* $Id: array.c,v 1.478 2009/05/15 17:02:34 moriyoshi Exp $ */
 
 #include php.h

 #include php_ini.h
@@ -2889,7 +2889,7 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
-   long sort_type = PHP_SORT_REGULAR;
+   long sort_type = PHP_SORT_STRING;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, sort_type) == FAILURE) {

return;





--
Email: christopher.jo...@oracle.com
Twitter:  http://twitter.com/ghrd

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-05-15 Thread Moriyoshi Koizumi
Christopher Jones wrote:
 
 Are there any tests for this?

Do we really need one?

Moriyoshi

 Chris
 
 Moriyoshi Koizumi wrote:
 moriyoshiFri May 15 17:02:35 2009 UTC

   Modified files:  /php-src/ext/standardarray.c  
 Log:
   * Roll it back then.  I wonder if defaulting it to SORT_REGULAR
 would work well
 and I think allowing user-supplied comparator should make more
 sense when it
 comes to objects.

 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.477r2=1.478diff_format=u

 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.477
 php-src/ext/standard/array.c:1.478
 --- php-src/ext/standard/array.c:1.477Fri May 15 16:44:51 2009
 +++ php-src/ext/standard/array.cFri May 15 17:02:34 2009
 @@ -21,7 +21,7 @@

 +--+
  */
  
 -/* $Id: array.c,v 1.477 2009/05/15 16:44:51 sixd Exp $ */
 +/* $Id: array.c,v 1.478 2009/05/15 17:02:34 moriyoshi Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -2889,7 +2889,7 @@
  };
  struct bucketindex *arTmp, *cmpdata, *lastkept;
  unsigned int i;
 -long sort_type = PHP_SORT_REGULAR;
 +long sort_type = PHP_SORT_STRING;
  
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l,
 array, sort_type) == FAILURE) {
  return;



 


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-05-15 Thread Hannes Magnusson
On Fri, May 15, 2009 at 20:40, Moriyoshi Koizumi m...@mozo.jp wrote:
 Christopher Jones wrote:

 Are there any tests for this?

 Do we really need one?

Yes.

-Hannes

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-05-15 Thread Christopher Jones



Hannes Magnusson wrote:
 On Fri, May 15, 2009 at 20:40, Moriyoshi Koizumi m...@mozo.jp wrote:
 Christopher Jones wrote:
 Are there any tests for this?
 Do we really need one?

 Yes.

 -Hannes

Tests would help bring to attention any future change, making it
easier to analyze the impact.  We might not have needed the
back-and-forth discussions on this isssue if it had been clearer what
the impact to scripts was.

Chris

--
Email: christopher.jo...@oracle.com
Twitter:  http://twitter.com/ghrd

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-02-18 Thread Andrei Zmievski

Moriyoshi Koizumi wrote:

I got a bug report, then I fixed it. That's just an normal procedure for
bugfixing. Isn't it? Am I supposed to have a written permission from you
whenever I fix a part you did ever touch?

And the old behavior is strange, but not *broken*. It just doesn't work
for your case.


I wasn't looking for you to ask permission, but simply to discuss this before fixing 
something that was already fixed for the release. I mean, did you wonder at all why I 
set the default to be SORT_REGULAR? Would have been nice to talk about it, that's all.


-Andrei

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-02-17 Thread Andrei Zmievski

Moriyoshi Koizumi wrote:

Whatever reasoning, I don't think it's a good idea to revert someone
else's patch before discussing anything.

Aside from this, I agree with you the old behavior is that stupid, but
BC should always be honored.


Moriyoshi,

You committed your fix and updated my NEWS entry without ever discussing what it is you 
were going to do. As for BC, it should be respected, but it is not paramount. If things 
are broken, then they should be fixed.


-Andrei

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-02-17 Thread Moriyoshi Koizumi
On 火, 2009-02-17 at 10:07 -0800, Andrei Zmievski wrote:
 Moriyoshi Koizumi wrote:
  Whatever reasoning, I don't think it's a good idea to revert someone
  else's patch before discussing anything.
  
  Aside from this, I agree with you the old behavior is that stupid,
 but
  BC should always be honored.
 
 Moriyoshi,
 
 You committed your fix and updated my NEWS entry without ever discussing 
 what it is you 
 were going to do. As for BC, it should be respected, but it is not paramount. 
 If things 
 are broken, then they should be fixed.

I got a bug report, then I fixed it. That's just an normal procedure for
bugfixing. Isn't it? Am I supposed to have a written permission from you
whenever I fix a part you did ever touch?

And the old behavior is strange, but not *broken*. It just doesn't work
for your case.

Moriyoshi


 
 -Andrei


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2009-02-13 Thread Andrei Zmievski
Don't do this please. Why did you feel the need to go back and change my patch including 
the NEWS entry? I knew what I was doing when I set the default behavior to SORT_REGULAR 
and this was discussed with both 5.3 and 5.2 RMs. With your change it'l back to the stupid 
 old behavior of:


$array = array(new stdClass(), new stdClass(), new Foo());
$array = array_unique($array);

And now $array has only 1 element. I really hate having tell PHP not to be stupid, rather 
than having it default to being smart.


I'm going to revert this.

-Andrei

Moriyoshi Koizumi wrote:

moriyoshi   Thu Feb 12 18:29:15 2009 UTC

  Modified files:  
/php-src/ext/standard	array.c 
  Log:

  * Fix bug #47370 (BC breakage of array_unique())
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.471r2=1.472diff_format=u

Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.471 php-src/ext/standard/array.c:1.472
--- php-src/ext/standard/array.c:1.471  Mon Feb  9 10:47:19 2009
+++ php-src/ext/standard/array.cThu Feb 12 18:29:15 2009
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.471 2009/02/09 10:47:19 dmitry Exp $ */

+/* $Id: array.c,v 1.472 2009/02/12 18:29:15 moriyoshi Exp $ */
 
 #include php.h

 #include php_ini.h
@@ -2924,7 +2924,7 @@
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
-   long sort_type = PHP_SORT_REGULAR;
+   long sort_type = PHP_SORT_STRING;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a|l, array, sort_type) == FAILURE) {

return;





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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-12-15 Thread Andrei Zmievski

Where do I edit the doc stuff again?

Kalle Sommer Nielsen wrote:

2008/12/12 Andrei Zmievski and...@php.net:

andrei  Fri Dec 12 19:19:04 2008 UTC

 Modified files:
   /php-src/ext/standard   array.c
 Log:
 Add sort flags parameter to array_unique().


http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.467r2=1.468diff_format=u


Guess it should have [DOC], cc'ed to phpdoc@ =)





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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-12-15 Thread Kalle Sommer Nielsen
2008/12/15 Andrei Zmievski and...@gravitonic.com:
 Where do I edit the doc stuff again?


Do a checkout of the 'phpdoc' repo, inside the /en/ directory theres
the english translation files.

/en/language/ -- for language specific features
/en/reference/ -- for references for extensions, eg. array, json ect.


On the note, I updated the docs for array_unique() a few days ago :)



-- 
Kalle Sommer Nielsen

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-12-12 Thread Kalle Sommer Nielsen
2008/12/12 Andrei Zmievski and...@php.net:
 andrei  Fri Dec 12 19:19:04 2008 UTC

  Modified files:
/php-src/ext/standard   array.c
  Log:
  Add sort flags parameter to array_unique().


 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.467r2=1.468diff_format=u

Guess it should have [DOC], cc'ed to phpdoc@ =)



-- 
Kalle Sommer Nielsen

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-07-23 Thread Jani Taskinen


Did you read my comment in that bug report?

--Jani

Felipe Pena wrote:

felipe  Wed Jul 23 16:27:16 2008 UTC

  Modified files:  
/php-src/ext/standard	array.c 
  Log:

  - Fixed bug #45605 (array_uintersect_assoc gives incorrect error message)
(patch by ilewis at uk dot ibm dot com)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.455r2=1.456diff_format=u

Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.455 php-src/ext/standard/array.c:1.456
--- php-src/ext/standard/array.c:1.455  Wed Jul  9 21:29:39 2008
+++ php-src/ext/standard/array.cWed Jul 23 16:27:16 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.455 2008/07/09 21:29:39 colder Exp $ */

+/* $Id: array.c,v 1.456 2008/07/23 16:27:16 felipe Exp $ */
 
 #include php.h

 #include php_ini.h
@@ -3061,10 +3061,14 @@
/* Get the argument count */
argc = ZEND_NUM_ARGS();
if (data_compare_type == INTERSECT_COMP_DATA_USER) {
-   if (argc  3 || zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, 
args, argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
+   if (argc  3) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
parameters are required, %d given, ZEND_NUM_ARGS());
return;
}
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, args, 
argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == FAILURE) {
+   return;
+   }
intersect_data_compare_func = zval_user_compare;
} else {
if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +, 
args, argc) == FAILURE) {






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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-07-23 Thread Felipe Pena
Em Qua, 2008-07-23 às 20:11 +0300, Jani Taskinen escreveu:
 Did you read my comment in that bug report?
 

Yes, but after the commit.

 --Jani
 
 Felipe Pena wrote:
  felipe  Wed Jul 23 16:27:16 2008 UTC
  
Modified files:  
  /php-src/ext/standard   array.c 
Log:
- Fixed bug #45605 (array_uintersect_assoc gives incorrect error message)
  (patch by ilewis at uk dot ibm dot com)


  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.455r2=1.456diff_format=u
  Index: php-src/ext/standard/array.c
  diff -u php-src/ext/standard/array.c:1.455 
  php-src/ext/standard/array.c:1.456
  --- php-src/ext/standard/array.c:1.455  Wed Jul  9 21:29:39 2008
  +++ php-src/ext/standard/array.cWed Jul 23 16:27:16 2008
  @@ -21,7 +21,7 @@
  +--+
   */
   
  -/* $Id: array.c,v 1.455 2008/07/09 21:29:39 colder Exp $ */
  +/* $Id: array.c,v 1.456 2008/07/23 16:27:16 felipe Exp $ */
   
   #include php.h
   #include php_ini.h
  @@ -3061,10 +3061,14 @@
  /* Get the argument count */
  argc = ZEND_NUM_ARGS();
  if (data_compare_type == INTERSECT_COMP_DATA_USER) {
  -   if (argc  3 || zend_parse_parameters(ZEND_NUM_ARGS() 
  TSRMLS_CC, +f, args, argc, BG(user_compare_fci), 
  BG(user_compare_fci_cache)) == FAILURE) {
  +   if (argc  3) {
  php_error_docref(NULL TSRMLS_CC, E_WARNING, at least 3 
  parameters are required, %d given, ZEND_NUM_ARGS());
  return;
  }
  +   
  +   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, +f, 
  args, argc, BG(user_compare_fci), BG(user_compare_fci_cache)) == 
  FAILURE) {
  +   return;
  +   }
  intersect_data_compare_func = zval_user_compare;
  } else {
  if (argc  2 || zend_parse_parameters(ZEND_NUM_ARGS() 
  TSRMLS_CC, +, args, argc) == FAILURE) {
  
  
  
 
-- 
Regards,
Felipe Pena.


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-07-23 Thread Jani Taskinen

Felipe Pena kirjoitti:

Em Qua, 2008-07-23 às 20:11 +0300, Jani Taskinen escreveu:

Did you read my comment in that bug report?


Yes, but after the commit.


...and? :)

--Jani


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-07-23 Thread Felipe Pena
Em Qua, 2008-07-23 às 22:53 +0300, Jani Taskinen escreveu:
 Felipe Pena kirjoitti:
  Em Qua, 2008-07-23 às 20:11 +0300, Jani Taskinen escreveu:
  Did you read my comment in that bug report?
 
  Yes, but after the commit.
 
 ...and? :)
 
 --Jani
 

I'll fix it again in some minutes... (goto home;)

Thanks.

-- 
Regards,
Felipe Pena.


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2008-01-25 Thread Antony Dovgal
On 25.01.2008 18:52, Rob Richards wrote:
 rrichards Fri Jan 25 15:52:00 2008 UTC
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   fix zts build

Thanks! 

-- 
Wbr, 
Antony Dovgal

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2007-11-02 Thread Jani Taskinen
Sorry, and thanks. :)
I tried to commit stuff separate from other changes and this happened..

--Jani

On Fri, 2007-11-02 at 12:03 +, Antony Dovgal wrote:
 tony2001  Fri Nov  2 12:03:25 2007 UTC
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   fix typo and silence compile warning
   
   
 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.425r2=1.426diff_format=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.425 php-src/ext/standard/array.c:1.426
 --- php-src/ext/standard/array.c:1.425Fri Nov  2 11:48:35 2007
 +++ php-src/ext/standard/array.c  Fri Nov  2 12:03:25 2007
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.425 2007/11/02 11:48:35 jani Exp $ */
 +/* $Id: array.c,v 1.426 2007/11/02 12:03:25 tony2001 Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -2304,9 +2304,9 @@
   zend_bool preserve_keys = 0; /* Whether to preserve keys while copying 
 to the new array or not */
   int  num_in,/* Number of elements in the 
 input array */
pos;   /* Current position in the 
 array */
 - zval*lenght_param;
 + zval*length_param;
   zstr string_key;
 - int string_key_len;
 + uint string_key_len;
   ulong num_key;
   HashPosition hpos;
  
 
-- 
Patches/Donations: http://pecl.php.net/~jani/

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2007-11-02 Thread Antony Dovgal
On 02.11.2007 15:22, Jani Taskinen wrote:
 Sorry, and thanks. :)
 I tried to commit stuff separate from other changes and this happened..

No worries, Jani. 

-- 
Wbr, 
Antony Dovgal

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2006-10-03 Thread Andrei Zmievski

Please use zend_parse_parameters() API.

-Andrei

On Oct 3, 2006, at 9:36 AM, Hannes Magnusson wrote:


bjori   Tue Oct  3 16:36:57 2006 UTC

  Modified files:
/php-src/ext/standard   array.c
  Log:
  compact() doesnt throw wrong param count


http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c? 
r1=1.386r2=1.387diff_format=u

Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.386  
php-src/ext/standard/array.c:1.387

--- php-src/ext/standard/array.c:1.386  Wed Sep 20 20:30:19 2006
+++ php-src/ext/standard/array.cTue Oct  3 16:36:57 2006
@@ -21,7 +21,7 @@
 
+-- 
+

 */

-/* $Id: array.c,v 1.386 2006/09/20 20:30:19 andrei Exp $ */
+/* $Id: array.c,v 1.387 2006/10/03 16:36:57 bjori Exp $ */

 #include php.h
 #include php_ini.h
@@ -1567,6 +1567,9 @@
zval ***args;   /* function arguments array */
int i;

+   if (ZEND_NUM_ARGS()  1) {
+   WRONG_PARAM_COUNT;
+   }
args = (zval ***)safe_emalloc(ZEND_NUM_ARGS(), sizeof(zval **), 0);

if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {

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


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array array_walk.phpt array_walk_objects.phpt array_walk_rec_objects.phpt array_walk_recursive1.phpt

2006-09-19 Thread Andrei Zmievski
Why do we want to continue treating objects as arrays? Can't people 
simply pass get_object_vars($obj) result to array_walk?

In any case, does the error message make sense though?

+		php_error_docref(NULL TSRMLS_CC, E_WARNING, The argument should be 
an array);


-Andrei

On Sep 19, 2006, at 2:33 AM, Antony Dovgal wrote:


tony2001Tue Sep 19 09:33:02 2006 UTC

  Added files:
/php-src/ext/standard/tests/array   array_walk_objects.phpt
array_walk_rec_objects.phpt

  Modified files:
/php-src/ext/standard   array.c
/php-src/ext/standard/tests/array   array_walk.phpt
array_walk_recursive1.phpt
  Log:
  support objects in array_walk*()
  add new tests, fix old ones

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


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array array_walk.phpt array_walk_objects.phpt array_walk_rec_objects.phpt array_walk_recursive1.phpt

2006-09-19 Thread Michael Wallner
Andrei Zmievski wrote:
 Why do we want to continue treating objects as arrays? Can't people
 simply pass get_object_vars($obj) result to array_walk?

That won't work because array_walk() takes a reference.

-- 
Michael

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array array_walk.phpt array_walk_objects.phpt array_walk_rec_objects.phpt array_walk_recursive1.phpt

2006-09-19 Thread Andrei Zmievski

So assign it to a variable.

-Andrei

On Sep 19, 2006, at 8:52 AM, Michael Wallner wrote:


Andrei Zmievski wrote:

Why do we want to continue treating objects as arrays? Can't people
simply pass get_object_vars($obj) result to array_walk?


That won't work because array_walk() takes a reference.

--
Michael


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c php_array.h /ext/unicode collator.c config.m4 config.w32 php_unicode.h unicode.c

2006-03-29 Thread Derick Rethans
On Sun, 26 Mar 2006, Andrei Zmievski wrote:

 Shouldn't it be called unicode_collator.c?

I was wondering why the rest of the filenames where prepended with 
unicode_... what's the point of that? :) 

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c php_array.h /ext/unicode collator.c config.m4 config.w32 php_unicode.h unicode.c

2006-03-26 Thread Andrei Zmievski

Shouldn't it be called unicode_collator.c?

-Andrei


On Mar 26, 2006, at 3:06 AM, Derick Rethans wrote:


derick  Sun Mar 26 11:06:24 2006 UTC

  Added files:
/php-src/ext/unicodecollator.c

  Modified files:
/php-src/ext/standard   array.c php_array.h
/php-src/ext/unicodeconfig.m4 config.w32 php_unicode.h unicode.c
  Log:
  - Implemented basic collation support. For some reason new  
Collator gives segfaults when the object's collation resource is  
used.

  - The following example shows what is implemented:

  ?php
  $orig = $strings = array(
  'côte',
  'cote',
  'côté',
  'coté',
  'fluße',
  'flüße',
  );

  echo German phonebook:\n;
  $c = collator_create( [EMAIL PROTECTED] );
  foreach($c-sort($strings) as $string) {
  echo $string, \n;
  }
  echo $c-getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
  ? With : Without,  french accent sorting order\n;

  echo \nFrench with options:\n;
  $c = collator_create( fr );
  $c-setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
  $c-setAttribute(Collator::CASE_LEVEL, Collator::ON);
  $c-setStrength(Collator::SECONDARY);
  foreach($c-sort($strings) as $string) {
  echo $string, \n;
  }
  echo $c-getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
  ? With : Without,  french accent sorting order\n;
  ?

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


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-12-27 Thread Marcus Boerger
Hello Antony,

  that looks pretty wrong (actually was wrong before already). The code
should read:
  if (zend_call_function(fci, fci_cache TSRMLS_CC) != SUCCESS || !result) {
or like this:
  if (zend_call_function(fci, fci_cache TSRMLS_CC) == FAILURE || !result) {

best regards
marcus

Tuesday, December 27, 2005, 11:33:40 PM, you wrote:

 tony2001Tue Dec 27 22:33:40 2005 EDT

   Modified files:  
 /php-src/ext/standard   array.c 
   Log:
   MF51: fix #35821 (array_map() segfaults when exception is throwed from the 
 callback)
   
   
 http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/array.c?r1=1.333r2=1.334diff_format=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.333 php-src/ext/standard/array.c:1.334
 --- php-src/ext/standard/array.c:1.333  Mon Dec  5 22:53:15 2005
 +++ php-src/ext/standard/array.cTue Dec 27 22:33:40 2005
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.333 2005/12/05 22:53:15 sniper Exp $ */
 +/* $Id: array.c,v 1.334 2005/12/27 22:33:40 tony2001 Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -4603,7 +4603,7 @@
 fci.params = params[1];
 fci.no_separation = 0;
  
 -   if (!zend_call_function(fci, fci_cache TSRMLS_CC) 
 == SUCCESS  result) {
 +   if (!zend_call_function(fci, fci_cache TSRMLS_CC) 
 == SUCCESS || !result) {
 php_error_docref(NULL TSRMLS_CC,
 E_WARNING, An error occurred while invoking the map callback);
 efree(array_len);
 efree(args);




Best regards,
 Marcus

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-12-27 Thread Antony Dovgal

On 28.12.2005 02:12, Marcus Boerger wrote:

Hello Antony,

  that looks pretty wrong (actually was wrong before already). The code
should read:
  if (zend_call_function(fci, fci_cache TSRMLS_CC) != SUCCESS || !result) {
or like this:
  if (zend_call_function(fci, fci_cache TSRMLS_CC) == FAILURE || !result) {


Ah, yeah.. thanks for noticing it.

--
Wbr, 
Antony Dovgal


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



RE: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array bug34934.phpt

2005-10-24 Thread Dmitry Stogov
Hi Marcus,

Thank you for catch.
I reverted the patch and marked bug as bogus.

Dmitry.

 -Original Message-
 From: Marcus Boerger [mailto:[EMAIL PROTECTED] 
 Sent: Friday, October 21, 2005 10:01 PM
 To: Dmitry Stogov
 Cc: php-cvs@lists.php.net
 Subject: Re: [PHP-CVS] cvs: php-src /ext/standard array.c 
 /ext/standard/tests/array bug34934.phpt
 
 
 Hello Dmitry,
 
   this is wrong! We agreed upon not allowing ArrayAccess in 
 array* functions. If you change this then change the macros 
 in array.c from Z_ARRVAL to HASH_OF and ensure that all 
 functions also work with ArrayAccess. Since you cannot do 
 that you might probably explain why the bug report is bogus!
 
 marcus
   
 
 Friday, October 21, 2005, 5:20:31 PM, you wrote:
 
  dmitry  Fri Oct 21 11:20:31 2005 EDT
 
Modified files:  
  /php-src/ext/standard   array.c 
  /php-src/ext/standard/tests/array   bug34934.phpt 
Log:
Fixed bug #34934 (offsetExists is not called from 
 array_key_exists)


  
 http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.327r2=1
  .328ty=u
  Index: php-src/ext/standard/array.c
  diff -u php-src/ext/standard/array.c:1.327 
 php-src/ext/standard/array.c:1.328
  --- php-src/ext/standard/array.c:1.327  Tue Oct  4 16:47:48 2005
  +++ php-src/ext/standard/array.cFri Oct 21 11:20:30 2005
  @@ -21,7 +21,7 @@
  
  
 +-
 -+
   */
   
  -/* $Id: array.c,v 1.327 2005/10/04 20:47:48 tony2001 Exp $ */
  +/* $Id: array.c,v 1.328 2005/10/21 15:20:30 dmitry Exp $ */
   
   #include php.h
   #include php_ini.h
  @@ -4658,6 +4658,17 @@
  RETURN_FALSE;
  }
   
  +   if (Z_TYPE_PP(array) == IS_OBJECT 
  +   Z_OBJ_HT_PP(array)-has_dimension 
  +   (Z_OBJ_HT_PP(array)-has_dimension != 
 std_object_handlers.has_dimension ||
  +instanceof_function_ex(Z_OBJCE_PP(array),
  U_CLASS_ENTRY(zend_ce_arrayaccess), 1 TSRMLS_CC))) {
  + if (Z_OBJ_HT_PP(array)-has_dimension(*array, 
 *key, 0 TSRMLS_CC)) {
  +   RETURN_TRUE;
  + } else {
  +   RETURN_FALSE;
  + }
  +   }
  +
  switch (Z_TYPE_PP(key)) {
  case IS_STRING:
  case IS_UNICODE: 
  
 http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug34934.
  phpt?r1=1.1r2=1.2ty=u
  Index: php-src/ext/standard/tests/array/bug34934.phpt
  diff -u /dev/null php-src/ext/standard/tests/array/bug34934.phpt:1.2
  --- /dev/null   Fri Oct 21 11:20:31 2005
  +++ php-src/ext/standard/tests/array/bug34934.phpt  Fri 
 Oct 21 11:20:30 2005
  @@ -0,0 +1,18 @@
  +--TEST--
  +Bug #34934 (offsetExists is not called from array_key_exists)
  +--FILE--
  +?php
  +class MyArray extends ArrayObject {
  +  function offsetExists($mKey) { 
  +   echo __METHOD__ . ($mKey)\n;
  +   return true;
  +  }
  +}
  +
  +$a = new MyArray();
  +
  +var_dump(array_key_exists(test, $a));
 +?
  +--EXPECT--
  +MyArray::offsetExists(test)
  +bool(true)
 
 
 
 
 Best regards,
  Marcus
 
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array bug34934.phpt

2005-10-21 Thread Marcus Boerger
Hello Dmitry,

  this is wrong! We agreed upon not allowing ArrayAccess in array*
functions. If you change this then change the macros in array.c from
Z_ARRVAL to HASH_OF and ensure that all functions also work with
ArrayAccess. Since you cannot do that you might probably explain why
the bug report is bogus!

marcus
  

Friday, October 21, 2005, 5:20:31 PM, you wrote:

 dmitry  Fri Oct 21 11:20:31 2005 EDT

   Modified files:  
 /php-src/ext/standard   array.c 
 /php-src/ext/standard/tests/array   bug34934.phpt 
   Log:
   Fixed bug #34934 (offsetExists is not called from array_key_exists)
   
   
 http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.327r2=1.328ty=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.327 php-src/ext/standard/array.c:1.328
 --- php-src/ext/standard/array.c:1.327  Tue Oct  4 16:47:48 2005
 +++ php-src/ext/standard/array.cFri Oct 21 11:20:30 2005
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.327 2005/10/04 20:47:48 tony2001 Exp $ */
 +/* $Id: array.c,v 1.328 2005/10/21 15:20:30 dmitry Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -4658,6 +4658,17 @@
 RETURN_FALSE;
 }
  
 +   if (Z_TYPE_PP(array) == IS_OBJECT 
 +   Z_OBJ_HT_PP(array)-has_dimension 
 +   (Z_OBJ_HT_PP(array)-has_dimension != 
 std_object_handlers.has_dimension ||
 +instanceof_function_ex(Z_OBJCE_PP(array),
 U_CLASS_ENTRY(zend_ce_arrayaccess), 1 TSRMLS_CC))) {
 + if (Z_OBJ_HT_PP(array)-has_dimension(*array, *key, 0 TSRMLS_CC)) {
 +   RETURN_TRUE;
 + } else {
 +   RETURN_FALSE;
 + }
 +   }
 +
 switch (Z_TYPE_PP(key)) {
 case IS_STRING:
 case IS_UNICODE:
 http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug34934.phpt?r1=1.1r2=1.2ty=u
 Index: php-src/ext/standard/tests/array/bug34934.phpt
 diff -u /dev/null php-src/ext/standard/tests/array/bug34934.phpt:1.2
 --- /dev/null   Fri Oct 21 11:20:31 2005
 +++ php-src/ext/standard/tests/array/bug34934.phpt  Fri Oct 21 11:20:30 
 2005
 @@ -0,0 +1,18 @@
 +--TEST--
 +Bug #34934 (offsetExists is not called from array_key_exists)
 +--FILE--
 +?php
 +class MyArray extends ArrayObject {
 +  function offsetExists($mKey) { 
 +   echo __METHOD__ . ($mKey)\n;
 +   return true;
 +  }
 +}
 +
 +$a = new MyArray();
 +
 +var_dump(array_key_exists(test, $a));
+?
 +--EXPECT--
 +MyArray::offsetExists(test)
 +bool(true)




Best regards,
 Marcus

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



RE: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-10-05 Thread Dmitry Stogov
Tony,

Please look into ext/standard/tests/array/bug30833.phpt
It is failed after your patch.
Probably test file itself should be fixed.

Thanks. Dmitry.

 -Original Message-
 From: Antony Dovgal [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 05, 2005 12:48 AM
 To: php-cvs@lists.php.net
 Subject: [PHP-CVS] cvs: php-src /ext/standard array.c 
 
 
 tony2001  Tue Oct  4 16:47:50 2005 EDT
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   fix #34723 (array_count_values() strips leading zeroes)
   
   
 http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.
 326r2=1.327ty=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.326 
 php-src/ext/standard/array.c:1.327
 --- php-src/ext/standard/array.c:1.326Mon Oct  3 10:01:36 2005
 +++ php-src/ext/standard/array.c  Tue Oct  4 16:47:48 2005
 @@ -21,7 +21,7 @@
 
 +-
 -+
  */
  
 -/* $Id: array.c,v 1.326 2005/10/03 14:01:36 iliaa Exp $ */
 +/* $Id: array.c,v 1.327 2005/10/04 20:47:48 tony2001 Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -2726,9 +2726,10 @@
   } else if (Z_TYPE_PP(entry) == IS_STRING ||
  Z_TYPE_PP(entry) == IS_BINARY ||
  Z_TYPE_PP(entry) == IS_UNICODE) {
 - /* make sure our array does not end up 
 with numeric string keys */
 - if ((Z_TYPE_PP(entry) == IS_STRING  
 is_numeric_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), 
 NULL, NULL, 0) == IS_LONG) ||
 - (Z_TYPE_PP(entry) == IS_UNICODE  
 is_numeric_unicode(Z_USTRVAL_PP(entry), Z_USTRLEN_PP(entry), 
 NULL, NULL, 0) == IS_LONG)) {
 + /* make sure our array does not end up 
 with numeric string keys 
 +  * but don't touch those strings that 
 start with 0 */
 + if ((Z_TYPE_PP(entry) == IS_STRING  
 !(Z_STRLEN_PP(entry)  1  Z_STRVAL_PP(entry)[0] == '0')  
 is_numeric_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), 
 NULL, NULL, 0) == IS_LONG) ||
 + (Z_TYPE_PP(entry) == IS_UNICODE  
 +zend_cmp_unicode_and_literal(Z_USTRVAL_PP(entry), 1, 0, 
 sizeof(0)-1)  is_numeric_unicode(Z_USTRVAL_PP(entry), 
 Z_USTRLEN_PP(entry), NULL, NULL, 0) == IS_LONG)) {
   zval tmp_entry;
   
   tmp_entry = **entry;
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-10-05 Thread Antony Dovgal

On 05.10.2005 10:57, Dmitry Stogov wrote:

Tony,

Please look into ext/standard/tests/array/bug30833.phpt
It is failed after your patch.
Probably test file itself should be fixed.



Fixed. 
Thanks for noticing it =)


--
Wbr, 
Antony Dovgal


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array locale_sort.phpt ZendEngine2 zend_operators.c

2005-09-12 Thread Andrei Zmievski

Perhaps we should cache the locale object somewhere..

-Andrei

On Sep 12, 2005, at 2:53 AM, Derick Rethans wrote:


derick  Mon Sep 12 05:53:23 2005 EDT

  Modified files:
/ZendEngine2zend_operators.c
/php-src/ext/standard   array.c
/php-src/ext/standard/tests/array   locale_sort.phpt
  Log:
  - Reimplement SORT_LOCALE_STRING with ICU locales.


http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c? 
r1=1.219r2=1.220ty=u

Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.219  
ZendEngine2/zend_operators.c:1.220

--- ZendEngine2/zend_operators.c:1.219  Tue Aug 23 18:05:22 2005
+++ ZendEngine2/zend_operators.cMon Sep 12 05:53:20 2005
@@ -17,7 +17,7 @@
 
+-- 
+

 */

-/* $Id: zend_operators.c,v 1.219 2005/08/23 22:05:22 andrei Exp $ */
+/* $Id: zend_operators.c,v 1.220 2005/09/12 09:53:20 derick Exp $ */

 #include ctype.h

@@ -32,6 +32,7 @@
 #include zend_strtod.h

 #include unicode/uchar.h
+#include unicode/ucol.h

 #define LONG_SIGN_MASK (1L  (8*sizeof(long)-1))

@@ -1508,14 +1509,17 @@
return SUCCESS;
 }

-#if HAVE_STRCOLL
 ZEND_API int string_locale_compare_function(zval *result, zval *op1,  
zval *op2 TSRMLS_DC)

 {
zval op1_copy, op2_copy;
int use_copy1, use_copy2;
+   UErrorCode status = U_ZERO_ERROR;
+   UCollator *col;

-   zend_make_printable_zval(op1, op1_copy, use_copy1);
-   zend_make_printable_zval(op2, op2_copy, use_copy2);
+   col = ucol_open(UG(default_locale), status);
+
+   zend_make_unicode_zval(op1, op1_copy, use_copy1);
+   zend_make_unicode_zval(op2, op2_copy, use_copy2);

if (use_copy1) {
op1 = op1_copy;
@@ -1524,7 +1528,7 @@
op2 = op2_copy;
}

-   result-value.lval = strcoll(op1-value.str.val, op2-value.str.val);
+	result-value.lval = ucol_strcoll(col, op1-value.str.val,  
op1-value.str.len, op2-value.str.val, op2-value.str.len);

result-type = IS_LONG;

if (use_copy1) {
@@ -1533,9 +1537,11 @@
if (use_copy2) {
zval_dtor(op2);
}
+
+   ucol_close(col);
+
return SUCCESS;
 }
-#endif

 ZEND_API int numeric_compare_function(zval *result, zval *op1, zval  
*op2 TSRMLS_DC)

 {
http://cvs.php.net/diff.php/php-src/ext/standard/array.c? 
r1=1.323r2=1.324ty=u

Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.323  
php-src/ext/standard/array.c:1.324

--- php-src/ext/standard/array.c:1.323  Thu Sep  1 07:58:39 2005
+++ php-src/ext/standard/array.cMon Sep 12 05:53:22 2005
@@ -21,7 +21,7 @@
 
+-- 
+

 */

-/* $Id: array.c,v 1.323 2005/09/01 11:58:39 dmitry Exp $ */
+/* $Id: array.c,v 1.324 2005/09/12 09:53:22 derick Exp $ */

 #include php.h
 #include php_ini.h
@@ -163,11 +163,9 @@
ARRAYG(compare_func) = string_compare_function;
break;

-#if HAVE_STRCOLL
case SORT_LOCALE_STRING:
ARRAYG(compare_func) = string_locale_compare_function;
break;
-#endif

case SORT_REGULAR:
default:
http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/ 
locale_sort.phpt?r1=1.3r2=1.4ty=u

Index: php-src/ext/standard/tests/array/locale_sort.phpt
diff -u php-src/ext/standard/tests/array/locale_sort.phpt:1.3  
php-src/ext/standard/tests/array/locale_sort.phpt:1.4
--- php-src/ext/standard/tests/array/locale_sort.phpt:1.3	Wed Aug 17  
10:01:06 2005
+++ php-src/ext/standard/tests/array/locale_sort.phpt	Mon Sep 12  
05:53:23 2005

@@ -7,20 +7,21 @@
 }
 ?
 --INI--
-unicode.script_encoding=ISO-8859-1
-unicode.output_encoding=ISO-8859-1
+unicode.script_encoding=UTF-8
+unicode.output_encoding=UTF-8
 --FILE--
 ?php
 setlocale(LC_ALL, 'fr_FR');
+i18n_loc_set_default('fr_FR');
 $table = array(AB = Alberta,
 BC = Colombie-Britannique,
 MB = Manitoba,
 NB = Nouveau-Brunswick,
 NL = Terre-Neuve-et-Labrador,
-NS = Nouvelle-Écosse,
+NS = Nouvelle-Écosse,
 ON = Ontario,
-PE = Île-du-Prince-Édouard,
-QC = Québec,
+PE = Île-du-Prince-Édouard,
+QC = Québec,
 SK = Saskatchewan,
 NT = Territoires du Nord-Ouest,
 NU = Nunavut,
@@ -35,19 +36,19 @@
   [BC]=
   string(20) Colombie-Britannique
   [PE]=
-  string(21) Île-du-Prince-Édouard
+  string(21) Île-du-Prince-Édouard
   [MB]=
   string(8) Manitoba
   [NB]=
   string(17) Nouveau-Brunswick
   [NS]=
-  string(15) Nouvelle-Écosse
+  string(15) Nouvelle-Écosse
   [NU]=
   string(7) Nunavut
   [ON]=
   string(7) Ontario
   [QC]=
-  string(6) Québec
+  string(6) Québec
   [SK]=
   string(12) Saskatchewan
   [NL]=
@@ -64,19 +65,19 @@
   [uBC]=
   unicode(20) Colombie-Britannique
   [uPE]=
-  unicode(21) Île-du-Prince-Édouard
+  unicode(21) Île-du-Prince-Édouard
   [uMB]=
   unicode(8) Manitoba
   [uNB]=
   unicode(17) Nouveau-Brunswick
   

Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array locale_sort.phpt ZendEngine2 zend_operators.c

2005-09-12 Thread Derick Rethans
On Mon, 12 Sep 2005, Andrei Zmievski wrote:

 Perhaps we should cache the locale object somewhere..

yes, that's already on my todo list. Have some basic stuff working for 
that already, but no time to finish. Probably tomorrow on the plane.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array range.phpt

2005-08-18 Thread Andrei Zmievski

Ok, I'll fix.

-Andrei

On Aug 17, 2005, at 2:43 PM, Andrei Zmievski wrote:

I think we can provide better Unicode support in range() if we follow 
a simple rule that the low and high parameters are interpreted as 
codepoints at the end of the range. It would be nice to be able to do 
range('\u0200', '\u0500') and get the string of all the chars 
inbetween.


-Andrei


On Aug 17, 2005, at 8:12 AM, Dmitry Stogov wrote:


dmitryWed Aug 17 11:12:03 2005 EDT

  Modified files:
/php-src/ext/standardarray.c
/php-src/ext/standard/tests/arrayrange.phpt
  Log:
  Unicode support for range()


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


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


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array range.phpt

2005-08-17 Thread Andrei Zmievski
I think we can provide better Unicode support in range() if we follow  
a simple rule that the low and high parameters are interpreted as  
codepoints at the end of the range. It would be nice to be able to do  
range('\u0200', '\u0500') and get the string of all the chars inbetween.


-Andrei


On Aug 17, 2005, at 8:12 AM, Dmitry Stogov wrote:


dmitryWed Aug 17 11:12:03 2005 EDT

  Modified files:
/php-src/ext/standardarray.c
/php-src/ext/standard/tests/arrayrange.phpt
  Log:
  Unicode support for range()


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


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



RE: [PHP-CVS] cvs: php-src /ext/standard array.c /ext/standard/tests/array range.phpt

2005-08-17 Thread Dmitry Stogov
I agree, but don't know how to do it.

Dmitry.

 -Original Message-
 From: Andrei Zmievski [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, August 18, 2005 1:44 AM
 To: Dmitry Stogov
 Cc: php-cvs@lists.php.net
 Subject: Re: [PHP-CVS] cvs: php-src /ext/standard array.c 
 /ext/standard/tests/array range.phpt 
 
 
 I think we can provide better Unicode support in range() if 
 we follow  
 a simple rule that the low and high parameters are interpreted as  
 codepoints at the end of the range. It would be nice to be 
 able to do  
 range('\u0200', '\u0500') and get the string of all the chars 
 inbetween.
 
 -Andrei
 
 
 On Aug 17, 2005, at 8:12 AM, Dmitry Stogov wrote:
 
  dmitryWed Aug 17 11:12:03 2005 EDT
 
Modified files:
  /php-src/ext/standardarray.c
  /php-src/ext/standard/tests/arrayrange.phpt
Log:
Unicode support for range()
 
 
  dmitry-20050817111203.txt
  --
  PHP CVS Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h

2005-06-16 Thread Jani Taskinen


Close the bug? Add a NEWS entry ? :)

--Jani


On Wed, 15 Jun 2005, Andrei Zmievski wrote:


andrei  Wed Jun 15 16:51:37 2005 EDT

 Modified files:
   /php-src/ext/standardbasic_functions.c basic_functions.h array.c
 Log:
 Fix FCI cache for array_walk and user array compare functions. Bug
 #33286. (Patch from [EMAIL PROTECTED])




--
Donate @ http://pecl.php.net/wishlist.php/sniper

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h

2005-06-15 Thread Antony Dovgal
On Wed, 15 Jun 2005 20:51:37 -
Andrei Zmievski [EMAIL PROTECTED] wrote:

 andreiWed Jun 15 16:51:37 2005 EDT
 
   Modified files:  
 /php-src/ext/standard basic_functions.c basic_functions.h array.c 
   Log:
   Fix FCI cache for array_walk and user array compare functions. Bug
   #33286. (Patch from [EMAIL PROTECTED])

Andrei, could you plz also fix whitespaces/tabs there ?

-   zval **old_compare_func;
+PHP_ARRAY_CMP_FUNC_VARS;
+

-   BG(user_compare_func_name) = old_compare_func;
+PHP_ARRAY_CMP_FUNC_RESTORE();
+
etc.

Thanks.

-- 
Wbr, 
Antony Dovgal aka tony2001

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-06-15 Thread Antony Dovgal
On Wed, 15 Jun 2005 21:20:28 -
Andrei Zmievski [EMAIL PROTECTED] wrote:

 andreiWed Jun 15 17:20:28 2005 EDT
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   WS fix

Thanks!

-- 
Wbr, 
Antony Dovgal aka tony2001

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c php_array.h

2005-05-11 Thread Jani Taskinen
I'd share the array_sum() code with array_product() code..
They're identical except for + being * in latter.
(I guess you simply copy'pasted it? :)
--Jani
On Wed, 11 May 2005, Andrey Hristov wrote:
andrey  Wed May 11 07:43:14 2005 EDT
 Modified files:
   /php-src/ext/standardbasic_functions.c php_array.h array.c
 Log:
 add function array_product()
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.714r2=1.715ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.714 
php-src/ext/standard/basic_functions.c:1.715
--- php-src/ext/standard/basic_functions.c:1.714Tue May 10 08:50:53 2005
+++ php-src/ext/standard/basic_functions.c  Wed May 11 07:43:10 2005
@@ -17,7 +17,7 @@
   +--+
 */
-/* $Id: basic_functions.c,v 1.714 2005/05/10 12:50:53 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.715 2005/05/11 11:43:10 andrey Exp $ */
#include php.h
#include php_streams.h
@@ -813,6 +813,7 @@
PHP_FE(array_diff_uassoc,   
NULL)
PHP_FE(array_udiff_uassoc,  
NULL)
PHP_FE(array_sum,   
NULL)
+   PHP_FE(array_product,   
NULL)
PHP_FE(array_filter,
NULL)
PHP_FE(array_map,   
NULL)
PHP_FE(array_chunk, 
NULL)
http://cvs.php.net/diff.php/php-src/ext/standard/php_array.h?r1=1.48r2=1.49ty=u
Index: php-src/ext/standard/php_array.h
diff -u php-src/ext/standard/php_array.h:1.48 
php-src/ext/standard/php_array.h:1.49
--- php-src/ext/standard/php_array.h:1.48   Mon Nov  1 07:09:46 2004
+++ php-src/ext/standard/php_array.hWed May 11 07:43:11 2005
@@ -19,7 +19,7 @@
   +--+
*/
-/* $Id: php_array.h,v 1.48 2004/11/01 12:09:46 helly Exp $ */
+/* $Id: php_array.h,v 1.49 2005/05/11 11:43:11 andrey Exp $ */
#ifndef PHP_ARRAY_H
#define PHP_ARRAY_H
@@ -92,6 +92,7 @@
PHP_FUNCTION(array_diff_uassoc);
PHP_FUNCTION(array_udiff_uassoc);
PHP_FUNCTION(array_sum);
+PHP_FUNCTION(array_product);
PHP_FUNCTION(array_filter);
PHP_FUNCTION(array_map);
PHP_FUNCTION(array_key_exists);
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.298r2=1.299ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.298 php-src/ext/standard/array.c:1.299
--- php-src/ext/standard/array.c:1.298  Mon Apr 25 02:13:57 2005
+++ php-src/ext/standard/array.cWed May 11 07:43:11 2005
@@ -21,7 +21,7 @@
   +--+
*/
-/* $Id: array.c,v 1.298 2005/04/25 06:13:57 dmitry Exp $ */
+/* $Id: array.c,v 1.299 2005/05/11 11:43:11 andrey Exp $ */
#include php.h
#include php_ini.h
@@ -3918,9 +3918,56 @@
Z_DVAL_P(return_value) += Z_DVAL(entry_n);
}
}
+/* }}} */
+/* {{{ proto mixed array_product(array input)
+   Returns the product of the array entries */
+PHP_FUNCTION(array_product)
+{
+   zval **input,
+**entry,
+entry_n;
+   int argc = ZEND_NUM_ARGS();
+   HashPosition pos;
+   double dval;
+
+   if (argc != 1 || zend_get_parameters_ex(argc, input) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+
+   if (Z_TYPE_PP(input) != IS_ARRAY) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The argument should be 
an array);
+   return;
+   }
+
+   ZVAL_LONG(return_value, 0);
+
+   for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), pos);
+zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)entry, 
pos) == SUCCESS;
+zend_hash_move_forward_ex(Z_ARRVAL_PP(input), pos)) {
+
+   if (Z_TYPE_PP(entry) == IS_ARRAY || Z_TYPE_PP(entry) == 
IS_OBJECT)
+   continue;
+
+   entry_n = **entry;
+   zval_copy_ctor(entry_n);
+   convert_scalar_to_number(entry_n TSRMLS_CC);
+
+   if (Z_TYPE(entry_n) == IS_LONG  Z_TYPE_P(return_value) == 
IS_LONG) {
+   dval = (double)Z_LVAL_P(return_value) * 
(double)Z_LVAL(entry_n);
+   if ( (double)LONG_MIN = dval  dval = 
(double)LONG_MAX ) {
+   Z_LVAL_P(return_value) *= 

Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2005-04-13 Thread Jani Taskinen
Can you add a regression test for this too?
(if there isn't already :)
--Jani
On Tue, 12 Apr 2005, Antony Dovgal wrote:
tony2001Tue Apr 12 10:00:55 2005 EDT
 Modified files:
   /php-src/ext/standardarray.c
 Log:
 fix #30833 (array_count_values modifying input array)
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.296r2=1.297ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.296 php-src/ext/standard/array.c:1.297
--- php-src/ext/standard/array.c:1.296  Mon Mar 21 20:45:17 2005
+++ php-src/ext/standard/array.cTue Apr 12 10:00:54 2005
@@ -21,7 +21,7 @@
   +--+
*/
-/* $Id: array.c,v 1.296 2005/03/22 01:45:17 iliaa Exp $ */
+/* $Id: array.c,v 1.297 2005/04/12 14:00:54 tony2001 Exp $ */
#include php.h
#include php_ini.h
@@ -2466,7 +2466,6 @@
zend_hash_internal_pointer_reset_ex(myht, pos);
while (zend_hash_get_current_data_ex(myht, (void **)entry, pos) == 
SUCCESS) {
if (Z_TYPE_PP(entry) == IS_LONG) {
-int_key:
if (zend_hash_index_find(Z_ARRVAL_P(return_value),
 
Z_LVAL_PP(entry),
 
(void**)tmp) == FAILURE) {
@@ -2481,9 +2480,28 @@
} else if (Z_TYPE_PP(entry) == IS_STRING) {
/* make sure our array does not end up with numeric 
string keys */
if (is_numeric_string(Z_STRVAL_PP(entry), 
Z_STRLEN_PP(entry), NULL, NULL, 0) == IS_LONG) {
-   SEPARATE_ZVAL(entry);
-   convert_to_long_ex(entry);
-   goto int_key;
+   zval tmp_entry;
+
+   tmp_entry = **entry;
+   zval_copy_ctor(tmp_entry);
+
+   convert_to_long(tmp_entry);
+
+   if 
(zend_hash_index_find(Z_ARRVAL_P(return_value),
+   
 Z_LVAL(tmp_entry),
+
(void**)tmp) == FAILURE) {
+   zval *data;
+   MAKE_STD_ZVAL(data);
+   Z_TYPE_P(data) = IS_LONG;
+   Z_LVAL_P(data) = 1;
+   
zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL(tmp_entry), data, 
sizeof(data), NULL);
+   } else {
+   Z_LVAL_PP(tmp)++;
+   }
+
+   zval_dtor(tmp_entry);
+   zend_hash_move_forward_ex(myht, pos);
+   continue;
}
if (zend_hash_find(Z_ARRVAL_P(return_value), 
Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)+1, (void**)tmp) == FAILURE) {

--
https://www.paypal.com/xclick/[EMAIL 
PROTECTED]no_note=1tax=0currency_code=EUR
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2004-09-15 Thread Derick Rethans
On Wed, 15 Sep 2004, Derick Rethans wrote:

 derickWed Sep 15 07:50:28 2004 EDT

   Modified files:
 /php-src/ext/standard array.c
   Log:
   - Added new boolean (fourth) parameter to array_slice() that turns on the
 preservation of keys in the returned array.

I'd like to merge this tiny patch into 4.3 after 4.3.9 is released. Do
you see any problems with that?

regards,
Derick

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c ZendEngine2 zend_operators.c zend_operators.h

2004-09-13 Thread Derick Rethans
On Sat, 11 Sep 2004, Marcus Boerger wrote:

 Hello Derick,

 why not define the const only if it is usefull (strcoll available)?

I was under the (wrong) impression that constants where evaluated at
compile time where possible. Though I don't think it's a bad thing to
have this always available.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c ZendEngine2 zend_operators.c zend_operators.h

2004-09-11 Thread Marcus Boerger
Hello Derick,

  why not define the const only if it is usefull (strcoll available)?

regards
marcus

Saturday, September 11, 2004, 4:22:36 PM, you wrote:

 derickSat Sep 11 10:22:36 2004 EDT

   Modified files:  
 /ZendEngine2  zend_operators.c zend_operators.h 
 /php-src/ext/standard array.c 
   Log:
   - MFB: Added the sorting flag SORT_LOCALE_STRING to the sort() functions which
 makes them sort based on the current locale. (Derick)
  
  
 http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.195r2=1.196ty=u
 Index: ZendEngine2/zend_operators.c
 diff -u ZendEngine2/zend_operators.c:1.195 ZendEngine2/zend_operators.c:1.196
 --- ZendEngine2/zend_operators.c:1.195Fri Sep 10 20:23:20 2004
 +++ ZendEngine2/zend_operators.c  Sat Sep 11 10:22:35 2004
 @@ -17,7 +17,7 @@

 +--+
  */
 
 -/* $Id: zend_operators.c,v 1.195 2004/09/11 00:23:20 andi Exp $ */
 +/* $Id: zend_operators.c,v 1.196 2004/09/11 14:22:35 derick Exp $ */
 
  #include ctype.h
 
 @@ -1221,6 +1221,35 @@
   }
   return SUCCESS;
  }
 +
 +#if HAVE_STRCOLL
 +ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 
 TSRMLS_DC)
 +{
 + zval op1_copy, op2_copy;
 + int use_copy1, use_copy2;
 +
 + zend_make_printable_zval(op1, op1_copy, use_copy1);
 + zend_make_printable_zval(op2, op2_copy, use_copy2);
 +
 + if (use_copy1) {
 + op1 = op1_copy;
 + }
 + if (use_copy2) {
 + op2 = op2_copy;
 + }
 +
 + result-value.lval = strcoll(op1-value.str.val, op2-value.str.val);
 + result-type = IS_LONG;
 +
 + if (use_copy1) {
 + zval_dtor(op1);
 + }
 + if (use_copy2) {
 + zval_dtor(op2);
 + }
 + return SUCCESS;
 +}
 +#endif
 
  ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
  {
 http://cvs.php.net/diff.php/ZendEngine2/zend_operators.h?r1=1.89r2=1.90ty=u
 Index: ZendEngine2/zend_operators.h
 diff -u ZendEngine2/zend_operators.h:1.89 ZendEngine2/zend_operators.h:1.90
 --- ZendEngine2/zend_operators.h:1.89 Thu Jul 15 22:03:25 2004
 +++ ZendEngine2/zend_operators.h  Sat Sep 11 10:22:35 2004
 @@ -17,7 +17,7 @@

 +--+
  */
 
 -/* $Id: zend_operators.h,v 1.89 2004/07/16 02:03:25 iliaa Exp $ */
 +/* $Id: zend_operators.h,v 1.90 2004/09/11 14:22:35 derick Exp $ */
 
  #ifndef ZEND_OPERATORS_H
  #define ZEND_OPERATORS_H
 @@ -179,6 +179,9 @@
  ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
  ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
  ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
 +#if HAVE_STRCOLL
 +ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 
 TSRMLS_DC);
 +#endif
 
  ZEND_API void zend_str_tolower(char *str, unsigned int length);
  ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int 
 length);
 http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.273r2=1.274ty=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.273 php-src/ext/standard/array.c:1.274
 --- php-src/ext/standard/array.c:1.273Wed Aug 25 20:26:19 2004
 +++ php-src/ext/standard/array.c  Sat Sep 11 10:22:35 2004
 @@ -21,7 +21,7 @@

 +--+
  */
 
 -/* $Id: array.c,v 1.273 2004/08/26 00:26:19 iliaa Exp $ */
 +/* $Id: array.c,v 1.274 2004/09/11 14:22:35 derick Exp $ */
 
  #include php.h
  #include php_ini.h
 @@ -65,6 +65,7 @@
  #define SORT_REGULAR 0
  #define SORT_NUMERIC 1
  #define  SORT_STRING 2
 +#define  SORT_LOCALE_STRING  5
 
  #define SORT_DESC3
  #define SORT_ASC 4
 @@ -114,6 +115,8 @@
   REGISTER_LONG_CONSTANT(SORT_REGULAR, SORT_REGULAR, CONST_CS | 
 CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT(SORT_NUMERIC, SORT_NUMERIC, CONST_CS | 
 CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT(SORT_STRING, SORT_STRING, CONST_CS | 
 CONST_PERSISTENT);
 + REGISTER_LONG_CONSTANT(SORT_LOCALE_STRING, SORT_LOCALE_STRING, CONST_CS | 
 CONST_PERSISTENT);
 +
   REGISTER_LONG_CONSTANT(CASE_LOWER, CASE_LOWER, CONST_CS | CONST_PERSISTENT);
   REGISTER_LONG_CONSTANT(CASE_UPPER, CASE_UPPER, CONST_CS | CONST_PERSISTENT);
 
 @@ -142,6 +145,12 @@
   case SORT_STRING:
   ARRAYG(compare_func) = string_compare_function;
   break;
 +
 +#if HAVE_STRCOLL
 + case SORT_LOCALE_STRING:
 + ARRAYG(compare_func) = string_locale_compare_function;
 + break;
 +#endif
 
   case SORT_REGULAR:
   default:




-- 

Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2004-01-28 Thread Andi Gutmans
Yeah you should.

At 01:30 AM 1/24/2004 +0100, Andrey Hristov wrote:
Ooops, something else slipped in :/ (no more commits so late).
Anyway, should I revert the irrelevant part about ZEND_ENGINE_2 ?
Andrey

Andrey Hristov wrote:
andrey  Fri Jan 23 19:25:58 2004 EDT
  Modified files:
/php-src/ext/standard   array.c   Log:
  Added third parameter (optional) to array_keys for strictness. It behaves
  like the strict parameter of in_array().
  #Closing feature request #24258
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.256r2=1.257ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.256 php-src/ext/standard/array.c:1.257
--- php-src/ext/standard/array.c:1.256  Sat Jan 17 12:33:10 2004
+++ php-src/ext/standard/array.cFri Jan 23 19:25:58 2004
@@ -21,7 +21,7 @@
+--+
 */
-/* $Id: array.c,v 1.256 2004/01/17 17:33:10 andrey Exp $ */
+/* $Id: array.c,v 1.257 2004/01/24 00:25:58 andrey Exp $ */
 #include php.h
 #include php_ini.h
@@ -1135,6 +1135,13 @@
WRONG_PARAM_COUNT;
}
+#ifndef ZEND_ENGINE_2
+   if (Z_TYPE_PP(value) == IS_OBJECT) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong 
datatype for first argument);
+   RETURN_FALSE;
+   }
+#endif
+
if (Z_TYPE_PP(array) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong 
datatype for second argument);
RETURN_FALSE;
@@ -1473,6 +1480,14 @@
}
newval = *val;
while (i--) {
+#ifndef ZEND_ENGINE_2
+   if (newval-refcount = 62000) {
+   MAKE_STD_ZVAL(newval);
+   *newval = **val;
+   zval_copy_ctor(newval);
+   newval-refcount = 0;
+   }
+#endif
zval_add_ref(newval);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), 
newval, sizeof(zval *), NULL);
}
@@ -2243,7 +2258,7 @@
 /* }}} */

-/* {{{ proto array array_keys(array input [, mixed search_value])
+/* {{{ proto array array_keys(array input [, mixed search_value[, bool 
strict]])
Return just the keys from the input array, optionally only for the 
specified search_value */
 PHP_FUNCTION(array_keys)
 {
@@ -2251,18 +2266,21 @@
 **search_value,/* Value to search for */
 **entry,   /* An entry in the input array */
   res, /* Result of comparison */
+**strict,  /* be strict */
  *new_val; /* New value */
intadd_key; /* Flag to indicate whether a key should 
be added */
char  *string_key;  /* String key */
uint   string_key_len;
ulong  num_key; /* Numeric key */
HashPosition pos;
+   int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = 
is_equal_function;
+

search_value = NULL;

/* Get arguments and do error-checking */
-   if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  2 ||
-   zend_get_parameters_ex(ZEND_NUM_ARGS(), input, 
search_value) == FAILURE) {
+   if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  3 ||
+   zend_get_parameters_ex(ZEND_NUM_ARGS(), input, 
search_value, strict) == FAILURE) {
WRONG_PARAM_COUNT;
}

@@ -2270,6 +2288,12 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, The first 
argument should be an array);
return;
}
+   if (ZEND_NUM_ARGS() == 3) {
+   convert_to_boolean_ex(strict);
+   if (Z_LVAL_PP(strict)) {
+   is_equal_func = is_identical_function;
+   }
+   }

/* Initialize return array */
array_init(return_value);
@@ -2279,7 +2303,7 @@
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void 
**)entry, pos) == SUCCESS) {
if (search_value != NULL) {
-   is_equal_function(res, *search_value, *entry 
TSRMLS_CC);
+   is_equal_func(res, *search_value, *entry TSRMLS_CC);
add_key = zval_is_true(res);
}

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


Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2004-01-24 Thread Jani Taskinen

Yes, what's the point in having such compatibility things
in HEAD?

--Jani

On Sat, 24 Jan 2004, Andrey Hristov wrote:

Ooops, something else slipped in :/ (no more commits so late).
Anyway, should I revert the irrelevant part about ZEND_ENGINE_2 ?

Andrey

Andrey Hristov wrote:
 andrey   Fri Jan 23 19:25:58 2004 EDT
 
   Modified files:  
 /php-src/ext/standardarray.c 
   Log:
   Added third parameter (optional) to array_keys for strictness. It behaves
   like the strict parameter of in_array().
   #Closing feature request #24258
   
   
 http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.256r2=1.257ty=u
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.256 php-src/ext/standard/array.c:1.257
 --- php-src/ext/standard/array.c:1.256   Sat Jan 17 12:33:10 2004
 +++ php-src/ext/standard/array.c Fri Jan 23 19:25:58 2004
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.256 2004/01/17 17:33:10 andrey Exp $ */
 +/* $Id: array.c,v 1.257 2004/01/24 00:25:58 andrey Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -1135,6 +1135,13 @@
  WRONG_PARAM_COUNT;
  }
  
 +#ifndef ZEND_ENGINE_2   
 +if (Z_TYPE_PP(value) == IS_OBJECT) {
 +php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for first 
 argument);
 +RETURN_FALSE;
 +}
 +#endif
 +
  if (Z_TYPE_PP(array) != IS_ARRAY) {
  php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for second 
 argument);
  RETURN_FALSE;
 @@ -1473,6 +1480,14 @@
  }
  newval = *val;
  while (i--) {
 +#ifndef ZEND_ENGINE_2
 +if (newval-refcount = 62000) {
 +MAKE_STD_ZVAL(newval);
 +*newval = **val;
 +zval_copy_ctor(newval);
 +newval-refcount = 0;
 +}
 +#endif  
  zval_add_ref(newval);
  zend_hash_next_index_insert(Z_ARRVAL_P(return_value), newval, 
 sizeof(zval *), NULL);
  }
 @@ -2243,7 +2258,7 @@
  /* }}} */
  
  
 -/* {{{ proto array array_keys(array input [, mixed search_value])
 +/* {{{ proto array array_keys(array input [, mixed search_value[, bool strict]])
 Return just the keys from the input array, optionally only for the specified 
 search_value */
  PHP_FUNCTION(array_keys)
  {
 @@ -2251,18 +2266,21 @@
   **search_value,/* Value to search for */
   **entry,   /* An entry in the input array */
 res, /* Result of comparison */
 + **strict,  /* be strict */
*new_val; /* New value */
  intadd_key; /* Flag to indicate whether a key should be added */
  char  *string_key;  /* String key */
  uint   string_key_len;
  ulong  num_key; /* Numeric key */
  HashPosition pos;
 +int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function;
 +
  
  search_value = NULL;
  
  /* Get arguments and do error-checking */
 -if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  2 ||
 -zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value) == 
 FAILURE) {
 +if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  3 ||
 +zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value, 
 strict) == FAILURE) {
  WRONG_PARAM_COUNT;
  }
  
 @@ -2270,6 +2288,12 @@
  php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument should 
 be an array);
  return;
  }
 +if (ZEND_NUM_ARGS() == 3) {
 +convert_to_boolean_ex(strict);
 +if (Z_LVAL_PP(strict)) {
 +is_equal_func = is_identical_function;
 +}
 +}
  
  /* Initialize return array */
  array_init(return_value);
 @@ -2279,7 +2303,7 @@
  zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), pos);
  while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)entry, 
 pos) == SUCCESS) {
  if (search_value != NULL) {
 -is_equal_function(res, *search_value, *entry TSRMLS_CC);
 +is_equal_func(res, *search_value, *entry TSRMLS_CC);
  add_key = zval_is_true(res);
  }
  
 



-- 
https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2004-01-24 Thread Andrey Hristov
Hi Jani,
there were some places in the codebase where the macro ZEND_ENGINE_2 was used.
I think these were the last 2 occurances.
Andrey

Jani Taskinen wrote:
Yes, what's the point in having such compatibility things
in HEAD?

--Jani

On Sat, 24 Jan 2004, Andrey Hristov wrote:


Ooops, something else slipped in :/ (no more commits so late).
Anyway, should I revert the irrelevant part about ZEND_ENGINE_2 ?
Andrey

Andrey Hristov wrote:

andrey		Fri Jan 23 19:25:58 2004 EDT

 Modified files:  
   /php-src/ext/standard	array.c 
 Log:
 Added third parameter (optional) to array_keys for strictness. It behaves
 like the strict parameter of in_array().
 #Closing feature request #24258
 
 
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.256r2=1.257ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.256 php-src/ext/standard/array.c:1.257
--- php-src/ext/standard/array.c:1.256	Sat Jan 17 12:33:10 2004
+++ php-src/ext/standard/array.c	Fri Jan 23 19:25:58 2004
@@ -21,7 +21,7 @@
   +--+
*/

-/* $Id: array.c,v 1.256 2004/01/17 17:33:10 andrey Exp $ */
+/* $Id: array.c,v 1.257 2004/01/24 00:25:58 andrey Exp $ */
#include php.h
#include php_ini.h
@@ -1135,6 +1135,13 @@
WRONG_PARAM_COUNT;
}
+#ifndef ZEND_ENGINE_2  
+   if (Z_TYPE_PP(value) == IS_OBJECT) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for first 
argument);
+   RETURN_FALSE;
+   }
+#endif
+   
if (Z_TYPE_PP(array) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for second 
argument);
RETURN_FALSE;
@@ -1473,6 +1480,14 @@
}
newval = *val;
while (i--) {
+#ifndef ZEND_ENGINE_2
+   if (newval-refcount = 62000) {
+   MAKE_STD_ZVAL(newval);
+   *newval = **val;
+   zval_copy_ctor(newval);
+   newval-refcount = 0;
+   }
+#endif 
zval_add_ref(newval);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), newval, 
sizeof(zval *), NULL);
}
@@ -2243,7 +2258,7 @@
/* }}} */
-/* {{{ proto array array_keys(array input [, mixed search_value])
+/* {{{ proto array array_keys(array input [, mixed search_value[, bool strict]])
   Return just the keys from the input array, optionally only for the specified 
search_value */
PHP_FUNCTION(array_keys)
{
@@ -2251,18 +2266,21 @@
 **search_value,/* Value to search for */
 **entry,   /* An entry in the input array */
   res, /* Result of comparison */
+**strict,  /* be strict */
  *new_val; /* New value */
intadd_key; /* Flag to indicate whether a key should be added */
char  *string_key;  /* String key */
uint   string_key_len;
ulong  num_key; /* Numeric key */
HashPosition pos;
+   int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function;
+
search_value = NULL;

/* Get arguments and do error-checking */
-   if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  2 ||
-   zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value) == 
FAILURE) {
+   if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  3 ||
+   zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value, 
strict) == FAILURE) {
WRONG_PARAM_COUNT;
}

@@ -2270,6 +2288,12 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument should be 
an array);
return;
}
+   if (ZEND_NUM_ARGS() == 3) {
+   convert_to_boolean_ex(strict);
+   if (Z_LVAL_PP(strict)) {
+   is_equal_func = is_identical_function;
+   }
+   }

/* Initialize return array */
array_init(return_value);
@@ -2279,7 +2303,7 @@
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)entry, 
pos) == SUCCESS) {
if (search_value != NULL) {
-   is_equal_function(res, *search_value, *entry TSRMLS_CC);
+   is_equal_func(res, *search_value, *entry TSRMLS_CC);
add_key = zval_is_true(res);
}




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


Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2004-01-23 Thread Andrey Hristov
Ooops, something else slipped in :/ (no more commits so late).
Anyway, should I revert the irrelevant part about ZEND_ENGINE_2 ?
Andrey

Andrey Hristov wrote:
andrey		Fri Jan 23 19:25:58 2004 EDT

  Modified files:  
/php-src/ext/standard	array.c 
  Log:
  Added third parameter (optional) to array_keys for strictness. It behaves
  like the strict parameter of in_array().
  #Closing feature request #24258
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.256r2=1.257ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.256 php-src/ext/standard/array.c:1.257
--- php-src/ext/standard/array.c:1.256	Sat Jan 17 12:33:10 2004
+++ php-src/ext/standard/array.c	Fri Jan 23 19:25:58 2004
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: array.c,v 1.256 2004/01/17 17:33:10 andrey Exp $ */
+/* $Id: array.c,v 1.257 2004/01/24 00:25:58 andrey Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -1135,6 +1135,13 @@
 		WRONG_PARAM_COUNT;
 	}
 
+#ifndef ZEND_ENGINE_2	
+	if (Z_TYPE_PP(value) == IS_OBJECT) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for first argument);
+		RETURN_FALSE;
+	}
+#endif
+	
 	if (Z_TYPE_PP(array) != IS_ARRAY) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, Wrong datatype for second argument);
 		RETURN_FALSE;
@@ -1473,6 +1480,14 @@
 	}
 	newval = *val;
 	while (i--) {
+#ifndef ZEND_ENGINE_2
+		if (newval-refcount = 62000) {
+			MAKE_STD_ZVAL(newval);
+			*newval = **val;
+			zval_copy_ctor(newval);
+			newval-refcount = 0;
+		}
+#endif		
 		zval_add_ref(newval);
 		zend_hash_next_index_insert(Z_ARRVAL_P(return_value), newval, sizeof(zval *), NULL);
 	}
@@ -2243,7 +2258,7 @@
 /* }}} */
 
 
-/* {{{ proto array array_keys(array input [, mixed search_value])
+/* {{{ proto array array_keys(array input [, mixed search_value[, bool strict]])
Return just the keys from the input array, optionally only for the specified search_value */
 PHP_FUNCTION(array_keys)
 {
@@ -2251,18 +2266,21 @@
 	 **search_value,	/* Value to search for */
 	 **entry,		/* An entry in the input array */
 	   res,		/* Result of comparison */
+	 **strict,		/* be strict */
 	  *new_val;		/* New value */
 	intadd_key;		/* Flag to indicate whether a key should be added */
 	char  *string_key;	/* String key */
 	uint   string_key_len;
 	ulong  num_key;		/* Numeric key */
 	HashPosition pos;
+	int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function;
+
 
 	search_value = NULL;
 	
 	/* Get arguments and do error-checking */
-	if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  2 ||
-		zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value) == FAILURE) {
+	if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  3 ||
+		zend_get_parameters_ex(ZEND_NUM_ARGS(), input, search_value, strict) == FAILURE) {
 		WRONG_PARAM_COUNT;
 	}
 	
@@ -2270,6 +2288,12 @@
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, The first argument should be an array);
 		return;
 	}
+	if (ZEND_NUM_ARGS() == 3) {
+		convert_to_boolean_ex(strict);
+		if (Z_LVAL_PP(strict)) {
+			is_equal_func = is_identical_function;
+		}
+	}
 	
 	/* Initialize return array */
 	array_init(return_value);
@@ -2279,7 +2303,7 @@
 	zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), pos);
 	while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)entry, pos) == SUCCESS) {
 		if (search_value != NULL) {
-	 		is_equal_function(res, *search_value, *entry TSRMLS_CC);
+	 		is_equal_func(res, *search_value, *entry TSRMLS_CC);
 			add_key = zval_is_true(res);
 		}
 	

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


Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c php_array.h

2003-09-26 Thread Jani Taskinen
  
Still waiting for the documentation for these..and also
where are the NEWS entries?

--Jani


On Tue, 23 Sep 2003, Andrey Hristov wrote:

andrey Tue Sep 23 13:37:29 2003 EDT

  Modified files:  
/php-src/ext/standard  array.c basic_functions.c php_array.h 
  Log:
  4 new functions :
  array_udiff()
  array_udiff_assoc()
  array_diff_uassoc()
  array_udiff_uassoc()
  They work like array_diff() or array_diff_assoc() but callback function(s)
  can be used to perform the comparisons. For example array_udiff_uassoc()
  expects 2 callbacks are last 2 parameters one is used to compare the values
  of the entries in the arrays the second to compare the keys.
  Class methods are also valid callbacks. Even when the data that should be
  used in the comparison is private or protected then a static method of a
  class should be used (this behaviour can be seen in the regression test -
  007.phpt).
  
  

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c php_array.h

2003-09-26 Thread Andrey Hristov
I will work on the documentation next week and will add a news entry soon.

Andrey

Jani Taskinen wrote:

 
   Still waiting for the documentation for these..and also
   where are the NEWS entries?
   
   --Jani
   

On Tue, 23 Sep 2003, Andrey Hristov wrote:

 

andrey		Tue Sep 23 13:37:29 2003 EDT

Modified files:  
  /php-src/ext/standard	array.c basic_functions.c php_array.h 
Log:
4 new functions :
array_udiff()
array_udiff_assoc()
array_diff_uassoc()
array_udiff_uassoc()
They work like array_diff() or array_diff_assoc() but callback function(s)
can be used to perform the comparisons. For example array_udiff_uassoc()
expects 2 callbacks are last 2 parameters one is used to compare the values
of the entries in the arrays the second to compare the keys.
Class methods are also valid callbacks. Even when the data that should be
used in the comparison is private or protected then a static method of a
class should be used (this behaviour can be seen in the regression test -
007.phpt).

   

 

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


Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c php_array.h

2003-09-24 Thread Andrey Hristov
Wez Furlong wrote:
 Should these functions really go into the core?
 Perhaps they are better off in an extension (pecl/array_utils ?)

 The names aren't really all that obvious to me either.

 --Wez.
Hi Wez,
well maybe array_udiff_uassoc() and array_diff_uassoc() are of little 
need but I added them for completeness to array_udiff() and 
array_udiff_assoc(). It's easy not to export array_udiff_uassoc() and 
array_diff_uassoc() and this won't hurt me. However I think that 
array_udiff() and array_udiff_assoc() are useful. As I stated in my talk 
to Jani, in 4_3 it is impossible to use array_diff() or 
array_diff_assoc() on arrays that contain objects. When I started to 
implement (and implemented) these functions few months ago I had no need 
of them, I did it for fun.  However, month or two ago I faced a case 
where I needed this functionality but unfortunately it wasn't available 
so I had to find a way to workaround it.
 Let me show you a small example :
?php
class CPerson {
private $priv_member;
public  $public_member;
function CPerson($val) {
$this-priv_member = $val;
$this-public_member = $val;
}
static function comp_func_cr($a, $b) {
if ($a-priv_member === $b-priv_member) return 0;
return ($a-priv_member  $b-priv_member)? 1:-1;
}
}// class CPerson
$a = array(
0.1 = new cr(9),
0.5 = new cr(12),
0 = new cr(23),
1=  new cr(4),
2 = new cr(-15),
);
$b = array(0.2 = new cr(9),
0.5 = new cr(22),
0 = new cr( 3),
1= new cr(4),
2 = new cr(-15),
);
?
In this case $a and $b contain objects. Even more they have private 
member variables. array_diff() is in no use here since it _cannot_ work 
with objects well : if I execute array_diff($a, $b) the returned array 
will contain the elements of $a . So, what to do to make a diff of the 
two arrays and not to code a function (in PHP) for that by myself? - 
Implement core function for that. This functionality goes to 5.0.0 where 
the object model is better and if core functions can work well with 
object(s) it will be good and not bad IMO.
Using array_udiff() it is easy to diff $a and $b :
?php
array_udiff($a, $b, array(cr, comp_func_cr));
?

If there are better names for these functions I have nothing against to 
rename them. I named them this way because of the function usort() that 
sorts an array by using a callback function.

Regards,
Andrey
P.S.
I will appreciate the opinion of Marcus Boerger and Sebastian Bergmann 
whether these functions are useful or not. However, any other opinions 
are welcome (this is why i cross-post to internals@)




 - Original Message -
 From: Andrey Hristov [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, September 23, 2003 6:37 PM
 Subject: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c
 php_array.h



andrey Tue Sep 23 13:37:29 2003 EDT

  Modified files:
/php-src/ext/standard array.c basic_functions.c php_array.h
  Log:
  4 new functions :
  array_udiff()
  array_udiff_assoc()
  array_diff_uassoc()
  array_udiff_uassoc()
  They work like array_diff() or array_diff_assoc() but callback

 function(s)

  can be used to perform the comparisons. For example 
array_udiff_uassoc()
  expects 2 callbacks are last 2 parameters one is used to compare the

 values

  of the entries in the arrays the second to compare the keys.
  Class methods are also valid callbacks. Even when the data that should

 be

  used in the comparison is private or protected then a static method 
of a
  class should be used (this behaviour can be seen in the regression

 test -

  007.phpt).



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


Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c php_array.h

2003-09-23 Thread Wez Furlong
Should these functions really go into the core?
Perhaps they are better off in an extension (pecl/array_utils ?)

The names aren't really all that obvious to me either.

--Wez.

- Original Message - 
From: Andrey Hristov [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 23, 2003 6:37 PM
Subject: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c
php_array.h


 andrey Tue Sep 23 13:37:29 2003 EDT

   Modified files:
 /php-src/ext/standard array.c basic_functions.c php_array.h
   Log:
   4 new functions :
   array_udiff()
   array_udiff_assoc()
   array_diff_uassoc()
   array_udiff_uassoc()
   They work like array_diff() or array_diff_assoc() but callback
function(s)
   can be used to perform the comparisons. For example array_udiff_uassoc()
   expects 2 callbacks are last 2 parameters one is used to compare the
values
   of the entries in the arrays the second to compare the keys.
   Class methods are also valid callbacks. Even when the data that should
be
   used in the comparison is private or protected then a static method of a
   class should be used (this behaviour can be seen in the regression
test -
   007.phpt).

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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2003-08-14 Thread Ilia Alshanetsky
I'll make it set the defaut value to NULL, that addresses the problem you've 
described and maintains acceptable behaviour for the original problem.

Ilia

On August 9, 2003 02:09 am, Moriyoshi Koizumi wrote:
 I don't think using 0 as the initial value by default is a good idea.
 because array_reduce() can take any kind of element other than integer.

 ?php
 $a = array(a, b, c);
 $lambda = create_function('$a, $b', 'return $a . $b;');
 var_dump(array_reduce($a, $lambda));
 ?

 [Before this patch]
 string(3) abc

 [After this patch]
 string(4) 0abc

 Those results imply a significant BC break. I don't know what *is* the
 correct behaviour though.

 Moriyoshi

 Ilia Alshanetsky [EMAIL PROTECTED] wrote:
  iliaa   Fri Aug  8 19:50:36 2003 EDT
 
Modified files:
  /php-src/ext/standard   array.c
Log:
Fixed bug #24980 (array_reduce() uses first element as default running
total).
Fixed memory leak that can be replicated using the function example on
http://www.php.net/array_reduce
 
 
  Index: php-src/ext/standard/array.c
  diff -u php-src/ext/standard/array.c:1.238
  php-src/ext/standard/array.c:1.239 ---
  php-src/ext/standard/array.c:1.238  Tue Aug  5 06:29:03 2003
  +++ php-src/ext/standard/array.cFri Aug  8 19:50:36 2003
  @@ -21,7 +21,7 @@
 
  +--+
  */
 
  -/* $Id: array.c,v 1.238 2003/08/05 10:29:03 zeev Exp $ */
  +/* $Id: array.c,v 1.239 2003/08/08 23:50:36 iliaa Exp $ */
 
   #include php.h
   #include php_ini.h
  @@ -3374,7 +3374,9 @@
 
  if (ZEND_NUM_ARGS()  2) {
  result = *initial;
  -   zval_add_ref(result);
  +   } else {
  +   MAKE_STD_ZVAL(result);
  +   ZVAL_LONG(result, 0);
  }
 
  /* (zval **)input points to an element of argument stack
 
 
 
  --
  PHP CVS Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2003-08-14 Thread Moriyoshi Koizumi
I don't think using 0 as the initial value by default is a good idea.
because array_reduce() can take any kind of element other than integer.

?php
$a = array(a, b, c);
$lambda = create_function('$a, $b', 'return $a . $b;');
var_dump(array_reduce($a, $lambda));
?

[Before this patch]
string(3) abc

[After this patch]
string(4) 0abc

Those results imply a significant BC break. I don't know what *is* the 
correct behaviour though.

Moriyoshi

Ilia Alshanetsky [EMAIL PROTECTED] wrote:

 iliaa Fri Aug  8 19:50:36 2003 EDT
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   Fixed bug #24980 (array_reduce() uses first element as default running
   total).
   Fixed memory leak that can be replicated using the function example on 
   http://www.php.net/array_reduce
   
   
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.238 php-src/ext/standard/array.c:1.239
 --- php-src/ext/standard/array.c:1.238Tue Aug  5 06:29:03 2003
 +++ php-src/ext/standard/array.c  Fri Aug  8 19:50:36 2003
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.238 2003/08/05 10:29:03 zeev Exp $ */
 +/* $Id: array.c,v 1.239 2003/08/08 23:50:36 iliaa Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -3374,7 +3374,9 @@
  
   if (ZEND_NUM_ARGS()  2) {
   result = *initial;
 - zval_add_ref(result);
 + } else {
 + MAKE_STD_ZVAL(result);
 + ZVAL_LONG(result, 0);
   }
  
   /* (zval **)input points to an element of argument stack
 
 
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP-CVS] cvs: php-src /ext/standard array.c

2003-08-05 Thread Sterling Hughes
Am Mon, 2003-08-04 um 04.38 schrieb Zeev Suraski:
 zeev  Mon Aug  4 04:38:24 2003 EDT
 
   Modified files:  
 /php-src/ext/standard array.c 
   Log:
   Fix bug #24652 - Sterling, do you begin to think that maybe it wasn't such
   a good idea?

Nope.  Needs only to be fixed once, and the performance gain is
signifigant enough. :)

-Sterling

   
   
 Index: php-src/ext/standard/array.c
 diff -u php-src/ext/standard/array.c:1.236 php-src/ext/standard/array.c:1.237
 --- php-src/ext/standard/array.c:1.236Thu Jul 24 23:03:26 2003
 +++ php-src/ext/standard/array.c  Mon Aug  4 04:38:24 2003
 @@ -21,7 +21,7 @@
 +--+
  */
  
 -/* $Id: array.c,v 1.236 2003/07/25 03:03:26 iliaa Exp $ */
 +/* $Id: array.c,v 1.237 2003/08/04 08:38:24 zeev Exp $ */
  
  #include php.h
  #include php_ini.h
 @@ -2545,7 +2545,7 @@
   if (Z_TYPE_PP(entry) == IS_LONG) {
   zend_hash_index_update(Z_ARRVAL_P(return_value), 
 Z_LVAL_PP(entry), data, sizeof(data), NULL);
   } else if (Z_TYPE_PP(entry) == IS_STRING) {
 - zend_hash_update(Z_ARRVAL_P(return_value), Z_STRVAL_PP(entry), 
 Z_STRLEN_PP(entry) + 1, data, sizeof(data), NULL);
 + zend_symtable_update(Z_ARRVAL_P(return_value), 
 Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, data, sizeof(data), NULL);
   } else {
   zval_ptr_dtor(data); /* will free also zval structure */
   php_error_docref(NULL TSRMLS_CC, E_WARNING, Can only flip 
 STRING and INTEGER values!);
-- 
We all agree on the necessity of compromise.  We just can't agree on when  
it's necessary to compromise. 
  - Larry Wall

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