Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38665 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86107 invoked from network); 28 Jun 2008 03:41:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2008 03:41:36 -0000 Authentication-Results: pb1.pair.com header.from=jordan@wambaugh.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jordan@wambaugh.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain wambaugh.org from 74.125.46.28 cause and error) X-PHP-List-Original-Sender: jordan@wambaugh.org X-Host-Fingerprint: 74.125.46.28 yw-out-2324.google.com Received: from [74.125.46.28] ([74.125.46.28:20136] helo=yw-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/57-24558-0F2B5684 for ; Fri, 27 Jun 2008 23:41:36 -0400 Received: by yw-out-2324.google.com with SMTP id 5so327700ywb.83 for ; Fri, 27 Jun 2008 20:41:33 -0700 (PDT) Received: by 10.150.198.18 with SMTP id v18mr3505543ybf.76.1214624493508; Fri, 27 Jun 2008 20:41:33 -0700 (PDT) Received: from ?192.168.1.6? ( [70.161.167.72]) by mx.google.com with ESMTPS id 33sm681422yxr.3.2008.06.27.20.41.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 27 Jun 2008 20:41:33 -0700 (PDT) Cc: 'PHP Internals' Message-ID: <043C48F1-00DF-4882-AB70-A368C5D32DA1@wambaugh.org> To: Stanislav Malyshev In-Reply-To: <485AE658.3050204@zend.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v924) Date: Fri, 27 Jun 2008 23:41:11 -0400 References: <485AE658.3050204@zend.com> X-Mailer: Apple Mail (2.924) Subject: Re: [PHP-DEV] cleaning up the functions - any volunteers? From: jordan@wambaugh.org (Jordan Wambaugh) 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 jordan@wambaugh.org 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;