Enable common subexpression optimization in GCC.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2012 01:39:55 +0000 (03:39 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2012 01:39:55 +0000 (03:39 +0200)
* lib/unitypes.in.h (_UC_ATTRIBUTE_CONST, _UC_ATTRIBUTE_PURE): New
macros.
* lib/unicase.in.h (uc_toupper, uc_tolower, uc_totitle): Declare with
GCC attribute 'const'.
(uc_locale_language): Declare with GCC attribute 'pure'.
* lib/unicase/caseprop.h (uc_is_cased, uc_is_case_ignorable): Declare
with GCC attribute 'const'.
* lib/unictype.in.h (uc_is_general_category_withtable,
uc_combining_class, uc_combining_class_name,
uc_combining_class_long_name, uc_bidi_class_name,
uc_bidi_category_name, uc_bidi_class_long_name, uc_bidi_class,
uc_bidi_category, uc_is_bidi_class, uc_is_bidi_category,
uc_decimal_value, uc_digit_value, uc_numeric_value,
uc_joining_type_name, uc_joining_type_long_name, uc_joining_type,
uc_joining_group_name, uc_joining_group, uc_is_property_*, uc_script,
uc_block, uc_is_c_whitespace, uc_is_java_whitespace,
uc_c_ident_category, uc_java_ident_category, uc_is_alnum, uc_is_alpha,
uc_is_cntrl, uc_is_digit, uc_is_graph, uc_is_lower, uc_is_print,
uc_is_punct, uc_is_space, uc_is_upper, uc_is_xdigit, uc_is_blank):
Declare with GCC attribute 'const'.
(uc_general_category_name, uc_general_category_long_name,
uc_general_category_byname, uc_general_category,
uc_is_general_category, uc_combining_class_byname,
uc_bidi_class_byname, uc_bidi_category_byname, uc_joining_type_byname,
uc_joining_group_byname, uc_script_byname, uc_is_script, uc_is_block):
Declare with GCC attribute 'pure'.
* lib/unigbrk.in.h (uc_graphemeclusterbreak_property,
uc_is_grapheme_break, u8_grapheme_next, u16_grapheme_next,
u32_grapheme_next, u8_grapheme_prev, u16_grapheme_prev,
u32_grapheme_prev, lib/uniname.in.h (unicode_name_character): Declare
with GCC attribute 'pure'.
* lib/uninorm.in.h (uc_composition): Declare with GCC attribute
'const'.
(uninorm_decomposing_form): Declare with GCC attribute 'pure'.
* lib/unistr.in.h (): Declare with GCC attribute 'const'.
(u8_check, u16_check, u32_check, u8_mblen, u16_mblen, u32_mblen,
u8_cmp, u16_cmp, u32_cmp, u8_cmp2, u16_cmp2, u32_cmp2, u8_chr, u16_chr,
u32_chr, u8_mbsnlen, u16_mbsnlen, u32_mbsnlen, u8_strmblen,
u16_strmblen, u32_strmblen, u8_strlen, u16_strlen, u32_strlen,
u8_strnlen, u16_strnlen, u32_strnlen, u8_strcmp_gnu, u8_strcmp,
u16_strcmp, u32_strcmp, u8_strncmp, u16_strncmp, u32_strncmp,
u8_strchr, u16_strchr, u32_strchr, u8_strrchr, u16_strrchr,
u32_strrchr, u8_strcspn, u16_strcspn, u32_strcspn, u8_strspn,
u16_strspn, u32_strspn, u8_strpbrk, u16_strpbrk, u32_strpbrk,
u8_strstr, u16_strstr, u32_strstr, u8_startswith, u16_startswith,
u32_startswith, u8_endswith, u16_endswith, u32_endswith): Declare with
GCC attribute 'pure'.
* lib/uniwbrk.in.h (uc_wordbreak_property): Declare with GCC attribute
'const'.
* lib/uniwidth.in.h (uc_width): Simplify declaration.
(u8_width, u16_width, u32_width, u8_strwidth, u16_strwidth,
u32_strwidth): Declare with GCC attribute 'pure'.

ChangeLog
lib/unicase.in.h
lib/unicase/caseprop.h
lib/unictype.in.h
lib/unigbrk.in.h
lib/uniname.in.h
lib/uninorm.in.h
lib/unistr.in.h
lib/unitypes.in.h
lib/uniwbrk.in.h
lib/uniwidth.in.h

index 55b242d..efac2e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,60 @@
 2012-03-24  Bruno Haible  <bruno@clisp.org>
 
        Enable common subexpression optimization in GCC.
+       * lib/unitypes.in.h (_UC_ATTRIBUTE_CONST, _UC_ATTRIBUTE_PURE): New
+       macros.
+       * lib/unicase.in.h (uc_toupper, uc_tolower, uc_totitle): Declare with
+       GCC attribute 'const'.
+       (uc_locale_language): Declare with GCC attribute 'pure'.
+       * lib/unicase/caseprop.h (uc_is_cased, uc_is_case_ignorable): Declare
+       with GCC attribute 'const'.
+       * lib/unictype.in.h (uc_is_general_category_withtable,
+       uc_combining_class, uc_combining_class_name,
+       uc_combining_class_long_name, uc_bidi_class_name,
+       uc_bidi_category_name, uc_bidi_class_long_name, uc_bidi_class,
+       uc_bidi_category, uc_is_bidi_class, uc_is_bidi_category,
+       uc_decimal_value, uc_digit_value, uc_numeric_value,
+       uc_joining_type_name, uc_joining_type_long_name, uc_joining_type,
+       uc_joining_group_name, uc_joining_group, uc_is_property_*, uc_script,
+       uc_block, uc_is_c_whitespace, uc_is_java_whitespace,
+       uc_c_ident_category, uc_java_ident_category, uc_is_alnum, uc_is_alpha,
+       uc_is_cntrl, uc_is_digit, uc_is_graph, uc_is_lower, uc_is_print,
+       uc_is_punct, uc_is_space, uc_is_upper, uc_is_xdigit, uc_is_blank):
+       Declare with GCC attribute 'const'.
+       (uc_general_category_name, uc_general_category_long_name,
+       uc_general_category_byname, uc_general_category,
+       uc_is_general_category, uc_combining_class_byname,
+       uc_bidi_class_byname, uc_bidi_category_byname, uc_joining_type_byname,
+       uc_joining_group_byname, uc_script_byname, uc_is_script, uc_is_block):
+       Declare with GCC attribute 'pure'.
+       * lib/unigbrk.in.h (uc_graphemeclusterbreak_property,
+       uc_is_grapheme_break, u8_grapheme_next, u16_grapheme_next,
+       u32_grapheme_next, u8_grapheme_prev, u16_grapheme_prev,
+       u32_grapheme_prev, lib/uniname.in.h (unicode_name_character): Declare
+       with GCC attribute 'pure'.
+       * lib/uninorm.in.h (uc_composition): Declare with GCC attribute
+       'const'.
+       (uninorm_decomposing_form): Declare with GCC attribute 'pure'.
+       * lib/unistr.in.h (): Declare with GCC attribute 'const'.
+       (u8_check, u16_check, u32_check, u8_mblen, u16_mblen, u32_mblen,
+       u8_cmp, u16_cmp, u32_cmp, u8_cmp2, u16_cmp2, u32_cmp2, u8_chr, u16_chr,
+       u32_chr, u8_mbsnlen, u16_mbsnlen, u32_mbsnlen, u8_strmblen,
+       u16_strmblen, u32_strmblen, u8_strlen, u16_strlen, u32_strlen,
+       u8_strnlen, u16_strnlen, u32_strnlen, u8_strcmp_gnu, u8_strcmp,
+       u16_strcmp, u32_strcmp, u8_strncmp, u16_strncmp, u32_strncmp,
+       u8_strchr, u16_strchr, u32_strchr, u8_strrchr, u16_strrchr,
+       u32_strrchr, u8_strcspn, u16_strcspn, u32_strcspn, u8_strspn,
+       u16_strspn, u32_strspn, u8_strpbrk, u16_strpbrk, u32_strpbrk,
+       u8_strstr, u16_strstr, u32_strstr, u8_startswith, u16_startswith,
+       u32_startswith, u8_endswith, u16_endswith, u32_endswith): Declare with
+       GCC attribute 'pure'.
+       * lib/uniwbrk.in.h (uc_wordbreak_property): Declare with GCC attribute
+       'const'.
+       * lib/uniwidth.in.h (uc_width): Simplify declaration.
+       (u8_width, u16_width, u32_width, u8_strwidth, u16_strwidth,
+       u32_strwidth): Declare with GCC attribute 'pure'.
+
+       Enable common subexpression optimization in GCC.
        * lib/dirent.in.h (_GL_ATTRIBUTE_PURE): Define, like in string.in.h.
        (alphasort): Declare with GCC attribute 'pure'.
        * lib/stdlib.in.h (_GL_ATTRIBUTE_PURE): Define, like in string.in.h.
index 11b35c8..f25a25a 100644 (file)
@@ -42,15 +42,18 @@ extern "C" {
 
 /* Return the uppercase mapping of a Unicode character.  */
 extern ucs4_t
-       uc_toupper (ucs4_t uc);
+       uc_toupper (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the lowercase mapping of a Unicode character.  */
 extern ucs4_t
-       uc_tolower (ucs4_t uc);
+       uc_tolower (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the titlecase mapping of a Unicode character.  */
 extern ucs4_t
-       uc_totitle (ucs4_t uc);
+       uc_totitle (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -63,7 +66,8 @@ extern ucs4_t
 /* Return the ISO 639 language code of the current locale.
    Return "" if it is unknown, or in the "C" locale.  */
 extern const char *
-       uc_locale_language (void);
+       uc_locale_language (void)
+       _UC_ATTRIBUTE_PURE;
 
 /* Conventions:
 
index 4bcdd14..c4c32f4 100644 (file)
    <http://www.unicode.org/versions/Unicode5.0.0/ch03.pdf>, section 3.13,
    definition D120.  */
 extern bool
-       uc_is_cased (ucs4_t uc);
+       uc_is_cased (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Determine whether a character is "case-ignorable"
    according to the Unicode Standard,
    <http://www.unicode.org/versions/Unicode5.0.0/ch03.pdf>, section 3.13,
    definition D121.  */
 extern bool
-       uc_is_case_ignorable (ucs4_t uc);
+       uc_is_case_ignorable (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
index 55ce822..db34b4d 100644 (file)
@@ -205,29 +205,35 @@ extern uc_general_category_t
 
 /* Return the name of a general category.  */
 extern const char *
-       uc_general_category_name (uc_general_category_t category);
+       uc_general_category_name (uc_general_category_t category)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the long name of a general category.  */
 extern const char *
-       uc_general_category_long_name (uc_general_category_t category);
+       uc_general_category_long_name (uc_general_category_t category)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the general category given by name, e.g. "Lu", or by long name,
    e.g. "Uppercase Letter".  */
 extern uc_general_category_t
-       uc_general_category_byname (const char *category_name);
+       uc_general_category_byname (const char *category_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the general category of a Unicode character.  */
 extern uc_general_category_t
-       uc_general_category (ucs4_t uc);
+       uc_general_category (ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 
 /* Test whether a Unicode character belongs to a given category.
    The CATEGORY argument can be the combination of several predefined
    general categories.  */
 extern bool
-       uc_is_general_category (ucs4_t uc, uc_general_category_t category);
+       uc_is_general_category (ucs4_t uc, uc_general_category_t category)
+       _UC_ATTRIBUTE_PURE;
 /* Likewise.  This function uses a big table comprising all categories.  */
 extern bool
-       uc_is_general_category_withtable (ucs4_t uc, uint32_t bitmask);
+       uc_is_general_category_withtable (ucs4_t uc, uint32_t bitmask)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -262,20 +268,24 @@ enum
 
 /* Return the canonical combining class of a Unicode character.  */
 extern int
-       uc_combining_class (ucs4_t uc);
+       uc_combining_class (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the name of a canonical combining class.  */
 extern const char *
-       uc_combining_class_name (int ccc);
+       uc_combining_class_name (int ccc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the long name of a canonical combining class.  */
 extern const char *
-       uc_combining_class_long_name (int ccc);
+       uc_combining_class_long_name (int ccc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the canonical combining class given by name, e.g. "BL", or by long
    name, e.g. "Below Left".  */
 extern int
-       uc_combining_class_byname (const char *ccc_name);
+       uc_combining_class_byname (const char *ccc_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* ========================================================================= */
 
@@ -307,36 +317,45 @@ enum
 
 /* Return the name of a bidi class.  */
 extern const char *
-       uc_bidi_class_name (int bidi_class);
+       uc_bidi_class_name (int bidi_class)
+       _UC_ATTRIBUTE_CONST;
 /* Same; obsolete function name.  */
 extern const char *
-       uc_bidi_category_name (int category);
+       uc_bidi_category_name (int category)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the long name of a bidi class.  */
 extern const char *
-       uc_bidi_class_long_name (int bidi_class);
+       uc_bidi_class_long_name (int bidi_class)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the bidi class given by name, e.g. "LRE", or by long name, e.g.
    "Left-to-Right Embedding".  */
 extern int
-       uc_bidi_class_byname (const char *bidi_class_name);
+       uc_bidi_class_byname (const char *bidi_class_name)
+       _UC_ATTRIBUTE_PURE;
 /* Same; obsolete function name.  */
 extern int
-       uc_bidi_category_byname (const char *category_name);
+       uc_bidi_category_byname (const char *category_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the bidi class of a Unicode character.  */
 extern int
-       uc_bidi_class (ucs4_t uc);
+       uc_bidi_class (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 /* Same; obsolete function name.  */
 extern int
-       uc_bidi_category (ucs4_t uc);
+       uc_bidi_category (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test whether a Unicode character belongs to a given bidi class.  */
 extern bool
-       uc_is_bidi_class (ucs4_t uc, int bidi_class);
+       uc_is_bidi_class (ucs4_t uc, int bidi_class)
+       _UC_ATTRIBUTE_CONST;
 /* Same; obsolete function name.  */
 extern bool
-       uc_is_bidi_category (ucs4_t uc, int category);
+       uc_is_bidi_category (ucs4_t uc, int category)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -349,7 +368,8 @@ extern bool
 
 /* Return the decimal digit value of a Unicode character.  */
 extern int
-       uc_decimal_value (ucs4_t uc);
+       uc_decimal_value (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -357,7 +377,8 @@ extern int
 
 /* Return the digit value of a Unicode character.  */
 extern int
-       uc_digit_value (ucs4_t uc);
+       uc_digit_value (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -371,7 +392,8 @@ typedef struct
 }
 uc_fraction_t;
 extern uc_fraction_t
-       uc_numeric_value (ucs4_t uc);
+       uc_numeric_value (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -413,20 +435,24 @@ enum
 
 /* Return the name of a joining type.  */
 extern const char *
-       uc_joining_type_name (int joining_type);
+       uc_joining_type_name (int joining_type)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the long name of a joining type.  */
 extern const char *
-       uc_joining_type_long_name (int joining_type);
+       uc_joining_type_long_name (int joining_type)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the joining type given by name, e.g. "D", or by long name, e.g.
    "Dual Joining".  */
 extern int
-       uc_joining_type_byname (const char *joining_type_name);
+       uc_joining_type_byname (const char *joining_type_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the joining type of a Unicode character.  */
 extern int
-       uc_joining_type (ucs4_t uc);
+       uc_joining_type (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -497,15 +523,18 @@ enum
 
 /* Return the name of a joining group.  */
 extern const char *
-       uc_joining_group_name (int joining_group);
+       uc_joining_group_name (int joining_group)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the joining group given by name, e.g. "Teh_Marbuta".  */
 extern int
-       uc_joining_group_byname (const char *joining_group_name);
+       uc_joining_group_byname (const char *joining_group_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the joining group of a Unicode character.  */
 extern int
-       uc_joining_group (ucs4_t uc);
+       uc_joining_group (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -626,92 +655,178 @@ extern uc_property_t
 /* Test whether a Unicode character has a given property.  */
 extern bool
        uc_is_property (ucs4_t uc, uc_property_t property);
-extern bool uc_is_property_white_space (ucs4_t uc);
-extern bool uc_is_property_alphabetic (ucs4_t uc);
-extern bool uc_is_property_other_alphabetic (ucs4_t uc);
-extern bool uc_is_property_not_a_character (ucs4_t uc);
-extern bool uc_is_property_default_ignorable_code_point (ucs4_t uc);
-extern bool uc_is_property_other_default_ignorable_code_point (ucs4_t uc);
-extern bool uc_is_property_deprecated (ucs4_t uc);
-extern bool uc_is_property_logical_order_exception (ucs4_t uc);
-extern bool uc_is_property_variation_selector (ucs4_t uc);
-extern bool uc_is_property_private_use (ucs4_t uc);
-extern bool uc_is_property_unassigned_code_value (ucs4_t uc);
-extern bool uc_is_property_uppercase (ucs4_t uc);
-extern bool uc_is_property_other_uppercase (ucs4_t uc);
-extern bool uc_is_property_lowercase (ucs4_t uc);
-extern bool uc_is_property_other_lowercase (ucs4_t uc);
-extern bool uc_is_property_titlecase (ucs4_t uc);
-extern bool uc_is_property_cased (ucs4_t uc);
-extern bool uc_is_property_case_ignorable (ucs4_t uc);
-extern bool uc_is_property_changes_when_lowercased (ucs4_t uc);
-extern bool uc_is_property_changes_when_uppercased (ucs4_t uc);
-extern bool uc_is_property_changes_when_titlecased (ucs4_t uc);
-extern bool uc_is_property_changes_when_casefolded (ucs4_t uc);
-extern bool uc_is_property_changes_when_casemapped (ucs4_t uc);
-extern bool uc_is_property_soft_dotted (ucs4_t uc);
-extern bool uc_is_property_id_start (ucs4_t uc);
-extern bool uc_is_property_other_id_start (ucs4_t uc);
-extern bool uc_is_property_id_continue (ucs4_t uc);
-extern bool uc_is_property_other_id_continue (ucs4_t uc);
-extern bool uc_is_property_xid_start (ucs4_t uc);
-extern bool uc_is_property_xid_continue (ucs4_t uc);
-extern bool uc_is_property_pattern_white_space (ucs4_t uc);
-extern bool uc_is_property_pattern_syntax (ucs4_t uc);
-extern bool uc_is_property_join_control (ucs4_t uc);
-extern bool uc_is_property_grapheme_base (ucs4_t uc);
-extern bool uc_is_property_grapheme_extend (ucs4_t uc);
-extern bool uc_is_property_other_grapheme_extend (ucs4_t uc);
-extern bool uc_is_property_grapheme_link (ucs4_t uc);
-extern bool uc_is_property_bidi_control (ucs4_t uc);
-extern bool uc_is_property_bidi_left_to_right (ucs4_t uc);
-extern bool uc_is_property_bidi_hebrew_right_to_left (ucs4_t uc);
-extern bool uc_is_property_bidi_arabic_right_to_left (ucs4_t uc);
-extern bool uc_is_property_bidi_european_digit (ucs4_t uc);
-extern bool uc_is_property_bidi_eur_num_separator (ucs4_t uc);
-extern bool uc_is_property_bidi_eur_num_terminator (ucs4_t uc);
-extern bool uc_is_property_bidi_arabic_digit (ucs4_t uc);
-extern bool uc_is_property_bidi_common_separator (ucs4_t uc);
-extern bool uc_is_property_bidi_block_separator (ucs4_t uc);
-extern bool uc_is_property_bidi_segment_separator (ucs4_t uc);
-extern bool uc_is_property_bidi_whitespace (ucs4_t uc);
-extern bool uc_is_property_bidi_non_spacing_mark (ucs4_t uc);
-extern bool uc_is_property_bidi_boundary_neutral (ucs4_t uc);
-extern bool uc_is_property_bidi_pdf (ucs4_t uc);
-extern bool uc_is_property_bidi_embedding_or_override (ucs4_t uc);
-extern bool uc_is_property_bidi_other_neutral (ucs4_t uc);
-extern bool uc_is_property_hex_digit (ucs4_t uc);
-extern bool uc_is_property_ascii_hex_digit (ucs4_t uc);
-extern bool uc_is_property_ideographic (ucs4_t uc);
-extern bool uc_is_property_unified_ideograph (ucs4_t uc);
-extern bool uc_is_property_radical (ucs4_t uc);
-extern bool uc_is_property_ids_binary_operator (ucs4_t uc);
-extern bool uc_is_property_ids_trinary_operator (ucs4_t uc);
-extern bool uc_is_property_zero_width (ucs4_t uc);
-extern bool uc_is_property_space (ucs4_t uc);
-extern bool uc_is_property_non_break (ucs4_t uc);
-extern bool uc_is_property_iso_control (ucs4_t uc);
-extern bool uc_is_property_format_control (ucs4_t uc);
-extern bool uc_is_property_dash (ucs4_t uc);
-extern bool uc_is_property_hyphen (ucs4_t uc);
-extern bool uc_is_property_punctuation (ucs4_t uc);
-extern bool uc_is_property_line_separator (ucs4_t uc);
-extern bool uc_is_property_paragraph_separator (ucs4_t uc);
-extern bool uc_is_property_quotation_mark (ucs4_t uc);
-extern bool uc_is_property_sentence_terminal (ucs4_t uc);
-extern bool uc_is_property_terminal_punctuation (ucs4_t uc);
-extern bool uc_is_property_currency_symbol (ucs4_t uc);
-extern bool uc_is_property_math (ucs4_t uc);
-extern bool uc_is_property_other_math (ucs4_t uc);
-extern bool uc_is_property_paired_punctuation (ucs4_t uc);
-extern bool uc_is_property_left_of_pair (ucs4_t uc);
-extern bool uc_is_property_combining (ucs4_t uc);
-extern bool uc_is_property_composite (ucs4_t uc);
-extern bool uc_is_property_decimal_digit (ucs4_t uc);
-extern bool uc_is_property_numeric (ucs4_t uc);
-extern bool uc_is_property_diacritic (ucs4_t uc);
-extern bool uc_is_property_extender (ucs4_t uc);
-extern bool uc_is_property_ignorable_control (ucs4_t uc);
+extern bool uc_is_property_white_space (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_alphabetic (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_alphabetic (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_not_a_character (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_default_ignorable_code_point (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_default_ignorable_code_point (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_deprecated (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_logical_order_exception (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_variation_selector (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_private_use (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_unassigned_code_value (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_uppercase (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_uppercase (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_lowercase (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_lowercase (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_titlecase (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_cased (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_case_ignorable (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_changes_when_lowercased (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_changes_when_uppercased (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_changes_when_titlecased (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_changes_when_casefolded (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_changes_when_casemapped (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_soft_dotted (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_id_start (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_id_start (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_id_continue (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_id_continue (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_xid_start (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_xid_continue (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_pattern_white_space (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_pattern_syntax (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_join_control (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_grapheme_base (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_grapheme_extend (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_grapheme_extend (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_grapheme_link (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_control (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_left_to_right (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_hebrew_right_to_left (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_arabic_right_to_left (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_european_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_eur_num_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_eur_num_terminator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_arabic_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_common_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_block_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_segment_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_whitespace (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_non_spacing_mark (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_boundary_neutral (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_pdf (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_embedding_or_override (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_bidi_other_neutral (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_hex_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_ascii_hex_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_ideographic (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_unified_ideograph (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_radical (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_ids_binary_operator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_ids_trinary_operator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_zero_width (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_space (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_non_break (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_iso_control (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_format_control (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_dash (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_hyphen (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_punctuation (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_line_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_paragraph_separator (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_quotation_mark (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_sentence_terminal (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_terminal_punctuation (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_currency_symbol (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_math (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_other_math (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_paired_punctuation (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_left_of_pair (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_combining (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_composite (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_decimal_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_numeric (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_diacritic (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_extender (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
+extern bool uc_is_property_ignorable_control (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -734,15 +849,18 @@ uc_script_t;
 
 /* Return the script of a Unicode character.  */
 extern const uc_script_t *
-       uc_script (ucs4_t uc);
+       uc_script (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the script given by name, e.g. "HAN".  */
 extern const uc_script_t *
-       uc_script_byname (const char *script_name);
+       uc_script_byname (const char *script_name)
+       _UC_ATTRIBUTE_PURE;
 
 /* Test whether a Unicode character belongs to a given script.  */
 extern bool
-       uc_is_script (ucs4_t uc, const uc_script_t *script);
+       uc_is_script (ucs4_t uc, const uc_script_t *script)
+       _UC_ATTRIBUTE_PURE;
 
 /* Get the list of all scripts.  */
 extern void
@@ -762,11 +880,13 @@ uc_block_t;
 
 /* Return the block a character belongs to.  */
 extern const uc_block_t *
-       uc_block (ucs4_t uc);
+       uc_block (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test whether a Unicode character belongs to a given block.  */
 extern bool
-       uc_is_block (ucs4_t uc, const uc_block_t *block);
+       uc_is_block (ucs4_t uc, const uc_block_t *block)
+       _UC_ATTRIBUTE_PURE;
 
 /* Get the list of all blocks.  */
 extern void
@@ -778,11 +898,13 @@ extern void
 
 /* Test whether a Unicode character is considered whitespace in ISO C 99.  */
 extern bool
-       uc_is_c_whitespace (ucs4_t uc);
+       uc_is_c_whitespace (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test whether a Unicode character is considered whitespace in Java.  */
 extern bool
-       uc_is_java_whitespace (ucs4_t uc);
+       uc_is_java_whitespace (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 enum
 {
@@ -795,12 +917,14 @@ enum
 /* Return the categorization of a Unicode character w.r.t. the ISO C 99
    identifier syntax.  */
 extern int
-       uc_c_ident_category (ucs4_t uc);
+       uc_c_ident_category (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Return the categorization of a Unicode character w.r.t. the Java
    identifier syntax.  */
 extern int
-       uc_java_ident_category (ucs4_t uc);
+       uc_java_ident_category (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -812,65 +936,77 @@ extern int
 
 /* Test for any character for which 'uc_is_alpha' or 'uc_is_digit' is true.  */
 extern bool
-       uc_is_alnum (ucs4_t uc);
+       uc_is_alnum (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character for which 'uc_is_upper' or 'uc_is_lower' is true,
    or any character that is one of a locale-specific set of characters for
    which none of 'uc_is_cntrl', 'uc_is_digit', 'uc_is_punct', or 'uc_is_space'
    is true.  */
 extern bool
-       uc_is_alpha (ucs4_t uc);
+       uc_is_alpha (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any control character.  */
 extern bool
-       uc_is_cntrl (ucs4_t uc);
+       uc_is_cntrl (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character that corresponds to a decimal-digit character.  */
 extern bool
-       uc_is_digit (ucs4_t uc);
+       uc_is_digit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character for which 'uc_is_print' is true and 'uc_is_space'
    is false.  */
 extern bool
-       uc_is_graph (ucs4_t uc);
+       uc_is_graph (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character that corresponds to a lowercase letter or is one
    of a locale-specific set of characters for which none of 'uc_is_cntrl',
    'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true.  */
 extern bool
-       uc_is_lower (ucs4_t uc);
+       uc_is_lower (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any printing character.  */
 extern bool
-       uc_is_print (ucs4_t uc);
+       uc_is_print (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any printing character that is one of a locale-specific set of
    characters for which neither 'uc_is_space' nor 'uc_is_alnum' is true.  */
 extern bool
-       uc_is_punct (ucs4_t uc);
+       uc_is_punct (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character that corresponds to a locale-specific set of
    characters for which none of 'uc_is_alnum', 'uc_is_graph', or 'uc_is_punct'
    is true.  */
 extern bool
-       uc_is_space (ucs4_t uc);
+       uc_is_space (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character that corresponds to an uppercase letter or is one
    of a locale-specific set of character for which none of 'uc_is_cntrl',
    'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true.  */
 extern bool
-       uc_is_upper (ucs4_t uc);
+       uc_is_upper (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* Test for any character that corresponds to a hexadecimal-digit
    character.  */
 extern bool
-       uc_is_xdigit (ucs4_t uc);
+       uc_is_xdigit (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* GNU extension. */
 /* Test for any character that corresponds to a standard blank character or
    a locale-specific set of characters for which 'uc_is_alnum' is false.  */
 extern bool
-       uc_is_blank (ucs4_t uc);
+       uc_is_blank (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
index 0f21d34..fc088a3 100644 (file)
@@ -56,7 +56,8 @@ enum
 
 /* Return the Grapheme_Cluster_Break property of a Unicode character. */
 extern int
-       uc_graphemeclusterbreak_property (ucs4_t uc);
+       uc_graphemeclusterbreak_property (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
@@ -76,25 +77,32 @@ extern int
    Use A == 0 or B == 0 to indicate start of text or end of text,
    respectively. */
 extern bool
-       uc_is_grapheme_break (ucs4_t a, ucs4_t b);
+       uc_is_grapheme_break (ucs4_t a, ucs4_t b)
+       _UC_ATTRIBUTE_CONST;
 
 /* Returns the start of the next grapheme cluster following S, or NULL if the
    end of the string has been reached. */
 extern const uint8_t *
-       u8_grapheme_next (const uint8_t *s, const uint8_t *end);
+       u8_grapheme_next (const uint8_t *s, const uint8_t *end)
+       _UC_ATTRIBUTE_PURE;
 extern const uint16_t *
-       u16_grapheme_next (const uint16_t *s, const uint16_t *end);
+       u16_grapheme_next (const uint16_t *s, const uint16_t *end)
+       _UC_ATTRIBUTE_PURE;
 extern const uint32_t *
-       u32_grapheme_next (const uint32_t *s, const uint32_t *end);
+       u32_grapheme_next (const uint32_t *s, const uint32_t *end)
+       _UC_ATTRIBUTE_PURE;
 
 /* Returns the start of the previous grapheme cluster before S, or NULL if the
    start of the string has been reached. */
 extern const uint8_t *
-       u8_grapheme_prev (const uint8_t *s, const uint8_t *start);
+       u8_grapheme_prev (const uint8_t *s, const uint8_t *start)
+       _UC_ATTRIBUTE_PURE;
 extern const uint16_t *
-       u16_grapheme_prev (const uint16_t *s, const uint16_t *start);
+       u16_grapheme_prev (const uint16_t *s, const uint16_t *start)
+       _UC_ATTRIBUTE_PURE;
 extern const uint32_t *
-       u32_grapheme_prev (const uint32_t *s, const uint32_t *start);
+       u32_grapheme_prev (const uint32_t *s, const uint32_t *start)
+       _UC_ATTRIBUTE_PURE;
 
 /* Determine the grapheme cluster boundaries in S, and store the result at
    p[0..n-1].  p[i] = 1 means that a new grapheme cluster begins at s[i].  p[i]
index 331fd14..16a4448 100644 (file)
@@ -35,7 +35,8 @@ extern char *
 /* Looks up the Unicode character with a given name, in upper- or lowercase
    ASCII.  Returns the character if found, or UNINAME_INVALID if not found.  */
 extern ucs4_t
-       unicode_name_character (const char *name);
+       unicode_name_character (const char *name)
+       _UC_ATTRIBUTE_PURE;
 #define UNINAME_INVALID ((ucs4_t) 0xFFFF)
 
 #ifdef __cplusplus
index 8a6707a..c273d26 100644 (file)
@@ -99,7 +99,8 @@ extern int
    Not all decompositions can be recombined using this function.  See the
    Unicode file CompositionExclusions.txt for details.  */
 extern ucs4_t
-       uc_composition (ucs4_t uc1, ucs4_t uc2);
+       uc_composition (ucs4_t uc1, ucs4_t uc2)
+       _UC_ATTRIBUTE_CONST;
 
 
 /* An object of type uninorm_t denotes a Unicode normalization form.  */
@@ -134,7 +135,9 @@ extern const struct unicode_normalization_form uninorm_nfkc;
 
 /* Return the decomposing variant of a normalization form.
    This maps NFC,NFD -> NFD and NFKC,NFKD -> NFKD.  */
-extern uninorm_t uninorm_decomposing_form (uninorm_t nf);
+extern uninorm_t
+       uninorm_decomposing_form (uninorm_t nf)
+       _UC_ATTRIBUTE_PURE;
 
 
 /* Return the specified normalization form of a string.  */
index 83aeeee..2706789 100644 (file)
@@ -66,17 +66,20 @@ extern "C" {
 /* Check whether an UTF-8 string is well-formed.
    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
 extern const uint8_t *
-       u8_check (const uint8_t *s, size_t n);
+       u8_check (const uint8_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Check whether an UTF-16 string is well-formed.
    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
 extern const uint16_t *
-       u16_check (const uint16_t *s, size_t n);
+       u16_check (const uint16_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Check whether an UCS-4 string is well-formed.
    Return NULL if valid, or a pointer to the first invalid unit otherwise.  */
 extern const uint32_t *
-       u32_check (const uint32_t *s, size_t n);
+       u32_check (const uint32_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 
 /* Elementary string conversions.  */
@@ -119,11 +122,14 @@ extern uint16_t *
    failure.  */
 /* Similar to mblen(), except that s must not be NULL.  */
 extern int
-       u8_mblen (const uint8_t *s, size_t n);
+       u8_mblen (const uint8_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_mblen (const uint16_t *s, size_t n);
+       u16_mblen (const uint16_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_mblen (const uint32_t *s, size_t n);
+       u32_mblen (const uint32_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the length (number of units) of the first character in S, putting
    its 'ucs4_t' representation in *PUC.  Upon failure, *PUC is set to 0xfffd,
@@ -400,38 +406,50 @@ extern uint32_t *
 /* Compare S1 and S2, each of length N.  */
 /* Similar to memcmp().  */
 extern int
-       u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n);
+       u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n);
+       u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n);
+       u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Compare S1 and S2.  */
 /* Similar to the gnulib function memcmp2().  */
 extern int
-       u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
+       u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
+       u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
+       u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2)
+       _UC_ATTRIBUTE_PURE;
 
 /* Search the string at S for UC.  */
 /* Similar to memchr().  */
 extern uint8_t *
-       u8_chr (const uint8_t *s, size_t n, ucs4_t uc);
+       u8_chr (const uint8_t *s, size_t n, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint16_t *
-       u16_chr (const uint16_t *s, size_t n, ucs4_t uc);
+       u16_chr (const uint16_t *s, size_t n, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint32_t *
-       u32_chr (const uint32_t *s, size_t n, ucs4_t uc);
+       u32_chr (const uint32_t *s, size_t n, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 
 /* Count the number of Unicode characters in the N units from S.  */
 /* Similar to mbsnlen().  */
 extern size_t
-       u8_mbsnlen (const uint8_t *s, size_t n);
+       u8_mbsnlen (const uint8_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u16_mbsnlen (const uint16_t *s, size_t n);
+       u16_mbsnlen (const uint16_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u32_mbsnlen (const uint32_t *s, size_t n);
+       u32_mbsnlen (const uint32_t *s, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Elementary string functions with memory allocation.  */
 
@@ -448,11 +466,14 @@ extern uint32_t *
 /* Return the length (number of units) of the first character in S.
    Return 0 if it is the NUL character.  Return -1 upon failure.  */
 extern int
-       u8_strmblen (const uint8_t *s);
+       u8_strmblen (const uint8_t *s)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_strmblen (const uint16_t *s);
+       u16_strmblen (const uint16_t *s)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_strmblen (const uint32_t *s);
+       u32_strmblen (const uint32_t *s)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the length (number of units) of the first character in S, putting
    its 'ucs4_t' representation in *PUC.  Return 0 if it is the NUL
@@ -487,20 +508,26 @@ extern const uint32_t *
 /* Return the number of units in S.  */
 /* Similar to strlen(), wcslen().  */
 extern size_t
-       u8_strlen (const uint8_t *s);
+       u8_strlen (const uint8_t *s)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u16_strlen (const uint16_t *s);
+       u16_strlen (const uint16_t *s)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u32_strlen (const uint32_t *s);
+       u32_strlen (const uint32_t *s)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the number of units in S, but at most MAXLEN.  */
 /* Similar to strnlen(), wcsnlen().  */
 extern size_t
-       u8_strnlen (const uint8_t *s, size_t maxlen);
+       u8_strnlen (const uint8_t *s, size_t maxlen)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u16_strnlen (const uint16_t *s, size_t maxlen);
+       u16_strnlen (const uint16_t *s, size_t maxlen)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u32_strnlen (const uint32_t *s, size_t maxlen);
+       u32_strnlen (const uint32_t *s, size_t maxlen)
+       _UC_ATTRIBUTE_PURE;
 
 /* Copy SRC to DEST.  */
 /* Similar to strcpy(), wcscpy().  */
@@ -562,16 +589,20 @@ extern uint32_t *
 #ifdef __sun
 /* Avoid a collision with the u8_strcmp() function in Solaris 11 libc.  */
 extern int
-       u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2);
+       u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2)
+       _UC_ATTRIBUTE_PURE;
 # define u8_strcmp u8_strcmp_gnu
 #else
 extern int
-       u8_strcmp (const uint8_t *s1, const uint8_t *s2);
+       u8_strcmp (const uint8_t *s1, const uint8_t *s2)
+       _UC_ATTRIBUTE_PURE;
 #endif
 extern int
-       u16_strcmp (const uint16_t *s1, const uint16_t *s2);
+       u16_strcmp (const uint16_t *s1, const uint16_t *s2)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_strcmp (const uint32_t *s1, const uint32_t *s2);
+       u32_strcmp (const uint32_t *s1, const uint32_t *s2)
+       _UC_ATTRIBUTE_PURE;
 
 /* Compare S1 and S2 using the collation rules of the current locale.
    Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2.
@@ -587,11 +618,14 @@ extern int
 /* Compare no more than N units of S1 and S2.  */
 /* Similar to strncmp(), wcsncmp().  */
 extern int
-       u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n);
+       u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n);
+       u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n);
+       u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n)
+       _UC_ATTRIBUTE_PURE;
 
 /* Duplicate S, returning an identical malloc'd string.  */
 /* Similar to strdup(), wcsdup().  */
@@ -605,74 +639,98 @@ extern uint32_t *
 /* Find the first occurrence of UC in STR.  */
 /* Similar to strchr(), wcschr().  */
 extern uint8_t *
-       u8_strchr (const uint8_t *str, ucs4_t uc);
+       u8_strchr (const uint8_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint16_t *
-       u16_strchr (const uint16_t *str, ucs4_t uc);
+       u16_strchr (const uint16_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint32_t *
-       u32_strchr (const uint32_t *str, ucs4_t uc);
+       u32_strchr (const uint32_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 
 /* Find the last occurrence of UC in STR.  */
 /* Similar to strrchr(), wcsrchr().  */
 extern uint8_t *
-       u8_strrchr (const uint8_t *str, ucs4_t uc);
+       u8_strrchr (const uint8_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint16_t *
-       u16_strrchr (const uint16_t *str, ucs4_t uc);
+       u16_strrchr (const uint16_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 extern uint32_t *
-       u32_strrchr (const uint32_t *str, ucs4_t uc);
+       u32_strrchr (const uint32_t *str, ucs4_t uc)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the length of the initial segment of STR which consists entirely
    of Unicode characters not in REJECT.  */
 /* Similar to strcspn(), wcscspn().  */
 extern size_t
-       u8_strcspn (const uint8_t *str, const uint8_t *reject);
+       u8_strcspn (const uint8_t *str, const uint8_t *reject)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u16_strcspn (const uint16_t *str, const uint16_t *reject);
+       u16_strcspn (const uint16_t *str, const uint16_t *reject)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u32_strcspn (const uint32_t *str, const uint32_t *reject);
+       u32_strcspn (const uint32_t *str, const uint32_t *reject)
+       _UC_ATTRIBUTE_PURE;
 
 /* Return the length of the initial segment of STR which consists entirely
    of Unicode characters in ACCEPT.  */
 /* Similar to strspn(), wcsspn().  */
 extern size_t
-       u8_strspn (const uint8_t *str, const uint8_t *accept);
+       u8_strspn (const uint8_t *str, const uint8_t *accept)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u16_strspn (const uint16_t *str, const uint16_t *accept);
+       u16_strspn (const uint16_t *str, const uint16_t *accept)
+       _UC_ATTRIBUTE_PURE;
 extern size_t
-       u32_strspn (const uint32_t *str, const uint32_t *accept);
+       u32_strspn (const uint32_t *str, const uint32_t *accept)
+       _UC_ATTRIBUTE_PURE;
 
 /* Find the first occurrence in STR of any character in ACCEPT.  */
 /* Similar to strpbrk(), wcspbrk().  */
 extern uint8_t *
-       u8_strpbrk (const uint8_t *str, const uint8_t *accept);
+       u8_strpbrk (const uint8_t *str, const uint8_t *accept)
+       _UC_ATTRIBUTE_PURE;
 extern uint16_t *
-       u16_strpbrk (const uint16_t *str, const uint16_t *accept);
+       u16_strpbrk (const uint16_t *str, const uint16_t *accept)
+       _UC_ATTRIBUTE_PURE;
 extern uint32_t *
-       u32_strpbrk (const uint32_t *str, const uint32_t *accept);
+       u32_strpbrk (const uint32_t *str, const uint32_t *accept)
+       _UC_ATTRIBUTE_PURE;
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
 /* Similar to strstr(), wcsstr().  */
 extern uint8_t *
-       u8_strstr (const uint8_t *haystack, const uint8_t *needle);
+       u8_strstr (const uint8_t *haystack, const uint8_t *needle)
+       _UC_ATTRIBUTE_PURE;
 extern uint16_t *
-       u16_strstr (const uint16_t *haystack, const uint16_t *needle);
+       u16_strstr (const uint16_t *haystack, const uint16_t *needle)
+       _UC_ATTRIBUTE_PURE;
 extern uint32_t *
-       u32_strstr (const uint32_t *haystack, const uint32_t *needle);
+       u32_strstr (const uint32_t *haystack, const uint32_t *needle)
+       _UC_ATTRIBUTE_PURE;
 
 /* Test whether STR starts with PREFIX.  */
 extern bool
-       u8_startswith (const uint8_t *str, const uint8_t *prefix);
+       u8_startswith (const uint8_t *str, const uint8_t *prefix)
+       _UC_ATTRIBUTE_PURE;
 extern bool
-       u16_startswith (const uint16_t *str, const uint16_t *prefix);
+       u16_startswith (const uint16_t *str, const uint16_t *prefix)
+       _UC_ATTRIBUTE_PURE;
 extern bool
-       u32_startswith (const uint32_t *str, const uint32_t *prefix);
+       u32_startswith (const uint32_t *str, const uint32_t *prefix)
+       _UC_ATTRIBUTE_PURE;
 
 /* Test whether STR ends with SUFFIX.  */
 extern bool
-       u8_endswith (const uint8_t *str, const uint8_t *suffix);
+       u8_endswith (const uint8_t *str, const uint8_t *suffix)
+       _UC_ATTRIBUTE_PURE;
 extern bool
-       u16_endswith (const uint16_t *str, const uint16_t *suffix);
+       u16_endswith (const uint16_t *str, const uint16_t *suffix)
+       _UC_ATTRIBUTE_PURE;
 extern bool
-       u32_endswith (const uint32_t *str, const uint32_t *suffix);
+       u32_endswith (const uint32_t *str, const uint32_t *suffix)
+       _UC_ATTRIBUTE_PURE;
 
 /* Divide STR into tokens separated by characters in DELIM.
    This interface is actually more similar to wcstok than to strtok.  */
index c1204e1..c588589 100644 (file)
@@ -1,4 +1,4 @@
-/* Elementary types for the GNU UniString library.
+/* Elementary types and macros for the GNU UniString library.
    Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
 /* Type representing a Unicode character.  */
 typedef uint32_t ucs4_t;
 
+/* Attribute of a function whose result depends only on the arguments
+   (not pointers!) and which has no side effects.  */
+#ifndef _UC_ATTRIBUTE_CONST
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+#  define _UC_ATTRIBUTE_CONST __attribute__ ((__const__))
+# else
+#  define _UC_ATTRIBUTE_CONST
+# endif
+#endif
+
+/* Attribute of a function whose result depends only on the arguments
+   (possibly pointers) and global memory, and which has no side effects.  */
+#ifndef _UC_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+#  define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _UC_ATTRIBUTE_PURE
+# endif
+#endif
+
 #endif /* _UNITYPES_H */
index a4a68a8..37d4498 100644 (file)
@@ -54,7 +54,8 @@ enum
 
 /* Return the Word_Break property of a Unicode character.  */
 extern int
-       uc_wordbreak_property (ucs4_t uc);
+       uc_wordbreak_property (ucs4_t uc)
+       _UC_ATTRIBUTE_CONST;
 
 /* ========================================================================= */
 
index 39f4dcd..126efbb 100644 (file)
@@ -39,27 +39,30 @@ extern "C" {
 /* Determine number of column positions required for UC.  */
 extern int
        uc_width (ucs4_t uc, const char *encoding)
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-       __attribute__ ((__pure__))
-#endif
-       ;
+       _UC_ATTRIBUTE_PURE;
 
 /* Determine number of column positions required for first N units
    (or fewer if S ends before this) in S.  */
 extern int
-       u8_width (const uint8_t *s, size_t n, const char *encoding);
+       u8_width (const uint8_t *s, size_t n, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_width (const uint16_t *s, size_t n, const char *encoding);
+       u16_width (const uint16_t *s, size_t n, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_width (const uint32_t *s, size_t n, const char *encoding);
+       u32_width (const uint32_t *s, size_t n, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 
 /* Determine number of column positions required for S.  */
 extern int
-       u8_strwidth (const uint8_t *s, const char *encoding);
+       u8_strwidth (const uint8_t *s, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u16_strwidth (const uint16_t *s, const char *encoding);
+       u16_strwidth (const uint16_t *s, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 extern int
-       u32_strwidth (const uint32_t *s, const char *encoding);
+       u32_strwidth (const uint32_t *s, const char *encoding)
+       _UC_ATTRIBUTE_PURE;
 
 
 #ifdef __cplusplus