mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 07:10:06 +00:00
cf684340ce
Variable declarations removed. (__ctype_b_loc, __ctype_toupper_loc, __ctype_tolower_loc): Declare these functions to replace them. (__isctype, tolower, toupper, _tolower, _toupper): Use those accessor functions plus an indirection rather than the old global variables. * include/ctype.h (__isctype, tolower, _tolower, toupper, _toupper): Macros removed. (__ctype_b_loc, __ctype_toupper_loc, __ctype_tolower_loc): New extern inline functions. * ctype/ctype-info.c: Revert last reversion back the other way. Define tsd vars CTYPE_B, CTYPE_TOLOWER, CTYPE_TOUPPER. Define real function versions of include/ctype.h inlines here. * ctype/Versions (libc: GLIBC_2.3): Add __ctype_b_loc, __ctype_tolower_loc, __ctype_toupper_loc. * locale/lc-ctype.c: Revert last reversion back the other way. (_nl_postload_ctype): If current thread uses the global locale, update its tsd vars. * locale/uselocale.c (__uselocale): Update tsd vars from new locale. * hurd/hurd/threadvar.h (enum __hurd_threadvar_index): Add CTYPE_B, CTYPE_TOLOWER, CTYPE_TOUPPER. * sysdeps/generic/bits/libc-tsd.h (__libc_tsd_address): New macro. * sysdeps/mach/hurd/bits/libc-tsd.h (__libc_tsd_address): Renamed from __libc_tsd_threadvar_location. (__libc_tsd_set, __libc_tsd_get): Update uses.
73 lines
3.0 KiB
C
73 lines
3.0 KiB
C
/* Define current locale data for LC_CTYPE category.
|
|
Copyright (C) 1995-1999, 2000, 2002 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#include "localeinfo.h"
|
|
#include <ctype.h>
|
|
#include <endian.h>
|
|
#include <stdint.h>
|
|
|
|
_NL_CURRENT_DEFINE (LC_CTYPE);
|
|
|
|
/* We are called after loading LC_CTYPE data to load it into
|
|
the variables used by the ctype.h macros. */
|
|
|
|
void
|
|
_nl_postload_ctype (void)
|
|
{
|
|
#define current(type,x,offset) \
|
|
((const type *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_##x) + offset)
|
|
|
|
/* These are defined in ctype-info.c.
|
|
The declarations here must match those in localeinfo.h.
|
|
|
|
These point into arrays of 384, so they can be indexed by any `unsigned
|
|
char' value [0,255]; by EOF (-1); or by any `signed char' value
|
|
[-128,-1). ISO C requires that the ctype functions work for `unsigned
|
|
char' values and for EOF; we also support negative `signed char' values
|
|
for broken old programs. The case conversion arrays are of `int's
|
|
rather than `unsigned char's because tolower (EOF) must be EOF, which
|
|
doesn't fit into an `unsigned char'. But today more important is that
|
|
the arrays are also used for multi-byte character sets. */
|
|
|
|
if (_NL_CURRENT_LOCALE == &_nl_global_locale)
|
|
{
|
|
__libc_tsd_set (CTYPE_B, (void *) current (uint16_t, CLASS, 128));
|
|
__libc_tsd_set (CTYPE_TOUPPER, (void *) current (int32_t, TOUPPER, 128));
|
|
__libc_tsd_set (CTYPE_TOLOWER, (void *) current (int32_t, TOLOWER, 128));
|
|
}
|
|
|
|
#include <shlib-compat.h>
|
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
|
|
extern __const unsigned short int *__ctype_old_b; /* Characteristics. */
|
|
extern __const __int32_t *__ctype_old_tolower; /* Case conversions. */
|
|
extern __const __int32_t *__ctype_old_toupper; /* Case conversions. */
|
|
|
|
extern const uint32_t *__ctype32_old_b;
|
|
extern const uint32_t *__ctype32_old_toupper;
|
|
extern const uint32_t *__ctype32_old_tolower;
|
|
|
|
__ctype_old_b = current (uint16_t, CLASS, 128);
|
|
__ctype_old_toupper = current (uint32_t, TOUPPER, 128);
|
|
__ctype_old_tolower = current (uint32_t, TOLOWER, 128);
|
|
__ctype32_old_b = current (uint32_t, CLASS32, 0);
|
|
__ctype32_old_toupper = current (uint32_t, TOUPPER32, 0);
|
|
__ctype32_old_tolower = current (uint32_t, TOLOWER32, 0);
|
|
#endif
|
|
}
|