]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/tolower.c.patch
6de7d33f3d5b0558b680b9e091705f9db3f6e8c0
[apple/libc.git] / locale / FreeBSD / tolower.c.patch
1 --- tolower.c.orig Tue May 20 15:21:44 2003
2 +++ tolower.c Tue Jun 17 17:45:56 2003
3 @@ -39,6 +39,10 @@
4
5 #include <stdio.h>
6 #include <rune.h>
7 +#include <stdlib.h>
8 +
9 +__private_extern__ int
10 +__compRuneEntry(const void *, const void *); // from runetype.c
11
12 __ct_rune_t
13 ___tolower(c)
14 @@ -46,17 +50,16 @@
15 {
16 int x;
17 _RuneRange *rr = &_CurrentRuneLocale->maplower_ext;
18 - _RuneEntry *re = rr->ranges;
19 + _RuneEntry *re;
20
21 if (c < 0 || c == EOF)
22 return(c);
23
24 - for (x = 0; x < rr->nranges; ++x, ++re) {
25 - if (c < re->min)
26 - return(c);
27 - if (c <= re->max)
28 - return(re->map + c - re->min);
29 - }
30 + re = (_RuneEntry *)bsearch(&c, rr->ranges, rr->nranges,
31 + sizeof(_RuneEntry), __compRuneEntry);
32 +
33 + if (re)
34 + return(re->map + c - re->min);
35
36 return(c);
37 }