1
1
/* +----------------------------------------------------------------------+
2
- | PHP Version 5 |
2
+ | PHP Version 7 |
3
3
+----------------------------------------------------------------------+
4
- | Copyright (c) 1997-2013 The PHP Group |
4
+ | Copyright (c) 1997-2018 The PHP Group |
5
5
+----------------------------------------------------------------------+
6
6
| This source file is subject to version 3.01 of the PHP license, |
7
7
| that is bundled with this package in the file LICENSE, and is |
29
29
# define PAA_LENGTH_ADJ (l ) (l)
30
30
# define PAA_SYM_EXISTS zend_symtable_str_exists
31
31
# define PAA_SYM_DEL zend_symtable_str_del
32
+ # define PAA_LONG zend_long
33
+ # define PAA_ULONG zend_ulong
32
34
#else
33
35
# define PAA_LENGTH_ADJ (l ) (l+1)
34
36
# define PAA_SYM_EXISTS zend_symtable_exists
35
37
# define PAA_SYM_DEL zend_symtable_del
38
+ # define PAA_LONG long
39
+ # define PAA_ULONG ulong
36
40
#endif
37
41
38
42
/**
72
76
* zend_bool php_array_existsc(zval *zarr, const char *litstr)
73
77
* zend_bool php_array_existsl(zval *zarr, const char *key, int key_len)
74
78
* zend_bool php_array_existsl_safe(zval *zarr, const char *key, int key_len)
75
- * zend_bool php_array_existsn(zval *zarr, long idx)
79
+ * zend_bool php_array_existsn(zval *zarr, unsigned long idx)
76
80
* zend_bool php_array_existsz(zval *zarr, zval *key)
77
81
*/
78
82
static inline
@@ -153,7 +157,7 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
153
157
* NULL terminated string key of known length
154
158
* php_array_fetchl_safe_T(zval *zarr, const char *key, int key_len, ...)
155
159
* String key of known length, may not be NULL terminated
156
- * php_array_fetchn_T(zval *zarr, long idx, ...)
160
+ * php_array_fetchn_T(zval *zarr, unsigned long idx, ...)
157
161
* Numeric key
158
162
* php_array_fetchz_T(zval *zarr, zval *key, ...)
159
163
* zval* key
@@ -164,7 +168,7 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
164
168
* zval *php_array_fetch(zval *zarr, const char *key)
165
169
* zval *php_array_fetchl(zval *zarr, const char *key, int key_len)
166
170
* zval *php_array_fetchl_safe(zval *zarr, const char *key, int key_len)
167
- * zval *php_array_fetchn(zval *zarr, long idx)
171
+ * zval *php_array_fetchn(zval *zarr, unsigned long idx)
168
172
* zval *php_array_fetchc(zval *zarr, const char *litstr)
169
173
* zval *php_array_fetchz(zval *zarr, zval *key)
170
174
*/
@@ -201,7 +205,7 @@ zval *php_array_fetchl_safe(zval *zarr, const char *key, int key_len) {
201
205
return ret ;
202
206
}
203
207
static inline
204
- zval * php_array_fetchn (zval * zarr , long idx ) {
208
+ zval * php_array_fetchn (zval * zarr , PAA_ULONG idx ) {
205
209
#ifdef ZEND_ENGINE_3
206
210
return zend_hash_index_find (Z_ARRVAL_P (zarr ), idx );
207
211
#else
@@ -244,7 +248,7 @@ static inline ctype php_array_fetchl_##ztype(zval *zarr, const char *key, int ke
244
248
{ return php_array_zval_to_##ztype(php_array_fetchl(zarr, key, key_len)); } \
245
249
static inline ctype php_array_fetchl_safe_##ztype(zval *zarr, const char *key, int key_len) \
246
250
{ return php_array_zval_to_##ztype(php_array_fetchl_safe(zarr, key, key_len)); } \
247
- static inline ctype php_array_fetchn_##ztype(zval *zarr, long idx) \
251
+ static inline ctype php_array_fetchn_##ztype(zval *zarr, PAA_ULONG idx) \
248
252
{ return php_array_zval_to_##ztype(php_array_fetchn(zarr, idx)); } \
249
253
static inline ctype php_array_fetchz_##ztype(zval *zarr, zval *key) \
250
254
{ return php_array_zval_to_##ztype(php_array_fetchz(zarr, key)); }
@@ -254,7 +258,7 @@ static inline ctype php_array_fetchz_##ztype(zval *zarr, zval *key) \
254
258
* zend_bool php_array_fetch_bool(zval *zarr, const char *key)
255
259
* zend_bool php_array_fetchl_bool(zval *zarr, const char *key, int key_len)
256
260
* zend_bool php_array_fetchl_safe_bool(zval *zarr, const char *key, int key_len)
257
- * zend_bool php_array_fetchn_bool(zval *zarr, long idx)
261
+ * zend_bool php_array_fetchn_bool(zval *zarr, unsigned long idx)
258
262
* zend_bool php_array_fetchc_bool(zval *zarr, const char *litstr)
259
263
* zend_bool php_array_fetchz_bool(zval *zarr, zval *key)
260
264
*/
@@ -271,12 +275,12 @@ PHP_ARRAY_FETCH_TYPE_MAP(zend_bool, bool)
271
275
* long php_array_fetch_long(zval *zarr, const char *key)
272
276
* long php_array_fetchl_long(zval *zarr, const char *key, int key_len)
273
277
* long php_array_fetchl_safe_long(zval *zarr, const char *key, int key_len)
274
- * long php_array_fetchn_long(zval *zarr, long idx)
278
+ * long php_array_fetchn_long(zval *zarr, unsigned long idx)
275
279
* long php_array_fetchc_long(zval *zarr, const char *litstr)
276
280
* long php_array_fetchz_long(zval *zarr, zval *key)
277
281
*/
278
282
static inline
279
- long php_array_zval_to_long (zval * z ) {
283
+ PAA_LONG php_array_zval_to_long (zval * z ) {
280
284
if (!z ) { return 0 ; }
281
285
switch (Z_TYPE_P (z )) {
282
286
case IS_NULL : return 0 ;
@@ -287,7 +291,6 @@ long php_array_zval_to_long(zval *z) {
287
291
case IS_BOOL : return Z_BVAL_P (z );
288
292
#endif
289
293
case IS_LONG : return Z_LVAL_P (z );
290
- case IS_DOUBLE : return (long )Z_DVAL_P (z );
291
294
default :
292
295
{
293
296
zval c = * z ;
@@ -297,7 +300,7 @@ long php_array_zval_to_long(zval *z) {
297
300
}
298
301
}
299
302
}
300
- PHP_ARRAY_FETCH_TYPE_MAP (long , long )
303
+ PHP_ARRAY_FETCH_TYPE_MAP (PAA_LONG , long )
301
304
#define php_array_fetchc_long (zarr , litstr ) \
302
305
php_array_zval_to_long(php_array_fetchc(zarr, litstr))
303
306
@@ -306,7 +309,7 @@ PHP_ARRAY_FETCH_TYPE_MAP(long, long)
306
309
* double php_array_fetch_double(zval *zarr, const char *key)
307
310
* double php_array_fetchl_double(zval *zarr, const char *key, int key_len)
308
311
* double php_array_fetchl_safe_double(zval *zarr, const char *key, int key_len)
309
- * double php_array_fetchn_double(zval *zarr, long idx)
312
+ * double php_array_fetchn_double(zval *zarr, unsigned long idx)
310
313
* double php_array_fetchc_double(zval *zarr, const char *litstr)
311
314
* double php_array_fetchz_double(zval *zarr, zval *key)
312
315
*/
@@ -346,7 +349,7 @@ PHP_ARRAY_FETCH_TYPE_MAP(double, double)
346
349
* char *php_array_fetch_string(zval *zarr, const char *key, int *plen, zend_bool *pfree)
347
350
* char *php_array_fetchl_string(zval *zarr, const char *key, int key_len, int *plen, zend_bool *pfree)
348
351
* char *php_array_fetchl_safe_string(zval *zarr, const char *key, int key_len, int *plen, zend_bool *pfree)
349
- * char *php_array_fetchn_string(zval *zarr, long idx, int *plen, zend_bool *pfree)
352
+ * char *php_array_fetchn_string(zval *zarr, unsigned long idx, int *plen, zend_bool *pfree)
350
353
* char *php_array_fetchc_string(zval *zarr, const char *litstr, int *plen, zend_bool *pfree)
351
354
* char *php_array_fetchz_string(zval *zarr, zval *key, int *plen, zend_bool *pfree)
352
355
*/
@@ -400,7 +403,7 @@ char *php_array_zval_to_string(zval *z, int *plen, zend_bool *pfree) {
400
403
* zval *php_array_fetch_array(zval *zarr, const char *key)
401
404
* zval *php_array_fetchl_array(zval *zarr, const char *key, int key_len)
402
405
* zval *php_array_fetchl_safe_array(zval *zarr, const char *key, int key_len)
403
- * zval *php_array_fetchn_array(zval *zarr, long idx)
406
+ * zval *php_array_fetchn_array(zval *zarr, unsigned long idx)
404
407
* zval *php_array_fetchc_array(zval *zarr, const char *litstr)
405
408
* zval *php_array_fetchz_array(zval *zarr, zval *key)
406
409
*/
@@ -431,7 +434,7 @@ PHP_ARRAY_FETCH_TYPE_MAP(zval*, array)
431
434
* zval *php_array_fetch_resource(zval *zarr, const char *key, int le)
432
435
* zval *php_array_fetchl_resource(zval *zarr, const char *key, int key_len, int le)
433
436
* zval *php_array_fetchl_safe_resource(zval *zarr, const char *key, int key_len, int le)
434
- * zval *php_array_fetchn_resource(zval *zarr, long idx, int le)
437
+ * zval *php_array_fetchn_resource(zval *zarr, unsigned long idx, int le)
435
438
* zval *php_array_fetchc_resource(zval *zarr, const char *litstr, int le)
436
439
* zval *php_array_fetchz_resource(zval *zarr, zval *key, int le)
437
440
*/
@@ -472,7 +475,7 @@ void *php_array_zval_to_resource(zval *z, int le TSRMLS_DC) {
472
475
* zval *php_array_fetch_object(zval *zarr, const char *key, zend_class_entry *ce)
473
476
* zval *php_array_fetchl_object(zval *zarr, const char *key, int key_len, zend_class_entry *ce)
474
477
* zval *php_array_fetchl_safe_object(zval *zarr, const char *key, int key_len, zend_class_entry *ce)
475
- * zval *php_array_fetchn_object(zval *zarr, long idx, zend_class_entry *ce)
478
+ * zval *php_array_fetchn_object(zval *zarr, unsigned long idx, zend_class_entry *ce)
476
479
* zval *php_array_fetchc_object(zval *zarr, const char *litstr, zend_class_entry *ce)
477
480
* zval *php_array_fetchz_object(zval *zarr, zval *key, zend_class_entry *ce)
478
481
*/
@@ -517,13 +520,8 @@ void php_array_unsetl_safe(zval *zarr, const char *key, int key_len) {
517
520
}
518
521
#define php_array_unsetn (zarr , idx ) \
519
522
zend_symtable_index_del(Z_ARRVAL_P(zarr), idx)
520
- #ifdef ZEND_ENGINE_3
521
- # define php_array_unsetc (zarr , litstr ) \
522
- zend_symtable_str_del(Z_ARRVAL_P(zarr), litstr, PAA_LENGTH_ADJ(sizeof(litstr) - 1))
523
- #else
524
- # define php_array_unsetc (zarr , litstr ) \
525
- zend_symtable_del(Z_ARRVAL_P(zarr), litstr, PAA_LENGTH_ADJ(sizeof(litstr) - 1))
526
- #endif
523
+ #define php_array_unsetc (zarr , litstr ) \
524
+ PAA_SYM_DEL(Z_ARRVAL_P(zarr), litstr, PAA_LENGTH_ADJ(sizeof(litstr) - 1))
527
525
static inline void php_array_unsetz (zval * zarr , zval * key ) {
528
526
switch (Z_TYPE_P (key )) {
529
527
case IS_NULL :
0 commit comments