]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/toupper.c.patch
aea5ad9181a92abf28d042429ff679c7df8f01eb
[apple/libc.git] / locale / FreeBSD / toupper.c.patch
1 --- toupper.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2 +++ toupper.c 2009-11-09 17:30:20.000000000 -0800
3 @@ -32,22 +32,34 @@
4
5 #include <sys/cdefs.h>
6 __FBSDID("$FreeBSD: src/lib/libc/locale/toupper.c,v 1.13 2007/01/09 00:28:01 imp Exp $");
7 +
8 +#include "xlocale_private.h"
9
10 #include <ctype.h>
11 #include <stdio.h>
12 #include <runetype.h>
13
14 __ct_rune_t
15 -___toupper(c)
16 +___toupper_l(c, loc)
17 __ct_rune_t c;
18 + locale_t loc;
19 {
20 size_t lim;
21 - _RuneRange *rr = &_CurrentRuneLocale->__mapupper_ext;
22 + _RuneRange *rr;
23 _RuneEntry *base, *re;
24
25 if (c < 0 || c == EOF)
26 return(c);
27
28 + NORMALIZE_LOCALE(loc);
29 + /*
30 + * the following is not used by toupper(), but can be used by
31 + * toupper_l(). This provides the oppurtunity to optimize toupper()
32 + * when compatibility for Panther and lower is no longer needed
33 + */
34 + if (c < _CACHED_RUNES)
35 + return loc->__lc_ctype->_CurrentRuneLocale.__mapupper[c];
36 + rr = &loc->__lc_ctype->_CurrentRuneLocale.__mapupper_ext;
37 /* Binary search -- see bsearch.c for explanation. */
38 base = rr->__ranges;
39 for (lim = rr->__nranges; lim != 0; lim >>= 1) {
40 @@ -62,3 +74,10 @@ ___toupper(c)
41
42 return(c);
43 }
44 +
45 +__ct_rune_t
46 +___toupper(c)
47 + __ct_rune_t c;
48 +{
49 + return ___toupper_l(c, __current_locale());
50 +}