Mercurial > hg > octave-nkf > gnulib-hg
changeset 11695:5db59585568b
Define u8_casefold as a wrapper around u8_ct_casefold.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 30 Jun 2009 00:17:58 +0200 |
parents | 4d3cd6359179 |
children | cb572406bb3b |
files | ChangeLog lib/unicase/u-casefold.h lib/unicase/u8-casefold.c modules/unicase/u8-casefold |
diffstat | 4 files changed, 15 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-06-29 Bruno Haible <bruno@clisp.org> + Define u8_casefold as a wrapper around u8_ct_casefold. + * lib/unicase/u-casefold.h (FUNC): Delegate to U_CT_CASEFOLD. + * lib/unicase/u8-casefold.c: Update. + * modules/unicase/u8-casefold (Depends-on): Add unicase/u8-ct-casefold, + unicase/empty-prefix-context, unicase/empty-suffix-context. Clean up. + Define u32_totitle as a wrapper around u32_ct_totitle. * lib/unicase/u32-totitle.c: Update. * modules/unicase/u32-totitle (Depends-on): Add unicase/u32-ct-totitle,
--- a/lib/unicase/u-casefold.h +++ b/lib/unicase/u-casefold.h @@ -20,84 +20,9 @@ uninorm_t nf, UNIT *resultbuf, size_t *lengthp) { - /* Implement the three definitions of caseless matching, as described in - Unicode 5.0, section "Default caseless matching": - - If no normalization is requested, simply apply the casefolding. - X -> toCasefold(X). - - If canonical normalization is requested, apply it, and apply an NFD - before. - X -> NFD(toCasefold(NFD(X))). - - If compatibility normalization is requested, apply it twice, apply - the normalization after each, and apply an NFD before: - X -> NFKD(toCasefold(NFKD(toCasefold(NFD(X))))). */ - if (nf == NULL) - /* X -> toCasefold(X) */ - return U_CASEMAP (s, n, iso639_language, - uc_tocasefold, offsetof (struct special_casing_rule, casefold[0]), - NULL, - resultbuf, lengthp); - else - { - uninorm_t nfd = uninorm_decomposing_form (nf); - /* X -> nf(toCasefold(NFD(X))) or - X -> nf(toCasefold(nfd(toCasefold(NFD(X))))) */ - int repeat = (uninorm_is_compat_decomposing (nf) ? 2 : 1); - UNIT tmpbuf1[2048 / sizeof (UNIT)]; - UNIT tmpbuf2[2048 / sizeof (UNIT)]; - UNIT *tmp1; - size_t tmp1_length; - UNIT *tmp2; - size_t tmp2_length; - - tmp1_length = sizeof (tmpbuf1) / sizeof (UNIT); - tmp1 = U_NORMALIZE (UNINORM_NFD, s, n, tmpbuf1, &tmp1_length); - if (tmp1 == NULL) - /* errno is set here. */ - return NULL; - - do - { - tmp2_length = sizeof (tmpbuf2) / sizeof (UNIT); - tmp2 = U_CASEMAP (tmp1, tmp1_length, iso639_language, - uc_tocasefold, offsetof (struct special_casing_rule, casefold[0]), - NULL, - tmpbuf2, &tmp2_length); - if (tmp2 == NULL) - { - int saved_errno = errno; - if (tmp1 != tmpbuf1) - free (tmp1); - errno = saved_errno; - return NULL; - } - - if (tmp1 != tmpbuf1) - free (tmp1); - - if (repeat > 1) - { - tmp1_length = sizeof (tmpbuf1) / sizeof (UNIT); - tmp1 = U_NORMALIZE (nfd, tmp2, tmp2_length, - tmpbuf1, &tmp1_length); - } - else - /* Last run through this loop. */ - tmp1 = U_NORMALIZE (nf, tmp2, tmp2_length, - resultbuf, lengthp); - if (tmp1 == NULL) - { - int saved_errno = errno; - if (tmp2 != tmpbuf2) - free (tmp2); - errno = saved_errno; - return NULL; - } - - if (tmp2 != tmpbuf2) - free (tmp2); - } - while (--repeat > 0); - - return tmp1; - } + return U_CT_CASEFOLD (s, n, + unicase_empty_prefix_context, unicase_empty_suffix_context, + iso639_language, + nf, + resultbuf, lengthp); }
--- a/lib/unicase/u8-casefold.c +++ b/lib/unicase/u8-casefold.c @@ -20,18 +20,9 @@ /* Specification. */ #include "unicase.h" -#include <errno.h> -#include <stddef.h> -#include <stdlib.h> - -#include "unicasemap.h" -#include "special-casing.h" -#include "casefold.h" - #define FUNC u8_casefold #define UNIT uint8_t -#define U_CASEMAP u8_casemap -#define U_NORMALIZE u8_normalize +#define U_CT_CASEFOLD u8_ct_casefold #include "u-casefold.h"
--- a/modules/unicase/u8-casefold +++ b/modules/unicase/u8-casefold @@ -7,12 +7,9 @@ Depends-on: unicase/base -unicase/u8-casemap -unicase/special-casing -unicase/tocasefold -uninorm/decomposing-form -uninorm/u8-normalize -uninorm/nfd +unicase/u8-ct-casefold +unicase/empty-prefix-context +unicase/empty-suffix-context configure.ac: