From: Hyunjee Kim Date: Mon, 10 Apr 2017 06:25:04 +0000 (+0900) Subject: Fix print format error in showDatentimeFormat X-Git-Tag: submit/tizen/20170424.073737~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93ece46774b565235b2b2cc7ee594f4a7538e8e1;p=platform%2Fcore%2Fapi%2Fbase-utils.git Fix print format error in showDatentimeFormat Change-Id: Ia48b60867f906a69269d89a19d4e551d3673f6dd Signed-off-by: Hyunjee Kim --- diff --git a/i18ninfo/i18ninfo.c b/i18ninfo/i18ninfo.c index 031fc8c..07bee02 100644 --- a/i18ninfo/i18ninfo.c +++ b/i18ninfo/i18ninfo.c @@ -11,7 +11,7 @@ #define DEBUG_FLAG 0 static int ASCIIDOC_FLAG = 0; -#define BUF_SIZE 64 +#define BUF_SIZE 1000 #define MS_TO_MIN 60000 #define MS_TO_HOUR 3600000 @@ -29,8 +29,8 @@ static int ASCIIDOC_FLAG = 0; } #define COPY_STR(dst, src, dst_len) do { \ - strncpy((dst), (src), (dst_len)); \ - (dst)[(dst_len) - 1] = '\0'; \ + strncpy((dst), (src), (dst_len + 1)); \ + (dst)[(dst_len)] = '\0'; \ } while (0) #define PRINT_ASCIIDOC_LOG(fmt) if (ASCIIDOC_FLAG) printf(fmt) @@ -362,13 +362,13 @@ static int __get_date_basic_format() printf(" Day - Formatting\n"); PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n"); PRINT_ASCIIDOC_LOG("|===\n"); - printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); + printf("| # | %s | %s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); for (i = 0; i < 7; i++) { f_narrow = _date_basic_format_convert("EEEEE", i, "day"); f_short = _date_basic_format_convert("EEE", i, "day"); f_long = _date_basic_format_convert("EEEE", i, "day"); - printf("| %d | %-11.1s | %-11.3s | %s\n", i, f_narrow, f_short, f_long); + printf("| %d | %s | %s | %s\n", i, f_narrow, f_short, f_long); } PRINT_ASCIIDOC_LOG("|===\n"); @@ -376,13 +376,13 @@ static int __get_date_basic_format() printf(" Day - Stand-alone\n"); PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n"); PRINT_ASCIIDOC_LOG("|===\n"); - printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); + printf("| # | %-s | %s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); for (i = 0; i < 7; i++) { s_narrow = _date_basic_format_convert("ccccc", i, "day"); s_short = _date_basic_format_convert("ccc", i, "day"); s_long = _date_basic_format_convert("cccc", i, "day"); - printf("| %d | %-11.1s | %-11.3s | %s\n", i, s_narrow, s_short, s_long); + printf("| %d | %s | %s | %s\n", i, s_narrow, s_short, s_long); } PRINT_ASCIIDOC_LOG("|===\n"); @@ -390,13 +390,13 @@ static int __get_date_basic_format() printf(" Month - Formatting\n"); PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n"); PRINT_ASCIIDOC_LOG("|===\n"); - printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); + printf("| # | %-s | %s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); for (i = 0; i < 12; i++) { f_narrow = _date_basic_format_convert("MMMMM", i, "month"); f_short = _date_basic_format_convert("MMM", i, "month"); f_long = _date_basic_format_convert("MMMM", i, "month"); - printf("| %-2d | %-11.11s | %-11.11s | %-11.11s\n", i, f_narrow, f_short, f_long); + printf("| %-2d | %s | %s | %s\n", i, f_narrow, f_short, f_long); } PRINT_ASCIIDOC_LOG("|===\n"); @@ -404,14 +404,14 @@ static int __get_date_basic_format() printf(" Month - Stand-alone\n"); PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n"); PRINT_ASCIIDOC_LOG("|===\n"); - printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); + printf("| # | %s | %s | %s \n", "Narrow Names" , "Short Names" , "Long Names"); for (i = 0; i < 12; i++) { s_narrow = _date_basic_format_convert("LLLLL", i, "month"); s_short = _date_basic_format_convert("LLL", i, "month"); s_long = _date_basic_format_convert("LLLL", i, "month"); - printf("| %-2d | %-11.1s | %-11.3s | %s\n", i, s_narrow, s_short, s_long); + printf("| %-2d | %s | %s | %s\n", i, s_narrow, s_short, s_long); } PRINT_ASCIIDOC_LOG("|===\n"); @@ -433,7 +433,7 @@ i18n_udate _time_convert(char *input_time) PRINT_DEBUG_LOG("Date from strptime, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n", result.tm_year, result.tm_mon+1, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec); /*create i18n_ucalendar_h */ - ret = i18n_ucalendar_create(0, -1, "en_US", I18N_UCALENDAR_DEFAULT, &ucal); + ret = i18n_ucalendar_create(0, -1, NULL, I18N_UCALENDAR_DEFAULT, &ucal); if (ret) { printf("i18n_ucalendar_create failed.\n"); return -1; @@ -720,6 +720,7 @@ static int __manage_string_iteration(char *input_string) /* Displays the first element in the given text */ for (i = 0; i <= I18N_UBRK_SENTENCE; i++) { + iter_type = NULL; error_code = i18n_ubrk_create(i, default_locale, string_to_examine, -1, &boundary); CHECK_ERROR("i18n_ubrk_create", error_code); int32_t start = i18n_ubrk_first(boundary); @@ -733,6 +734,7 @@ static int __manage_string_iteration(char *input_string) iter_type = __print_i18n_type_string("iter_type", i); printf("| %-19.19s | %s\n", iter_type, str); + free(iter_type); } PRINT_ASCIIDOC_LOG("|===\n"); @@ -742,6 +744,7 @@ static int __manage_string_iteration(char *input_string) printf("| %-19.19s | %s\n", "ITER Last", "VALUE"); /* Displays the last element in the given text */ for (i = 0; i <= I18N_UBRK_SENTENCE; i++) { + iter_type = NULL; error_code = i18n_ubrk_create(i, default_locale, string_to_examine, -1, &boundary); CHECK_ERROR("i18n_ubrk_create", error_code); int32_t end = i18n_ubrk_last(boundary); @@ -755,10 +758,10 @@ static int __manage_string_iteration(char *input_string) iter_type = __print_i18n_type_string("iter_type", i); printf("| %-19.19s | %s\n", iter_type, str); + free(iter_type); } PRINT_ASCIIDOC_LOG("|===\n"); - free(iter_type); free(string_to_examine); error_code = i18n_ubrk_destroy(boundary); CHECK_ERROR("i18n_ubrk_destroy", error_code); @@ -1037,7 +1040,7 @@ void showDatentimeFormat(char *locale) void testDatentime(char *input, char *locale) { - int ret = 0, i = 0; + int ret = 0, i = 0; int loc_count; if (!locale) {