Coverage Improvement of Contacts Service
[platform/core/pim/contacts-service.git] / server / ctsvc_normalize.c
index d8b2e68..b8d4117 100644 (file)
@@ -189,19 +189,17 @@ static int __ctsvc_normalize_str(const char *src, char **dest, bool is_index)
 
        u_strFromUTF8(tmp_result, tmp_size + 1, &tmp_size, src, -1, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
+                       /* LCOV_EXCL_START */
                status = U_ZERO_ERROR;
                free(tmp_result);
                tmp_result = calloc(1, sizeof(UChar) * (tmp_size + 1));
                if (NULL == tmp_result) {
-                       /* LCOV_EXCL_START */
                        ERR("calloc() Fail");
                        return CONTACTS_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
 
                u_strFromUTF8(tmp_result, tmp_size + 1, NULL, src, -1, &status);
                if (U_FAILURE(status)) {
-                       /* LCOV_EXCL_START */
                        ERR("u_strFromUTF8()Fail(%s)", u_errorName(status));
                        free(tmp_result);
                        return CONTACTS_ERROR_SYSTEM;
@@ -226,20 +224,18 @@ static int __ctsvc_normalize_str(const char *src, char **dest, bool is_index)
 
        upper_size = u_strToUpper(tmp_upper, tmp_size+1, tmp_result, -1, NULL, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
+                       /* LCOV_EXCL_START */
                status = U_ZERO_ERROR;
                free(tmp_upper);
                tmp_upper = calloc(1, sizeof(UChar) * (upper_size + 1));
                if (NULL == tmp_upper) {
-                       /* LCOV_EXCL_START */
                        ERR("calloc() Fail");
                        free(tmp_result);
                        return CONTACTS_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
 
                u_strFromUTF8(tmp_upper, upper_size + 1, NULL, src, -1, &status);
                if (U_FAILURE(status)) {
-                       /* LCOV_EXCL_START */
                        ERR("u_strFromUTF8()Fail(%s)", u_errorName(status));
                        free(tmp_result);
                        free(tmp_upper);
@@ -267,21 +263,19 @@ static int __ctsvc_normalize_str(const char *src, char **dest, bool is_index)
 
        size = unorm_normalize(tmp_upper, -1, UNORM_NFD, 0, result, size+1, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
+                       /* LCOV_EXCL_START */
                status = U_ZERO_ERROR;
                free(result);
                result = calloc(1, sizeof(UChar)*(size + 1));
                if (NULL == result) {
-                       /* LCOV_EXCL_START */
                        ERR("calloc() Fail");
                        free(tmp_result);
                        free(tmp_upper);
                        return CONTACTS_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
 
                unorm_normalize(tmp_upper, -1, UNORM_NFD, 0, result, size+1, &status);
                if (U_FAILURE(status)) {
-                       /* LCOV_EXCL_START */
                        ERR("unorm_normalize() Fail(%s)", u_errorName(status));
                        free(tmp_result);
                        free(tmp_upper);
@@ -330,9 +324,11 @@ static int __ctsvc_normalize_str(const char *src, char **dest, bool is_index)
        }
 
        if (replaced) {
+                       /* LCOV_EXCL_START */
                temp_result[j] = 0x0;
                free(result);
                result = temp_result;
+                       /* LCOV_EXCL_STOP */
        } else {
                free(temp_result);
        }
@@ -388,13 +384,16 @@ static int __ctsvc_convert_halfwidth_ascii_and_symbol(const char *src, UChar *de
        for (i = 0; i < size; i++) {
                /* FF00 ~ FF60: Fullwidth ASCII variants */
                if (CTSVC_COMPARE_BETWEEN((UChar)0xFF00, dest[i], (UChar)0xFF60)) {
+                       /* LCOV_EXCL_START */
                        int unicode_value1 = 0;
                        int unicode_value2 = 0;
                        unicode_value1 = 0x0;
                        unicode_value2 = (0xFF & dest[i]) + 0x20;
                        dest[i] = unicode_value1 << 8 | unicode_value2;
+                       /* LCOV_EXCL_STOP */
                } else if (CTSVC_COMPARE_BETWEEN((UChar)0xFFE0, dest[i], (UChar)0xFFE6)) {
                        /* FFE0~FFE6: Fullwidth symbol variants */
+                       /* LCOV_EXCL_START */
                        if (dest[i] == (UChar)0xFFE0)
                                dest[i] = (UChar)0x00A2;
                        else if (dest[i] == (UChar)0xFFE1)
@@ -409,6 +408,7 @@ static int __ctsvc_convert_halfwidth_ascii_and_symbol(const char *src, UChar *de
                                dest[i] = (UChar)0x00A5;
                        else if (dest[i] == (UChar)0xFFE6)
                                dest[i] = (UChar)0x20A9;
+                       /* LCOV_EXCL_STOP */
                        /* else */
                } /* else */
 
@@ -467,7 +467,7 @@ int ctsvc_normalize_str(const char *src, char **dest)
        ret = __ctsvc_normalize_str(temp, dest, false);
        return ret;
 }
-
+                       /* LCOV_EXCL_START */
 static void __ctsvc_convert_japanese_group_letter(char *dest)
 {
        int i, size, dest_len;
@@ -492,7 +492,7 @@ static void __ctsvc_convert_japanese_group_letter(char *dest)
        RETM_IF(U_FAILURE(status), "u_strToUTF8() Fail(%s)", u_errorName(status));
 
 }
-
+                       /* LCOV_EXCL_STOP */
 static bool __ctsvc_check_range_out_index(const char src[])
 {
        if (src[0] == 0xe2 && src[1] == 0x80 && src[2] == 0xa6)
@@ -529,7 +529,9 @@ int ctsvc_normalize_index(const char *src, char **dest)
        }
 
        if (ret == CTSVC_LANG_JAPANESE)
+                       /* LCOV_EXCL_START */
                __ctsvc_convert_japanese_group_letter(*dest);
+                       /* LCOV_EXCL_STOP */
 
        return ret;
 }