changeset 13189:668c57e24078

187 locale -a dumps core Reviewed by: richlowe@richlowe.net, gwr@nexenta.com, vineeth@nexenta.com Approved by: gwr@nexenta.com
author Garrett D'Amore <garrett@nexenta.com>
date Tue, 14 Sep 2010 09:43:15 -0700
parents d3448309c82d
children 4c137ceda4dc
files usr/src/lib/libc/port/locale/none.c usr/src/lib/libc/port/locale/setrunelocale.c
diffstat 2 files changed, 12 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libc/port/locale/none.c	Tue Sep 14 12:50:00 2010 +0800
+++ b/usr/src/lib/libc/port/locale/none.c	Tue Sep 14 09:43:15 2010 -0700
@@ -47,7 +47,6 @@
 #include <note.h>
 #include "runetype.h"
 #include "mblocal.h"
-#include "../i18n/_locale.h"
 
 static size_t	_none_mbrtowc(wchar_t *_RESTRICT_KYWD,
     const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD);
@@ -64,28 +63,11 @@
 
 /* setup defaults */
 
-extern unsigned char __ctype_C[];
-
 int
 _none_init(_RuneLocale *rl)
 {
-	/*
-	 * We need to populate the ctype stuff.  This means the
-	 * tolower table, the type masks, etc.
-	 * There are 257 entries for the type array, 257 entries for the
-	 * tolower/toupper array, and 7 bytes for CSWIDTH array.
-	 *
-	 * We have to set this stuff up because for POSIX/C we short
-	 * circuit most of the logic in setrunelocale that would handle it.
-	 */
-	(void) memcpy(__ctype, __ctype_C, SZ_TOTAL);
-
 	charset_is_ascii = 1;
 
-	__ctype_mask = rl->__runetype;
-	__trans_upper = rl->__mapupper;
-	__trans_lower = rl->__maplower;
-
 	__mbrtowc = _none_mbrtowc;
 	__mbsinit = _none_mbsinit;
 	__mbsnrtowcs = _none_mbsnrtowcs;
--- a/usr/src/lib/libc/port/locale/setrunelocale.c	Tue Sep 14 12:50:00 2010 +0800
+++ b/usr/src/lib/libc/port/locale/setrunelocale.c	Tue Sep 14 09:43:15 2010 -0700
@@ -48,8 +48,10 @@
 #include "mblocal.h"
 #include "setlocale.h"
 #include "_ctype.h"
+#include "../i18n/_locale.h"
 
 extern _RuneLocale	*_Read_RuneMagi(FILE *);
+extern unsigned char	__ctype_C[];
 
 static int		__setrunelocale(const char *);
 
@@ -89,6 +91,16 @@
 	 * The "C" and "POSIX" locale are always here.
 	 */
 	if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
+		int i;
+
+		(void) memcpy(__ctype, __ctype_C, SZ_TOTAL);
+
+		for (i = 0; i < _CACHED_RUNES; i++) {
+			__ctype_mask[i] = _DefaultRuneLocale.__runetype[i];
+			__trans_upper[i] = _DefaultRuneLocale.__mapupper[i];
+			__trans_lower[i] = _DefaultRuneLocale.__maplower[i];
+		}
+
 		(void) _none_init(&_DefaultRuneLocale);
 		return (0);
 	}