-/* $Id: icu_I18N.c,v 1.3 2007-05-01 13:16:09 marc Exp $
+/* $Id: icu_I18N.c,v 1.4 2007-05-02 14:01:36 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
int icu_check_status (UErrorCode status)
{
- if(U_FAILURE(status))
+ //if(U_FAILURE(status))
+ if(!U_SUCCESS(status))
yaz_log(YLOG_WARN,
- "ICU Error: %d %s\n", status, u_errorName(status));
+ "ICU: %d %s\n", status, u_errorName(status));
return status;
}
struct icu_termmap * icu_termmap_create(NMEM nmem)
{
struct icu_termmap *itmp = nmem_malloc(nmem, sizeof(*itmp));
- itmp->sort_len = 0;
itmp->sort_key = 0;
itmp->norm_term = 0;
itmp->disp_term = 0;
{
struct icu_termmap *itmp1 = *(struct icu_termmap **) vp1;
struct icu_termmap *itmp2 = *(struct icu_termmap **) vp2;
- int cmp = 0;
-#if 0
- size_t len = itmp1->sort_len;
- // minimum sortkey length
- if (itmp2->sort_len < len)
- len = itmp2->sort_len;
-
- cmp = strncmp(itmp1->sort_key, itmp2->sort_key, len);
-
- if (cmp == 0 && (itmp1->sort_len < itmp2->sort_len))
- cmp = -1;
-
- if (cmp == 0 && (itmp1->sort_len > itmp2->sort_len))
- cmp = 1;
-#else
- cmp = strcmp(itmp1->sort_key, itmp2->sort_key);
-#endif
- return cmp;
+ return strcmp(itmp1->sort_key, itmp2->sort_key);
}
-/* $Id: icu_I18N.h,v 1.3 2007-05-01 13:16:09 marc Exp $
+/* $Id: icu_I18N.h,v 1.4 2007-05-02 14:01:36 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
struct icu_termmap
{
- size_t sort_len; // needed, because
- char * sort_key; // no guarantee on '\0' termination ???
+ char * sort_key; // standard C string '\0' terminated
char * norm_term; // standard C utf-8 string
char * disp_term; // standard C utf-8 string
};
-/* $Id: test_icu_I18N.c,v 1.6 2007-05-01 13:27:32 marc Exp $
+/* $Id: test_icu_I18N.c,v 1.7 2007-05-02 14:01:36 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
//dest8_list[i]->sort_key = nmem_strdup(nmem, src8_list[i]);
//dest8_list[i]->sort_len = strlen(src8_list[i]);
dest8_list[i]->sort_key
- = icu_sortmap(nmem, buf, buf_cap, &(dest8_list[i]->sort_len),
- src8_list[i], locale);
+ = icu_sortmap(nmem, buf, buf_cap, 0, src8_list[i], locale);
+ // = icu_sortmap(nmem, buf, buf_cap, &(dest8_list[i]->sort_len),
+ // src8_list[i], locale);
}
// do the sorting
}
}
- if (!sucess)
- for (i = 0; i < list_len; i++){
- printf("icu_sortmap '%s': '%s' '%s'\n", locale,
- dest8_list[i]->disp_term, check8_list[i]);
- }
-
+ if (1 || !sucess){
+ printf("\n");
+ printf("Input '%s':", locale);
+ for (i = 0; i < list_len; i++)
+ printf(" '%s'", src8_list[i]);
+ printf("\n");
+ printf("ICU sort '%s':", locale);
+ for (i = 0; i < list_len; i++)
+ printf(" '%s'", dest8_list[i]->disp_term);
+ if (sucess)
+ printf(" OK");
+ else
+ printf(" ERROR ??");
+ printf("\n");
+ printf("Expected '%s':", locale);
+ for (i = 0; i < list_len; i++)
+ printf(" '%s'", check8_list[i]);
+ printf("\n");
+ }
+
nmem_destroy(nmem);
return sucess;