From 22c9b5841f81c8611067502bdc62255a0739f4d9 Mon Sep 17 00:00:00 2001 From: JinWang An Date: Fri, 18 Jun 2021 15:17:14 +0900 Subject: [PATCH] Fix i18ninfo/i18ninfo.cpp to clean source Change-Id: I83f63804b9d747dbefa4560bb5347aaa9edb237f Signed-off-by: JinWang An --- i18ninfo/i18ninfo.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/i18ninfo/i18ninfo.cpp b/i18ninfo/i18ninfo.cpp index 7daf794..f283c05 100644 --- a/i18ninfo/i18ninfo.cpp +++ b/i18ninfo/i18ninfo.cpp @@ -22,12 +22,12 @@ static int ASCIIDOC_FLAG = 0; #define PRINT_DEBUG_LOG(fmt, arg...) ((DEBUG_FLAG) ? fprintf(stdout, "\033[0;32m" fmt "\033[1;32m \033[0m", ##arg) : 0 ) #define CHECK_ERROR(fun_name, error_code) if (error_code != 0) { \ - PRINT_ERROR_LOG(fun_name, error_code); \ - } + PRINT_ERROR_LOG(fun_name, error_code); \ +} #define COPY_STR(dst, src, dst_len) do { \ - strncpy((dst), (src), (dst_len + 1)); \ - (dst)[(dst_len)] = '\0'; \ + strncpy((dst), (src), (dst_len + 1)); \ + (dst)[(dst_len)] = '\0'; \ } while (0) #define PRINT_ASCIIDOC_LOG(fmt) if (ASCIIDOC_FLAG) printf(fmt) @@ -363,7 +363,7 @@ static char *_date_basic_format_convert(const char *input_pattern, int i, const i18n_udate date_now = 259200000; if (!strcmp(type, "day")) { - date_now += i * 86400000; + date_now += i * 86400000; } else if (!strcmp(type, "month")) { int k; for (k = 0; k < i; k++) @@ -553,9 +553,9 @@ static int __get_date_and_time(char *input_time) ret = i18n_timezone_create_default(&tmz); CHECK_ERROR("18n_timezone_create_default", ret); ret = i18n_timezone_get_id(tmz, &timezone_id); - timezone_id_len = strlen(timezone_id); - i18n_ustring_copy_ua_n(default_timezone_id, timezone_id, - (timezone_id_len > BUF_SIZE - 1)? BUF_SIZE - 1 : timezone_id_len); + CHECK_ERROR("i18n_timezone_get_id", ret); + + i18n_ustring_copy_ua_n(default_timezone_id, timezone_id, BUF_SIZE - 1); int pattern_len, len; i18n_uchar pattern[BUF_SIZE], skeleton[BUF_SIZE]; @@ -747,7 +747,7 @@ static int __get_language_info() int name_len; int ret = - i18n_ulocale_get_display_name(default_locale, default_locale, name, BUF_SIZE, &name_len); + i18n_ulocale_get_display_name(default_locale, default_locale, name, BUF_SIZE, &name_len); CHECK_ERROR("i18n_ulocale_get_display_name", ret); char name_ch[BUF_SIZE]; i18n_ustring_copy_au(name_ch, name); @@ -808,7 +808,7 @@ static int __manage_string_iteration(char *input_string) const char *input_text = "Twinkle, twinkle, little star. How I wonder what you are"; printf(" - Input string : %s\n", input_text); string_to_examine = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); if(NULL == string_to_examine) return I18N_ERROR_OUT_OF_MEMORY; i18n_ustring_copy_ua(string_to_examine, input_text); @@ -817,7 +817,7 @@ static int __manage_string_iteration(char *input_string) COPY_STR(input_text, input_string, 999); printf(" - Input string : %s\n", input_text); string_to_examine = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); if(NULL == string_to_examine) return I18N_ERROR_OUT_OF_MEMORY; i18n_ustring_copy_ua(string_to_examine, input_text); @@ -901,13 +901,13 @@ static int __analyze_string(char *custom_string) const char *input_text = "String"; printf(" - Input string : %s\n", input_text); string_to_examine = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); i18n_ustring_copy_ua(string_to_examine, input_text); } else { char *input_text = custom_string; printf(" - Input string : %s\n", input_text); string_to_examine = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1)); i18n_ustring_copy_ua(string_to_examine, input_text); } @@ -1282,7 +1282,7 @@ static int __convert_number(char *custom_number) const char *input_number = "abc০১২৩def四五六ⅦⅧⅨ"; printf(" Input number : %s\n", input_number); number_to_convert = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_number) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_number) + 1)); if (NULL == number_to_convert) return I18N_ERROR_OUT_OF_MEMORY; @@ -1304,7 +1304,7 @@ static int __convert_number(char *custom_number) char *input_number = custom_number; printf(" Input number : %s\n", input_number); number_to_convert = - (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_number) + 1)); + (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_number) + 1)); i18n_ustring_copy_ua(number_to_convert, input_number); i18n_uchar *str = _convert_unicode_numeric_values(number_to_convert, i18n_ustring_get_length(number_to_convert)); @@ -1451,7 +1451,7 @@ struct create_mu mu[] = { {"volume", "quart", i18n_measure_unit_create_quart}, {"volume", "tablespoon", i18n_measure_unit_create_tablespoon}, {"volume", "teaspoon", i18n_measure_unit_create_teaspoon} - }; +}; static int __show_measure_unit(char *input_number) { @@ -1529,7 +1529,7 @@ static int __show_measure_unit(char *input_number) printf("| %-12s | %-24s |%-10s |%-15s |%s\n", mu[i].unit_type, mu[i].unit_subtype, output_text_narrow, output_text_short, output_text_wide); i18n_measure_destroy(measure); } - PRINT_ASCIIDOC_LOG("|===\n"); + PRINT_ASCIIDOC_LOG("|===\n"); return 0; } -- 2.7.4