* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: icu_I18N.c,v 1.9 2007-10-29 10:22:23 marc Exp $
+ * $Id: icu_I18N.c,v 1.12 2007-11-07 10:19:12 adam Exp $
*/
#if HAVE_CONFIG_H
size_t src8cstr_len = 0;
int32_t utf16_len = 0;
+ *status = U_ZERO_ERROR;
src8cstr_len = strlen(src8cstr);
u_strFromUTF8(dest16->utf16, dest16->utf16_cap,
-struct icu_chain * icu_chain_create(const uint8_t * locale,
+struct icu_chain * icu_chain_create(const char *locale,
int sort,
UErrorCode * status)
{
struct icu_chain * chain
= (struct icu_chain *) malloc(sizeof(struct icu_chain));
+ *status = U_ZERO_ERROR;
+
strncpy((char *) chain->locale, (const char *) locale, 16);
chain->locale[16 - 1] = '\0';
-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){
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 (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)
/* 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:
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;
}
{
int got_token = 0;
+ *status = U_ZERO_ERROR;
+
if (!chain)
return 0;
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++;