From: guenther Date: Wed, 27 Jul 2022 20:00:11 +0000 (+0000) Subject: Since we only do US-ASCII and UTF-8, several parts of the locale X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=09cbbb72c04f57bdaa8965a966a3f3876e5b9a5a;p=openbsd Since we only do US-ASCII and UTF-8, several parts of the locale data are unused and unnecessary, so delete them: rl_tabs, rl_magic, rl_encoding, and rl_invalid_rune. ok schwarze@ --- diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index 89cb470966b..5509156d5e6 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.25 2022/07/25 21:38:24 guenther Exp $ +# $OpenBSD: Makefile.inc,v 1.26 2022/07/27 20:00:11 guenther Exp $ # locale sources .PATH: ${LIBCSRCDIR}/locale @@ -12,7 +12,7 @@ SRCS+= btowc.c _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \ wcscoll_l.c \ wcstombs.c wctob.c wctomb.c wcstof.c wcstod.c wcstold.c wcstol.c \ wcstoul.c wcstoll.c wcstoull.c wcstoimax.c wcstoumax.c \ - runeglue.c rune.c runetable.c ___runetype_mb.c \ + rune.c runetable.c ___runetype_mb.c \ _wctrans.c wcsxfrm.c wcsxfrm_l.c MAN+= nl_langinfo.3 setlocale.3 newlocale.3 uselocale.3 localeconv.3 \ diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c index a017b31740b..12614a65b9c 100644 --- a/lib/libc/locale/rune.c +++ b/lib/libc/locale/rune.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rune.c,v 1.9 2022/07/25 21:38:24 guenther Exp $ */ +/* $OpenBSD: rune.c,v 1.10 2022/07/27 20:00:11 guenther Exp $ */ /* $NetBSD: rune.c,v 1.26 2004/05/09 11:26:33 kleink Exp $ */ /*- @@ -262,11 +262,6 @@ _Read_RuneMagi(FILE *fp) rl = (_RuneLocale *)hostdata; rl->rl_variable = rl + 1; - memcpy(rl->rl_magic, frl.frl_magic, sizeof(rl->rl_magic)); - memcpy(rl->rl_encoding, frl.frl_encoding, sizeof(rl->rl_encoding)); - - /* XXX assumes rune_t = uint32_t */ - rl->rl_invalid_rune = ntohl((uint32_t)frl.frl_invalid_rune); rl->rl_variable_len = ntohl((uint32_t)frl.frl_variable_len); for (x = 0; x < _CACHED_RUNES; ++x) { @@ -297,10 +292,9 @@ _Read_RuneMagi(FILE *fp) goto rune_err; /* - * error if we have junk at the tail, - * or if we can't allocate memory. + * error if we have junk at the tail */ - if (ftello(fp) != sb.st_size || __make_ctype_tabs(rl) == -1) + if (ftello(fp) != sb.st_size) goto rune_err; return(rl); diff --git a/lib/libc/locale/rune_local.h b/lib/libc/locale/rune_local.h index d2967475e0a..337e8891c05 100644 --- a/lib/libc/locale/rune_local.h +++ b/lib/libc/locale/rune_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rune_local.h,v 1.7 2017/09/05 03:16:13 schwarze Exp $ */ +/* $OpenBSD: rune_local.h,v 1.8 2022/07/27 20:00:11 guenther Exp $ */ /* $NetBSD: rune_local.h,v 1.7 2003/03/02 22:18:15 tshiozak Exp $ */ /*- @@ -35,9 +35,6 @@ __BEGIN_HIDDEN_DECLS /* rune.c */ extern _RuneLocale *_Read_RuneMagi(FILE *fp); -/* runeglue.c */ -extern int __make_ctype_tabs(_RuneLocale *); - /* ___runetype_mb.c */ extern _RuneType ___runetype_mb(wint_t, _RuneLocale *); diff --git a/lib/libc/locale/runeglue.c b/lib/libc/locale/runeglue.c deleted file mode 100644 index 058e9f1bf0a..00000000000 --- a/lib/libc/locale/runeglue.c +++ /dev/null @@ -1,114 +0,0 @@ -/* $OpenBSD: runeglue.c,v 1.5 2017/08/05 15:16:32 schwarze Exp $ */ -/* $NetBSD: runeglue.c,v 1.10 2003/03/10 21:18:49 tshiozak Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * 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 - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * Id: runeglue.c,v 1.7 2000/12/22 22:52:29 itojun Exp - */ - -/* - * Glue code to hide "rune" facility from user programs. - * This is important to keep backward/future compatibility. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "rune.h" -#include "rune_local.h" -#include "ctype_private.h" - -#if EOF != -1 -#error "EOF != -1" -#endif -#if _CACHED_RUNES != 256 -#error "_CACHED_RUNES != 256" -#endif - -int -__make_ctype_tabs(_RuneLocale *rl) -{ - int i, limit; - struct old_tabs *p; - - p = malloc(sizeof *p); - if (!p) - return -1; - - /* By default, fill the ctype tab completely. */ - limit = CTYPE_NUM_CHARS; - - /* In UTF-8-encoded locales, the single-byte ctype functions - * must only return non-zero values for ASCII characters. - * Any non-ASCII single-byte character is not a valid UTF-8 sequence. - */ - if (strcmp(rl->rl_encoding, "UTF8") == 0) - limit = 128; - - rl->rl_tabs = p; - p->ctype_tab[0] = 0; - p->toupper_tab[0] = EOF; - p->tolower_tab[0] = EOF; - for (i = 0; i < limit; i++) { - p->ctype_tab[i + 1] = 0; - if (rl->rl_runetype[i] & _CTYPE_U) - p->ctype_tab[i + 1] |= _U; - if (rl->rl_runetype[i] & _CTYPE_L) - p->ctype_tab[i + 1] |= _L; - if (rl->rl_runetype[i] & _CTYPE_D) - p->ctype_tab[i + 1] |= _N; - if (rl->rl_runetype[i] & _CTYPE_S) - p->ctype_tab[i + 1] |= _S; - if (rl->rl_runetype[i] & _CTYPE_P) - p->ctype_tab[i + 1] |= _P; - if (rl->rl_runetype[i] & _CTYPE_C) - p->ctype_tab[i + 1] |= _C; - if (rl->rl_runetype[i] & _CTYPE_X) - p->ctype_tab[i + 1] |= _X; - /* - * _B has been used incorrectly (or with older declaration) - * in ctype.h isprint() macro. - * _B does not mean isblank, it means "isprint && !isgraph". - * the following is okay since isblank() was hardcoded in - * function (i.e. isblank() is inherently locale unfriendly). - */ - if ((rl->rl_runetype[i] & (_CTYPE_R | _CTYPE_G)) - == _CTYPE_R) - p->ctype_tab[i + 1] |= _B; - - p->toupper_tab[i + 1] = (short)rl->rl_mapupper[i]; - p->tolower_tab[i + 1] = (short)rl->rl_maplower[i]; - } - for (i = limit; i < CTYPE_NUM_CHARS; i++) - p->ctype_tab[i + 1] = 0; - - return 0; -} diff --git a/lib/libc/locale/runetable.c b/lib/libc/locale/runetable.c index 6adc16350be..5ef9a05fe45 100644 --- a/lib/libc/locale/runetable.c +++ b/lib/libc/locale/runetable.c @@ -44,10 +44,6 @@ #include "citrus_ctype.h" _RuneLocale _DefaultRuneLocale = { - _RUNE_MAGIC_1, - "NONE", - _DEFAULT_INVALID_RUNE, - { /*00*/ _CTYPE_C, _CTYPE_C, _CTYPE_C, @@ -252,5 +248,4 @@ _RuneLocale _DefaultRuneLocale = { { NULL, NULL, NULL }, { NULL, NULL, NULL }, }, - NULL }; diff --git a/lib/libc/locale/runetype.h b/lib/libc/locale/runetype.h index 8532dfef493..dab5db33d99 100644 --- a/lib/libc/locale/runetype.h +++ b/lib/libc/locale/runetype.h @@ -1,7 +1,7 @@ #ifndef _NB_RUNETYPE_H_ #define _NB_RUNETYPE_H_ -/* $OpenBSD: runetype.h,v 1.9 2022/07/25 21:38:24 guenther Exp $ */ +/* $OpenBSD: runetype.h,v 1.10 2022/07/27 20:00:11 guenther Exp $ */ /* $NetBSD: runetype.h,v 1.18 2003/08/07 16:43:04 agc Exp $ */ /*- * Copyright (c) 1993 @@ -168,23 +168,10 @@ typedef struct _WCTypeEntry { #define _WCTYPE_NINDEXES 12 /* - * ctype stuffs + * The parts of _FileRuneLocale needed at runtime */ -struct old_tabs { - /* compatibility with `old' ctype */ - char ctype_tab[CTYPE_NUM_CHARS + 1]; - short tolower_tab[256 + 1]; - short toupper_tab[256 + 1]; -}; - typedef struct { - /* - * copied from _FileRuneLocale - */ - char rl_magic[8]; /* Magic saying what version we are */ - char rl_encoding[32];/* ASCII name of this encoding */ - rune_t rl_invalid_rune; _RuneType rl_runetype[_CACHED_RUNES]; rune_t rl_maplower[_CACHED_RUNES]; rune_t rl_mapupper[_CACHED_RUNES]; @@ -200,9 +187,6 @@ typedef struct { */ char *rl_codeset; _WCTransEntry rl_wctrans[_WCTRANS_NINDEXES]; - - struct old_tabs * rl_tabs; - } _RuneLocale; /* magic number for LC_CTYPE (rune)locale declaration */