From: ByungWoo Lee Date: Thu, 9 Jul 2015 04:18:14 +0000 (+0900) Subject: Modify the value of I18N_WARNING_SORT_KEY_TOO_SHORT X-Git-Tag: submit/tizen/20150709.043730^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7ef44d3731446b90960361b3ec46ee05c918619;p=platform%2Fcore%2Fapi%2Fbase-utils.git Modify the value of I18N_WARNING_SORT_KEY_TOO_SHORT Change-Id: I4a49844d764708a4ff4e68555d20c37a258d60ed --- diff --git a/packaging/capi-base-utils.spec b/packaging/capi-base-utils.spec index ebe41b5..c2978cf 100755 --- a/packaging/capi-base-utils.spec +++ b/packaging/capi-base-utils.spec @@ -1,6 +1,6 @@ Name: capi-base-utils Summary: Base Utils -Version: 1.0.0 +Version: 1.0.1 Release: 1 Group: Base License: Apache-2.0 and ICU diff --git a/src/include/mobile/utils_i18n.h b/src/include/mobile/utils_i18n.h index 49629f4..f0040d2 100755 --- a/src/include/mobile/utils_i18n.h +++ b/src/include/mobile/utils_i18n.h @@ -87,7 +87,7 @@ extern "C" { * * * @ref CAPI_BASE_UTILS_I18N_UDATE_MODULE - * Udate module consists of functions that convert dates and times from their + * Udate module consists of functions that convert dates and times from their internal representations to textual form and back again in a language-independent manner. * * @@ -233,11 +233,6 @@ extern "C" { * * * @ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE - * #i18n_timezone_in_daylight_time - * inDaylightTime - * - * - * @ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE * #i18n_timezone_has_same_rule * hasSameRules * @@ -463,7 +458,7 @@ extern "C" { * * * @ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE - * #i18n_usearch_create + * #i18n_usearch_create_new * usearch_open * * @@ -535,7 +530,7 @@ extern "C" { * @ref CAPI_BASE_UTILS_I18N_USTRING_MODULE * #i18n_ustring_r_string * u_strrstr - * + * * * @ref CAPI_BASE_UTILS_I18N_USTRING_MODULE * #i18n_ustring_find_last @@ -713,7 +708,7 @@ extern "C" { * * * @ref CAPI_BASE_UTILS_I18N_USTRING_MODULE - * #i18n_ustring_to_title + * #i18n_ustring_to_title_new * u_strToTitle * * @@ -778,7 +773,7 @@ extern "C" { * * */ - + #ifdef __cplusplus } #endif diff --git a/src/include/mobile/utils_i18n_timezone.h b/src/include/mobile/utils_i18n_timezone.h index 1b97ace..32aa638 100755 --- a/src/include/mobile/utils_i18n_timezone.h +++ b/src/include/mobile/utils_i18n_timezone.h @@ -250,7 +250,8 @@ const char* i18n_timezone_get_tzdata_version(void); * @param[in] timezone_id The system time zone ID. * @param[out] region Output buffer for receiving the region code. * @param[out] region_len The length of the region code. - * @param[in] region_capacity The size of the output buffer. + * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size, + * then I18N_ERROR_BUFFER_OVERFLOW error is returned. * * @return the version string, such as "2007f" */ @@ -346,8 +347,8 @@ int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] timezone The i18n_timezone_h to get a display name. - * @param[in] language The language in which to supply the display name. - * @param[in] country The country in which to supply the display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. * @param[out] display_name The human-readable name of this time zone in the default locale. * * @retval #I18N_ERROR_NONE Successful @@ -378,8 +379,8 @@ int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_uboo * @param[in] timezone The i18n_timezone_h to get a display name. * @param[in] daylight If true, display_name is filled with the daylight savings name. * @param[in] style The style displayed on. - * @param[in] language The language in which to supply the display name. - * @param[in] country The country in which to supply the display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. * @param[out] display_name The human-readable name of this time zone in the default locale. * * @retval #I18N_ERROR_NONE Successful diff --git a/src/include/mobile/utils_i18n_types.h b/src/include/mobile/utils_i18n_types.h index 58b08be..beee7fb 100644 --- a/src/include/mobile/utils_i18n_types.h +++ b/src/include/mobile/utils_i18n_types.h @@ -83,7 +83,7 @@ typedef enum { I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/ - I18N_WARNING_SORT_KEY_TOO_SHORT = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/ } i18n_error_code_e; diff --git a/src/include/mobile/utils_i18n_ubrk.h b/src/include/mobile/utils_i18n_ubrk.h index 059ab87..bdda0b4 100755 --- a/src/include/mobile/utils_i18n_ubrk.h +++ b/src/include/mobile/utils_i18n_ubrk.h @@ -60,7 +60,8 @@ extern "C" { * #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE * @param[in] locale The locale specifying the text-breaking conventions. * If @c NULL, the default locale will be used. - * @param[in] text The text to be iterated over. + * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text. + * The text can be set later with i18n_ubrk_set_text() function. * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale. * @return The obtained error code. diff --git a/src/include/mobile/utils_i18n_ustring.h b/src/include/mobile/utils_i18n_ustring.h index b29871b..91bf3e9 100644 --- a/src/include/mobile/utils_i18n_ustring.h +++ b/src/include/mobile/utils_i18n_ustring.h @@ -1006,7 +1006,7 @@ int32_t i18n_ustring_to_title ( i18n_uchar *dest, int32_t dest_capacity, const i * algorithm of Unicode TR 21.\n * The result may be longer or shorter than the original. * The source string and the destination buffer are allowed to overlap. - * @since_tizen MOBILE 2.3.1 + * @since_tizen 2.3.1 * * @param[out] dest A buffer for the result string.\n * The result will be zero-terminated if the buffer is large enough. diff --git a/src/include/wearable/utils_i18n.h b/src/include/wearable/utils_i18n.h index 921688f..f0040d2 100755 --- a/src/include/wearable/utils_i18n.h +++ b/src/include/wearable/utils_i18n.h @@ -233,11 +233,6 @@ extern "C" { * * * @ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE - * #i18n_ucalendar_is_in_daylight_time - * inDaylightTime - * - * - * @ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE * #i18n_timezone_has_same_rule * hasSameRules * diff --git a/src/include/wearable/utils_i18n_timezone.h b/src/include/wearable/utils_i18n_timezone.h index 1ae023e..391b343 100755 --- a/src/include/wearable/utils_i18n_timezone.h +++ b/src/include/wearable/utils_i18n_timezone.h @@ -250,7 +250,8 @@ const char* i18n_timezone_get_tzdata_version(void); * @param[in] timezone_id The system time zone ID. * @param[out] region Output buffer for receiving the region code. * @param[out] region_len The length of the region code. - * @param[in] region_capacity The size of the output buffer. + * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size, + * then I18N_ERROR_BUFFER_OVERFLOW error is returned. * * @return the version string, such as "2007f" */ @@ -346,8 +347,8 @@ int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] timezone The i18n_timezone_h to get a display name. - * @param[in] language The language in which to supply the display name. - * @param[in] country The country in which to supply the display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. * @param[out] display_name The human-readable name of this time zone in the default locale. * * @retval #I18N_ERROR_NONE Successful @@ -378,8 +379,8 @@ int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_uboo * @param[in] timezone The i18n_timezone_h to get a display name. * @param[in] daylight If true, display_name is filled with the daylight savings name. * @param[in] style The style displayed on. - * @param[in] language The language in which to supply the display name. - * @param[in] country The country in which to supply the display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. * @param[out] display_name The human-readable name of this time zone in the default locale. * * @retval #I18N_ERROR_NONE Successful diff --git a/src/include/wearable/utils_i18n_types.h b/src/include/wearable/utils_i18n_types.h index 58b08be..beee7fb 100644 --- a/src/include/wearable/utils_i18n_types.h +++ b/src/include/wearable/utils_i18n_types.h @@ -83,7 +83,7 @@ typedef enum { I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/ - I18N_WARNING_SORT_KEY_TOO_SHORT = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/ } i18n_error_code_e; diff --git a/src/include/wearable/utils_i18n_ubrk.h b/src/include/wearable/utils_i18n_ubrk.h index 059ab87..bdda0b4 100755 --- a/src/include/wearable/utils_i18n_ubrk.h +++ b/src/include/wearable/utils_i18n_ubrk.h @@ -60,7 +60,8 @@ extern "C" { * #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE * @param[in] locale The locale specifying the text-breaking conventions. * If @c NULL, the default locale will be used. - * @param[in] text The text to be iterated over. + * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text. + * The text can be set later with i18n_ubrk_set_text() function. * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale. * @return The obtained error code. diff --git a/src/include/wearable/utils_i18n_ucollator.h b/src/include/wearable/utils_i18n_ucollator.h index 0721d68..cd129da 100755 --- a/src/include/wearable/utils_i18n_ucollator.h +++ b/src/include/wearable/utils_i18n_ucollator.h @@ -68,7 +68,7 @@ extern "C" { dlog_print(DLOG_INFO, LOG_TAG, "%s %s %s\n", src, result == 1 ? "is equal to" : "is not equal to", target ); // tizen is not equal to bada // destroys the collator - i18n_ucollator_destroy( coll ); + i18n_ucollator_destroy( coll ); * @endcode * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_2 Sample Code 2 * @brief Sorts in ascending order on the given data using string_ucollator @@ -115,7 +115,7 @@ extern "C" { for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) { dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] ); } // ariplane banana cat - * @endcode + * @endcode */ /** @@ -141,7 +141,7 @@ extern "C" { */ int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator ); -/** +/** * @brief Closes a i18n_ucollator_h. * @details Once closed, a string_ucollator_h should not be used. Every an open collator should be closed. Otherwise, a memory leak will result. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/src/include/wearable/utils_i18n_uenumeration.h b/src/include/wearable/utils_i18n_uenumeration.h index 3be1937..05285eb 100755 --- a/src/include/wearable/utils_i18n_uenumeration.h +++ b/src/include/wearable/utils_i18n_uenumeration.h @@ -51,7 +51,7 @@ extern "C" { * @brief Disposes of resources in use by the iterator. * @details If @c enumeration is NULL, does nothing. After this call, any char* or i18n_uchar* returned * by i18n_uenumeration_unext() or i18n_uenumeration_next() is invalid. - * @remarks Error codes are described in Exceptions section. + * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * * @param[in] enumeration An #i18n_uenumeration_h to destroy @@ -132,7 +132,7 @@ const char *i18n_uenumeration_next ( i18n_uenumeration_h enumeration, int32_t *r /** * @brief Resets the iterator to the current list of service IDs. * @details This re-establishes sync with the service and rewinds the iterator to start at the first element. - * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description. + * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * * @param[in] enumeration An #i18n_uenumeration_h @@ -140,7 +140,6 @@ const char *i18n_uenumeration_next ( i18n_uenumeration_h enumeration, int32_t *r * @return The obtained error code. * @retval #I18N_ERROR_NONE Successful * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter - * @retval #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync */ int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration ); @@ -148,7 +147,7 @@ int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration ); * @brief Given an array of const i18n_uchar* strings, return an #i18n_uenumeration_h. * @details String pointers from 0..count-1 must not be NULL. * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). - * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description. + * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * * @param[in] strings An array of const i18n_uchar* strings (each null terminated). All storage is owned by the caller. @@ -167,7 +166,7 @@ int i18n_uenumeration_uchar_strings_enumeration_create(const i18n_uchar *const s * @brief Given an array of const char* strings (invariant chars only), return an #i18n_uenumeration_h. * @details String pointers from 0..count-1 must not be NULL. * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). - * @remarks Error codes are described in Exceptions section and #i18n_error_code_e description. + * @remarks Error codes are described in #i18n_error_code_e description. * @since_tizen 2.3.1 * * @param[in] strings A array of char* strings (each null terminated). All storage is owned by the caller. diff --git a/src/utils_i18n_timezone.cpp b/src/utils_i18n_timezone.cpp index 26c77d9..ad5de02 100755 --- a/src/utils_i18n_timezone.cpp +++ b/src/utils_i18n_timezone.cpp @@ -212,7 +212,8 @@ const char* i18n_timezone_get_tzdata_version(void) int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity) { - retv_if(timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(timezone_id == NULL || region == NULL || region_len == NULL, I18N_ERROR_INVALID_PARAMETER); + UErrorCode status = U_ZERO_ERROR; const UnicodeString id(timezone_id); *region_len = TimeZone::getRegion(id, region, region_capacity, status); @@ -223,7 +224,8 @@ int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *reg int i18n_timezone_get_offset_with_date(i18n_timezone_h timezone, i18n_udate date, i18n_ubool local, int32_t *raw_offset, int32_t *dst_offset) { - retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(timezone == NULL || raw_offset == NULL || dst_offset == NULL, I18N_ERROR_INVALID_PARAMETER); + UErrorCode status = U_ZERO_ERROR; ((TimeZone*)timezone)->getOffset( date, local, *raw_offset, *dst_offset, status ); @@ -241,7 +243,8 @@ int i18n_timezone_set_raw_offset(i18n_timezone_h timezone, int32_t offset_millis int i18n_timezone_get_raw_offset(i18n_timezone_h timezone, int32_t *offset_milliseconds) { - retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(timezone == NULL || offset_milliseconds == NULL, I18N_ERROR_INVALID_PARAMETER); + *offset_milliseconds = ((TimeZone*)timezone)->getRawOffset(); return I18N_ERROR_NONE; diff --git a/src/utils_i18n_ucalendar.c b/src/utils_i18n_ucalendar.c index 77c588f..6de7b6b 100644 --- a/src/utils_i18n_ucalendar.c +++ b/src/utils_i18n_ucalendar.c @@ -385,12 +385,34 @@ int32_t i18n_ucalendar_get_limit ( const i18n_ucalendar_h calendar, i18n_ucalend set_last_result(I18N_ERROR_INVALID_PARAMETER); return 0; } - i18n_error_code_e i18n_error; - UErrorCode icu_error = U_ZERO_ERROR; - int32_t result_ucal_getLimit = ucal_getLimit(calendar, field, type, &icu_error); - ERR("ErrorCode : %d", icu_error); - ERR_MAPPING(icu_error, i18n_error); - set_last_result(i18n_error); + + int32_t result_ucal_getLimit = 0; + switch (field) { + case I18N_UCALENDAR_YEAR_WOY: + case I18N_UCALENDAR_DOW_LOCAL: + case I18N_UCALENDAR_EXTENDED_YEAR: + case I18N_UCALENDAR_JULIAN_DAY: + case I18N_UCALENDAR_MILLISECONDS_IN_DAY: + case I18N_UCALENDAR_IS_LEAP_MONTH: + case I18N_UCALENDAR_FIELD_COUNT: + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + ERR("Unsupported filed"); + break; + } + default: + { + i18n_error_code_e i18n_error = I18N_ERROR_NONE; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t limit = ucal_getLimit(calendar, field, type, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + if(i18n_error == I18N_ERROR_NONE) + result_ucal_getLimit = limit; + } + } + return result_ucal_getLimit; } diff --git a/src/utils_i18n_udate.c b/src/utils_i18n_udate.c index 0bdb159..cf44f44 100644 --- a/src/utils_i18n_udate.c +++ b/src/utils_i18n_udate.c @@ -59,7 +59,18 @@ int i18n_udate_to_calendar_date_field ( i18n_udate_format_field_e field, i18n_uc { return I18N_ERROR_INVALID_PARAMETER; } - *date_field_type = (i18n_ucalendar_date_fields_e)udat_toCalendarDateField(field); + + switch (field) { + case I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD: + case I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD: + case I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD: + case I18N_UDATE_FORMAT_FIELD_COUNT: + ERR("Unsupported filed"); + return I18N_ERROR_INVALID_PARAMETER; + default: + *date_field_type = (i18n_ucalendar_date_fields_e)udat_toCalendarDateField(field); + } + return I18N_ERROR_NONE; } @@ -97,7 +108,7 @@ int i18n_udate_parse ( const i18n_udate_format_h format, const i18n_uchar *text, int i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h * calendar, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos ) { - if (format == NULL || calendar == NULL || text == NULL) + if (format == NULL || calendar == NULL || text == NULL || text_length < -1) { return I18N_ERROR_INVALID_PARAMETER; } @@ -135,7 +146,7 @@ int i18n_udate_set_lenient ( i18n_udate_format_h format, i18n_ubool is_lenient ) int i18n_udate_get_calendar ( const i18n_udate_format_h format, i18n_ucalendar_h *calendar) { - if (format == NULL) + if (format == NULL || calendar == NULL) { return I18N_ERROR_INVALID_PARAMETER; } @@ -283,7 +294,7 @@ int32_t i18n_udate_count_symbols ( const i18n_udate_format_h format, i18n_udate_ int i18n_udate_set_symbols ( i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *value, int32_t value_length ) { - if (format == NULL) + if (format == NULL || symbol_index < 0) { return I18N_ERROR_INVALID_PARAMETER; } diff --git a/src/utils_i18n_ulocale.c b/src/utils_i18n_ulocale.c index aa1973f..ff1b2e5 100755 --- a/src/utils_i18n_ulocale.c +++ b/src/utils_i18n_ulocale.c @@ -47,8 +47,18 @@ int i18n_ulocale_get_language (const char *locale_id, char *language, int32_t la int32_t i18n_ulocale_get_country (const char *locale_id, char *country, int32_t country_capacity, int *error) { - int32_t result = uloc_getCountry(locale_id, country, country_capacity, error); - *error = _i18n_error_mapping(*error); + if(NULL == country) { + if(NULL != error) { + *error = I18N_ERROR_INVALID_PARAMETER; + } + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = uloc_getCountry(locale_id, country, country_capacity, &icu_error); + if(NULL != error) { + *error = _i18n_error_mapping(icu_error); + } return result; } @@ -291,7 +301,7 @@ int i18n_ulocale_keywords_create (const char *locale_id, i18n_uenumeration_h *en int32_t i18n_ulocale_get_keyword_value (const char *locale_id, const char *keyword_name, char *buffer, int32_t buffer_capacity) { - if(NULL == keyword_name || NULL == buffer || buffer_capacity < 0){ + if(NULL == locale_id || NULL == keyword_name || NULL == buffer || buffer_capacity < 0){ set_last_result(I18N_ERROR_INVALID_PARAMETER); return -1; } diff --git a/src/utils_i18n_unumber.c b/src/utils_i18n_unumber.c index b6bbf22..cda3dd9 100755 --- a/src/utils_i18n_unumber.c +++ b/src/utils_i18n_unumber.c @@ -40,7 +40,7 @@ int i18n_unumber_destroy (i18n_unumber_format_h fmt) int i18n_unumber_get_symbol (const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol) { - retv_if(fmt == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(fmt == NULL || len_symbol == NULL, I18N_ERROR_INVALID_PARAMETER); UErrorCode icu_error = U_ZERO_ERROR; *len_symbol = unum_getSymbol(fmt, symbol, buffer, size, &icu_error); @@ -115,7 +115,7 @@ int32_t i18n_unumber_format_double (const i18n_unumber_format_h fmt, double numb int32_t i18n_unumber_format_decimal (const i18n_unumber_format_h fmt, const char *number, int32_t length, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos) { - if(fmt == NULL) { + if(fmt == NULL || number == NULL) { set_last_result(I18N_ERROR_INVALID_PARAMETER); return 0; } @@ -217,7 +217,7 @@ int32_t i18n_unumber_parse_decimal (const i18n_unumber_format_h fmt, const i18n_ double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_uchar *currency) { - if(fmt == NULL || text == NULL) { + if(fmt == NULL || text == NULL || currency == NULL) { set_last_result(I18N_ERROR_INVALID_PARAMETER); return 0; } @@ -234,7 +234,7 @@ double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, cons int i18n_unumber_apply_pattern (i18n_unumber_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length, i18n_uparse_error_s* parse_error) { - if(format == NULL) { + if(format == NULL || pattern == NULL || pattern_length < -1) { return I18N_ERROR_INVALID_PARAMETER; } diff --git a/src/utils_i18n_uset.c b/src/utils_i18n_uset.c index ef109dd..b8e6f89 100644 --- a/src/utils_i18n_uset.c +++ b/src/utils_i18n_uset.c @@ -84,7 +84,7 @@ int i18n_uset_destroy ( i18n_uset_h set ) int i18n_uset_clone ( const i18n_uset_h set, i18n_uset_h *set_clone ) { set_last_result(I18N_ERROR_NONE); - if (set == NULL) { + if (set == NULL || set_clone == NULL) { return I18N_ERROR_INVALID_PARAMETER; } *set_clone = (i18n_uset_h)uset_clone((const USet*)set); @@ -114,7 +114,7 @@ int i18n_uset_freeze ( i18n_uset_h set ) int i18n_uset_clone_as_thawed ( const i18n_uset_h set, i18n_uset_h *set_copy ) { set_last_result(I18N_ERROR_NONE); - if (set == NULL) { + if (set == NULL || set_copy == NULL) { return I18N_ERROR_INVALID_PARAMETER; } *set_copy = (i18n_uset_h)uset_cloneAsThawed((const USet*)set); @@ -482,7 +482,7 @@ int32_t i18n_uset_get_item_count ( const i18n_uset_h set ) int32_t i18n_uset_get_item ( const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end, i18n_uchar *str, int32_t str_capacity ) { - if (set == NULL || (item_index < 0 || item_index > uset_getItemCount((const USet*)set)-1)) { + if (set == NULL || (item_index < 0 || item_index > uset_getItemCount((const USet*)set)-1) || start == NULL || end == NULL) { set_last_result(I18N_ERROR_INVALID_PARAMETER); return 0; }