1 --- PHP_5_3/ext/standard/string.c 2011/04/13 03:32:19 310193
2 +++ PHP_5_3/ext/standard/string.c 2011/04/13 06:32:41 310194
3 @@ -2352,20 +2352,35 @@
5 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(str), &pos_str);
6 while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(str), (void **) &tmp_str, &pos_str) == SUCCESS) {
7 - convert_to_string_ex(tmp_str);
10 + if(Z_TYPE_PP(tmp_str) != IS_STRING) {
13 + zval_copy_ctor(orig_str);
14 + convert_to_string(orig_str);
16 + orig_str = *tmp_str;
19 if (Z_TYPE_PP(from) == IS_ARRAY) {
20 if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(from), (void **) &tmp_from, &pos_from)) {
21 - convert_to_long_ex(tmp_from);
22 + if(Z_TYPE_PP(tmp_from) != IS_LONG) {
23 + zval dummy = **tmp_from;
24 + zval_copy_ctor(&dummy);
25 + convert_to_long(&dummy);
28 + f = Z_LVAL_PP(tmp_from);
31 - f = Z_LVAL_PP(tmp_from);
33 - f = Z_STRLEN_PP(tmp_str) + f;
34 + f = Z_STRLEN_P(orig_str) + f;
38 - } else if (f > Z_STRLEN_PP(tmp_str)) {
39 - f = Z_STRLEN_PP(tmp_str);
40 + } else if (f > Z_STRLEN_P(orig_str)) {
41 + f = Z_STRLEN_P(orig_str);
43 zend_hash_move_forward_ex(Z_ARRVAL_PP(from), &pos_from);
45 @@ -2374,72 +2389,94 @@
49 - f = Z_STRLEN_PP(tmp_str) + f;
50 + f = Z_STRLEN_P(orig_str) + f;
54 - } else if (f > Z_STRLEN_PP(tmp_str)) {
55 - f = Z_STRLEN_PP(tmp_str);
56 + } else if (f > Z_STRLEN_P(orig_str)) {
57 + f = Z_STRLEN_P(orig_str);
61 if (argc > 3 && Z_TYPE_PP(len) == IS_ARRAY) {
62 if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(len), (void **) &tmp_len, &pos_len)) {
63 - convert_to_long_ex(tmp_len);
64 + if(Z_TYPE_PP(tmp_len) != IS_LONG) {
65 + zval dummy = **tmp_len;
66 + zval_copy_ctor(&dummy);
67 + convert_to_long(&dummy);
70 + l = Z_LVAL_PP(tmp_len);
73 l = Z_LVAL_PP(tmp_len);
74 zend_hash_move_forward_ex(Z_ARRVAL_PP(len), &pos_len);
76 - l = Z_STRLEN_PP(tmp_str);
77 + l = Z_STRLEN_P(orig_str);
79 } else if (argc > 3) {
82 - l = Z_STRLEN_PP(tmp_str);
83 + l = Z_STRLEN_P(orig_str);
87 - l = (Z_STRLEN_PP(tmp_str) - f) + l;
88 + l = (Z_STRLEN_P(orig_str) - f) + l;
94 - if ((f + l) > Z_STRLEN_PP(tmp_str)) {
95 - l = Z_STRLEN_PP(tmp_str) - f;
96 + if ((f + l) > Z_STRLEN_P(orig_str)) {
97 + l = Z_STRLEN_P(orig_str) - f;
100 - result_len = Z_STRLEN_PP(tmp_str) - l;
101 + result_len = Z_STRLEN_P(orig_str) - l;
103 if (Z_TYPE_PP(repl) == IS_ARRAY) {
104 if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(repl), (void **) &tmp_repl, &pos_repl)) {
105 - convert_to_string_ex(tmp_repl);
106 - result_len += Z_STRLEN_PP(tmp_repl);
109 + if(Z_TYPE_PP(tmp_repl) != IS_STRING) {
110 + zrepl = **tmp_repl;
112 + zval_copy_ctor(repl_str);
113 + convert_to_string(repl_str);
115 + repl_str = *tmp_repl;
118 + result_len += Z_STRLEN_P(repl_str);
119 zend_hash_move_forward_ex(Z_ARRVAL_PP(repl), &pos_repl);
120 result = emalloc(result_len + 1);
122 - memcpy(result, Z_STRVAL_PP(tmp_str), f);
123 - memcpy((result + f), Z_STRVAL_PP(tmp_repl), Z_STRLEN_PP(tmp_repl));
124 - memcpy((result + f + Z_STRLEN_PP(tmp_repl)), Z_STRVAL_PP(tmp_str) + f + l, Z_STRLEN_PP(tmp_str) - f - l);
125 + memcpy(result, Z_STRVAL_P(orig_str), f);
126 + memcpy((result + f), Z_STRVAL_P(repl_str), Z_STRLEN_P(repl_str));
127 + memcpy((result + f + Z_STRLEN_P(repl_str)), Z_STRVAL_P(orig_str) + f + l, Z_STRLEN_P(orig_str) - f - l);
128 + if(Z_TYPE_PP(tmp_repl) != IS_STRING) {
129 + zval_dtor(repl_str);
132 result = emalloc(result_len + 1);
134 - memcpy(result, Z_STRVAL_PP(tmp_str), f);
135 - memcpy((result + f), Z_STRVAL_PP(tmp_str) + f + l, Z_STRLEN_PP(tmp_str) - f - l);
136 + memcpy(result, Z_STRVAL_P(orig_str), f);
137 + memcpy((result + f), Z_STRVAL_P(orig_str) + f + l, Z_STRLEN_P(orig_str) - f - l);
140 result_len += Z_STRLEN_PP(repl);
142 result = emalloc(result_len + 1);
144 - memcpy(result, Z_STRVAL_PP(tmp_str), f);
145 + memcpy(result, Z_STRVAL_P(orig_str), f);
146 memcpy((result + f), Z_STRVAL_PP(repl), Z_STRLEN_PP(repl));
147 - memcpy((result + f + Z_STRLEN_PP(repl)), Z_STRVAL_PP(tmp_str) + f + l, Z_STRLEN_PP(tmp_str) - f - l);
148 + memcpy((result + f + Z_STRLEN_PP(repl)), Z_STRVAL_P(orig_str) + f + l, Z_STRLEN_P(orig_str) - f - l);
151 result[result_len] = '\0';
152 add_next_index_stringl(return_value, result, result_len, 0);
154 + if(Z_TYPE_PP(tmp_str) != IS_STRING) {
155 + zval_dtor(orig_str);
157 zend_hash_move_forward_ex(Z_ARRVAL_PP(str), &pos_str);