On Wed, 2002-10-09 at 22:21, Thies C. Arntzen wrote:
> On Wed, Oct 09, 2002 at 06:29:45PM -0000, Sterling Hughes wrote:
> > sterling            Wed Oct  9 14:29:45 2002 EDT
> > 
> >   Modified files:              
> >     /php4/ext/standard      array.c 
> >   Log:
> >   clean these functions up using zend_parse_parameters and nuke the use of 
> >   HASH_OF() which is inappropriate in these cases...
> 
>     will prev still work on objects after your patch?
> 

none of them do - none of them should either - why would you want to
access an object like you would an _indexed_ array?

-Sterling

>     re,
>     tc
> >   
> >   
> > Index: php4/ext/standard/array.c
> > diff -u php4/ext/standard/array.c:1.195 php4/ext/standard/array.c:1.196
> > --- php4/ext/standard/array.c:1.195 Wed Oct  9 13:15:56 2002
> > +++ php4/ext/standard/array.c       Wed Oct  9 14:29:45 2002
> > @@ -21,7 +21,7 @@
> >     +----------------------------------------------------------------------+
> >  */
> >  
> > -/* $Id: array.c,v 1.195 2002/10/09 17:15:56 sterling Exp $ */
> > +/* $Id: array.c,v 1.196 2002/10/09 18:29:45 sterling Exp $ */
> >  
> >  #include "php.h"
> >  #include "php_ini.h"
> > @@ -705,21 +705,16 @@
> >     Move array argument's internal pointer to the previous element and return it */
> >  PHP_FUNCTION(prev)
> >  {
> > -   pval **array, **entry;
> > -   HashTable *target_hash;
> > +   zval **entry;
> > +   zval  *array;
> >  
> > -   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
> > -           WRONG_PARAM_COUNT;
> > -   }
> > -   target_hash = HASH_OF(*array);
> > -   if (!target_hash) {
> > -           php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
>array or object");
> > +   if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
> >             RETURN_FALSE;
> >     }
> > -   zend_hash_move_backwards(target_hash);
> > +   zend_hash_move_backwards(Z_ARRVAL_P(array));
> >  
> >     if (return_value_used) {        
> > -           if (zend_hash_get_current_data(target_hash, (void **) &entry) == 
>FAILURE) {
> > +           if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &entry) == 
>FAILURE) {
> >                     RETURN_FALSE;
> >             }
> >     
> > @@ -733,21 +728,16 @@
> >     Move array argument's internal pointer to the next element and return it */
> >  PHP_FUNCTION(next)
> >  {
> > -   pval **array, **entry;
> > -   HashTable *target_hash;
> > +   zval **entry;
> > +   zval  *array;
> >  
> > -   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
> > -           WRONG_PARAM_COUNT;
> > -   }
> > -   target_hash = HASH_OF(*array);
> > -   if (!target_hash) {
> > -           php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
>array or object");
> > +   if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
> >             RETURN_FALSE;
> >     }
> > -   zend_hash_move_forward(target_hash);
> > +   zend_hash_move_forward(Z_ARRVAL_P(array));
> >  
> >     if (return_value_used) {
> > -           if (zend_hash_get_current_data(target_hash, (void **) &entry) == 
>FAILURE) {
> > +           if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &entry) == 
>FAILURE) {
> >                     RETURN_FALSE;
> >             }
> >       
> > @@ -761,21 +751,16 @@
> >     Set array argument's internal pointer to the first element and return it */    
> 
> >  PHP_FUNCTION(reset)
> >  {
> > -   pval **array, **entry;
> > -   HashTable *target_hash;
> > +   zval **entry;
> > +   zval  *array;
> >  
> > -   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
> > -           WRONG_PARAM_COUNT;
> > -   }
> > -   target_hash = HASH_OF(*array);
> > -   if (!target_hash) {
> > -           php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
>array or object");
> > +   if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
> >             RETURN_FALSE;
> >     }
> > -   zend_hash_internal_pointer_reset(target_hash);
> > +   zend_hash_internal_pointer_reset(Z_ARRVAL_P(array));
> >  
> >     if (return_value_used) {        
> > -           if (zend_hash_get_current_data(target_hash, (void **) &entry) == 
>FAILURE) {
> > +           if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &entry) == 
>FAILURE) {
> >                     RETURN_FALSE;
> >             }
> >  
> > @@ -789,20 +774,17 @@
> >     Return the element currently pointed to by the internal array pointer */
> >  PHP_FUNCTION(current)
> >  {
> > -   pval **array, **entry;
> > -   HashTable *target_hash;
> > +   zval **entry;
> > +   zval  *array;
> >  
> > -   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
> > -           WRONG_PARAM_COUNT;
> > -   }
> > -   target_hash = HASH_OF(*array);
> > -   if (!target_hash) {
> > -           php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
>array or object");
> > +   if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
> >             RETURN_FALSE;
> >     }
> > -   if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
> > +
> > +   if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &entry) == 
>FAILURE) {
> >             RETURN_FALSE;
> >     }
> > +
> >     *return_value = **entry;
> >     zval_copy_ctor(return_value);
> >  }
> > @@ -812,29 +794,27 @@
> >     Return the key of the element currently pointed to by the internal array 
>pointer */
> >  PHP_FUNCTION(key)
> >  {
> > -   pval **array;
> > -   char *string_key;
> > -   uint string_length;
> > -   ulong num_key;
> > -   HashTable *target_hash;
> > +   zval  *array;
> > +   char  *string_key;
> > +   uint   string_key_length;
> > +   ulong  num_key = -1;
> >  
> > -   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
> > -           WRONG_PARAM_COUNT;
> > -   }
> > -   target_hash = HASH_OF(*array);
> > -   if (!target_hash) {
> > -           php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
>array or object");
> > +   if (zend_parse_parameters(1 TSRMLS_CC, "a", &array) == FAILURE) {
> >             RETURN_FALSE;
> >     }
> > -   switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, 
>&num_key, 0, NULL)) {
> > +
> > +   switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(array),
> > +                                                                            
>&string_key,
> > +                                                                            
>&string_key_length,
> > +                                                                            
>&num_key,
> > +                                                                            0,
> > +                                                                            
>NULL)) {
> >             case HASH_KEY_IS_STRING:
> > -                   RETVAL_STRINGL(string_key, string_length - 1, 1);
> > -                   break;
> > +                   RETURN_STRINGL(string_key, string_key_length - 1, 1);
> >             case HASH_KEY_IS_LONG:
> > -                   RETVAL_LONG(num_key);
> > -                   break;
> > -           case HASH_KEY_NON_EXISTANT:
> > -                   return;
> > +                   RETURN_LONG(num_key);
> > +           default:
> > +                   RETURN_NULL();
> >     }
> >  }
> >  /* }}} */
> > 
> > 
> > 
> > -- 
> > PHP CVS Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> Thies C. Arntzen   -   Looking for all sorts of freelance work  -   just ask..
>     Whishlist:  http://www.amazon.de/exec/obidos/wishlist/AB9DY62QWDSZ


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

Reply via email to