felipe          Fri Jun 27 00:22:18 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/sysvshm        sysvshm.c 
    /php-src/ext/sysvshm/tests  001.phpt 002.phpt 003.phpt 004.phpt 
                                005.phpt 006.phpt 007.phpt 
  Log:
  - New parameter parsing API
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/sysvshm.c?r1=1.70.2.2.2.5.2.2&r2=1.70.2.2.2.5.2.3&diff_format=u
Index: php-src/ext/sysvshm/sysvshm.c
diff -u php-src/ext/sysvshm/sysvshm.c:1.70.2.2.2.5.2.2 
php-src/ext/sysvshm/sysvshm.c:1.70.2.2.2.5.2.3
--- php-src/ext/sysvshm/sysvshm.c:1.70.2.2.2.5.2.2      Mon Dec 31 07:17:16 2007
+++ php-src/ext/sysvshm/sysvshm.c       Fri Jun 27 00:22:18 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: sysvshm.c,v 1.70.2.2.2.5.2.2 2007/12/31 07:17:16 sebastian Exp $ */
+/* $Id: sysvshm.c,v 1.70.2.2.2.5.2.3 2008/06/27 00:22:18 felipe Exp $ */
 
 /* This has been built and tested on Linux 2.2.14 
  *
@@ -107,7 +107,7 @@
    Creates or open a shared memory segment */
 PHP_FUNCTION(shm_attach)
 {
-       zval **arg_key, **arg_size, **arg_flag;
+       long arg_key, arg_size, arg_flag;
        long shm_size, shm_flag;
        sysvshm_shm *shm_list_ptr;
        char *shm_ptr;
@@ -118,21 +118,18 @@
 
        shm_flag = 0666;
        shm_size = php_sysvshm.init_mem;
-       
-       if (ac < 1 || ac > 3 || zend_get_parameters_ex(ac, &arg_key, &arg_size, 
&arg_flag) == FAILURE) {
-               WRONG_PARAM_COUNT;
+
+       if (zend_parse_parameters(ac TSRMLS_CC, "l|ll", &arg_key, &arg_size, 
&arg_flag) == FAILURE) {
+               return;
        }
+       
+       shm_key = arg_key;
 
-       switch (ac) {
-               case 3:
-                       convert_to_long_ex(arg_flag);
-                       shm_flag = Z_LVAL_PP(arg_flag);
-               case 2:
-                       convert_to_long_ex(arg_size);
-                       shm_size= Z_LVAL_PP(arg_size);
-               case 1:
-                       convert_to_long_ex(arg_key);
-                       shm_key = Z_LVAL_PP(arg_key);
+       if (ac > 1) {
+               shm_size = arg_size;
+               if (ac > 2) {
+                       shm_flag = arg_flag;
+               }
        }
 
        if (shm_size < 1) {
@@ -184,22 +181,21 @@
    Disconnects from shared memory segment */
 PHP_FUNCTION(shm_detach)
 {
-       zval **arg_id;
+       long arg_id;
        int type;
        sysvshm_shm *shm_list_ptr;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_id) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg_id) == 
FAILURE) {
+               return;
        }
 
-       convert_to_long_ex(arg_id);
-       shm_list_ptr = (sysvshm_shm *) zend_list_find(Z_LVAL_PP(arg_id), &type);
+       shm_list_ptr = (sysvshm_shm *) zend_list_find(arg_id, &type);
        if (!shm_list_ptr || type != php_sysvshm.le_shm) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The parameter is 
not a valid shm_identifier");
                RETURN_FALSE;
        }
 
-       zend_list_delete(Z_LVAL_PP(arg_id));
+       zend_list_delete(arg_id);
 
        RETURN_TRUE;
 }
@@ -209,17 +205,16 @@
    Removes shared memory from Unix systems */
 PHP_FUNCTION(shm_remove)
 {
-       zval **arg_id;
+       long arg_id;
        long id;
        int type;
        sysvshm_shm *shm_list_ptr;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_id) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg_id) == 
FAILURE) {
+               return;
        }
 
-       convert_to_long_ex(arg_id);
-       id = Z_LVAL_PP(arg_id);
+       id = arg_id;
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
 
        if (!shm_list_ptr || type != php_sysvshm.le_shm) {
@@ -240,7 +235,8 @@
    Inserts or updates a variable in shared memory */
 PHP_FUNCTION(shm_put_var)
 {
-       zval **arg_id, **arg_key, **arg_var;
+       long arg_id, arg_key;
+       zval **arg_var;
        long key, id;
        sysvshm_shm *shm_list_ptr;
        int type;
@@ -248,14 +244,12 @@
        int ret;        
        php_serialize_data_t var_hash;
 
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg_id, 
&arg_key, &arg_var) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llZ", &arg_id, 
&arg_key, &arg_var) == FAILURE) {
+               return;
        }
-                       
-       convert_to_long_ex(arg_id);
-       id = Z_LVAL_PP(arg_id);
-       convert_to_long_ex(arg_key);
-       key = Z_LVAL_PP(arg_key);
+
+       id = arg_id;
+       key = arg_key;
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
        if (!shm_list_ptr || type != php_sysvshm.le_shm) {
@@ -286,7 +280,7 @@
    Returns a variable from shared memory */
 PHP_FUNCTION(shm_get_var)
 {
-       zval **arg_id, **arg_key;
+       long arg_id, arg_key;
        long key, id;
        sysvshm_shm *shm_list_ptr;
        int type;
@@ -294,15 +288,13 @@
        long shm_varpos;
        sysvshm_chunk *shm_var;
        php_unserialize_data_t var_hash;
-       
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg_id, 
&arg_key) == FAILURE) {
-               WRONG_PARAM_COUNT;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &arg_id, 
&arg_key) == FAILURE) {
+               return;
        }
 
-       convert_to_long_ex(arg_id);
-       id = Z_LVAL_PP(arg_id);
-       convert_to_long_ex(arg_key);
-       key = Z_LVAL_PP(arg_key);
+       id = arg_id;
+       key = arg_key;
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
        if (!shm_list_ptr || type != php_sysvshm.le_shm) {
@@ -335,20 +327,18 @@
    Removes variable from shared memory */
 PHP_FUNCTION(shm_remove_var)
 {
-       zval **arg_id, **arg_key;
+       long arg_id, arg_key;
        long key, id;
        sysvshm_shm *shm_list_ptr;
        int type;
        long shm_varpos;
-       
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg_id, 
&arg_key) == FAILURE) {
-               WRONG_PARAM_COUNT;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &arg_id, 
&arg_key) == FAILURE) {
+               return;
        }
 
-       convert_to_long_ex(arg_id);
-       id = Z_LVAL_PP(arg_id);
-       convert_to_long_ex(arg_key);
-       key = Z_LVAL_PP(arg_key);
+       id = arg_id;
+       key = arg_key;
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
        if (!shm_list_ptr || type != php_sysvshm.le_shm) {
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/001.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/001.phpt
diff -u php-src/ext/sysvshm/tests/001.phpt:1.1.2.2 
php-src/ext/sysvshm/tests/001.phpt:1.1.2.2.2.1
--- php-src/ext/sysvshm/tests/001.phpt:1.1.2.2  Thu Jun 29 09:00:33 2006
+++ php-src/ext/sysvshm/tests/001.phpt  Fri Jun 27 00:22:18 2008
@@ -18,13 +18,13 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for ftok() in %s on line %d
+Warning: ftok() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for ftok() in %s on line %d
+Warning: ftok() expects exactly 2 parameters, 1 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for ftok() in %s on line %d
+Warning: ftok() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
 Warning: ftok(): Pathname is invalid in %s on line %d
@@ -38,5 +38,5 @@
 
 Warning: ftok(): ftok() failed - No such file or directory in %s on line %d
 int(-1)
-int(%d)
+int(1895944710)
 Done
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/002.phpt?r1=1.1.2.3&r2=1.1.2.3.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/002.phpt
diff -u php-src/ext/sysvshm/tests/002.phpt:1.1.2.3 
php-src/ext/sysvshm/tests/002.phpt:1.1.2.3.2.1
--- php-src/ext/sysvshm/tests/002.phpt:1.1.2.3  Sat Feb 24 15:44:43 2007
+++ php-src/ext/sysvshm/tests/002.phpt  Fri Jun 27 00:22:18 2008
@@ -33,35 +33,35 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_attach() in %s/sysvshm/tests/002.php on 
line %d
+Warning: shm_attach() expects at least 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for shm_attach() in %s/sysvshm/tests/002.php on 
line %d
+Warning: shm_attach() expects at most 3 parameters, 4 given in %s on line %d
 NULL
 
-Warning: shm_attach(): Segment size must be greater then zero. in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s on line %d
 bool(false)
 
-Warning: shm_attach(): Segment size must be greater then zero. in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s on line %d
 bool(false)
 
-Warning: shm_attach(): Segment size must be greater then zero. in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s on line %d
 bool(false)
 
-Warning: shm_attach(): Segment size must be greater then zero. in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s on line %d
 bool(false)
 
-Warning: shm_remove(): The parameter is not a valid shm_identifier in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
 
-Warning: shm_attach(): Segment size must be greater then zero. in 
%s/sysvshm/tests/002.php on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s on line %d
 bool(false)
 
-Warning: shm_remove(): The parameter is not a valid shm_identifier in 
%s/sysvshm/tests/002.php on line %d
-int(%d)
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
+int(4)
 
-Warning: shm_remove(): The parameter is not a valid shm_identifier in 
%s/sysvshm/tests/002.php on line %d
-int(%d)
-int(%d)
-int(%d)
-int(%d)
-Done
\ No newline at end of file
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
+int(5)
+int(6)
+int(7)
+int(8)
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/003.phpt?r1=1.1.2.3&r2=1.1.2.3.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/003.phpt
diff -u php-src/ext/sysvshm/tests/003.phpt:1.1.2.3 
php-src/ext/sysvshm/tests/003.phpt:1.1.2.3.2.1
--- php-src/ext/sysvshm/tests/003.phpt:1.1.2.3  Mon Jun 25 17:37:55 2007
+++ php-src/ext/sysvshm/tests/003.phpt  Fri Jun 27 00:22:18 2008
@@ -31,10 +31,10 @@
 
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_detach() in %s on line %d
+Warning: shm_detach() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for shm_detach() in %s on line %d
+Warning: shm_detach() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 bool(true)
 
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/004.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/004.phpt
diff -u php-src/ext/sysvshm/tests/004.phpt:1.1.2.2 
php-src/ext/sysvshm/tests/004.phpt:1.1.2.2.2.1
--- php-src/ext/sysvshm/tests/004.phpt:1.1.2.2  Thu Jun 29 09:00:33 2006
+++ php-src/ext/sysvshm/tests/004.phpt  Fri Jun 27 00:22:18 2008
@@ -23,7 +23,7 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_put_var() in %s on line %d
+Warning: shm_put_var() expects exactly 3 parameters, 0 given in %s on line %d
 NULL
 
 Warning: shm_put_var(): -1 is not a SysV shared memory index in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/005.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/005.phpt
diff -u php-src/ext/sysvshm/tests/005.phpt:1.1.2.2 
php-src/ext/sysvshm/tests/005.phpt:1.1.2.2.2.1
--- php-src/ext/sysvshm/tests/005.phpt:1.1.2.2  Thu Jun 29 09:00:33 2006
+++ php-src/ext/sysvshm/tests/005.phpt  Fri Jun 27 00:22:18 2008
@@ -38,7 +38,7 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_get_var() in %s on line %d
+Warning: shm_get_var() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
 Warning: shm_get_var(): -1 is not a SysV shared memory index in %s on line %d
@@ -49,10 +49,11 @@
 
 Warning: shm_get_var(): variable key -10000 doesn't exist in %s on line %d
 bool(false)
-object(stdClass)#%d (0) {
-}
+
+Warning: shm_get_var() expects parameter 2 to be long, array given in %s on 
line %d
+NULL
 string(11) "test string"
-object(stdClass)#%d (0) {
+object(stdClass)#1 (0) {
 }
 array(3) {
   [0]=>
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/006.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/006.phpt
diff -u php-src/ext/sysvshm/tests/006.phpt:1.1.2.2 
php-src/ext/sysvshm/tests/006.phpt:1.1.2.2.2.1
--- php-src/ext/sysvshm/tests/006.phpt:1.1.2.2  Thu Jun 29 09:00:33 2006
+++ php-src/ext/sysvshm/tests/006.phpt  Fri Jun 27 00:22:18 2008
@@ -26,7 +26,7 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_remove_var() in %s on line %d
+Warning: shm_remove_var() expects exactly 2 parameters, 0 given in %s on line 
%d
 NULL
 
 Warning: shm_remove_var(): -1 is not a SysV shared memory index in %s on line 
%d
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvshm/tests/007.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvshm/tests/007.phpt
diff -u php-src/ext/sysvshm/tests/007.phpt:1.1.2.2 
php-src/ext/sysvshm/tests/007.phpt:1.1.2.2.2.1
--- php-src/ext/sysvshm/tests/007.phpt:1.1.2.2  Thu Jun 29 09:00:33 2006
+++ php-src/ext/sysvshm/tests/007.phpt  Fri Jun 27 00:22:18 2008
@@ -22,7 +22,7 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for shm_remove() in %s on line %d
+Warning: shm_remove() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
@@ -31,8 +31,8 @@
 Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
 bool(false)
 
-Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on 
line %d
-bool(false)
+Warning: shm_remove() expects parameter 1 to be long, string given in %s on 
line %d
+NULL
 bool(true)
 bool(true)
 

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

Reply via email to