]> granicus.if.org Git - php/commitdiff
Remove zpp L specifier
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 3 Jun 2019 07:39:17 +0000 (09:39 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 3 Jun 2019 07:39:17 +0000 (09:39 +0200)
We don't use this internally anymore, and external usages should
be encouraged to move towards 'l'.

UPGRADING.INTERNALS
Zend/zend_API.c
Zend/zend_API.h

index 41c270ab405248354d2842225170bd8508cd0063..5580145a42a50a14c0a27a927c04ef1b97f18797 100644 (file)
@@ -5,6 +5,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
   b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler
   c. TSRM changes
   d. get() and set() object handlers
+  e. zend_parse_parameters 'L' specifier
 
 2. Build system changes
   a. Abstract
@@ -47,6 +48,9 @@ PHP 8.0 INTERNALS UPGRADE NOTES
      functionality should be provided in some other way (for example, as
      modification of an object property).
 
+  e. The zend_parse_parameters 'L' specifier and the Z_PARAM_STRICT_LONG()
+     family of macros have been removed. Use 'l' and Z_PARAM_LONG() insead,
+     which, despite the confusing name, actually have stricter input validation.
 
 ========================
 2. Build system changes
index 0770b97aed0cd164826e07e1b81d682991667552..d588266b423d51087a6b3728f9c1f00fcbe26fd5 100644 (file)
@@ -343,47 +343,6 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest)
 }
 /* }}} */
 
-ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *dest) /* {{{ */
-{
-       if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
-               if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
-                       return 0;
-               }
-               *dest = zend_dval_to_lval_cap(Z_DVAL_P(arg));
-       } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
-               double d;
-               int type;
-
-               if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
-                       if (EXPECTED(type != 0)) {
-                               if (UNEXPECTED(zend_isnan(d))) {
-                                       return 0;
-                               }
-                               *dest = zend_dval_to_lval_cap(d);
-                       } else {
-                               return 0;
-                       }
-               }
-       } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
-               *dest = 0;
-       } else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
-               *dest = 1;
-       } else {
-               return 0;
-       }
-       return 1;
-}
-/* }}} */
-
-ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_slow(zval *arg, zend_long *dest) /* {{{ */
-{
-       if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
-               return 0;
-       }
-       return zend_parse_arg_long_cap_weak(arg, dest);
-}
-/* }}} */
-
 ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */
 {
        if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
@@ -481,7 +440,6 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
 
        switch (c) {
                case 'l':
-               case 'L':
                        {
                                zend_long *p = va_arg(*va, zend_long *);
                                zend_bool *is_null = NULL;
@@ -490,7 +448,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
                                        is_null = va_arg(*va, zend_bool *);
                                }
 
-                               if (!zend_parse_arg_long(arg, p, is_null, check_null, c == 'L')) {
+                               if (!zend_parse_arg_long(arg, p, is_null, check_null)) {
                                        return "int";
                                }
                        }
@@ -688,9 +646,9 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
                        }
                        break;
 
-               case 'Z':
-                       /* 'Z' iz not supported anymore and should be replaced with 'z' */
-                       ZEND_ASSERT(c != 'Z');
+               case 'Z': /* replace with 'z' */
+               case 'L': /* replace with 'l' */
+                       ZEND_ASSERT(0 && "ZPP modifier no longer supported");
                default:
                        return "unknown";
        }
index 6d77fb78b78e6ffef7031b5e9552be27601ef541..8b534647a178e475b62172b5e17576fc07a18855 100644 (file)
@@ -1331,7 +1331,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
 /* old "l" */
 #define Z_PARAM_LONG_EX2(dest, is_null, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
-               if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
+               if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null))) { \
                        _expected_type = Z_EXPECTED_LONG; \
                        _error_code = ZPP_ERROR_WRONG_ARG; \
                        break; \
@@ -1343,21 +1343,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
 #define Z_PARAM_LONG(dest) \
        Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
 
-/* old "L" */
-#define Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, deref, separate) \
-               Z_PARAM_PROLOGUE(deref, separate); \
-               if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
-                       _expected_type = Z_EXPECTED_LONG; \
-                       _error_code = ZPP_ERROR_WRONG_ARG; \
-                       break; \
-               }
-
-#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
-       Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, separate, separate)
-
-#define Z_PARAM_STRICT_LONG(dest) \
-       Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0)
-
 /* old "o" */
 #define Z_PARAM_OBJECT_EX2(dest, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
@@ -1514,8 +1499,6 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest);
-ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_slow(zval *arg, zend_long *dest);
-ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest);
 ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest);
@@ -1539,7 +1522,7 @@ static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, ze
        return 1;
 }
 
-static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int cap)
+static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null)
 {
        if (check_null) {
                *is_null = 0;
@@ -1549,8 +1532,6 @@ static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, ze
        } else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
                *is_null = 1;
                *dest = 0;
-       } else if (cap) {
-               return zend_parse_arg_long_cap_slow(arg, dest);
        } else {
                return zend_parse_arg_long_slow(arg, dest);
        }