25
25
#include " zend_hash.h"
26
26
#include " zend_list.h"
27
27
28
- #ifdef ZEND_ENGINE_3
29
28
# define PAA_LENGTH_ADJ (l ) (l)
30
29
# define PAA_SYM_EXISTS zend_symtable_str_exists
31
30
# define PAA_SYM_DEL zend_symtable_str_del
32
31
# define PAA_LONG zend_long
33
32
# define PAA_ULONG zend_ulong
34
- #else
35
- # define PAA_LENGTH_ADJ (l ) (l+1 )
36
- # define PAA_SYM_EXISTS zend_symtable_exists
37
- # define PAA_SYM_DEL zend_symtable_del
38
- # define PAA_LONG long
39
- # define PAA_ULONG ulong
40
- #endif
41
33
42
34
/* *
43
35
* All APIs in this file follow a general format:
@@ -89,15 +81,9 @@ zend_bool php_array_exists(zval *zarr, const char *key) {
89
81
PAA_SYM_EXISTS (Z_ARRVAL_P(zarr), key, PAA_LENGTH_ADJ(len))
90
82
static inline
91
83
zend_bool php_array_existsl_safe(zval *zarr, const char *key, int key_len) {
92
- #ifdef ZEND_ENGINE_3
93
84
zend_string *keystr = zend_string_init (key, key_len, 0 );
94
85
zend_bool ret = zend_symtable_exists (Z_ARRVAL_P (zarr), keystr);
95
86
zend_string_release (keystr);
96
- #else
97
- char *k = estrndup (key, key_len);
98
- zend_bool ret = zend_symtable_exists (Z_ARRVAL_P (zarr), k, key_len + 1 );
99
- efree (k);
100
- #endif
101
87
return ret;
102
88
}
103
89
#define php_array_existsn (zarr, idx ) \
@@ -107,14 +93,10 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
107
93
switch (Z_TYPE_P (key)) {
108
94
case IS_NULL:
109
95
return php_array_existsc (zarr, " " );
110
- #ifdef ZEND_ENGINE_3
111
96
case IS_FALSE:
112
97
return zend_hash_index_exists (Z_ARRVAL_P (zarr), 0 );
113
98
case IS_TRUE:
114
99
return zend_hash_index_exists (Z_ARRVAL_P (zarr), 1 );
115
- #else
116
- case IS_BOOL: /* fallthrough */
117
- #endif
118
100
case IS_LONG:
119
101
return zend_hash_index_exists (Z_ARRVAL_P (zarr), Z_LVAL_P (key));
120
102
case IS_DOUBLE:
@@ -174,17 +156,7 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
174
156
*/
175
157
static inline
176
158
zval *php_array_fetchl (zval *zarr, const char *key, int key_len) {
177
- #ifdef ZEND_ENGINE_3
178
159
return zend_symtable_str_find (Z_ARRVAL_P (zarr), key, key_len);
179
- #else
180
- zval **ppzval;
181
- if (FAILURE == zend_symtable_find (Z_ARRVAL_P (zarr),
182
- key, key_len + 1 ,
183
- (void **)&ppzval)) {
184
- return NULL ;
185
- }
186
- return *ppzval;
187
- #endif
188
160
}
189
161
static inline
190
162
zval *php_array_fetch (zval *zarr, const char *key) {
@@ -193,43 +165,24 @@ zval *php_array_fetch(zval *zarr, const char *key) {
193
165
#define php_array_fetchc (zarr, litstr ) php_array_fetchl(zarr, litstr, sizeof (litstr)-1 )
194
166
static inline
195
167
zval *php_array_fetchl_safe (zval *zarr, const char *key, int key_len) {
196
- #ifdef ZEND_ENGINE_3
197
168
zend_string *keystr = zend_string_init (key, key_len, 0 );
198
169
zval *ret = zend_symtable_find (Z_ARRVAL_P (zarr), keystr);
199
170
zend_string_release (keystr);
200
- #else
201
- char *k = estrndup (key, key_len);
202
- zval *ret = php_array_fetchl (zarr, k, key_len);
203
- efree (k);
204
- #endif
205
171
return ret;
206
172
}
207
173
static inline
208
174
zval *php_array_fetchn (zval *zarr, PAA_ULONG idx) {
209
- #ifdef ZEND_ENGINE_3
210
175
return zend_hash_index_find (Z_ARRVAL_P (zarr), idx);
211
- #else
212
- zval **ppzval;
213
- if (FAILURE == zend_hash_index_find (Z_ARRVAL_P (zarr),
214
- idx, (void **)&ppzval)) {
215
- return NULL ;
216
- }
217
- return *ppzval;
218
- #endif
219
176
}
220
177
static inline
221
178
zval *php_array_fetchz (zval *zarr, zval *key) {
222
179
switch (Z_TYPE_P (key)) {
223
180
case IS_NULL:
224
181
return php_array_fetchn (zarr, 0 );
225
- #ifdef ZEND_ENGINE_3
226
182
case IS_FALSE:
227
183
return php_array_fetchn (zarr, 0 );
228
184
case IS_TRUE:
229
185
return php_array_fetchn (zarr, 1 );
230
- #else
231
- case IS_BOOL: /* fallthrough */
232
- #endif
233
186
case IS_LONG:
234
187
return php_array_fetchn (zarr, Z_LVAL_P (key));
235
188
case IS_DOUBLE:
@@ -288,12 +241,8 @@ PAA_LONG php_array_zval_to_long(zval *z) {
288
241
ZVAL_DEREF (z);
289
242
goto try_again;
290
243
case IS_NULL: return 0 ;
291
- #ifdef ZEND_ENGINE_3
292
244
case IS_FALSE: return 0 ;
293
245
case IS_TRUE: return 1 ;
294
- #else
295
- case IS_BOOL: return Z_BVAL_P (z);
296
- #endif
297
246
case IS_LONG: return Z_LVAL_P (z);
298
247
default :
299
248
{
@@ -326,12 +275,8 @@ double php_array_zval_to_double(zval *z) {
326
275
ZVAL_DEREF (z);
327
276
goto try_again;
328
277
case IS_NULL: return 0.0 ;
329
- #ifdef ZEND_ENGINE_3
330
278
case IS_FALSE: return 0.0 ;
331
279
case IS_TRUE: return 1.0 ;
332
- #else
333
- case IS_BOOL: return (double )Z_BVAL_P (z);
334
- #endif
335
280
case IS_LONG: return (double )Z_LVAL_P (z);
336
281
case IS_DOUBLE: return Z_DVAL_P (z);
337
282
default :
@@ -381,11 +326,7 @@ char *php_array_zval_to_string(zval *z, int *plen, zend_bool *pfree) {
381
326
zval c = *z;
382
327
zval_copy_ctor (&c);
383
328
convert_to_string (&c);
384
- #ifdef ZEND_ENGINE_3
385
329
*pfree = ! IS_INTERNED (Z_STR (c));
386
- #else
387
- *pfree = ! IS_INTERNED (Z_STRVAL (c));
388
- #endif
389
330
*plen = Z_STRLEN (c);
390
331
return Z_STRVAL (c);
391
332
}
@@ -454,18 +395,7 @@ PHP_ARRAY_FETCH_TYPE_MAP(zval*, array)
454
395
*/
455
396
static inline
456
397
void *php_array_zval_to_resource (zval *z, int le) {
457
- #ifdef ZEND_ENGINE_3
458
398
return zend_fetch_resource_ex (z, NULL , le);
459
- #else
460
- void *ret;
461
- int rtype;
462
- if (!z || Z_TYPE_P (z) != IS_RESOURCE) { return NULL ; }
463
- ret = zend_list_find (Z_RESVAL_P (z), &rtype);
464
- if (!ret || (rtype != le)) {
465
- return NULL ;
466
- }
467
- return ret;
468
- #endif
469
399
}
470
400
#define php_array_fetch_resource (zarr, key, le ) \
471
401
php_array_zval_to_resource (php_array_fetch(zarr, key), le)
@@ -543,16 +473,12 @@ static inline void php_array_unsetz(zval *zarr, zval *key) {
543
473
case IS_NULL:
544
474
zend_hash_index_del (Z_ARRVAL_P (zarr), 0 );
545
475
return ;
546
- #ifdef ZEND_ENGINE_3
547
476
case IS_FALSE:
548
477
zend_hash_index_del (Z_ARRVAL_P (zarr), 0 );
549
478
return ;
550
479
case IS_TRUE:
551
480
zend_hash_index_del (Z_ARRVAL_P (zarr), 1 );
552
481
return ;
553
- #else
554
- case IS_BOOL: /* fallthrough */
555
- #endif
556
482
case IS_LONG:
557
483
zend_hash_index_del (Z_ARRVAL_P (zarr), Z_LVAL_P (key));
558
484
return ;
0 commit comments