]>
Commit | Line | Data |
---|---|---|
9385eb3d A |
1 | --- toupper.c.orig Tue May 20 15:21:44 2003 |
2 | +++ toupper.c Tue Jun 17 17:49:05 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 | ___toupper(c) | |
14 | @@ -46,17 +50,16 @@ | |
15 | { | |
16 | int x; | |
17 | _RuneRange *rr = &_CurrentRuneLocale->mapupper_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 | } |