rbtree: add rb_search_exact()
[nasm.git] / include / nctype.h
blobba594b972d36f080f1e3752ae0d089bf58792552
1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2018 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
9 * conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * ctype-like functions specific to NASM
37 #ifndef NASM_NCTYPE_H
38 #define NASM_NCTYPE_H
40 #include "compiler.h"
42 void nasm_ctype_init(void);
44 extern unsigned char nasm_tolower_tab[256];
45 static inline char nasm_tolower(char x)
47 return nasm_tolower_tab[(unsigned char)x];
51 * NASM ctype table
53 enum nasm_ctype {
54 NCT_CTRL = 0x0001,
55 NCT_SPACE = 0x0002,
56 NCT_ASCII = 0x0004,
57 NCT_LOWER = 0x0008, /* isalpha(x) && tolower(x) == x */
58 NCT_UPPER = 0x0010, /* isalpha(x) && tolower(x) != x */
59 NCT_DIGIT = 0x0020,
60 NCT_HEX = 0x0040,
61 NCT_ID = 0x0080,
62 NCT_IDSTART = 0x0100,
63 NCT_MINUS = 0x0200, /* - */
64 NCT_DOLLAR = 0x0400, /* $ */
65 NCT_UNDER = 0x0800, /* _ */
66 NCT_QUOTE = 0x1000 /* " ' ` */
69 extern uint16_t nasm_ctype_tab[256];
70 static inline bool nasm_ctype(unsigned char x, enum nasm_ctype mask)
72 return (nasm_ctype_tab[x] & mask) != 0;
75 static inline bool nasm_isspace(char x)
77 return nasm_ctype(x, NCT_SPACE);
80 static inline bool nasm_isalpha(char x)
82 return nasm_ctype(x, NCT_LOWER|NCT_UPPER);
85 static inline bool nasm_isdigit(char x)
87 return nasm_ctype(x, NCT_DIGIT);
89 static inline bool nasm_isalnum(char x)
91 return nasm_ctype(x, NCT_LOWER|NCT_UPPER|NCT_DIGIT);
93 static inline bool nasm_isxdigit(char x)
95 return nasm_ctype(x, NCT_HEX);
97 static inline bool nasm_isidstart(char x)
99 return nasm_ctype(x, NCT_IDSTART);
101 static inline bool nasm_isidchar(char x)
103 return nasm_ctype(x, NCT_ID);
105 static inline bool nasm_isbrcchar(char x)
107 return nasm_ctype(x, NCT_ID|NCT_MINUS);
109 static inline bool nasm_isnumstart(char x)
111 return nasm_ctype(x, NCT_DIGIT|NCT_DOLLAR);
113 static inline bool nasm_isnumchar(char x)
115 return nasm_ctype(x, NCT_DIGIT|NCT_LOWER|NCT_UPPER|NCT_UNDER);
117 static inline bool nasm_isquote(char x)
119 return nasm_ctype(x, NCT_QUOTE);
122 static inline void nasm_ctype_tasm_mode(void)
124 /* No differences at the present moment */
127 #endif /* NASM_NCTYPE_H */