[PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c /ext/standard/tests/assert assert04.phpt assert_error1.phpt

2008-07-23 Thread Felipe Pena
felipe  Wed Jul 23 19:33:58 2008 UTC

  Modified files:  
/php-src/ext/standard   assert.c basic_functions.c 
/php-src/ext/standard/tests/assert  assert04.phpt assert_error1.phpt 
  Log:
  - New parameter parsing API
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.76r2=1.77diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.76 php-src/ext/standard/assert.c:1.77
--- php-src/ext/standard/assert.c:1.76  Mon Dec 31 07:12:15 2007
+++ php-src/ext/standard/assert.c   Wed Jul 23 19:33:58 2008
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: assert.c,v 1.76 2007/12/31 07:12:15 sebastian Exp $ */
+/* $Id: assert.c,v 1.77 2008/07/23 19:33:58 felipe Exp $ */
 
 /* {{{ includes */
 #include php.h
@@ -149,8 +149,8 @@
RETURN_TRUE;
}
 
-   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, assertion) == 
FAILURE) {
-   WRONG_PARAM_COUNT;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z, assertion) 
== FAILURE) {
+   return;
}
 
if (Z_TYPE_PP(assertion) == IS_STRING || Z_TYPE_PP(assertion) == 
IS_UNICODE) {
@@ -262,17 +262,16 @@
Set/get the various assert flags */
 PHP_FUNCTION(assert_options)
 {
-   zval **what, **value;
+   zval **value;
+   long what;
int oldint;
int ac = ZEND_NUM_ARGS();
 
-   if (ac  1 || ac  2 || zend_get_parameters_ex(ac, what, value) == 
FAILURE) {
-   WRONG_PARAM_COUNT;
+   if (zend_parse_parameters(ac TSRMLS_CC, l|Z, what, value) == 
FAILURE) {
+   return;
}
 
-   convert_to_long_ex(what);
-
-   switch (Z_LVAL_PP(what)) {
+   switch (what) {
case ASSERT_ACTIVE:
oldint = ASSERTG(active);
if (ac == 2) {
@@ -328,7 +327,7 @@
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;
}
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.905r2=1.906diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.905 
php-src/ext/standard/basic_functions.c:1.906
--- php-src/ext/standard/basic_functions.c:1.905Mon Jul 21 11:27:45 2008
+++ php-src/ext/standard/basic_functions.c  Wed Jul 23 19:33:58 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.905 2008/07/21 11:27:45 jani Exp $ */
+/* $Id: basic_functions.c,v 1.906 2008/07/23 19:33:58 felipe Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -4928,65 +4928,17 @@
Send an error message somewhere */
 PHP_FUNCTION(error_log)
 {
-   zval **string, **erropt = NULL, **option = NULL, **emailhead = NULL;
-   int opt_err = 0;
char *message, *opt = NULL, *headers = NULL;
+   int message_len, opt_len, headers_len;
+   int opt_err = 0, argc = ZEND_NUM_ARGS();
+   long erropt;
 
-   switch (ZEND_NUM_ARGS()) {
-   case 1:
-   if (zend_get_parameters_ex(1, string) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Argument 1 invalid);
-   RETURN_FALSE;
-   }
-   break;
-
-   case 2:
-   if (zend_get_parameters_ex(2, string, erropt) == 
FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Invalid arguments);
-   RETURN_FALSE;
-   }
-   convert_to_long_ex(erropt);
-   opt_err = Z_LVAL_PP(erropt);
-   break;
-
-   case 3:
-   if (zend_get_parameters_ex(3, string, erropt, 
option) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Invalid arguments);
-   RETURN_FALSE;
-   }
-   convert_to_long_ex(erropt);
-   opt_err = Z_LVAL_PP(erropt);
-   convert_to_string_ex(option);
-   opt = Z_STRVAL_PP(option);
-   break;
-
-   case 4:
-   if (zend_get_parameters_ex (4, string, erropt, 
option, emailhead) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Invalid arguments);
-   RETURN_FALSE;
-   }
-   break;
-
-   default:
-   WRONG_PARAM_COUNT;
-   }
-
-   convert_to_string_ex(string);
-   message = 

[PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Dmitry Stogov
dmitry  Fri Feb 16 13:12:55 2007 UTC

  Modified files:  
/php-src/ext/standard   assert.c basic_functions.c 
  Log:
  Fixed return value of assert_options(ASSERT_CALLBACK) and possible crash 
(Andy Wharmby)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.71r2=1.72diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/assert.c:1.72
--- php-src/ext/standard/assert.c:1.71  Mon Jan  1 09:29:30 2007
+++ php-src/ext/standard/assert.c   Fri Feb 16 13:12:55 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
+/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */
 
 /* {{{ includes/startup/misc */
 
@@ -114,6 +114,16 @@
return SUCCESS;
 }
 
+PHP_RINIT_FUNCTION(assert)
+{
+   if (ASSERTG(cb)) {
+   MAKE_STD_ZVAL(ASSERTG(callback));
+   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
+   }
+
+   return SUCCESS;
+}
+
 PHP_RSHUTDOWN_FUNCTION(assert)
 {
if (ASSERTG(callback)) { 
@@ -202,11 +212,6 @@
RETURN_TRUE;
}
 
-   if (!ASSERTG(callback)  ASSERTG(cb)) {
-   MAKE_STD_ZVAL(ASSERTG(callback));
-   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
-   }
-
if (ASSERTG(callback)) {
zval *args[3];
zval *retval;
@@ -309,6 +314,11 @@
break;
 
case ASSERT_CALLBACK:
+   if (ASSERTG(callback) != NULL) {
+   RETVAL_ZVAL(ASSERTG(callback), 1, 0);
+   } else {
+   RETVAL_NULL();
+   }
if (ac == 2) {
if (ASSERTG(callback)) {
zval_ptr_dtor(ASSERTG(callback));
@@ -316,7 +326,7 @@
ASSERTG(callback) = *value;
zval_add_ref(value);
}
-   RETURN_TRUE;
+   return;
break;
 
default:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.846r2=1.847diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.846 
php-src/ext/standard/basic_functions.c:1.847
--- php-src/ext/standard/basic_functions.c:1.846Thu Feb  8 15:31:01 2007
+++ php-src/ext/standard/basic_functions.c  Fri Feb 16 13:12:55 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01 helly Exp $ */
+/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 dmitry Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -4147,6 +4147,7 @@
 #ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
+   PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Ilia Alshanetsky

Dmitry,

Please revert this patch. The code adds RINIT that hits every request  
for functionality that is only needed for testing of the code and is  
otherwise rarely used. I do not believe it warrants slowing down  
every single request, even by a little bit.



On 16-Feb-07, at 8:12 AM, Dmitry Stogov wrote:


dmitry  Fri Feb 16 13:12:55 2007 UTC

  Modified files:
/php-src/ext/standard   assert.c basic_functions.c
  Log:
  Fixed return value of assert_options(ASSERT_CALLBACK) and  
possible crash (Andy Wharmby)



http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c? 
r1=1.71r2=1.72diff_format=u

Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/ 
assert.c:1.72

--- php-src/ext/standard/assert.c:1.71  Mon Jan  1 09:29:30 2007
+++ php-src/ext/standard/assert.c   Fri Feb 16 13:12:55 2007
@@ -16,7 +16,7 @@
 
+- 
-+

  */

-/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
+/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */

 /* {{{ includes/startup/misc */

@@ -114,6 +114,16 @@
return SUCCESS;
 }

+PHP_RINIT_FUNCTION(assert)
+{
+   if (ASSERTG(cb)) {
+   MAKE_STD_ZVAL(ASSERTG(callback));
+   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
+   }
+
+   return SUCCESS;
+}
+
 PHP_RSHUTDOWN_FUNCTION(assert)
 {
if (ASSERTG(callback)) {
@@ -202,11 +212,6 @@
RETURN_TRUE;
}

-   if (!ASSERTG(callback)  ASSERTG(cb)) {
-   MAKE_STD_ZVAL(ASSERTG(callback));
-   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
-   }
-
if (ASSERTG(callback)) {
zval *args[3];
zval *retval;
@@ -309,6 +314,11 @@
break;

case ASSERT_CALLBACK:
+   if (ASSERTG(callback) != NULL) {
+   RETVAL_ZVAL(ASSERTG(callback), 1, 0);
+   } else {
+   RETVAL_NULL();
+   }
if (ac == 2) {
if (ASSERTG(callback)) {
zval_ptr_dtor(ASSERTG(callback));
@@ -316,7 +326,7 @@
ASSERTG(callback) = *value;
zval_add_ref(value);
}
-   RETURN_TRUE;
+   return;
break;

default:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ 
basic_functions.c?r1=1.846r2=1.847diff_format=u

Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.846 php-src/ext/ 
standard/basic_functions.c:1.847
--- php-src/ext/standard/basic_functions.c:1.846	Thu Feb  8  
15:31:01 2007

+++ php-src/ext/standard/basic_functions.c  Fri Feb 16 13:12:55 2007
@@ -17,7 +17,7 @@
 
+- 
-+

  */

-/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01 helly Exp $ */
+/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 dmitry Exp $ */

 #include php.h
 #include php_streams.h
@@ -4147,6 +4147,7 @@
 #ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
+   PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);


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



Ilia Alshanetsky

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



Re: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Steph Fox

Ilia, hi,

There's no way to query the current callback setting there. If RINIT's the 
only way to achieve it, and we can't have RINIT, the manual needs fixing to 
reflect reality.


So - are you officially calling it a 'won't fix'?

Or is there a less intrusive fix in the wings? (Read: I've no idea whether 
promoting OnChangeCallback to ZEND_INI_MH() would do the trick.)


- Steph


- Original Message - 
From: Ilia Alshanetsky [EMAIL PROTECTED]

To: Dmitry Stogov [EMAIL PROTECTED]
Cc: php-cvs@lists.php.net
Sent: Friday, February 16, 2007 1:47 PM
Subject: Re: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c



Dmitry,

Please revert this patch. The code adds RINIT that hits every request  for 
functionality that is only needed for testing of the code and is 
otherwise rarely used. I do not believe it warrants slowing down  every 
single request, even by a little bit.



On 16-Feb-07, at 8:12 AM, Dmitry Stogov wrote:


dmitry Fri Feb 16 13:12:55 2007 UTC

  Modified files:
/php-src/ext/standard assert.c basic_functions.c
  Log:
  Fixed return value of assert_options(ASSERT_CALLBACK) and  possible 
crash (Andy Wharmby)



http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c? 
r1=1.71r2=1.72diff_format=u

Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/ 
assert.c:1.72

--- php-src/ext/standard/assert.c:1.71 Mon Jan  1 09:29:30 2007
+++ php-src/ext/standard/assert.c Fri Feb 16 13:12:55 2007
@@ -16,7 +16,7 @@

+- 
-+

  */

-/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
+/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */

 /* {{{ includes/startup/misc */

@@ -114,6 +114,16 @@
 return SUCCESS;
 }

+PHP_RINIT_FUNCTION(assert)
+{
+ if (ASSERTG(cb)) {
+ MAKE_STD_ZVAL(ASSERTG(callback));
+ ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
+ }
+
+ return SUCCESS;
+}
+
 PHP_RSHUTDOWN_FUNCTION(assert)
 {
 if (ASSERTG(callback)) {
@@ -202,11 +212,6 @@
 RETURN_TRUE;
 }

- if (!ASSERTG(callback)  ASSERTG(cb)) {
- MAKE_STD_ZVAL(ASSERTG(callback));
- ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
- }
-
 if (ASSERTG(callback)) {
 zval *args[3];
 zval *retval;
@@ -309,6 +314,11 @@
 break;

 case ASSERT_CALLBACK:
+ if (ASSERTG(callback) != NULL) {
+ RETVAL_ZVAL(ASSERTG(callback), 1, 0);
+ } else {
+ RETVAL_NULL();
+ }
 if (ac == 2) {
 if (ASSERTG(callback)) {
 zval_ptr_dtor(ASSERTG(callback));
@@ -316,7 +326,7 @@
 ASSERTG(callback) = *value;
 zval_add_ref(value);
 }
- RETURN_TRUE;
+ return;
 break;

 default:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ 
basic_functions.c?r1=1.846r2=1.847diff_format=u

Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.846 php-src/ext/ 
standard/basic_functions.c:1.847
--- php-src/ext/standard/basic_functions.c:1.846 Thu Feb  8  15:31:01 
2007

+++ php-src/ext/standard/basic_functions.c Fri Feb 16 13:12:55 2007
@@ -17,7 +17,7 @@

+- 
-+

  */

-/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01 helly Exp $ */
+/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 dmitry Exp $ */

 #include php.h
 #include php_streams.h
@@ -4147,6 +4147,7 @@
 #ifdef HAVE_SYSLOG_H
 PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
+ PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
 PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
 PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);


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



Ilia Alshanetsky

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



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



Re: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Ilia Alshanetsky


On 16-Feb-07, at 9:55 AM, Steph Fox wrote:


Ilia, hi,

There's no way to query the current callback setting there. If  
RINIT's the only way to achieve it, and we can't have RINIT, the  
manual needs fixing to reflect reality.


So - are you officially calling it a 'won't fix'?'


yes! I already did it inside the bug report.

Ilia Alshanetsky

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



RE: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Dmitry Stogov
Really this patch fixes a SIGSEGV.
I'll try to look how to optimize it.

Thanks. Dmitry.

 -Original Message-
 From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] 
 Sent: Friday, February 16, 2007 4:47 PM
 To: Dmitry Stogov
 Cc: php-cvs@lists.php.net
 Subject: Re: [PHP-CVS] cvs: php-src /ext/standard assert.c 
 basic_functions.c 
 
 
 Dmitry,
 
 Please revert this patch. The code adds RINIT that hits every 
 request  
 for functionality that is only needed for testing of the code and is  
 otherwise rarely used. I do not believe it warrants slowing down  
 every single request, even by a little bit.
 
 
 On 16-Feb-07, at 8:12 AM, Dmitry Stogov wrote:
 
  dmitry  Fri Feb 16 13:12:55 2007 UTC
 
Modified files:
  /php-src/ext/standard   assert.c basic_functions.c
Log:
Fixed return value of assert_options(ASSERT_CALLBACK) and
  possible crash (Andy Wharmby)
 
 
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c? 
  r1=1.71r2=1.72diff_format=u
  Index: php-src/ext/standard/assert.c
  diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/ 
  assert.c:1.72
  --- php-src/ext/standard/assert.c:1.71  Mon Jan  1 09:29:30 2007
  +++ php-src/ext/standard/assert.c   Fri Feb 16 13:12:55 2007
  @@ -16,7 +16,7 @@
   
  
 +-
  
  -+
*/
 
  -/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
  +/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */
 
   /* {{{ includes/startup/misc */
 
  @@ -114,6 +114,16 @@
  return SUCCESS;
   }
 
  +PHP_RINIT_FUNCTION(assert)
  +{
  +   if (ASSERTG(cb)) {
  +   MAKE_STD_ZVAL(ASSERTG(callback));
  +   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
  +   }
  +
  +   return SUCCESS;
  +}
  +
   PHP_RSHUTDOWN_FUNCTION(assert)
   {
  if (ASSERTG(callback)) {
  @@ -202,11 +212,6 @@
  RETURN_TRUE;
  }
 
  -   if (!ASSERTG(callback)  ASSERTG(cb)) {
  -   MAKE_STD_ZVAL(ASSERTG(callback));
  -   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
  -   }
  -
  if (ASSERTG(callback)) {
  zval *args[3];
  zval *retval;
  @@ -309,6 +314,11 @@
  break;
 
  case ASSERT_CALLBACK:
  +   if (ASSERTG(callback) != NULL) {
  +   RETVAL_ZVAL(ASSERTG(callback), 1, 0);
  +   } else {
  +   RETVAL_NULL();
  +   }
  if (ac == 2) {
  if (ASSERTG(callback)) {
  zval_ptr_dtor(ASSERTG(callback));
  @@ -316,7 +326,7 @@
  ASSERTG(callback) = *value;
  zval_add_ref(value);
  }
  -   RETURN_TRUE;
  +   return;
  break;
 
  default:
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ 
  basic_functions.c?r1=1.846r2=1.847diff_format=u
  Index: php-src/ext/standard/basic_functions.c
  diff -u php-src/ext/standard/basic_functions.c:1.846 php-src/ext/ 
  standard/basic_functions.c:1.847
  --- php-src/ext/standard/basic_functions.c:1.846Thu Feb  8  
  15:31:01 2007
  +++ php-src/ext/standard/basic_functions.c  Fri Feb 16 13:12:55 2007
  @@ -17,7 +17,7 @@
   
  
 +-
  
  -+
*/
 
  -/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01 
 helly Exp $ */
  +/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 
 dmitry Exp $ */
 
   #include php.h
   #include php_streams.h
  @@ -4147,6 +4147,7 @@
   #ifdef HAVE_SYSLOG_H
  PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
   #endif
  +   PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
  PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
  PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
 
 
  -- 
  PHP CVS Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Ilia Alshanetsky
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Nuno Lopes

So where is the test? *hint* :-)

- Original Message - 

Really this patch fixes a SIGSEGV.
I'll try to look how to optimize it.

Thanks. Dmitry.


-Original Message-
From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 16, 2007 4:47 PM

To: Dmitry Stogov
Cc: php-cvs@lists.php.net
Subject: Re: [PHP-CVS] cvs: php-src /ext/standard assert.c 
basic_functions.c 



Dmitry,

Please revert this patch. The code adds RINIT that hits every 
request  
for functionality that is only needed for testing of the code and is  
otherwise rarely used. I do not believe it warrants slowing down  
every single request, even by a little bit.



On 16-Feb-07, at 8:12 AM, Dmitry Stogov wrote:

 dmitry Fri Feb 16 13:12:55 2007 UTC

   Modified files:
 /php-src/ext/standard assert.c basic_functions.c
   Log:
   Fixed return value of assert_options(ASSERT_CALLBACK) and
 possible crash (Andy Wharmby)


 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c? 
 r1=1.71r2=1.72diff_format=u

 Index: php-src/ext/standard/assert.c
 diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/ 
 assert.c:1.72

 --- php-src/ext/standard/assert.c:1.71 Mon Jan  1 09:29:30 2007
 +++ php-src/ext/standard/assert.c Fri Feb 16 13:12:55 2007
 @@ -16,7 +16,7 @@
  
 
+-
 
 -+

   */

 -/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
 +/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */

  /* {{{ includes/startup/misc */

 @@ -114,6 +114,16 @@
  return SUCCESS;
  }

 +PHP_RINIT_FUNCTION(assert)
 +{
 + if (ASSERTG(cb)) {
 + MAKE_STD_ZVAL(ASSERTG(callback));
 + ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
 + }
 +
 + return SUCCESS;
 +}
 +
  PHP_RSHUTDOWN_FUNCTION(assert)
  {
  if (ASSERTG(callback)) {
 @@ -202,11 +212,6 @@
  RETURN_TRUE;
  }

 - if (!ASSERTG(callback)  ASSERTG(cb)) {
 - MAKE_STD_ZVAL(ASSERTG(callback));
 - ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
 - }
 -
  if (ASSERTG(callback)) {
  zval *args[3];
  zval *retval;
 @@ -309,6 +314,11 @@
  break;

  case ASSERT_CALLBACK:
 + if (ASSERTG(callback) != NULL) {
 + RETVAL_ZVAL(ASSERTG(callback), 1, 0);
 + } else {
 + RETVAL_NULL();
 + }
  if (ac == 2) {
  if (ASSERTG(callback)) {
  zval_ptr_dtor(ASSERTG(callback));
 @@ -316,7 +326,7 @@
  ASSERTG(callback) = *value;
  zval_add_ref(value);
  }
 - RETURN_TRUE;
 + return;
  break;

  default:
 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/ 
 basic_functions.c?r1=1.846r2=1.847diff_format=u

 Index: php-src/ext/standard/basic_functions.c
 diff -u php-src/ext/standard/basic_functions.c:1.846 php-src/ext/ 
 standard/basic_functions.c:1.847
 --- php-src/ext/standard/basic_functions.c:1.846 Thu Feb  8  
 15:31:01 2007

 +++ php-src/ext/standard/basic_functions.c Fri Feb 16 13:12:55 2007
 @@ -17,7 +17,7 @@
  
 
+-
 
 -+

   */

 -/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01 
helly Exp $ */
 +/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 
dmitry Exp $ */


  #include php.h
  #include php_streams.h
 @@ -4147,6 +4147,7 @@
  #ifdef HAVE_SYSLOG_H
  PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
  #endif
 + PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
  PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
  PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);


 -- 
 PHP CVS Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php


Ilia Alshanetsky


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



[PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Dmitry Stogov
dmitry  Fri Feb 16 16:33:37 2007 UTC

  Modified files:  
/php-src/ext/standard   assert.c basic_functions.c 
  Log:
  Optimize out RINIT()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.72r2=1.73diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.72 php-src/ext/standard/assert.c:1.73
--- php-src/ext/standard/assert.c:1.72  Fri Feb 16 13:12:55 2007
+++ php-src/ext/standard/assert.c   Fri Feb 16 16:33:37 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */
+/* $Id: assert.c,v 1.73 2007/02/16 16:33:37 dmitry Exp $ */
 
 /* {{{ includes/startup/misc */
 
@@ -114,16 +114,6 @@
return SUCCESS;
 }
 
-PHP_RINIT_FUNCTION(assert)
-{
-   if (ASSERTG(cb)) {
-   MAKE_STD_ZVAL(ASSERTG(callback));
-   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
-   }
-
-   return SUCCESS;
-}
-
 PHP_RSHUTDOWN_FUNCTION(assert)
 {
if (ASSERTG(callback)) { 
@@ -212,6 +202,11 @@
RETURN_TRUE;
}
 
+   if (!ASSERTG(callback)  ASSERTG(cb)) {
+   MAKE_STD_ZVAL(ASSERTG(callback));
+   ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
+   }
+
if (ASSERTG(callback)) {
zval *args[3];
zval *retval;
@@ -316,6 +311,8 @@
case ASSERT_CALLBACK:
if (ASSERTG(callback) != NULL) {
RETVAL_ZVAL(ASSERTG(callback), 1, 0);
+   } else if (ASSERTG(cb)) {
+   RETVAL_STRING(ASSERTG(cb), 1);
} else {
RETVAL_NULL();
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.847r2=1.848diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.847 
php-src/ext/standard/basic_functions.c:1.848
--- php-src/ext/standard/basic_functions.c:1.847Fri Feb 16 13:12:55 2007
+++ php-src/ext/standard/basic_functions.c  Fri Feb 16 16:33:37 2007
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55 dmitry Exp $ */
+/* $Id: basic_functions.c,v 1.848 2007/02/16 16:33:37 dmitry Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -4147,7 +4147,6 @@
 #ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
-   PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
 

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



RE: [PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2007-02-16 Thread Dmitry Stogov
I am not sure how I got a crash. :)
Probably it wasn't related to this bug/fix, but it was a result of another
bad fix for the same problem.

Dmitry.

 -Original Message-
 From: Nuno Lopes [mailto:[EMAIL PROTECTED] 
 Sent: Friday, February 16, 2007 7:28 PM
 To: Dmitry Stogov; 'Ilia Alshanetsky'
 Cc: php-cvs@lists.php.net
 Subject: Re: [PHP-CVS] cvs: php-src /ext/standard assert.c 
 basic_functions.c 
 
 
 So where is the test? *hint* :-)
 
 - Original Message - 
  Really this patch fixes a SIGSEGV.
  I'll try to look how to optimize it.
  
  Thanks. Dmitry.
  
  -Original Message-
  From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED]
  Sent: Friday, February 16, 2007 4:47 PM
  To: Dmitry Stogov
  Cc: php-cvs@lists.php.net
  Subject: Re: [PHP-CVS] cvs: php-src /ext/standard assert.c 
  basic_functions.c 
  
  
  Dmitry,
  
  Please revert this patch. The code adds RINIT that hits every
  request  
  for functionality that is only needed for testing of the 
 code and is  
  otherwise rarely used. I do not believe it warrants slowing down  
  every single request, even by a little bit.
  
  
  On 16-Feb-07, at 8:12 AM, Dmitry Stogov wrote:
  
   dmitry Fri Feb 16 13:12:55 2007 UTC
  
 Modified files:
   /php-src/ext/standard assert.c basic_functions.c
 Log:
 Fixed return value of assert_options(ASSERT_CALLBACK) and 
   possible crash (Andy Wharmby)
  
  
   http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?
   r1=1.71r2=1.72diff_format=u
   Index: php-src/ext/standard/assert.c
   diff -u php-src/ext/standard/assert.c:1.71 php-src/ext/standard/ 
   assert.c:1.72
   --- php-src/ext/standard/assert.c:1.71 Mon Jan  1 09:29:30 2007
   +++ php-src/ext/standard/assert.c Fri Feb 16 13:12:55 2007
   @@ -16,7 +16,7 @@

   
  +-
  
   -+
 */
  
   -/* $Id: assert.c,v 1.71 2007/01/01 09:29:30 sebastian Exp $ */
   +/* $Id: assert.c,v 1.72 2007/02/16 13:12:55 dmitry Exp $ */
  
/* {{{ includes/startup/misc */
  
   @@ -114,6 +114,16 @@
return SUCCESS;
}
  
   +PHP_RINIT_FUNCTION(assert)
   +{
   + if (ASSERTG(cb)) {
   + MAKE_STD_ZVAL(ASSERTG(callback));  
 ZVAL_STRING(ASSERTG(callback), 
   +ASSERTG(cb), 1);  }
   +
   + return SUCCESS;
   +}
   +
PHP_RSHUTDOWN_FUNCTION(assert)
{
if (ASSERTG(callback)) {
   @@ -202,11 +212,6 @@
RETURN_TRUE;
}
  
   - if (!ASSERTG(callback)  ASSERTG(cb)) {
   - MAKE_STD_ZVAL(ASSERTG(callback));
   - ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
   - }
   -
if (ASSERTG(callback)) {
zval *args[3];
zval *retval;
   @@ -309,6 +314,11 @@
break;
  
case ASSERT_CALLBACK:
   + if (ASSERTG(callback) != NULL) { 
 RETVAL_ZVAL(ASSERTG(callback), 
   + 1, 0); } else {
   + RETVAL_NULL();
   + }
if (ac == 2) {
if (ASSERTG(callback)) {  zval_ptr_dtor(ASSERTG(callback));
   @@ -316,7 +326,7 @@
ASSERTG(callback) = *value;
zval_add_ref(value);
}
   - RETURN_TRUE;
   + return;
break;
  
default: http://cvs.php.net/viewvc.cgi/php-src/ext/standard/
   basic_functions.c?r1=1.846r2=1.847diff_format=u
   Index: php-src/ext/standard/basic_functions.c
   diff -u php-src/ext/standard/basic_functions.c:1.846 
 php-src/ext/ 
   standard/basic_functions.c:1.847
   --- php-src/ext/standard/basic_functions.c:1.846 Thu Feb  8  
   15:31:01 2007
   +++ php-src/ext/standard/basic_functions.c Fri Feb 16 
 13:12:55 2007
   @@ -17,7 +17,7 @@

   
  +-
  
   -+
 */
  
   -/* $Id: basic_functions.c,v 1.846 2007/02/08 15:31:01
  helly Exp $ */
   +/* $Id: basic_functions.c,v 1.847 2007/02/16 13:12:55
  dmitry Exp $ */
  
#include php.h
#include php_streams.h
   @@ -4147,6 +4147,7 @@
#ifdef HAVE_SYSLOG_H  
 PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
#endif
   + PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
  
  
   --
   PHP CVS Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  Ilia Alshanetsky
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP-CVS] cvs: php-src /ext/standard assert.c basic_functions.c

2006-09-21 Thread Sara Golemon
pollita Fri Sep 22 01:55:48 2006 UTC

  Modified files:  
/php-src/ext/standard   assert.c basic_functions.c 
  Log:
  PHP6 Updates
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.68r2=1.69diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.68 php-src/ext/standard/assert.c:1.69
--- php-src/ext/standard/assert.c:1.68  Tue Aug  8 17:32:19 2006
+++ php-src/ext/standard/assert.c   Fri Sep 22 01:55:47 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: assert.c,v 1.68 2006/08/08 17:32:19 tony2001 Exp $ */
+/* $Id: assert.c,v 1.69 2006/09/22 01:55:47 pollita Exp $ */
 
 /* {{{ includes/startup/misc */
 
@@ -119,7 +119,7 @@
 /* }}} */
 /* {{{ internal functions */
 /* }}} */
-/* {{{ proto int assert(string|bool assertion)
+/* {{{ proto int assert(string|bool assertion) U
Checks if assertion is false */
 
 PHP_FUNCTION(assert)
@@ -238,7 +238,7 @@
 }
 
 /* }}} */
-/* {{{ proto mixed assert_options(int what [, mixed value])
+/* {{{ proto mixed assert_options(int what [, mixed value]) U
Set/get the various assert flags */
 
 PHP_FUNCTION(assert_options)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.804r2=1.805diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.804 
php-src/ext/standard/basic_functions.c:1.805
--- php-src/ext/standard/basic_functions.c:1.804Tue Sep 19 23:45:12 2006
+++ php-src/ext/standard/basic_functions.c  Fri Sep 22 01:55:47 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.804 2006/09/19 23:45:12 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.805 2006/09/22 01:55:47 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -4217,7 +4217,7 @@
 /* }}} */
 
 #ifdef HAVE_INET_NTOP
-/* {{{ proto string inet_ntop(string in_addr)
+/* {{{ proto string inet_ntop(string in_addr) U
Converts a packed inet address to a human readable IP address string */
 PHP_NAMED_FUNCTION(php_inet_ntop)
 {
@@ -4225,7 +4225,7 @@
int address_len, af = AF_INET;
char buffer[40];
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, address, 
address_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, S, address, 
address_len) == FAILURE) {
RETURN_FALSE;
}
 
@@ -4244,13 +4244,13 @@
RETURN_FALSE;
}
 
-   RETURN_STRING(buffer, 1);
+   RETURN_RT_STRING(buffer, ZSTR_DUPLICATE);
 }
 /* }}} */
 #endif /* HAVE_INET_NTOP */
 
 #ifdef HAVE_INET_PTON
-/* {{{ proto string inet_pton(string ip_address)
+/* {{{ proto string inet_pton(string ip_address) U
Converts a human readable IP address to a packed binary string */
 PHP_NAMED_FUNCTION(php_inet_pton)
 {
@@ -4289,24 +4289,24 @@
 
 
 
-/* {{{ proto int ip2long(string ip_address)
+/* {{{ proto int ip2long(string ip_address) U
Converts a string containing an (IPv4) Internet Protocol dotted address 
into a proper address */
 PHP_FUNCTION(ip2long)
 {
-   zval **str;
+   char *addr;
+   int addr_len;
unsigned long int ip;
 
-   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, str) == FAILURE) 
{
-   WRONG_PARAM_COUNT;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, addr, 
addr_len) == FAILURE) {
+   return;
}
 
-   convert_to_string_ex(str);
-
-   if (Z_STRLEN_PP(str) == 0 || (ip = inet_addr(Z_STRVAL_PP(str))) == 
INADDR_NONE) {
+   if (addr_len == 0 || (ip = inet_addr(addr)) == INADDR_NONE) {
/* the only special case when we should return -1 ourselves,
 * because inet_addr() considers it wrong.
 */
-   if (!memcmp(Z_STRVAL_PP(str), 255.255.255.255, 
Z_STRLEN_PP(str))) {
+   if (addr_len == sizeof(255.255.255.255) - 1 
+   !memcmp(addr, 255.255.255.255, 
sizeof(255.255.255.255) - 1)) {
RETURN_LONG(-1);
}

@@ -4317,23 +4317,24 @@
 }
 /* }}} */
 
-/* {{{ proto string long2ip(int proper_address)
+/* {{{ proto string long2ip(int proper_address) U
Converts an (IPv4) Internet network address into a string in Internet 
standard dotted format */
 PHP_FUNCTION(long2ip)
 {
-   zval **num;
+   /* It's a long but it's not, PHP ints are signed */
+   char *ip;
+   int ip_len;
unsigned long n;
struct in_addr myaddr;
 
-   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, num) == FAILURE) 
{
-   WRONG_PARAM_COUNT;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, ip, ip_len) 
== FAILURE) {
+   return;
}
-   convert_to_string_ex(num);

-   n = strtoul(Z_STRVAL_PP(num), NULL, 0);
+   n = strtoul(ip, NULL,