This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Bugs in ld-collate.c?
- To: drepper at cygnus dot com (Ulrich Drepper)
- Subject: Re: Bugs in ld-collate.c?
- From: Isamu Hasegawa <isamu at yamato dot ibm dot com>
- Date: Fri, 10 Aug 2001 10:26:47 +0900
- Cc: libc-alpha at sourceware dot cygnus dot com, shoji at jp dot ibm dot com
- References: <u3d71r0wh.wl@YMTISAMU-H.yamato.ibm.com><m3hevh423s.fsf@otr.mynet>
Ulrich Drepper <drepper@redhat.com> wrote:
> Isamu Hasegawa <isamu@yamato.ibm.com> writes:
>
> > In locale/programs/ld-collate.c, line.2459...2502:
>
> Test case?
I'm sorry for insufficient report.
Attached program is a test case.
da_DK has at least 4 collating elements, AA, Aa, aA, and aa.
But the test program found no collating element.
And after applied my previous patch (and regenerating da_DK.* locales),
the test program found 4 collating elements.
In addition, da_DK.UTF-8 returns the same results.
Thanks,
--
Isamu Hasegawa
IBM Japan, Ltd.
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <locale/localeinfo.h>
int main()
{
int32_t table_size, idx, i, found;
const int32_t *symb_table;
const unsigned char *extra;
uint32_t nrules;
char *ca;
ca = setlocale(LC_ALL, "da_DK.ISO-8859-1");
printf("current locale : %s\n", ca);
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
if (nrules == 0)
{
printf("No rule\n");
return 1;
}
table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
symb_table = (const int32_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
extra = (const unsigned char *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
found = 0;
for (i = 0; i < table_size; i++)
{
if (symb_table[2 * i] != 0)
{
char elem[256];
idx = symb_table[2 * i + 1];
strncpy (elem, extra + idx + 1, extra[idx]);
elem[extra[idx]] = '\0';
printf ("Found a collating element: %s\n", elem);
found++;
}
}
if (found == 0)
{
printf ("No collating element!\n");
return 1;
}
return 0;
}