1 /* Line breaking auxiliary tables.
2 Copyright (C) 2001-2003, 2006-2008 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 Lesser 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Line breaking classification. */
24 /* Values >= 20 are resolved at run time. */
25 LBP_BK = 0, /* 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 = 20, /* attached characters and combining marks */
29 /*LBP_SG, surrogates - not used here because they are not characters */
30 LBP_ZW = 1, /* zero width space */
31 LBP_IN = 2, /* inseparable */
32 LBP_GL = 3, /* non-breaking (glue) */
33 LBP_CB = 22, /* contingent break opportunity */
34 LBP_SP = 21, /* space */
35 LBP_BA = 4, /* break opportunity after */
36 LBP_BB = 5, /* break opportunity before */
37 LBP_B2 = 6, /* break opportunity before and after */
38 LBP_HY = 7, /* hyphen */
39 LBP_NS = 8, /* non starter */
40 LBP_OP = 9, /* opening punctuation */
41 LBP_CL = 10, /* closing punctuation */
42 LBP_QU = 11, /* ambiguous quotation */
43 LBP_EX = 12, /* exclamation/interrogation */
44 LBP_ID = 13, /* ideographic */
45 LBP_NU = 14, /* numeric */
46 LBP_IS = 15, /* infix separator (numeric) */
47 LBP_SY = 16, /* symbols allowing breaks */
48 LBP_AL = 17, /* ordinary alphabetic and symbol characters */
49 LBP_PR = 18, /* prefix (numeric) */
50 LBP_PO = 19, /* postfix (numeric) */
51 LBP_SA = 23, /* complex context (South East Asian) */
52 LBP_AI = 24, /* ambiguous (alphabetic or ideograph) */
53 LBP_XX = 25 /* unknown */
56 #include "lbrkprop1.h"
58 static inline unsigned char
59 unilbrkprop_lookup (ucs4_t uc)
61 unsigned int index1 = uc >> lbrkprop_header_0;
62 if (index1 < lbrkprop_header_1)
64 int lookup1 = unilbrkprop.level1[index1];
67 unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3;
68 int lookup2 = unilbrkprop.level2[lookup1 + index2];
71 unsigned int index3 = uc & lbrkprop_header_4;
72 return unilbrkprop.level3[lookup2 + index3];
79 /* Table indexed by two line breaking classifications. */
80 #define D 1 /* direct break opportunity, empty in table 7.3 of UTR #14 */
81 #define I 2 /* indirect break opportunity, '%' in table 7.3 of UTR #14 */
82 #define P 3 /* prohibited break, '^' in table 7.3 of UTR #14 */
84 extern const unsigned char unilbrk_table[19][19];
86 /* We don't support line breaking of complex-context dependent characters
87 (Thai, Lao, Myanmar, Khmer) yet, because it requires dictionary lookup. */