void icu_chain_destroy(yaz_icu_chain_t chain);
yaz_icu_chain_t icu_chain_xml_config(const xmlNode *xml_node,
- const char *locale,
int sort,
UErrorCode * status);
struct icu_casemap
{
- char locale[16];
char action;
};
int icu_casemap_casemap(struct icu_casemap * casemap,
struct icu_buf_utf16 * dest16,
struct icu_buf_utf16 * src16,
- UErrorCode *status);
+ UErrorCode *status,
+ const char *locale);
int icu_utf16_casemap(struct icu_buf_utf16 * dest16,
struct icu_buf_utf16 * src16,
struct icu_chain
{
- uint8_t locale[16];
+ char locale[16];
int sort;
const char * src8cstr;
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: icu_I18N.c,v 1.13 2007-11-08 08:17:17 adam Exp $
+ * $Id: icu_I18N.c,v 1.14 2007-11-08 13:35:13 adam Exp $
*/
#if HAVE_CONFIG_H
{
struct icu_casemap * casemap
= (struct icu_casemap *) malloc(sizeof(struct icu_casemap));
- strcpy(casemap->locale, locale);
casemap->action = action;
switch(casemap->action) {
void icu_casemap_destroy(struct icu_casemap * casemap)
{
- if (casemap)
+ if (casemap)
free(casemap);
}
int icu_casemap_casemap(struct icu_casemap * casemap,
struct icu_buf_utf16 * dest16,
struct icu_buf_utf16 * src16,
- UErrorCode *status)
+ UErrorCode *status,
+ const char *locale)
{
if(!casemap)
return 0;
- return icu_utf16_casemap(dest16, src16,
- casemap->locale, casemap->action, status);
+ return icu_utf16_casemap(dest16, src16, locale,
+ casemap->action, status);
}
struct icu_chain * icu_chain_xml_config(const xmlNode *xml_node,
- const char *locale,
int sort,
- UErrorCode * status){
-
+ UErrorCode * status)
+{
xmlNode *node = 0;
struct icu_chain * chain = 0;
*status = U_ZERO_ERROR;
- if (!xml_node
- ||xml_node->type != XML_ELEMENT_NODE
- // || strcmp((const char *) xml_node->name, "icu_chain")
- )
-
+ if (!xml_node ||xml_node->type != XML_ELEMENT_NODE)
return 0;
-
- chain = icu_chain_create(locale, sort, status);
-
+
+ {
+ 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;
-
for (node = xml_node->children; node; node = node->next)
{
xmlChar *xml_rule;
break;
case ICU_chain_step_type_casemap:
icu_casemap_casemap(step->u.casemap,
- step->buf16, src16, status);
+ step->buf16, src16, status,
+ chain->locale);
break;
case ICU_chain_step_type_normalize:
icu_normalizer_normalize(step->u.normalizer,
* Copyright (C) 2005-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tst_icu_I18N.c,v 1.13 2007-11-08 09:03:11 adam Exp $
+ * $Id: tst_icu_I18N.c,v 1.14 2007-11-08 13:35:14 adam Exp $
*
*/
struct icu_chain * chain = 0;
- const char * xml_str = "<icu>"
+ const char * xml_str = "<icu locale=\"en\">"
"<normalize rule=\"[:Control:] Any-Remove\"/>"
"<tokenize rule=\"l\"/>"
"<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
-
- chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
+ chain = icu_chain_xml_config(xml_node, 0, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
- const char * xml_str = "<icu>"
+ const char * xml_str = "<icu locale=\"en\">"
/* if the first rule is normalize instead. Then it works */
#if 0
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
+ chain = icu_chain_xml_config(xml_node, 0, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
- const char * xml_str = "<icu>"
+ const char * xml_str = "<icu locale=\"en\">"
"<tokenize rule=\"w\"/>"
"<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
"</icu>";
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
+ chain = icu_chain_xml_config(xml_node, 0, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
- const char * xml_str = "<icu>"
+ const char * xml_str = "<icu locale=\"en\">"
"</icu>";
const char * src8 = "some 5487 weired !ยค%&(/& sTuFf";
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
+ chain = icu_chain_xml_config(xml_node, 0, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: yaz-icu.c,v 1.10 2007-11-08 09:29:39 adam Exp $
+ * $Id: yaz-icu.c,v 1.11 2007-11-08 13:35:14 adam Exp $
*/
#if HAVE_CONFIG_H
xmlDoc *doc = xmlParseFile(config.conffile);
xmlNode *xml_node = xmlDocGetRootElement(doc);
- xmlChar *xml_locale = xmlGetProp(xml_node, (xmlChar *) "locale");
long unsigned int token_count = 0;
long unsigned int line_count = 0;
exit (1);
}
- if (!xml_locale || !strlen((const char *) xml_locale))
- return;
-
- config.chain = icu_chain_xml_config(xml_node, (const char *) xml_locale, 0,
- &status);
-
- xmlFree(xml_locale);
-
+ config.chain = icu_chain_xml_config(xml_node, 0, &status);
if (config.chain && U_SUCCESS(status))
success = 1;