On Jun 19, 2008, at 7:06 PM, Stanislav Malyshev wrote:

I have cleaned up Zend engine functions, converting them to the new API, but there are about 1000 instances throughout PHP code (especially ext/standard) which still use the old way. This way is less correct, inconsistent with the new code, gives worse error messages, more prone to various bugs, etc. All new extensions and functions use the new way, and the only reason for keeping the old way in the code seems to be that nobody cleaned it up. Somebody has to bring the old ones into sync, and I don't think I personally will have time to do it in near timeframe. So if anybody could step up to that - by doing at least part of the work - that'd be great. The work is pretty simple, taking something like:



I went ahead and took care of standard/assert.c and standard/ formatted_print.c for 5.3 as well. All tests are passing.

Cheers!

--
Jordan CM Wambaugh
[EMAIL PROTECTED]




Index: assert.c
===================================================================
RCS file: /repository/php-src/ext/standard/assert.c,v
retrieving revision 1.60.2.3.2.6.2.2
diff -u -r1.60.2.3.2.6.2.2 assert.c
--- assert.c    31 Dec 2007 07:17:14 -0000      1.60.2.3.2.6.2.2
+++ assert.c    28 Jun 2008 03:39:28 -0000
@@ -139,7 +139,7 @@
    Checks if assertion is false */
 PHP_FUNCTION(assert)
 {
-       zval **assertion;
+       zval *assertion;
        int val;
        char *myeval = NULL;
        char *compiled_string_description;
@@ -148,15 +148,15 @@
                RETURN_TRUE;
        }

- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &assertion) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(1 TSRMLS_CC, "z", &assertion) == FAILURE) {
                WRONG_PARAM_COUNT;
        }

-       if (Z_TYPE_PP(assertion) == IS_STRING) {
+       if (Z_TYPE_PP(&assertion) == IS_STRING) {
                zval retval;
                int old_error_reporting = 0; /* shut up gcc! */

-               myeval = Z_STRVAL_PP(assertion);
+               myeval = Z_STRVAL_PP(&assertion);

                if (ASSERTG(quiet_eval)) {
                        old_error_reporting = EG(error_reporting);
@@ -181,8 +181,8 @@
                convert_to_boolean(&retval);
                val = Z_LVAL(retval);
        } else {
-               convert_to_boolean_ex(assertion);
-               val = Z_LVAL_PP(assertion);
+               convert_to_boolean_ex(&assertion);
+               val = Z_LVAL_PP(&assertion);
        }

        if (val) {
@@ -235,26 +235,25 @@
 }
 /* }}} */

-/* {{{ proto mixed assert_options(int what [, mixed value])
+/* {{{ proto mixed assert_options(int what[, mixed value])
    Set/get the various assert flags */
 PHP_FUNCTION(assert_options)
 {
-       zval **what, **value;
-       int oldint;
+       zval *value=0;
+       int oldint, what;
        int ac = ZEND_NUM_ARGS();

- if (ac < 1 || ac > 2 || zend_get_parameters_ex(ac, &what, &value) == FAILURE) { + if (ac <1 || ac > 2 || zend_parse_parameters(ac TSRMLS_CC, "i|z", &what, &value) == FAILURE) {
                WRONG_PARAM_COUNT;
        }

-       convert_to_long_ex(what);

-       switch (Z_LVAL_PP(what)) {
+       switch (what) {
        case ASSERT_ACTIVE:
                oldint = ASSERTG(active);
                if (ac == 2) {
-                       convert_to_long_ex(value);
-                       ASSERTG(active) = Z_LVAL_PP(value);
+                       convert_to_long_ex(&value);
+                       ASSERTG(active) = Z_LVAL_PP(&value);
                }
                RETURN_LONG(oldint);
                break;
@@ -262,8 +261,8 @@
        case ASSERT_BAIL:
                oldint = ASSERTG(bail);
                if (ac == 2) {
-                       convert_to_long_ex(value);
-                       ASSERTG(bail) = Z_LVAL_PP(value);
+                       convert_to_long_ex(&value);
+                       ASSERTG(bail) = Z_LVAL_PP(&value);
                }
                RETURN_LONG(oldint);
                break;
@@ -271,8 +270,8 @@
        case ASSERT_QUIET_EVAL:
                oldint = ASSERTG(quiet_eval);
                if (ac == 2) {
-                       convert_to_long_ex(value);
-                       ASSERTG(quiet_eval) = Z_LVAL_PP(value);
+                       convert_to_long_ex(&value);
+                       ASSERTG(quiet_eval) = Z_LVAL_PP(&value);
                }
                RETURN_LONG(oldint);
                break;
@@ -280,8 +279,8 @@
        case ASSERT_WARNING:
                oldint = ASSERTG(warning);
                if (ac == 2) {
-                       convert_to_long_ex(value);
-                       ASSERTG(warning) = Z_LVAL_PP(value);
+                       convert_to_long_ex(&value);
+                       ASSERTG(warning) = Z_LVAL_PP(&value);
                }
                RETURN_LONG(oldint);
                break;
@@ -298,14 +297,14 @@
                        if (ASSERTG(callback)) {
                                zval_ptr_dtor(&ASSERTG(callback));
                        }
-                       ASSERTG(callback) = *value;
-                       zval_add_ref(value);
+                       ASSERTG(callback) = value;
+                       zval_add_ref(&value);
                }
                return;
                break;

        default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown value %ld", Z_LVAL_PP(what)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown value %ld", what);
                break;
        }


Index: formatted_print.c
===================================================================
RCS file: /repository/php-src/ext/standard/formatted_print.c,v
retrieving revision 1.82.2.1.2.16.2.6
diff -u -r1.82.2.1.2.16.2.6 formatted_print.c
--- formatted_print.c   25 Jun 2008 10:16:52 -0000      1.82.2.1.2.16.2.6
+++ formatted_print.c   28 Jun 2008 03:34:12 -0000
@@ -731,19 +731,19 @@
 PHP_FUNCTION(fprintf)
 {
        php_stream *stream;
-       zval **arg1;
+       zval *arg1;
        char *result;
        int len;
        
        if (ZEND_NUM_ARGS() < 2) {
                WRONG_PARAM_COUNT;
        }
-       
-       if (zend_get_parameters_ex(1, &arg1)==FAILURE) {
+
+       if (zend_parse_parameters(1 TSRMLS_CC, "z", &arg1) ==FAILURE){    
                RETURN_FALSE;
        }
        
-       php_stream_from_zval(stream, arg1);
+       php_stream_from_zval(stream, &arg1);

        if ((result=php_formatted_print(ht, &len, 0, 1 TSRMLS_CC))==NULL) {
                RETURN_FALSE;
@@ -762,19 +762,20 @@
 PHP_FUNCTION(vfprintf)
 {
        php_stream *stream;
-       zval **arg1;
+       zval *arg1;
        char *result;
        int len;
        
        if (ZEND_NUM_ARGS() != 3) {
                WRONG_PARAM_COUNT;
        }
-       
-       if (zend_get_parameters_ex(1, &arg1)==FAILURE) {
+
+       if (zend_parse_parameters(1 TSRMLS_CC, "z", &arg1) ==FAILURE){    
                RETURN_FALSE;
        }
+
        
-       php_stream_from_zval(stream, arg1);
+       php_stream_from_zval(stream, &arg1);

        if ((result=php_formatted_print(ht, &len, 1, 1 TSRMLS_CC))==NULL) {
                RETURN_FALSE;


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to