Skip to content

Commit 00a2cd1

Browse files
committed
Move spl_offset_convert_to_long() to spl_fixedarray.c
It is only used there, which explains its weird offset semantics
1 parent acb7803 commit 00a2cd1

File tree

5 files changed

+30
-63
lines changed

5 files changed

+30
-63
lines changed

ext/spl/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
1+
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
22
PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
33
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
44
PHP_ADD_EXTENSION_DEP(spl, standard, true)

ext/spl/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vim:ft=javascript
22

3-
EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
3+
EXTENSION("spl", "php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
44
PHP_SPL="yes";
55
PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");

ext/spl/spl_engine.c

Lines changed: 0 additions & 59 deletions
This file was deleted.

ext/spl/spl_engine.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#include "php_spl.h"
2222
#include "zend_interfaces.h"
2323

24-
PHPAPI zend_long spl_offset_convert_to_long(zval *offset);
25-
2624
static inline void spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
2725
{
2826
object_init_ex(retval, pce);

ext/spl/spl_fixedarray.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,34 @@ static zend_object *spl_fixedarray_object_clone(zend_object *old_object)
309309
return new_object;
310310
}
311311

312+
static zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */
313+
{
314+
zend_ulong idx;
315+
316+
try_again:
317+
switch (Z_TYPE_P(offset)) {
318+
case IS_STRING:
319+
if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), idx)) {
320+
return idx;
321+
}
322+
break;
323+
case IS_DOUBLE:
324+
return zend_dval_to_lval_safe(Z_DVAL_P(offset));
325+
case IS_LONG:
326+
return Z_LVAL_P(offset);
327+
case IS_FALSE:
328+
return 0;
329+
case IS_TRUE:
330+
return 1;
331+
case IS_REFERENCE:
332+
offset = Z_REFVAL_P(offset);
333+
goto try_again;
334+
case IS_RESOURCE:
335+
return Z_RES_HANDLE_P(offset);
336+
}
337+
return -1;
338+
}
339+
312340
static zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_object *intern, zval *offset)
313341
{
314342
zend_long index;

0 commit comments

Comments
 (0)