-/* $OpenBSD: wctype.h,v 1.2 2017/09/05 03:16:13 schwarze Exp $ */
+/* $OpenBSD: wctype.h,v 1.3 2022/07/25 21:38:24 guenther Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
PROTO_DEPRECATED(towupper_l);
PROTO_STD_DEPRECATED(wctrans);
PROTO_DEPRECATED(wctrans_l);
-PROTO_STD_DEPRECATED(wctype);
+PROTO_NORMAL(wctype);
PROTO_DEPRECATED(wctype_l);
#endif /* !_LIBC_WCTYPE_H_ */
-# $OpenBSD: Makefile.inc,v 1.24 2018/04/04 14:53:02 schwarze Exp $
+# $OpenBSD: Makefile.inc,v 1.25 2022/07/25 21:38:24 guenther Exp $
# locale sources
.PATH: ${LIBCSRCDIR}/locale
localeconv.c nl_langinfo.c nl_langinfo_l.c setlocale.c \
duplocale.c freelocale.c newlocale.c uselocale.c \
__mb_cur_max.c _CurrentRuneLocale.c _get_locname.c \
- isctype_l.c iswctype.c iswctype_l.c \
+ isctype_l.c iswctype.c iswctype_l.c wctype.c \
mblen.c mbrlen.c mbstowcs.c mbtowc.c multibyte_citrus.c wcscoll.c \
wcscoll_l.c \
wcstombs.c wctob.c wctomb.c wcstof.c wcstod.c wcstold.c wcstol.c \
-/* $OpenBSD: iswctype.c,v 1.7 2017/09/05 03:16:13 schwarze Exp $ */
+/* $OpenBSD: iswctype.c,v 1.8 2022/07/25 21:38:24 guenther Exp $ */
/* $NetBSD: iswctype.c,v 1.15 2005/02/09 21:35:46 kleink Exp $ */
/*
}
DEF_STRONG(towctrans);
-wctype_t
-wctype(const char *property)
-{
- int i;
- _RuneLocale *rl = _CurrentRuneLocale();
-
- for (i=0; i<_WCTYPE_NINDEXES; i++)
- if (!strcmp(rl->rl_wctype[i].te_name, property))
- return ((wctype_t)&rl->rl_wctype[i]);
- return ((wctype_t)NULL);
-}
-
int
iswctype(wint_t c, wctype_t charclass)
{
-/* $OpenBSD: iswctype_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */
+/* $OpenBSD: iswctype_l.c,v 1.2 2022/07/25 21:38:24 guenther Exp $ */
/* $NetBSD: iswctype.c,v 1.15 2005/02/09 21:35:46 kleink Exp $ */
/*
return towctrans(c, desc);
}
-wctype_t
-wctype_l(const char *property, locale_t locale)
-{
- _RuneLocale *rl;
- int i;
-
- rl = __runelocale(locale);
- for (i = 0; i < _WCTYPE_NINDEXES; i++)
- if (strcmp(rl->rl_wctype[i].te_name, property) == 0)
- return &rl->rl_wctype[i];
- return NULL;
-}
-
int
iswctype_l(wint_t c, wctype_t charclass, locale_t locale)
{
-/* $OpenBSD: rune.c,v 1.8 2019/06/28 13:32:41 deraadt Exp $ */
+/* $OpenBSD: rune.c,v 1.9 2022/07/25 21:38:24 guenther Exp $ */
/* $NetBSD: rune.c,v 1.26 2004/05/09 11:26:33 kleink Exp $ */
/*-
static int readrange(_RuneLocale *, _RuneRange *, uint32_t, void *, FILE *);
static void _freeentry(_RuneRange *);
-static void _wctype_init(_RuneLocale *rl);
static int
readrange(_RuneLocale *rl, _RuneRange *rr, uint32_t nranges, void *lastp,
}
}
-void
-_wctype_init(_RuneLocale *rl)
-{
- memcpy(&rl->rl_wctype, &_DefaultRuneLocale.rl_wctype,
- sizeof(rl->rl_wctype));
-}
-
_RuneLocale *
_Read_RuneMagi(FILE *fp)
goto rune_err;
if (find_codeset(rl))
goto rune_err;
- _wctype_init(rl);
/*
* error if we have junk at the tail,
{ NULL, NULL, NULL },
{ NULL, NULL, NULL },
},
- {
- { "alnum", _CTYPE_A|_CTYPE_D },
- { "alpha", _CTYPE_A },
- { "blank", _CTYPE_B },
- { "cntrl", _CTYPE_C },
- { "digit", _CTYPE_D },
- { "graph", _CTYPE_G },
- { "lower", _CTYPE_L },
- { "print", _CTYPE_R },
- { "punct", _CTYPE_P },
- { "space", _CTYPE_S },
- { "upper", _CTYPE_U },
- { "xdigit", _CTYPE_X },
- },
NULL
};
#ifndef _NB_RUNETYPE_H_
#define _NB_RUNETYPE_H_
-/* $OpenBSD: runetype.h,v 1.8 2016/09/05 09:47:03 schwarze Exp $ */
+/* $OpenBSD: runetype.h,v 1.9 2022/07/25 21:38:24 guenther Exp $ */
/* $NetBSD: runetype.h,v 1.18 2003/08/07 16:43:04 agc Exp $ */
/*-
* Copyright (c) 1993
* wctype stuffs.
*/
typedef struct _WCTypeEntry {
- char *te_name;
+ char te_name[8];
_RuneType te_mask;
} _WCTypeEntry;
#define _WCTYPE_INDEX_ALNUM 0
*/
char *rl_codeset;
_WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];
- _WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];
struct old_tabs * rl_tabs;
--- /dev/null
+/* $OpenBSD: wctype.c,v 1.1 2022/07/25 21:38:24 guenther Exp $ */
+/* $NetBSD: iswctype.c,v 1.15 2005/02/09 21:35:46 kleink Exp $ */
+
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. 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 <wchar.h>
+#include <wctype.h>
+#include <string.h>
+#include "rune.h"
+#include "runetype.h"
+
+static struct _WCTypeEntry wctype_entries[_WCTYPE_NINDEXES] =
+{
+ { "alnum", _CTYPE_A|_CTYPE_D },
+ { "alpha", _CTYPE_A },
+ { "blank", _CTYPE_B },
+ { "cntrl", _CTYPE_C },
+ { "digit", _CTYPE_D },
+ { "graph", _CTYPE_G },
+ { "lower", _CTYPE_L },
+ { "print", _CTYPE_R },
+ { "punct", _CTYPE_P },
+ { "space", _CTYPE_S },
+ { "upper", _CTYPE_U },
+ { "xdigit", _CTYPE_X },
+};
+
+wctype_t
+wctype(const char *property)
+{
+ int i;
+
+ for (i = 0; i < _WCTYPE_NINDEXES; i++)
+ if (strcmp(wctype_entries[i].te_name, property) == 0)
+ return &wctype_entries[i];
+ return NULL;
+}
+DEF_STRONG(wctype);
+
+wctype_t
+wctype_l(const char *property, locale_t locale __attribute__((__unused__)))
+{
+ return wctype(property);
+}