]> git.saurik.com Git - apple/libc.git/blobdiff - locale/FreeBSD/toupper.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / locale / FreeBSD / toupper.c.patch
index 2f54eebbe638d15e50877dbf582b62961edcfc73..aea5ad9181a92abf28d042429ff679c7df8f01eb 100644 (file)
@@ -1,37 +1,50 @@
---- toupper.c.orig     Tue May 20 15:21:44 2003
-+++ toupper.c  Tue Jun 17 17:49:05 2003
-@@ -39,6 +39,10 @@
+--- toupper.c.bsdnew   2009-11-09 15:05:25.000000000 -0800
++++ toupper.c  2009-11-09 17:30:20.000000000 -0800
+@@ -32,22 +32,34 @@
  
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD: src/lib/libc/locale/toupper.c,v 1.13 2007/01/09 00:28:01 imp Exp $");
++  
++#include "xlocale_private.h"
+ #include <ctype.h>
  #include <stdio.h>
- #include <rune.h>
-+#include <stdlib.h>
-+
-+__private_extern__ int
-+__compRuneEntry(const void *, const void *); // from runetype.c
+ #include <runetype.h>
  
  __ct_rune_t
- ___toupper(c)
-@@ -46,17 +50,16 @@
+-___toupper(c)
++___toupper_l(c, loc)
+       __ct_rune_t c;
++      locale_t loc;
  {
-       int x;
-       _RuneRange *rr = &_CurrentRuneLocale->mapupper_ext;
--      _RuneEntry *re = rr->ranges;
-+      _RuneEntry *re;
+       size_t lim;
+-      _RuneRange *rr = &_CurrentRuneLocale->__mapupper_ext;
++      _RuneRange *rr;
+       _RuneEntry *base, *re;
  
        if (c < 0 || c == EOF)
                return(c);
  
--      for (x = 0; x < rr->nranges; ++x, ++re) {
--              if (c < re->min)
--                      return(c);
--              if (c <= re->max)
--                      return(re->map + c - re->min);
--      }
-+      re = (_RuneEntry *)bsearch(&c, rr->ranges, rr->nranges,
-+          sizeof(_RuneEntry), __compRuneEntry);
-+
-+      if (re)
-+              return(re->map + c - re->min);
++      NORMALIZE_LOCALE(loc);
++      /*
++       * the following is not used by toupper(), but can be used by
++       * toupper_l().  This provides the oppurtunity to optimize toupper()
++       * when compatibility for Panther and lower is no longer needed
++       */
++      if (c < _CACHED_RUNES)
++              return loc->__lc_ctype->_CurrentRuneLocale.__mapupper[c];
++      rr = &loc->__lc_ctype->_CurrentRuneLocale.__mapupper_ext;
+       /* Binary search -- see bsearch.c for explanation. */
+       base = rr->__ranges;
+       for (lim = rr->__nranges; lim != 0; lim >>= 1) {
+@@ -62,3 +74,10 @@ ___toupper(c)
  
        return(c);
  }
++
++__ct_rune_t
++___toupper(c)
++      __ct_rune_t c;
++{
++      return ___toupper_l(c, __current_locale());
++}