]> granicus.if.org Git - php/commitdiff
Simplify ZEND_EXIT and count boolean values to it as exit status
authorBob Weinand <bobwei9@hotmail.com>
Tue, 11 Aug 2015 20:36:47 +0000 (22:36 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 11 Aug 2015 20:36:47 +0000 (22:36 +0200)
NEWS
UPGRADING
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
Zend/zend_vm_gen.php

diff --git a/NEWS b/NEWS
index 3d02db773cb46e94738f20a10e8db4c927f2d32f..74ccbce8d2dbb8fed2599c4aa400430594f2532b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ PHP                                                                        NEWS
   . Fixed bug #70198 (Checking liveness does not work as expected).
     (Shafreeck Sea, Anatol Belski)
   . Fixed bug #70241 (Skipped assertions affect Generator returns). (Bob)
+  . exit() and die() interpret all scalars except strings as exit_status now.
+    (Bob)
 
 - CLI server:
   . Fixed bug #66606 (Sets HTTP_CONTENT_TYPE but not CONTENT_TYPE).
index 6f420650d2534d79c3c6291f4e449b1c07edae34..b9b4c6964e2fb0f03a7af785be816780d7aa67ab 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -425,6 +425,7 @@ Other language changes
   . Removed support for #-style comments in ini files. Use ;-style comments
     instead.
   . $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
+  . exit() and die() interpret all scalars except strings as exit_status now.
 
 Standard library changes
 ========================
index c968fd290772243d45673962c546ac473bbf1caa..9286f41ca70a5af60b09127fa0e6c74d9898aa48 100644 (file)
@@ -6637,22 +6637,17 @@ ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMPVAR|UNUSED|CV, ANY)
        SAVE_OPLINE();
        if (OP1_TYPE != IS_UNUSED) {
                zend_free_op free_op1;
-               zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
-
-               do {
-                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                               EG(exit_status) = Z_LVAL_P(ptr);
-                       } else {
-                               if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
-                                       ptr = Z_REFVAL_P(ptr);
-                                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                                               EG(exit_status) = Z_LVAL_P(ptr);
-                                               break;
-                                       }
-                               }
-                               zend_print_variable(ptr);
-                       }
-               } while (0);
+               zval *ptr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
+
+               if (Z_TYPE_P(ptr) == IS_LONG) {
+                       EG(exit_status) = Z_LVAL_P(ptr);
+               } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+                       EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+               } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+                       EG(exit_status) = (int) Z_DVAL_P(ptr);
+               } else {
+                       zend_print_variable(ptr);
+               }
                FREE_OP1();
        }
        zend_bailout();
index 5645ed625a3a04768d9080ecea6f98098d156000..3f9583a6428d3e6220fbc663fd98d74c3cf9abff 100644 (file)
@@ -3966,20 +3966,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_O
 
                zval *ptr = EX_CONSTANT(opline->op1);
 
-               do {
-                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                               EG(exit_status) = Z_LVAL_P(ptr);
-                       } else {
-                               if ((IS_CONST & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
-                                       ptr = Z_REFVAL_P(ptr);
-                                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                                               EG(exit_status) = Z_LVAL_P(ptr);
-                                               break;
-                                       }
-                               }
-                               zend_print_variable(ptr);
-                       }
-               } while (0);
+               if (Z_TYPE_P(ptr) == IS_LONG) {
+                       EG(exit_status) = Z_LVAL_P(ptr);
+               } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+                       EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+               } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+                       EG(exit_status) = (int) Z_DVAL_P(ptr);
+               } else {
+                       zend_print_variable(ptr);
+               }
 
        }
        zend_bailout();
@@ -22771,20 +22766,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_UNUSED_HANDLER(ZEND_
 
                zval *ptr = NULL;
 
-               do {
-                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                               EG(exit_status) = Z_LVAL_P(ptr);
-                       } else {
-                               if ((IS_UNUSED & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
-                                       ptr = Z_REFVAL_P(ptr);
-                                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                                               EG(exit_status) = Z_LVAL_P(ptr);
-                                               break;
-                                       }
-                               }
-                               zend_print_variable(ptr);
-                       }
-               } while (0);
+               if (Z_TYPE_P(ptr) == IS_LONG) {
+                       EG(exit_status) = Z_LVAL_P(ptr);
+               } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+                       EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+               } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+                       EG(exit_status) = (int) Z_DVAL_P(ptr);
+               } else {
+                       zend_print_variable(ptr);
+               }
 
        }
        zend_bailout();
@@ -29365,22 +29355,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCO
        SAVE_OPLINE();
        if (IS_CV != IS_UNUSED) {
 
-               zval *ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var);
+               zval *ptr = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var);
 
-               do {
-                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                               EG(exit_status) = Z_LVAL_P(ptr);
-                       } else {
-                               if ((IS_CV & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
-                                       ptr = Z_REFVAL_P(ptr);
-                                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                                               EG(exit_status) = Z_LVAL_P(ptr);
-                                               break;
-                                       }
-                               }
-                               zend_print_variable(ptr);
-                       }
-               } while (0);
+               if (Z_TYPE_P(ptr) == IS_LONG) {
+                       EG(exit_status) = Z_LVAL_P(ptr);
+               } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+                       EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+               } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+                       EG(exit_status) = (int) Z_DVAL_P(ptr);
+               } else {
+                       zend_print_variable(ptr);
+               }
 
        }
        zend_bailout();
@@ -40507,22 +40492,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_TMPVAR_HANDLER(ZEND_
        SAVE_OPLINE();
        if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) {
                zend_free_op free_op1;
-               zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1);
+               zval *ptr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1);
 
-               do {
-                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                               EG(exit_status) = Z_LVAL_P(ptr);
-                       } else {
-                               if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
-                                       ptr = Z_REFVAL_P(ptr);
-                                       if (Z_TYPE_P(ptr) == IS_LONG) {
-                                               EG(exit_status) = Z_LVAL_P(ptr);
-                                               break;
-                                       }
-                               }
-                               zend_print_variable(ptr);
-                       }
-               } while (0);
+               if (Z_TYPE_P(ptr) == IS_LONG) {
+                       EG(exit_status) = Z_LVAL_P(ptr);
+               } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+                       EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+               } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+                       EG(exit_status) = (int) Z_DVAL_P(ptr);
+               } else {
+                       zend_print_variable(ptr);
+               }
                zval_ptr_dtor_nogc(free_op1);
        }
        zend_bailout();
index cb4ac8433b1a9c38a449ffc68ceb28d378fd76d0..a66002c1aa8dca02788237571601713437a25470 100644 (file)
@@ -186,7 +186,7 @@ $op1_get_zval_ptr_deref = array(
        "CONST"  => "EX_CONSTANT(opline->op1)",
        "UNUSED" => "NULL",
        "CV"     => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var)",
-       "TMPVAR" => "???",
+       "TMPVAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
 );
 
 $op2_get_zval_ptr_deref = array(
@@ -196,7 +196,7 @@ $op2_get_zval_ptr_deref = array(
        "CONST"  => "EX_CONSTANT(opline->op2)",
        "UNUSED" => "NULL",
        "CV"     => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var)",
-       "TMPVAR" => "???",
+       "TMPVAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
 );
 
 $op1_get_zval_ptr_undef = array(