Browse Source

Merge branch 'PHP-7.0' of git.php.net:php-src into PHP-7.0

* 'PHP-7.0' of git.php.net:php-src:
  Drop HAVE_PACKED_OBJECT_VALUE
  More zpp cleanup in ext/intl
pull/1557/head
Dmitry Stogov 10 years ago
parent
commit
2c92f33b1d
  1. 44
      ext/intl/calendar/calendar_methods.cpp
  2. 3
      ext/intl/tests/calendar_clear_error.phpt
  3. 4
      ext/intl/timezone/timezone_methods.cpp
  4. 20
      ext/spl/config.m4
  5. 40
      ext/spl/spl_observer.c

44
ext/intl/calendar/calendar_methods.cpp

@ -522,48 +522,28 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
U_CFUNC PHP_FUNCTION(intlcal_clear)
{
zval args_a[2] = {0},
*args = &args_a[0];
zend_long field;
int variant;
zend_long field;
zend_bool field_is_null = 1;
CALENDAR_METHOD_INIT_VARS;
if (ZEND_NUM_ARGS() > (getThis() ? 1 : 2) ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: too many arguments", 0);
RETURN_FALSE;
}
if (!getThis()) {
args++;
}
if (Z_ISUNDEF(args[0]) || Z_TYPE(args[0]) == IS_NULL) {
zval *dummy; /* we know it's null */
if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
getThis(), "O|z", &object, Calendar_ce_ptr, &dummy) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: bad arguments", 0);
RETURN_FALSE;
}
variant = 0;
} else if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
getThis(), "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
getThis(), "O|l!", &object, Calendar_ce_ptr, &field, &field_is_null) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: bad arguments", 0);
RETURN_FALSE;
} else if (field < 0 || field >= UCAL_FIELD_COUNT) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: invalid field", 0);
RETURN_FALSE;
} else {
variant = 1;
}
CALENDAR_METHOD_FETCH_OBJECT;
if (variant == 0) {
if (field_is_null) {
co->ucal->clear();
} else {
if (field < 0 || field >= UCAL_FIELD_COUNT) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: invalid field", 0);
RETURN_FALSE;
}
co->ucal->clear((UCalendarDateFields)field);
}
@ -614,7 +594,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum)
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
{
zend_ulong dow;
zend_long dow;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),

3
ext/intl/tests/calendar_clear_error.phpt

@ -18,8 +18,9 @@ var_dump($c->clear(-1));
var_dump(intlcal_clear($c, -1));
var_dump(intlcal_clear(1, 2));
--EXPECTF--
Warning: IntlCalendar::clear() expects at most 1 parameter, 2 given in %s on line %d
Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d
Warning: IntlCalendar::clear(): intlcal_clear: bad arguments in %s on line %d
bool(false)
Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d

4
ext/intl/timezone/timezone_methods.cpp

@ -440,7 +440,7 @@ U_CFUNC PHP_FUNCTION(intltz_use_daylight_time)
U_CFUNC PHP_FUNCTION(intltz_get_offset)
{
UDate date;
double date;
zend_bool local;
zval *rawOffsetArg,
*dstOffsetArg;
@ -458,7 +458,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_offset)
TIMEZONE_METHOD_FETCH_OBJECT;
to->utimezone->getOffset(date, (UBool) local, rawOffset, dstOffset,
to->utimezone->getOffset((UDate) date, (UBool) local, rawOffset, dstOffset,
TIMEZONE_ERROR_CODE(to));
INTL_METHOD_CHECK_STATUS(to, "intltz_get_offset: error obtaining offset");

20
ext/spl/config.m4

@ -1,26 +1,6 @@
dnl $Id$
dnl config.m4 for extension SPL
AC_MSG_CHECKING(whether zend_object_value is packed)
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$INCLUDES -I$abs_srcdir $CPPFLAGS"
AC_TRY_RUN([
#include "Zend/zend_types.h"
int main(int argc, char **argv) {
return ((sizeof(zend_object_handle) + sizeof(zend_object_handlers*)) == sizeof(zend_object_value)) ? 0 : 1;
}
], [
ac_result=1
AC_MSG_RESULT(yes)
],[
ac_result=0
AC_MSG_RESULT(no)
], [
ac_result=0
AC_MSG_RESULT(no)
])
CPPFLAGS=$old_CPPFLAGS
AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
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)
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])

40
ext/spl/spl_observer.c

@ -90,7 +90,7 @@ typedef struct _spl_SplObjectStorage { /* {{{ */
zend_object std;
} spl_SplObjectStorage; /* }}} */
/* {{{ storage is an assoc aray of [zend_object_value]=>[zval *obj, zval *inf] */
/* {{{ storage is an assoc aray of [zend_object*]=>[zval *obj, zval *inf] */
typedef struct _spl_SplObjectStorageElement {
zval obj;
zval inf;
@ -138,49 +138,11 @@ static zend_string *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zv
memcpy(ZSTR_VAL(hash), (void*)&Z_OBJ_P(obj), sizeof(zend_object*));
ZSTR_VAL(hash)[ZSTR_LEN(hash)] = '\0';
return hash;
/* !!! FIXME
int hash_len = sizeof(zend_object_value);
#if HAVE_PACKED_OBJECT_VALUE
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return (char*)&Z_OBJVAL_P(obj);
#else
char *hash = emalloc(hash_len + 1);
zend_object_value zvalue;
memset(&zvalue, 0, sizeof(zend_object_value));
zvalue.handle = Z_OBJ_HANDLE_P(obj);
zvalue.handlers = Z_OBJ_HT_P(obj);
memcpy(hash, (char *)&zvalue, hash_len);
hash[hash_len] = 0;
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return hash;
#endif
*/
return NULL;
}
}
static void spl_object_storage_free_hash(spl_SplObjectStorage *intern, zend_string *hash) {
zend_string_release(hash);
/*
if (intern->fptr_get_hash) {
} else {
#if HAVE_PACKED_OBJECT_VALUE
#else
efree(hash);
#endif
}
*/
}
static void spl_object_storage_dtor(zval *element) /* {{{ */

Loading…
Cancel
Save