tolower.c.patch   [plain text]


--- tolower.c.orig	2004-11-25 11:38:19.000000000 -0800
+++ tolower.c	2005-02-17 16:43:19.000000000 -0800
@@ -37,20 +37,32 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/tolower.c,v 1.11 2004/07/29 06:16:19 tjr Exp $");
 
+#include "xlocale_private.h"
+
 #include <stdio.h>
 #include <runetype.h>
 
 __ct_rune_t
-___tolower(c)
+___tolower_l(c, loc)
 	__ct_rune_t c;
+	locale_t loc;
 {
 	size_t lim;
-	_RuneRange *rr = &_CurrentRuneLocale->__maplower_ext;
+	_RuneRange *rr;
 	_RuneEntry *base, *re;
 
 	if (c < 0 || c == EOF)
 		return(c);
 
+	NORMALIZE_LOCALE(loc);
+	/*
+	 * the following is not used by tolower(), but can be used by
+	 * tolower_l().  This provides the oppurtunity to optimize tolower()
+	 * when compatibility for Panther and lower is no longer needed
+	 */
+	if (c < _CACHED_RUNES)
+		return loc->__lc_ctype->_CurrentRuneLocale.__maplower[c];
+	rr = &loc->__lc_ctype->_CurrentRuneLocale.__maplower_ext;
 	/* Binary search -- see bsearch.c for explanation. */
 	base = rr->__ranges;
 	for (lim = rr->__nranges; lim != 0; lim >>= 1) {
@@ -65,3 +77,10 @@
 
 	return(c);
 }
+
+__ct_rune_t
+___tolower(c)
+	__ct_rune_t c;
+{
+	return ___tolower_l(c, __current_locale());
+}