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