1 /* Line breaking auxiliary tables.
2 Copyright (C) 2001-2003, 2006-2015 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2001.
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Line breaking classification. */
24 /* Values >= 27 are resolved at run time. */
25 LBP_BK = 27, /* mandatory break */
26 /*LBP_CR, carriage return - not used here because it's a DOSism */
27 /*LBP_LF, line feed - not used here because it's a DOSism */
28 LBP_CM = 28, /* attached characters and combining marks */
29 /*LBP_NL, next line - not used here because it's equivalent to LBP_BK */
30 /*LBP_SG, surrogates - not used here because they are not characters */
31 LBP_WJ = 0, /* word joiner */
32 LBP_ZW = 29, /* zero width space */
33 LBP_GL = 1, /* non-breaking (glue) */
34 LBP_SP = 30, /* space */
35 LBP_B2 = 2, /* break opportunity before and after */
36 LBP_BA = 3, /* break opportunity after */
37 LBP_BB = 4, /* break opportunity before */
38 LBP_HY = 5, /* hyphen */
39 LBP_CB = 31, /* contingent break opportunity */
40 LBP_CL = 6, /* closing punctuation */
41 LBP_CP = 7, /* closing parenthesis */
42 LBP_EX = 8, /* exclamation/interrogation */
43 LBP_IN = 9, /* inseparable */
44 LBP_NS = 10, /* non starter */
45 LBP_OP = 11, /* opening punctuation */
46 LBP_QU = 12, /* ambiguous quotation */
47 LBP_IS = 13, /* infix separator (numeric) */
48 LBP_NU = 14, /* numeric */
49 LBP_PO = 15, /* postfix (numeric) */
50 LBP_PR = 16, /* prefix (numeric) */
51 LBP_SY = 17, /* symbols allowing breaks */
52 LBP_AI = 32, /* ambiguous (alphabetic or ideograph) */
53 LBP_AL = 18, /* ordinary alphabetic and symbol characters */
54 /*LBP_CJ, conditional Japanese starters, resolved to NS */
55 LBP_H2 = 19, /* Hangul LV syllable */
56 LBP_H3 = 20, /* Hangul LVT syllable */
57 LBP_HL = 25, /* Hebrew letter */
58 LBP_ID = 21, /* ideographic */
59 LBP_JL = 22, /* Hangul L Jamo */
60 LBP_JV = 23, /* Hangul V Jamo */
61 LBP_JT = 24, /* Hangul T Jamo */
62 LBP_RI = 26, /* regional indicator */
63 LBP_SA = 33, /* complex context (South East Asian) */
64 LBP_XX = 34 /* unknown */
67 #include "lbrkprop1.h"
69 static inline unsigned char
70 unilbrkprop_lookup (ucs4_t uc)
72 unsigned int index1 = uc >> lbrkprop_header_0;
73 if (index1 < lbrkprop_header_1)
75 int lookup1 = unilbrkprop.level1[index1];
78 unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3;
79 int lookup2 = unilbrkprop.level2[lookup1 + index2];
82 unsigned int index3 = uc & lbrkprop_header_4;
83 return unilbrkprop.level3[lookup2 + index3];
90 /* Table indexed by two line breaking classifications. */
91 #define D 1 /* direct break opportunity, empty in table 7.3 of UTR #14 */
92 #define I 2 /* indirect break opportunity, '%' in table 7.3 of UTR #14 */
93 #define P 3 /* prohibited break, '^' in table 7.3 of UTR #14 */
95 extern const unsigned char unilbrk_table[27][27];
97 /* We don't support line breaking of complex-context dependent characters
98 (Thai, Lao, Myanmar, Khmer) yet, because it requires dictionary lookup. */