diff options
author | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 |
---|---|---|
committer | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 |
commit | bd6adfa17d453e4c486e36fed4c5779db90a8a0e (patch) | |
tree | 9798677560d5f99061afe9f0db105a8c97f2438a /lib/unicase | |
parent | 79ca645d222db2e158784642c3b464a47bea26f3 (diff) | |
parent | 3e0814cd9862b89c7a39672672937477bd87ddfb (diff) |
Merge commit 'upstream/0.9.3'
Diffstat (limited to 'lib/unicase')
84 files changed, 1144 insertions, 1141 deletions
diff --git a/lib/unicase/cased.c b/lib/unicase/cased.c index 5fbf4cb7..ced6a0e5 100644 --- a/lib/unicase/cased.c +++ b/lib/unicase/cased.c @@ -1,5 +1,5 @@ /* Test whether a Unicode character is cased. - Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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/casefold.h b/lib/unicase/casefold.h index d1f434ca..1a4fe926 100644 --- a/lib/unicase/casefold.h +++ b/lib/unicase/casefold.h @@ -1,5 +1,5 @@ /* Casefolding of Unicode characters. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/caseprop.h b/lib/unicase/caseprop.h index f84453ec..391d1692 100644 --- a/lib/unicase/caseprop.h +++ b/lib/unicase/caseprop.h @@ -1,5 +1,5 @@ /* Case related properties of Unicode characters. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/context.h b/lib/unicase/context.h index 6a35798d..a3303d6e 100644 --- a/lib/unicase/context.h +++ b/lib/unicase/context.h @@ -1,5 +1,5 @@ /* Case-mapping contexts of UTF-8/UTF-16/UTF-32 substring. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/empty-prefix-context.c b/lib/unicase/empty-prefix-context.c index 3c46e9e3..dada1047 100644 --- a/lib/unicase/empty-prefix-context.c +++ b/lib/unicase/empty-prefix-context.c @@ -1,5 +1,5 @@ /* Case-mapping context of empty prefix string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/empty-suffix-context.c b/lib/unicase/empty-suffix-context.c index 4e00bffe..fc59a6e2 100644 --- a/lib/unicase/empty-suffix-context.c +++ b/lib/unicase/empty-suffix-context.c @@ -1,5 +1,5 @@ /* Case-mapping context of empty suffix string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/ignorable.c b/lib/unicase/ignorable.c index 84b2634c..9cfce9fa 100644 --- a/lib/unicase/ignorable.c +++ b/lib/unicase/ignorable.c @@ -1,5 +1,5 @@ /* Test whether a Unicode character is case-ignorable. - Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 20151433..c65ae23e 100644 --- a/lib/unicase/invariant.h +++ b/lib/unicase/invariant.h @@ -1,5 +1,5 @@ /* Internal functions for Unicode character case mappings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 074baa41..2ee65c72 100644 --- a/lib/unicase/locale-language.c +++ b/lib/unicase/locale-language.c @@ -1,5 +1,5 @@ /* Language code of current locale. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 44cecc81..83200b49 100644 --- a/lib/unicase/simple-mapping.h +++ b/lib/unicase/simple-mapping.h @@ -1,5 +1,5 @@ /* Simple case mapping for Unicode characters. - Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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/special-casing.c b/lib/unicase/special-casing.c index 9cc207c6..95b6c824 100644 --- a/lib/unicase/special-casing.c +++ b/lib/unicase/special-casing.c @@ -1,5 +1,5 @@ /* Special casing table. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/special-casing.h b/lib/unicase/special-casing.h index ab88b84d..33911cfc 100644 --- a/lib/unicase/special-casing.h +++ b/lib/unicase/special-casing.h @@ -1,5 +1,5 @@ /* Special casing table. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/tocasefold.c b/lib/unicase/tocasefold.c index 752ba60a..1ba79bd3 100644 --- a/lib/unicase/tocasefold.c +++ b/lib/unicase/tocasefold.c @@ -1,5 +1,5 @@ /* Casefold mapping for Unicode characters (locale and context independent). - Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/tolower.c b/lib/unicase/tolower.c index 5ed0c6d2..c69f691d 100644 --- a/lib/unicase/tolower.c +++ b/lib/unicase/tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for Unicode characters (locale and context independent). - Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/totitle.c b/lib/unicase/totitle.c index 0ca5a45b..ced1b69c 100644 --- a/lib/unicase/totitle.c +++ b/lib/unicase/totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for Unicode characters (locale and context independent). - Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/toupper.c b/lib/unicase/toupper.c index d74e45c7..9642b706 100644 --- a/lib/unicase/toupper.c +++ b/lib/unicase/toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for Unicode characters (locale and context independent). - Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u-casecmp.h b/lib/unicase/u-casecmp.h index e1cf99c4..88c308b4 100644 --- a/lib/unicase/u-casecmp.h +++ b/lib/unicase/u-casecmp.h @@ -1,5 +1,5 @@ /* Case and normalization insensitive comparison of Unicode strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 73094abe..700d49b1 100644 --- a/lib/unicase/u-casecoll.h +++ b/lib/unicase/u-casecoll.h @@ -1,6 +1,6 @@ /* Locale dependent, case and normalization insensitive comparison of Unicode strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 c41f4e18..b0dc89a6 100644 --- a/lib/unicase/u-casefold.h +++ b/lib/unicase/u-casefold.h @@ -1,5 +1,5 @@ /* Casefolding mapping for Unicode strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 ea41444a..b5b4d2fc 100644 --- a/lib/unicase/u-casemap.h +++ b/lib/unicase/u-casemap.h @@ -1,5 +1,5 @@ /* Case mapping for UTF-8/UTF-16/UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 e36aff3b..5c7430c0 100644 --- a/lib/unicase/u-casexfrm.h +++ b/lib/unicase/u-casexfrm.h @@ -1,6 +1,6 @@ /* Locale dependent transformation for case insensitive comparison of Unicode strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 d97be264..e11d0a81 100644 --- a/lib/unicase/u-ct-casefold.h +++ b/lib/unicase/u-ct-casefold.h @@ -1,5 +1,5 @@ /* Casefolding mapping for Unicode substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 f0d4fd77..8892a5df 100644 --- a/lib/unicase/u-ct-totitle.h +++ b/lib/unicase/u-ct-totitle.h @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-8/UTF-16/UTF-32 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 b96a60f0..c187a30e 100644 --- a/lib/unicase/u-is-cased.h +++ b/lib/unicase/u-is-cased.h @@ -1,5 +1,5 @@ /* Test whether case matters for a Unicode string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 e6b7fbb4..541dd8df 100644 --- a/lib/unicase/u-is-invariant.h +++ b/lib/unicase/u-is-invariant.h @@ -1,5 +1,5 @@ /* Test whether a Unicode string is invariant under a given case mapping. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.h b/lib/unicase/u-totitle.h index 431f000a..658c95fd 100644 --- a/lib/unicase/u-totitle.h +++ b/lib/unicase/u-totitle.h @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-8/UTF-16/UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-casecmp.c b/lib/unicase/u16-casecmp.c index 1110874e..e6780a99 100644 --- a/lib/unicase/u16-casecmp.c +++ b/lib/unicase/u16-casecmp.c @@ -1,5 +1,5 @@ /* Case and normalization insensitive comparison of UTF-16 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-casecoll.c b/lib/unicase/u16-casecoll.c index 882039cf..986bdb85 100644 --- a/lib/unicase/u16-casecoll.c +++ b/lib/unicase/u16-casecoll.c @@ -1,6 +1,6 @@ /* Locale dependent, case and normalization insensitive comparison of UTF-16 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-casefold.c b/lib/unicase/u16-casefold.c index 55522753..037d51fa 100644 --- a/lib/unicase/u16-casefold.c +++ b/lib/unicase/u16-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-16 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-casemap.c b/lib/unicase/u16-casemap.c index 0766de92..b8021e7f 100644 --- a/lib/unicase/u16-casemap.c +++ b/lib/unicase/u16-casemap.c @@ -1,5 +1,5 @@ /* Case mapping for UTF-16 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-casexfrm.c b/lib/unicase/u16-casexfrm.c index 09d08ce1..661902fc 100644 --- a/lib/unicase/u16-casexfrm.c +++ b/lib/unicase/u16-casexfrm.c @@ -1,6 +1,6 @@ /* Locale dependent transformation for case insensitive comparison of UTF-16 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-ct-casefold.c b/lib/unicase/u16-ct-casefold.c index 6dff77d7..65e49e75 100644 --- a/lib/unicase/u16-ct-casefold.c +++ b/lib/unicase/u16-ct-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-16 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-ct-tolower.c b/lib/unicase/u16-ct-tolower.c index 36b34e04..2b09c7e1 100644 --- a/lib/unicase/u16-ct-tolower.c +++ b/lib/unicase/u16-ct-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-16 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.c b/lib/unicase/u16-ct-totitle.c index c01021b8..095bd9f4 100644 --- a/lib/unicase/u16-ct-totitle.c +++ b/lib/unicase/u16-ct-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-16 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-ct-toupper.c b/lib/unicase/u16-ct-toupper.c index 029c74b4..d26f6c5a 100644 --- a/lib/unicase/u16-ct-toupper.c +++ b/lib/unicase/u16-ct-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-16 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-cased.c b/lib/unicase/u16-is-cased.c index c2196cef..385c01a7 100644 --- a/lib/unicase/u16-is-cased.c +++ b/lib/unicase/u16-is-cased.c @@ -1,5 +1,5 @@ /* Test whether case matters for an UTF-16 string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-is-casefolded.c b/lib/unicase/u16-is-casefolded.c index 64a4ec18..dd3b6c17 100644 --- a/lib/unicase/u16-is-casefolded.c +++ b/lib/unicase/u16-is-casefolded.c @@ -1,5 +1,5 @@ /* Test whether an UTF-16 string is already case-folded. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-invariant.c b/lib/unicase/u16-is-invariant.c index cace25a7..a7f40da3 100644 --- a/lib/unicase/u16-is-invariant.c +++ b/lib/unicase/u16-is-invariant.c @@ -1,5 +1,5 @@ /* Test whether an UTF-16 string is invariant under a given case mapping. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -21,6 +21,7 @@ #include "unicase/invariant.h" #include <errno.h> +#include <stdbool.h> #include <stdlib.h> #include "uninorm.h" diff --git a/lib/unicase/u16-is-lowercase.c b/lib/unicase/u16-is-lowercase.c index 36a01512..de51a04a 100644 --- a/lib/unicase/u16-is-lowercase.c +++ b/lib/unicase/u16-is-lowercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-16 string is entirely lower case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 19aacea1..4192aad3 100644 --- a/lib/unicase/u16-is-titlecase.c +++ b/lib/unicase/u16-is-titlecase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-16 string is entirely title case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 53e697fd..509c9bb0 100644 --- a/lib/unicase/u16-is-uppercase.c +++ b/lib/unicase/u16-is-uppercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-16 string is entirely upper case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 0629cb4d..c931cca9 100644 --- a/lib/unicase/u16-tolower.c +++ b/lib/unicase/u16-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-16 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.c b/lib/unicase/u16-totitle.c index e0d14e83..f7c59462 100644 --- a/lib/unicase/u16-totitle.c +++ b/lib/unicase/u16-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-16 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u16-toupper.c b/lib/unicase/u16-toupper.c index f92989aa..12e888aa 100644 --- a/lib/unicase/u16-toupper.c +++ b/lib/unicase/u16-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-16 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-casecmp.c b/lib/unicase/u32-casecmp.c index e964915f..7b67bb1c 100644 --- a/lib/unicase/u32-casecmp.c +++ b/lib/unicase/u32-casecmp.c @@ -1,5 +1,5 @@ /* Case and normalization insensitive comparison of UTF-32 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-casecoll.c b/lib/unicase/u32-casecoll.c index 88d994a0..6d1d772d 100644 --- a/lib/unicase/u32-casecoll.c +++ b/lib/unicase/u32-casecoll.c @@ -1,6 +1,6 @@ /* Locale dependent, case and normalization insensitive comparison of UTF-32 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-casefold.c b/lib/unicase/u32-casefold.c index aff44f82..d1a13410 100644 --- a/lib/unicase/u32-casefold.c +++ b/lib/unicase/u32-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-casemap.c b/lib/unicase/u32-casemap.c index 43e2641c..6c8213ca 100644 --- a/lib/unicase/u32-casemap.c +++ b/lib/unicase/u32-casemap.c @@ -1,5 +1,5 @@ /* Case mapping for UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-casexfrm.c b/lib/unicase/u32-casexfrm.c index cf8fee67..bd54497b 100644 --- a/lib/unicase/u32-casexfrm.c +++ b/lib/unicase/u32-casexfrm.c @@ -1,6 +1,6 @@ /* Locale dependent transformation for case insensitive comparison of UTF-32 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-ct-casefold.c b/lib/unicase/u32-ct-casefold.c index e206b677..f360cce7 100644 --- a/lib/unicase/u32-ct-casefold.c +++ b/lib/unicase/u32-ct-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-32 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-ct-tolower.c b/lib/unicase/u32-ct-tolower.c index 83e9fa84..7df6a563 100644 --- a/lib/unicase/u32-ct-tolower.c +++ b/lib/unicase/u32-ct-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-32 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.c b/lib/unicase/u32-ct-totitle.c index f2a38782..d9f51bb7 100644 --- a/lib/unicase/u32-ct-totitle.c +++ b/lib/unicase/u32-ct-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-32 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-ct-toupper.c b/lib/unicase/u32-ct-toupper.c index 9043ddeb..e6165564 100644 --- a/lib/unicase/u32-ct-toupper.c +++ b/lib/unicase/u32-ct-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-32 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-cased.c b/lib/unicase/u32-is-cased.c index 783e57e9..e836dc15 100644 --- a/lib/unicase/u32-is-cased.c +++ b/lib/unicase/u32-is-cased.c @@ -1,5 +1,5 @@ /* Test whether case matters for an UTF-32 string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-is-casefolded.c b/lib/unicase/u32-is-casefolded.c index a71c767d..6c2bbb0e 100644 --- a/lib/unicase/u32-is-casefolded.c +++ b/lib/unicase/u32-is-casefolded.c @@ -1,5 +1,5 @@ /* Test whether an UTF-32 string is already case-folded. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-invariant.c b/lib/unicase/u32-is-invariant.c index 190a30fe..aea4c61e 100644 --- a/lib/unicase/u32-is-invariant.c +++ b/lib/unicase/u32-is-invariant.c @@ -1,5 +1,5 @@ /* Test whether an UTF-32 string is invariant under a given case mapping. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -21,6 +21,7 @@ #include "unicase/invariant.h" #include <errno.h> +#include <stdbool.h> #include <stdlib.h> #include "uninorm.h" diff --git a/lib/unicase/u32-is-lowercase.c b/lib/unicase/u32-is-lowercase.c index 104afaae..cc2fa2dc 100644 --- a/lib/unicase/u32-is-lowercase.c +++ b/lib/unicase/u32-is-lowercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-32 string is entirely lower case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 5b07c8dd..ee48fc73 100644 --- a/lib/unicase/u32-is-titlecase.c +++ b/lib/unicase/u32-is-titlecase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-32 string is entirely title case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 bb38fc69..369a68b9 100644 --- a/lib/unicase/u32-is-uppercase.c +++ b/lib/unicase/u32-is-uppercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-32 string is entirely upper case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 daa5c4d3..b9c53eda 100644 --- a/lib/unicase/u32-tolower.c +++ b/lib/unicase/u32-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.c b/lib/unicase/u32-totitle.c index 21e1b0d1..d144ae75 100644 --- a/lib/unicase/u32-totitle.c +++ b/lib/unicase/u32-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u32-toupper.c b/lib/unicase/u32-toupper.c index 3430ad95..d58c8e24 100644 --- a/lib/unicase/u32-toupper.c +++ b/lib/unicase/u32-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-casecmp.c b/lib/unicase/u8-casecmp.c index 4a55de91..4edbfc35 100644 --- a/lib/unicase/u8-casecmp.c +++ b/lib/unicase/u8-casecmp.c @@ -1,5 +1,5 @@ /* Case and normalization insensitive comparison of UTF-8 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-casecoll.c b/lib/unicase/u8-casecoll.c index 28170e54..694011c9 100644 --- a/lib/unicase/u8-casecoll.c +++ b/lib/unicase/u8-casecoll.c @@ -1,6 +1,6 @@ /* Locale dependent, case and normalization insensitive comparison of UTF-8 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-casefold.c b/lib/unicase/u8-casefold.c index 32108137..e3c91771 100644 --- a/lib/unicase/u8-casefold.c +++ b/lib/unicase/u8-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-8 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-casemap.c b/lib/unicase/u8-casemap.c index 6f329155..9e4d0c09 100644 --- a/lib/unicase/u8-casemap.c +++ b/lib/unicase/u8-casemap.c @@ -1,5 +1,5 @@ /* Case mapping for UTF-8 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-casexfrm.c b/lib/unicase/u8-casexfrm.c index 7e1d767c..b3e0c664 100644 --- a/lib/unicase/u8-casexfrm.c +++ b/lib/unicase/u8-casexfrm.c @@ -1,6 +1,6 @@ /* Locale dependent transformation for case insensitive comparison of UTF-8 strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-ct-casefold.c b/lib/unicase/u8-ct-casefold.c index 4cc149c3..45bacfc5 100644 --- a/lib/unicase/u8-ct-casefold.c +++ b/lib/unicase/u8-ct-casefold.c @@ -1,5 +1,5 @@ /* Casefolding mapping for UTF-8 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-ct-tolower.c b/lib/unicase/u8-ct-tolower.c index 3755821e..1b0ee33c 100644 --- a/lib/unicase/u8-ct-tolower.c +++ b/lib/unicase/u8-ct-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-8 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-totitle.c b/lib/unicase/u8-ct-totitle.c index 64891afd..7bcdc0dc 100644 --- a/lib/unicase/u8-ct-totitle.c +++ b/lib/unicase/u8-ct-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-8 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-ct-toupper.c b/lib/unicase/u8-ct-toupper.c index 9dca2fca..c22b25af 100644 --- a/lib/unicase/u8-ct-toupper.c +++ b/lib/unicase/u8-ct-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-8 substrings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-cased.c b/lib/unicase/u8-is-cased.c index 5cdcc33b..56fc9c7c 100644 --- a/lib/unicase/u8-is-cased.c +++ b/lib/unicase/u8-is-cased.c @@ -1,5 +1,5 @@ /* Test whether case matters for an UTF-8 string. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/u8-is-casefolded.c b/lib/unicase/u8-is-casefolded.c index 30122b78..007a5126 100644 --- a/lib/unicase/u8-is-casefolded.c +++ b/lib/unicase/u8-is-casefolded.c @@ -1,5 +1,5 @@ /* Test whether an UTF-8 string is already case-folded. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-invariant.c b/lib/unicase/u8-is-invariant.c index 2c4913bf..4794e567 100644 --- a/lib/unicase/u8-is-invariant.c +++ b/lib/unicase/u8-is-invariant.c @@ -1,5 +1,5 @@ /* Test whether an UTF-8 string is invariant under a given case mapping. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -21,6 +21,7 @@ #include "unicase/invariant.h" #include <errno.h> +#include <stdbool.h> #include <stdlib.h> #include "uninorm.h" diff --git a/lib/unicase/u8-is-lowercase.c b/lib/unicase/u8-is-lowercase.c index 5b0df8be..8501614e 100644 --- a/lib/unicase/u8-is-lowercase.c +++ b/lib/unicase/u8-is-lowercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-8 string is entirely lower case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 474502a7..6357a34e 100644 --- a/lib/unicase/u8-is-titlecase.c +++ b/lib/unicase/u8-is-titlecase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-8 string is entirely title case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 7f14f924..817579f3 100644 --- a/lib/unicase/u8-is-uppercase.c +++ b/lib/unicase/u8-is-uppercase.c @@ -1,5 +1,5 @@ /* Test whether an UTF-8 string is entirely upper case. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 1cd7cfa4..f657feb3 100644 --- a/lib/unicase/u8-tolower.c +++ b/lib/unicase/u8-tolower.c @@ -1,5 +1,5 @@ /* Lowercase mapping for UTF-8 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 cf29c1ba..e63cda9e 100644 --- a/lib/unicase/u8-totitle.c +++ b/lib/unicase/u8-totitle.c @@ -1,5 +1,5 @@ /* Titlecase mapping for UTF-8 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 a97d98ce..7429e525 100644 --- a/lib/unicase/u8-toupper.c +++ b/lib/unicase/u8-toupper.c @@ -1,5 +1,5 @@ /* Uppercase mapping for UTF-8 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 e0710219..1f343cd5 100644 --- a/lib/unicase/ulc-casecmp.c +++ b/lib/unicase/ulc-casecmp.c @@ -1,5 +1,5 @@ /* Case and normalization insensitive comparison of strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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-casecoll.c b/lib/unicase/ulc-casecoll.c index 9730b6dc..9645e147 100644 --- a/lib/unicase/ulc-casecoll.c +++ b/lib/unicase/ulc-casecoll.c @@ -1,5 +1,5 @@ /* Locale dependent, case and normalization insensitive comparison of strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/unicase/ulc-casexfrm.c b/lib/unicase/ulc-casexfrm.c index aded556f..89982116 100644 --- a/lib/unicase/ulc-casexfrm.c +++ b/lib/unicase/ulc-casexfrm.c @@ -1,5 +1,5 @@ /* Locale dependent transformation for case insensitive comparison of strings. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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 8da8c51d..01880834 100644 --- a/lib/unicase/unicasemap.h +++ b/lib/unicase/unicasemap.h @@ -1,5 +1,5 @@ /* Case mapping for UTF-8/UTF-16/UTF-32 strings (locale dependent). - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -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); |