-/* $Id: zebramap.c,v 1.65 2007-11-06 10:30:02 adam Exp $
+/* $Id: zebramap.c,v 1.69 2007-11-08 09:30:05 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
#include <attrfind.h>
#include <yaz/yaz-util.h>
-#if HAVE_ICU
-#include <yaz/icu_I18N.h>
+#if YAZ_HAVE_ICU
+#include <yaz/icu.h>
#endif
#include <zebramap.h>
#if YAZ_HAVE_XML2
xmlDocPtr doc;
#endif
-#if HAVE_ICU
+#if YAZ_HAVE_ICU
struct icu_chain *icu_chain;
#endif
WRBUF simple_buf;
{
if (zm->maptab)
chrmaptab_destroy(zm->maptab);
-#if HAVE_ICU
+#if YAZ_HAVE_ICU
if (zm->icu_chain)
icu_chain_destroy(zm->icu_chain);
#endif
zms->map_list = zm;
zms->last_map = zm;
zm->next = 0;
-#if HAVE_ICU
+#if YAZ_HAVE_ICU
zm->icu_chain = 0;
#endif
#if YAZ_HAVE_XML2
else if (!yaz_matchstr(argv[0], "simplechain"))
{
zm->use_chain = 1;
+#if YAZ_HAVE_ICU
zm->icu_chain = 0;
+#endif
}
else if (!yaz_matchstr(argv[0], "icuchain"))
{
}
else
{
-#if HAVE_ICU
+#if YAZ_HAVE_ICU
UErrorCode status;
xmlNode *xml_node = xmlDocGetRootElement(zm->doc);
zm->icu_chain =
icu_chain_xml_config(xml_node, zm->locale,
+/* not sure about sort for this function yet.. */
+#if 1
+ 1,
+#else
zm->type == ZEBRA_MAP_TYPE_SORT,
+#endif
&status);
if (!zm->icu_chain)
{
const char **result_buf, size_t *result_len)
{
assert(zm->use_chain);
+
+ if (buf)
+ {
+ wrbuf_rewind(zm->simple_buf);
+ wrbuf_write(zm->simple_buf, buf, len);
+ zm->simple_off = 0;
+ }
+
+#if YAZ_HAVE_ICU
if (!zm->icu_chain)
+ return tokenize_simple(zm, result_buf, result_len);
+ else
{
+ UErrorCode status;
if (buf)
{
- wrbuf_rewind(zm->simple_buf);
- wrbuf_write(zm->simple_buf, buf, len);
- zm->simple_off = 0;
+ yaz_log(YLOG_LOG, "assicn_cstr %s", wrbuf_cstr(zm->simple_buf));
+ icu_chain_assign_cstr(zm->icu_chain,
+ wrbuf_cstr(zm->simple_buf),
+ &status);
+ assert(U_SUCCESS(status));
}
- return tokenize_simple(zm, result_buf, result_len);
+ while (icu_chain_next_token(zm->icu_chain, &status))
+ {
+ assert(U_SUCCESS(status));
+ *result_buf = icu_chain_token_norm(zm->icu_chain);
+ assert(*result_buf);
+ yaz_log(YLOG_LOG, "got result %s", *result_buf);
+ *result_len = strlen(*result_buf);
+ if (**result_buf != '\0')
+ return 1;
+ }
+ assert(U_SUCCESS(status));
}
return 0;
+#else
+ return tokenize_simple(zm, result_buf, result_len);
+#endif
}
int zebra_maps_is_icu(zebra_map_t zm)
{
-#if HAVE_ICU
+#if YAZ_HAVE_ICU
return zm->use_chain;
#else
return 0;