]> granicus.if.org Git - php/commitdiff
MFH: add zend_atol()
authorAntony Dovgal <tony2001@php.net>
Wed, 19 Mar 2008 12:41:23 +0000 (12:41 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 19 Mar 2008 12:41:23 +0000 (12:41 +0000)
Zend/zend_ini.c
Zend/zend_operators.c
Zend/zend_operators.h

index 4bdb8d87562a7771c27fe216bd9a9aed36e7db79..c773f0a05b6a851a07af816e12b617c0f8aa538b 100644 (file)
@@ -556,7 +556,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
 
        p = (long *) (base+(size_t) mh_arg1);
 
-       *p = zend_atoi(new_value, new_value_length);
+       *p = zend_atol(new_value, new_value_length);
        return SUCCESS;
 }
 /* }}} */
@@ -572,7 +572,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
        base = (char *) ts_resource(*((int *) mh_arg2));
 #endif
 
-       tmp = zend_atoi(new_value, new_value_length);
+       tmp = zend_atol(new_value, new_value_length);
        if (tmp < 0) {
                return FAILURE;
        }
index 542af1576f97b10b935887f80d6fc24a811b1991..6a905cef9d0ee65247a31fa05f2aa5a5925d6cdf 100644 (file)
@@ -71,6 +71,33 @@ ZEND_API int zend_atoi(const char *str, int str_len)
        return retval;
 }
 
+ZEND_API long zend_atol(const char *str, int str_len)
+{
+       long retval;
+
+       if (!str_len) {
+               str_len = strlen(str);
+       }
+       retval = strtol(str, NULL, 0);
+       if (str_len>0) {
+               switch (str[str_len-1]) {
+                       case 'g':
+                       case 'G':
+                               retval *= 1024;
+                               /* break intentionally missing */
+                       case 'm':
+                       case 'M':
+                               retval *= 1024;
+                               /* break intentionally missing */
+                       case 'k':
+                       case 'K':
+                               retval *= 1024;
+                               break;
+               }
+       }
+       return retval;
+}
+
 
 ZEND_API double zend_string_to_double(const char *number, zend_uint length)
 {
index 1bf25ee93e1e4684c5709d65347e60ddac59d68e..46cecf27305e2528a3fd686350fee1ad98991cb6 100644 (file)
@@ -312,6 +312,7 @@ ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC);
 ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC);
 
 ZEND_API int zend_atoi(const char *str, int str_len);
+ZEND_API int zend_atol(const char *str, int str_len);
 
 ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
 END_EXTERN_C()