cvs: ZendEngine2(PHP_5_1) / zend_API.c zend_operators.h
| From: | Ilia Alshanetsky | Date: | Thu, 17 Nov 2005 00:19:26 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend_API.c zend_operators.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4351@lists.php.net to get a copy of this message | ||
iliaa Wed Nov 16 19:19:26 2005 EDT
Modified files: (Branch: PHP_5_1)
/ZendEngine2 zend_operators.h zend_API.c
Log:
Allow zend_parse_parameters to handle non-well formed integers, but raise
E_NOTICE in the process.
http://cvs.php.net/diff.php/ZendEngine2/zend_operators.h?r1=1.94&r2=1.94.2.1&ty=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.94 ZendEngine2/zend_operators.h:1.94.2.1
--- ZendEngine2/zend_operators.h:1.94 Wed Aug 3 09:30:56 2005
+++ ZendEngine2/zend_operators.h Wed Nov 16 19:19:23 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.94 2005/08/03 13:30:56 sniper Exp $ */
+/* $Id: zend_operators.h,v 1.94.2.1 2005/11/17 00:19:23 iliaa Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -65,7 +65,7 @@
ZEND_API zend_bool instanceof_function(zend_class_entry *instance_ce, zend_class_entry *ce
TSRMLS_DC);
END_EXTERN_C()
-static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval,
zend_bool allow_errors)
+static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval, int
allow_errors)
{
long local_lval;
double local_dval;
@@ -116,16 +116,21 @@
} else {
end_ptr_double=NULL;
}
- if (allow_errors) {
- if (end_ptr_double>end_ptr_long && dval) {
- *dval = local_dval;
- return IS_DOUBLE;
- } else if (end_ptr_long && lval) {
- *lval = local_lval;
- return IS_LONG;
- }
+
+ if (!allow_errors) {
+ return 0;
+ }
+ if (allow_errors == -1) {
+ zend_error(E_NOTICE, "A non well formed numeric value encountered");
+ }
+
+ if (end_ptr_double>end_ptr_long && dval) {
+ *dval = local_dval;
+ return IS_DOUBLE;
+ } else if (end_ptr_long && lval) {
+ *lval = local_lval;
+ return IS_LONG;
}
- return 0;
}
static inline char *
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.296.2.9&r2=1.296.2.10&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.9 ZendEngine2/zend_API.c:1.296.2.10
--- ZendEngine2/zend_API.c:1.296.2.9 Thu Nov 3 18:45:18 2005
+++ ZendEngine2/zend_API.c Wed Nov 16 19:19:23 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.296.2.9 2005/11/03 23:45:18 helly Exp $ */
+/* $Id: zend_API.c,v 1.296.2.10 2005/11/17 00:19:23 iliaa Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -296,7 +296,7 @@
double d;
int type;
- if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, 0)) == 0) {
+ if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) {
return "long";
} else if (type == IS_DOUBLE) {
*p = (long) d;
@@ -330,7 +330,7 @@
long l;
int type;
- if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, 0)) == 0) {
+ if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, -1)) == 0) {
return "double";
} else if (type == IS_LONG) {
*p = (double) l;