Super User's BSD Cross Reference: /NetBSD/lib/libc/regex/utils.h

1 /* $NetBSD: utils.h,v 1.9 2021年04月22日 19:20:24 christos Exp $ */
2
3 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
7 * Copyright (c) 1992, 1993, 1994
8 * The Regents of the University of California. All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * Henry Spencer.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)utils.h 8.3 (Berkeley) 3/20/94
38 * $FreeBSD: head/lib/libc/regex/utils.h 341838 2018年12月12日 04:23:00Z yuripv $
39 */
40
41#ifdef NLS
42#include <wchar.h>
43#include <wctype.h>
44#else
45#include <ctype.h>
46#define wint_t regex_wint_t
47#define mbstate_t regex_mbstate_t
48#define wctype_t regex_wctype_t
49 typedef short wint_t;
50 typedef char mbstate_t;
51 typedef short wctype_t;
52#define iswupper(a) isupper(a)
53#define iswlower(a) islower(a)
54#define iswalpha(a) isalpha(a)
55#define iswalnum(a) isalnum(a)
56#define towupper(a) toupper(a)
57#define towlower(a) tolower(a)
58 extern wctype_t __regex_wctype(const char *);
59 extern int __regex_iswctype(wint_t, wctype_t);
60#define wctype(s) __regex_wctype(s)
61#define iswctype(c, t) __regex_iswctype((c), (t))
62#endif
63
64 /* utility definitions */
65#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
66#define INFINITY (DUPMAX + 1)
67
68#define NC_MAX (CHAR_MAX - CHAR_MIN + 1)
69#define NC ((MB_CUR_MAX) == 1 ? (NC_MAX) : (128))
70 typedef unsigned char uch;
71
72 /* switch off assertions (if not already off) if no REDEBUG */
73#ifndef REDEBUG
74#ifndef NDEBUG
75#define NDEBUG /* no assertions please */
76#endif
77#endif
78#include <assert.h>
79
80 /* for old systems with bcopy() but no memmove() */
81#ifdef USEBCOPY
82#define memmove(d, s, c) bcopy(s, d, c)
83#endif
84 

AltStyle によって変換されたページ (->オリジナル) /