com php-src: Simplify ZEND_EXIT and count boolean val ues to it as exit status: NEWS UPGRADING Zend /zend_vm_def.h Zend/zend_vm_execute.h Zend/zend
_vm_gen.php
| From: | Bob Weinand | Date: | Tue, 11 Aug 2015 20:36:47 +0000 |
| Subject: | com php-src: Simplify ZEND_EXIT and count boolean val ues to it as exit status: NEWS UPGRADING Zend /zend_vm_def.h Zend/zend_vm_execute.h Zend/zend _vm_gen.php |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88480@lists.php.net to get a copy of this message | ||
Commit: 7c003948c618adb2a6691f529057388f02202f09
Author: Bob Weinand <bobwei9@hotmail.com> Tue, 11 Aug 2015 22:36:47 +0200
Parents: dbd8edbbd08fbb2906ee9b540348b340715b5dbe
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7c003948c618adb2a6691f529057388f02202f09
Log:
Simplify ZEND_EXIT and count boolean values to it as exit status
Changed paths:
M NEWS
M UPGRADING
M Zend/zend_vm_def.h
M Zend/zend_vm_execute.h
M Zend/zend_vm_gen.php
Diff:
diff --git a/NEWS b/NEWS
index 3d02db7..74ccbce 100644
--- 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).
diff --git a/UPGRADING b/UPGRADING
index 6f42065..b9b4c69 100644
--- 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
========================
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index c968fd2..9286f41 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 5645ed6..3f9583a 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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();
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index cb4ac84..a66002c 100644
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -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(