mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
ext/intl: Refactor error handling (#19196)
This is a comprehensive refactoring of the error mechanism of the Intl extension. By moving the prefixing of the current method/function being executed to actual error message creation by accessing the execution context, we get the following benefits: - Accurate error messages indicating *what* call caused the error - As we *always* "copy" the message, the `copyMsg` arg becomes unused, meaning we can reduce the size of the `intl_error` struct by 4 bytes. - Saving it as a zend_string means we know the length of the message - Remove the need to pass around a "function name" `char*` across multiple calls - Use Intl's exception mechanism to generate exceptions for constructor call - This removes the need for replacing the error handler - Which didn't do anything anyway in silent mode, which required throwing non-descriptive exceptions
This commit is contained in:
parent
03e2613ddd
commit
6600d0e00f
102 changed files with 684 additions and 847 deletions
|
@ -43,7 +43,7 @@ inline BreakIterator *_breakiter_prolog(zend_object_iterator *iter)
|
|||
if (bio->biter == NULL) {
|
||||
intl_errors_set(BREAKITER_ERROR_P(bio), U_INVALID_STATE_ERROR,
|
||||
"The BreakIterator object backing the PHP iterator is not "
|
||||
"properly constructed", 0);
|
||||
"properly constructed");
|
||||
}
|
||||
return bio->biter;
|
||||
}
|
||||
|
|
|
@ -41,14 +41,13 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, __construct)
|
|||
0 );
|
||||
}
|
||||
|
||||
static void _breakiter_factory(const char *func_name,
|
||||
BreakIterator *(*func)(const Locale&, UErrorCode&),
|
||||
INTERNAL_FUNCTION_PARAMETERS)
|
||||
static void _breakiter_factory(
|
||||
BreakIterator *(*func)(const Locale&, UErrorCode&),
|
||||
INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
BreakIterator *biter;
|
||||
char *locale_str = NULL;
|
||||
size_t dummy;
|
||||
char *msg;
|
||||
UErrorCode status = UErrorCode();
|
||||
intl_error_reset(NULL);
|
||||
|
||||
|
@ -64,10 +63,7 @@ static void _breakiter_factory(const char *func_name,
|
|||
biter = func(Locale::createFromName(locale_str), status);
|
||||
intl_error_set_code(NULL, status);
|
||||
if (U_FAILURE(status)) {
|
||||
spprintf(&msg, 0, "%s: error creating BreakIterator",
|
||||
func_name);
|
||||
intl_error_set_custom_msg(NULL, msg, 1);
|
||||
efree(msg);
|
||||
intl_error_set_custom_msg(NULL, "error creating BreakIterator");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
|
@ -76,35 +72,35 @@ static void _breakiter_factory(const char *func_name,
|
|||
|
||||
U_CFUNC PHP_METHOD(IntlBreakIterator, createWordInstance)
|
||||
{
|
||||
_breakiter_factory("breakiter_create_word_instance",
|
||||
_breakiter_factory(
|
||||
&BreakIterator::createWordInstance,
|
||||
INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlBreakIterator, createLineInstance)
|
||||
{
|
||||
_breakiter_factory("breakiter_create_line_instance",
|
||||
_breakiter_factory(
|
||||
&BreakIterator::createLineInstance,
|
||||
INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlBreakIterator, createCharacterInstance)
|
||||
{
|
||||
_breakiter_factory("breakiter_create_character_instance",
|
||||
_breakiter_factory(
|
||||
&BreakIterator::createCharacterInstance,
|
||||
INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlBreakIterator, createSentenceInstance)
|
||||
{
|
||||
_breakiter_factory("breakiter_create_sentence_instance",
|
||||
_breakiter_factory(
|
||||
&BreakIterator::createSentenceInstance,
|
||||
INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlBreakIterator, createTitleInstance)
|
||||
{
|
||||
_breakiter_factory("breakiter_create_title_instance",
|
||||
_breakiter_factory(
|
||||
&BreakIterator::createTitleInstance,
|
||||
INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
|
@ -149,12 +145,11 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, setText)
|
|||
BREAKITER_METHOD_FETCH_OBJECT;
|
||||
|
||||
ut = utext_openUTF8(ut, ZSTR_VAL(text), ZSTR_LEN(text), BREAKITER_ERROR_CODE_P(bio));
|
||||
INTL_METHOD_CHECK_STATUS(bio, "breakiter_set_text: error opening UText");
|
||||
INTL_METHOD_CHECK_STATUS(bio, "error opening UText");
|
||||
|
||||
bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio));
|
||||
utext_close(ut); /* ICU shallow clones the UText */
|
||||
INTL_METHOD_CHECK_STATUS(bio, "breakiter_set_text: error calling "
|
||||
"BreakIterator::setText()");
|
||||
INTL_METHOD_CHECK_STATUS(bio, "error calling BreakIterator::setText()");
|
||||
|
||||
/* When ICU clones the UText, it does not copy the buffer, so we have to
|
||||
* keep the string buffer around by holding a reference to its zval. This
|
||||
|
@ -302,10 +297,10 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale)
|
|||
Z_PARAM_LONG(locale_type)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
/* Change to ValueError? */
|
||||
/* TODO: Change to ValueError? */
|
||||
if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"breakiter_get_locale: invalid locale type", 0);
|
||||
"invalid locale type");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -313,8 +308,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale)
|
|||
|
||||
Locale locale = bio->biter->getLocale((ULocDataLocaleType)locale_type,
|
||||
BREAKITER_ERROR_CODE(bio));
|
||||
INTL_METHOD_CHECK_STATUS(bio,
|
||||
"breakiter_get_locale: Call to ICU method has failed");
|
||||
INTL_METHOD_CHECK_STATUS(bio, "Call to ICU method has failed");
|
||||
|
||||
RETURN_STRING(locale.getName());
|
||||
}
|
||||
|
|
|
@ -105,8 +105,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRules)
|
|||
if (!u8str)
|
||||
{
|
||||
intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio),
|
||||
"rbbi_hash_code: Error converting result to UTF-8 string",
|
||||
0);
|
||||
"Error converting result to UTF-8 string");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_STR(u8str);
|
||||
|
@ -144,8 +143,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatusVec)
|
|||
BREAKITER_ERROR_CODE(bio));
|
||||
if (U_FAILURE(BREAKITER_ERROR_CODE(bio))) {
|
||||
intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio),
|
||||
"rbbi_get_rule_status_vec: failed obtaining the status values",
|
||||
0);
|
||||
"failed obtaining the status values");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -169,8 +167,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getBinaryRules)
|
|||
|
||||
if (rules_len > INT_MAX - 1) {
|
||||
intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio),
|
||||
"rbbi_get_binary_rules: the rules are too large",
|
||||
0);
|
||||
"the rules are too large");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ U_CFUNC PHP_FUNCTION(intlcal_create_instance)
|
|||
Z_PARAM_STRING_OR_NULL(locale_str, locale_len)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
timeZone = timezone_process_timezone_argument(zv_timezone, NULL,
|
||||
"intlcal_create_instance");
|
||||
timeZone = timezone_process_timezone_argument(zv_timezone, NULL);
|
||||
if (timeZone == NULL) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -99,7 +98,7 @@ U_CFUNC PHP_FUNCTION(intlcal_create_instance)
|
|||
Locale::createFromName(locale_str), status);
|
||||
if (UNEXPECTED(cal == NULL)) {
|
||||
delete timeZone;
|
||||
intl_error_set(NULL, status, "Error creating ICU Calendar object", 0);
|
||||
intl_error_set(NULL, status, "Error creating ICU Calendar object");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
|
@ -179,8 +178,8 @@ U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale)
|
|||
Locale::createFromName(locale), (UBool)commonly_used,
|
||||
status);
|
||||
if (se == NULL) {
|
||||
intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: "
|
||||
"error calling underlying method", 0);
|
||||
intl_error_set(NULL, status,
|
||||
"error calling underlying method");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -252,8 +251,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_time)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
UDate result = co->ucal->getTime(CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_get_time: error calling ICU Calendar::getTime");
|
||||
INTL_METHOD_CHECK_STATUS(co, "error calling ICU Calendar::getTime");
|
||||
|
||||
RETURN_DOUBLE((double)result);
|
||||
}
|
||||
|
@ -293,7 +291,7 @@ U_CFUNC PHP_FUNCTION(intlcal_add)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
co->ucal->add((UCalendarDateFields)field, (int32_t)amount, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_add: Call to underlying method failed");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to underlying method failed");
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -316,7 +314,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_time_zone)
|
|||
}
|
||||
|
||||
timeZone = timezone_process_timezone_argument(zv_timezone,
|
||||
CALENDAR_ERROR_P(co), "intlcal_set_time_zone");
|
||||
CALENDAR_ERROR_P(co));
|
||||
if (timeZone == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -350,7 +348,7 @@ static void _php_intlcal_before_after(
|
|||
}
|
||||
|
||||
UBool res = (co->ucal->*func)(*when_co->ucal, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_before/after: Error calling ICU method");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method");
|
||||
|
||||
RETURN_BOOL((int)res);
|
||||
}
|
||||
|
@ -490,7 +488,7 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
|
|||
|
||||
co->ucal->roll((UCalendarDateFields)field, (int32_t)value, CALENDAR_ERROR_CODE(co));
|
||||
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_roll: Error calling ICU Calendar::roll");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Error calling ICU Calendar::roll");
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -536,8 +534,7 @@ U_CFUNC PHP_FUNCTION(intlcal_field_difference)
|
|||
|
||||
int32_t result = co->ucal->fieldDifference((UDate)when,
|
||||
(UCalendarDateFields)field, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_field_difference: Call to ICU method has failed");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
|
||||
|
||||
RETURN_LONG((zend_long)result);
|
||||
}
|
||||
|
@ -570,8 +567,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
|
|||
|
||||
int32_t result = co->ucal->getDayOfWeekType(
|
||||
(UCalendarDaysOfWeek)dow, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_get_day_of_week_type: Call to ICU method has failed");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
|
||||
|
||||
RETURN_LONG((zend_long)result);
|
||||
}
|
||||
|
@ -588,8 +584,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
int32_t result = co->ucal->getFirstDayOfWeek(CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_get_first_day_of_week: Call to ICU method has failed");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
|
||||
|
||||
RETURN_LONG((zend_long)result);
|
||||
}
|
||||
|
@ -647,8 +642,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_locale)
|
|||
|
||||
Locale locale = co->ucal->getLocale((ULocDataLocaleType)locale_type,
|
||||
CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_get_locale: Call to ICU method has failed");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
|
||||
|
||||
RETURN_STRING(locale.getName());
|
||||
}
|
||||
|
@ -671,8 +665,8 @@ U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
uint8_t result = co->ucal->getMinimalDaysInFirstWeek();
|
||||
INTL_METHOD_CHECK_STATUS(co,
|
||||
"intlcal_get_first_day_of_week: Call to ICU method has failed"); /* TODO Is it really a failure? */
|
||||
/* TODO Is it really a failure? */
|
||||
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
|
||||
|
||||
RETURN_LONG((zend_long)result);
|
||||
}
|
||||
|
@ -697,7 +691,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_time_zone)
|
|||
TimeZone *tz = co->ucal->getTimeZone().clone();
|
||||
if (UNEXPECTED(tz == NULL)) {
|
||||
intl_errors_set(CALENDAR_ERROR_P(co), U_MEMORY_ALLOCATION_ERROR,
|
||||
"intlcal_get_time_zone: could not clone TimeZone", 0);
|
||||
"could not clone TimeZone");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -734,8 +728,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition)
|
|||
|
||||
int32_t res = co->ucal->getWeekendTransition((UCalendarDaysOfWeek)dow,
|
||||
CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_get_weekend_transition: "
|
||||
"Error calling ICU method");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method");
|
||||
|
||||
RETURN_LONG((zend_long)res);
|
||||
}
|
||||
|
@ -752,8 +745,7 @@ U_CFUNC PHP_FUNCTION(intlcal_in_daylight_time)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
UBool ret = co->ucal->inDaylightTime(CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_in_daylight_time: "
|
||||
"Error calling ICU method");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method");
|
||||
|
||||
RETURN_BOOL((int)ret);
|
||||
}
|
||||
|
@ -829,8 +821,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_weekend)
|
|||
RETURN_BOOL((int)co->ucal->isWeekend());
|
||||
} else {
|
||||
UBool ret = co->ucal->isWeekend((UDate)date, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_is_weekend: "
|
||||
"Error calling ICU method");
|
||||
INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method");
|
||||
RETURN_BOOL((int)ret);
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +906,7 @@ U_CFUNC PHP_FUNCTION(intlcal_equals)
|
|||
}
|
||||
|
||||
UBool result = co->ucal->equals(*other_co->ucal, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlcal_equals: error calling ICU Calendar::equals");
|
||||
INTL_METHOD_CHECK_STATUS(co, "error calling ICU Calendar::equals");
|
||||
|
||||
RETURN_BOOL((int)result);
|
||||
}
|
||||
|
@ -1028,16 +1019,14 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time)
|
|||
datetime = php_date_obj_from_obj(date_obj);
|
||||
if (!datetime->time) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_from_date_time: DateTime object is unconstructed",
|
||||
0);
|
||||
"DateTime object is unconstructed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
zend_call_method_with_0_params(date_obj, php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp);
|
||||
if (Z_TYPE(zv_timestamp) != IS_LONG) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_from_date_time: bad DateTime; call to "
|
||||
"DateTime::getTimestamp() failed", 0);
|
||||
"bad DateTime; call to DateTime::getTimestamp() failed");
|
||||
zval_ptr_dtor(&zv_timestamp);
|
||||
goto error;
|
||||
}
|
||||
|
@ -1046,7 +1035,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time)
|
|||
timeZone = TimeZone::getGMT()->clone();
|
||||
} else {
|
||||
timeZone = timezone_convert_datetimezone(datetime->time->zone_type,
|
||||
datetime, 1, NULL, "intlcal_from_date_time");
|
||||
datetime, 1, NULL);
|
||||
if (timeZone == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
@ -1060,16 +1049,16 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time)
|
|||
Locale::createFromName(locale_str), status);
|
||||
if (UNEXPECTED(cal == NULL)) {
|
||||
delete timeZone;
|
||||
intl_error_set(NULL, status, "intlcal_from_date_time: "
|
||||
"error creating ICU Calendar object", 0);
|
||||
intl_error_set(NULL, status,
|
||||
"error creating ICU Calendar object");
|
||||
goto error;
|
||||
}
|
||||
cal->setTime(((UDate)Z_LVAL(zv_timestamp)) * 1000., status);
|
||||
if (U_FAILURE(status)) {
|
||||
/* time zone was adopted by cal; should not be deleted here */
|
||||
delete cal;
|
||||
intl_error_set(NULL, status, "intlcal_from_date_time: "
|
||||
"error creating ICU Calendar::setTime()", 0);
|
||||
intl_error_set(NULL, status,
|
||||
"error creating ICU Calendar::setTime()");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -1105,8 +1094,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
|
|||
|
||||
if (UNEXPECTED(date > (double)U_INT64_MAX || date < (double)U_INT64_MIN)) {
|
||||
intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_to_date_time: The calendar date is out of the "
|
||||
"range for a 64-bit integer", 0);
|
||||
"The calendar date is out of the range for a 64-bit integer");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1107,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
|
|||
/* Now get the time zone */
|
||||
const TimeZone& tz = co->ucal->getTimeZone();
|
||||
zval *timezone_zval = timezone_convert_to_datetimezone(
|
||||
&tz, CALENDAR_ERROR_P(co), "intlcal_to_date_time", &tmp);
|
||||
&tz, CALENDAR_ERROR_P(co), &tmp);
|
||||
if (timezone_zval == NULL) {
|
||||
zval_ptr_dtor(&ts_zval);
|
||||
RETURN_FALSE;
|
||||
|
@ -1146,8 +1134,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
|
|||
&retval, timezone_zval);
|
||||
if (Z_ISUNDEF(retval) || Z_TYPE(retval) == IS_FALSE) {
|
||||
intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_to_date_time: call to DateTime::setTimeZone has failed",
|
||||
1);
|
||||
"call to DateTime::setTimeZone has failed");
|
||||
zval_ptr_dtor(return_value);
|
||||
RETVAL_FALSE;
|
||||
goto error;
|
||||
|
|
|
@ -53,9 +53,7 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode
|
|||
{
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status,
|
||||
"IntlGregorianCalendar: Error creating ICU GregorianCalendar from date",
|
||||
0
|
||||
);
|
||||
"Error creating ICU GregorianCalendar from date");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -64,10 +62,8 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode
|
|||
UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name));
|
||||
if (tzstr.isBogus()) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlGregorianCalendar: Could not create UTF-8 string "
|
||||
"from PHP's default timezone name (see date_default_timezone_get())",
|
||||
0
|
||||
);
|
||||
"Could not create UTF-8 string from PHP's default timezone "
|
||||
"name (see date_default_timezone_get())");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -78,8 +74,7 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode
|
|||
return true;
|
||||
}
|
||||
|
||||
static void _php_intlgregcal_constructor_body(
|
||||
INTERNAL_FUNCTION_PARAMETERS, bool is_constructor, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor)
|
||||
{
|
||||
zval *tz_object = NULL;
|
||||
zval args_a[6],
|
||||
|
@ -127,11 +122,6 @@ static void _php_intlgregcal_constructor_body(
|
|||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
// instantion of ICU object
|
||||
Calendar_object *co = Z_INTL_CALENDAR_P(return_value);
|
||||
std::unique_ptr<GregorianCalendar> gcal;
|
||||
|
@ -143,9 +133,9 @@ static void _php_intlgregcal_constructor_body(
|
|||
|
||||
if (variant <= 2) {
|
||||
// From timezone and locale (0 to 2 arguments)
|
||||
TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL,
|
||||
"intlgregcal_create_instance");
|
||||
TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL);
|
||||
if (tz == NULL) {
|
||||
// TODO: Exception should always occur already?
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
|
||||
}
|
||||
|
@ -163,8 +153,8 @@ static void _php_intlgregcal_constructor_body(
|
|||
status));
|
||||
// Should this throw?
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
|
||||
"creating ICU GregorianCalendar from time zone and locale", 0);
|
||||
intl_error_set(NULL, status, "error creating ICU "
|
||||
"GregorianCalendar from time zone and locale");
|
||||
delete tz;
|
||||
if (!is_constructor) {
|
||||
zval_ptr_dtor(return_value);
|
||||
|
@ -209,29 +199,27 @@ static void _php_intlgregcal_constructor_body(
|
|||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
|
||||
{
|
||||
intl_error_reset(NULL);
|
||||
|
||||
object_init_ex(return_value, GregorianCalendar_ce_ptr);
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ 0, NULL, NULL);
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ false);
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
return_value = ZEND_THIS;
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ 1, &error_handling, &error_handling_replaced);
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
}
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ true);
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate)
|
||||
{
|
||||
zend_long year, month, day;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
zend_error_handling error_handling;
|
||||
Calendar_object *co;
|
||||
std::unique_ptr<GregorianCalendar> gcal;
|
||||
|
||||
|
@ -247,10 +235,12 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate)
|
|||
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(month, 2);
|
||||
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(day, 3);
|
||||
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
|
||||
gcal = std::unique_ptr<GregorianCalendar>(new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, status));
|
||||
if (!set_gregorian_calendar_time_zone(gcal.get(), status)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -259,7 +249,8 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate)
|
|||
co->ucal = gcal.release();
|
||||
|
||||
cleanup:
|
||||
zend_restore_error_handling(&error_handling);
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime)
|
||||
|
@ -267,7 +258,6 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime)
|
|||
zend_long year, month, day, hour, minute, second;
|
||||
bool second_is_null = 1;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
zend_error_handling error_handling;
|
||||
Calendar_object *co;
|
||||
GregorianCalendar *tmp;
|
||||
|
||||
|
@ -289,8 +279,6 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime)
|
|||
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(hour, 4);
|
||||
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(minute, 5);
|
||||
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
|
||||
|
||||
if (second_is_null) {
|
||||
tmp = new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, (int32_t) hour, (int32_t) minute, status);
|
||||
} else {
|
||||
|
@ -298,7 +286,10 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime)
|
|||
tmp = new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, (int32_t) hour, (int32_t) minute, (int32_t) second, status);
|
||||
}
|
||||
auto gcal = std::unique_ptr<GregorianCalendar>(tmp);
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
if (!set_gregorian_calendar_time_zone(gcal.get(), status)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -308,7 +299,8 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime)
|
|||
co->ucal = gcal.release();
|
||||
|
||||
cleanup:
|
||||
zend_restore_error_handling(&error_handling);
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change)
|
||||
|
@ -325,8 +317,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change)
|
|||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
fetch_greg(co)->setGregorianChange(date, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlgregcal_set_gregorian_change: error "
|
||||
"calling ICU method");
|
||||
INTL_METHOD_CHECK_STATUS(co, "error calling ICU method");
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ extern zend_class_entry *Collator_ce_ptr;
|
|||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); \
|
||||
if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) \
|
||||
{ \
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg, 0 ); \
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ PHP_FUNCTION( collator_compare )
|
|||
|
||||
if (!co || !co->ucoll) {
|
||||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Object not initialized", 0 );
|
||||
intl_errors_set_custom_msg(COLLATOR_ERROR_P( co ), "Object not initialized");
|
||||
zend_throw_error(NULL, "Object not initialized");
|
||||
|
||||
RETURN_THROWS();
|
||||
|
@ -70,8 +69,7 @@ PHP_FUNCTION( collator_compare )
|
|||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Error converting first argument to UTF-16", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting first argument to UTF-16");
|
||||
if (ustr1) {
|
||||
efree( ustr1 );
|
||||
}
|
||||
|
@ -86,8 +84,7 @@ PHP_FUNCTION( collator_compare )
|
|||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Error converting second argument to UTF-16", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting second argument to UTF-16");
|
||||
if (ustr1) {
|
||||
efree( ustr1 );
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "intl_data.h"
|
||||
|
||||
/* {{{ */
|
||||
static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
char* locale;
|
||||
size_t locale_len = 0;
|
||||
|
@ -35,11 +35,6 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro
|
|||
Z_PARAM_STRING(locale, locale_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
|
||||
COLLATOR_METHOD_FETCH_OBJECT;
|
||||
|
||||
|
@ -49,7 +44,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro
|
|||
|
||||
/* Open ICU collator. */
|
||||
co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
|
||||
INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
|
||||
INTL_CTOR_CHECK_STATUS(co, "unable to open ICU collator");
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -58,7 +53,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro
|
|||
PHP_FUNCTION( collator_create )
|
||||
{
|
||||
object_init_ex( return_value, Collator_ce_ptr );
|
||||
if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -68,17 +63,16 @@ PHP_FUNCTION( collator_create )
|
|||
/* {{{ Collator object constructor. */
|
||||
PHP_METHOD( Collator, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
return_value = ZEND_THIS;
|
||||
if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -43,8 +43,7 @@ PHP_FUNCTION( collator_get_locale )
|
|||
|
||||
if (!co || !co->ucoll) {
|
||||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Object not initialized", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized");
|
||||
zend_throw_error(NULL, "Object not initialized");
|
||||
|
||||
RETURN_THROWS();
|
||||
|
|
|
@ -359,8 +359,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
|
|||
|
||||
if (!co || !co->ucoll) {
|
||||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Object not initialized", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized");
|
||||
zend_throw_error(NULL, "Object not initialized");
|
||||
|
||||
RETURN_THROWS();
|
||||
|
@ -393,7 +392,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
|
|||
if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) )
|
||||
{
|
||||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Sort with sort keys failed", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Sort with sort keys failed");
|
||||
|
||||
if( utf16_buf )
|
||||
efree( utf16_buf );
|
||||
|
@ -516,8 +515,7 @@ PHP_FUNCTION( collator_get_sort_key )
|
|||
|
||||
if (!co || !co->ucoll) {
|
||||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Object not initialized", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized");
|
||||
zend_throw_error(NULL, "Object not initialized");
|
||||
|
||||
RETURN_THROWS();
|
||||
|
@ -536,8 +534,7 @@ PHP_FUNCTION( collator_get_sort_key )
|
|||
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
|
||||
"Error converting first argument to UTF-16", 0 );
|
||||
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting first argument to UTF-16");
|
||||
efree( ustr );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,9 @@ using icu::UnicodeString;
|
|||
|
||||
/* {{{ timezone_convert_datetimezone
|
||||
* The timezone in DateTime and DateTimeZone is not unified. */
|
||||
U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
|
||||
void *object,
|
||||
int is_datetime,
|
||||
intl_error *outside_error,
|
||||
const char *func)
|
||||
U_CFUNC TimeZone *timezone_convert_datetimezone(
|
||||
int type, void *object, bool is_datetime,
|
||||
intl_error *outside_error)
|
||||
{
|
||||
char *id = NULL,
|
||||
offset_id[] = "GMT+00:00";
|
||||
|
@ -58,11 +56,8 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
|
|||
minutes *= minutes > 0 ? 1 : -1;
|
||||
|
||||
if (offset_mins <= -24 * 60 || offset_mins >= 24 * 60) {
|
||||
spprintf(&message, 0, "%s: object has an time zone offset "
|
||||
"that's too large", func);
|
||||
intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
efree(message);
|
||||
"object has an time zone offset that's too large");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -82,10 +77,9 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
|
|||
UnicodeString s = UnicodeString(id, id_len, US_INV);
|
||||
timeZone = TimeZone::createTimeZone(s);
|
||||
if (*timeZone == TimeZone::getUnknown()) {
|
||||
spprintf(&message, 0, "%s: time zone id '%s' "
|
||||
"extracted from ext/date DateTimeZone not recognized", func, id);
|
||||
intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
spprintf(&message, 0, "time zone id '%s' "
|
||||
"extracted from ext/date DateTimeZone not recognized", id);
|
||||
intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message);
|
||||
efree(message);
|
||||
delete timeZone;
|
||||
return NULL;
|
||||
|
@ -95,7 +89,7 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
|
|||
/* }}} */
|
||||
|
||||
U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz,
|
||||
intl_error *err, const char *func)
|
||||
intl_error *err)
|
||||
{
|
||||
char *message;
|
||||
php_date_obj *datetime = php_date_obj_from_obj(obj);
|
||||
|
@ -125,8 +119,8 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti
|
|||
// TODO: Remove this when DateTimeInterface::getTimestamp() no longer has a tentative return type
|
||||
if (Z_TYPE(retval) != IS_LONG) {
|
||||
zval_ptr_dtor(&retval);
|
||||
spprintf(&message, 0, "%s: %s::getTimestamp() did not return an int", func, ZSTR_VAL(obj->ce->name));
|
||||
intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, message, 1);
|
||||
spprintf(&message, 0, "%s::getTimestamp() did not return an int", ZSTR_VAL(obj->ce->name));
|
||||
intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, message);
|
||||
efree(message);
|
||||
return FAILURE;
|
||||
}
|
||||
|
@ -136,10 +130,9 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti
|
|||
|
||||
if (tz) {
|
||||
if (!datetime->time) {
|
||||
spprintf(&message, 0, "%s: the %s object is not properly "
|
||||
"initialized", func, ZSTR_VAL(obj->ce->name));
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
spprintf(&message, 0, "the %s object is not properly "
|
||||
"initialized", ZSTR_VAL(obj->ce->name));
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message);
|
||||
efree(message);
|
||||
return FAILURE;
|
||||
}
|
||||
|
@ -147,13 +140,10 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti
|
|||
*tz = TimeZone::getGMT()->clone();
|
||||
} else {
|
||||
*tz = timezone_convert_datetimezone(datetime->time->zone_type,
|
||||
datetime, 1, NULL, func);
|
||||
datetime, 1, NULL);
|
||||
if (*tz == NULL) {
|
||||
spprintf(&message, 0, "%s: could not convert DateTime's "
|
||||
"time zone", func);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
efree(message);
|
||||
"could not convert DateTime's time zone");
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +152,11 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
|
||||
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err)
|
||||
{
|
||||
double rv = ZEND_NAN;
|
||||
zend_long lv;
|
||||
int type;
|
||||
char *message;
|
||||
|
||||
if (err && U_FAILURE(err->code)) {
|
||||
return ZEND_NAN;
|
||||
|
@ -182,11 +171,12 @@ try_again:
|
|||
} else if (type == IS_LONG) {
|
||||
rv = U_MILLIS_PER_SECOND * (double)lv;
|
||||
} else {
|
||||
spprintf(&message, 0, "%s: string '%s' is not numeric, "
|
||||
"which would be required for it to be a valid date", func,
|
||||
char *message;
|
||||
spprintf(&message, 0, "string '%s' is not numeric, "
|
||||
"which would be required for it to be a valid date",
|
||||
Z_STRVAL_P(z));
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
message);
|
||||
efree(message);
|
||||
}
|
||||
break;
|
||||
|
@ -198,42 +188,32 @@ try_again:
|
|||
break;
|
||||
case IS_OBJECT:
|
||||
if (instanceof_function(Z_OBJCE_P(z), php_date_get_interface_ce())) {
|
||||
intl_datetime_decompose(Z_OBJ_P(z), &rv, nullptr, err, func);
|
||||
intl_datetime_decompose(Z_OBJ_P(z), &rv, nullptr, err);
|
||||
} else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr)) {
|
||||
Calendar_object *co = Z_INTL_CALENDAR_P(z);
|
||||
if (co->ucal == NULL) {
|
||||
spprintf(&message, 0, "%s: IntlCalendar object is not properly "
|
||||
"constructed", func);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
efree(message);
|
||||
"IntlCalendar object is not properly constructed");
|
||||
} else {
|
||||
UErrorCode status = UErrorCode();
|
||||
rv = (double)co->ucal->getTime(status);
|
||||
if (U_FAILURE(status)) {
|
||||
spprintf(&message, 0, "%s: call to internal "
|
||||
"Calendar::getTime() has failed", func);
|
||||
intl_errors_set(err, status, message, 1);
|
||||
efree(message);
|
||||
intl_errors_set(err, status, "call to internal Calendar::getTime() has failed");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* TODO: try with cast(), get() to obtain a number */
|
||||
spprintf(&message, 0, "%s: invalid object type for date/time "
|
||||
"(only IntlCalendar and DateTimeInterface permitted)", func);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
efree(message);
|
||||
"invalid object type for date/time "
|
||||
"(only IntlCalendar and DateTimeInterface permitted)");
|
||||
}
|
||||
break;
|
||||
case IS_REFERENCE:
|
||||
z = Z_REFVAL_P(z);
|
||||
goto try_again;
|
||||
default:
|
||||
spprintf(&message, 0, "%s: invalid PHP type for date", func);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
efree(message);
|
||||
"invalid PHP type for date");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ U_CDECL_END
|
|||
|
||||
using icu::TimeZone;
|
||||
|
||||
U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func);
|
||||
U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz, intl_error *err, const char *func);
|
||||
U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, bool is_datetime, intl_error *outside_error);
|
||||
U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz, intl_error *err);
|
||||
|
||||
#endif
|
||||
|
||||
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func);
|
||||
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err);
|
||||
|
||||
#endif /* COMMON_DATE_H */
|
||||
|
|
|
@ -74,8 +74,7 @@ static void string_enum_current_move_forward(zend_object_iterator *iter)
|
|||
|
||||
intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii));
|
||||
if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
|
||||
"Error fetching next iteration element", 0);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error fetching next iteration element");
|
||||
} else if (result) {
|
||||
ZVAL_STRINGL(&zoi_iter->current, result, result_length);
|
||||
} //else we've reached the end of the enum, nothing more is required
|
||||
|
@ -105,8 +104,7 @@ static void string_enum_rewind(zend_object_iterator *iter)
|
|||
|
||||
intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii));
|
||||
if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
|
||||
"Error resetting enumeration", 0);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error resetting enumeration");
|
||||
} else {
|
||||
iter->funcs->move_forward(iter);
|
||||
}
|
||||
|
@ -268,7 +266,7 @@ PHP_METHOD(IntlIterator, rewind)
|
|||
ii->iterator->funcs->rewind(ii->iterator);
|
||||
} else {
|
||||
intl_errors_set(INTLITERATOR_ERROR_P(ii), U_UNSUPPORTED_ERROR,
|
||||
"IntlIterator::rewind: rewind not supported", 0);
|
||||
"rewind not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ static zend_class_entry *php_converter_ce;
|
|||
static zend_object_handlers php_converter_object_handlers;
|
||||
|
||||
#define CONV_GET(pzv) (Z_INTL_CONVERTER_P((pzv)))
|
||||
#define THROW_UFAILURE(obj, fname, error) php_converter_throw_failure(obj, error, \
|
||||
fname "() returned error " ZEND_LONG_FMT ": %s", (zend_long)error, u_errorName(error))
|
||||
#define THROW_UFAILURE(obj, error) php_converter_throw_failure(obj, error, \
|
||||
"returned error " ZEND_LONG_FMT ": %s", (zend_long)error, u_errorName(error))
|
||||
|
||||
/* {{{ php_converter_throw_failure */
|
||||
static inline void php_converter_throw_failure(php_converter_object *objval, UErrorCode error, const char *format, ...) {
|
||||
|
@ -55,7 +55,7 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr
|
|||
vsnprintf(message, sizeof(message), format, vargs);
|
||||
va_end(vargs);
|
||||
|
||||
intl_errors_set(err, error, message, 1);
|
||||
intl_errors_set(err, error, message);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -90,7 +90,7 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, zend_
|
|||
*/
|
||||
ucnv_getSubstChars(objval->src, chars, &chars_len, &uerror);
|
||||
if (U_FAILURE(uerror)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getSubstChars", uerror);
|
||||
THROW_UFAILURE(objval, uerror);
|
||||
chars[0] = 0x1A;
|
||||
chars[1] = 0;
|
||||
chars_len = 1;
|
||||
|
@ -341,7 +341,7 @@ static inline bool php_converter_set_callbacks(php_converter_object *objval, UCo
|
|||
ucnv_setToUCallBack(cnv, (UConverterToUCallback)php_converter_to_u_callback, (const void*)objval,
|
||||
NULL, NULL, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_setToUCallBack", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ static inline bool php_converter_set_callbacks(php_converter_object *objval, UCo
|
|||
ucnv_setFromUCallBack(cnv, (UConverterFromUCallback)php_converter_from_u_callback, (const void*)objval,
|
||||
NULL, NULL, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_setFromUCallBack", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
|
@ -373,11 +373,11 @@ static bool php_converter_set_encoding(php_converter_object *objval,
|
|||
php_error_docref(NULL, E_WARNING, "Ambiguous encoding specified, using %s", actual_encoding);
|
||||
} else if (U_FAILURE(error)) {
|
||||
if (objval) {
|
||||
THROW_UFAILURE(objval, "ucnv_open", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
} else {
|
||||
char *msg;
|
||||
spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
|
||||
intl_error_set(NULL, error, msg, 1);
|
||||
intl_error_set(NULL, error, msg);
|
||||
efree(msg);
|
||||
}
|
||||
return false;
|
||||
|
@ -439,7 +439,7 @@ static void php_converter_do_get_encoding(php_converter_object *objval, UConvert
|
|||
|
||||
name = ucnv_getName(cnv, &objval->error.code);
|
||||
if (U_FAILURE(objval->error.code)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getName()", objval->error.code);
|
||||
THROW_UFAILURE(objval, objval->error.code);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ static void php_converter_do_get_type(php_converter_object *objval, UConverter *
|
|||
|
||||
t = ucnv_getType(cnv);
|
||||
if (U_FAILURE(objval->error.code)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getType", objval->error.code);
|
||||
THROW_UFAILURE(objval, objval->error.code);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ PHP_METHOD(UConverter, setSubstChars) {
|
|||
UErrorCode error = U_ZERO_ERROR;
|
||||
ucnv_setSubstChars(objval->src, chars, chars_len, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_setSubstChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
ret = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -566,7 +566,7 @@ PHP_METHOD(UConverter, setSubstChars) {
|
|||
UErrorCode error = U_ZERO_ERROR;
|
||||
ucnv_setSubstChars(objval->dest, chars, chars_len, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_setSubstChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
ret = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -597,7 +597,7 @@ PHP_METHOD(UConverter, getSubstChars) {
|
|||
*/
|
||||
ucnv_getSubstChars(objval->src, chars, &chars_len, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getSubstChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv,
|
|||
/* Get necessary buffer size first */
|
||||
temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, &error);
|
||||
if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) {
|
||||
THROW_UFAILURE(objval, "ucnv_toUChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
return NULL;
|
||||
}
|
||||
temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar));
|
||||
|
@ -633,7 +633,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv,
|
|||
error = U_ZERO_ERROR;
|
||||
temp_len = ucnv_toUChars(src_cnv, temp, temp_len, src, src_len, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_toUChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
efree(temp);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv,
|
|||
/* Get necessary output buffer size */
|
||||
ret_len = ucnv_fromUChars(dest_cnv, NULL, 0, temp, temp_len, &error);
|
||||
if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) {
|
||||
THROW_UFAILURE(objval, "ucnv_fromUChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
efree(temp);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv,
|
|||
ZSTR_LEN(ret) = ucnv_fromUChars(dest_cnv, ZSTR_VAL(ret), ret_len+1, temp, temp_len, &error);
|
||||
efree(temp);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_fromUChars", error);
|
||||
THROW_UFAILURE(objval, error);
|
||||
zend_string_efree(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -758,7 +758,7 @@ PHP_METHOD(UConverter, transcode) {
|
|||
}
|
||||
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(NULL, "transcode", error);
|
||||
THROW_UFAILURE(NULL, error);
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -831,7 +831,7 @@ PHP_METHOD(UConverter, getAliases) {
|
|||
|
||||
count = ucnv_countAliases(name, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(NULL, "ucnv_countAliases", error);
|
||||
THROW_UFAILURE(NULL, error);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -843,7 +843,7 @@ PHP_METHOD(UConverter, getAliases) {
|
|||
error = U_ZERO_ERROR;
|
||||
alias = ucnv_getAlias(name, i, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(NULL, "ucnv_getAlias", error);
|
||||
THROW_UFAILURE(NULL, error);
|
||||
zend_array_destroy(Z_ARR_P(return_value));
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ PHP_METHOD(UConverter, getStandards) {
|
|||
UErrorCode error = U_ZERO_ERROR;
|
||||
const char *name = ucnv_getStandard(i, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(NULL, "ucnv_getStandard", error);
|
||||
THROW_UFAILURE(NULL, error);
|
||||
zend_array_destroy(Z_ARR_P(return_value));
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ U_CFUNC PHP_FUNCTION(datefmt_get_timezone)
|
|||
TimeZone *tz_clone = tz.clone();
|
||||
if (UNEXPECTED(tz_clone == NULL)) {
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
|
||||
"datefmt_get_timezone: Out of memory when cloning time zone",
|
||||
0);
|
||||
"Out of memory when cloning time zone");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -95,7 +94,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_timezone)
|
|||
DATE_FORMAT_METHOD_FETCH_OBJECT;
|
||||
|
||||
timezone = timezone_process_timezone_argument(timezone_zv,
|
||||
INTL_DATA_ERROR_P(dfo), "datefmt_set_timezone");
|
||||
INTL_DATA_ERROR_P(dfo));
|
||||
if (timezone == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -146,8 +145,7 @@ U_CFUNC PHP_FUNCTION(datefmt_get_calendar_object)
|
|||
Calendar *cal_clone = cal->clone();
|
||||
if (UNEXPECTED(cal_clone == NULL)) {
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
|
||||
"datefmt_get_calendar_object: Out of memory when cloning "
|
||||
"calendar", 0);
|
||||
"Out of memory when cloning calendar");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -187,7 +185,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar)
|
|||
// must store the requested locale on object creation
|
||||
|
||||
if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale,
|
||||
"datefmt_set_calendar", INTL_DATA_ERROR_P(dfo), cal, cal_type, cal_owned) == FAILURE
|
||||
INTL_DATA_ERROR_P(dfo), cal, cal_type, cal_owned) == FAILURE
|
||||
) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -197,8 +195,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar)
|
|||
TimeZone *old_timezone = fetch_datefmt(dfo)->getTimeZone().clone();
|
||||
if (UNEXPECTED(old_timezone == NULL)) {
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
|
||||
"datefmt_set_calendar: Out of memory when cloning calendar",
|
||||
0);
|
||||
"Out of memory when cloning calendar");
|
||||
delete cal;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -207,8 +204,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar)
|
|||
cal = cal->clone();
|
||||
if (UNEXPECTED(cal == NULL)) {
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
|
||||
"datefmt_set_calendar: Out of memory when cloning calendar",
|
||||
0);
|
||||
"Out of memory when cloning calendar");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ extern "C" {
|
|||
UDAT_PATTERN == (i))
|
||||
|
||||
/* {{{ */
|
||||
static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
zval *object;
|
||||
char *locale_str;
|
||||
|
@ -81,28 +81,23 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
Z_PARAM_STRING_OR_NULL(pattern_str, pattern_str_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
if (DATE_FORMAT_OBJECT(dfo) != NULL) {
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: cannot call constructor twice", 0);
|
||||
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "cannot call constructor twice");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (!INTL_UDATE_FMT_OK(date_type)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid date format style", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid date format style");
|
||||
return FAILURE;
|
||||
}
|
||||
if (!INTL_UDATE_FMT_OK(time_type)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid time format style");
|
||||
return FAILURE;
|
||||
}
|
||||
if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "time format must be UDAT_PATTERN if date format is UDAT_PATTERN");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
@ -118,7 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
}
|
||||
|
||||
/* process calendar */
|
||||
if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale, "datefmt_create",
|
||||
if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale,
|
||||
INTL_DATA_ERROR_P(dfo), cal, calendar_type, calendar_owned) == FAILURE
|
||||
) {
|
||||
goto error;
|
||||
|
@ -130,7 +125,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
if (explicit_tz || calendar_owned ) {
|
||||
//we have an explicit time zone or a non-object calendar
|
||||
timezone = timezone_process_timezone_argument(timezone_zv,
|
||||
INTL_DATA_ERROR_P(dfo), "datefmt_create");
|
||||
INTL_DATA_ERROR_P(dfo));
|
||||
if (timezone == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
@ -142,8 +137,8 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
|
||||
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
|
||||
/* object construction -> only set global error */
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
|
||||
"error converting pattern to UTF-16", 0);
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo),
|
||||
"error converting pattern to UTF-16");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +150,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
if (pattern_str && pattern_str_len > 0) {
|
||||
udat_applyPattern(DATE_FORMAT_OBJECT(dfo), true, svalue, slength);
|
||||
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: error applying pattern", 0);
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "error applying pattern");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -173,8 +168,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
|||
df->adoptTimeZone(timezone);
|
||||
}
|
||||
} else {
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
|
||||
"formatter creation failed", 0);
|
||||
intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "date formatter creation failed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -203,7 +197,7 @@ error:
|
|||
U_CFUNC PHP_FUNCTION( datefmt_create )
|
||||
{
|
||||
object_init_ex( return_value, IntlDateFormatter_ce_ptr );
|
||||
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -213,21 +207,18 @@ U_CFUNC PHP_FUNCTION( datefmt_create )
|
|||
/* {{{ IntlDateFormatter object constructor. */
|
||||
U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
/* return_value param is being changed, therefore we will always return
|
||||
* NULL here */
|
||||
return_value = ZEND_THIS;
|
||||
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_string *err = intl_error_get_message(NULL);
|
||||
zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL));
|
||||
zend_string_release_ex(err, 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -66,17 +66,17 @@ static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo,
|
|||
|
||||
if ((ele_value = zend_hash_str_find_deref(hash_arr, key_name, strlen(key_name))) != NULL) {
|
||||
if(Z_TYPE_P(ele_value) != IS_LONG) {
|
||||
spprintf(&message, 0, "datefmt_format: parameter array contains "
|
||||
spprintf(&message, 0, "parameter array contains "
|
||||
"a non-integer element for key '%s'", key_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message);
|
||||
efree(message);
|
||||
} else {
|
||||
if (Z_LVAL_P(ele_value) > INT32_MAX ||
|
||||
Z_LVAL_P(ele_value) < INT32_MIN) {
|
||||
spprintf(&message, 0, "datefmt_format: value " ZEND_LONG_FMT " is out of "
|
||||
spprintf(&message, 0, "value " ZEND_LONG_FMT " is out of "
|
||||
"bounds for a 32-bit integer in key '%s'",
|
||||
Z_LVAL_P(ele_value), key_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message);
|
||||
efree(message);
|
||||
} else {
|
||||
result = Z_LVAL_P(ele_value);
|
||||
|
@ -121,8 +121,7 @@ static UDate internal_get_timestamp(IntlDateFormatter_object *dfo,
|
|||
&INTL_DATA_ERROR_CODE(dfo));
|
||||
|
||||
if (INTL_DATA_ERROR_CODE(dfo) != U_ZERO_ERROR) {
|
||||
intl_errors_set(err, INTL_DATA_ERROR_CODE(dfo), "datefmt_format: "
|
||||
"error cloning calendar", 0);
|
||||
intl_errors_set(err, INTL_DATA_ERROR_CODE(dfo), "error cloning calendar");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,8 +148,6 @@ PHP_FUNCTION(datefmt_format)
|
|||
/* Parse parameters. */
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz",
|
||||
&object, IntlDateFormatter_ce_ptr, &zarg) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: unable "
|
||||
"to parse input params", 0 );
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
@ -163,10 +160,9 @@ PHP_FUNCTION(datefmt_format)
|
|||
}
|
||||
|
||||
timestamp = internal_get_timestamp(dfo, hash_arr);
|
||||
INTL_METHOD_CHECK_STATUS(dfo, "datefmt_format: date formatting failed")
|
||||
INTL_METHOD_CHECK_STATUS(dfo, "date formatting failed")
|
||||
} else {
|
||||
timestamp = intl_zval_to_millis(zarg, INTL_DATA_ERROR_P(dfo),
|
||||
"datefmt_format");
|
||||
timestamp = intl_zval_to_millis(zarg, INTL_DATA_ERROR_P(dfo));
|
||||
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
HashTable *ht = Z_ARRVAL_P(format);
|
||||
if (zend_hash_num_elements(ht) != 2) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: bad format; if array, it must have "
|
||||
"two elements", 0);
|
||||
"bad format; if array, it must have "
|
||||
"two elements");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
if (!valid_format(z)) {
|
||||
if (idx == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: bad format; the date format (first "
|
||||
"element of the array) is not valid", 0);
|
||||
"bad format; the date format (first "
|
||||
"element of the array) is not valid");
|
||||
} else {
|
||||
ZEND_ASSERT(idx == 1 && "We checked that there are two elements above");
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: bad format; the time format (second "
|
||||
"element of the array) is not valid", 0);
|
||||
"bad format; the time format (second "
|
||||
"element of the array) is not valid");
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
} else if (Z_TYPE_P(format) == IS_LONG) {
|
||||
if (!valid_format(format)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: the date/time format type is invalid",
|
||||
0);
|
||||
"the date/time format type is invalid");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
dateStyle = timeStyle = (DateFormat::EStyle)Z_LVAL_P(format);
|
||||
|
@ -138,7 +137,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
}
|
||||
if (Z_STRLEN_P(format) == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: the format is empty", 0);
|
||||
"the format is empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
pattern = true;
|
||||
|
@ -154,37 +153,31 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
Calendar *obj_cal = calendar_fetch_native_calendar(object);
|
||||
if (obj_cal == NULL) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"datefmt_format_object: bad IntlCalendar instance: "
|
||||
"not initialized properly", 0);
|
||||
"bad IntlCalendar instance: not initialized properly");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
timeZone = std::unique_ptr<TimeZone>(obj_cal->getTimeZone().clone());
|
||||
date = obj_cal->getTime(status);
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status,
|
||||
"datefmt_format_object: error obtaining instant from "
|
||||
"IntlCalendar", 0);
|
||||
"error obtaining instant from IntlCalendar");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
cal = std::unique_ptr<Calendar>(obj_cal->clone());
|
||||
} else if (instanceof_function(instance_ce, php_date_get_interface_ce())) {
|
||||
TimeZone *tz;
|
||||
if (intl_datetime_decompose(object, &date, &tz, NULL,
|
||||
"datefmt_format_object") == FAILURE) {
|
||||
if (intl_datetime_decompose(object, &date, &tz, NULL) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
timeZone = std::unique_ptr<TimeZone>(tz);
|
||||
cal = std::unique_ptr<Calendar>(new GregorianCalendar(Locale::createFromName(locale_str), status));
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status,
|
||||
"datefmt_format_object: could not create GregorianCalendar",
|
||||
0);
|
||||
intl_error_set(NULL, status, "could not create GregorianCalendar");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
intl_error_set(NULL, status, "datefmt_format_object: the passed object "
|
||||
"must be an instance of either IntlCalendar or DateTimeInterface",
|
||||
0);
|
||||
intl_error_set(NULL, status, "the passed object must be an instance "
|
||||
"of either IntlCalendar or DateTimeInterface");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -196,9 +189,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
status));
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status,
|
||||
"datefmt_format_object: could not create SimpleDateFormat",
|
||||
0);
|
||||
intl_error_set(NULL, status, "could not create SimpleDateFormat");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -206,9 +197,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
Locale::createFromName(locale_str)));
|
||||
|
||||
if (df == NULL) { /* according to ICU sources, this should never happen */
|
||||
intl_error_set(NULL, status,
|
||||
"datefmt_format_object: could not create DateFormat",
|
||||
0);
|
||||
intl_error_set(NULL, status, "could not create DateFormat");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -224,9 +213,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
|
|||
|
||||
u8str = intl_charFromString(result, &status);
|
||||
if (!u8str) {
|
||||
intl_error_set(NULL, status,
|
||||
"datefmt_format_object: error converting result to UTF-8",
|
||||
0);
|
||||
intl_error_set(NULL, status, "error converting result to UTF-8");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_STR(u8str);
|
||||
|
|
|
@ -28,11 +28,10 @@ extern "C" {
|
|||
|
||||
using icu::GregorianCalendar;
|
||||
|
||||
int datefmt_process_calendar_arg(
|
||||
zend_result datefmt_process_calendar_arg(
|
||||
zend_object *calendar_obj, zend_long calendar_long, bool calendar_is_null, Locale const& locale,
|
||||
const char *func_name, intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned
|
||||
intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned
|
||||
) {
|
||||
char *msg;
|
||||
UErrorCode status = UErrorCode();
|
||||
|
||||
if (calendar_is_null) {
|
||||
|
@ -45,13 +44,11 @@ int datefmt_process_calendar_arg(
|
|||
} else if (!calendar_obj) {
|
||||
zend_long v = calendar_long;
|
||||
if (v != (zend_long)UCAL_TRADITIONAL && v != (zend_long)UCAL_GREGORIAN) {
|
||||
spprintf(&msg, 0, "%s: Invalid value for calendar type; it must be "
|
||||
"one of IntlDateFormatter::TRADITIONAL (locale's default "
|
||||
"calendar) or IntlDateFormatter::GREGORIAN. "
|
||||
"Alternatively, it can be an IntlCalendar object",
|
||||
func_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1);
|
||||
efree(msg);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Invalid value for calendar type; it must be one of "
|
||||
"IntlDateFormatter::TRADITIONAL (locale's default calendar) or"
|
||||
" IntlDateFormatter::GREGORIAN. Alternatively, it can be an "
|
||||
"IntlCalendar object");
|
||||
return FAILURE;
|
||||
} else if (v == (zend_long)UCAL_TRADITIONAL) {
|
||||
cal = Calendar::createInstance(locale, status);
|
||||
|
@ -65,10 +62,7 @@ int datefmt_process_calendar_arg(
|
|||
} else if (calendar_obj) {
|
||||
cal = calendar_fetch_native_calendar(calendar_obj);
|
||||
if (cal == NULL) {
|
||||
spprintf(&msg, 0, "%s: Found unconstructed IntlCalendar object",
|
||||
func_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1);
|
||||
efree(msg);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar object");
|
||||
return FAILURE;
|
||||
}
|
||||
calendar_owned = false;
|
||||
|
@ -76,10 +70,8 @@ int datefmt_process_calendar_arg(
|
|||
cal_int_type = -1;
|
||||
|
||||
} else {
|
||||
spprintf(&msg, 0, "%s: Invalid calendar argument; should be an integer "
|
||||
"or an IntlCalendar instance", func_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1);
|
||||
efree(msg);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Invalid calendar argument; should be an integer or an IntlCalendar instance");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
@ -87,9 +79,7 @@ int datefmt_process_calendar_arg(
|
|||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
spprintf(&msg, 0, "%s: Failure instantiating calendar", func_name);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1);
|
||||
efree(msg);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, "Failure instantiating calendar");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ using icu::Locale;
|
|||
using icu::Calendar;
|
||||
using icu::DateFormat;
|
||||
|
||||
int datefmt_process_calendar_arg(
|
||||
zend_result datefmt_process_calendar_arg(
|
||||
zend_object *calendar_obj, zend_long calendar_long, bool calendar_is_null, Locale const& locale,
|
||||
const char *func_name, intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned
|
||||
intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned
|
||||
);
|
||||
|
||||
#endif /* DATEFORMAT_HELPERS_H */
|
||||
|
|
|
@ -150,7 +150,7 @@ PHP_FUNCTION(datefmt_parse)
|
|||
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
|
||||
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
|
||||
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
parse_pos = (int32_t)long_parse_pos;
|
||||
|
@ -193,7 +193,7 @@ PHP_METHOD(IntlDateFormatter, parseToCalendar)
|
|||
}
|
||||
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
|
||||
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
parse_pos = (int32_t)long_parse_pos;
|
||||
|
@ -232,7 +232,7 @@ PHP_FUNCTION(datefmt_localtime)
|
|||
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
|
||||
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
|
||||
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
|
||||
intl_error_set_custom_msg(NULL, "String index is out of valid range.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
parse_pos = (int32_t)long_parse_pos;
|
||||
|
|
|
@ -30,7 +30,7 @@ using icu::DateTimePatternGenerator;
|
|||
using icu::Locale;
|
||||
using icu::StringPiece;
|
||||
|
||||
static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
char *locale_str;
|
||||
size_t locale_len = 0;
|
||||
|
@ -44,15 +44,10 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *
|
|||
Z_PARAM_STRING_OR_NULL(locale_str, locale_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
DTPATTERNGEN_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
if (dtpgo->dtpg != NULL) {
|
||||
intl_errors_set(DTPATTERNGEN_ERROR_P(dtpgo), U_ILLEGAL_ARGUMENT_ERROR, "Cannot call constructor twice", 0);
|
||||
intl_errors_set(DTPATTERNGEN_ERROR_P(dtpgo), U_ILLEGAL_ARGUMENT_ERROR, "Cannot call constructor twice");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
@ -68,8 +63,7 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *
|
|||
|
||||
if (U_FAILURE(DTPATTERNGEN_ERROR_CODE(dtpgo))) {
|
||||
intl_error_set(NULL, DTPATTERNGEN_ERROR_CODE(dtpgo),
|
||||
"Error creating DateTimePatternGenerator",
|
||||
0);
|
||||
"Error creating DateTimePatternGenerator");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
@ -79,7 +73,7 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *
|
|||
U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create )
|
||||
{
|
||||
object_init_ex( return_value, IntlDatePatternGenerator_ce_ptr );
|
||||
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -87,22 +81,19 @@ U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create )
|
|||
|
||||
U_CFUNC PHP_METHOD( IntlDatePatternGenerator, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
/* return_value param is being changed, therefore we will always return
|
||||
* NULL here */
|
||||
return_value = ZEND_THIS;
|
||||
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_string *err = intl_error_get_message(NULL);
|
||||
zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL));
|
||||
zend_string_release_ex(err, 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ PHP_FUNCTION( numfmt_get_symbol )
|
|||
}
|
||||
|
||||
if(symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "numfmt_get_symbol: invalid symbol value", 0 );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ PHP_FUNCTION( numfmt_set_symbol )
|
|||
}
|
||||
|
||||
if (symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "numfmt_set_symbol: invalid symbol value", 0 );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ PHP_FUNCTION( numfmt_set_pattern )
|
|||
if (U_FAILURE(INTL_DATA_ERROR_CODE(nfo))) {
|
||||
char *msg;
|
||||
spprintf(&msg, 0, "Error setting pattern value at line %d, offset %d", spattern_error.line, spattern_error.offset);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(nfo), msg, 1);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(nfo), msg);
|
||||
efree(msg);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ PHP_FUNCTION( numfmt_format_currency )
|
|||
|
||||
if( U_FAILURE( INTL_DATA_ERROR_CODE((nfo)) ) ) {
|
||||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((nfo)) );
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(nfo), "Number formatting failed", 0 );
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(nfo), "Number formatting failed");
|
||||
RETVAL_FALSE;
|
||||
if (formatted != format_buf) {
|
||||
efree(formatted);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "intl_convert.h"
|
||||
|
||||
/* {{{ */
|
||||
static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
char* locale;
|
||||
char* pattern = NULL;
|
||||
|
@ -41,11 +41,6 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
Z_PARAM_STRING_OR_NULL(pattern, pattern_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
|
||||
object = return_value;
|
||||
FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
@ -57,7 +52,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
/* Convert pattern (if specified) to UTF-16. */
|
||||
if(pattern && pattern_len) {
|
||||
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(nfo));
|
||||
INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16");
|
||||
INTL_CTOR_CHECK_STATUS(nfo, "error converting pattern to UTF-16");
|
||||
}
|
||||
|
||||
if(locale_len == 0) {
|
||||
|
@ -76,7 +71,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
efree(spattern);
|
||||
}
|
||||
|
||||
INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed");
|
||||
INTL_CTOR_CHECK_STATUS(nfo, "number formatter creation failed");
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -85,7 +80,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
PHP_FUNCTION( numfmt_create )
|
||||
{
|
||||
object_init_ex( return_value, NumberFormatter_ce_ptr );
|
||||
if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -95,18 +90,17 @@ PHP_FUNCTION( numfmt_create )
|
|||
/* {{{ NumberFormatter object constructor. */
|
||||
PHP_METHOD( NumberFormatter, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
return_value = ZEND_THIS;
|
||||
if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ PHP_FUNCTION(grapheme_strlen)
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16");
|
||||
if (ustring) {
|
||||
efree( ustring );
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ PHP_FUNCTION(grapheme_substr)
|
|||
grapheme_substr_ascii(str, str_len, start, (int32_t)length, &sub_str, &asub_str_len);
|
||||
|
||||
if ( NULL == sub_str ) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: invalid parameters", 1 );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid parameters");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ PHP_FUNCTION(grapheme_substr)
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16");
|
||||
if (ustr) {
|
||||
efree( ustr );
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ PHP_FUNCTION(grapheme_substr)
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8");
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ PHP_FUNCTION(grapheme_substr)
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8");
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ PHP_FUNCTION(grapheme_extract)
|
|||
}
|
||||
|
||||
if ( lstart > INT32_MAX || lstart < 0 || (size_t)lstart >= str_len ) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: start not contained in string", 0 );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "start not contained in string");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -779,7 +779,7 @@ PHP_FUNCTION(grapheme_extract)
|
|||
start++;
|
||||
if ( pstr >= str_end ) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"grapheme_extract: invalid input string", 0 );
|
||||
"grapheme_extract: invalid input string");
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -808,7 +808,7 @@ PHP_FUNCTION(grapheme_extract)
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error opening UTF-8 text");
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ PHP_FUNCTION(grapheme_str_split)
|
|||
intl_error_set_code( NULL, ustatus );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error opening UTF-8 text");
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
|
||||
intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16");
|
||||
RETVAL_FALSE;
|
||||
goto out_ustring1;
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
|
||||
intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16");
|
||||
RETVAL_FALSE;
|
||||
goto out_ustring2;
|
||||
}
|
||||
|
@ -1013,7 +1013,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
bi1 = grapheme_get_break_iterator(u_break_iterator_buffer1, &ustatus);
|
||||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #1 ($string1)", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #1 ($string1)");
|
||||
RETVAL_FALSE;
|
||||
goto out_bi1;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
bi2 = grapheme_get_break_iterator(u_break_iterator_buffer2, &ustatus);
|
||||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #2 ($string2)", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #2 ($string2)");
|
||||
RETVAL_FALSE;
|
||||
goto out_bi2;
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
|
||||
intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #1 ($string1)", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #1 ($string1)");
|
||||
RETVAL_FALSE;
|
||||
goto out_bi2;
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
|
||||
intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #2 ($string2)", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #2 ($string2)");
|
||||
RETVAL_FALSE;
|
||||
goto out_bi2;
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ PHP_FUNCTION(grapheme_levenshtein)
|
|||
if (U_FAILURE(ustatus)) {
|
||||
intl_error_set_code(NULL, ustatus);
|
||||
|
||||
intl_error_set_custom_msg(NULL, "Error on ucol_open", 0);
|
||||
intl_error_set_custom_msg(NULL, "Error on ucol_open");
|
||||
RETVAL_FALSE;
|
||||
goto out_collator;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void grapheme_substr_ascii(char *str, size_t str_len, int32_t f, int32_t l, char
|
|||
#define STRPOS_CHECK_STATUS(status, error) \
|
||||
if ( U_FAILURE( (status) ) ) { \
|
||||
intl_error_set_code( NULL, (status) ); \
|
||||
intl_error_set_custom_msg( NULL, (error), 0 ); \
|
||||
intl_error_set_custom_msg( NULL, (error)); \
|
||||
ret_pos = -1; \
|
||||
goto finish; \
|
||||
}
|
||||
|
|
|
@ -42,12 +42,7 @@ static zend_result php_intl_idn_check_status(UErrorCode err, const char *msg)
|
|||
{
|
||||
intl_error_set_code(NULL, err);
|
||||
if (U_FAILURE(err)) {
|
||||
char *buff;
|
||||
spprintf(&buff, 0, "%s: %s",
|
||||
get_active_function_name(),
|
||||
msg);
|
||||
intl_error_set_custom_msg(NULL, buff, 1);
|
||||
efree(buff);
|
||||
intl_error_set_custom_msg(NULL, msg);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, (err) ); \
|
||||
if( U_FAILURE((err)) ) \
|
||||
{ \
|
||||
intl_error_set_custom_msg( NULL, msg, 0 ); \
|
||||
intl_error_set_custom_msg( NULL, msg); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, (err) ); \
|
||||
if( U_FAILURE((err)) ) \
|
||||
{ \
|
||||
intl_error_set_custom_msg( NULL, msg, 0 ); \
|
||||
intl_error_set_custom_msg( NULL, msg); \
|
||||
RETURN_NULL(); \
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
|
||||
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
|
||||
{ \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
|
||||
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
|
||||
{ \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \
|
||||
RETVAL_FALSE; \
|
||||
goto label; \
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
|
||||
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
|
||||
{ \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \
|
||||
zval_ptr_dtor(return_value); \
|
||||
RETURN_NULL(); \
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ typedef struct _intl_data {
|
|||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
|
||||
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
|
||||
{ \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \
|
||||
return FAILURE; \
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ typedef struct _intl_data {
|
|||
if((locale_len) > INTL_MAX_LOCALE_LEN) { \
|
||||
char *_msg; \
|
||||
spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg); \
|
||||
efree(_msg); \
|
||||
RETURN_NULL(); \
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ typedef struct _intl_data {
|
|||
if((locale_len) > INTL_MAX_LOCALE_LEN) { \
|
||||
char *_msg; \
|
||||
spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg); \
|
||||
efree(_msg); \
|
||||
return FAILURE; \
|
||||
}
|
||||
|
|
|
@ -42,12 +42,10 @@ static void intl_free_custom_error_msg( intl_error* err )
|
|||
if( !err && !( err = intl_g_error_get( ) ) )
|
||||
return;
|
||||
|
||||
if(err->free_custom_error_message ) {
|
||||
efree( err->custom_error_message );
|
||||
if (err->custom_error_message) {
|
||||
zend_string_release_ex(err->custom_error_message, false);
|
||||
err->custom_error_message = NULL;
|
||||
}
|
||||
|
||||
err->custom_error_message = NULL;
|
||||
err->free_custom_error_message = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -70,7 +68,6 @@ void intl_error_init( intl_error* err )
|
|||
|
||||
err->code = U_ZERO_ERROR;
|
||||
err->custom_error_message = NULL;
|
||||
err->free_custom_error_message = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -87,28 +84,41 @@ void intl_error_reset( intl_error* err )
|
|||
/* }}} */
|
||||
|
||||
/* {{{ Set last error message to msg copying it if needed. */
|
||||
void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg )
|
||||
void intl_error_set_custom_msg( intl_error* err, const char* msg)
|
||||
{
|
||||
if( !msg )
|
||||
/* See ext/intl/tests/bug70451.phpt and uchar.c:zif_IntlChar_charFromName */
|
||||
if (UNEXPECTED(msg == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
zend_string *method_or_func = get_active_function_or_method_name();
|
||||
zend_string *prefixed_message = zend_string_concat3(
|
||||
ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func),
|
||||
ZEND_STRL("(): "),
|
||||
msg, strlen(msg)
|
||||
);
|
||||
zend_string_release_ex(method_or_func, false);
|
||||
|
||||
if( !err ) {
|
||||
if( INTL_G( error_level ) )
|
||||
if (INTL_G(error_level)) {
|
||||
/* Docref will prefix the function/method for us, so use original message */
|
||||
php_error_docref( NULL, INTL_G( error_level ), "%s", msg );
|
||||
if( INTL_G( use_exceptions ) )
|
||||
zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg );
|
||||
}
|
||||
if (INTL_G(use_exceptions)) {
|
||||
/* Use this variant as we have a zend_string already */
|
||||
zend_throw_error_exception(IntlException_ce_ptr, prefixed_message, 0, 0);
|
||||
}
|
||||
}
|
||||
if( !err && !( err = intl_g_error_get( ) ) )
|
||||
if (!err && !(err = intl_g_error_get() )) {
|
||||
zend_string_release_ex(prefixed_message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Free previous message if any */
|
||||
intl_free_custom_error_msg( err );
|
||||
|
||||
/* Mark message copied if any */
|
||||
err->free_custom_error_message = copyMsg;
|
||||
|
||||
/* Set user's error text message */
|
||||
err->custom_error_message = copyMsg ? estrdup( msg ) : (char *) msg;
|
||||
err->custom_error_message = prefixed_message;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -116,21 +126,22 @@ void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg )
|
|||
zend_string * intl_error_get_message( intl_error* err )
|
||||
{
|
||||
const char *uErrorName = NULL;
|
||||
zend_string *errMessage = 0;
|
||||
zend_string *errMessage = NULL;
|
||||
|
||||
if( !err && !( err = intl_g_error_get( ) ) )
|
||||
return ZSTR_EMPTY_ALLOC();
|
||||
|
||||
uErrorName = u_errorName( err->code );
|
||||
size_t uErrorLen = strlen(uErrorName);
|
||||
|
||||
/* Format output string */
|
||||
if( err->custom_error_message )
|
||||
{
|
||||
errMessage = strpprintf(0, "%s: %s", err->custom_error_message, uErrorName );
|
||||
}
|
||||
else
|
||||
{
|
||||
errMessage = strpprintf(0, "%s", uErrorName );
|
||||
if (err->custom_error_message) {
|
||||
errMessage = zend_string_concat3(
|
||||
ZSTR_VAL(err->custom_error_message), ZSTR_LEN(err->custom_error_message),
|
||||
ZEND_STRL(": "),
|
||||
uErrorName, uErrorLen);
|
||||
} else {
|
||||
errMessage = zend_string_init(uErrorName, strlen(uErrorName), false);
|
||||
}
|
||||
|
||||
return errMessage;
|
||||
|
@ -158,18 +169,18 @@ UErrorCode intl_error_get_code( intl_error* err )
|
|||
/* }}} */
|
||||
|
||||
/* {{{ Set error code and message. */
|
||||
void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg )
|
||||
void intl_error_set( intl_error* err, UErrorCode code, const char* msg)
|
||||
{
|
||||
intl_error_set_code( err, code );
|
||||
intl_error_set_custom_msg( err, msg, copyMsg );
|
||||
intl_error_set_custom_msg( err, msg);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Set error code and message. */
|
||||
void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg )
|
||||
void intl_errors_set( intl_error* err, UErrorCode code, const char* msg)
|
||||
{
|
||||
intl_errors_set_code( err, code );
|
||||
intl_errors_set_custom_msg( err, msg, copyMsg );
|
||||
intl_errors_set_custom_msg( err, msg);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -184,12 +195,12 @@ void intl_errors_reset( intl_error* err )
|
|||
/* }}} */
|
||||
|
||||
/* {{{ */
|
||||
void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg )
|
||||
void intl_errors_set_custom_msg(intl_error* err, const char* msg)
|
||||
{
|
||||
if(err) {
|
||||
intl_error_set_custom_msg( err, msg, copyMsg );
|
||||
intl_error_set_custom_msg( err, msg);
|
||||
}
|
||||
intl_error_set_custom_msg( NULL, msg, copyMsg );
|
||||
intl_error_set_custom_msg( NULL, msg);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -23,26 +23,25 @@
|
|||
|
||||
#define INTL_ERROR_CODE(e) (e).code
|
||||
|
||||
typedef struct _intl_error {
|
||||
UErrorCode code;
|
||||
int free_custom_error_message;
|
||||
char* custom_error_message;
|
||||
typedef struct {
|
||||
zend_string *custom_error_message;
|
||||
UErrorCode code;
|
||||
} intl_error;
|
||||
|
||||
intl_error* intl_error_create( void );
|
||||
void intl_error_init( intl_error* err );
|
||||
void intl_error_reset( intl_error* err );
|
||||
void intl_error_set_code( intl_error* err, UErrorCode err_code );
|
||||
void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
|
||||
void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
|
||||
void intl_error_set_custom_msg( intl_error* err, const char* msg);
|
||||
void intl_error_set( intl_error* err, UErrorCode code, const char* msg);
|
||||
UErrorCode intl_error_get_code( intl_error* err );
|
||||
zend_string* intl_error_get_message( intl_error* err );
|
||||
|
||||
// Wrappers to synchonize object's and global error structures.
|
||||
void intl_errors_reset( intl_error* err );
|
||||
void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
|
||||
void intl_errors_set_custom_msg( intl_error* err, const char* msg);
|
||||
void intl_errors_set_code( intl_error* err, UErrorCode err_code );
|
||||
void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
|
||||
void intl_errors_set( intl_error* err, UErrorCode code, const char* msg);
|
||||
|
||||
// Other error helpers
|
||||
smart_str intl_parse_error_to_string( UParseError* pe );
|
||||
|
|
|
@ -109,7 +109,7 @@ PHP_METHOD(IntlListFormatter, __construct)
|
|||
#endif
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status, "Constructor failed", 0);
|
||||
intl_error_set(NULL, status, "Constructor failed");
|
||||
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ PHP_METHOD(IntlListFormatter, format)
|
|||
}
|
||||
efree(items);
|
||||
efree(itemLengths);
|
||||
intl_error_set(NULL, status, "Failed to convert string to UTF-16", 0);
|
||||
intl_error_set(NULL, status, "Failed to convert string to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ PHP_METHOD(IntlListFormatter, format)
|
|||
resultLength = ulistfmt_format(LISTFORMATTER_OBJECT(obj), items, itemLengths, count, NULL, 0, &status);
|
||||
|
||||
if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
|
||||
intl_error_set(NULL, status, "Failed to format list", 0);
|
||||
intl_error_set(NULL, status, "Failed to format list");
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ PHP_METHOD(IntlListFormatter, format)
|
|||
if (result) {
|
||||
efree(result);
|
||||
}
|
||||
intl_error_set(NULL, status, "Failed to format list", 0);
|
||||
intl_error_set(NULL, status, "Failed to format list");
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ PHP_METHOD(IntlListFormatter, format)
|
|||
efree(result);
|
||||
|
||||
if (!ret) {
|
||||
intl_error_set(NULL, status, "Failed to convert result to UTF-8", 0);
|
||||
intl_error_set(NULL, status, "Failed to convert result to UTF-8");
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_NEW_STR(ret);
|
||||
|
|
|
@ -473,7 +473,6 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
|||
size_t loc_name_len = 0;
|
||||
|
||||
zend_string* tag_value = NULL;
|
||||
char* empty_result = "";
|
||||
|
||||
int result = 0;
|
||||
char* msg = NULL;
|
||||
|
@ -501,19 +500,18 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
|||
if( tag_value){
|
||||
zend_string_release_ex( tag_value, 0 );
|
||||
}
|
||||
RETURN_STRING( empty_result);
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
/* value found */
|
||||
if( tag_value){
|
||||
RETVAL_STR( tag_value );
|
||||
return;
|
||||
RETURN_STR( tag_value );
|
||||
}
|
||||
|
||||
/* Error encountered while fetching the value */
|
||||
if( result ==0) {
|
||||
spprintf(&msg , 0, "locale_get_%s : unable to get locale %s", tag_name , tag_name );
|
||||
intl_error_set( NULL, status, msg , 1 );
|
||||
spprintf(&msg , 0, "unable to get locale %s", tag_name );
|
||||
intl_error_set( NULL, status, msg);
|
||||
efree(msg);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -577,9 +575,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
|||
|
||||
if(loc_name_len > ULOC_FULLNAME_CAPACITY) {
|
||||
/* See bug 67397: overlong locale names cause trouble in uloc_getDisplayName */
|
||||
spprintf(&msg , 0, "locale_get_display_%s : name too long", tag_name );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 );
|
||||
efree(msg);
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "name too long");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -636,8 +632,8 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
|||
continue;
|
||||
}
|
||||
|
||||
spprintf(&msg, 0, "locale_get_display_%s : unable to get locale %s", tag_name , tag_name );
|
||||
intl_error_set( NULL, status, msg , 1 );
|
||||
spprintf(&msg, 0, "unable to get locale %s", tag_name );
|
||||
intl_error_set( NULL, status, msg);
|
||||
efree(msg);
|
||||
if( disp_name){
|
||||
efree( disp_name );
|
||||
|
@ -665,8 +661,8 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
|
|||
efree( disp_name );
|
||||
if( !u8str )
|
||||
{
|
||||
spprintf(&msg, 0, "locale_get_display_%s :error converting display name for %s to UTF-8", tag_name , tag_name );
|
||||
intl_error_set( NULL, status, msg , 1 );
|
||||
spprintf(&msg, 0, "error converting display name for %s to UTF-8", tag_name );
|
||||
intl_error_set( NULL, status, msg);
|
||||
efree(msg);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -773,7 +769,7 @@ U_CFUNC PHP_FUNCTION( locale_get_keywords )
|
|||
kw_value_str = zend_string_truncate(kw_value_str, kw_value_len, 0);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 );
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "Error encountered while getting the keyword value for the keyword");
|
||||
if( kw_value_str){
|
||||
zend_string_efree( kw_value_str );
|
||||
}
|
||||
|
@ -925,7 +921,7 @@ static int handleAppendResult( int result, smart_str* loc_name)
|
|||
intl_error_reset( NULL );
|
||||
if( result == FAILURE) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"locale_compose: parameter array element is not a string", 0 );
|
||||
"parameter array element is not a string");
|
||||
smart_str_free(loc_name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1284,16 +1280,14 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)
|
|||
/* canonicalize loc_range */
|
||||
can_loc_range=get_icu_value_internal( loc_range , LOC_CANONICALIZE_TAG , &result , 0);
|
||||
if( result <=0) {
|
||||
intl_error_set( NULL, status,
|
||||
"locale_filter_matches : unable to canonicalize loc_range" , 0 );
|
||||
intl_error_set(NULL, status, "unable to canonicalize loc_range");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* canonicalize lang_tag */
|
||||
can_lang_tag = get_icu_value_internal( lang_tag , LOC_CANONICALIZE_TAG , &result , 0);
|
||||
if( result <=0) {
|
||||
intl_error_set( NULL, status,
|
||||
"locale_filter_matches : unable to canonicalize lang_tag" , 0 );
|
||||
intl_error_set(NULL, status, "unable to canonicalize lang_tag");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1443,7 +1437,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr,
|
|||
cur_arr[cur_arr_len*2] = estrndup(Z_STRVAL_P(ele_value), Z_STRLEN_P(ele_value));
|
||||
result = strToMatch(Z_STRVAL_P(ele_value), cur_arr[cur_arr_len*2]);
|
||||
if(result == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag");
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
cur_arr[cur_arr_len*2+1] = Z_STRVAL_P(ele_value);
|
||||
|
@ -1458,14 +1452,14 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr,
|
|||
if(lang_tag) {
|
||||
zend_string_release_ex(lang_tag, 0);
|
||||
}
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag");
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
cur_arr[i*2] = reinterpret_cast<char *>(erealloc(cur_arr[i*2], lang_tag->len+1));
|
||||
result = strToMatch(lang_tag->val, cur_arr[i*2]);
|
||||
zend_string_release_ex(lang_tag, 0);
|
||||
if(result == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag");
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
}
|
||||
|
@ -1477,7 +1471,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr,
|
|||
can_loc_range = get_icu_value_internal(loc_range, LOC_CANONICALIZE_TAG, &result , 0);
|
||||
if( result != 1 || can_loc_range == NULL || !can_loc_range->val[0]) {
|
||||
/* Error */
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize loc_range" , 0 );
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize loc_range");
|
||||
if(can_loc_range) {
|
||||
zend_string_release_ex(can_loc_range, 0);
|
||||
}
|
||||
|
@ -1495,7 +1489,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr,
|
|||
}
|
||||
if(result == 0) {
|
||||
efree(cur_loc_range);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag");
|
||||
LOOKUP_CLEAN_RETURN(NULL);
|
||||
}
|
||||
|
||||
|
@ -1605,7 +1599,7 @@ U_CFUNC PHP_FUNCTION(locale_accept_from_http)
|
|||
len = end ? end-start : http_accept_len-(start-http_accept);
|
||||
if(len > ULOC_FULLNAME_CAPACITY) {
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"locale_accept_from_http: locale string too long", 0 );
|
||||
"locale string too long");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if(end) {
|
||||
|
@ -1615,11 +1609,11 @@ U_CFUNC PHP_FUNCTION(locale_accept_from_http)
|
|||
}
|
||||
|
||||
available = ures_openAvailableLocales(NULL, &status);
|
||||
INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to retrieve locale list");
|
||||
INTL_CHECK_STATUS(status, "failed to retrieve locale list");
|
||||
len = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN,
|
||||
&outResult, http_accept, available, &status);
|
||||
uenum_close(available);
|
||||
INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to find acceptable locale");
|
||||
INTL_CHECK_STATUS(status, "failed to find acceptable locale");
|
||||
if (len < 0 || outResult == ULOC_ACCEPT_FAILED) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -1658,7 +1652,7 @@ U_CFUNC PHP_FUNCTION(locale_add_likely_subtags)
|
|||
}
|
||||
|
||||
int32_t maximized_locale_len = uloc_addLikelySubtags(locale, maximized_locale, sizeof(maximized_locale), &status);
|
||||
INTL_CHECK_STATUS(status, "locale_add_likely_subtags: invalid locale");
|
||||
INTL_CHECK_STATUS(status, "invalid locale");
|
||||
if (maximized_locale_len < 0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -1681,7 +1675,7 @@ U_CFUNC PHP_FUNCTION(locale_minimize_subtags)
|
|||
}
|
||||
|
||||
int32_t minimized_locale_len = uloc_minimizeSubtags(locale, minimized_locale, sizeof(minimized_locale), &status);
|
||||
INTL_CHECK_STATUS(status, "locale_minimize_subtags: invalid locale");
|
||||
INTL_CHECK_STATUS(status, "invalid locale");
|
||||
if (minimized_locale_len < 0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "intl_convert.h"
|
||||
|
||||
/* {{{ */
|
||||
static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
char* locale;
|
||||
char* pattern;
|
||||
|
@ -43,18 +43,13 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
Z_PARAM_STRING(pattern, pattern_len)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
|
||||
MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
/* Convert pattern (if specified) to UTF-16. */
|
||||
if(pattern && pattern_len) {
|
||||
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(mfo));
|
||||
INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16");
|
||||
INTL_CTOR_CHECK_STATUS(mfo, "error converting pattern to UTF-16");
|
||||
} else {
|
||||
spattern_len = 0;
|
||||
spattern = NULL;
|
||||
|
@ -92,13 +87,13 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
smart_str_free( &parse_error_str );
|
||||
|
||||
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE( mfo ) );
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P( mfo ), msg, 1 );
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P( mfo ), msg);
|
||||
|
||||
efree( msg );
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed");
|
||||
INTL_CTOR_CHECK_STATUS(mfo, "message formatter creation failed");
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -107,7 +102,7 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
|
|||
PHP_FUNCTION( msgfmt_create )
|
||||
{
|
||||
object_init_ex( return_value, MessageFormatter_ce_ptr );
|
||||
if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -117,20 +112,17 @@ PHP_FUNCTION( msgfmt_create )
|
|||
/* {{{ MessageFormatter object constructor. */
|
||||
PHP_METHOD( MessageFormatter, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
return_value = ZEND_THIS;
|
||||
if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_string *err = intl_error_get_message(NULL);
|
||||
zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL));
|
||||
zend_string_release_ex(err, 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ PHP_FUNCTION( msgfmt_set_pattern )
|
|||
if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {
|
||||
char *msg;
|
||||
spprintf(&msg, 0, "Error setting symbol value at line %d, offset %d", spattern_error.line, spattern_error.offset);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(mfo), msg, 1);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(mfo), msg);
|
||||
efree(msg);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ PHP_FUNCTION( msgfmt_format_message )
|
|||
if( U_FAILURE(INTL_DATA_ERROR_CODE((mfo))) )
|
||||
{
|
||||
intl_error_set(/* intl_error* */ NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"msgfmt_format_message: error converting pattern to UTF-16", 0 );
|
||||
"error converting pattern to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -114,7 +114,7 @@ PHP_FUNCTION( msgfmt_format_message )
|
|||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
|
||||
intl_error_set(/* intl_error* */ NULL, U_INVALID_FORMAT_ERROR,
|
||||
"msgfmt_format_message: error converting pattern to quote-friendly format", 0 );
|
||||
"msgfmt_format_message: error converting pattern to quote-friendly format");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
@ -136,11 +136,11 @@ PHP_FUNCTION( msgfmt_format_message )
|
|||
|
||||
/* Pass NULL to intl_error* parameter to store message in global Intl error msg stack */
|
||||
intl_error_set_code(/* intl_error* */ NULL, INTL_DATA_ERROR_CODE( mfo ) );
|
||||
intl_errors_set_custom_msg(/* intl_error* */ NULL, msg, 1 );
|
||||
intl_errors_set_custom_msg(/* intl_error* */ NULL, msg);
|
||||
|
||||
efree( msg );
|
||||
} else {
|
||||
intl_errors_set_custom_msg(/* intl_error* */ NULL, "Creating message formatter failed", 0 );
|
||||
intl_errors_set_custom_msg(/* intl_error* */ NULL, "Creating message formatter failed");
|
||||
}
|
||||
umsg_close(MSG_FORMAT_OBJECT(mfo));
|
||||
RETURN_FALSE;
|
||||
|
|
|
@ -187,7 +187,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
|
|||
int32_t argNumber = name_part.getValue();
|
||||
if (argNumber < 0) {
|
||||
intl_errors_set(&err, U_INVALID_FORMAT_ERROR,
|
||||
"Found part with negative number", 0);
|
||||
"Found part with negative number");
|
||||
continue;
|
||||
}
|
||||
if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (zend_ulong)argNumber)) == NULL) {
|
||||
|
@ -196,7 +196,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
|
|||
storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (zend_ulong)argNumber, (void*)&bogusType, sizeof(bogusType));
|
||||
}
|
||||
} else {
|
||||
intl_errors_set(&err, U_INVALID_FORMAT_ERROR, "Invalid part type encountered", 0);
|
||||
intl_errors_set(&err, U_INVALID_FORMAT_ERROR, "Invalid part type encountered");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
|
|||
* is broken. */
|
||||
intl_errors_set(&err, U_PARSE_ERROR,
|
||||
"Expected UMSGPAT_PART_TYPE_ARG_TYPE part following "
|
||||
"UMSGPAT_ARG_TYPE_SIMPLE part", 0);
|
||||
"UMSGPAT_ARG_TYPE_SIMPLE part");
|
||||
continue;
|
||||
}
|
||||
} else if (argType == UMSGPAT_ARG_TYPE_PLURAL) {
|
||||
|
@ -262,7 +262,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
|
|||
/* We found a different type for the same arg! */
|
||||
if (*storedType != Formattable::kObject && *storedType != type) {
|
||||
intl_errors_set(&err, U_ARGUMENT_TYPE_MISMATCH,
|
||||
"Inconsistent types declared for an argument", 0);
|
||||
"Inconsistent types declared for an argument");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo,
|
|||
|
||||
if (UNEXPECTED(formats == NULL)) {
|
||||
intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
|
||||
"Out of memory retrieving subformats", 0);
|
||||
"Out of memory retrieving subformats");
|
||||
}
|
||||
|
||||
for (int i = 0; U_SUCCESS(err.code) && i < count; i++) {
|
||||
|
@ -343,7 +343,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo,
|
|||
if (used_tz == NULL) {
|
||||
zval nullzv;
|
||||
ZVAL_NULL(&nullzv);
|
||||
used_tz = timezone_process_timezone_argument(&nullzv, &err, "msgfmt_format");
|
||||
used_tz = timezone_process_timezone_argument(&nullzv, &err);
|
||||
if (used_tz == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
/* includes case where index < 0 because it's exposed as unsigned */
|
||||
if (UNEXPECTED(num_index > (zend_ulong)INT32_MAX)) {
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found negative or too large array key", 0);
|
||||
"Found negative or too large array key");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
char *message;
|
||||
spprintf(&message, 0,
|
||||
"Invalid UTF-8 data in argument key: '%s'", ZSTR_VAL(str_index));
|
||||
intl_errors_set(&err, err.code, message, 1);
|
||||
intl_errors_set(&err, err.code, message);
|
||||
efree(message);
|
||||
continue;
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
char *message;
|
||||
spprintf(&message, 0, "Invalid UTF-8 data in string argument: "
|
||||
"'%s'", ZSTR_VAL(str));
|
||||
intl_errors_set(&err, err.code, message, 1);
|
||||
intl_errors_set(&err, err.code, message);
|
||||
efree(message);
|
||||
delete text;
|
||||
continue;
|
||||
|
@ -481,7 +481,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
Z_DVAL_P(elem) < (double)INT32_MIN)) {
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found PHP float with absolute value too large for "
|
||||
"32 bit integer argument", 0);
|
||||
"32 bit integer argument");
|
||||
} else {
|
||||
tInt32 = (int32_t)Z_DVAL_P(elem);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
Z_LVAL_P(elem) < INT32_MIN)) {
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found PHP integer with absolute value too large "
|
||||
"for 32 bit integer argument", 0);
|
||||
"for 32 bit integer argument");
|
||||
} else {
|
||||
tInt32 = (int32_t)Z_LVAL_P(elem);
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
Z_DVAL_P(elem) < (double)U_INT64_MIN)) {
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found PHP float with absolute value too large for "
|
||||
"64 bit integer argument", 0);
|
||||
"64 bit integer argument");
|
||||
} else {
|
||||
tInt64 = (int64_t)Z_DVAL_P(elem);
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
}
|
||||
case Formattable::kDate:
|
||||
{
|
||||
double dd = intl_zval_to_millis(elem, &err, "msgfmt_format");
|
||||
double dd = intl_zval_to_millis(elem, &err);
|
||||
if (U_FAILURE(err.code)) {
|
||||
char *message;
|
||||
zend_string *u8key;
|
||||
|
@ -533,7 +533,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
if (u8key) {
|
||||
spprintf(&message, 0, "The argument for key '%s' "
|
||||
"cannot be used as a date or time", ZSTR_VAL(u8key));
|
||||
intl_errors_set(&err, err.code, message, 1);
|
||||
intl_errors_set(&err, err.code, message);
|
||||
zend_string_release_ex(u8key, 0);
|
||||
efree(message);
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
}
|
||||
default:
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found unsupported argument type", 0);
|
||||
"Found unsupported argument type");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -578,8 +578,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
spprintf(&message, 0, "No strategy to convert the "
|
||||
"value given for the argument with key '%s' "
|
||||
"is available", ZSTR_VAL(u8key));
|
||||
intl_errors_set(&err,
|
||||
U_ILLEGAL_ARGUMENT_ERROR, message, 1);
|
||||
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, message);
|
||||
zend_string_release_ex(u8key, 0);
|
||||
efree(message);
|
||||
}
|
||||
|
@ -602,7 +601,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
|
||||
if (U_FAILURE(err.code)) {
|
||||
intl_errors_set(&err, err.code,
|
||||
"Call to ICU MessageFormat::format() has failed", 0);
|
||||
"Call to ICU MessageFormat::format() has failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -610,8 +609,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
|
|||
*formatted = eumalloc(*formatted_len+1);
|
||||
resultStr.extract(*formatted, *formatted_len+1, err.code);
|
||||
if (U_FAILURE(err.code)) {
|
||||
intl_errors_set(&err, err.code,
|
||||
"Error copying format() result", 0);
|
||||
intl_errors_set(&err, err.code, "Error copying format() result");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ PHP_FUNCTION( msgfmt_parse_message )
|
|||
if( U_FAILURE(INTL_DATA_ERROR_CODE((mfo))) )
|
||||
{
|
||||
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"msgfmt_parse_message: error converting pattern to UTF-16", 0 );
|
||||
"error converting pattern to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -130,7 +130,7 @@ PHP_FUNCTION( normalizer_normalize )
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16");
|
||||
if (uinput) {
|
||||
efree( uinput );
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ PHP_FUNCTION( normalizer_normalize )
|
|||
* (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
|
||||
*/
|
||||
if( U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR && status != U_STRING_NOT_TERMINATED_WARNING ) {
|
||||
intl_error_set_custom_msg( NULL, "Error normalizing string", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error normalizing string");
|
||||
efree( uret_buf );
|
||||
efree( uinput );
|
||||
RETURN_FALSE;
|
||||
|
@ -172,7 +172,7 @@ PHP_FUNCTION( normalizer_normalize )
|
|||
/* Bail out if an unexpected error occurred. */
|
||||
if( U_FAILURE(status) ) {
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL,"Error normalizing string", 0 );
|
||||
intl_error_set_custom_msg( NULL,"Error normalizing string");
|
||||
efree( uret_buf );
|
||||
efree( uinput );
|
||||
RETURN_FALSE;
|
||||
|
@ -190,7 +190,7 @@ PHP_FUNCTION( normalizer_normalize )
|
|||
if( !u8str )
|
||||
{
|
||||
intl_error_set( NULL, status,
|
||||
"normalizer_normalize: error converting normalized text UTF-8", 0 );
|
||||
"error converting normalized text UTF-8");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ PHP_FUNCTION( normalizer_is_normalized )
|
|||
intl_error_set_code( NULL, status );
|
||||
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.", 0 );
|
||||
intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.");
|
||||
if (uinput) {
|
||||
efree( uinput );
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ PHP_FUNCTION( normalizer_is_normalized )
|
|||
/* Bail out if an unexpected error occurred. */
|
||||
if( U_FAILURE(status) ) {
|
||||
/* Set error messages. */
|
||||
intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 0 );
|
||||
intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -304,13 +304,13 @@ PHP_FUNCTION( normalizer_get_raw_decomposition )
|
|||
U8_NEXT(input, offset, input_length, codepoint);
|
||||
if ((size_t)offset != input_length) {
|
||||
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
|
||||
intl_error_set_custom_msg(NULL, "Input string must be exactly one UTF-8 encoded code point long.", 0);
|
||||
intl_error_set_custom_msg(NULL, "Input string must be exactly one UTF-8 encoded code point long.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((codepoint < UCHAR_MIN_VALUE) || (codepoint > UCHAR_MAX_VALUE)) {
|
||||
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
|
||||
intl_error_set_custom_msg(NULL, "Code point out of range", 0);
|
||||
intl_error_set_custom_msg(NULL, "Code point out of range");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
|
|||
/* }}} */
|
||||
|
||||
/* {{{ ResourceBundle_ctor */
|
||||
static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
|
||||
static zend_result resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
char *bundlename;
|
||||
size_t bundlename_len = 0;
|
||||
|
@ -92,11 +92,6 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling
|
|||
Z_PARAM_BOOL(fallback)
|
||||
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
|
||||
|
||||
if (error_handling != NULL) {
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
|
||||
*error_handling_replaced = 1;
|
||||
}
|
||||
|
||||
if (rb->me) {
|
||||
zend_throw_error(NULL, "ResourceBundle object is already constructed");
|
||||
return FAILURE;
|
||||
|
@ -119,18 +114,18 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling
|
|||
rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
|
||||
}
|
||||
|
||||
INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
|
||||
INTL_CTOR_CHECK_STATUS(rb, "Cannot load libICU resource bundle");
|
||||
|
||||
if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||
|
||||
INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
|
||||
char *pbuf;
|
||||
intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb));
|
||||
spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource "
|
||||
spprintf(&pbuf, 0, "Cannot load libICU resource "
|
||||
"'%s' without fallback from %s to %s",
|
||||
bundlename ? bundlename : "(default data)", locale,
|
||||
ures_getLocaleByType(
|
||||
rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1);
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf);
|
||||
efree(pbuf);
|
||||
return FAILURE;
|
||||
}
|
||||
|
@ -142,18 +137,17 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling
|
|||
/* {{{ ResourceBundle object constructor */
|
||||
PHP_METHOD( ResourceBundle, __construct )
|
||||
{
|
||||
zend_error_handling error_handling;
|
||||
bool error_handling_replaced = 0;
|
||||
const bool old_use_exception = INTL_G(use_exceptions);
|
||||
const zend_long old_error_level = INTL_G(error_level);
|
||||
INTL_G(use_exceptions) = true;
|
||||
INTL_G(error_level) = 0;
|
||||
|
||||
return_value = ZEND_THIS;
|
||||
if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
|
||||
}
|
||||
}
|
||||
if (error_handling_replaced) {
|
||||
zend_restore_error_handling(&error_handling);
|
||||
if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
}
|
||||
INTL_G(use_exceptions) = old_use_exception;
|
||||
INTL_G(error_level) = old_error_level;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -161,7 +155,7 @@ PHP_METHOD( ResourceBundle, __construct )
|
|||
PHP_FUNCTION( resourcebundle_create )
|
||||
{
|
||||
object_init_ex( return_value, ResourceBundle_ce_ptr );
|
||||
if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
|
||||
if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
|
||||
zval_ptr_dtor(return_value);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -214,7 +208,7 @@ static zval *resource_bundle_array_fetch(
|
|||
} else {
|
||||
spprintf( &pbuf, 0, "Cannot load resource element '%s'", key );
|
||||
}
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 );
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf);
|
||||
efree(pbuf);
|
||||
RETVAL_NULL();
|
||||
return return_value;
|
||||
|
@ -228,7 +222,7 @@ static zval *resource_bundle_array_fetch(
|
|||
} else {
|
||||
spprintf(&pbuf, 0, "Cannot load element '%s' without fallback from to %s", key, locale);
|
||||
}
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1);
|
||||
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf);
|
||||
efree(pbuf);
|
||||
RETVAL_NULL();
|
||||
return return_value;
|
||||
|
@ -307,7 +301,7 @@ static zend_result resourcebundle_array_count(zend_object *object, zend_long *co
|
|||
|
||||
if (rb->me == NULL) {
|
||||
intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"Found unconstructed ResourceBundle", 0);
|
||||
"Found unconstructed ResourceBundle");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr;
|
|||
#define SPOOFCHECKER_CHECK_STATUS(co, msg) \
|
||||
intl_error_set_code(NULL, SPOOFCHECKER_ERROR_CODE(co)); \
|
||||
if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) { \
|
||||
intl_errors_set_custom_msg(SPOOFCHECKER_ERROR_P(co), msg, 0); \
|
||||
intl_errors_set_custom_msg(SPOOFCHECKER_ERROR_P(co), msg); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
|
||||
|
|
|
@ -26,17 +26,17 @@ PHP_METHOD(Spoofchecker, __construct)
|
|||
#if U_ICU_VERSION_MAJOR_NUM < 58
|
||||
int checks;
|
||||
#endif
|
||||
zend_error_handling error_handling;
|
||||
SPOOFCHECKER_METHOD_INIT_VARS;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
|
||||
|
||||
SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
|
||||
if (U_FAILURE(INTL_DATA_ERROR_CODE(co))) {
|
||||
zend_throw_exception(IntlException_ce_ptr,
|
||||
"Spoofchecker::__construct(): unable to open ICU Spoof Checker", 0);
|
||||
}
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 58
|
||||
/* TODO save it into the object for further suspiction check comparison. */
|
||||
|
@ -56,6 +56,5 @@ PHP_METHOD(Spoofchecker, __construct)
|
|||
checks = uspoof_getChecks(co->uspoof, SPOOFCHECKER_ERROR_CODE_P(co));
|
||||
uspoof_setChecks(co->uspoof, checks & ~USPOOF_SINGLE_SCRIPT, SPOOFCHECKER_ERROR_CODE_P(co));
|
||||
#endif
|
||||
zend_restore_error_handling(&error_handling);
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -19,10 +19,10 @@ foreach ($badvals as $val) {
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -4,23 +4,20 @@ Bug #62017: datefmt_create with incorrectly encoded timezone leaks pattern
|
|||
intl
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set('intl.error_level', E_WARNING);
|
||||
try {
|
||||
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
|
||||
IntlDateFormatter::GREGORIAN, 'a');
|
||||
} catch (IntlException $e) {
|
||||
echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
|
||||
new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
|
||||
IntlDateFormatter::GREGORIAN, "\x80");
|
||||
} catch (IntlException $e) {
|
||||
echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Exception: datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
|
||||
|
||||
Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d
|
||||
--EXPECT--
|
||||
IntlException: datefmt_create(): Time zone identifier given is not a valid UTF-8 string
|
||||
IntlException: IntlDateFormatter::__construct(): error converting pattern to UTF-16
|
||||
|
|
|
@ -8,11 +8,11 @@ intl
|
|||
<?php
|
||||
ini_set('intl.error_level', E_WARNING);
|
||||
$x = new IntlDateFormatter('en', 1, 1);
|
||||
var_dump($x->__construct('en', 1, 1));
|
||||
try {
|
||||
var_dump($x->__construct('en', 1, 1));
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %sbug62081.php:4
|
||||
Stack trace:
|
||||
#0 %sbug62081.php(4): IntlDateFormatter->__construct('en', 1, 1)
|
||||
#1 {main}
|
||||
thrown in %sbug62081.php on line 4
|
||||
--EXPECT--
|
||||
IntlException: IntlDateFormatter::__construct(): cannot call constructor twice
|
||||
|
|
|
@ -16,6 +16,6 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(65) "Locale::getDisplayName(): name too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(66) "locale_get_display_name(): name too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -25,10 +25,10 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(74) "Locale::acceptFromHttp(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(75) "locale_accept_from_http(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(74) "Locale::acceptFromHttp(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(75) "locale_accept_from_http(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -17,4 +17,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
intlcal_create_instance: passed IntlTimeZone is not properly constructed
|
||||
intlcal_create_instance(): passed IntlTimeZone is not properly constructed
|
||||
|
|
|
@ -27,7 +27,7 @@ var_dump(intlcal_field_difference(1, 0, 1));
|
|||
--EXPECTF--
|
||||
IntlCalendar::fieldDifference() expects exactly 2 arguments, 3 given
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
|
||||
Warning: IntlCalendar::fieldDifference(): Call to ICU method has failed in %s on line %d
|
||||
bool(false)
|
||||
intlcal_field_difference() expects exactly 3 arguments, 4 given
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ var_dump(IntlCalendar::fromDateTime($date));
|
|||
?>
|
||||
--EXPECTF--
|
||||
threw exception, OK
|
||||
Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: DateTime object is unconstructed in %s on line %d
|
||||
Warning: IntlCalendar::fromDateTime(): DateTime object is unconstructed in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: object has an time zone offset that's too large in %s on line %d
|
||||
Warning: IntlCalendar::fromDateTime(): object has an time zone offset that's too large in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
||||
Warning: IntlCalendar::fromDateTime(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
||||
NULL
|
||||
|
|
|
@ -32,8 +32,8 @@ int(0)
|
|||
string(12) "U_ZERO_ERROR"
|
||||
string(12) "U_ZERO_ERROR"
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
|
||||
Warning: IntlCalendar::fieldDifference(): Call to ICU method has failed in %s on line %d
|
||||
int(1)
|
||||
int(1)
|
||||
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(88) "IntlCalendar::fieldDifference(): Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(88) "IntlCalendar::fieldDifference(): Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -19,8 +19,8 @@ $intlcal->setTimeZone($pstdate->getTimeZone());
|
|||
var_dump($intlcal->getTimeZone()->getID());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
||||
Warning: IntlCalendar::setTimeZone(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
||||
string(16) "Europe/Amsterdam"
|
||||
|
||||
Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: object has an time zone offset that's too large in %s on line %d
|
||||
Warning: IntlCalendar::setTimeZone(): object has an time zone offset that's too large in %s on line %d
|
||||
string(16) "Europe/Amsterdam"
|
||||
|
|
|
@ -40,15 +40,15 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
|
||||
Warning: IntlCalendar::toDateTime(): DateTimeZone constructor threw exception in %s on line %d
|
||||
string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
|
||||
|
||||
Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
|
||||
Warning: intlcal_to_date_time(): DateTimeZone constructor threw exception in %s on line %d
|
||||
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
|
||||
|
||||
Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
|
||||
Warning: IntlCalendar::toDateTime(): DateTimeZone constructor threw exception in %s on line %d
|
||||
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
|
||||
|
||||
Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
|
||||
Warning: intlcal_to_date_time(): DateTimeZone constructor threw exception in %s on line %d
|
||||
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
|
||||
intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given
|
||||
|
|
|
@ -28,13 +28,13 @@ foreach ($locales as $locale) {
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: Constructor failed
|
||||
IntlException: Collator::__construct(): unable to open ICU collator
|
||||
NULL
|
||||
string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(73) "Collator::create(): unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
NULL
|
||||
string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
IntlException: Constructor failed
|
||||
string(72) "collator_create(): unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
IntlException: Collator::__construct(): Locale string too long, should be no longer than 156 characters
|
||||
NULL
|
||||
string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(109) "Collator::create(): Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
NULL
|
||||
string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(108) "collator_create(): Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -18,6 +18,6 @@ var_dump(collator_get_error_message($coll));
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(81) "Collator::getAttribute(): Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(81) "collator_get_attribute(): Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -4,34 +4,25 @@ IntlDateFormatter::__construct(): bad timezone or calendar
|
|||
intl
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "pt_PT");
|
||||
ini_set("date.timezone", 'Atlantic/Azores');
|
||||
|
||||
function print_exception($e) {
|
||||
echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
|
||||
} catch (IntlException $e) {
|
||||
print_exception($e);
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
|
||||
} catch (IntlException $e) {
|
||||
print_exception($e);
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
|
||||
} catch (TypeError $e) {
|
||||
print_exception($e);
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
--EXPECT--
|
||||
IntlException: IntlDateFormatter::__construct(): No such time zone: "bad timezone"
|
||||
IntlException: IntlDateFormatter::__construct(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object
|
||||
TypeError: IntlDateFormatter::__construct(): Argument #5 ($calendar) must be of type IntlCalendar|int|null, stdClass given
|
||||
|
||||
Exception: datefmt_create: No such time zone: 'bad timezone' in %s on line %d
|
||||
|
||||
Exception: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d
|
||||
|
||||
Exception: IntlDateFormatter::__construct(): Argument #5 ($calendar) must be of type IntlCalendar|int|null, stdClass given in %s on line %d
|
||||
|
|
|
@ -14,6 +14,6 @@ var_dump($f, intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(67) "datefmt_create: invalid date format style: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(69) "datefmt_create(): invalid date format style: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
NULL
|
||||
string(67) "datefmt_create: invalid time format style: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(69) "datefmt_create(): invalid time format style: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -26,8 +26,8 @@ var_dump(intl_get_error_message());
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR
|
||||
IntlException: IntlDateFormatter::__construct(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object
|
||||
NULL
|
||||
string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(245) "IntlDateFormatter::create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
NULL
|
||||
string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(234) "datefmt_create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -43,18 +43,18 @@ var_dump(intl_get_error_message());
|
|||
--EXPECT--
|
||||
DateObjectError: Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor
|
||||
bool(false)
|
||||
string(118) "datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR"
|
||||
string(130) "IntlDateFormatter::formatObject(): the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR"
|
||||
bool(false)
|
||||
string(100) "datefmt_format_object: bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(112) "IntlDateFormatter::formatObject(): bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(85) "datefmt_format_object: the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(97) "IntlDateFormatter::formatObject(): the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(108) "IntlDateFormatter::formatObject(): bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(108) "IntlDateFormatter::formatObject(): bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(118) "datefmt_format_object: bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(130) "IntlDateFormatter::formatObject(): bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(119) "datefmt_format_object: bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(131) "IntlDateFormatter::formatObject(): bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(68) "datefmt_format_object: the format is empty: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(80) "IntlDateFormatter::formatObject(): the format is empty: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -21,6 +21,6 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(127) "datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(140) "IntlDateFormatter::format(): invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(127) "datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(129) "datefmt_format(): invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -24,5 +24,5 @@ try {
|
|||
?>
|
||||
--EXPECTF--
|
||||
Warning: Array to string conversion in %s on line %d
|
||||
datefmt_set_timezone: No such time zone: 'Array'
|
||||
datefmt_set_timezone: No such time zone: 'non existing timezone'
|
||||
IntlDateFormatter::setTimeZone(): No such time zone: "Array"
|
||||
IntlDateFormatter::setTimeZone(): No such time zone: "non existing timezone"
|
||||
|
|
|
@ -12,8 +12,7 @@ function err($fmt) {
|
|||
}
|
||||
|
||||
function print_exception($e) {
|
||||
echo "\n" . get_class($e) . ": " . $e->getMessage()
|
||||
. " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
|
||||
echo "\n", $e::class, ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
function crt($t, $l, $s) {
|
||||
|
@ -62,14 +61,14 @@ try {
|
|||
err($fmt);
|
||||
try {
|
||||
$fmt = numfmt_create();
|
||||
} catch (TypeError $e) {
|
||||
} catch (Throwable $e) {
|
||||
print_exception($e);
|
||||
$fmt = null;
|
||||
}
|
||||
err($fmt);
|
||||
try {
|
||||
$fmt = NumberFormatter::create();
|
||||
} catch (TypeError $e) {
|
||||
} catch (Throwable $e) {
|
||||
print_exception($e);
|
||||
$fmt = null;
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ err($fmt);
|
|||
$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
|
||||
try {
|
||||
$fmt->__construct('en_US', NumberFormatter::DECIMAL);
|
||||
} catch (Error $e) {
|
||||
} catch (Throwable $e) {
|
||||
print_exception($e);
|
||||
$fmt = null;
|
||||
}
|
||||
|
@ -95,16 +94,16 @@ foreach($args as $arg) {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
ArgumentCountError: NumberFormatter::__construct() expects at least 2 arguments, 0 given in %s on line %d
|
||||
ArgumentCountError: NumberFormatter::__construct() expects at least 2 arguments, 0 given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
ArgumentCountError: numfmt_create() expects at least 2 arguments, 0 given in %s on line %d
|
||||
ArgumentCountError: numfmt_create() expects at least 2 arguments, 0 given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
ArgumentCountError: NumberFormatter::create() expects at least 2 arguments, 0 given in %s on line %d
|
||||
ArgumentCountError: NumberFormatter::create() expects at least 2 arguments, 0 given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
Error: NumberFormatter object is already constructed in %s on line %d
|
||||
Error: NumberFormatter object is already constructed
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
Deprecated: NumberFormatter::__construct(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
|
||||
|
@ -119,30 +118,30 @@ Deprecated: numfmt_create(): Passing null to parameter #1 ($locale) of type stri
|
|||
|
||||
Deprecated: numfmt_create(): Passing null to parameter #2 ($style) of type int is deprecated in %s on line %d
|
||||
|
||||
ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "%s" is invalid in %s on line %d
|
||||
ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "whatever" is invalid
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
ValueError: NumberFormatter::create(): Argument #1 ($locale) "%s" is invalid in %s on line %d
|
||||
ValueError: NumberFormatter::create(): Argument #1 ($locale) "whatever" is invalid
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
ValueError: numfmt_create(): Argument #1 ($locale) "%s" is invalid in %s on line %d
|
||||
ValueError: numfmt_create(): Argument #1 ($locale) "whatever" is invalid
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
TypeError: NumberFormatter::__construct(): Argument #1 ($locale) must be of type string, array given in %s on line %d
|
||||
TypeError: NumberFormatter::__construct(): Argument #1 ($locale) must be of type string, array given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
TypeError: NumberFormatter::create(): Argument #1 ($locale) must be of type string, array given in %s on line %d
|
||||
TypeError: NumberFormatter::create(): Argument #1 ($locale) must be of type string, array given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
TypeError: numfmt_create(): Argument #1 ($locale) must be of type string, array given in %s on line %d
|
||||
TypeError: numfmt_create(): Argument #1 ($locale) must be of type string, array given
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
IntlException: Constructor failed in %s on line %d
|
||||
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
IntlException: NumberFormatter::__construct(): number formatter creation failed
|
||||
'NumberFormatter::__construct(): number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
'NumberFormatter::create(): number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
'numfmt_create(): number formatter creation failed: U_UNSUPPORTED_ERROR'
|
||||
|
||||
IntlException: Constructor failed in %s on line %d
|
||||
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
IntlException: NumberFormatter::__construct(): number formatter creation failed
|
||||
'NumberFormatter::__construct(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
'NumberFormatter::create(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
'numfmt_create(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
|
||||
|
|
|
@ -32,16 +32,16 @@ var_dump($nf->getErrorCode());
|
|||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(36) "Number parsing failed: U_PARSE_ERROR"
|
||||
string(70) "NumberFormatter::parseCurrency(): Number parsing failed: U_PARSE_ERROR"
|
||||
int(9)
|
||||
NULL
|
||||
string(36) "Number parsing failed: U_PARSE_ERROR"
|
||||
string(70) "NumberFormatter::parseCurrency(): Number parsing failed: U_PARSE_ERROR"
|
||||
int(9)
|
||||
bool(false)
|
||||
NULL
|
||||
string(36) "Number parsing failed: U_PARSE_ERROR"
|
||||
string(61) "numfmt_parse_currency(): Number parsing failed: U_PARSE_ERROR"
|
||||
int(9)
|
||||
bool(false)
|
||||
NULL
|
||||
string(36) "Number parsing failed: U_PARSE_ERROR"
|
||||
string(61) "numfmt_parse_currency(): Number parsing failed: U_PARSE_ERROR"
|
||||
int(9)
|
||||
|
|
|
@ -16,6 +16,6 @@ var_dump(numfmt_get_error_message($fmt));
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL"
|
||||
string(98) "NumberFormatter::setPattern(): Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL"
|
||||
bool(false)
|
||||
string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL"
|
||||
string(89) "numfmt_set_pattern(): Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL"
|
||||
|
|
|
@ -13,10 +13,10 @@ var_dump(msgfmt_format_message('en', 'some {wrong.format}', []), intl_get_error_
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(128) "pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
string(163) "MessageFormatter::formatMessage(): pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
bool(false)
|
||||
string(116) "pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
string(151) "MessageFormatter::formatMessage(): pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
bool(false)
|
||||
string(128) "pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
string(153) "msgfmt_format_message(): pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
bool(false)
|
||||
string(116) "pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
string(141) "msgfmt_format_message(): pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR"
|
||||
|
|
|
@ -21,4 +21,4 @@ try {
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN: U_ILLEGAL_ARGUMENT_ERROR
|
||||
IntlDateFormatter::__construct(): time format must be UDAT_PATTERN if date format is UDAT_PATTERN
|
||||
|
|
|
@ -32,5 +32,5 @@ try {
|
|||
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d
|
||||
|
||||
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5
|
||||
Error setting encoding: 4 - U_FILE_ACCESS_ERROR
|
||||
Error setting encoding: 4 - U_FILE_ACCESS_ERROR
|
||||
UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR
|
||||
UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR
|
||||
|
|
|
@ -16,7 +16,7 @@ ini_set("intl.error_level", E_NOTICE);
|
|||
var_dump($t->transliterate('a', 3));
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"
|
||||
string(133) "Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"
|
||||
|
||||
Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
|
||||
Notice: Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
|
||||
bool(false)
|
||||
|
|
|
@ -15,4 +15,4 @@ else
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
Error getting locale by type: U_ILLEGAL_ARGUMENT_ERROR
|
||||
collator_get_locale(): Error getting locale by type: U_ILLEGAL_ARGUMENT_ERROR
|
||||
|
|
|
@ -47,12 +47,12 @@ try {
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(90) "Locale::composeLocale(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(83) "locale_compose(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(90) "Locale::composeLocale(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(83) "locale_compose(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
ValueError: Locale::composeLocale(): Argument #1 ($subtags) must contain a "language" key
|
||||
ValueError: locale_compose(): Argument #1 ($subtags) must contain a "language" key
|
||||
|
|
|
@ -26,10 +26,10 @@ bool(true)
|
|||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(67) "locale_add_likely_subtags: invalid locale: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(68) "Locale::addLikelySubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(65) "locale_minimize_subtags: invalid locale: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(67) "Locale::minimizeSubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(%d) "locale_add_likely_subtags: invalid locale: %s"
|
||||
string(68) "Locale::addLikelySubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(%d) "locale_minimize_subtags: invalid locale: %s"
|
||||
string(%d) "Locale::minimizeSubtags(): invalid locale: %s"
|
||||
|
|
|
@ -23,8 +23,8 @@ var_dump(intl_get_error_message());
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR
|
||||
IntlException: MessageFormatter::__construct(): message formatter creation failed
|
||||
NULL
|
||||
string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(87) "MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
NULL
|
||||
string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(76) "msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -130,23 +130,23 @@ Deprecated: MessageFormatter::__construct(): Passing null to parameter #1 ($loca
|
|||
|
||||
Deprecated: MessageFormatter::__construct(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
|
||||
|
||||
IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d
|
||||
'MessageFormatter::__construct(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
|
||||
Deprecated: MessageFormatter::create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
|
||||
|
||||
Deprecated: MessageFormatter::create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
|
||||
Deprecated: msgfmt_create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
|
||||
|
||||
Deprecated: msgfmt_create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
|
||||
IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d
|
||||
'MessageFormatter::__construct(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
'msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
|
||||
|
||||
TypeError: MessageFormatter::__construct(): Argument #1 ($locale) must be of type string, array given in %s on line %d
|
||||
'U_ZERO_ERROR'
|
||||
|
@ -157,17 +157,17 @@ TypeError: MessageFormatter::create(): Argument #1 ($locale) must be of type str
|
|||
TypeError: msgfmt_create(): Argument #1 ($locale) must be of type string, array given in %s on line %d
|
||||
'U_ZERO_ERROR'
|
||||
|
||||
IntlException: pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR in %s on line %d
|
||||
'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
IntlException: MessageFormatter::__construct(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}") in %s on line %d
|
||||
'MessageFormatter::__construct(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
'MessageFormatter::create(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
'msgfmt_create(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR'
|
||||
|
||||
IntlException: msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES in %s on line %d
|
||||
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d
|
||||
'MessageFormatter::__construct(): message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
'MessageFormatter::create(): message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
'msgfmt_create(): message formatter creation failed: U_UNMATCHED_BRACES'
|
||||
|
||||
IntlException: msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND in %s on line %d
|
||||
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
IntlException: MessageFormatter::__construct(): error converting pattern to UTF-16 in %s on line %d
|
||||
'MessageFormatter::__construct(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
'MessageFormatter::create(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
'msgfmt_create(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
|
||||
|
|
|
@ -19,4 +19,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: Inconsistent types declared for an argument
|
||||
IntlException: MessageFormatter::format(): Inconsistent types declared for an argument
|
||||
|
|
|
@ -19,4 +19,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: Found negative or too large array key
|
||||
IntlException: MessageFormatter::format(): Found negative or too large array key
|
||||
|
|
|
@ -16,14 +16,14 @@ try {
|
|||
var_dump($mf->format(array("foo" => 7, "\x80" => "bar")));
|
||||
} catch (Throwable $e) {
|
||||
var_dump($e::class === 'IntlException');
|
||||
var_dump("Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage());
|
||||
var_dump("MessageFormatter::format(): Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump($mf->format(array("foo" => "\x80")));
|
||||
} catch (Throwable $e) {
|
||||
var_dump($e::class === 'IntlException');
|
||||
var_dump("Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
|
||||
var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -20,4 +20,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: The argument for key 'foo' cannot be used as a date or time
|
||||
IntlException: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time
|
||||
|
|
|
@ -19,4 +19,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: No strategy to convert the value given for the argument with key '7' is available
|
||||
IntlException: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available
|
||||
|
|
|
@ -22,6 +22,6 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(47) "Creating message formatter failed: U_ZERO_ERROR"
|
||||
string(82) "MessageFormatter::formatMessage(): Creating message formatter failed: U_ZERO_ERROR"
|
||||
bool(false)
|
||||
string(47) "Creating message formatter failed: U_ZERO_ERROR"
|
||||
string(72) "msgfmt_format_message(): Creating message formatter failed: U_ZERO_ERROR"
|
||||
|
|
|
@ -22,6 +22,6 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(93) "MessageFormatter::parseMessage(): Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(83) "msgfmt_parse_message(): Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -18,5 +18,5 @@ var_dump($mf->getErrorMessage());
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR"
|
||||
string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR"
|
||||
string(103) "MessageFormatter::setPattern(): Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR"
|
||||
string(93) "msgfmt_set_pattern(): Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR"
|
||||
|
|
|
@ -45,9 +45,9 @@ string(3) "ㅡ"
|
|||
string(3) "ㅡ"
|
||||
string(33) "صلى الله عليه وسلم"
|
||||
string(33) "صلى الله عليه وسلم"
|
||||
string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(124) "Normalizer::getRawDecomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(125) "normalizer_get_raw_decomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(124) "Normalizer::getRawDecomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(125) "normalizer_get_raw_decomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(84) "Normalizer::getRawDecomposition(): Code point out of range: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(85) "normalizer_get_raw_decomposition(): Code point out of range: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -54,4 +54,4 @@ testarray: string 3
|
|||
Using a reference as an offset:
|
||||
string(12) "Hello World!"
|
||||
NULL
|
||||
2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
|
||||
2: main(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
|
||||
|
|
|
@ -33,9 +33,9 @@ var_dump(intl_get_error_message());
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
IntlException: Constructor failed
|
||||
IntlException: ResourceBundle::__construct(): Cannot load libICU resource bundle
|
||||
NULL
|
||||
string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR"
|
||||
IntlException: Constructor failed
|
||||
string(85) "resourcebundle_create(): Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR"
|
||||
IntlException: ResourceBundle::__construct(): Cannot load libICU resource bundle
|
||||
NULL
|
||||
string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR"
|
||||
string(85) "resourcebundle_create(): Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR"
|
||||
|
|
|
@ -19,7 +19,7 @@ var_dump($bundle->get('teststring'));
|
|||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR"
|
||||
string(91) "ResourceBundle::get(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR"
|
||||
NULL
|
||||
string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR"
|
||||
string(90) "resourcebundle_get(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR"
|
||||
string(12) "Hello World!"
|
||||
|
|
|
@ -11,4 +11,4 @@ var_dump(intl_get_error_message());
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(50) "unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(85) "IntlTimeZone::getIDForWindowsID(): unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -6,11 +6,12 @@ date.timezone=Atlantic/Azores
|
|||
intl
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$dt = new DateTime('2012-08-01 00:00:00 WEST');
|
||||
var_dump(IntlTimeZone::fromDateTimeZone($dt->getTimeZone()));
|
||||
var_dump(intl_get_error_message());
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(131) "IntlTimeZone::fromDateTimeZone(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -31,4 +31,4 @@ string(12) "U_ZERO_ERROR"
|
|||
Warning: IntlTimeZone::getOffset(): error obtaining offset in %s on line %d
|
||||
bool(false)
|
||||
int(1)
|
||||
string(48) "error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(75) "IntlTimeZone::getOffset(): error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
|
|
|
@ -17,7 +17,7 @@ try {
|
|||
var_dump(intltz_to_date_time_zone(1));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: DateTimeZone constructor threw exception in %s on line %d
|
||||
Warning: IntlTimeZone::toDateTimeZone(): DateTimeZone constructor threw exception in %s on line %d
|
||||
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
|
||||
|
||||
Fatal error: Uncaught TypeError: intltz_to_date_time_zone(): Argument #1 ($timezone) must be of type IntlTimeZone, int given in %s:%d
|
||||
|
|
|
@ -33,7 +33,7 @@ string(18) "Cuba Standard Time"
|
|||
string(21) "Central Standard Time"
|
||||
string(21) "Pacific Standard Time"
|
||||
bool(false)
|
||||
Error: unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: IntlTimeZone::getWindowsID(): unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR
|
||||
string(21) "Morocco Standard Time"
|
||||
string(23) "Singapore Standard Time"
|
||||
string(26) "W. Australia Standard Time"
|
||||
|
|
|
@ -5,18 +5,14 @@ intl
|
|||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
Transliterator::create("inexistent id");
|
||||
var_dump(Transliterator::create("inexistent id"));
|
||||
echo intl_get_error_message(), "\n";
|
||||
Transliterator::create("bad UTF-8 \x8F");
|
||||
var_dump(Transliterator::create("bad UTF-8 \x8F"));
|
||||
echo intl_get_error_message(), "\n";
|
||||
|
||||
echo "Done.\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Transliterator::create(): transliterator_create: unable to open ICU transliterator with id "inexistent id" in %s on line %d
|
||||
transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID
|
||||
|
||||
Warning: Transliterator::create(): String conversion of id to UTF-16 failed in %s on line %d
|
||||
String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
Done.
|
||||
--EXPECT--
|
||||
NULL
|
||||
Transliterator::create(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID
|
||||
NULL
|
||||
Transliterator::create(): String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
|
|
|
@ -27,11 +27,11 @@ echo "Done.\n";
|
|||
?>
|
||||
--EXPECTF--
|
||||
Warning: Transliterator::createFromRules(): String conversion of rules to UTF-16 failed in %s on line %d
|
||||
String conversion of rules to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
Transliterator::createFromRules(): String conversion of rules to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
|
||||
Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;") in %s on line %d
|
||||
transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;"): U_RULE_MASK_ERROR
|
||||
Warning: Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;") in %s on line %d
|
||||
Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;"): U_RULE_MASK_ERROR
|
||||
|
||||
Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff") in %s on line %d
|
||||
transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff"): U_MISSING_OPERATOR
|
||||
Warning: Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff") in %s on line %d
|
||||
Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff"): U_MISSING_OPERATOR
|
||||
Done.
|
||||
|
|
|
@ -19,8 +19,8 @@ echo "Done.\n";
|
|||
--EXPECTF--
|
||||
Warning: Transliterator::transliterate(): String conversion of string to UTF-16 failed in %s on line %d
|
||||
bool(false)
|
||||
String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
Transliterator::transliterate(): String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
Transliterator::transliterate(): String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
string(0) ""
|
||||
U_ZERO_ERROR
|
||||
Done.
|
||||
|
|
|
@ -24,7 +24,7 @@ transliterator_transliterate($tr, "\x80\x03");
|
|||
echo "Done.\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: transliterator_transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d
|
||||
Warning: transliterator_transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d
|
||||
bool(false)
|
||||
transliterator_transliterate(): Argument #2 ($string) must be less than or equal to argument #3 ($end)
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ Warning: transliterator_transliterate(): String conversion of id to UTF-16 faile
|
|||
|
||||
Warning: transliterator_transliterate(): Could not create transliterator with ID %s
|
||||
|
||||
String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
transliterator_transliterate(): String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND
|
||||
|
||||
Warning: transliterator_transliterate(): transliterator_create: unable to open ICU transliterator with id "inexistent id" in %s on line %d
|
||||
Warning: transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id" in %s on line %d
|
||||
|
||||
Warning: transliterator_transliterate(): Could not create transliterator with ID "inexistent id" (transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID) in %s on line %d
|
||||
Warning: transliterator_transliterate(): Could not create transliterator with ID "inexistent id" (transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID) in %s on line %d
|
||||
|
||||
transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID
|
||||
transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID
|
||||
Done.
|
||||
|
|
|
@ -10,6 +10,6 @@ $c = new UConverter('utf-8', "\x80");
|
|||
var_dump($c);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: UConverter::__construct(): ucnv_open() returned error 4: U_FILE_ACCESS_ERROR in %s on line %d
|
||||
Warning: UConverter::__construct(): returned error 4: U_FILE_ACCESS_ERROR in %s on line %d
|
||||
object(UConverter)#%d (0) {
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ foreach(array('?','','??') as $subst) {
|
|||
--EXPECT--
|
||||
string(23) "This is an ascii string"
|
||||
string(12) "Snowman: (?)"
|
||||
Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR
|
||||
|
|
|
@ -61,18 +61,16 @@ U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int o
|
|||
* Convert from TimeZone to DateTimeZone object */
|
||||
U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
|
||||
intl_error *outside_error,
|
||||
const char *func, zval *ret)
|
||||
zval *ret)
|
||||
{
|
||||
UnicodeString id;
|
||||
char *message = NULL;
|
||||
php_timezone_obj *tzobj;
|
||||
zval arg;
|
||||
|
||||
timeZone->getID(id);
|
||||
if (id.isBogus()) {
|
||||
spprintf(&message, 0, "%s: could not obtain TimeZone id", func);
|
||||
intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
"could not obtain TimeZone id");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -91,19 +89,16 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
|
|||
/* Call the constructor! */
|
||||
u8str = intl_charFromString(id, &INTL_ERROR_CODE(*outside_error));
|
||||
if (!u8str) {
|
||||
spprintf(&message, 0, "%s: could not convert id to UTF-8", func);
|
||||
intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error),
|
||||
message, 1);
|
||||
"could not convert id to UTF-8");
|
||||
goto error;
|
||||
}
|
||||
ZVAL_STR(&arg, u8str);
|
||||
zend_call_known_instance_method_with_1_params(
|
||||
Z_OBJCE_P(ret)->constructor, Z_OBJ_P(ret), NULL, &arg);
|
||||
if (EG(exception)) {
|
||||
spprintf(&message, 0,
|
||||
"%s: DateTimeZone constructor threw exception", func);
|
||||
intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
message, 1);
|
||||
"DateTimeZone constructor threw exception");
|
||||
zend_object_store_ctor_failed(Z_OBJ_P(ret));
|
||||
zval_ptr_dtor(&arg);
|
||||
goto error;
|
||||
|
@ -118,19 +113,26 @@ error:
|
|||
}
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (message) {
|
||||
efree(message);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void timezone_throw_exception_with_call_location(const char *msg, const char *add_info)
|
||||
{
|
||||
zend_string *fn = get_active_function_or_method_name();
|
||||
zend_throw_error(IntlException_ce_ptr, "%s(): %s%s%s%s",
|
||||
ZSTR_VAL(fn), msg,
|
||||
add_info ? "\"" : "",
|
||||
add_info ? add_info : "",
|
||||
add_info ? "\"" : ""
|
||||
);
|
||||
zend_string_release_ex(fn, false);
|
||||
}
|
||||
|
||||
/* {{{ timezone_process_timezone_argument
|
||||
* TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */
|
||||
U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
|
||||
intl_error *outside_error,
|
||||
const char *func)
|
||||
intl_error *outside_error)
|
||||
{
|
||||
zval local_zv_tz;
|
||||
std::unique_ptr<TimeZone> timeZone;
|
||||
|
@ -148,14 +150,14 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
|
|||
TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone);
|
||||
|
||||
if (to->utimezone == NULL) {
|
||||
zend_throw_error(IntlException_ce_ptr, "%s: passed IntlTimeZone is not "
|
||||
"properly constructed", func);
|
||||
timezone_throw_exception_with_call_location("passed IntlTimeZone is not "
|
||||
"properly constructed", NULL);
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return NULL;
|
||||
}
|
||||
timeZone = std::unique_ptr<TimeZone>(to->utimezone->clone());
|
||||
if (UNEXPECTED(timeZone == NULL)) {
|
||||
zend_throw_error(IntlException_ce_ptr, "%s: could not clone TimeZone", func);
|
||||
timezone_throw_exception_with_call_location("could not clone TimeZone", NULL);
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -165,8 +167,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
|
|||
php_timezone_obj *tzobj = Z_PHPTIMEZONE_P(zv_timezone);
|
||||
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return timezone_convert_datetimezone(tzobj->type, tzobj, 0,
|
||||
outside_error, func);
|
||||
return timezone_convert_datetimezone(tzobj->type, tzobj, 0, outside_error);
|
||||
} else {
|
||||
UnicodeString id;
|
||||
UErrorCode status = U_ZERO_ERROR; /* outside_error may be NULL */
|
||||
|
@ -176,20 +177,19 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
|
|||
}
|
||||
if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone),
|
||||
&status) == FAILURE) {
|
||||
zend_throw_error(IntlException_ce_ptr, "%s: Time zone identifier given is not a "
|
||||
"valid UTF-8 string", func);
|
||||
timezone_throw_exception_with_call_location("Time zone identifier given is not a "
|
||||
"valid UTF-8 string", NULL);
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return NULL;
|
||||
}
|
||||
timeZone = std::unique_ptr<TimeZone>(TimeZone::createTimeZone(id));
|
||||
if (UNEXPECTED(timeZone == NULL)) {
|
||||
zend_throw_error(IntlException_ce_ptr, "%s: Could not create time zone", func);
|
||||
timezone_throw_exception_with_call_location("Could not create time zone", NULL);
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return NULL;
|
||||
}
|
||||
if (*timeZone == TimeZone::getUnknown()) {
|
||||
zend_throw_error(IntlException_ce_ptr, "%s: No such time zone: '%s'",
|
||||
func, Z_STRVAL_P(zv_timezone));
|
||||
timezone_throw_exception_with_call_location("No such time zone: ", Z_STRVAL_P(zv_timezone));
|
||||
zval_ptr_dtor_str(&local_zv_tz);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ static inline TimeZone_object *php_intl_timezone_fetch_object(zend_object *obj)
|
|||
RETURN_THROWS(); \
|
||||
}
|
||||
|
||||
zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func, zval *ret);
|
||||
TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *error, const char *func);
|
||||
zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, zval *ret);
|
||||
TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *error);
|
||||
|
||||
void timezone_object_construct(const TimeZone *zone, zval *object, int owned);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ 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,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,11 @@ U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone)
|
|||
tzobj = Z_PHPTIMEZONE_P(zv_timezone);
|
||||
if (!tzobj->initialized) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"DateTimeZone object is unconstructed",
|
||||
0);
|
||||
"DateTimeZone object is unconstructed");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL,
|
||||
"intltz_from_date_time_zone");
|
||||
tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL);
|
||||
if (tz == NULL) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
@ -145,7 +143,7 @@ int_offset:
|
|||
if (UNEXPECTED(Z_LVAL_P(arg) < (zend_long)INT32_MIN ||
|
||||
Z_LVAL_P(arg) > (zend_long)INT32_MAX)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"value is out of range", 0);
|
||||
"value is out of range");
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
se = TimeZone::createEnumeration((int32_t) Z_LVAL_P(arg));
|
||||
|
@ -173,8 +171,9 @@ double_offset:
|
|||
/* else call string version */
|
||||
se = TimeZone::createEnumeration(Z_STRVAL_P(arg));
|
||||
} else {
|
||||
// TODO Should be a TypeError
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"invalid argument type", 0);
|
||||
"invalid argument type");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -182,7 +181,7 @@ double_offset:
|
|||
IntlIterator_from_StringEnumeration(se, return_value);
|
||||
} else {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"error obtaining enumeration", 0);
|
||||
"error obtaining enumeration");
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +200,7 @@ 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,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -230,15 +229,14 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration)
|
|||
|
||||
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,
|
||||
"bad zone type", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "bad zone type");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!arg3isnull) {
|
||||
if (UNEXPECTED(offset_arg < (zend_long)INT32_MIN || offset_arg > (zend_long)INT32_MAX)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"offset out of bounds", 0);
|
||||
"offset out of bounds");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
offset = (int32_t)offset_arg;
|
||||
|
@ -271,7 +269,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,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -305,7 +303,7 @@ 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,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -348,7 +346,7 @@ 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,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_iana_id)
|
|||
UnicodeString id;
|
||||
if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) {
|
||||
intl_error_set(NULL, status,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -484,8 +482,7 @@ U_CFUNC PHP_FUNCTION(intltz_has_same_rules)
|
|||
TIMEZONE_METHOD_FETCH_OBJECT;
|
||||
other_to = Z_INTL_TIMEZONE_P(other_object);
|
||||
if (other_to->utimezone == NULL) {
|
||||
intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"The second IntlTimeZone is unconstructed", 0);
|
||||
intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, "The second IntlTimeZone is unconstructed");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -519,8 +516,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name)
|
|||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"wrong display type", 0);
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "wrong display type");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -567,7 +563,7 @@ U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone)
|
|||
TIMEZONE_METHOD_FETCH_OBJECT;
|
||||
|
||||
zval *ret = timezone_convert_to_datetimezone(to->utimezone,
|
||||
&TIMEZONE_ERROR(to), "intltz_to_date_time_zone", &tmp);
|
||||
&TIMEZONE_ERROR(to), &tmp);
|
||||
|
||||
if (ret) {
|
||||
ZVAL_COPY_VALUE(return_value, ret);
|
||||
|
@ -630,16 +626,16 @@ U_CFUNC PHP_FUNCTION(intltz_get_windows_id)
|
|||
error = U_ZERO_ERROR;
|
||||
if (intl_stringFromChar(uID, id->val, id->len, &error) == FAILURE) {
|
||||
intl_error_set(NULL, error,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
error = U_ZERO_ERROR;
|
||||
TimeZone::getWindowsID(uID, uWinID, error);
|
||||
INTL_CHECK_STATUS(error, "intltz_get_windows_id: Unable to get timezone from windows ID");
|
||||
INTL_CHECK_STATUS(error, "Unable to get timezone from windows ID");
|
||||
if (uWinID.length() == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"unknown system timezone", 0);
|
||||
"unknown system timezone");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -668,7 +664,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id)
|
|||
error = U_ZERO_ERROR;
|
||||
if (intl_stringFromChar(uWinID, winID->val, winID->len, &error) == FAILURE) {
|
||||
intl_error_set(NULL, error,
|
||||
"could not convert time zone id to UTF-16", 0);
|
||||
"could not convert time zone id to UTF-16");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -677,7 +673,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id)
|
|||
INTL_CHECK_STATUS(error, "unable to get windows ID for timezone");
|
||||
if (uID.length() == 0) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"unknown windows timezone", 0);
|
||||
"unknown windows timezone");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue