diff options
Diffstat (limited to 'ext/intl/timezone/timezone_methods.cpp')
-rw-r--r-- | ext/intl/timezone/timezone_methods.cpp | 314 |
1 files changed, 152 insertions, 162 deletions
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index 9ca6b44c89..a35174d3da 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -41,19 +41,18 @@ U_CFUNC PHP_METHOD(IntlTimeZone, __construct) { zend_throw_exception( NULL, "An object of this type cannot be created with the new operator", - 0 TSRMLS_CC ); + 0 ); } U_CFUNC PHP_FUNCTION(intltz_create_time_zone) { char *str_id; - int str_id_len; - intl_error_reset(NULL TSRMLS_CC); + size_t str_id_len; + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &str_id, &str_id_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str_id, &str_id_len) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_time_zone: bad arguments", 0 TSRMLS_CC); + "intltz_create_time_zone: bad arguments", 0); RETURN_NULL(); } @@ -61,13 +60,13 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone) UnicodeString id = UnicodeString(); if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "intltz_create_time_zone: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + "intltz_create_time_zone: could not convert time zone id to UTF-16", 0); RETURN_NULL(); } //guaranteed non-null; GMT if timezone cannot be understood TimeZone *tz = TimeZone::createTimeZone(id); - timezone_object_construct(tz, return_value, 1 TSRMLS_CC); + timezone_object_construct(tz, return_value, 1); } U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone) @@ -75,135 +74,133 @@ U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone) zval *zv_timezone; TimeZone *tz; php_timezone_obj *tzobj; - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zv_timezone, php_date_get_timezone_ce()) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_from_date_time_zone: bad arguments", 0 TSRMLS_CC); + "intltz_from_date_time_zone: bad arguments", 0); RETURN_NULL(); } - tzobj = (php_timezone_obj *)zend_objects_get_address(zv_timezone TSRMLS_CC); + tzobj = Z_PHPTIMEZONE_P(zv_timezone); if (!tzobj->initialized) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_from_date_time_zone: DateTimeZone object is unconstructed", - 0 TSRMLS_CC); + 0); RETURN_NULL(); } tz = timezone_convert_datetimezone(tzobj->type, tzobj, FALSE, NULL, - "intltz_from_date_time_zone" TSRMLS_CC); + "intltz_from_date_time_zone"); if (tz == NULL) { RETURN_NULL(); } - timezone_object_construct(tz, return_value, 1 TSRMLS_CC); + timezone_object_construct(tz, return_value, 1); } U_CFUNC PHP_FUNCTION(intltz_create_default) { - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_default: bad arguments", 0 TSRMLS_CC); + "intltz_create_default: bad arguments", 0); RETURN_NULL(); } TimeZone *tz = TimeZone::createDefault(); - timezone_object_construct(tz, return_value, 1 TSRMLS_CC); + timezone_object_construct(tz, return_value, 1); } U_CFUNC PHP_FUNCTION(intltz_get_gmt) { - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_gmt: bad arguments", 0 TSRMLS_CC); + "intltz_get_gmt: bad arguments", 0); RETURN_NULL(); } - timezone_object_construct(TimeZone::getGMT(), return_value, 0 TSRMLS_CC); + timezone_object_construct(TimeZone::getGMT(), return_value, 0); } #if U_ICU_VERSION_MAJOR_NUM >= 49 U_CFUNC PHP_FUNCTION(intltz_get_unknown) { - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_unknown: bad arguments", 0 TSRMLS_CC); + "intltz_get_unknown: bad arguments", 0); RETURN_NULL(); } - timezone_object_construct(&TimeZone::getUnknown(), return_value, 0 TSRMLS_CC); + timezone_object_construct(&TimeZone::getUnknown(), return_value, 0); } #endif U_CFUNC PHP_FUNCTION(intltz_create_enumeration) { - zval **arg = NULL; + zval *arg = NULL; StringEnumeration *se = NULL; - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); /* double indirection to have the zend engine destroy the new zval that * results from separation */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z", &arg) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_enumeration: bad arguments", 0 TSRMLS_CC); + "intltz_create_enumeration: bad arguments", 0); RETURN_FALSE; } - if (arg == NULL || Z_TYPE_PP(arg) == IS_NULL) { + if (arg == NULL || Z_TYPE_P(arg) == IS_NULL) { se = TimeZone::createEnumeration(); - } else if (Z_TYPE_PP(arg) == IS_LONG) { + } else if (Z_TYPE_P(arg) == IS_LONG) { int_offset: - if (Z_LVAL_PP(arg) < (long)INT32_MIN || - Z_LVAL_PP(arg) > (long)INT32_MAX) { + if (Z_LVAL_P(arg) < (zend_long)INT32_MIN || + Z_LVAL_P(arg) > (zend_long)INT32_MAX) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_enumeration: value is out of range", 0 TSRMLS_CC); + "intltz_create_enumeration: value is out of range", 0); RETURN_FALSE; } else { - se = TimeZone::createEnumeration((int32_t) Z_LVAL_PP(arg)); + se = TimeZone::createEnumeration((int32_t) Z_LVAL_P(arg)); } - } else if (Z_TYPE_PP(arg) == IS_DOUBLE) { + } else if (Z_TYPE_P(arg) == IS_DOUBLE) { double_offset: convert_to_long_ex(arg); goto int_offset; - } else if (Z_TYPE_PP(arg) == IS_OBJECT || Z_TYPE_PP(arg) == IS_STRING) { - long lval; + } else if (Z_TYPE_P(arg) == IS_OBJECT || Z_TYPE_P(arg) == IS_STRING) { + zend_long lval; double dval; convert_to_string_ex(arg); - switch (is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &lval, &dval, 0)) { + switch (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, 0)) { case IS_DOUBLE: SEPARATE_ZVAL(arg); - zval_dtor(*arg); - Z_TYPE_PP(arg) = IS_DOUBLE; - Z_DVAL_PP(arg) = dval; + zval_dtor(arg); + ZVAL_DOUBLE(arg, dval); goto double_offset; case IS_LONG: SEPARATE_ZVAL(arg); - zval_dtor(*arg); - Z_TYPE_PP(arg) = IS_LONG; - Z_LVAL_PP(arg) = lval; + zval_dtor(arg); + ZVAL_LONG(arg, lval); goto int_offset; } /* else call string version */ - se = TimeZone::createEnumeration(Z_STRVAL_PP(arg)); + se = TimeZone::createEnumeration(Z_STRVAL_P(arg)); } else { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_enumeration: invalid argument type", 0 TSRMLS_CC); + "intltz_create_enumeration: invalid argument type", 0); RETURN_FALSE; } if (se) { - IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC); + IntlIterator_from_StringEnumeration(se, return_value); } else { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_enumeration: error obtaining enumeration", 0 TSRMLS_CC); + "intltz_create_enumeration: error obtaining enumeration", 0); RETVAL_FALSE; } } @@ -211,13 +208,13 @@ double_offset: U_CFUNC PHP_FUNCTION(intltz_count_equivalent_ids) { char *str_id; - int str_id_len; - intl_error_reset(NULL TSRMLS_CC); + size_t str_id_len; + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str_id, &str_id_len) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_count_equivalent_ids: bad arguments", 0 TSRMLS_CC); + "intltz_count_equivalent_ids: bad arguments", 0); RETURN_FALSE; } @@ -225,59 +222,50 @@ U_CFUNC PHP_FUNCTION(intltz_count_equivalent_ids) UnicodeString id = UnicodeString(); if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "intltz_count_equivalent_ids: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + "intltz_count_equivalent_ids: could not convert time zone id to UTF-16", 0); RETURN_FALSE; } int32_t result = TimeZone::countEquivalentIDs(id); - RETURN_LONG((long)result); + RETURN_LONG((zend_long)result); } #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) { - long zoneType, - offset_arg; - char *region = NULL; - int region_len = 0; - int32_t offset, - *offsetp = NULL; - int arg3isnull = 0; - intl_error_reset(NULL TSRMLS_CC); - - /* must come before zpp because zpp would convert the arg in the stack to 0 */ - if (ZEND_NUM_ARGS() == 3) { - zval **dummy, **zvoffset; - arg3isnull = zend_get_parameters_ex(3, &dummy, &dummy, &zvoffset) - != FAILURE && Z_TYPE_PP(zvoffset) == IS_NULL; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s!l", - &zoneType, ®ion, ®ion_len, &offset_arg) == FAILURE) { + zend_long zoneType, + offset_arg; + char *region = NULL; + size_t region_len = 0; + int32_t offset, + *offsetp = NULL; + zend_bool arg3isnull = 1; + + intl_error_reset(NULL); + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s!l!", + &zoneType, ®ion, ®ion_len, &offset_arg, &arg3isnull) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_time_zone_id_enumeration: bad arguments", 0 TSRMLS_CC); + "intltz_create_time_zone_id_enumeration: bad arguments", 0); RETURN_FALSE; } if (zoneType != UCAL_ZONE_TYPE_ANY && zoneType != UCAL_ZONE_TYPE_CANONICAL && zoneType != UCAL_ZONE_TYPE_CANONICAL_LOCATION) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_time_zone_id_enumeration: bad zone type", 0 TSRMLS_CC); + "intltz_create_time_zone_id_enumeration: bad zone type", 0); RETURN_FALSE; } - if (ZEND_NUM_ARGS() == 3) { - if (offset_arg < (long)INT32_MIN || offset_arg > (long)INT32_MAX) { + if (!arg3isnull) { + if (offset_arg < (zend_long)INT32_MIN || offset_arg > (zend_long)INT32_MAX) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_create_time_zone_id_enumeration: offset out of bounds", 0 TSRMLS_CC); + "intltz_create_time_zone_id_enumeration: offset out of bounds", 0); RETURN_FALSE; } - - if (!arg3isnull) { - offset = (int32_t)offset_arg; - offsetp = &offset; - } //else leave offsetp NULL - } + offset = (int32_t)offset_arg; + offsetp = &offset; + } //else leave offsetp NULL StringEnumeration *se; UErrorCode uec = UErrorCode(); @@ -286,21 +274,21 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) INTL_CHECK_STATUS(uec, "intltz_create_time_zone_id_enumeration: " "Error obtaining time zone id enumeration") - IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC); + IntlIterator_from_StringEnumeration(se, return_value); } #endif U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) { char *str_id; - int str_id_len; + size_t str_id_len; zval *is_systemid = NULL; - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z", &str_id, &str_id_len, &is_systemid) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_canonical_id: bad arguments", 0 TSRMLS_CC); + "intltz_get_canonical_id: bad arguments", 0); RETURN_FALSE; } @@ -308,7 +296,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "intltz_get_canonical_id: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + "intltz_get_canonical_id: could not convert time zone id to UTF-16", 0); RETURN_FALSE; } @@ -316,14 +304,14 @@ U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) UBool isSystemID; TimeZone::getCanonicalID(id, result, isSystemID, status); INTL_CHECK_STATUS(status, "intltz_get_canonical_id: error obtaining canonical ID"); - - intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), - result.getBuffer(), result.length(), &status); + + zend_string *u8str =intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), &status); INTL_CHECK_STATUS(status, "intltz_get_canonical_id: could not convert time zone id to UTF-16"); - Z_TYPE_P(return_value) = IS_STRING; - + RETVAL_NEW_STR(u8str); + if (is_systemid) { /* by-ref argument passed */ + ZVAL_DEREF(is_systemid); zval_dtor(is_systemid); ZVAL_BOOL(is_systemid, isSystemID); } @@ -333,14 +321,14 @@ U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) U_CFUNC PHP_FUNCTION(intltz_get_region) { char *str_id; - int str_id_len; - char outbuf[3]; - intl_error_reset(NULL TSRMLS_CC); + size_t str_id_len; + char outbuf[3]; + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str_id, &str_id_len) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_region: bad arguments", 0 TSRMLS_CC); + "intltz_get_region: bad arguments", 0); RETURN_FALSE; } @@ -348,24 +336,24 @@ U_CFUNC PHP_FUNCTION(intltz_get_region) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "intltz_get_region: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + "intltz_get_region: could not convert time zone id to UTF-16", 0); RETURN_FALSE; } int32_t region_len = TimeZone::getRegion(id, outbuf, sizeof(outbuf), status); INTL_CHECK_STATUS(status, "intltz_get_region: Error obtaining region"); - RETURN_STRINGL(outbuf, region_len, 1); + RETURN_STRINGL(outbuf, region_len); } #endif U_CFUNC PHP_FUNCTION(intltz_get_tz_data_version) { - intl_error_reset(NULL TSRMLS_CC); + intl_error_reset(NULL); if (zend_parse_parameters_none() == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_tz_data_version: bad arguments", 0 TSRMLS_CC); + "intltz_get_tz_data_version: bad arguments", 0); RETURN_FALSE; } @@ -374,21 +362,21 @@ U_CFUNC PHP_FUNCTION(intltz_get_tz_data_version) INTL_CHECK_STATUS(status, "intltz_get_tz_data_version: " "Error obtaining time zone data version"); - RETURN_STRING(res, 1); + RETURN_STRING(res); } U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) { - char *str_id; - int str_id_len; - long index; - intl_error_reset(NULL TSRMLS_CC); + char *str_id; + size_t str_id_len; + zend_long index; + intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl", &str_id, &str_id_len, &index) == FAILURE || - index < (long)INT32_MIN || index > (long)INT32_MAX) { + index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_equivalent_id: bad arguments", 0 TSRMLS_CC); + "intltz_get_equivalent_id: bad arguments", 0); RETURN_FALSE; } @@ -396,26 +384,27 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "intltz_get_equivalent_id: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + "intltz_get_equivalent_id: could not convert time zone id to UTF-16", 0); RETURN_FALSE; } const UnicodeString result = TimeZone::getEquivalentID(id, (int32_t)index); - intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), - result.getBuffer(), result.length(), &status); + zend_string *u8str; + + u8str = intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), &status); INTL_CHECK_STATUS(status, "intltz_get_equivalent_id: " "could not convert resulting time zone id to UTF-16"); - Z_TYPE_P(return_value) = IS_STRING; + RETVAL_NEW_STR(u8str); } U_CFUNC PHP_FUNCTION(intltz_get_id) { TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_id: bad arguments", 0 TSRMLS_CC); + "intltz_get_id: bad arguments", 0); RETURN_FALSE; } @@ -424,24 +413,23 @@ U_CFUNC PHP_FUNCTION(intltz_get_id) UnicodeString id_us; to->utimezone->getID(id_us); - char *id = NULL; - int id_len = 0; + zend_string *u8str; - intl_convert_utf16_to_utf8(&id, &id_len, + u8str = intl_convert_utf16_to_utf8( id_us.getBuffer(), id_us.length(), TIMEZONE_ERROR_CODE_P(to)); INTL_METHOD_CHECK_STATUS(to, "intltz_get_id: Could not convert id to UTF-8"); - RETURN_STRINGL(id, id_len, 0); + RETVAL_NEW_STR(u8str); } U_CFUNC PHP_FUNCTION(intltz_use_daylight_time) { TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_use_daylight_time: bad arguments", 0 TSRMLS_CC); + "intltz_use_daylight_time: bad arguments", 0); RETURN_FALSE; } @@ -452,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; @@ -460,23 +448,25 @@ U_CFUNC PHP_FUNCTION(intltz_get_offset) dstOffset; TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), - "Odbzz", &object, TimeZone_ce_ptr, &date, &local, &rawOffsetArg, + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), + "Odbz/z/", &object, TimeZone_ce_ptr, &date, &local, &rawOffsetArg, &dstOffsetArg) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_offset: bad arguments", 0 TSRMLS_CC); + "intltz_get_offset: bad arguments", 0); RETURN_FALSE; } 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"); + ZVAL_DEREF(rawOffsetArg); zval_dtor(rawOffsetArg); ZVAL_LONG(rawOffsetArg, rawOffset); + ZVAL_DEREF(dstOffsetArg); zval_dtor(dstOffsetArg); ZVAL_LONG(dstOffsetArg, dstOffset); @@ -487,10 +477,10 @@ U_CFUNC PHP_FUNCTION(intltz_get_raw_offset) { TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_raw_offset: bad arguments", 0 TSRMLS_CC); + "intltz_get_raw_offset: bad arguments", 0); RETURN_FALSE; } @@ -505,18 +495,18 @@ U_CFUNC PHP_FUNCTION(intltz_has_same_rules) TimeZone_object *other_to; TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, TimeZone_ce_ptr, &other_object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_has_same_rules: bad arguments", 0 TSRMLS_CC); + "intltz_has_same_rules: bad arguments", 0); RETURN_FALSE; } TIMEZONE_METHOD_FETCH_OBJECT; - other_to = (TimeZone_object *) zend_object_store_get_object(other_object TSRMLS_CC); + other_to = Z_INTL_TIMEZONE_P(other_object); if (other_to->utimezone == NULL) { intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_has_same_rules: The second IntlTimeZone is unconstructed", 0 TSRMLS_CC); + "intltz_has_same_rules: The second IntlTimeZone is unconstructed", 0); RETURN_FALSE; } @@ -535,16 +525,16 @@ static const TimeZone::EDisplayType display_types[] = { U_CFUNC PHP_FUNCTION(intltz_get_display_name) { zend_bool daylight = 0; - long display_type = TimeZone::LONG; - const char *locale_str = NULL; - int dummy = 0; + zend_long display_type = TimeZone::LONG; + const char *locale_str = NULL; + size_t dummy = 0; TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|bls!", &object, TimeZone_ce_ptr, &daylight, &display_type, &locale_str, &dummy) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_display_name: bad arguments", 0 TSRMLS_CC); + "intltz_get_display_name: bad arguments", 0); RETURN_FALSE; } @@ -555,12 +545,12 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name) } if (!found) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_display_name: wrong display type", 0 TSRMLS_CC); + "intltz_get_display_name: wrong display type", 0); RETURN_FALSE; } if (!locale_str) { - locale_str = intl_locale_get_default(TSRMLS_C); + locale_str = intl_locale_get_default(); } TIMEZONE_METHOD_FETCH_OBJECT; @@ -569,48 +559,48 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name) to->utimezone->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)display_type, Locale::createFromName(locale_str), result); - intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), - result.getBuffer(), result.length(), TIMEZONE_ERROR_CODE_P(to)); + zend_string *u8str = intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), TIMEZONE_ERROR_CODE_P(to)); INTL_METHOD_CHECK_STATUS(to, "intltz_get_display_name: " "could not convert resulting time zone id to UTF-16"); - Z_TYPE_P(return_value) = IS_STRING; + RETVAL_NEW_STR(u8str); } U_CFUNC PHP_FUNCTION(intltz_get_dst_savings) { TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_dst_savings: bad arguments", 0 TSRMLS_CC); + "intltz_get_dst_savings: bad arguments", 0); RETURN_FALSE; } TIMEZONE_METHOD_FETCH_OBJECT; - RETURN_LONG((long)to->utimezone->getDSTSavings()); + RETURN_LONG((zend_long)to->utimezone->getDSTSavings()); } U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone) { + zval tmp; TIMEZONE_METHOD_INIT_VARS; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_to_date_time_zone: bad arguments", 0 TSRMLS_CC); + "intltz_to_date_time_zone: bad arguments", 0); RETURN_FALSE; } TIMEZONE_METHOD_FETCH_OBJECT; zval *ret = timezone_convert_to_datetimezone(to->utimezone, - &TIMEZONE_ERROR(to), "intltz_to_date_time_zone" TSRMLS_CC); + &TIMEZONE_ERROR(to), "intltz_to_date_time_zone", &tmp); if (ret) { - RETURN_ZVAL(ret, 1, 1); + ZVAL_COPY_VALUE(return_value, ret); } else { RETURN_FALSE; } @@ -620,40 +610,40 @@ U_CFUNC PHP_FUNCTION(intltz_get_error_code) { TIMEZONE_METHOD_INIT_VARS - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_error_code: bad arguments", 0 TSRMLS_CC); + "intltz_get_error_code: bad arguments", 0); RETURN_FALSE; } /* Fetch the object (without resetting its last error code ). */ - to = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + to = Z_INTL_TIMEZONE_P(object); if (to == NULL) RETURN_FALSE; - RETURN_LONG((long)TIMEZONE_ERROR_CODE(to)); + RETURN_LONG((zend_long)TIMEZONE_ERROR_CODE(to)); } U_CFUNC PHP_FUNCTION(intltz_get_error_message) { - const char* message = NULL; + zend_string* message = NULL; TIMEZONE_METHOD_INIT_VARS - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intltz_get_error_message: bad arguments", 0 TSRMLS_CC ); + "intltz_get_error_message: bad arguments", 0 ); RETURN_FALSE; } /* Fetch the object (without resetting its last error code ). */ - to = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + to = Z_INTL_TIMEZONE_P(object); if (to == NULL) RETURN_FALSE; /* Return last error message. */ - message = intl_error_get_message(TIMEZONE_ERROR_P(to) TSRMLS_CC); - RETURN_STRING(message, 0); + message = intl_error_get_message(TIMEZONE_ERROR_P(to)); + RETURN_STR(message); } |