31#define ALLOC(size) palloc(size)
32#define FREE(size) pfree(size)
34#define ALLOC(size) malloc(size)
35#define FREE(size) free(size)
46#define NCOUNT VCOUNT * TCOUNT
47#define SCOUNT LCOUNT * NCOUNT
52conv_compare(
const void *p1,
const void *p2)
59 return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
84 h = decompinfo.
hash(&hashkey);
100 return bsearch(&(code),
133static const char32_t *
178 sindex = code -
SBASE;
201 for (
i = 0;
i < dec_size;
i++)
243 *result =
start + tindex;
270 h = recompinfo.
hash(&hashkey);
340 char32_t *res = *result;
342 sindex = code -
SBASE;
354 res[*current] =
TBASE + tindex;
372 char32_t *res = *result;
374 res[*current] = code;
383 for (
i = 0;
i < dec_size;
i++)
406 char32_t *decomp_chars;
407 char32_t *recomp_chars;
425 for (p =
input; *p; p++)
428 decomp_chars = (
char32_t *)
ALLOC((decomp_size + 1) *
sizeof(
char32_t));
429 if (decomp_chars == NULL)
437 for (p =
input; *p; p++)
439 decomp_chars[decomp_size] =
'\0';
443 if (decomp_size == 0)
449 for (count = 1; count < decomp_size; count++)
451 char32_t prev = decomp_chars[count - 1];
452 char32_t next = decomp_chars[count];
465 if (prevClass == 0 || nextClass == 0)
468 if (prevClass <= nextClass)
472 tmp = decomp_chars[count - 1];
473 decomp_chars[count - 1] = decomp_chars[count];
474 decomp_chars[count] = tmp;
490 recomp_chars = (
char32_t *)
ALLOC((decomp_size + 1) *
sizeof(
char32_t));
500 starter_ch = recomp_chars[0] = decomp_chars[0];
502 for (count = 1; count < decomp_size; count++)
504 char32_t ch = decomp_chars[count];
508 if (last_class < ch_class &&
511 recomp_chars[starter_pos] = composite;
512 starter_ch = composite;
514 else if (ch_class == 0)
516 starter_pos = target_pos;
519 recomp_chars[target_pos++] = ch;
523 last_class = ch_class;
524 recomp_chars[target_pos++] = ch;
527 recomp_chars[target_pos] = (
char32_t)
'\0';
553 h = norminfo->
hash(&hashkey);
600 uint8 lastCanonicalClass = 0;
613 for (
const char32_t *p =
input; *p; p++)
616 uint8 canonicalClass;
620 if (lastCanonicalClass > canonicalClass && canonicalClass != 0)
629 lastCanonicalClass = canonicalClass;
Assert(PointerIsAligned(start, uint64))
static int64 current_size
const pg_unicode_decomposition * decomps
const pg_unicode_normprops * normprops
const uint16 * inverse_lookup
static void decompose_code(char32_t code, bool compat, char32_t **result, int *current)
static uint8 get_canonical_class(char32_t code)
UnicodeNormalizationQC unicode_is_normalized_quickcheck(UnicodeNormalizationForm form, const char32_t *input)
static const pg_unicode_normprops * qc_hash_lookup(char32_t ch, const pg_unicode_norminfo *norminfo)
static const char32_t * get_code_decomposition(const pg_unicode_decomposition *entry, int *dec_size)
char32_t * unicode_normalize(UnicodeNormalizationForm form, const char32_t *input)
static int get_decomposed_size(char32_t code, bool compat)
static UnicodeNormalizationQC qc_is_allowed(UnicodeNormalizationForm form, char32_t ch)
static const pg_unicode_decomposition * get_code_entry(char32_t code)
static bool recompose_code(uint32 start, uint32 code, uint32 *result)
static const pg_unicode_decompinfo UnicodeDecompInfo
static const pg_unicode_recompinfo UnicodeRecompInfo
#define DECOMPOSITION_NO_COMPOSE(x)
static const uint32 UnicodeDecomp_codepoints[5138]
#define DECOMPOSITION_IS_INLINE(x)
static const pg_unicode_decomposition UnicodeDecompMain[6843]
#define DECOMPOSITION_IS_COMPAT(x)
#define DECOMPOSITION_SIZE(x)
static const pg_unicode_norminfo UnicodeNormInfo_NFKC_QC
static const pg_unicode_norminfo UnicodeNormInfo_NFC_QC