Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24186 invoked from network); 28 Jun 2008 11:27:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2008 11:27:05 -0000 Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.146.182 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: david.coallier@gmail.com X-Host-Fingerprint: 209.85.146.182 wa-out-1112.google.com Received: from [209.85.146.182] ([209.85.146.182:61460] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/2C-24558-70026684 for ; Sat, 28 Jun 2008 07:27:04 -0400 Received: by wa-out-1112.google.com with SMTP id v27so554774wah.17 for ; Sat, 28 Jun 2008 04:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=BKF+rbz2DHHTcHBEKuuXddO7FDa46Dpvgkp37LvKQFs=; b=RlTFqq7y2+0lQlF0thKDWYq0z034b8iqQjMQR4rpB66k+mnKAcc9WaAZ4/hLf4XsR0 nIoCPuD/+2tYITsaFZgqxjueTf20Bu0UtUOgnmf80deDKfkKN9FiFR/Xb3u2IxVU7Gi4 9qwRn9EBBZChJqBljxxLUZ9OC2LxJA6hvKF4s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=c8VIIDt21bhEStjd18iOuX6AWGRQrTuk2vFSDLUUwUCIOPAPZmiHiSyg8kUBQAqLVW E90eb+KzdX3PNyMFxiBgHHxshD8QfjBpznI5HrL8qpfosP9S262nmgSCq8wm/KwBa3w5 nsQYKjR0azUvoDmBEUPIvSZUnuZsqr20+4TyQ= Received: by 10.115.109.1 with SMTP id l1mr2422649wam.90.1214652421430; Sat, 28 Jun 2008 04:27:01 -0700 (PDT) Received: by 10.115.61.1 with HTTP; Sat, 28 Jun 2008 04:27:01 -0700 (PDT) Message-ID: Date: Sat, 28 Jun 2008 12:27:01 +0100 Sender: david.coallier@gmail.com To: "Jordan Wambaugh" Cc: "Stanislav Malyshev" , "PHP Internals" In-Reply-To: <043C48F1-00DF-4882-AB70-A368C5D32DA1@wambaugh.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <485AE658.3050204@zend.com> <043C48F1-00DF-4882-AB70-A368C5D32DA1@wambaugh.org> X-Google-Sender-Auth: b69287bf22448142 Subject: Re: [PHP-DEV] cleaning up the functions - any volunteers? From: davidc@php.net ("David Coallier") 2008/6/28 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; > > The idea of the new parsing parameter is to catch the number of parameters as well. For instance when you have if (ZEND_NUM_ARGS() < 2) { WRONG_PARAM_COUNT; } then your zend parse param function call should have 2 params or more Ex: int argc; char *name; zval **other; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sZ", &name, &other, &argc) == FAILURE) { return; } This way of parsing the parameters remove the ZEND_NUM_ARGS() and WRONG_PARAM_COUNT and adds consistency in the return error messages across the language. Also next time please read the previous entries of the thread : See: http://url.ie/hck that was about the 3rd or 4th message. Anyways that's ok, I lot of conflicts now in formatted_print.c and assert.c but I'll work around them to get the resolved. We just have to get organized on which files we'll be working on then. Right now, Olivier is working on file.c and has done string.c so please don't do those 2 files. -- Slan, David