summaryrefslogtreecommitdiff
path: root/lib/unicase
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicase')
-rw-r--r--lib/unicase/cased.c4
-rw-r--r--lib/unicase/ignorable.c12
-rw-r--r--lib/unicase/invariant.h30
-rw-r--r--lib/unicase/locale-language.c4
-rw-r--r--lib/unicase/simple-mapping.h20
-rw-r--r--lib/unicase/u-casecmp.h10
-rw-r--r--lib/unicase/u-casecoll.h12
-rw-r--r--lib/unicase/u-casefold.h8
-rw-r--r--lib/unicase/u-casemap.h628
-rw-r--r--lib/unicase/u-casexfrm.h38
-rw-r--r--lib/unicase/u-ct-casefold.h88
-rw-r--r--lib/unicase/u-ct-totitle.h738
-rw-r--r--lib/unicase/u-is-cased.h38
-rw-r--r--lib/unicase/u-is-invariant.h18
-rw-r--r--lib/unicase/u-prefix-context.h32
-rw-r--r--lib/unicase/u-suffix-context.h48
-rw-r--r--lib/unicase/u-totitle.h8
-rw-r--r--lib/unicase/u16-ct-tolower.c16
-rw-r--r--lib/unicase/u16-ct-toupper.c16
-rw-r--r--lib/unicase/u16-is-casefolded.c2
-rw-r--r--lib/unicase/u16-is-lowercase.c2
-rw-r--r--lib/unicase/u16-is-titlecase.c2
-rw-r--r--lib/unicase/u16-is-uppercase.c2
-rw-r--r--lib/unicase/u16-tolower.c14
-rw-r--r--lib/unicase/u16-toupper.c14
-rw-r--r--lib/unicase/u32-ct-tolower.c16
-rw-r--r--lib/unicase/u32-ct-toupper.c16
-rw-r--r--lib/unicase/u32-is-casefolded.c2
-rw-r--r--lib/unicase/u32-is-lowercase.c2
-rw-r--r--lib/unicase/u32-is-titlecase.c2
-rw-r--r--lib/unicase/u32-is-uppercase.c2
-rw-r--r--lib/unicase/u32-tolower.c14
-rw-r--r--lib/unicase/u32-toupper.c14
-rw-r--r--lib/unicase/u8-casefold.c44
-rw-r--r--lib/unicase/u8-ct-tolower.c16
-rw-r--r--lib/unicase/u8-ct-toupper.c16
-rw-r--r--lib/unicase/u8-is-casefolded.c2
-rw-r--r--lib/unicase/u8-is-lowercase.c2
-rw-r--r--lib/unicase/u8-is-titlecase.c2
-rw-r--r--lib/unicase/u8-is-uppercase.c2
-rw-r--r--lib/unicase/u8-tolower.c58
-rw-r--r--lib/unicase/u8-totitle.c44
-rw-r--r--lib/unicase/u8-toupper.c58
-rw-r--r--lib/unicase/ulc-casecmp.c18
-rw-r--r--lib/unicase/ulc-casexfrm.c18
-rw-r--r--lib/unicase/unicasemap.h42
46 files changed, 1097 insertions, 1097 deletions
diff --git a/lib/unicase/cased.c b/lib/unicase/cased.c
index 5fbf4cb745..13b88e454e 100644
--- a/lib/unicase/cased.c
+++ b/lib/unicase/cased.c
@@ -33,8 +33,8 @@ bool
uc_is_cased (ucs4_t uc)
{
return (uc_is_property_lowercase (uc)
- || uc_is_property_uppercase (uc)
- || uc_is_general_category (uc, UC_TITLECASE_LETTER));
+ || uc_is_property_uppercase (uc)
+ || uc_is_general_category (uc, UC_TITLECASE_LETTER));
}
#else
diff --git a/lib/unicase/ignorable.c b/lib/unicase/ignorable.c
index 84b2634ccb..9721046a50 100644
--- a/lib/unicase/ignorable.c
+++ b/lib/unicase/ignorable.c
@@ -47,12 +47,12 @@ uc_is_case_ignorable (ucs4_t uc)
int wbp = uc_wordbreak_property (uc);
return (wbp == WBP_MIDLETTER || wbp == WBP_MIDNUMLET
- || uc_is_general_category_withtable (uc, UC_CATEGORY_MASK_Mn
- | UC_CATEGORY_MASK_Me
- | UC_CATEGORY_MASK_Cf
- | UC_CATEGORY_MASK_Lm
- | UC_CATEGORY_MASK_Sk))
- && !uc_is_cased (uc);
+ || uc_is_general_category_withtable (uc, UC_CATEGORY_MASK_Mn
+ | UC_CATEGORY_MASK_Me
+ | UC_CATEGORY_MASK_Cf
+ | UC_CATEGORY_MASK_Lm
+ | UC_CATEGORY_MASK_Sk))
+ && !uc_is_cased (uc);
}
#else
diff --git a/lib/unicase/invariant.h b/lib/unicase/invariant.h
index 201514333e..170358ef6d 100644
--- a/lib/unicase/invariant.h
+++ b/lib/unicase/invariant.h
@@ -24,22 +24,22 @@
/* Return true if mapping NFD(S) to via MAPPING is a no-op. */
extern int
u8_is_invariant (const uint8_t *s, size_t n,
- uint8_t * (*mapping) (const uint8_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp),
- const char *iso639_language,
- bool *resultp);
+ uint8_t * (*mapping) (const uint8_t *s, size_t n, const char *iso639_language,
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp),
+ const char *iso639_language,
+ bool *resultp);
extern int
u16_is_invariant (const uint16_t *s, size_t n,
- uint16_t * (*mapping) (const uint16_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp),
- const char *iso639_language,
- bool *resultp);
+ uint16_t * (*mapping) (const uint16_t *s, size_t n, const char *iso639_language,
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp),
+ const char *iso639_language,
+ bool *resultp);
extern int
u32_is_invariant (const uint32_t *s, size_t n,
- uint32_t * (*mapping) (const uint32_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp),
- const char *iso639_language,
- bool *resultp);
+ uint32_t * (*mapping) (const uint32_t *s, size_t n, const char *iso639_language,
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp),
+ const char *iso639_language,
+ bool *resultp);
diff --git a/lib/unicase/locale-language.c b/lib/unicase/locale-language.c
index 074baa4106..3b74556933 100644
--- a/lib/unicase/locale-language.c
+++ b/lib/unicase/locale-language.c
@@ -46,9 +46,9 @@ uc_locale_language (void)
if (p != locale_name)
{
const char *language =
- uc_locale_languages_lookup (locale_name, p - locale_name);
+ uc_locale_languages_lookup (locale_name, p - locale_name);
if (language != NULL)
- return language;
+ return language;
}
return "";
diff --git a/lib/unicase/simple-mapping.h b/lib/unicase/simple-mapping.h
index 44cecc81d4..fcd2a4bacd 100644
--- a/lib/unicase/simple-mapping.h
+++ b/lib/unicase/simple-mapping.h
@@ -23,17 +23,17 @@ FUNC (ucs4_t uc)
{
int lookup1 = u_mapping.level1[index1];
if (lookup1 >= 0)
- {
- unsigned int index2 = (uc >> mapping_header_2) & mapping_header_3;
- int lookup2 = u_mapping.level2[lookup1 + index2];
- if (lookup2 >= 0)
- {
- unsigned int index3 = (uc & mapping_header_4);
- int lookup3 = u_mapping.level3[lookup2 + index3];
+ {
+ unsigned int index2 = (uc >> mapping_header_2) & mapping_header_3;
+ int lookup2 = u_mapping.level2[lookup1 + index2];
+ if (lookup2 >= 0)
+ {
+ unsigned int index3 = (uc & mapping_header_4);
+ int lookup3 = u_mapping.level3[lookup2 + index3];
- return uc + lookup3;
- }
- }
+ return uc + lookup3;
+ }
+ }
}
return uc;
}
diff --git a/lib/unicase/u-casecmp.h b/lib/unicase/u-casecmp.h
index e1cf99c467..c152063c80 100644
--- a/lib/unicase/u-casecmp.h
+++ b/lib/unicase/u-casecmp.h
@@ -45,11 +45,11 @@ FUNC (const SRC_UNIT *s1, size_t n1, const SRC_UNIT *s2, size_t n2,
if (norms2 == NULL)
{
if (norms1 != buf1)
- {
- int saved_errno = errno;
- free (norms1);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (norms1);
+ errno = saved_errno;
+ }
return -1;
}
diff --git a/lib/unicase/u-casecoll.h b/lib/unicase/u-casecoll.h
index 73094abe87..a2cd5ec638 100644
--- a/lib/unicase/u-casecoll.h
+++ b/lib/unicase/u-casecoll.h
@@ -43,17 +43,17 @@ FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2,
if (transformed2 == NULL)
{
if (transformed1 != buf1)
- {
- int saved_errno = errno;
- free (transformed1);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (transformed1);
+ errno = saved_errno;
+ }
return -1;
}
/* Compare the transformed strings. */
cmp = memcmp2 (transformed1, transformed1_length,
- transformed2, transformed2_length);
+ transformed2, transformed2_length);
if (cmp < 0)
cmp = -1;
else if (cmp > 0)
diff --git a/lib/unicase/u-casefold.h b/lib/unicase/u-casefold.h
index c41f4e1827..0124509e62 100644
--- a/lib/unicase/u-casefold.h
+++ b/lib/unicase/u-casefold.h
@@ -21,8 +21,8 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language,
UNIT *resultbuf, size_t *lengthp)
{
return U_CT_CASEFOLD (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u-casemap.h b/lib/unicase/u-casemap.h
index ea41444a1f..bbcfd27a9f 100644
--- a/lib/unicase/u-casemap.h
+++ b/lib/unicase/u-casemap.h
@@ -58,311 +58,311 @@ FUNC (const UNIT *s, size_t n,
while (s < s_end)
{
- ucs4_t uc;
- int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
-
- ucs4_t mapped_uc[3];
- unsigned int mapped_count;
-
- if (uc < 0x10000)
- {
- /* Look first in the special-casing table. */
- char code[3];
-
- code[0] = (uc >> 8) & 0xff;
- code[1] = uc & 0xff;
-
- for (code[2] = 0; ; code[2]++)
- {
- const struct special_casing_rule *rule =
- gl_unicase_special_lookup (code, 3);
-
- if (rule == NULL)
- break;
-
- /* Test if the condition applies. */
- /* Does the language apply? */
- if (rule->language[0] == '\0'
- || (iso639_language != NULL
- && iso639_language[0] == rule->language[0]
- && iso639_language[1] == rule->language[1]))
- {
- /* Does the context apply? */
- int context = rule->context;
- bool applies;
-
- if (context < 0)
- context = - context;
- switch (context)
- {
- case SCC_ALWAYS:
- applies = true;
- break;
-
- case SCC_FINAL_SIGMA:
- /* "Before" condition: preceded by a sequence
- consisting of a cased letter and a case-ignorable
- sequence.
- "After" condition: not followed by a sequence
- consisting of a case-ignorable sequence and then a
- cased letter. */
- /* Test the "before" condition. */
- applies = uc_is_cased (last_char_except_ignorable);
- /* Test the "after" condition. */
- if (applies)
- {
- const UNIT *s2 = s + count;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- /* Our uc_is_case_ignorable function is
- known to return false for all cased
- characters. So we can call
- uc_is_case_ignorable first. */
- if (!uc_is_case_ignorable (uc2))
- {
- applies = ! uc_is_cased (uc2);
- break;
- }
- s2 += count2;
- }
- else
- {
- applies = ! uc_is_cased (suffix_context.first_char_except_ignorable);
- break;
- }
- }
- }
- break;
-
- case SCC_AFTER_SOFT_DOTTED:
- /* "Before" condition: There is a Soft_Dotted character
- before it, with no intervening character of
- combining class 0 or 230 (Above). */
- /* Test the "before" condition. */
- applies = uc_is_property_soft_dotted (last_char_normal_or_above);
- break;
-
- case SCC_MORE_ABOVE:
- /* "After" condition: followed by a character of
- combining class 230 (Above) with no intervening
- character of combining class 0 or 230 (Above). */
- /* Test the "after" condition. */
- {
- const UNIT *s2 = s + count;
- applies = false;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- int ccc = uc_combining_class (uc2);
- if (ccc == UC_CCC_A)
- {
- applies = true;
- break;
- }
- if (ccc == UC_CCC_NR)
- break;
- s2 += count2;
- }
- else
- {
- applies = ((suffix_context.bits & SCC_MORE_ABOVE_MASK) != 0);
- break;
- }
- }
- }
- break;
-
- case SCC_BEFORE_DOT:
- /* "After" condition: followed by COMBINING DOT ABOVE
- (U+0307). Any sequence of characters with a
- combining class that is neither 0 nor 230 may
- intervene between the current character and the
- combining dot above. */
- /* Test the "after" condition. */
- {
- const UNIT *s2 = s + count;
- applies = false;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- if (uc2 == 0x0307) /* COMBINING DOT ABOVE */
- {
- applies = true;
- break;
- }
- {
- int ccc = uc_combining_class (uc2);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- break;
- }
- s2 += count2;
- }
- else
- {
- applies = ((suffix_context.bits & SCC_BEFORE_DOT_MASK) != 0);
- break;
- }
- }
- }
- break;
-
- case SCC_AFTER_I:
- /* "Before" condition: There is an uppercase I before
- it, and there is no intervening character of
- combining class 0 or 230 (Above). */
- /* Test the "before" condition. */
- applies = (last_char_normal_or_above == 'I');
- break;
-
- default:
- abort ();
- }
- if (rule->context < 0)
- applies = !applies;
-
- if (applies)
- {
- /* The rule applies.
- Look up the mapping (0 to 3 characters). */
- const unsigned short *mapped_in_rule =
- (const unsigned short *)((const char *)rule + offset_in_rule);
-
- if (mapped_in_rule[0] == 0)
- mapped_count = 0;
- else
- {
- mapped_uc[0] = mapped_in_rule[0];
- if (mapped_in_rule[1] == 0)
- mapped_count = 1;
- else
- {
- mapped_uc[1] = mapped_in_rule[1];
- if (mapped_in_rule[2] == 0)
- mapped_count = 2;
- else
- {
- mapped_uc[2] = mapped_in_rule[2];
- mapped_count = 3;
- }
- }
- }
- goto found_mapping;
- }
- }
-
- /* Optimization: Save a hash table lookup in the next round. */
- if (!rule->has_next)
- break;
- }
- }
-
- /* No special-cased mapping. So use the locale and context independent
- mapping. */
- mapped_uc[0] = single_character_map (uc);
- mapped_count = 1;
+ ucs4_t uc;
+ int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
+
+ ucs4_t mapped_uc[3];
+ unsigned int mapped_count;
+
+ if (uc < 0x10000)
+ {
+ /* Look first in the special-casing table. */
+ char code[3];
+
+ code[0] = (uc >> 8) & 0xff;
+ code[1] = uc & 0xff;
+
+ for (code[2] = 0; ; code[2]++)
+ {
+ const struct special_casing_rule *rule =
+ gl_unicase_special_lookup (code, 3);
+
+ if (rule == NULL)
+ break;
+
+ /* Test if the condition applies. */
+ /* Does the language apply? */
+ if (rule->language[0] == '\0'
+ || (iso639_language != NULL
+ && iso639_language[0] == rule->language[0]
+ && iso639_language[1] == rule->language[1]))
+ {
+ /* Does the context apply? */
+ int context = rule->context;
+ bool applies;
+
+ if (context < 0)
+ context = - context;
+ switch (context)
+ {
+ case SCC_ALWAYS:
+ applies = true;
+ break;
+
+ case SCC_FINAL_SIGMA:
+ /* "Before" condition: preceded by a sequence
+ consisting of a cased letter and a case-ignorable
+ sequence.
+ "After" condition: not followed by a sequence
+ consisting of a case-ignorable sequence and then a
+ cased letter. */
+ /* Test the "before" condition. */
+ applies = uc_is_cased (last_char_except_ignorable);
+ /* Test the "after" condition. */
+ if (applies)
+ {
+ const UNIT *s2 = s + count;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ /* Our uc_is_case_ignorable function is
+ known to return false for all cased
+ characters. So we can call
+ uc_is_case_ignorable first. */
+ if (!uc_is_case_ignorable (uc2))
+ {
+ applies = ! uc_is_cased (uc2);
+ break;
+ }
+ s2 += count2;
+ }
+ else
+ {
+ applies = ! uc_is_cased (suffix_context.first_char_except_ignorable);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_AFTER_SOFT_DOTTED:
+ /* "Before" condition: There is a Soft_Dotted character
+ before it, with no intervening character of
+ combining class 0 or 230 (Above). */
+ /* Test the "before" condition. */
+ applies = uc_is_property_soft_dotted (last_char_normal_or_above);
+ break;
+
+ case SCC_MORE_ABOVE:
+ /* "After" condition: followed by a character of
+ combining class 230 (Above) with no intervening
+ character of combining class 0 or 230 (Above). */
+ /* Test the "after" condition. */
+ {
+ const UNIT *s2 = s + count;
+ applies = false;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ int ccc = uc_combining_class (uc2);
+ if (ccc == UC_CCC_A)
+ {
+ applies = true;
+ break;
+ }
+ if (ccc == UC_CCC_NR)
+ break;
+ s2 += count2;
+ }
+ else
+ {
+ applies = ((suffix_context.bits & SCC_MORE_ABOVE_MASK) != 0);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_BEFORE_DOT:
+ /* "After" condition: followed by COMBINING DOT ABOVE
+ (U+0307). Any sequence of characters with a
+ combining class that is neither 0 nor 230 may
+ intervene between the current character and the
+ combining dot above. */
+ /* Test the "after" condition. */
+ {
+ const UNIT *s2 = s + count;
+ applies = false;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ if (uc2 == 0x0307) /* COMBINING DOT ABOVE */
+ {
+ applies = true;
+ break;
+ }
+ {
+ int ccc = uc_combining_class (uc2);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ break;
+ }
+ s2 += count2;
+ }
+ else
+ {
+ applies = ((suffix_context.bits & SCC_BEFORE_DOT_MASK) != 0);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_AFTER_I:
+ /* "Before" condition: There is an uppercase I before
+ it, and there is no intervening character of
+ combining class 0 or 230 (Above). */
+ /* Test the "before" condition. */
+ applies = (last_char_normal_or_above == 'I');
+ break;
+
+ default:
+ abort ();
+ }
+ if (rule->context < 0)
+ applies = !applies;
+
+ if (applies)
+ {
+ /* The rule applies.
+ Look up the mapping (0 to 3 characters). */
+ const unsigned short *mapped_in_rule =
+ (const unsigned short *)((const char *)rule + offset_in_rule);
+
+ if (mapped_in_rule[0] == 0)
+ mapped_count = 0;
+ else
+ {
+ mapped_uc[0] = mapped_in_rule[0];
+ if (mapped_in_rule[1] == 0)
+ mapped_count = 1;
+ else
+ {
+ mapped_uc[1] = mapped_in_rule[1];
+ if (mapped_in_rule[2] == 0)
+ mapped_count = 2;
+ else
+ {
+ mapped_uc[2] = mapped_in_rule[2];
+ mapped_count = 3;
+ }
+ }
+ }
+ goto found_mapping;
+ }
+ }
+
+ /* Optimization: Save a hash table lookup in the next round. */
+ if (!rule->has_next)
+ break;
+ }
+ }
+
+ /* No special-cased mapping. So use the locale and context independent
+ mapping. */
+ mapped_uc[0] = single_character_map (uc);
+ mapped_count = 1;
found_mapping:
- /* Found the mapping: uc maps to mapped_uc[0..mapped_count-1]. */
- {
- unsigned int i;
-
- for (i = 0; i < mapped_count; i++)
- {
- ucs4_t muc = mapped_uc[i];
-
- /* Append muc to the result accumulator. */
- if (length < allocated)
- {
- int ret = U_UCTOMB (result + length, muc, allocated - length);
- if (ret == -1)
- {
- errno = EINVAL;
- goto fail;
- }
- if (ret >= 0)
- {
- length += ret;
- goto done_appending;
- }
- }
- {
- size_t old_allocated = allocated;
- size_t new_allocated = 2 * old_allocated;
- if (new_allocated < 64)
- new_allocated = 64;
- if (new_allocated < old_allocated) /* integer overflow? */
- abort ();
- {
- UNIT *larger_result;
- if (result == NULL)
- {
- larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail;
- }
- }
- else if (result == resultbuf)
- {
- larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail;
- }
- U_CPY (larger_result, resultbuf, length);
- }
- else
- {
- larger_result =
- (UNIT *) realloc (result, new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail;
- }
- }
- result = larger_result;
- allocated = new_allocated;
- {
- int ret = U_UCTOMB (result + length, muc, allocated - length);
- if (ret == -1)
- {
- errno = EINVAL;
- goto fail;
- }
- if (ret < 0)
- abort ();
- length += ret;
- goto done_appending;
- }
- }
- }
- done_appending: ;
- }
- }
-
- if (!uc_is_case_ignorable (uc))
- last_char_except_ignorable = uc;
-
- {
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- last_char_normal_or_above = uc;
- }
-
- s += count;
+ /* Found the mapping: uc maps to mapped_uc[0..mapped_count-1]. */
+ {
+ unsigned int i;
+
+ for (i = 0; i < mapped_count; i++)
+ {
+ ucs4_t muc = mapped_uc[i];
+
+ /* Append muc to the result accumulator. */
+ if (length < allocated)
+ {
+ int ret = U_UCTOMB (result + length, muc, allocated - length);
+ if (ret == -1)
+ {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (ret >= 0)
+ {
+ length += ret;
+ goto done_appending;
+ }
+ }
+ {
+ size_t old_allocated = allocated;
+ size_t new_allocated = 2 * old_allocated;
+ if (new_allocated < 64)
+ new_allocated = 64;
+ if (new_allocated < old_allocated) /* integer overflow? */
+ abort ();
+ {
+ UNIT *larger_result;
+ if (result == NULL)
+ {
+ larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail;
+ }
+ }
+ else if (result == resultbuf)
+ {
+ larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail;
+ }
+ U_CPY (larger_result, resultbuf, length);
+ }
+ else
+ {
+ larger_result =
+ (UNIT *) realloc (result, new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail;
+ }
+ }
+ result = larger_result;
+ allocated = new_allocated;
+ {
+ int ret = U_UCTOMB (result + length, muc, allocated - length);
+ if (ret == -1)
+ {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (ret < 0)
+ abort ();
+ length += ret;
+ goto done_appending;
+ }
+ }
+ }
+ done_appending: ;
+ }
+ }
+
+ if (!uc_is_case_ignorable (uc))
+ last_char_except_ignorable = uc;
+
+ {
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ last_char_normal_or_above = uc;
+ }
+
+ s += count;
}
}
@@ -373,7 +373,7 @@ FUNC (const UNIT *s, size_t n,
normalized_result = U_NORMALIZE (nf, result, length, resultbuf, lengthp);
if (normalized_result == NULL)
- goto fail;
+ goto fail;
free (result);
return normalized_result;
@@ -382,15 +382,15 @@ FUNC (const UNIT *s, size_t n,
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- goto fail;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -399,7 +399,7 @@ FUNC (const UNIT *s, size_t n,
memory = (UNIT *) realloc (result, length * sizeof (UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unicase/u-casexfrm.h b/lib/unicase/u-casexfrm.h
index e36aff3b9e..abb34d6387 100644
--- a/lib/unicase/u-casexfrm.h
+++ b/lib/unicase/u-casexfrm.h
@@ -38,18 +38,18 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language, uninorm_t nf,
/* Convert it to locale encoding. */
convs_length = sizeof (convsbuf) - 1;
convs = U_CONV_TO_ENCODING (locale_charset (),
- iconveh_error,
- foldeds, foldeds_length,
- NULL,
- convsbuf, &convs_length);
+ iconveh_error,
+ foldeds, foldeds_length,
+ NULL,
+ convsbuf, &convs_length);
if (convs == NULL)
{
if (foldeds != foldedsbuf)
- {
- int saved_errno = errno;
- free (foldeds);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (foldeds);
+ errno = saved_errno;
+ }
return NULL;
}
@@ -61,11 +61,11 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language, uninorm_t nf,
{
char *memory = (char *) realloc (convs, convs_length + 1);
if (memory == NULL)
- {
- free (convs);
- errno = ENOMEM;
- return NULL;
- }
+ {
+ free (convs);
+ errno = ENOMEM;
+ return NULL;
+ }
convs = memory;
}
@@ -74,11 +74,11 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language, uninorm_t nf,
if (result == NULL)
{
if (convs != convsbuf)
- {
- int saved_errno = errno;
- free (convs);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (convs);
+ errno = saved_errno;
+ }
return NULL;
}
diff --git a/lib/unicase/u-ct-casefold.h b/lib/unicase/u-ct-casefold.h
index d97be264be..1f4a18c829 100644
--- a/lib/unicase/u-ct-casefold.h
+++ b/lib/unicase/u-ct-casefold.h
@@ -36,14 +36,14 @@ FUNC (const UNIT *s, size_t n,
if (nf == NULL)
/* X -> toCasefold(X) */
return U_CASEMAP (s, n, prefix_context, suffix_context, iso639_language,
- uc_tocasefold, offsetof (struct special_casing_rule, casefold[0]),
- NULL,
- resultbuf, lengthp);
+ 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))))) */
+ 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)];
@@ -55,51 +55,51 @@ FUNC (const UNIT *s, size_t n,
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;
+ /* errno is set here. */
+ return NULL;
do
- {
- tmp2_length = sizeof (tmpbuf2) / sizeof (UNIT);
- tmp2 = U_CASEMAP (tmp1, tmp1_length,
- prefix_context, suffix_context, 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;
- }
+ {
+ tmp2_length = sizeof (tmpbuf2) / sizeof (UNIT);
+ tmp2 = U_CASEMAP (tmp1, tmp1_length,
+ prefix_context, suffix_context, 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 (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 (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);
- }
+ if (tmp2 != tmpbuf2)
+ free (tmp2);
+ }
while (--repeat > 0);
return tmp1;
diff --git a/lib/unicase/u-ct-totitle.h b/lib/unicase/u-ct-totitle.h
index f0d4fd7736..b09dcfc6f3 100644
--- a/lib/unicase/u-ct-totitle.h
+++ b/lib/unicase/u-ct-totitle.h
@@ -55,10 +55,10 @@ FUNC (const UNIT *s, size_t n,
{
wordbreaks = (char *) malloc (n);
if (wordbreaks == NULL)
- {
- errno = ENOMEM;
- goto fail2;
- }
+ {
+ errno = ENOMEM;
+ goto fail2;
+ }
U_WORDBREAKS (s, n, wordbreaks);
}
else
@@ -70,12 +70,12 @@ FUNC (const UNIT *s, size_t n,
/* When considering the string as segmented by word boundaries: For each
such segment:
- - In the first part, we are searching for the first cased character.
- In this state, in_word_first_part = true, and no conversion takes
- place.
- - In the second part, we are converting every character: the first
- among these characters to title case, the other ones to lower case.
- In this state, in_word_first_part = false. */
+ - In the first part, we are searching for the first cased character.
+ In this state, in_word_first_part = true, and no conversion takes
+ place.
+ - In the second part, we are converting every character: the first
+ among these characters to title case, the other ones to lower case.
+ In this state, in_word_first_part = false. */
bool in_word_first_part = true;
/* Helper for evaluating the FINAL_SIGMA condition:
@@ -90,356 +90,356 @@ FUNC (const UNIT *s, size_t n,
while (s < s_end)
{
- /* Fetch the next character. */
- ucs4_t uc;
- int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
-
- ucs4_t (*single_character_map) (ucs4_t);
- size_t offset_in_rule; /* offset in 'struct special_casing_rule' */
-
- ucs4_t mapped_uc[3];
- unsigned int mapped_count;
-
- if (*wp)
- /* Crossing a word boundary. */
- in_word_first_part = true;
-
- /* Determine single_character_map, offset_in_rule.
- There are three possibilities:
- - uc should not be converted.
- - uc should be titlecased.
- - uc should be lowercased. */
- if (in_word_first_part)
- {
- if (uc_is_cased (uc))
- {
- /* uc is to be titlecased. */
- single_character_map = uc_totitle;
- offset_in_rule = offsetof (struct special_casing_rule, title[0]);
- in_word_first_part = false;
- }
- else
- {
- /* uc is not converted. */
- single_character_map = NULL;
- offset_in_rule = 0;
- }
- }
- else
- {
- /* uc is to be lowercased. */
- single_character_map = uc_tolower;
- offset_in_rule = offsetof (struct special_casing_rule, lower[0]);
- }
-
- /* Actually map uc. */
- if (single_character_map == NULL)
- {
- mapped_uc[0] = uc;
- mapped_count = 1;
- goto found_mapping;
- }
-
- if (uc < 0x10000)
- {
- /* Look first in the special-casing table. */
- char code[3];
-
- code[0] = (uc >> 8) & 0xff;
- code[1] = uc & 0xff;
-
- for (code[2] = 0; ; code[2]++)
- {
- const struct special_casing_rule *rule =
- gl_unicase_special_lookup (code, 3);
-
- if (rule == NULL)
- break;
-
- /* Test if the condition applies. */
- /* Does the language apply? */
- if (rule->language[0] == '\0'
- || (iso639_language != NULL
- && iso639_language[0] == rule->language[0]
- && iso639_language[1] == rule->language[1]))
- {
- /* Does the context apply? */
- int context = rule->context;
- bool applies;
-
- if (context < 0)
- context = - context;
- switch (context)
- {
- case SCC_ALWAYS:
- applies = true;
- break;
-
- case SCC_FINAL_SIGMA:
- /* "Before" condition: preceded by a sequence
- consisting of a cased letter and a case-ignorable
- sequence.
- "After" condition: not followed by a sequence
- consisting of a case-ignorable sequence and then a
- cased letter. */
- /* Test the "before" condition. */
- applies = uc_is_cased (last_char_except_ignorable);
- /* Test the "after" condition. */
- if (applies)
- {
- const UNIT *s2 = s + count;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- /* Our uc_is_case_ignorable function is
- known to return false for all cased
- characters. So we can call
- uc_is_case_ignorable first. */
- if (!uc_is_case_ignorable (uc2))
- {
- applies = ! uc_is_cased (uc2);
- break;
- }
- s2 += count2;
- }
- else
- {
- applies = ! uc_is_cased (suffix_context.first_char_except_ignorable);
- break;
- }
- }
- }
- break;
-
- case SCC_AFTER_SOFT_DOTTED:
- /* "Before" condition: There is a Soft_Dotted character
- before it, with no intervening character of
- combining class 0 or 230 (Above). */
- /* Test the "before" condition. */
- applies = uc_is_property_soft_dotted (last_char_normal_or_above);
- break;
-
- case SCC_MORE_ABOVE:
- /* "After" condition: followed by a character of
- combining class 230 (Above) with no intervening
- character of combining class 0 or 230 (Above). */
- /* Test the "after" condition. */
- {
- const UNIT *s2 = s + count;
- applies = false;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- int ccc = uc_combining_class (uc2);
- if (ccc == UC_CCC_A)
- {
- applies = true;
- break;
- }
- if (ccc == UC_CCC_NR)
- break;
- s2 += count2;
- }
- else
- {
- applies = ((suffix_context.bits & SCC_MORE_ABOVE_MASK) != 0);
- break;
- }
- }
- }
- break;
-
- case SCC_BEFORE_DOT:
- /* "After" condition: followed by COMBINING DOT ABOVE
- (U+0307). Any sequence of characters with a
- combining class that is neither 0 nor 230 may
- intervene between the current character and the
- combining dot above. */
- /* Test the "after" condition. */
- {
- const UNIT *s2 = s + count;
- applies = false;
- for (;;)
- {
- if (s2 < s_end)
- {
- ucs4_t uc2;
- int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
- if (uc2 == 0x0307) /* COMBINING DOT ABOVE */
- {
- applies = true;
- break;
- }
- {
- int ccc = uc_combining_class (uc2);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- break;
- }
- s2 += count2;
- }
- else
- {
- applies = ((suffix_context.bits & SCC_BEFORE_DOT_MASK) != 0);
- break;
- }
- }
- }
- break;
-
- case SCC_AFTER_I:
- /* "Before" condition: There is an uppercase I before
- it, and there is no intervening character of
- combining class 0 or 230 (Above). */
- /* Test the "before" condition. */
- applies = (last_char_normal_or_above == 'I');
- break;
-
- default:
- abort ();
- }
- if (rule->context < 0)
- applies = !applies;
-
- if (applies)
- {
- /* The rule applies.
- Look up the mapping (0 to 3 characters). */
- const unsigned short *mapped_in_rule =
- (const unsigned short *)((const char *)rule + offset_in_rule);
-
- if (mapped_in_rule[0] == 0)
- mapped_count = 0;
- else
- {
- mapped_uc[0] = mapped_in_rule[0];
- if (mapped_in_rule[1] == 0)
- mapped_count = 1;
- else
- {
- mapped_uc[1] = mapped_in_rule[1];
- if (mapped_in_rule[2] == 0)
- mapped_count = 2;
- else
- {
- mapped_uc[2] = mapped_in_rule[2];
- mapped_count = 3;
- }
- }
- }
- goto found_mapping;
- }
- }
-
- /* Optimization: Save a hash table lookup in the next round. */
- if (!rule->has_next)
- break;
- }
- }
-
- /* No special-cased mapping. So use the locale and context independent
- mapping. */
- mapped_uc[0] = single_character_map (uc);
- mapped_count = 1;
+ /* Fetch the next character. */
+ ucs4_t uc;
+ int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
+
+ ucs4_t (*single_character_map) (ucs4_t);
+ size_t offset_in_rule; /* offset in 'struct special_casing_rule' */
+
+ ucs4_t mapped_uc[3];
+ unsigned int mapped_count;
+
+ if (*wp)
+ /* Crossing a word boundary. */
+ in_word_first_part = true;
+
+ /* Determine single_character_map, offset_in_rule.
+ There are three possibilities:
+ - uc should not be converted.
+ - uc should be titlecased.
+ - uc should be lowercased. */
+ if (in_word_first_part)
+ {
+ if (uc_is_cased (uc))
+ {
+ /* uc is to be titlecased. */
+ single_character_map = uc_totitle;
+ offset_in_rule = offsetof (struct special_casing_rule, title[0]);
+ in_word_first_part = false;
+ }
+ else
+ {
+ /* uc is not converted. */
+ single_character_map = NULL;
+ offset_in_rule = 0;
+ }
+ }
+ else
+ {
+ /* uc is to be lowercased. */
+ single_character_map = uc_tolower;
+ offset_in_rule = offsetof (struct special_casing_rule, lower[0]);
+ }
+
+ /* Actually map uc. */
+ if (single_character_map == NULL)
+ {
+ mapped_uc[0] = uc;
+ mapped_count = 1;
+ goto found_mapping;
+ }
+
+ if (uc < 0x10000)
+ {
+ /* Look first in the special-casing table. */
+ char code[3];
+
+ code[0] = (uc >> 8) & 0xff;
+ code[1] = uc & 0xff;
+
+ for (code[2] = 0; ; code[2]++)
+ {
+ const struct special_casing_rule *rule =
+ gl_unicase_special_lookup (code, 3);
+
+ if (rule == NULL)
+ break;
+
+ /* Test if the condition applies. */
+ /* Does the language apply? */
+ if (rule->language[0] == '\0'
+ || (iso639_language != NULL
+ && iso639_language[0] == rule->language[0]
+ && iso639_language[1] == rule->language[1]))
+ {
+ /* Does the context apply? */
+ int context = rule->context;
+ bool applies;
+
+ if (context < 0)
+ context = - context;
+ switch (context)
+ {
+ case SCC_ALWAYS:
+ applies = true;
+ break;
+
+ case SCC_FINAL_SIGMA:
+ /* "Before" condition: preceded by a sequence
+ consisting of a cased letter and a case-ignorable
+ sequence.
+ "After" condition: not followed by a sequence
+ consisting of a case-ignorable sequence and then a
+ cased letter. */
+ /* Test the "before" condition. */
+ applies = uc_is_cased (last_char_except_ignorable);
+ /* Test the "after" condition. */
+ if (applies)
+ {
+ const UNIT *s2 = s + count;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ /* Our uc_is_case_ignorable function is
+ known to return false for all cased
+ characters. So we can call
+ uc_is_case_ignorable first. */
+ if (!uc_is_case_ignorable (uc2))
+ {
+ applies = ! uc_is_cased (uc2);
+ break;
+ }
+ s2 += count2;
+ }
+ else
+ {
+ applies = ! uc_is_cased (suffix_context.first_char_except_ignorable);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_AFTER_SOFT_DOTTED:
+ /* "Before" condition: There is a Soft_Dotted character
+ before it, with no intervening character of
+ combining class 0 or 230 (Above). */
+ /* Test the "before" condition. */
+ applies = uc_is_property_soft_dotted (last_char_normal_or_above);
+ break;
+
+ case SCC_MORE_ABOVE:
+ /* "After" condition: followed by a character of
+ combining class 230 (Above) with no intervening
+ character of combining class 0 or 230 (Above). */
+ /* Test the "after" condition. */
+ {
+ const UNIT *s2 = s + count;
+ applies = false;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ int ccc = uc_combining_class (uc2);
+ if (ccc == UC_CCC_A)
+ {
+ applies = true;
+ break;
+ }
+ if (ccc == UC_CCC_NR)
+ break;
+ s2 += count2;
+ }
+ else
+ {
+ applies = ((suffix_context.bits & SCC_MORE_ABOVE_MASK) != 0);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_BEFORE_DOT:
+ /* "After" condition: followed by COMBINING DOT ABOVE
+ (U+0307). Any sequence of characters with a
+ combining class that is neither 0 nor 230 may
+ intervene between the current character and the
+ combining dot above. */
+ /* Test the "after" condition. */
+ {
+ const UNIT *s2 = s + count;
+ applies = false;
+ for (;;)
+ {
+ if (s2 < s_end)
+ {
+ ucs4_t uc2;
+ int count2 = U_MBTOUC_UNSAFE (&uc2, s2, s_end - s2);
+ if (uc2 == 0x0307) /* COMBINING DOT ABOVE */
+ {
+ applies = true;
+ break;
+ }
+ {
+ int ccc = uc_combining_class (uc2);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ break;
+ }
+ s2 += count2;
+ }
+ else
+ {
+ applies = ((suffix_context.bits & SCC_BEFORE_DOT_MASK) != 0);
+ break;
+ }
+ }
+ }
+ break;
+
+ case SCC_AFTER_I:
+ /* "Before" condition: There is an uppercase I before
+ it, and there is no intervening character of
+ combining class 0 or 230 (Above). */
+ /* Test the "before" condition. */
+ applies = (last_char_normal_or_above == 'I');
+ break;
+
+ default:
+ abort ();
+ }
+ if (rule->context < 0)
+ applies = !applies;
+
+ if (applies)
+ {
+ /* The rule applies.
+ Look up the mapping (0 to 3 characters). */
+ const unsigned short *mapped_in_rule =
+ (const unsigned short *)((const char *)rule + offset_in_rule);
+
+ if (mapped_in_rule[0] == 0)
+ mapped_count = 0;
+ else
+ {
+ mapped_uc[0] = mapped_in_rule[0];
+ if (mapped_in_rule[1] == 0)
+ mapped_count = 1;
+ else
+ {
+ mapped_uc[1] = mapped_in_rule[1];
+ if (mapped_in_rule[2] == 0)
+ mapped_count = 2;
+ else
+ {
+ mapped_uc[2] = mapped_in_rule[2];
+ mapped_count = 3;
+ }
+ }
+ }
+ goto found_mapping;
+ }
+ }
+
+ /* Optimization: Save a hash table lookup in the next round. */
+ if (!rule->has_next)
+ break;
+ }
+ }
+
+ /* No special-cased mapping. So use the locale and context independent
+ mapping. */
+ mapped_uc[0] = single_character_map (uc);
+ mapped_count = 1;
found_mapping:
- /* Found the mapping: uc maps to mapped_uc[0..mapped_count-1]. */
- {
- unsigned int i;
-
- for (i = 0; i < mapped_count; i++)
- {
- ucs4_t muc = mapped_uc[i];
-
- /* Append muc to the result accumulator. */
- if (length < allocated)
- {
- int ret = U_UCTOMB (result + length, muc, allocated - length);
- if (ret == -1)
- {
- errno = EINVAL;
- goto fail1;
- }
- if (ret >= 0)
- {
- length += ret;
- goto done_appending;
- }
- }
- {
- size_t old_allocated = allocated;
- size_t new_allocated = 2 * old_allocated;
- if (new_allocated < 64)
- new_allocated = 64;
- if (new_allocated < old_allocated) /* integer overflow? */
- abort ();
- {
- UNIT *larger_result;
- if (result == NULL)
- {
- larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail1;
- }
- }
- else if (result == resultbuf)
- {
- larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail1;
- }
- U_CPY (larger_result, resultbuf, length);
- }
- else
- {
- larger_result =
- (UNIT *) realloc (result, new_allocated * sizeof (UNIT));
- if (larger_result == NULL)
- {
- errno = ENOMEM;
- goto fail1;
- }
- }
- result = larger_result;
- allocated = new_allocated;
- {
- int ret = U_UCTOMB (result + length, muc, allocated - length);
- if (ret == -1)
- {
- errno = EINVAL;
- goto fail1;
- }
- if (ret < 0)
- abort ();
- length += ret;
- goto done_appending;
- }
- }
- }
- done_appending: ;
- }
- }
-
- if (!uc_is_case_ignorable (uc))
- last_char_except_ignorable = uc;
-
- {
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- last_char_normal_or_above = uc;
- }
-
- s += count;
- wp += count;
+ /* Found the mapping: uc maps to mapped_uc[0..mapped_count-1]. */
+ {
+ unsigned int i;
+
+ for (i = 0; i < mapped_count; i++)
+ {
+ ucs4_t muc = mapped_uc[i];
+
+ /* Append muc to the result accumulator. */
+ if (length < allocated)
+ {
+ int ret = U_UCTOMB (result + length, muc, allocated - length);
+ if (ret == -1)
+ {
+ errno = EINVAL;
+ goto fail1;
+ }
+ if (ret >= 0)
+ {
+ length += ret;
+ goto done_appending;
+ }
+ }
+ {
+ size_t old_allocated = allocated;
+ size_t new_allocated = 2 * old_allocated;
+ if (new_allocated < 64)
+ new_allocated = 64;
+ if (new_allocated < old_allocated) /* integer overflow? */
+ abort ();
+ {
+ UNIT *larger_result;
+ if (result == NULL)
+ {
+ larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail1;
+ }
+ }
+ else if (result == resultbuf)
+ {
+ larger_result = (UNIT *) malloc (new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail1;
+ }
+ U_CPY (larger_result, resultbuf, length);
+ }
+ else
+ {
+ larger_result =
+ (UNIT *) realloc (result, new_allocated * sizeof (UNIT));
+ if (larger_result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail1;
+ }
+ }
+ result = larger_result;
+ allocated = new_allocated;
+ {
+ int ret = U_UCTOMB (result + length, muc, allocated - length);
+ if (ret == -1)
+ {
+ errno = EINVAL;
+ goto fail1;
+ }
+ if (ret < 0)
+ abort ();
+ length += ret;
+ goto done_appending;
+ }
+ }
+ }
+ done_appending: ;
+ }
+ }
+
+ if (!uc_is_case_ignorable (uc))
+ last_char_except_ignorable = uc;
+
+ {
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ last_char_normal_or_above = uc;
+ }
+
+ s += count;
+ wp += count;
}
}
@@ -452,7 +452,7 @@ FUNC (const UNIT *s, size_t n,
normalized_result = U_NORMALIZE (nf, result, length, resultbuf, lengthp);
if (normalized_result == NULL)
- goto fail2;
+ goto fail2;
free (result);
return normalized_result;
@@ -461,15 +461,15 @@ FUNC (const UNIT *s, size_t n,
if (length == 0)
{
if (result == NULL)
- {
- /* Return a non-NULL value. NULL means error. */
- result = (UNIT *) malloc (1);
- if (result == NULL)
- {
- errno = ENOMEM;
- goto fail2;
- }
- }
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail2;
+ }
+ }
}
else if (result != resultbuf && length < allocated)
{
@@ -478,7 +478,7 @@ FUNC (const UNIT *s, size_t n,
memory = (UNIT *) realloc (result, length * sizeof (UNIT));
if (memory != NULL)
- result = memory;
+ result = memory;
}
*lengthp = length;
diff --git a/lib/unicase/u-is-cased.h b/lib/unicase/u-is-cased.h
index b96a60f0ce..de007f5a1a 100644
--- a/lib/unicase/u-is-cased.h
+++ b/lib/unicase/u-is-cased.h
@@ -39,30 +39,30 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language,
/* Apply toupper mapping. */
mapped_toupper = U_TOUPPER (norms, norms_length, iso639_language, NULL,
- mappedbuf, &mapped_length);
+ mappedbuf, &mapped_length);
if (mapped_toupper == NULL)
goto fail;
/* Compare. */
if (!(mapped_length == norms_length
- && U_CMP (mapped_toupper, norms, norms_length) == 0))
+ && U_CMP (mapped_toupper, norms, norms_length) == 0))
{
if (mapped_toupper != mappedbuf)
- free (mapped_toupper);
+ free (mapped_toupper);
goto yes;
}
/* Apply tolower mapping. */
mapped_tolower = U_TOLOWER (norms, norms_length, iso639_language, NULL,
- mapped_toupper, &mapped_length);
+ mapped_toupper, &mapped_length);
if (mapped_tolower == NULL)
{
if (mapped_toupper != mappedbuf)
- {
- int saved_errno = errno;
- free (mapped_toupper);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (mapped_toupper);
+ errno = saved_errno;
+ }
goto fail;
}
@@ -71,24 +71,24 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language,
/* Compare. */
if (!(mapped_length == norms_length
- && U_CMP (mapped_tolower, norms, norms_length) == 0))
+ && U_CMP (mapped_tolower, norms, norms_length) == 0))
{
if (mapped_tolower != mappedbuf)
- free (mapped_tolower);
+ free (mapped_tolower);
goto yes;
}
/* Apply totitle mapping. */
mapped_totitle = U_TOTITLE (norms, norms_length, iso639_language, NULL,
- mapped_tolower, &mapped_length);
+ mapped_tolower, &mapped_length);
if (mapped_totitle == NULL)
{
if (mapped_tolower != mappedbuf)
- {
- int saved_errno = errno;
- free (mapped_tolower);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (mapped_tolower);
+ errno = saved_errno;
+ }
goto fail;
}
@@ -97,10 +97,10 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language,
/* Compare. */
if (!(mapped_length == norms_length
- && U_CMP (mapped_totitle, norms, norms_length) == 0))
+ && U_CMP (mapped_totitle, norms, norms_length) == 0))
{
if (mapped_totitle != mappedbuf)
- free (mapped_totitle);
+ free (mapped_totitle);
goto yes;
}
diff --git a/lib/unicase/u-is-invariant.h b/lib/unicase/u-is-invariant.h
index e6b7fbb413..33f23bcd4b 100644
--- a/lib/unicase/u-is-invariant.h
+++ b/lib/unicase/u-is-invariant.h
@@ -18,8 +18,8 @@
int
FUNC (const UNIT *s, size_t n,
UNIT * (*mapping) (const UNIT *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- UNIT *resultbuf, size_t *lengthp),
+ uninorm_t nf,
+ UNIT *resultbuf, size_t *lengthp),
const char *iso639_language,
bool *resultp)
{
@@ -40,21 +40,21 @@ FUNC (const UNIT *s, size_t n,
/* Apply mapping. */
mapped_length = sizeof (mappedbuf) / sizeof (UNIT);
mapped = mapping (norms, norms_length, iso639_language, NULL,
- mappedbuf, &mapped_length);
+ mappedbuf, &mapped_length);
if (mapped == NULL)
{
if (norms != normsbuf)
- {
- int saved_errno = errno;
- free (norms);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (norms);
+ errno = saved_errno;
+ }
return -1;
}
/* Compare. */
*resultp = (mapped_length == norms_length
- && U_CMP (mapped, norms, norms_length) == 0);
+ && U_CMP (mapped, norms, norms_length) == 0);
if (mapped != mappedbuf)
free (mapped);
diff --git a/lib/unicase/u-prefix-context.h b/lib/unicase/u-prefix-context.h
index e58b4114e0..85b9448d39 100644
--- a/lib/unicase/u-prefix-context.h
+++ b/lib/unicase/u-prefix-context.h
@@ -35,12 +35,12 @@ FUNC2 (const UNIT *s, size_t n, casing_prefix_context_t a_context)
int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
if (!uc_is_case_ignorable (uc))
- context.last_char_except_ignorable = uc;
+ context.last_char_except_ignorable = uc;
{
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- context.last_char_normal_or_above = uc;
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ context.last_char_normal_or_above = uc;
}
s += count;
@@ -59,24 +59,24 @@ FUNC2 (const UNIT *s, size_t n, casing_prefix_context_t a_context)
ucs4_t uc;
p = U_PREV (&uc, p, s);
if (p == NULL)
- break;
+ break;
if (last_char_except_ignorable == (ucs4_t)(-1))
- {
- if (!uc_is_case_ignorable (uc))
- last_char_except_ignorable = uc;
- }
+ {
+ if (!uc_is_case_ignorable (uc))
+ last_char_except_ignorable = uc;
+ }
if (last_char_normal_or_above == (ucs4_t)(-1))
- {
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- last_char_normal_or_above = uc;
- }
+ {
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ last_char_normal_or_above = uc;
+ }
if (last_char_except_ignorable != (ucs4_t)(-1)
- && last_char_normal_or_above != (ucs4_t)(-1))
- break;
+ && last_char_normal_or_above != (ucs4_t)(-1))
+ break;
}
context.last_char_except_ignorable =
(last_char_except_ignorable != (ucs4_t)(-1)
diff --git a/lib/unicase/u-suffix-context.h b/lib/unicase/u-suffix-context.h
index a8880953bf..37fc8ea138 100644
--- a/lib/unicase/u-suffix-context.h
+++ b/lib/unicase/u-suffix-context.h
@@ -39,36 +39,36 @@ FUNC2 (const UNIT *s, size_t n, casing_suffix_context_t a_context)
int count = U_MBTOUC_UNSAFE (&uc, s, s_end - s);
if (first_char_except_ignorable == (ucs4_t)(-1))
- {
- if (!uc_is_case_ignorable (uc))
- first_char_except_ignorable = uc;
- }
+ {
+ if (!uc_is_case_ignorable (uc))
+ first_char_except_ignorable = uc;
+ }
if (scc_MORE_ABOVE < 0)
- {
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A)
- scc_MORE_ABOVE = SCC_MORE_ABOVE_MASK;
- else if (ccc == UC_CCC_NR)
- scc_MORE_ABOVE = 0;
- }
+ {
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A)
+ scc_MORE_ABOVE = SCC_MORE_ABOVE_MASK;
+ else if (ccc == UC_CCC_NR)
+ scc_MORE_ABOVE = 0;
+ }
if (scc_BEFORE_DOT < 0)
- {
- if (uc == 0x0307) /* COMBINING DOT ABOVE */
- scc_BEFORE_DOT = SCC_BEFORE_DOT_MASK;
- else
- {
- int ccc = uc_combining_class (uc);
- if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
- scc_BEFORE_DOT = 0;
- }
- }
+ {
+ if (uc == 0x0307) /* COMBINING DOT ABOVE */
+ scc_BEFORE_DOT = SCC_BEFORE_DOT_MASK;
+ else
+ {
+ int ccc = uc_combining_class (uc);
+ if (ccc == UC_CCC_A || ccc == UC_CCC_NR)
+ scc_BEFORE_DOT = 0;
+ }
+ }
if (first_char_except_ignorable != (ucs4_t)(-1)
- && (scc_MORE_ABOVE | scc_BEFORE_DOT) >= 0)
- /* All conditions have been determined. */
- break;
+ && (scc_MORE_ABOVE | scc_BEFORE_DOT) >= 0)
+ /* All conditions have been determined. */
+ break;
s += count;
}
diff --git a/lib/unicase/u-totitle.h b/lib/unicase/u-totitle.h
index 431f000aec..a02859f750 100644
--- a/lib/unicase/u-totitle.h
+++ b/lib/unicase/u-totitle.h
@@ -21,8 +21,8 @@ FUNC (const UNIT *s, size_t n, const char *iso639_language,
UNIT *resultbuf, size_t *lengthp)
{
return U_CT_TOTITLE (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u16-ct-tolower.c b/lib/unicase/u16-ct-tolower.c
index 36b34e0400..c924009bba 100644
--- a/lib/unicase/u16-ct-tolower.c
+++ b/lib/unicase/u16-ct-tolower.c
@@ -27,14 +27,14 @@
uint16_t *
u16_ct_tolower (const uint16_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp)
{
return u16_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u16-ct-toupper.c b/lib/unicase/u16-ct-toupper.c
index 029c74b46c..8ffff9a077 100644
--- a/lib/unicase/u16-ct-toupper.c
+++ b/lib/unicase/u16-ct-toupper.c
@@ -27,14 +27,14 @@
uint16_t *
u16_ct_toupper (const uint16_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp)
{
return u16_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u16-is-casefolded.c b/lib/unicase/u16-is-casefolded.c
index 64a4ec18ef..8dca6f8430 100644
--- a/lib/unicase/u16-is-casefolded.c
+++ b/lib/unicase/u16-is-casefolded.c
@@ -24,7 +24,7 @@
int
u16_is_casefolded (const uint16_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u16_is_invariant (s, n, u16_casefold, iso639_language, resultp);
}
diff --git a/lib/unicase/u16-is-lowercase.c b/lib/unicase/u16-is-lowercase.c
index 36a0151258..f5dd971ba8 100644
--- a/lib/unicase/u16-is-lowercase.c
+++ b/lib/unicase/u16-is-lowercase.c
@@ -24,7 +24,7 @@
int
u16_is_lowercase (const uint16_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u16_is_invariant (s, n, u16_tolower, iso639_language, resultp);
}
diff --git a/lib/unicase/u16-is-titlecase.c b/lib/unicase/u16-is-titlecase.c
index 19aacea1fb..679b64fa1c 100644
--- a/lib/unicase/u16-is-titlecase.c
+++ b/lib/unicase/u16-is-titlecase.c
@@ -24,7 +24,7 @@
int
u16_is_titlecase (const uint16_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u16_is_invariant (s, n, u16_totitle, iso639_language, resultp);
}
diff --git a/lib/unicase/u16-is-uppercase.c b/lib/unicase/u16-is-uppercase.c
index 53e697fd2e..31620bbdb0 100644
--- a/lib/unicase/u16-is-uppercase.c
+++ b/lib/unicase/u16-is-uppercase.c
@@ -24,7 +24,7 @@
int
u16_is_uppercase (const uint16_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u16_is_invariant (s, n, u16_toupper, iso639_language, resultp);
}
diff --git a/lib/unicase/u16-tolower.c b/lib/unicase/u16-tolower.c
index 0629cb4d29..7bf9820194 100644
--- a/lib/unicase/u16-tolower.c
+++ b/lib/unicase/u16-tolower.c
@@ -27,13 +27,13 @@
uint16_t *
u16_tolower (const uint16_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp)
{
return u16_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u16-toupper.c b/lib/unicase/u16-toupper.c
index f92989aa26..475f618e46 100644
--- a/lib/unicase/u16-toupper.c
+++ b/lib/unicase/u16-toupper.c
@@ -27,13 +27,13 @@
uint16_t *
u16_toupper (const uint16_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp)
{
return u16_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u32-ct-tolower.c b/lib/unicase/u32-ct-tolower.c
index 83e9fa842b..876219c4b3 100644
--- a/lib/unicase/u32-ct-tolower.c
+++ b/lib/unicase/u32-ct-tolower.c
@@ -27,14 +27,14 @@
uint32_t *
u32_ct_tolower (const uint32_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp)
{
return u32_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u32-ct-toupper.c b/lib/unicase/u32-ct-toupper.c
index 9043ddebed..d245b23dce 100644
--- a/lib/unicase/u32-ct-toupper.c
+++ b/lib/unicase/u32-ct-toupper.c
@@ -27,14 +27,14 @@
uint32_t *
u32_ct_toupper (const uint32_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp)
{
return u32_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u32-is-casefolded.c b/lib/unicase/u32-is-casefolded.c
index a71c767dab..3abb7f6927 100644
--- a/lib/unicase/u32-is-casefolded.c
+++ b/lib/unicase/u32-is-casefolded.c
@@ -24,7 +24,7 @@
int
u32_is_casefolded (const uint32_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u32_is_invariant (s, n, u32_casefold, iso639_language, resultp);
}
diff --git a/lib/unicase/u32-is-lowercase.c b/lib/unicase/u32-is-lowercase.c
index 104afaae90..d4eb8b68e5 100644
--- a/lib/unicase/u32-is-lowercase.c
+++ b/lib/unicase/u32-is-lowercase.c
@@ -24,7 +24,7 @@
int
u32_is_lowercase (const uint32_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u32_is_invariant (s, n, u32_tolower, iso639_language, resultp);
}
diff --git a/lib/unicase/u32-is-titlecase.c b/lib/unicase/u32-is-titlecase.c
index 5b07c8dd07..ad66edb2d4 100644
--- a/lib/unicase/u32-is-titlecase.c
+++ b/lib/unicase/u32-is-titlecase.c
@@ -24,7 +24,7 @@
int
u32_is_titlecase (const uint32_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u32_is_invariant (s, n, u32_totitle, iso639_language, resultp);
}
diff --git a/lib/unicase/u32-is-uppercase.c b/lib/unicase/u32-is-uppercase.c
index bb38fc69d6..c94c10ea8b 100644
--- a/lib/unicase/u32-is-uppercase.c
+++ b/lib/unicase/u32-is-uppercase.c
@@ -24,7 +24,7 @@
int
u32_is_uppercase (const uint32_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u32_is_invariant (s, n, u32_toupper, iso639_language, resultp);
}
diff --git a/lib/unicase/u32-tolower.c b/lib/unicase/u32-tolower.c
index daa5c4d368..b22f9155ef 100644
--- a/lib/unicase/u32-tolower.c
+++ b/lib/unicase/u32-tolower.c
@@ -27,13 +27,13 @@
uint32_t *
u32_tolower (const uint32_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp)
{
return u32_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u32-toupper.c b/lib/unicase/u32-toupper.c
index 3430ad952d..b7f857a883 100644
--- a/lib/unicase/u32-toupper.c
+++ b/lib/unicase/u32-toupper.c
@@ -27,13 +27,13 @@
uint32_t *
u32_toupper (const uint32_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp)
{
return u32_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u8-casefold.c b/lib/unicase/u8-casefold.c
index 321081372f..39254a0963 100644
--- a/lib/unicase/u8-casefold.c
+++ b/lib/unicase/u8-casefold.c
@@ -47,28 +47,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -92,9 +92,9 @@ main (int argc, char * argv[])
int length = strlen (input);
size_t output_length;
uint8_t *output =
- u8_casefold ((uint8_t *) input, length, uc_locale_language (),
- NULL,
- NULL, &output_length);
+ u8_casefold ((uint8_t *) input, length, uc_locale_language (),
+ NULL,
+ NULL, &output_length);
fwrite (output, 1, output_length, stdout);
diff --git a/lib/unicase/u8-ct-tolower.c b/lib/unicase/u8-ct-tolower.c
index 3755821e30..c212d732a5 100644
--- a/lib/unicase/u8-ct-tolower.c
+++ b/lib/unicase/u8-ct-tolower.c
@@ -27,14 +27,14 @@
uint8_t *
u8_ct_tolower (const uint8_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp)
{
return u8_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u8-ct-toupper.c b/lib/unicase/u8-ct-toupper.c
index 9dca2fcac5..252b1a7169 100644
--- a/lib/unicase/u8-ct-toupper.c
+++ b/lib/unicase/u8-ct-toupper.c
@@ -27,14 +27,14 @@
uint8_t *
u8_ct_toupper (const uint8_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp)
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp)
{
return u8_casemap (s, n, prefix_context, suffix_context, iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
diff --git a/lib/unicase/u8-is-casefolded.c b/lib/unicase/u8-is-casefolded.c
index 30122b785f..66f261e838 100644
--- a/lib/unicase/u8-is-casefolded.c
+++ b/lib/unicase/u8-is-casefolded.c
@@ -24,7 +24,7 @@
int
u8_is_casefolded (const uint8_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u8_is_invariant (s, n, u8_casefold, iso639_language, resultp);
}
diff --git a/lib/unicase/u8-is-lowercase.c b/lib/unicase/u8-is-lowercase.c
index 5b0df8be7e..018c495fad 100644
--- a/lib/unicase/u8-is-lowercase.c
+++ b/lib/unicase/u8-is-lowercase.c
@@ -24,7 +24,7 @@
int
u8_is_lowercase (const uint8_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u8_is_invariant (s, n, u8_tolower, iso639_language, resultp);
}
diff --git a/lib/unicase/u8-is-titlecase.c b/lib/unicase/u8-is-titlecase.c
index 474502a726..a0a339309e 100644
--- a/lib/unicase/u8-is-titlecase.c
+++ b/lib/unicase/u8-is-titlecase.c
@@ -24,7 +24,7 @@
int
u8_is_titlecase (const uint8_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u8_is_invariant (s, n, u8_totitle, iso639_language, resultp);
}
diff --git a/lib/unicase/u8-is-uppercase.c b/lib/unicase/u8-is-uppercase.c
index 7f14f9249a..2613c292b8 100644
--- a/lib/unicase/u8-is-uppercase.c
+++ b/lib/unicase/u8-is-uppercase.c
@@ -24,7 +24,7 @@
int
u8_is_uppercase (const uint8_t *s, size_t n, const char *iso639_language,
- bool *resultp)
+ bool *resultp)
{
return u8_is_invariant (s, n, u8_toupper, iso639_language, resultp);
}
diff --git a/lib/unicase/u8-tolower.c b/lib/unicase/u8-tolower.c
index 1cd7cfa431..456d0f5407 100644
--- a/lib/unicase/u8-tolower.c
+++ b/lib/unicase/u8-tolower.c
@@ -27,15 +27,15 @@
uint8_t *
u8_tolower (const uint8_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp)
{
return u8_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_tolower, offsetof (struct special_casing_rule, lower[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_tolower, offsetof (struct special_casing_rule, lower[0]),
+ nf,
+ resultbuf, lengthp);
}
@@ -60,28 +60,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -105,9 +105,9 @@ main (int argc, char * argv[])
int length = strlen (input);
size_t output_length;
uint8_t *output =
- u8_tolower ((uint8_t *) input, length, uc_locale_language (),
- NULL,
- NULL, &output_length);
+ u8_tolower ((uint8_t *) input, length, uc_locale_language (),
+ NULL,
+ NULL, &output_length);
fwrite (output, 1, output_length, stdout);
diff --git a/lib/unicase/u8-totitle.c b/lib/unicase/u8-totitle.c
index cf29c1bab7..925e23d7d6 100644
--- a/lib/unicase/u8-totitle.c
+++ b/lib/unicase/u8-totitle.c
@@ -47,28 +47,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -92,9 +92,9 @@ main (int argc, char * argv[])
int length = strlen (input);
size_t output_length;
uint8_t *output =
- u8_toupper ((uint8_t *) input, length, uc_locale_language (),
- NULL,
- NULL, &output_length);
+ u8_toupper ((uint8_t *) input, length, uc_locale_language (),
+ NULL,
+ NULL, &output_length);
fwrite (output, 1, output_length, stdout);
diff --git a/lib/unicase/u8-toupper.c b/lib/unicase/u8-toupper.c
index a97d98ce58..ad10613138 100644
--- a/lib/unicase/u8-toupper.c
+++ b/lib/unicase/u8-toupper.c
@@ -27,15 +27,15 @@
uint8_t *
u8_toupper (const uint8_t *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp)
{
return u8_casemap (s, n,
- unicase_empty_prefix_context, unicase_empty_suffix_context,
- iso639_language,
- uc_toupper, offsetof (struct special_casing_rule, upper[0]),
- nf,
- resultbuf, lengthp);
+ unicase_empty_prefix_context, unicase_empty_suffix_context,
+ iso639_language,
+ uc_toupper, offsetof (struct special_casing_rule, upper[0]),
+ nf,
+ resultbuf, lengthp);
}
@@ -60,28 +60,28 @@ read_file (FILE *stream)
while (! feof (stream))
{
if (size + BUFSIZE > alloc)
- {
- alloc = alloc + alloc / 2;
- if (alloc < size + BUFSIZE)
- alloc = size + BUFSIZE;
- buf = realloc (buf, alloc);
- if (buf == NULL)
- {
- fprintf (stderr, "out of memory\n");
- exit (1);
- }
- }
+ {
+ alloc = alloc + alloc / 2;
+ if (alloc < size + BUFSIZE)
+ alloc = size + BUFSIZE;
+ buf = realloc (buf, alloc);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ exit (1);
+ }
+ }
count = fread (buf + size, 1, BUFSIZE, stream);
if (count == 0)
- {
- if (ferror (stream))
- {
- perror ("fread");
- exit (1);
- }
- }
+ {
+ if (ferror (stream))
+ {
+ perror ("fread");
+ exit (1);
+ }
+ }
else
- size += count;
+ size += count;
}
buf = realloc (buf, size + 1);
if (buf == NULL)
@@ -105,9 +105,9 @@ main (int argc, char * argv[])
int length = strlen (input);
size_t output_length;
uint8_t *output =
- u8_toupper ((uint8_t *) input, length, uc_locale_language (),
- NULL,
- NULL, &output_length);
+ u8_toupper ((uint8_t *) input, length, uc_locale_language (),
+ NULL,
+ NULL, &output_length);
fwrite (output, 1, output_length, stdout);
diff --git a/lib/unicase/ulc-casecmp.c b/lib/unicase/ulc-casecmp.c
index e07102190c..3fd8dfcd58 100644
--- a/lib/unicase/ulc-casecmp.c
+++ b/lib/unicase/ulc-casecmp.c
@@ -30,8 +30,8 @@
static uint8_t *
ulc_u8_casefold (const char *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp)
{
uint8_t convbuf[2048 / sizeof (uint8_t)];
uint8_t *conv;
@@ -42,22 +42,22 @@ ulc_u8_casefold (const char *s, size_t n, const char *iso639_language,
conv_length = sizeof (convbuf) / sizeof (uint8_t);
conv =
u8_conv_from_encoding (locale_charset (), iconveh_error, s, n, NULL,
- convbuf, &conv_length);
+ convbuf, &conv_length);
if (conv == NULL)
/* errno is set here. */
return NULL;
/* Case-fold and normalize. */
result = u8_casefold (conv, conv_length, iso639_language, nf,
- resultbuf, lengthp);
+ resultbuf, lengthp);
if (result == NULL)
{
if (conv != convbuf)
- {
- int saved_errno = errno;
- free (conv);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (conv);
+ errno = saved_errno;
+ }
return NULL;
}
diff --git a/lib/unicase/ulc-casexfrm.c b/lib/unicase/ulc-casexfrm.c
index aded556fe3..883b98d964 100644
--- a/lib/unicase/ulc-casexfrm.c
+++ b/lib/unicase/ulc-casexfrm.c
@@ -27,8 +27,8 @@
char *
ulc_casexfrm (const char *s, size_t n, const char *iso639_language,
- uninorm_t nf,
- char *resultbuf, size_t *lengthp)
+ uninorm_t nf,
+ char *resultbuf, size_t *lengthp)
{
uint8_t convbuf[2048 / sizeof (uint8_t)];
uint8_t *conv;
@@ -39,22 +39,22 @@ ulc_casexfrm (const char *s, size_t n, const char *iso639_language,
conv_length = sizeof (convbuf) / sizeof (uint8_t);
conv =
u8_conv_from_encoding (locale_charset (), iconveh_error, s, n, NULL,
- convbuf, &conv_length);
+ convbuf, &conv_length);
if (conv == NULL)
/* errno is set here. */
return NULL;
/* Case-fold and normalize. */
result = u8_casexfrm (conv, conv_length, iso639_language, nf,
- resultbuf, lengthp);
+ resultbuf, lengthp);
if (result == NULL)
{
if (conv != convbuf)
- {
- int saved_errno = errno;
- free (conv);
- errno = saved_errno;
- }
+ {
+ int saved_errno = errno;
+ free (conv);
+ errno = saved_errno;
+ }
return NULL;
}
diff --git a/lib/unicase/unicasemap.h b/lib/unicase/unicasemap.h
index 8da8c51d28..14d1b467fe 100644
--- a/lib/unicase/unicasemap.h
+++ b/lib/unicase/unicasemap.h
@@ -23,30 +23,30 @@
extern uint8_t *
u8_casemap (const uint8_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- ucs4_t (*single_character_map) (ucs4_t),
- size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
- uninorm_t nf,
- uint8_t *resultbuf, size_t *lengthp);
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ ucs4_t (*single_character_map) (ucs4_t),
+ size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
+ uninorm_t nf,
+ uint8_t *resultbuf, size_t *lengthp);
extern uint16_t *
u16_casemap (const uint16_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- ucs4_t (*single_character_map) (ucs4_t),
- size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
- uninorm_t nf,
- uint16_t *resultbuf, size_t *lengthp);
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ ucs4_t (*single_character_map) (ucs4_t),
+ size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
+ uninorm_t nf,
+ uint16_t *resultbuf, size_t *lengthp);
extern uint32_t *
u32_casemap (const uint32_t *s, size_t n,
- casing_prefix_context_t prefix_context,
- casing_suffix_context_t suffix_context,
- const char *iso639_language,
- ucs4_t (*single_character_map) (ucs4_t),
- size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
- uninorm_t nf,
- uint32_t *resultbuf, size_t *lengthp);
+ casing_prefix_context_t prefix_context,
+ casing_suffix_context_t suffix_context,
+ const char *iso639_language,
+ ucs4_t (*single_character_map) (ucs4_t),
+ size_t offset_in_rule, /* offset in 'struct special_casing_rule' */
+ uninorm_t nf,
+ uint32_t *resultbuf, size_t *lengthp);