Branch data Line data Source code
1 : : /* tables.c - IDNA table checking functions
2 : : Copyright (C) 2011 Simon Josefsson
3 : :
4 : : This program is free software: you can redistribute it and/or modify
5 : : it under the terms of the GNU General Public License as published by
6 : : the Free Software Foundation, either version 3 of the License, or
7 : : (at your option) any later version.
8 : :
9 : : This program is distributed in the hope that it will be useful,
10 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : : GNU General Public License for more details.
13 : :
14 : : You should have received a copy of the GNU General Public License
15 : : along with this program. If not, see <http://www.gnu.org/licenses/>.
16 : : */
17 : :
18 : : #include <config.h>
19 : :
20 : : #include "tables.h"
21 : :
22 : : #include <stdlib.h> /* abort */
23 : :
24 : : #include "data.h"
25 : :
26 : : static int
27 : 10591 : property (uint32_t cp)
28 : : {
29 : 10591 : const struct idna_table *p = idna_table;
30 : :
31 [ + + ][ + - ]: 4696759 : while (p->start != 0 || p->end != 0)
32 : : {
33 [ + + ][ + + ]: 4696759 : if (p->end == 0 && p->start == cp)
34 : 580 : return p->state;
35 [ + - ][ + + ]: 4696179 : else if (p->start <= cp && p->end >= cp)
36 : 10011 : return p->state;
37 : 4686168 : p++;
38 : : }
39 : :
40 : 10591 : abort ();
41 : : }
42 : :
43 : : int
44 : 2826 : _idn2_disallowed_p (uint32_t cp)
45 : : {
46 : 2826 : return property (cp) == DISALLOWED;
47 : : }
48 : :
49 : : int
50 : 2631 : _idn2_contextj_p (uint32_t cp)
51 : : {
52 : 2631 : return property (cp) == CONTEXTJ;
53 : : }
54 : :
55 : : int
56 : 2590 : _idn2_contexto_p (uint32_t cp)
57 : : {
58 : 2590 : return property (cp) == CONTEXTO;
59 : : }
60 : :
61 : : int
62 : 2544 : _idn2_unassigned_p (uint32_t cp)
63 : : {
64 : 2544 : return property (cp) == UNASSIGNED;
65 : : }
|