]> granicus.if.org Git - php/commitdiff
Restore behavior of $str["str"]. (Now $str["str"] is equivalent to $str[0] again)
authorDmitry Stogov <dmitry@php.net>
Fri, 14 Jan 2005 09:01:22 +0000 (09:01 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 14 Jan 2005 09:01:22 +0000 (09:01 +0000)
Zend/tests/bug31098.phpt
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 8e6c0277f96046378908ac91973bad4ff47fbafa..fa753678eee8dfbedc648d21a2de672a693e6dd4 100644 (file)
@@ -17,7 +17,7 @@ var_dump(isset($a{'b'}));
 
 $simpleString = "Bogus String Text";
 echo isset($simpleString->wrong)?"bug\n":"ok\n";
-echo isset($simpleString["wrong"])?"bug\n":"ok\n";
+echo isset($simpleString["wrong"])?"ok\n":"bug\n";
 echo isset($simpleString[-1])?"bug\n":"ok\n";
 echo isset($simpleString[0])?"ok\n":"bug\n";
 echo isset($simpleString["0"])?"ok\n":"bug\n";
@@ -25,18 +25,18 @@ echo isset($simpleString["16"])?"ok\n":"bug\n";
 echo isset($simpleString["17"])?"bug\n":"ok\n";
 echo isset($simpleString["wrong"][0])?"bug\n":"ok\n";
 echo $simpleString->wrong === null?"ok\n":"bug\n";
-echo $simpleString["wrong"] === null?"ok\n":"bug\n";
+echo $simpleString["wrong"] === "B"?"ok\n":"bug\n";
 echo $simpleString["0"] === "B"?"ok\n":"bug\n";
 $simpleString["wrong"] = "f";
-echo $simpleString["0"] === "B"?"ok\n":"bug\n";
+echo $simpleString["0"] === "f"?"ok\n":"bug\n";
 ?>
 --EXPECTF--
 bool(false)
 bool(false)
 bool(false)
 bool(false)
-bool(false)
-bool(false)
+bool(true)
+bool(true)
 ok
 ok
 ok
@@ -48,10 +48,6 @@ ok
 
 Notice: Trying to get property of non-object in %sbug31098.php on line %d
 ok
-
-Notice: Trying to get string index from a string in %sbug31098.php on line %d
 ok
 ok
-
-Notice: Trying to get string index from a string in %sbug31098.php on line %d
 ok
index 7e75696b93a20e5d22365fc5a1c73e67c07aaae7..b249b37871a0ed4f7ff5ed452305660d93226548 100644 (file)
@@ -1190,28 +1190,7 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container
                                        zend_error_noreturn(E_ERROR, "[] operator not supported for strings");
                                }
 
-                               if (Z_TYPE_P(dim) == IS_STRING) {
-                                       char *strval;
-                                       long  lval;
-
-                                       strval = Z_STRVAL_P(dim);
-                                       if (is_numeric_string(strval, Z_STRLEN_P(dim), &lval, NULL, 0) == IS_LONG) {
-                                         ZVAL_LONG(&tmp, lval);
-                                               dim = &tmp;
-                                       } else {
-                                               if (type != BP_VAR_IS) {
-                                                       zend_error(E_NOTICE, "Trying to get string index from a string");
-                                               }
-                                               if (result) {
-                                                       result->var.ptr_ptr = &EG(error_zval_ptr);
-                                                       PZVAL_LOCK(*result->var.ptr_ptr);
-                                                       if (type == BP_VAR_R || type == BP_VAR_IS) {
-                                                               AI_USE_PTR(result->var);
-                                                       }
-                                               }
-                                               return;
-                                       }
-                               } else if (dim->type != IS_LONG) {
+                               if (dim->type != IS_LONG) {
                                        tmp = *dim;
                                        zval_copy_ctor(&tmp);
                                        convert_to_long(&tmp);
index 61c38777c8364394972546c923f2be55549bf2a9..304b4e6740889d737369d5aa2664dd748b013c63 100644 (file)
@@ -3193,16 +3193,7 @@ ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, VAR|UNUSED|CV, CONST|
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
index 348fd3a6b744cbbba4850d4279c2e1853992f846..ebb49e13d6064a4e956b9cfd29434186eb46d9ad 100644 (file)
@@ -9013,16 +9013,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CONST(int prop_dim,
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -10337,16 +10328,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_TMP(int prop_dim, ZE
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -11682,16 +11664,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_VAR(int prop_dim, ZE
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -13157,16 +13130,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CV(int prop_dim, ZEN
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -14232,16 +14196,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CONST(int prop_di
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -15190,16 +15145,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_TMP(int prop_dim,
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -16148,16 +16094,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_VAR(int prop_dim,
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -17225,16 +17162,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CV(int prop_dim,
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -19719,16 +19647,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CONST(int prop_dim, Z
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -21043,16 +20962,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_TMP(int prop_dim, ZEN
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -22388,16 +22298,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_VAR(int prop_dim, ZEN
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -23863,16 +23764,7 @@ static int zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CV(int prop_dim, ZEND
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);
@@ -30938,16 +30830,7 @@ static int zend_isset_isempty_dim_prop_obj_handler(int prop_dim, ZEND_OPCODE_HAN
                } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */
                        zval tmp;
 
-                       if (Z_TYPE_P(offset) == IS_STRING) {
-                               char *strval;
-                               long  lval;
-
-                               strval = Z_STRVAL_P(offset);
-                               if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) {
-                                       ZVAL_LONG(&tmp, lval);
-                                       offset = &tmp;
-                               }
-                       } else if (offset->type != IS_LONG) {
+                       if (offset->type != IS_LONG) {
                                tmp = *offset;
                                zval_copy_ctor(&tmp);
                                convert_to_long(&tmp);