]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/runetype.c.patch
Libc-320.tar.gz
[apple/libc.git] / locale / FreeBSD / runetype.c.patch
1 --- runetype.c.orig Tue May 20 15:21:44 2003
2 +++ runetype.c Tue Jun 17 17:50:43 2003
3 @@ -39,27 +39,39 @@
4
5 #include <stdio.h>
6 #include <rune.h>
7 +#include <stdlib.h>
8 +
9 +__private_extern__ int
10 +__compRuneEntry(const void *rune, const void *range)
11 +{
12 + __ct_rune_t c = *(__ct_rune_t *)rune;
13 + _RuneEntry *re = (_RuneEntry *)range;
14 +
15 + if (c < re->min)
16 + return(-1);
17 + if (c > re->max)
18 + return(1);
19 + return(0);
20 +}
21
22 unsigned long
23 ___runetype(c)
24 __ct_rune_t c;
25 {
26 - int x;
27 _RuneRange *rr = &_CurrentRuneLocale->runetype_ext;
28 - _RuneEntry *re = rr->ranges;
29 + _RuneEntry *re;
30
31 if (c < 0 || c == EOF)
32 return(0L);
33
34 - for (x = 0; x < rr->nranges; ++x, ++re) {
35 - if (c < re->min)
36 - return(0L);
37 - if (c <= re->max) {
38 - if (re->types)
39 - return(re->types[c - re->min]);
40 - else
41 - return(re->map);
42 - }
43 + re = (_RuneEntry *)bsearch(&c, rr->ranges, rr->nranges,
44 + sizeof(_RuneEntry), __compRuneEntry);
45 +
46 + if (re) {
47 + if (re->types)
48 + return(re->types[c - re->min]);
49 + else
50 + return(re->map);
51 }
52
53 return(0L);