1 /* Copyright (C) 1996, 1997, 1998, 1999 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* Find index of weight. */
22 findidx (const wint_t **cpp
)
32 while (names
[idx
] != ch
)
35 /* We didn't find the name. It is case for UNDEFINED. */
42 /* This is an index into the weight table. Cool. */
45 /* Oh well, more than one sequence starting with this byte.
46 Search for the correct one. */
51 const wint_t *usrc
= *cpp
;
53 /* The first thing is the index. */
54 i
= *((int32_t *) cp
);
55 cp
+= sizeof (int32_t);
57 /* Next is the length of the byte sequence. These are always
58 short byte sequences so there is no reason to call any
59 function (even if they are inlined). */
64 /* It is a single character. If it matches we found our
65 index. Note that at the end of each list there is an
66 entry of length zero which represents the single byte
67 sequence. The first (and here only) byte was tested
71 for (cnt
= 0; cnt
< nhere
; ++cnt
)
72 if (cp
[cnt
] != usrc
[cnt
])
82 /* Up to the next entry. */
87 /* This is a range of characters. First decide whether the
88 current byte sequence lies in the range. */
92 for (cnt
= 0; cnt
< nhere
; ++cnt
)
93 if (cp
[cnt
] != usrc
[cnt
])
98 if (cp
[cnt
] > usrc
[cnt
])
100 /* Cannot be in this range. */
105 /* Test against the end of the range. */
106 for (cnt
= 0; cnt
< nhere
; ++cnt
)
107 if (cp
[nhere
+ cnt
] != usrc
[cnt
])
110 if (cnt
!= nhere
&& cp
[nhere
+ cnt
] < usrc
[cnt
])
112 /* Cannot be in this range. */
117 /* This range matches the next characters. Now find
118 the offset in the indirect table. */
119 for (cnt
= 0; cp
[cnt
] == usrc
[cnt
]; ++cnt
);
124 offset
+= usrc
[cnt
] - cp
[cnt
];
126 while (++cnt
< nhere
);