1 /* fribidi-brackets.c - get bracketed character
3 * Copyright (C) 2004 Sharif FarsiWeb, Inc
4 * Copyright (C) 2001, 2002, 2004 Behdad Esfahbod
5 * Copyright (C) 1999, 2000, 2017 Dov Grobgeld
7 * This file is part of GNU FriBidi.
9 * GNU FriBidi is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GNU FriBidi is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with GNU FriBidi; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * For licensing issues, contact <fribidi.license@gmail.com> or write to
24 * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
28 * Behdad Esfahbod, 2001, 2002, 2004
29 * Dov Grobgeld, 1999, 2000, 2017
34 #include <fribidi-brackets.h>
36 #include "brackets.tab.i"
37 #include "brackets-type.tab.i"
40 #define FRIBIDI_TYPE_BRACKET_OPEN 2
42 FRIBIDI_ENTRY FriBidiBracketType
48 FriBidiBracketType bracket_type;
49 register uint8_t char_type = FRIBIDI_GET_BRACKET_TYPE (ch);
51 /* The bracket type from the table may be:
56 This will be recodeded into the FriBidiBracketType as having a
57 bracket_id = 0 if the character is not a bracket.
59 fribidi_boolean is_open = false;
62 bracket_type = FRIBIDI_NO_BRACKET;
65 is_open = (char_type & FRIBIDI_TYPE_BRACKET_OPEN) != 0;
66 bracket_type = FRIBIDI_GET_BRACKETS (ch) & FRIBIDI_BRACKET_ID_MASK;
69 bracket_type |= FRIBIDI_BRACKET_OPEN_MASK;
75 fribidi_get_bracket_types (
77 const FriBidiChar *str,
78 const FriBidiStrIndex len,
79 const FriBidiCharType *types,
81 FriBidiBracketType *btypes
87 /* Optimization that bracket must be of types ON */
88 if (*types == FRIBIDI_TYPE_ON)
89 *btypes = fribidi_get_bracket (*str);
91 *btypes = FRIBIDI_NO_BRACKET;
103 * indent-tabs-mode: t
106 * vim: textwidth=78: autoindent: cindent: shiftwidth=2: tabstop=8: