Remove redunant "warning: " prefix from stub warnings.
[glibc.git] / locale / weight.h
blob645eda2fe959383a0f9866b9073df72bc5614501
1 /* Copyright (C) 1996-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Written by Ulrich Drepper, <drepper@cygnus.com>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* Find index of weight. */
20 auto inline int32_t
21 __attribute ((always_inline))
22 findidx (const unsigned char **cpp, size_t len)
24 int_fast32_t i = table[*(*cpp)++];
25 const unsigned char *cp;
26 const unsigned char *usrc;
28 if (i >= 0)
29 /* This is an index into the weight table. Cool. */
30 return i;
32 /* Oh well, more than one sequence starting with this byte.
33 Search for the correct one. */
34 cp = &extra[-i];
35 usrc = *cpp;
36 --len;
37 while (1)
39 size_t nhere;
41 /* The first thing is the index. */
42 i = *((const int32_t *) cp);
43 cp += sizeof (int32_t);
45 /* Next is the length of the byte sequence. These are always
46 short byte sequences so there is no reason to call any
47 function (even if they are inlined). */
48 nhere = *cp++;
50 if (i >= 0)
52 /* It is a single character. If it matches we found our
53 index. Note that at the end of each list there is an
54 entry of length zero which represents the single byte
55 sequence. The first (and here only) byte was tested
56 already. */
57 size_t cnt;
59 for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
60 if (cp[cnt] != usrc[cnt])
61 break;
63 if (cnt == nhere)
65 /* Found it. */
66 *cpp += nhere;
67 return i;
70 /* Up to the next entry. */
71 cp += nhere;
72 if ((1 + nhere) % __alignof__ (int32_t) != 0)
73 cp += __alignof__ (int32_t) - (1 + nhere) % __alignof__ (int32_t);
75 else
77 /* This is a range of characters. First decide whether the
78 current byte sequence lies in the range. */
79 size_t cnt;
80 size_t offset = 0;
82 for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
83 if (cp[cnt] != usrc[cnt])
84 break;
86 if (cnt != nhere)
88 if (cnt == len || cp[cnt] > usrc[cnt])
90 /* Cannot be in this range. */
91 cp += 2 * nhere;
92 if ((1 + 2 * nhere) % __alignof__ (int32_t) != 0)
93 cp += (__alignof__ (int32_t)
94 - (1 + 2 * nhere) % __alignof__ (int32_t));
95 continue;
98 /* Test against the end of the range. */
99 for (cnt = 0; cnt < nhere; ++cnt)
100 if (cp[nhere + cnt] != usrc[cnt])
101 break;
103 if (cnt != nhere && cp[nhere + cnt] < usrc[cnt])
105 /* Cannot be in this range. */
106 cp += 2 * nhere;
107 if ((1 + 2 * nhere) % __alignof__ (int32_t) != 0)
108 cp += (__alignof__ (int32_t)
109 - (1 + 2 * nhere) % __alignof__ (int32_t));
110 continue;
113 /* This range matches the next characters. Now find
114 the offset in the indirect table. */
115 for (cnt = 0; cp[cnt] == usrc[cnt]; ++cnt);
119 offset <<= 8;
120 offset += usrc[cnt] - cp[cnt];
122 while (++cnt < nhere);
125 *cpp += nhere;
126 return indirect[-i + offset];
130 /* NOTREACHED */
131 return 0x43219876;