|
Packit Service |
4684c1 |
/* Three-level bitmap lookup.
|
|
Packit Service |
4684c1 |
Copyright (C) 2000-2002, 2005-2007, 2009-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
Written by Bruno Haible <bruno@clisp.org>, 2000-2002.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
This program is free software: you can redistribute it and/or
|
|
Packit Service |
4684c1 |
modify it under the terms of either:
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 3 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 2 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or both in parallel, as here.
|
|
Packit Service |
4684c1 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
Lesser General Public License for more details.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static inline int bitmap_lookup (const void *table, ucs4_t uc);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* These values are currently hardcoded into gen-ctype.c. */
|
|
Packit Service |
4684c1 |
#define header_0 16
|
|
Packit Service |
4684c1 |
#define header_2 9
|
|
Packit Service |
4684c1 |
#define header_3 127
|
|
Packit Service |
4684c1 |
#define header_4 15
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static inline int
|
|
Packit Service |
4684c1 |
bitmap_lookup (const void *table, ucs4_t uc)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index1 = uc >> header_0;
|
|
Packit Service |
4684c1 |
if (index1 < ((const int *) table)[0])
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int lookup1 = ((const int *) table)[1 + index1];
|
|
Packit Service |
4684c1 |
if (lookup1 >= 0)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index2 = (uc >> header_2) & header_3;
|
|
Packit Service |
4684c1 |
int lookup2 = ((const short *) table)[lookup1 + index2];
|
|
Packit Service |
4684c1 |
if (lookup2 >= 0)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index3 = (uc >> 5) & header_4;
|
|
Packit Service |
4684c1 |
unsigned int lookup3 = ((const int *) table)[lookup2 + index3];
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return (lookup3 >> (uc & 0x1f)) & 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|