Print this page
2964 need POSIX 2008 locale object support (more C++ fixes)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/head/string.h
+++ new/usr/src/head/string.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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 */
26 26
27 27 /* Copyright (c) 1988 AT&T */
28 28 /* All Rights Reserved */
29 29
30 30 #ifndef _STRING_H
31 31 #define _STRING_H
32 32
33 33 #include <iso/string_iso.h>
34 34
35 35 /*
36 36 * Allow global visibility for symbols defined in
37 37 * C++ "std" namespace in <iso/string_iso.h>.
38 38 */
39 39 #if __cplusplus >= 199711L
40 40 using std::size_t;
41 41 using std::memchr;
42 42 using std::memcmp;
43 43 using std::memcpy;
44 44 using std::memmove;
45 45 using std::memset;
46 46 using std::strcat;
47 47 using std::strchr;
48 48 using std::strcmp;
49 49 using std::strcoll;
50 50 using std::strcpy;
51 51 using std::strcspn;
52 52 using std::strerror;
53 53 using std::strlen;
54 54 using std::strncat;
55 55 using std::strncmp;
56 56 using std::strncpy;
57 57 using std::strpbrk;
58 58 using std::strrchr;
59 59 using std::strspn;
60 60 using std::strstr;
61 61 using std::strtok;
62 62 using std::strxfrm;
63 63 #endif
64 64
65 65 #ifdef __cplusplus
66 66 extern "C" {
67 67 #endif
68 68
69 69 #if defined(__STDC__)
70 70
71 71 #if defined(__EXTENSIONS__) || \
72 72 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
73 73 defined(_XPG6) || defined(_REENTRANT)
74 74 extern int strerror_r(int, char *, size_t);
75 75 #endif
76 76
77 77 #if defined(__EXTENSIONS__) || \
78 78 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
79 79 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
80 80 extern char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
81 81 char **_RESTRICT_KYWD);
82 82 #endif
83 83
84 84 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
85 85 defined(__XOPEN_OR_POSIX)
86 86 extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD,
87 87 int, size_t);
88 88 #endif
89 89
|
↓ open down ↓ |
89 lines elided |
↑ open up ↑ |
90 90 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
91 91
92 92 extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
93 93 extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
94 94 extern char *strndup(const char *, size_t);
95 95 extern size_t strnlen(const char *, size_t);
96 96 extern char *strsignal(int);
97 97
98 98 #ifndef _LOCALE_T
99 99 #define _LOCALE_T
100 -typedef struct locale *locale_t;
100 +typedef struct _locale *locale_t;
101 101 #endif
102 102
103 103 extern int strcoll_l(const char *, const char *, locale_t);
104 104 extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
105 105 size_t, locale_t);
106 106 extern int strcasecmp_l(const char *, const char *, locale_t);
107 107 extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
108 108
109 109 #endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */
110 110
111 111 #if !defined(_STRICT_SYMBOLS)
112 112
113 113 /* Note that some of these are also declared in strings.h for XPG4_2+ */
114 114 extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
115 115 extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
116 116 extern int ffs(int);
117 117 extern int ffsl(long);
118 118 extern int ffsll(long long);
119 119 extern int fls(int);
120 120 extern int flsl(long);
121 121 extern int flsll(long long);
122 122 extern void *memmem(const void *, size_t, const void *, size_t);
123 123 extern char *strcasestr(const char *, const char *);
124 124 extern char *strnstr(const char *, const char *, size_t);
125 125 extern size_t strlcpy(char *, const char *, size_t);
126 126 extern size_t strlcat(char *, const char *, size_t);
127 127 extern char *strsep(char **stringp, const char *delim);
128 128 extern char *strchrnul(const char *, int);
129 129 extern char *strcasestr_l(const char *, const char *, locale_t);
130 130 extern int strcasecmp(const char *, const char *);
131 131 extern int strncasecmp(const char *, const char *, size_t);
132 132 #endif /* defined(__EXTENSIONS__)... */
133 133
134 134 #if defined(__EXTENSIONS__) || \
135 135 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
136 136 defined(_XPG4_2)
137 137 extern char *strdup(const char *);
138 138 #endif
139 139
140 140 #if defined(__EXTENSIONS__) || \
141 141 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
142 142 #if defined(__GNUC__)
143 143
144 144 /*
145 145 * gcc provides this inlining facility but Studio C does not.
146 146 * We should use it exclusively once Studio C also provides it.
147 147 */
148 148 extern void *__builtin_alloca(size_t);
149 149
150 150 #define strdupa(s) \
151 151 (__extension__( \
152 152 { \
153 153 char *__str = (char *)(s); \
154 154 strcpy((char *)__builtin_alloca(strlen(__str) + 1), __str); \
155 155 }))
156 156
157 157 #define strndupa(s, n) \
158 158 (__extension__( \
159 159 { \
160 160 char *__str = (char *)(s); \
161 161 size_t __len = strnlen(__str, (n)); \
162 162 (__str = strncpy((char *)__builtin_alloca(__len + 1), \
163 163 __str, __len), \
164 164 __str[__len] = '\0', __str); \
165 165 }))
166 166
167 167 #else /* __GNUC__ */
168 168
169 169 #if defined(unix) /* excludes c99 */
170 170 /*
171 171 * Studio C currently can't do the gcc-style inlining,
172 172 * so we use thread-local storage instead.
173 173 */
174 174 extern void *__builtin_alloca(size_t);
175 175 extern __thread char *__strdupa_str;
176 176 extern __thread size_t __strdupa_len;
177 177
178 178 #define strdupa(s) \
179 179 (__strdupa_str = (char *)(s), \
180 180 strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \
181 181 __strdupa_str))
182 182
183 183 #define strndupa(s, n) \
184 184 (__strdupa_str = (char *)(s), \
185 185 __strdupa_len = strnlen(__strdupa_str, (n)), \
186 186 __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \
187 187 __strdupa_str, __strdupa_len), \
188 188 __strdupa_str[__strdupa_len] = '\0', __strdupa_str)
189 189 #endif /* unix */
190 190
191 191 #endif /* __GNUC__ */
192 192 #endif /* __EXTENSIONS__ ... */
193 193
194 194 #else /* __STDC__ */
195 195
196 196 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
197 197 defined(_XPG6) || defined(_REENTRANT)
198 198 extern int strerror_r();
199 199 #endif
200 200
201 201 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
202 202 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
203 203 extern char *strtok_r();
204 204 #endif
205 205
206 206 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
207 207 defined(__XOPEN_OR_POSIX)
208 208 extern void *memccpy();
209 209 #endif
210 210
211 211 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
212 212 extern int strcasecmp();
213 213 extern int strncasecmp();
214 214 extern int strcasecmp_l();
215 215 extern int strncasecmp_l();
216 216 extern char *stpcpy();
217 217 extern char *stpncpy();
218 218 extern char *strndup();
219 219 extern size_t strnlen();
220 220 extern char *strsignal();
221 221 #endif
222 222
223 223 #if !defined(_STRICT_SYMBOLS)
224 224 extern int uucopy();
225 225 extern int uucopystr();
226 226 extern int ffs();
227 227 extern int ffsl();
228 228 extern int ffsll();
229 229 extern int fls();
230 230 extern int flsl();
231 231 extern int flsll();
232 232 extern char *strcasestr();
233 233 extern char *strcasestr_l();
234 234 extern char *strnstr();
235 235 extern size_t strlcpy();
236 236 extern size_t strlcat();
237 237 extern char *strsep();
238 238 extern char *strchrnul();
239 239 #endif /* _STRICT_SYMBOLS */
240 240
241 241 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
242 242 extern char *strdup();
243 243 #endif
244 244
245 245 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
246 246 extern size_t strcoll_l();
247 247 extern size_t strxfrm_l();
248 248 #endif
249 249
250 250 #endif /* __STDC__ */
251 251
252 252 #ifdef __cplusplus
253 253 }
254 254 #endif
255 255
256 256 #endif /* _STRING_H */
|
↓ open down ↓ |
146 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX