Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/regex.h
+++ new/usr/src/head/regex.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 + *
23 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 /*
28 30 * Copyright 1989, 1994 by Mortice Kern Systems Inc.
29 31 * All rights reserved.
30 32 */
31 33 /*
32 34 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
33 35 * Use is subject to license terms.
34 36 */
35 37
36 38 #ifndef _REGEX_H
37 39 #define _REGEX_H
38 40
39 41 #include <sys/feature_tests.h>
40 42 #include <sys/types.h>
41 43
42 44 #ifdef __cplusplus
43 45 extern "C" {
44 46 #endif
45 47
46 48
47 49 /*
48 50 * wchar_t is a built-in type in standard C++ and as such is not
49 51 * defined here when using standard C++. However, the GNU compiler
50 52 * fixincludes utility nonetheless creates its own version of this
51 53 * header for use by gcc and g++. In that version it adds a redundant
52 54 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
53 55 * header we need to include the following magic comment:
54 56 *
55 57 * we must use the C++ compiler's type
56 58 *
57 59 * The above comment should not be removed or changed until GNU
58 60 * gcc/fixinc/inclhack.def is updated to bypass this header.
59 61 */
60 62 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
61 63 #ifndef _WCHAR_T
62 64 #define _WCHAR_T
63 65 #if defined(_LP64)
64 66 typedef int wchar_t;
65 67 #else
66 68 typedef long wchar_t;
67 69 #endif
68 70 #endif /* !_WCHAR_T */
69 71 #endif /* !defined(__cplusplus) ... */
70 72
71 73 typedef ssize_t regoff_t;
72 74
73 75 /* regcomp flags */
74 76 #define REG_BASIC 0x00
75 77 #define REG_EXTENDED 0x01 /* Use Extended Regular Expressions */
76 78 #define REG_NEWLINE 0x08 /* Treat \n as regular character */
77 79 #define REG_ICASE 0x04 /* Ignore case in match */
78 80 #define REG_NOSUB 0x02 /* Don't set subexpression */
79 81 #define REG_EGREP 0x1000 /* running as egrep(1) */
80 82
81 83 /* non-standard flags - note that most of these are not supported */
82 84 #define REG_DELIM 0x10 /* string[0] is delimiter */
83 85 #define REG_DEBUG 0x20 /* Debug recomp and regexec */
84 86 #define REG_ANCHOR 0x40 /* Implicit ^ and $ */
85 87 #define REG_WORDS 0x80 /* \< and \> match word boundries */
86 88
87 89 /* FreeBSD additions */
88 90 #define REG_DUMP 0x2000
89 91 #define REG_PEND 0x4000
90 92 #define REG_NOSPEC 0x8000
91 93 #define REG_STARTEND 0x10000
92 94
93 95 /* internal flags */
94 96 #define REG_MUST 0x100 /* check for regmust substring */
95 97
96 98 /* regexec flags */
97 99 #define REG_NOTBOL 0x200 /* string is not BOL */
98 100 #define REG_NOTEOL 0x400 /* string has no EOL */
99 101 #define REG_NOOPT 0x800 /* don't do regmust optimization */
100 102
101 103 /* regcomp and regexec return codes */
102 104 #define REG_OK 0 /* success (non-standard) */
103 105 #define REG_NOMATCH 1 /* regexec failed to match */
104 106 #define REG_ECOLLATE 2 /* invalid collation element ref. */
105 107 #define REG_EESCAPE 3 /* trailing \ in pattern */
106 108 #define REG_ENEWLINE 4 /* \n found before end of pattern */
107 109 #define REG_ENSUB 5 /* more than 9 \( \) pairs (OBS) */
108 110 #define REG_ESUBREG 6 /* number in \[0-9] invalid */
109 111 #define REG_EBRACK 7 /* [ ] imbalance */
110 112 #define REG_EPAREN 8 /* ( ) imbalance */
111 113 #define REG_EBRACE 9 /* \{ \} imbalance */
112 114 #define REG_ERANGE 10 /* invalid endpoint in range */
113 115 #define REG_ESPACE 11 /* no memory for compiled pattern */
114 116 #define REG_BADRPT 12 /* invalid repetition */
115 117 #define REG_ECTYPE 13 /* invalid char-class type */
116 118 #define REG_BADPAT 14 /* syntax error */
117 119 #define REG_BADBR 15 /* \{ \} contents bad */
118 120 #define REG_EFATAL 16 /* internal error, not POSIX.2 */
119 121 #define REG_ECHAR 17 /* invalid mulitbyte character */
120 122 #define REG_STACK 18 /* backtrack stack overflow */
121 123 #define REG_ENOSYS 19 /* function not supported (XPG4) */
122 124 #define REG__LAST 20 /* first unused code */
123 125 #define REG_EBOL 21 /* ^ anchor and not BOL */
124 126 #define REG_EEOL 22 /* $ anchor and not EOL */
125 127 #define _REG_BACKREF_MAX 9 /* Max # of subexp. backreference */
126 128
127 129 typedef struct { /* regcomp() data saved for regexec() */
128 130 size_t re_nsub; /* # of subexpressions in RE pattern */
129 131
130 132 /*
131 133 * Internal use only. Note that any changes to this structure
132 134 * have to preserve sizing, as it is baked into applications.
133 135 */
134 136 struct re_guts *re_g;
↓ open down ↓ |
102 lines elided |
↑ open up ↑ |
135 137 int re_magic;
136 138 const char *re_endp;
137 139
138 140 /* here for compat */
139 141 size_t re_len; /* # wchar_t chars in compiled pattern */
140 142 struct _regex_ext_t *re_sc; /* for binary compatibility */
141 143 } regex_t;
142 144
143 145 /* subexpression positions */
144 146 typedef struct {
145 -#ifdef __STDC__
146 147 const char *rm_sp, *rm_ep; /* Start pointer, end pointer */
147 -#else
148 - char *rm_sp, *rm_ep; /* Start pointer, end pointer */
149 -#endif
150 148 regoff_t rm_so, rm_eo; /* Start offset, end offset */
151 149 int rm_ss, rm_es; /* Used internally */
152 150 } regmatch_t;
153 151
154 152
155 153 /*
156 154 * Additional API and structs to support regular expression manipulations
157 155 * on wide characters.
158 156 */
159 157
160 -#if defined(__STDC__)
161 -
162 158 extern int regcomp(regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, int);
163 159 extern int regexec(const regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
164 160 size_t, regmatch_t *_RESTRICT_KYWD, int);
165 161 extern size_t regerror(int, const regex_t *_RESTRICT_KYWD,
166 162 char *_RESTRICT_KYWD, size_t);
167 163 extern void regfree(regex_t *);
168 164
169 -#else /* defined(__STDC__) */
170 -
171 -extern int regcomp();
172 -extern int regexec();
173 -extern size_t regerror();
174 -extern void regfree();
175 -
176 -#endif /* defined(__STDC__) */
177 -
178 165 #ifdef __cplusplus
179 166 }
180 167 #endif
181 168
182 169 #endif /* _REGEX_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX