Reformat, remove a few redundant type casts
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 15 Nov 2011 12:55:45 +0000 (13:55 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 15 Nov 2011 12:55:45 +0000 (13:55 +0100)
src/icu_casemap.c
src/icu_chain.c
src/icu_tokenizer.c
src/icu_transform.c
src/icu_utf16.c
src/icu_utf8.c

index f75381e..2e3b9c3 100644 (file)
@@ -73,7 +73,7 @@ int icu_casemap_casemap(struct icu_casemap * casemap,
                         UErrorCode *status,
                         const char *locale)
 {
-    if(!casemap)
+    if (!casemap)
         return 0;
     
     return icu_utf16_casemap(dest16, src16, locale,
index 4f36502..7bf8109 100644 (file)
@@ -101,7 +101,7 @@ static struct icu_chain_step *icu_chain_insert_step(
                                                  0, status);
         break;
     case ICU_chain_step_type_tokenize:
-        step->u.tokenizer = icu_tokenizer_create((char *) chain->locale, 
+        step->u.tokenizer = icu_tokenizer_create(chain->locale, 
                                                  (char) rule[0], status);
         break;
     case ICU_chain_step_type_transliterate:
@@ -110,7 +110,8 @@ static struct icu_chain_step *icu_chain_insert_step(
                                                  (const char *) rule, status);
         break;
     case YAZ_chain_step_type_stemming:
-        step->u.stemmer = yaz_stemmer_create((char *) chain->locale, (const char *) rule, status);
+        step->u.stemmer = yaz_stemmer_create(chain->locale,
+                                             (const char *) rule, status);
         break;
     default:
         break;
@@ -201,7 +202,7 @@ struct icu_chain *icu_chain_create(const char *locale, int sort,
 
     chain->sort = sort;
 
-    chain->coll = ucol_open((const char *) chain->locale, status);
+    chain->coll = ucol_open(chain->locale, status);
 
     if (U_FAILURE(*status))
         return 0;
@@ -226,10 +227,6 @@ void icu_chain_destroy(struct icu_chain *chain)
     }
 }
 
-static struct icu_chain_step *icu_chain_insert_step(
-    struct icu_chain *chain, enum icu_chain_step_type type,
-    const uint8_t *rule, UErrorCode *status);
-
 struct icu_chain *icu_chain_xml_config(const xmlNode *xml_node, 
                                        int sort,
                                        UErrorCode *status)
@@ -241,20 +238,17 @@ struct icu_chain *icu_chain_xml_config(const xmlNode *xml_node,
    
     *status = U_ZERO_ERROR;
 
-    if (!xml_node ||xml_node->type != XML_ELEMENT_NODE)
-        return 0;
-    
+    if (xml_node && xml_node->type == XML_ELEMENT_NODE)
     {
         xmlChar *xml_locale = xmlGetProp((xmlNode *) xml_node, 
                                          (xmlChar *) "locale");
-        
         if (xml_locale)
         {
             chain = icu_chain_create((const char *) xml_locale, sort, status);
             xmlFree(xml_locale);
         }
-        
     }
+
     if (!chain)
         return 0;
 
index 54cfbf3..25b674c 100644 (file)
@@ -195,14 +195,16 @@ int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
     {
         tokenizer->token_count++;
         tokenizer->token_id++;
-    } else {
-        tokenizer->token_id = 0;    
     }
+    else
+        tokenizer->token_id = 0;    
+
     tokenizer->token_start = tkn_start;
     tokenizer->token_end = tkn_end;    
 
     /* copying into token buffer if it exists */
-    if (tkn16){
+    if (tkn16)
+    {
         if (tkn16->utf16_cap < tkn_len)
             icu_buf_utf16_resize(tkn16, (size_t) tkn_len * 2);
 
index e8d2012..2d2b1ce 100644 (file)
@@ -130,10 +130,10 @@ int icu_transform_trans(struct icu_transform * transform,
     if (!icu_buf_utf16_copy(dest16, src16))
         return 0;
 
-    utrans_transUChars (transform->trans, 
-                        dest16->utf16, &(dest16->utf16_len),
-                        dest16->utf16_cap,
-                        0, &(dest16->utf16_len), status);
+    utrans_transUChars(transform->trans, 
+                       dest16->utf16, &(dest16->utf16_len),
+                       dest16->utf16_cap,
+                       0, &(dest16->utf16_len), status);
 
     if (U_FAILURE(*status))
         icu_buf_utf16_clear(dest16);
index c5970ef..a5bfcb6 100644 (file)
@@ -61,7 +61,7 @@ struct icu_buf_utf16 * icu_buf_utf16_resize(struct icu_buf_utf16 * buf16,
     if (!buf16)
         return 0;
     
-    if (capacity >  0)
+    if (capacity > 0)
     {
         if (0 == buf16->utf16)
             buf16->utf16 = (UChar *) xmalloc(sizeof(UChar) * capacity);
@@ -79,7 +79,6 @@ struct icu_buf_utf16 * icu_buf_utf16_resize(struct icu_buf_utf16 * buf16,
         buf16->utf16_len = 0;
         buf16->utf16_cap = 0;
     }
-
     return buf16;
 }
 
index 77fc2b3..8b93753 100644 (file)
@@ -61,7 +61,7 @@ struct icu_buf_utf8 * icu_buf_utf8_resize(struct icu_buf_utf8 * buf8,
     if (!buf8)
         return 0;
 
-    if (capacity >  0)
+    if (capacity > 0)
     {
         if (0 == buf8->utf8)
             buf8->utf8 = (uint8_t *) xmalloc(sizeof(uint8_t) * capacity);
@@ -71,7 +71,8 @@ struct icu_buf_utf8 * icu_buf_utf8_resize(struct icu_buf_utf8 * buf8,
         
         buf8->utf8_cap = capacity;
     } 
-    else { 
+    else
+    { 
         xfree(buf8->utf8);
         buf8->utf8 = 0;
         buf8->utf8_len = 0;
@@ -125,8 +126,7 @@ UErrorCode icu_utf16_from_utf8_cstr(struct icu_buf_utf16 * dest16,
                       src8cstr, src8cstr_len, status);
     }
 
-    if (U_SUCCESS(*status)  
-        && utf16_len <= dest16->utf16_cap)
+    if (U_SUCCESS(*status) && utf16_len <= dest16->utf16_cap)
         dest16->utf16_len = utf16_len;
     else 
         icu_buf_utf16_clear(dest16);
@@ -154,8 +154,7 @@ UErrorCode icu_utf16_to_utf8(struct icu_buf_utf8 *dest8,
                     src16->utf16, src16->utf16_len, status);
     }
 
-    if (U_SUCCESS(*status)  
-        && utf8_len <= dest8->utf8_cap)
+    if (U_SUCCESS(*status) && utf8_len <= dest8->utf8_cap)
         dest8->utf8_len = utf8_len;
     else 
         icu_buf_utf8_clear(dest8);