Make init script LSB compliant. http://wiki.debian.org/LSBInitScripts .
[pazpar2-moved-to-github.git] / src / charsets.c
index 2eb2b01..2d5dad3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: charsets.c,v 1.2 2007-05-23 14:44:18 marc Exp $
+/* $Id: charsets.c,v 1.5 2007-05-25 10:32:55 marc Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -68,20 +68,15 @@ pp2_charset_t pp2_charset_create(struct icu_chain * icu_chn)
 {
     pp2_charset_t pct = xmalloc(sizeof(*pct));
 
+    pct->token_next_handler = pp2_relevance_token_a_to_z;
 #ifdef HAVE_ICU
+    pct->icu_chn = 0;
     if (icu_chn){
         pct->icu_chn = icu_chn;
         pct->icu_sts = U_ZERO_ERROR;
         pct->token_next_handler = pp2_relevance_token_icu;
     }
-    else {
-        pct->icu_chn = 0;
-        pct->token_next_handler = pp2_relevance_token_a_to_z;
-    }
-#else // HAVE_ICU
-    pct->token_next_handler = pp2_relevance_token_a_to_z;
-#endif // HAVE_ICU
-
+ #endif // HAVE_ICU
     return pct;
 }
 
@@ -97,28 +92,22 @@ pp2_relevance_token_t pp2_relevance_tokenize(pp2_charset_t pct,
 
     assert(pct);
 
+    prt->norm_str = wrbuf_alloc();
+    prt->cp = buf;
+    prt->pct = pct;
+
 #ifdef HAVE_ICU
-    if (pct->icu_chn){
+    if (pct->icu_chn)
+    {
         pct->icu_sts = U_ZERO_ERROR;
         int ok = 0;
         ok = icu_chain_assign_cstr(pct->icu_chn, buf, &pct->icu_sts);
-        printf("\nfield ok: %d '%s'\n", ok, buf);
-        //prt->cp = buf;
+        //printf("\nfield ok: %d '%s'\n", ok, buf);
         prt->pct = pct;
         prt->norm_str = 0;
-        return prt;
     }
-    else {
 #endif // HAVE_ICU
-
-    prt->norm_str = wrbuf_alloc();
-    prt->cp = buf;
-    prt->pct = pct;
     return prt;
-
-#ifdef HAVE_ICU
-    }
-#endif // HAVE_ICU
 }
 
 
@@ -170,16 +159,16 @@ static const char *pp2_relevance_token_icu(pp2_relevance_token_t prt)
 {
     //&& U_SUCCESS(pct->icu_sts))
     if (icu_chain_next_token(prt->pct->icu_chn, &prt->pct->icu_sts)){
-        printf("'%s' ",  icu_chain_get_norm(prt->pct->icu_chn)); 
+        //printf("'%s' ",  icu_chain_get_norm(prt->pct->icu_chn)); 
         if (U_FAILURE(prt->pct->icu_sts))
         {
-            printf("ICU status failure\n "); 
+            //printf("ICU status failure\n "); 
             return 0;
         }
             
         return icu_chain_get_norm(prt->pct->icu_chn);
     }
-    
+    //printf ("EOF\n");
     return 0;
 };
 #endif // HAVE_ICU