summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.h
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-06-13 17:58:33 +0000
committerSascha Schumann <sas@php.net>2000-06-13 17:58:33 +0000
commitdf74f1dfabafb515bdf8ffee5f989761c0d6604d (patch)
tree208700924af318225292a4982e9fc0ac2dda7c19 /Zend/zend_operators.h
parent307a234879aad2f47e00e158f9a424b9531c5879 (diff)
downloadphp-git-df74f1dfabafb515bdf8ffee5f989761c0d6604d.tar.gz
Add optional support for C0x inline semantics.
These are enabled by specifying `--enable-c0x-inline' on the command line. We might add an autoconf check for this particular feature later.
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r--Zend/zend_operators.h63
1 files changed, 62 insertions, 1 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 0d1fb6cf92..c522b1d492 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -21,6 +21,8 @@
#ifndef _OPERATORS_H
#define _OPERATORS_H
+#include <errno.h>
+
#define MAX_LENGTH_OF_LONG 18
#define MAX_LENGTH_OF_DOUBLE 32
@@ -47,7 +49,66 @@ ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2);
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2);
-ZEND_API inline int is_numeric_string(char *str, int length, long *lval, double *dval);
+ZEND_API inline int is_numeric_string(char *str, int length, long *lval, double *dval)
+#if defined(C0X_INLINE_SEMANTICS)
+{
+ long local_lval;
+ double local_dval;
+ char *end_ptr;
+
+ if (!length) {
+ return 0;
+ }
+
+ errno=0;
+ local_lval = strtol(str, &end_ptr, 10);
+ if (errno!=ERANGE && end_ptr == str+length) { /* integer string */
+ if (lval) {
+ *lval = local_lval;
+ }
+ return IS_LONG;
+ }
+
+ errno=0;
+ local_dval = strtod(str, &end_ptr);
+ if (errno!=ERANGE && end_ptr == str+length) { /* floating point string */
+ if (! finite(local_dval)) {
+ /* "inf","nan" and maybe other weird ones */
+ return 0;
+ }
+
+ if (dval) {
+ *dval = local_dval;
+ }
+#if WITH_BCMATH
+ if (length>16) {
+ register char *ptr=str, *end=str+length;
+
+ while(ptr<end) {
+ switch(*ptr++) {
+ case 'e':
+ case 'E':
+ /* scientific notation, not handled by the BC library */
+ return IS_DOUBLE;
+ break;
+ default:
+ break;
+ }
+ }
+ return FLAG_IS_BC;
+ } else {
+ return IS_DOUBLE;
+ }
+#else
+ return IS_DOUBLE;
+#endif
+ }
+
+ return 0;
+}
+#else
+;
+#endif
ZEND_API int increment_function(zval *op1);
ZEND_API int decrement_function(zval *op2);