Blame gllib/unictype/bitmap.h

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