| Ilia Alshanetsky 2005-11-16, 6:56 pm |
| iliaa Wed Nov 16 19:20:32 2005 EDT
Modified files:
/ZendEngine2 zend_operators.h zend_API.c
Log:
MFB51: Allow zend_parse_parameters to handle non-well formed integers, but
raise E_NOTICE in the process.
http://cvs.php.net/diff.php/ZendEng...1&r2=1.102&ty=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.101 ZendEngine2/zend_operators.h:1.102
--- ZendEngine2/zend_operators.h:1.101 Sat Oct 1 23:10:33 2005
+++ ZendEngine2/zend_operators.h Wed Nov 16 19:20:31 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.101 2005/10/02 03:10:33 andrei Exp $ */
+/* $Id: zend_operators.h,v 1.102 2005/11/17 00:20:31 iliaa Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -68,7 +68,7 @@
ZEND_API double zend_u_strtod(const UChar *nptr, UChar **endptr);
END_EXTERN_C()
-static inline zend_uchar is_numeric_string(char *str, int length, long *lval, double *dval, zend_bool allow_errors)
+static inline zend_uchar is_numeric_string(char *str, int length, long *lval, double *dval, int allow_errors)
{
long local_lval;
double local_dval;
@@ -119,16 +119,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 zend_uchar is_numeric_unicode(UChar *str, int32_t length, long *lval, double *dval, zend_bool allow_errors)
http://cvs.php.net/diff.php/ZendEng...5&r2=1.326&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.325 ZendEngine2/zend_API.c:1.326
--- ZendEngine2/zend_API.c:1.325 Tue Nov 1 11:53:29 2005
+++ ZendEngine2/zend_API.c Wed Nov 16 19:20:31 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.325 2005/11/01 16:53:29 helly Exp $ */
+/* $Id: zend_API.c,v 1.326 2005/11/17 00:20:31 iliaa Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -316,7 +316,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;
@@ -363,7 +363,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;
|