* 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.10 2007-10-29 13:50:57 marc Exp $
*/
#if HAVE_CONFIG_H
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;
}
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++;
-/* $Id: tst_icu_I18N.c,v 1.10 2007-10-29 10:22:23 marc Exp $
+/* $Id: tst_icu_I18N.c,v 1.11 2007-10-29 13:50:57 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- // printf("ICU chain:\ninput: '%s'\n", en_str);
-
chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
YAZ_CHECK(icu_chain_assign_cstr(chain, en_str, &status));
+ //printf("ICU chain:\ninput: '%s'\n", en_str);
while (icu_chain_next_token(chain, &status)){
;
- // printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
while (icu_chain_next_token(chain, &status)){
;
- //printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
while (icu_chain_next_token(chain, &status)){
;
- //printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
while (icu_chain_next_token(chain, &status)){
;
- //printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
/* we expect 'what' 'is' 'this', i.e. 3 tokens */
YAZ_CHECK(chain);
YAZ_CHECK(icu_chain_assign_cstr(
- chain, "a string with 15 wordbreaks and 8 tokens",
+ chain, "a string with 15 tokenss and 8 displays",
&status));
while (icu_chain_next_token(chain, &status)){
;
- //printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
- YAZ_CHECK_EQ(icu_chain_token_number(chain), 8);
+ YAZ_CHECK_EQ(icu_chain_token_number(chain), 15);
icu_chain_destroy(chain);
}
while (icu_chain_next_token(chain, &status)){
;
- //printf("%d '%s' '%s'\n",
- // icu_chain_token_number(chain),
- // icu_chain_token_norm(chain),
- // icu_chain_token_display(chain));
+ /* printf("%d '%s' '%s'\n",
+ icu_chain_token_number(chain),
+ icu_chain_token_norm(chain),
+ icu_chain_token_display(chain)); */
}
YAZ_CHECK_EQ(icu_chain_token_number(chain), 1);
- dest8 = icu_chain_token_norm(chain);
+ dest8 = (char *) icu_chain_token_norm(chain);
YAZ_CHECK_EQ(strcmp(src8, dest8), 0);