record_conv: change construct prototype
[yaz-moved-to-github.git] / src / icu_chain.c
index 4f36502..bf614d0 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2012 Index Data
  * See the file LICENSE for details.
  */
 
@@ -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;
@@ -191,21 +192,17 @@ struct icu_chain_step *icu_chain_step_clone(struct icu_chain_step *old)
 struct icu_chain *icu_chain_create(const char *locale, int sort,
                                    UErrorCode *status)
 {
-    struct icu_chain *chain 
-        = (struct icu_chain *) xmalloc(sizeof(*chain));
+    struct icu_chain *chain;
+    UCollator *coll = ucol_open(locale, status);
 
-    *status = U_ZERO_ERROR;
+    if (U_FAILURE(*status))
+        return 0;
 
+    chain = (struct icu_chain *) xmalloc(sizeof(*chain));
     chain->iter = 0;
     chain->locale = xstrdup(locale);
-
     chain->sort = sort;
-
-    chain->coll = ucol_open((const char *) chain->locale, status);
-
-    if (U_FAILURE(*status))
-        return 0;
-
+    chain->coll = coll;
     chain->csteps = 0;
 
     return chain;
@@ -226,10 +223,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 +234,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;