For ICU, locale, is a char ptr rather than uint8_t ptr.
[yaz-moved-to-github.git] / src / icu_I18N.c
index efc3cfc..1f30990 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: icu_I18N.c,v 1.8 2007-10-25 10:04:32 marc Exp $
+ * $Id: icu_I18N.c,v 1.11 2007-11-06 10:27:30 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -850,7 +850,7 @@ void icu_chain_step_destroy(struct icu_chain_step * step){
 
 
 
-struct icu_chain * icu_chain_create(const uint8_t * locale, 
+struct icu_chain * icu_chain_create(const char *locale, 
                                     int sort,
                                     UErrorCode * status)
 {
@@ -905,8 +905,8 @@ void icu_chain_destroy(struct icu_chain * chain)
 
 
 
-struct icu_chain * icu_chain_xml_config(xmlNode *xml_node, 
-                                        const uint8_t * locale, 
+struct icu_chain * icu_chain_xml_config(const xmlNode *xml_node, 
+                                        const char *locale, 
                                         int sort,
                                         UErrorCode * status){
 
@@ -1035,6 +1035,7 @@ int icu_chain_step_next_token(struct icu_chain * chain,
     if (step->previous){
         src16 = step->previous->buf16;
         /* tokens might be killed in previous steps, therefore looping */
+
         while (step->need_new_token 
                && step->previous->more_tokens
                && !got_new_token)
@@ -1088,8 +1089,10 @@ int icu_chain_step_next_token(struct icu_chain * chain,
         /* make sure to get new previous token if this one had been used up
            by recursive call to _same_ step */
 
-        if (!step->more_tokens)
+        if (!step->more_tokens){
             step->more_tokens = icu_chain_step_next_token(chain, step, status);
+            return step->more_tokens;  // avoid one token count too much!
+        }
 
         break;
     default:
@@ -1101,11 +1104,8 @@ int icu_chain_step_next_token(struct icu_chain * chain,
         return 0;
 
     /* if token disappered into thin air, tell caller */
-    if (!step->buf16->utf16_len)
-        return 0;
-    
-    if (U_FAILURE(*status))
-        return 0;
+    /* if (!step->buf16->utf16_len && !step->more_tokens) */ 
+    /*    return 0; */ 
 
     return 1;
 }
@@ -1173,7 +1173,7 @@ int icu_chain_next_token(struct icu_chain * chain,
 
         while(!got_token && chain->steps && chain->steps->more_tokens)
             got_token = icu_chain_step_next_token(chain, chain->steps, status);
-    
+
         if (got_token){
             chain->token_count++;
 
@@ -1191,7 +1191,7 @@ int icu_chain_next_token(struct icu_chain * chain,
     return 0;
 }
 
-int icu_chain_get_token_count(struct icu_chain * chain)
+int icu_chain_token_number(struct icu_chain * chain)
 {
     if (!chain)
         return 0;
@@ -1200,7 +1200,7 @@ int icu_chain_get_token_count(struct icu_chain * chain)
 }
 
 
-const char * icu_chain_get_display(struct icu_chain * chain)
+const char * icu_chain_token_display(struct icu_chain * chain)
 {
     if (chain->display8)
         return icu_buf_utf8_to_cstr(chain->display8);
@@ -1208,7 +1208,7 @@ const char * icu_chain_get_display(struct icu_chain * chain)
     return 0;
 }
 
-const char * icu_chain_get_norm(struct icu_chain * chain)
+const char * icu_chain_token_norm(struct icu_chain * chain)
 {
     if (!chain->steps)
         return chain->src8cstr;
@@ -1219,7 +1219,7 @@ const char * icu_chain_get_norm(struct icu_chain * chain)
     return 0;
 }
 
-const char * icu_chain_get_sort(struct icu_chain * chain)
+const char * icu_chain_token_sortkey(struct icu_chain * chain)
 {
     if (chain->sort8)
         return icu_buf_utf8_to_cstr(chain->sort8);