Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gettext/gettext-tools/libgettextpo/unilbrk/lbrktables.h
Line
Count
Source
1
/* Line breaking auxiliary tables.
2
   Copyright (C) 2001-2003, 2006-2026 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2001.
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 "unitypes.h"
27
28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31
32
33
/* Line breaking classification.  */
34
35
enum
36
{
37
  /* Values >= 43 are resolved at run time. */
38
  LBP_BK  = 43, /* mandatory break */
39
  LBP_CR  = 44, /* carriage return */
40
  LBP_LF  = 45, /* line feed */
41
  LBP_CM  = 46, /* attached characters and combining marks */
42
/*LBP_NL,          next line - not used here because it's equivalent to LBP_BK */
43
/*LBP_SG,          surrogates - not used here because they are not characters */
44
  LBP_WJ  =  0, /* word joiner */
45
  LBP_ZW  = 47, /* zero width space */
46
  LBP_GL  =  1, /* non-breaking (glue) */
47
  LBP_SP  = 48, /* space */
48
  LBP_B2  =  2, /* break opportunity before and after */
49
  LBP_BA  =  3, /* break opportunity after */
50
  LBP_BB  =  4, /* break opportunity before */
51
  LBP_HH  =  5, /* unambiguous hyphen */
52
  LBP_HY  =  6, /* hyphen */
53
  LBP_CB  = 49, /* contingent break opportunity */
54
  LBP_CL  =  7, /* closing punctuation */
55
  LBP_CP1 =  8, /* closing parenthesis, non-EastAsian character */
56
  LBP_CP2 =  9, /* closing parenthesis, EastAsian character */
57
  LBP_EX  = 10, /* exclamation/interrogation */
58
  LBP_IN  = 11, /* inseparable */
59
  LBP_NS  = 12, /* non starter */
60
  LBP_OP1 = 13, /* opening punctuation, non-EastAsian character */
61
  LBP_OP2 = 14, /* opening punctuation, EastAsian character */
62
  LBP_QU1 = 15, /* ambiguous quotation, neither initial nor final punctuation */
63
  LBP_QU2 = 16, /* ambiguous quotation, initial punctuation */
64
  LBP_QU3 = 17, /* ambiguous quotation, final punctuation */
65
  LBP_IS  = 18, /* infix separator (numeric) */
66
  LBP_NU  = 19, /* numeric */
67
  LBP_PO  = 20, /* postfix (numeric) */
68
  LBP_PR  = 21, /* prefix (numeric) */
69
  LBP_SY  = 22, /* symbols allowing breaks */
70
  LBP_AI  = 50, /* ambiguous (alphabetic or ideograph) */
71
  LBP_AL1 = 23, /* ordinary alphabetic and symbol characters, != U+25CC */
72
  LBP_AL2 = 24, /* ordinary alphabetic and symbol characters, == U+25CC */
73
/*LBP_CJ,          conditional Japanese starter, resolved to NS */
74
  LBP_H2  = 25, /* Hangul LV syllable */
75
  LBP_H3  = 26, /* Hangul LVT syllable */
76
  LBP_HL  = 32, /* Hebrew letter */
77
  LBP_ID  = 27, /* ideographic */
78
  LBP_EBF = 28, /* future emoji base */
79
  LBP_JL  = 29, /* Hangul L Jamo */
80
  LBP_JV  = 30, /* Hangul V Jamo */
81
  LBP_JT  = 31, /* Hangul T Jamo */
82
  LBP_AP  = 33, /* Brahmic scripts: pre-base repha */
83
  LBP_AK  = 34, /* Brahmic scripts: consonants */
84
  LBP_AS  = 35, /* Brahmic scripts: independent vowels */
85
  LBP_VI  = 36, /* Brahmic scripts: conjoining viramas */
86
  LBP_VF  = 37, /* Brahmic scripts: viramas for final consonants */
87
  LBP_RI  = 38, /* regional indicator */
88
  LBP_SA1 = 51, /* complex context (South East Asian), not combining mark */
89
  LBP_SA2 = 39, /* complex context (South East Asian), combining mark */
90
  LBP_ZWJ = 40, /* zero width joiner */
91
  LBP_EB  = 41, /* emoji base */
92
  LBP_EM  = 42, /* emoji modifier */
93
  LBP_XX  = 52, /* unknown */
94
  /* Artificial values that exist only at runtime, not in the tables. */
95
  LBP_AKLS_VI = 100,
96
  LBP_HL_HY = 101
97
};
98
99
#include "lbrkprop1.h"
100
101
/* Combining prop and ea to a table entry.  */
102
0
#define PROP_EA(prop,ea) (((prop) << 1) | (ea))
103
104
/* Splitting a table entry into prop and ea.  */
105
0
#define PROP(entry) ((entry) >> 1)
106
0
#define EA(entry) ((entry) & 1)
107
108
/* Returns (prop << 1) | ea, where
109
     - prop is the line breaking property,
110
     - ea is the EastAsian property (1 bit)
111
   of UC.  */
112
static inline unsigned char
113
unilbrkprop_lookup (ucs4_t uc)
114
0
{
115
0
  unsigned int index1 = uc >> lbrkprop_header_0;
116
0
  if (index1 < lbrkprop_header_1)
117
0
    {
118
0
      int lookup1 = unilbrkprop.level1[index1];
119
0
      if (lookup1 >= 0)
120
0
        {
121
0
          unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3;
122
0
          int lookup2 = unilbrkprop.level2[lookup1 + index2];
123
0
          if (lookup2 >= 0)
124
0
            {
125
0
              unsigned int index3 = uc & lbrkprop_header_4;
126
0
              return unilbrkprop.level3[lookup2 + index3];
127
0
            }
128
0
        }
129
0
    }
130
0
  return PROP_EA (LBP_XX, 0);
131
0
}
Unexecuted instantiation: ulc-width-linebreaks.c:unilbrkprop_lookup
Unexecuted instantiation: u8-width-linebreaks.c:unilbrkprop_lookup
Unexecuted instantiation: u8-possible-linebreaks.c:unilbrkprop_lookup
Unexecuted instantiation: lbrktables.c:unilbrkprop_lookup
132
133
134
/* Table indexed by two line breaking classifications.  */
135
0
#define D 1  /* direct break opportunity, empty in table 7.3 of UTR #14 */
136
0
#define I 2  /* indirect break opportunity, '%' in table 7.3 of UTR #14 */
137
0
#define P 3  /* prohibited break,           '^' in table 7.3 of UTR #14 */
138
139
extern const unsigned char unilbrk_table[43][43];
140
141
/* We don't support line breaking of complex-context dependent characters
142
   (Thai, Lao, Myanmar, Khmer) yet, because it requires dictionary lookup. */
143
144
145
#ifdef __cplusplus
146
}
147
#endif