setrunelocale.c revision 475b496bc008381e64c802250441cc256622ce91
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "lint.h"
#include "file64.h"
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wchar.h>
#include "runetype.h"
#include "ldpart.h"
#include "mblocal.h"
#include "setlocale.h"
#include "_ctype.h"
#include "../i18n/_locale.h"
extern unsigned char __ctype_C[];
static int __setrunelocale(const char *);
static int
__setrunelocale(const char *encoding)
{
int (*old__mbsinit)(const mbstate_t *);
static _RuneLocale *CachedRuneLocale;
static int (*Cached__mbsinit)(const mbstate_t *);
/*
* The "C" and "POSIX" locale are always here.
*/
int i;
for (i = 0; i < _CACHED_RUNES; i++) {
}
(void) _none_init(&_DefaultRuneLocale);
return (0);
}
/*
* If the locale name is the same as our cache, use the cache.
*/
if (CachedRuneLocale != NULL &&
return (0);
}
/*
* Slurp the locale file into the cache.
*/
return (saverr);
}
else
if (ret == 0) {
if (CachedRuneLocale != NULL) {
}
/*
* We need to overwrite the _ctype array. This requires
* some finagling. This is because references to it may
* have been baked into applications.
*
* produce defined results when the input is representable
* as a byte.
*/
/*
* The top half is the type mask array. Because we
* want to support both legacy Solaris code (which have
* mask valeus baked in to them), and we want to be able
* to import locale files from other sources (FreeBSD)
* which probably uses different masks, we have to perform
* a conversion here. Ugh. Note that the _CTYPE definitions
* we use from FreeBSD are richer than the Solaris legacy.
*
* We have to cope with these limitations though, because the
* inadequate Solaris definitions were baked into binaries.
*/
for (int i = 0; i < _CACHED_RUNES; i++) {
/* ctype can only encode the lower 8 bits. */
}
for (int i = 0; i < _CACHED_RUNES; i++) {
__ctype[258 + i] = i;
/* Don't forget these annoyances either! */
}
/*
* Note that we expect the init code will have populated
* the CSWIDTH array (__ctype[514-520]) properly.
*/
} else {
}
return (ret);
}
int
__wrap_setrunelocale(const char *locale)
{
if (ret != 0) {
return (_LDP_ERROR);
}
return (_LDP_LOADED);
}