Fix to get locale language and country data 28/223628/1 accepted/tizen/unified/20200204.125801 submit/tizen/20200203.063649
authorjinwang.an <jinwang.an@samsung.com>
Fri, 31 Jan 2020 09:28:51 +0000 (18:28 +0900)
committerjinwang.an <jinwang.an@samsung.com>
Fri, 31 Jan 2020 09:28:51 +0000 (18:28 +0900)
Change-Id: I6159f3232c69e413e1ac79498373901af557c316
Signed-off-by: jinwang.an <jinwang.an@samsung.com>
src/system_setting_platform.c
unit_test/src/unit_test.c

index aded30a..ddbb45b 100644 (file)
@@ -1374,9 +1374,15 @@ int system_setting_get_locale_country(system_settings_key_e key, void **value)
 
        /* parsing validation */
        /* en_US.UTF-8 */
-       char arr[20];
+       char arr[21] = {0,};
        snprintf(arr, 20, "%s", vconf_value);
-       arr[5] = '\0';
+       for (int i = 0; i < strlen(arr); i++) {
+               if ('.' == arr[i]) {
+                       arr[i] = 0;
+                       SETTING_TRACE("replace . to NULL : %d", i);
+                       break;
+               }
+       }
        *value = strdup(arr);
        free(vconf_value);
        vconf_value = NULL;
@@ -1427,9 +1433,15 @@ int system_setting_get_locale_language(system_settings_key_e key, void **value)
 
        /* parsing validation */
        /* en_US.UTF-8 */
-       char arr[20];
+       char arr[21] = {0,};
        snprintf(arr, 20, "%s", vconf_value);
-       arr[5] = '\0';
+       for (int i = 0; i < strlen(arr); i++) {
+               if ('.' == arr[i]) {
+                       arr[i] = 0;
+                       SETTING_TRACE("replace . to NULL : %d", i);
+                       break;
+               }
+       }
        *value = strdup(arr);
        free(vconf_value);
        vconf_value = NULL;
index 7785fdc..cc55f7d 100644 (file)
@@ -1968,6 +1968,7 @@ RETTYPE utc_system_settings_set_value_string_p4(void)
        if (ret_country != NULL && 0 == strcmp(ret_country, new_country)) {
                assert(1);
        } else {
+               printf("ret:%s new:%s not same\n", ret_country, new_country);
                assert(0);
        }