1/* Line breaking auxiliary tables. 2 Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. 3 Written by Bruno Haible <bruno@clisp.org>, 2001. 4 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. 9 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. 14 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/>. */ 17 18#include "unitypes.h" 19 20/* Line breaking classification. */ 21 22enum 23{ 24 /* Values >= 24 are resolved at run time. */ 25 LBP_BK = 24, /* 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 = 25, /* 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 = 26, /* zero width space */ 33 LBP_GL = 1, /* non-breaking (glue) */ 34 LBP_SP = 27, /* 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 = 28, /* contingent break opportunity */ 40 LBP_CL = 6, /* closing punctuation */ 41 LBP_EX = 7, /* exclamation/interrogation */ 42 LBP_IN = 8, /* inseparable */ 43 LBP_NS = 9, /* non starter */ 44 LBP_OP = 10, /* opening punctuation */ 45 LBP_QU = 11, /* ambiguous quotation */ 46 LBP_IS = 12, /* infix separator (numeric) */ 47 LBP_NU = 13, /* numeric */ 48 LBP_PO = 14, /* postfix (numeric) */ 49 LBP_PR = 15, /* prefix (numeric) */ 50 LBP_SY = 16, /* symbols allowing breaks */ 51 LBP_AI = 29, /* ambiguous (alphabetic or ideograph) */ 52 LBP_AL = 17, /* ordinary alphabetic and symbol characters */ 53 LBP_H2 = 18, /* Hangul LV syllable */ 54 LBP_H3 = 19, /* Hangul LVT syllable */ 55 LBP_ID = 20, /* ideographic */ 56 LBP_JL = 21, /* Hangul L Jamo */ 57 LBP_JV = 22, /* Hangul V Jamo */ 58 LBP_JT = 23, /* Hangul T Jamo */ 59 LBP_SA = 30, /* complex context (South East Asian) */ 60 LBP_XX = 31 /* unknown */ 61}; 62 63#include "lbrkprop1.h" 64 65static inline unsigned char 66unilbrkprop_lookup (ucs4_t uc) 67{ 68 unsigned int index1 = uc >> lbrkprop_header_0; 69 if (index1 < lbrkprop_header_1) 70 { 71 int lookup1 = unilbrkprop.level1[index1]; 72 if (lookup1 >= 0) 73 { 74 unsigned int index2 = (uc >> lbrkprop_header_2) & lbrkprop_header_3; 75 int lookup2 = unilbrkprop.level2[lookup1 + index2]; 76 if (lookup2 >= 0) 77 { 78 unsigned int index3 = uc & lbrkprop_header_4; 79 return unilbrkprop.level3[lookup2 + index3]; 80 } 81 } 82 } 83 return LBP_XX; 84} 85 86/* Table indexed by two line breaking classifications. */ 87#define D 1 /* direct break opportunity, empty in table 7.3 of UTR #14 */ 88#define I 2 /* indirect break opportunity, '%' in table 7.3 of UTR #14 */ 89#define P 3 /* prohibited break, '^' in table 7.3 of UTR #14 */ 90 91extern const unsigned char unilbrk_table[24][24]; 92 93/* We don't support line breaking of complex-context dependent characters 94 (Thai, Lao, Myanmar, Khmer) yet, because it requires dictionary lookup. */ 95