1 /* Copyright (C) 1996-2000, 2001, 2003 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* Find index of weight. */
22 __attribute ((always_inline
))
23 findidx (const wint_t **cpp
)
30 i
= __collidx_table_lookup ((const char *) table
, ch
);
33 /* This is an index into the weight table. Cool. */
36 /* Oh well, more than one sequence starting with this byte.
37 Search for the correct one. */
42 const wint_t *usrc
= *cpp
;
44 /* The first thing is the index. */
47 /* Next is the length of the byte sequence. These are always
48 short byte sequences so there is no reason to call any
49 function (even if they are inlined). */
54 /* It is a single character. If it matches we found our
55 index. Note that at the end of each list there is an
56 entry of length zero which represents the single byte
57 sequence. The first (and here only) byte was tested
61 for (cnt
= 0; cnt
< nhere
; ++cnt
)
62 if (cp
[cnt
] != usrc
[cnt
])
72 /* Up to the next entry. */
77 /* This is a range of characters. First decide whether the
78 current byte sequence lies in the range. */
82 for (cnt
= 0; cnt
< nhere
- 1; ++cnt
)
83 if (cp
[cnt
] != usrc
[cnt
])
92 if (cp
[nhere
- 1] > usrc
[nhere
-1])
98 if (cp
[2 * nhere
- 1] < usrc
[nhere
-1])
104 /* This range matches the next characters. Now find
105 the offset in the indirect table. */
106 offset
= usrc
[nhere
- 1] - cp
[nhere
- 1];
109 return indirect
[-i
+ offset
];