[PHP-CVS] com php-src: Fixed linkage with C++: Zend/zend_generators.h

2013-04-22 Thread Dmitry Stogov
Commit:13b039ff9ab5bb21fe2e739f666852e863aa1bf2
Author:Dmitry Stogov dmi...@zend.com Mon, 22 Apr 2013 15:39:50 
+0400
Parents:   32490673b94bc4a93bcbb8e897c198f38794472a
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=13b039ff9ab5bb21fe2e739f666852e863aa1bf2

Log:
Fixed linkage with C++

Changed paths:
  M  Zend/zend_generators.h


Diff:
diff --git a/Zend/zend_generators.h b/Zend/zend_generators.h
index 9f37b93..bc12565 100644
--- a/Zend/zend_generators.h
+++ b/Zend/zend_generators.h
@@ -22,8 +22,8 @@
 #define ZEND_GENERATORS_H
 
 BEGIN_EXTERN_C()
+
 extern ZEND_API zend_class_entry *zend_ce_generator;
-END_EXTERN_C()
 
 typedef struct _zend_generator_iterator {
zend_object_iterator intern;
@@ -66,6 +66,8 @@ ZEND_API zval *zend_generator_create_zval(zend_op_array 
*op_array TSRMLS_DC);
 ZEND_API void zend_generator_close(zend_generator *generator, zend_bool 
finished_execution TSRMLS_DC);
 ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC);
 
+END_EXTERN_C()
+
 #endif
 
 /*


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



[PHP-CVS] com php-src: overflow2 is not exported by system libgd: ext/gd/libgd/gd_compat.c

2013-04-22 Thread Remi Collet
Commit:6889a0d1f5a2eaa8103216d9cb01160e7a637f8d
Author:Remi Collet r...@php.net Mon, 22 Apr 2013 17:39:35 +0200
Parents:   13b039ff9ab5bb21fe2e739f666852e863aa1bf2
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=6889a0d1f5a2eaa8103216d9cb01160e7a637f8d

Log:
overflow2 is not exported by system libgd

Changed paths:
  M  ext/gd/libgd/gd_compat.c


Diff:
diff --git a/ext/gd/libgd/gd_compat.c b/ext/gd/libgd/gd_compat.c
index 473ea20..b563290 100644
--- a/ext/gd/libgd/gd_compat.c
+++ b/ext/gd/libgd/gd_compat.c
@@ -33,3 +33,14 @@ const char * gdPngGetVersionString()
 }
 #endif
 
+int overflow2(int a, int b)
+{
+   if(a = 0 || b = 0) {
+   return 1;
+   }
+   if(a  INT_MAX / b) {
+   return 1;
+   }
+   return 0;
+}
+


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



[PHP-CVS] com php-src: temporary disable WBM detection with system libgd, as gdGetC, getmbi and skipheader not exported: ext/gd/gd.c

2013-04-22 Thread Remi Collet
Commit:ec1678dd7c1c802748f8a5d6811c571cc5752a6a
Author:Remi Collet r...@php.net Mon, 22 Apr 2013 17:48:28 +0200
Parents:   6889a0d1f5a2eaa8103216d9cb01160e7a637f8d
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=ec1678dd7c1c802748f8a5d6811c571cc5752a6a

Log:
temporary disable WBM detection with system libgd, as gdGetC, getmbi and 
skipheader not exported

Changed paths:
  M  ext/gd/gd.c


Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index ba18b85..6cafb51 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -2403,6 +2403,8 @@ static int _php_image_type (char data[8])
} else if (!memcmp(data, php_sig_gif, 3)) {
return PHP_GDIMG_TYPE_GIF;
}
+/* Temporary disabled, as gdGetC, getmbi and skipheader not exported in system 
libgd */
+#if HAVE_GD_BUNDLED
 #ifdef HAVE_GD_WBMP
else {
gdIOCtx *io_ctx;
@@ -2425,6 +2427,7 @@ static int _php_image_type (char data[8])
}
}
 #endif
+#endif
return -1;
 #endif
 }


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



[PHP-CVS] com php-src: Merge branch 'PHP-5.5': ext/gd/gd.c

2013-04-22 Thread Remi Collet
Commit:41ef288ced776c1b1b8440cdbcaf3c82a27ff0c8
Author:Remi Collet r...@php.net Mon, 22 Apr 2013 17:48:43 +0200
Parents:   149cf2650a25fcff5d8de7a783c5d1fd7f1aeec7 
ec1678dd7c1c802748f8a5d6811c571cc5752a6a
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=41ef288ced776c1b1b8440cdbcaf3c82a27ff0c8

Log:
Merge branch 'PHP-5.5'

* PHP-5.5:
  temporary disable WBM detection with system libgd, as gdGetC, getmbi and 
skipheader not exported

Changed paths:
  MM  ext/gd/gd.c


Diff:



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



[PHP-CVS] com php-src: updated NEWS: NEWS

2013-04-22 Thread Anatol Belski
Commit:b3aa3c26168df33fd739669bb7ede2af88051158
Author:Anatol Belski a...@php.net Mon, 22 Apr 2013 18:59:47 +0200
Parents:   8febe2ad081dafa3d9d617c3d27f73777d735cc4
Branches:  PHP-5.4 PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=b3aa3c26168df33fd739669bb7ede2af88051158

Log:
updated NEWS

Changed paths:
  M  NEWS


Diff:
diff --git a/NEWS b/NEWS
index 9aa035c..c93c899 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP  
  NEWS
   . Fixed bug #64342 (ZipArchive::addFile() has to check for file existence).
 (Anatol)
 
+- Streams:
+  . Fixed Windows x64 version of stream_socket_pair() and improved error 
handling
+(Anatol Belski)
+
 11 Apr 2013, PHP 5.4.14
 
 - Core:


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



[PHP-CVS] com php-src: Fixed stream_socket_pair() on Windows x64 and: NEWS ext/standard/streamsfuncs.c win32/sockets.c

2013-04-22 Thread Anatol Belski
Commit:f082d6311b7998987f018fc6c791dd1892f2912a
Author:Anatol Belski a...@php.net Mon, 22 Apr 2013 18:53:52 +0200
Parents:   70b67f2e509ca05e60c85cc14c1b82b107713604
Branches:  PHP-5.3 PHP-5.4 PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=f082d6311b7998987f018fc6c791dd1892f2912a

Log:
Fixed stream_socket_pair() on Windows x64 and

improved errorhandling in the socketpair() implementation.

Changed paths:
  M  NEWS
  M  ext/standard/streamsfuncs.c
  M  win32/sockets.c


Diff:
diff --git a/NEWS b/NEWS
index a5cd7f2..0876c1e 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ PHP  
  NEWS
   . Fixed bug #64342 (ZipArchive::addFile() has to check for file existence).
   (Anatol)
 
+- Streams:
+  . Fixed Windows x64 version of stream_socket_pair() and improved error 
handling
+  (Anatol Belski)
+
 11 Apr 2013, PHP 5.3.24
 
 - Core
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 4a86007..27042f6 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -51,7 +51,7 @@ PHP_FUNCTION(stream_socket_pair)
 {
long domain, type, protocol;
php_stream *s1, *s2;
-   int pair[2];
+   php_socket_t pair[2];
 
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, lll,
domain, type, protocol)) {
diff --git a/win32/sockets.c b/win32/sockets.c
index d642808..c8fddd6 100644
--- a/win32/sockets.c
+++ b/win32/sockets.c
@@ -39,33 +39,54 @@ PHPAPI int socketpair(int domain, int type, int protocol, 
SOCKET sock[2])
return -1;
}
 
+   sock[0] = sock[1] = redirect = INVALID_SOCKET;
 
-   sock[0] = socket(domain, type, protocol);
-   address.sin_addr.s_addr = INADDR_ANY;
-   address.sin_family  = AF_INET;
-   address.sin_port= 0;
 
-   bind(sock[0], (struct sockaddr*)address, sizeof(address));
+   sock[0] = socket(domain, type, protocol);
+   if (INVALID_SOCKET == sock[0]) {
+   goto error;
+   }
+
+   address.sin_addr.s_addr = INADDR_ANY;
+   address.sin_family  = AF_INET;
+   address.sin_port= 0;
+
+   if (bind(sock[0], (struct sockaddr*)address, sizeof(address)) != 0) {
+   goto error;
+   }
 
if(getsockname(sock[0], (struct sockaddr *)address, size) != 0) {
+   goto error;
+   }
+
+   if (listen(sock[0], 2) != 0) {
+   goto error;
+   }
+
+   sock[1] = socket(domain, type, protocol);
+   if (INVALID_SOCKET == sock[1]) {
+   goto error;
}
 
-   listen(sock[0], 2);
-   sock[1] = socket(domain, type, protocol);   
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+   if(connect(sock[1], (struct sockaddr*)address, sizeof(address)) != 0) {
+   goto error;
+   }
 
-   connect(sock[1], (struct sockaddr*)address, sizeof(address));
redirect = accept(sock[0],(struct sockaddr*)address, size);
+   if (INVALID_SOCKET == redirect) {
+   goto error;
+   }
 
closesocket(sock[0]);
sock[0] = redirect;
 
-   if(sock[0] == INVALID_SOCKET ) {
-   closesocket(sock[0]);
-   closesocket(sock[1]);
-   WSASetLastError(WSAECONNABORTED);
-   return -1;
-   }
-   
return 0;
+
+error:
+   closesocket(redirect);
+   closesocket(sock[0]);
+   closesocket(sock[1]);
+   WSASetLastError(WSAECONNABORTED);
+   return -1;
 }


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



[PHP-CVS] com php-src: updated NEWS: NEWS

2013-04-22 Thread Anatol Belski
Commit:b119836765a72700a07b004b95c92beffa3daf95
Author:Anatol Belski a...@php.net Mon, 22 Apr 2013 19:00:46 +0200
Parents:   f578bb038874098140f408468a3999fe7dc7fc6c
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=b119836765a72700a07b004b95c92beffa3daf95

Log:
updated NEWS

Changed paths:
  M  NEWS


Diff:
diff --git a/NEWS b/NEWS
index 15aa0bc..74ed8dc 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP  
  NEWS
   . Fixed bug #64342 (ZipArchive::addFile() has to check for file existence).
 (Anatol)
 
+- Streams:
+  . Fixed Windows x64 version of stream_socket_pair() and improved error 
handling
+(Anatol Belski)
+
 11 Apr 2013, PHP 5.5.0 Beta 3
 
 - Core:


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



[PHP-CVS] com php-src: Merge branch 'PHP-5.3' into PHP-5.4: ext/standard/streamsfuncs.c

2013-04-22 Thread Anatol Belski
Commit:8febe2ad081dafa3d9d617c3d27f73777d735cc4
Author:Anatol Belski a...@php.net Mon, 22 Apr 2013 18:59:11 +0200
Parents:   0b2c411323413deffd3ae71a634f413ce04cdacc 
f082d6311b7998987f018fc6c791dd1892f2912a
Branches:  PHP-5.4 PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=8febe2ad081dafa3d9d617c3d27f73777d735cc4

Log:
Merge branch 'PHP-5.3' into PHP-5.4

* PHP-5.3:
  Fixed stream_socket_pair() on Windows x64 and

Changed paths:
  MM  ext/standard/streamsfuncs.c


Diff:



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



[PHP-CVS] com php-src: Fix handling of double keys in array_column: ext/standard/array.c ext/standard/tests/array/array_column_basic.phpt ext/standard/tests/array/array_column_error.phpt

2013-04-22 Thread Sara Golemon
Commit:7b34324f846505a0af6bed83556b840b50a1ef30
Author:Sara Golemon poll...@php.net Sun, 21 Apr 2013 22:21:40 
-0700
Parents:   b119836765a72700a07b004b95c92beffa3daf95
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=7b34324f846505a0af6bed83556b840b50a1ef30

Log:
Fix handling of double keys in array_column

Also fix resource test to not localize __FILE__ to cwd.

Changed paths:
  M  ext/standard/array.c
  M  ext/standard/tests/array/array_column_basic.phpt
  M  ext/standard/tests/array/array_column_error.phpt


Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 9a64cf4..425d53e 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2547,6 +2547,9 @@ PHP_FUNCTION(array_column)
case IS_LONG:
column_idx = Z_LVAL_PP(zcolumn);
break;
+   case IS_DOUBLE:
+   column_idx = (long)Z_DVAL_PP(zcolumn);
+   break;
case IS_STRING:
column = Z_STRVAL_PP(zcolumn);
column_len = Z_STRLEN_PP(zcolumn);
@@ -2569,6 +2572,9 @@ PHP_FUNCTION(array_column)
case IS_LONG:
key_idx = Z_LVAL_PP(zkey);
break;
+   case IS_DOUBLE:
+   key_idx = (long)Z_DVAL_PP(zkey);
+   break;
case IS_STRING:
key = Z_STRVAL_PP(zkey);
key_len = Z_STRLEN_PP(zkey);
diff --git a/ext/standard/tests/array/array_column_basic.phpt 
b/ext/standard/tests/array/array_column_basic.phpt
index 70ce213..8c49910 100644
--- a/ext/standard/tests/array/array_column_basic.phpt
+++ b/ext/standard/tests/array/array_column_basic.phpt
@@ -42,8 +42,7 @@ echo -- last_name column from recordset, keyed by value from 
first_name column
 var_dump(array_column($records, 'last_name', 'first_name'));
 
 echo \n*** Testing multiple data types ***\n;
-$file = basename(__FILE__);
-$fh = fopen($file, 'r', true);
+$fh = fopen(__FILE__, 'r', true);
 $values = array(
array(
'id' = 1,
@@ -89,11 +88,13 @@ $numericCols = array(
 );
 var_dump(array_column($numericCols, 1));
 var_dump(array_column($numericCols, 1, 0));
+var_dump(array_column($numericCols, 1, 0.123));
 
 echo \n*** Testing failure to find specified column ***\n;
 var_dump(array_column($numericCols, 2));
 var_dump(array_column($numericCols, 'foo'));
 var_dump(array_column($numericCols, 0, 'foo'));
+var_dump(array_column($numericCols, 3.14));
 
 echo \n*** Testing single dimensional array ***\n;
 $singleDimension = array('foo', 'bar', 'baz');
@@ -230,6 +231,14 @@ array(3) {
   [ccc]=
   string(3) 333
 }
+array(3) {
+  [aaa]=
+  string(3) 111
+  [bbb]=
+  string(3) 222
+  [ccc]=
+  string(3) 333
+}
 
 *** Testing failure to find specified column ***
 array(0) {
@@ -244,6 +253,8 @@ array(3) {
   [2]=
   string(3) ccc
 }
+array(0) {
+}
 
 *** Testing single dimensional array ***
 array(0) {
diff --git a/ext/standard/tests/array/array_column_error.phpt 
b/ext/standard/tests/array/array_column_error.phpt
index 1aec1ac..bdcbec0 100644
--- a/ext/standard/tests/array/array_column_error.phpt
+++ b/ext/standard/tests/array/array_column_error.phpt
@@ -26,18 +26,12 @@ var_dump(array_column(1, 'foo'));
 echo \n-- Testing array_column() column key parameter should be a string or 
an integer (testing bool) --\n;
 var_dump(array_column(array(), true));
 
-echo \n-- Testing array_column() column key parameter should be a string or 
integer (testing float) --\n;
-var_dump(array_column(array(), 2.3));
-
 echo \n-- Testing array_column() column key parameter should be a string or 
integer (testing array) --\n;
 var_dump(array_column(array(), array()));
 
 echo \n-- Testing array_column() index key parameter should be a string or an 
integer (testing bool) --\n;
 var_dump(array_column(array(), 'foo', true));
 
-echo \n-- Testing array_column() index key parameter should be a string or 
integer (testing float) --\n;
-var_dump(array_column(array(), 'foo', 2.3));
-
 echo \n-- Testing array_column() index key parameter should be a string or 
integer (testing array) --\n;
 var_dump(array_column(array(), 'foo', array()));
 
@@ -71,11 +65,6 @@ NULL
 Warning: array_column(): The column key should be either a string or an 
integer in %s on line %d
 bool(false)
 
--- Testing array_column() column key parameter should be a string or integer 
(testing float) --
-
-Warning: array_column(): The column key should be either a string or an 
integer in %s on line %d
-bool(false)
-
 -- Testing array_column() column key parameter should be a string or integer 
(testing array) --
 
 Warning: array_column(): The column key should be either a string or an 
integer in %s on line %d
@@ -86,11 +75,6 @@ bool(false)
 Warning: array_column(): The index 

[PHP-CVS] com php-src: Harden array_column_basic.phpt against resource renumbering.: ext/standard/tests/array/array_column_basic.phpt

2013-04-22 Thread Sara Golemon
Commit:f63db963c48775e89e7d5f63235733098c2f653d
Author:Sara Golemon poll...@php.net Mon, 22 Apr 2013 13:36:40 
-0700
Parents:   7b34324f846505a0af6bed83556b840b50a1ef30
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=f63db963c48775e89e7d5f63235733098c2f653d

Log:
Harden array_column_basic.phpt against resource renumbering.

We don't care what resource number it is, so long as there's a
stream resource returned.

Changed paths:
  M  ext/standard/tests/array/array_column_basic.phpt


Diff:
diff --git a/ext/standard/tests/array/array_column_basic.phpt 
b/ext/standard/tests/array/array_column_basic.phpt
index 8c49910..eb267da 100644
--- a/ext/standard/tests/array/array_column_basic.phpt
+++ b/ext/standard/tests/array/array_column_basic.phpt
@@ -192,7 +192,7 @@ array(8) {
   [6]=
   string(3) Foo
   [7]=
-  resource(5) of type (stream)
+  resource(%d) of type (stream)
 }
 array(8) {
   [1]=
@@ -211,7 +211,7 @@ array(8) {
   [7]=
   string(3) Foo
   [8]=
-  resource(5) of type (stream)
+  resource(%d) of type (stream)
 }
 
 *** Testing numeric column keys ***


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



[PHP-CVS] svn: /SVNROOT/ global_avail

2013-04-22 Thread Ferenc Kovacs
tyrael   Mon, 22 Apr 2013 21:28:57 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=330134

Log:
pecl/yaml is under git now

Changed paths:
U   SVNROOT/global_avail

Modified: SVNROOT/global_avail
===
--- SVNROOT/global_avail2013-04-22 17:58:30 UTC (rev 330133)
+++ SVNROOT/global_avail2013-04-22 21:28:57 UTC (rev 330134)
@@ -333,7 +333,7 @@
 avail|cyberspice|pecl/dio,pecl/framegrab,phpdoc,pecl/dbus
 avail|crodas|pecl/textcat,phpdoc
 avail|dmendolia,patrickallaert,dragoonis|pecl/apm,phpdoc
-avail|bd808|pecl/yaml,phpdoc
+avail|bd808|pecl/file_formats/yaml.git,phpdoc
 avail|dchill42pecl|pecl/xdom,phpdoc
 avail|hradtke|pecl/memcache,phpdoc
 avail|pdezwart,brodriguez,bkw|pecl/amqp,phpdoc

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

[PHP-CVS] com php-src: Allow array_column() to take -1 as a valid value in third param: ext/standard/array.c ext/standard/tests/array/array_column_basic.phpt

2013-04-22 Thread Sara Golemon
Commit:1a03bd5dee97a0f8b9e74b7f8db5231abd8cc7e4
Author:Sara Golemon poll...@php.net Mon, 22 Apr 2013 14:57:05 
-0700
Parents:   f63db963c48775e89e7d5f63235733098c2f653d
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=1a03bd5dee97a0f8b9e74b7f8db5231abd8cc7e4

Log:
Allow array_column() to take -1 as a valid value in third param

Also do some cleanup and simplification to make this code more
readable in the long term.

Changed paths:
  M  ext/standard/array.c
  M  ext/standard/tests/array/array_column_basic.phpt


Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 425d53e..6f769da 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2524,132 +2524,95 @@ PHP_FUNCTION(array_count_values)
 }
 /* }}} */
 
+/* {{{ array_column_param_helper
+ * Specialized conversion rules for array_column() function
+ */
+static inline
+zend_bool array_column_param_helper(zval **param,
+const char *name TSRMLS_DC) {
+   switch (Z_TYPE_PP(param)) {
+   case IS_NULL:
+   case IS_DOUBLE:
+   convert_to_long_ex(param);
+   /* fallthrough */
+   case IS_LONG:
+   return 1;
+
+   case IS_OBJECT:
+   convert_to_string_ex(param);
+   /* fallthrough */
+   case IS_STRING:
+   return 1;
+
+   default:
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The %s key 
should be either a string or an integer, name);
+   return 0;
+   }
+}
+
 /* {{{ proto array array_column(array input, mixed column_key[, mixed 
index_key])
Return the values from a single column in the input array, identified by the
value_key and optionally indexed by the index_key */
 PHP_FUNCTION(array_column)
 {
-   zval *zarray, **zcolumn, **zkey = NULL, **data, **zcolval, **zkeyval;
+   zval **zcolumn, **zkey = NULL, **data;
HashTable *arr_hash;
HashPosition pointer;
-   ulong column_idx = 0, key_idx = 0;
-   char *column = NULL, *key = NULL, *keyval = NULL;
-   int column_len = 0, key_len = 0, keyval_idx = -1;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, aZ|Z, zarray, 
zcolumn, zkey) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, hZ|Z!, 
arr_hash, zcolumn, zkey) == FAILURE) {
return;
}
 
-   switch (Z_TYPE_PP(zcolumn)) {
-   case IS_NULL:
-   column_idx = 0;
-   break;
-   case IS_LONG:
-   column_idx = Z_LVAL_PP(zcolumn);
-   break;
-   case IS_DOUBLE:
-   column_idx = (long)Z_DVAL_PP(zcolumn);
-   break;
-   case IS_STRING:
-   column = Z_STRVAL_PP(zcolumn);
-   column_len = Z_STRLEN_PP(zcolumn);
-   break;
-   case IS_OBJECT:
-   convert_to_string_ex(zcolumn);
-   column = Z_STRVAL_PP(zcolumn);
-   column_len = Z_STRLEN_PP(zcolumn);
-   break;
-   default:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, The column 
key should be either a string or an integer);
-   RETURN_FALSE;
-   }
-
-   if (zkey) {
-   switch (Z_TYPE_PP(zkey)) {
-   case IS_NULL:
-   key_idx = 0;
-   break;
-   case IS_LONG:
-   key_idx = Z_LVAL_PP(zkey);
-   break;
-   case IS_DOUBLE:
-   key_idx = (long)Z_DVAL_PP(zkey);
-   break;
-   case IS_STRING:
-   key = Z_STRVAL_PP(zkey);
-   key_len = Z_STRLEN_PP(zkey);
-   break;
-   case IS_OBJECT:
-   convert_to_string_ex(zkey);
-   key = Z_STRVAL_PP(zkey);
-   key_len = Z_STRLEN_PP(zkey);
-   break;
-   default:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
The index key should be either a string or an integer);
-   RETURN_FALSE;
-   }
+   if (!array_column_param_helper(zcolumn, column TSRMLS_CC) ||
+   (zkey  !array_column_param_helper(zkey, index TSRMLS_CC))) {
+   RETURN_FALSE;
}
 
-   arr_hash = Z_ARRVAL_P(zarray);
array_init(return_value);
-
for (zend_hash_internal_pointer_reset_ex(arr_hash, pointer);

[PHP-CVS] com php-src: array_column() - Use entire subject array when NULL passed for second param.: ext/standard/array.c ext/standard/tests/array/array_column_variant.phpt

2013-04-22 Thread Sara Golemon
Commit:734e165d4e427feca9a736b62832a2ff287a22c9
Author:Sara Golemon poll...@php.net Mon, 22 Apr 2013 16:19:21 
-0700
Parents:   1a03bd5dee97a0f8b9e74b7f8db5231abd8cc7e4
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=734e165d4e427feca9a736b62832a2ff287a22c9

Log:
array_column() - Use entire subject array when NULL passed for second param.

This starts to look like array_values(), except that you can reindex the arrays
using the third parameter.

Changed paths:
  M  ext/standard/array.c
  A  ext/standard/tests/array/array_column_variant.phpt


Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 6f769da..cfe9be8 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2531,7 +2531,6 @@ static inline
 zend_bool array_column_param_helper(zval **param,
 const char *name TSRMLS_DC) {
switch (Z_TYPE_PP(param)) {
-   case IS_NULL:
case IS_DOUBLE:
convert_to_long_ex(param);
/* fallthrough */
@@ -2555,15 +2554,15 @@ zend_bool array_column_param_helper(zval **param,
value_key and optionally indexed by the index_key */
 PHP_FUNCTION(array_column)
 {
-   zval **zcolumn, **zkey = NULL, **data;
+   zval **zcolumn = NULL, **zkey = NULL, **data;
HashTable *arr_hash;
HashPosition pointer;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, hZ|Z!, 
arr_hash, zcolumn, zkey) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, hZ!|Z!, 
arr_hash, zcolumn, zkey) == FAILURE) {
return;
}
 
-   if (!array_column_param_helper(zcolumn, column TSRMLS_CC) ||
+   if ((zcolumn  !array_column_param_helper(zcolumn, column 
TSRMLS_CC)) ||
(zkey  !array_column_param_helper(zkey, index TSRMLS_CC))) {
RETURN_FALSE;
}
@@ -2581,8 +2580,12 @@ PHP_FUNCTION(array_column)
}
ht = Z_ARRVAL_PP(data);
 
-   /* Skip if the value doesn't exist in our subarray */
-   if ((Z_TYPE_PP(zcolumn) == IS_STRING) 
+   if (!zcolumn) {
+   /* NULL column ID means use entire subarray as data */
+   zcolval = data;
+
+   /* Otherwise, skip if the value doesn't exist in our 
subarray */
+   } else if ((Z_TYPE_PP(zcolumn) == IS_STRING) 
(zend_hash_find(ht, Z_STRVAL_PP(zcolumn), 
Z_STRLEN_PP(zcolumn) + 1, (void**)zcolval) == FAILURE)) {
continue;
} else if ((Z_TYPE_PP(zcolumn) == IS_LONG) 
diff --git a/ext/standard/tests/array/array_column_variant.phpt 
b/ext/standard/tests/array/array_column_variant.phpt
new file mode 100644
index 000..0af0869
--- /dev/null
+++ b/ext/standard/tests/array/array_column_variant.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Test array_column() function: variant functionality
+--FILE--
+?php
+/* Array from Bug Request #64493 test script */
+$rows = array(
+  456 = array('id' = '3', 'title' = 'Foo', 'date' = '2013-03-25'),
+  457 = array('id' = '5', 'title' = 'Bar', 'date' = '2012-05-20'),
+);
+
+echo -- pass null as second parameter to get back all columns indexed by 
third parameter --\n;
+var_dump(array_column($rows, null, 'id'));
+
+echo -- pass null as second parameter and bogus third param to get back 
zero-indexed array of all columns --\n;
+var_dump(array_column($rows, null, 'foo'));
+
+echo -- pass null as second parameter and no third param to get back 
array_values(input) --\n;
+var_dump(array_column($rows, null));
+
+echo Done\n;
+--EXPECTF--
+-- pass null as second parameter to get back all columns indexed by third 
parameter --
+array(2) {
+  [3]=
+  array(3) {
+[id]=
+string(1) 3
+[title]=
+string(3) Foo
+[date]=
+string(10) 2013-03-25
+  }
+  [5]=
+  array(3) {
+[id]=
+string(1) 5
+[title]=
+string(3) Bar
+[date]=
+string(10) 2012-05-20
+  }
+}
+-- pass null as second parameter and bogus third param to get back 
zero-indexed array of all columns --
+array(2) {
+  [0]=
+  array(3) {
+[id]=
+string(1) 3
+[title]=
+string(3) Foo
+[date]=
+string(10) 2013-03-25
+  }
+  [1]=
+  array(3) {
+[id]=
+string(1) 5
+[title]=
+string(3) Bar
+[date]=
+string(10) 2012-05-20
+  }
+}
+-- pass null as second parameter and no third param to get back 
array_values(input) --
+array(2) {
+  [0]=
+  array(3) {
+[id]=
+string(1) 3
+[title]=
+string(3) Foo
+[date]=
+string(10) 2013-03-25
+  }
+  [1]=
+  array(3) {
+[id]=
+string(1) 5
+[title]=
+string(3) Bar
+[date]=
+string(10) 2012-05-20
+  }
+}
+Done


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