Coverage Report

Created: 2026-12-01 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libunistring/lib/unicase/ignorable.c
Line
Count
Source
1
/* Test whether a Unicode character is case-ignorable.
2
   Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5
   This file is free software.
6
   It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
7
   You can redistribute it and/or modify it under either
8
     - the terms of the GNU Lesser General Public License as published
9
       by the Free Software Foundation, either version 3, or (at your
10
       option) any later version, or
11
     - the terms of the GNU General Public License as published by the
12
       Free Software Foundation; either version 2, or (at your option)
13
       any later version, or
14
     - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
15
16
   This file is distributed in the hope that it will be useful,
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19
   Lesser General Public License and the GNU General Public License
20
   for more details.
21
22
   You should have received a copy of the GNU Lesser General Public
23
   License and of the GNU General Public License along with this
24
   program.  If not, see <https://www.gnu.org/licenses/>.  */
25
26
#include <config.h>
27
28
/* Specification.  */
29
#include "caseprop.h"
30
31
/* Quoting the Unicode standard:
32
     Definition: A character is defined to be "case-ignorable" if it has the
33
     value MidLetter or MidNumLet or Single_Quote for the Word_Break property or
34
     its General_Category is one of Nonspacing_Mark (Mn), Enclosing_Mark (Me),
35
     Format (Cf), Modifier_Letter (Lm), or Modifier_Symbol (Sk).
36
   The value MidNumLet was added in Unicode 5.1.0, see
37
   <https://www.unicode.org/versions/Unicode5.1.0/> section "Update of
38
   Definition of case-ignorable".
39
   The value Single_Quote was added in Unicode 6.3.0, see
40
   <https://www.unicode.org/versions/Unicode7.0.0/#Conformance_Changes> and
41
   <https://www.unicode.org/versions/Unicode6.3.0/#Conformance_Changes>.
42
   */
43
/* Since this predicate is only used for the "Before C" and "After C"
44
   conditions of FINAL_SIGMA, we exclude the "cased" characters here.
45
   This simplifies the evaluation of the regular expressions
46
     \p{cased} (\p{case-ignorable})* C
47
   and
48
     C (\p{case-ignorable})* \p{cased}
49
 */
50
51
#if 0
52
53
#include "unictype.h"
54
#include "uniwbrk.h"
55
56
bool
57
uc_is_case_ignorable (ucs4_t uc)
58
{
59
  int wbp = uc_wordbreak_property (uc);
60
61
  return (wbp == WBP_MIDLETTER || wbp == WBP_MIDNUMLET || wbp == WBP_SQ
62
          || uc_is_general_category_withtable (uc, UC_CATEGORY_MASK_Mn
63
                                                   | UC_CATEGORY_MASK_Me
64
                                                   | UC_CATEGORY_MASK_Cf
65
                                                   | UC_CATEGORY_MASK_Lm
66
                                                   | UC_CATEGORY_MASK_Sk))
67
         && !uc_is_cased (uc);
68
}
69
70
#else
71
72
#include "unictype/bitmap.h"
73
74
/* Define u_casing_property_case_ignorable table.  */
75
#include "ignorable.h"
76
77
bool
78
uc_is_case_ignorable (ucs4_t uc)
79
20.6M
{
80
20.6M
  return bitmap_lookup (&u_casing_property_case_ignorable, uc);
81
20.6M
}
82
83
#endif