diff options
Diffstat (limited to 'ext/intl/dateformat/dateformat_parse.c')
-rw-r--r-- | ext/intl/dateformat/dateformat_parse.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c index 4193e89017..15279da3a1 100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.c @@ -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 | @@ -57,14 +57,14 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex if(result > LONG_MAX || result < -LONG_MAX) { ZVAL_DOUBLE(return_value, result<0?ceil(result):floor(result)); } else { - ZVAL_LONG(return_value, (long)result); + ZVAL_LONG(return_value, (zend_long)result); } } /* }}} */ -static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, UCalendar parsed_calendar, long calendar_field, char* key_name TSRMLS_DC) +static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, const UCalendar *parsed_calendar, zend_long calendar_field, char* key_name TSRMLS_DC) { - long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo)); + zend_long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo)); INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : could not get a field from calendar" ); if( strcmp(key_name, CALENDAR_YEAR )==0 ){ @@ -83,16 +83,16 @@ static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_va */ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* text_to_parse, int32_t text_len, int32_t *parse_pos, zval *return_value TSRMLS_DC) { - UCalendar* parsed_calendar = NULL; + UCalendar *parsed_calendar = NULL; UChar* text_utf16 = NULL; int32_t text_utf16_len = 0; - long isInDST = 0; + zend_long isInDST = 0; /* Convert timezone to UTF-16. */ intl_convert_utf8_to_utf16(&text_utf16, &text_utf16_len, text_to_parse, text_len, &INTL_DATA_ERROR_CODE(dfo)); INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" ); - parsed_calendar = udat_getCalendar(DATE_FORMAT_OBJECT(dfo)); + parsed_calendar = (UCalendar *)udat_getCalendar(DATE_FORMAT_OBJECT(dfo)); udat_parseCalendar( DATE_FORMAT_OBJECT(dfo), parsed_calendar, text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo)); if (text_utf16) { @@ -128,14 +128,14 @@ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* tex PHP_FUNCTION(datefmt_parse) { char* text_to_parse = NULL; - int32_t text_len =0; + size_t text_len =0; zval* z_parse_pos = NULL; int32_t parse_pos = -1; DATE_FORMAT_METHOD_INIT_VARS; /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|z!", + if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|z/!", &object, IntlDateFormatter_ce_ptr, &text_to_parse, &text_len, &z_parse_pos ) == FAILURE ){ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse: unable to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; @@ -145,6 +145,7 @@ PHP_FUNCTION(datefmt_parse) DATE_FORMAT_METHOD_FETCH_OBJECT; if (z_parse_pos) { + ZVAL_DEREF(z_parse_pos); convert_to_long(z_parse_pos); parse_pos = (int32_t)Z_LVAL_P(z_parse_pos); if(parse_pos > text_len) { @@ -166,9 +167,9 @@ PHP_FUNCTION(datefmt_parse) PHP_FUNCTION(datefmt_localtime) { char* text_to_parse = NULL; - int32_t text_len =0; + size_t text_len =0; zval* z_parse_pos = NULL; - int32_t parse_pos = -1; + int32_t parse_pos = -1; DATE_FORMAT_METHOD_INIT_VARS; @@ -182,7 +183,8 @@ PHP_FUNCTION(datefmt_localtime) /* Fetch the object. */ DATE_FORMAT_METHOD_FETCH_OBJECT; - if(z_parse_pos) { + if (z_parse_pos) { + ZVAL_DEREF(z_parse_pos); convert_to_long(z_parse_pos); parse_pos = (int32_t)Z_LVAL_P(z_parse_pos); if(parse_pos > text_len) { @@ -190,7 +192,7 @@ PHP_FUNCTION(datefmt_localtime) } } internal_parse_to_localtime( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value TSRMLS_CC); - if(z_parse_pos) { + if (z_parse_pos) { zval_dtor(z_parse_pos); ZVAL_LONG(z_parse_pos, parse_pos); } |