don't use __link_set_* stuff for locale implementation. patch reviewed by matt@, thanks.diff -r1.9 -r1.10 src/lib/libc/citrus/citrus_lc_ctype.c
(tnozaki)
--- src/lib/libc/citrus/citrus_lc_ctype.c 2010/06/19 13:26:51 1.9
+++ src/lib/libc/citrus/citrus_lc_ctype.c 2012/03/04 21:14:55 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: citrus_lc_ctype.c,v 1.9 2010/06/19 13:26:51 tnozaki Exp $ */ | 1 | /* $NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: citrus_lc_ctype.c,v 1.9 2010/06/19 13:26:51 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include "reentrant.h" | 34 | #include "reentrant.h" | |
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/ctype_bits.h> | 36 | #include <sys/ctype_bits.h> | |
37 | #include <sys/queue.h> | 37 | #include <sys/queue.h> | |
38 | #include <assert.h> | 38 | #include <assert.h> | |
39 | #include <errno.h> | 39 | #include <errno.h> | |
40 | #include <langinfo.h> | 40 | #include <langinfo.h> | |
41 | #include <limits.h> | 41 | #include <limits.h> | |
42 | #define __SETLOCALE_SOURCE__ | 42 | #define __SETLOCALE_SOURCE__ | |
43 | #include <locale.h> | 43 | #include <locale.h> | |
44 | #include <stddef.h> | 44 | #include <stddef.h> | |
@@ -120,14 +120,13 @@ _PREFIX(fixup)(_RuneLocale *data) | @@ -120,14 +120,13 @@ _PREFIX(fixup)(_RuneLocale *data) | |||
120 | _tolower_tab_ = data->rl_tolower_tab; | 120 | _tolower_tab_ = data->rl_tolower_tab; | |
121 | _toupper_tab_ = data->rl_toupper_tab; | 121 | _toupper_tab_ = data->rl_toupper_tab; | |
122 | _CurrentRuneLocale = data; | 122 | _CurrentRuneLocale = data; | |
123 | } | 123 | } | |
124 | 124 | |||
125 | /* | 125 | /* | |
126 | * macro required by nb_lc_template.h | 126 | * macro required by nb_lc_template.h | |
127 | */ | 127 | */ | |
128 | #define _CATEGORY_ID LC_CTYPE | 128 | #define _CATEGORY_ID LC_CTYPE | |
129 | #define _CATEGORY_NAME "LC_CTYPE" | 129 | #define _CATEGORY_NAME "LC_CTYPE" | |
130 | #define _CATEGORY_DEFAULT _DefaultRuneLocale | 130 | #define _CATEGORY_DEFAULT _DefaultRuneLocale | |
131 | 131 | |||
132 | #include "nb_lc_template.h" | 132 | #include "nb_lc_template.h" | |
133 | _LOCALE_CATEGORY_ENTRY(_citrus_LC_CTYPE_); |
--- src/lib/libc/citrus/citrus_lc_messages.c 2010/06/13 04:14:57 1.4
+++ src/lib/libc/citrus/citrus_lc_messages.c 2012/03/04 21:14:55 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: citrus_lc_messages.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */ | 1 | /* $NetBSD: citrus_lc_messages.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: citrus_lc_messages.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: citrus_lc_messages.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include "namespace.h" | 34 | #include "namespace.h" | |
35 | #include "reentrant.h" | 35 | #include "reentrant.h" | |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> | |
37 | #include <sys/localedef.h> | 37 | #include <sys/localedef.h> | |
38 | #include <sys/queue.h> | 38 | #include <sys/queue.h> | |
39 | #include <assert.h> | 39 | #include <assert.h> | |
40 | #include <errno.h> | 40 | #include <errno.h> | |
41 | #include <langinfo.h> | 41 | #include <langinfo.h> | |
42 | #include <limits.h> | 42 | #include <limits.h> | |
43 | #define __SETLOCALE_SOURCE__ | 43 | #define __SETLOCALE_SOURCE__ | |
44 | #include <locale.h> | 44 | #include <locale.h> | |
@@ -150,14 +150,13 @@ _citrus_LC_MESSAGES_init_fallback(_Messa | @@ -150,14 +150,13 @@ _citrus_LC_MESSAGES_init_fallback(_Messa | |||
150 | 150 | |||
151 | fatal: | 151 | fatal: | |
152 | _citrus_LC_MESSAGES_uninit(data); | 152 | _citrus_LC_MESSAGES_uninit(data); | |
153 | return EFTYPE; | 153 | return EFTYPE; | |
154 | } | 154 | } | |
155 | 155 | |||
156 | /* | 156 | /* | |
157 | * macro required by citrus_lc_template.h | 157 | * macro required by citrus_lc_template.h | |
158 | */ | 158 | */ | |
159 | #define _CATEGORY_DB "LC_MESSAGES/SYS_LC_MESSAGES" | 159 | #define _CATEGORY_DB "LC_MESSAGES/SYS_LC_MESSAGES" | |
160 | #define _CATEGORY_MAGIC _CITRUS_LC_MESSAGES_MAGIC_1 | 160 | #define _CATEGORY_MAGIC _CITRUS_LC_MESSAGES_MAGIC_1 | |
161 | 161 | |||
162 | #include "citrus_lc_template.h" | 162 | #include "citrus_lc_template.h" | |
163 | _LOCALE_CATEGORY_ENTRY(_citrus_LC_MESSAGES_); |
--- src/lib/libc/citrus/citrus_lc_monetary.c 2010/06/13 04:14:57 1.4
+++ src/lib/libc/citrus/citrus_lc_monetary.c 2012/03/04 21:14:55 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: citrus_lc_monetary.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */ | 1 | /* $NetBSD: citrus_lc_monetary.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: citrus_lc_monetary.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: citrus_lc_monetary.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include "namespace.h" | 34 | #include "namespace.h" | |
35 | #include "reentrant.h" | 35 | #include "reentrant.h" | |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> | |
37 | #include <sys/localedef.h> | 37 | #include <sys/localedef.h> | |
38 | #include <sys/queue.h> | 38 | #include <sys/queue.h> | |
39 | #include <assert.h> | 39 | #include <assert.h> | |
40 | #include <errno.h> | 40 | #include <errno.h> | |
41 | #include <langinfo.h> | 41 | #include <langinfo.h> | |
42 | #include <limits.h> | 42 | #include <limits.h> | |
43 | #define __SETLOCALE_SOURCE__ | 43 | #define __SETLOCALE_SOURCE__ | |
44 | #include <locale.h> | 44 | #include <locale.h> | |
@@ -207,14 +207,13 @@ _citrus_LC_MONETARY_init_fallback(_Monet | @@ -207,14 +207,13 @@ _citrus_LC_MONETARY_init_fallback(_Monet | |||
207 | 207 | |||
208 | fatal: | 208 | fatal: | |
209 | _citrus_LC_MONETARY_uninit(data); | 209 | _citrus_LC_MONETARY_uninit(data); | |
210 | return EFTYPE; | 210 | return EFTYPE; | |
211 | } | 211 | } | |
212 | 212 | |||
213 | /* | 213 | /* | |
214 | * macro required by citrus_lc_template.h | 214 | * macro required by citrus_lc_template.h | |
215 | */ | 215 | */ | |
216 | #define _CATEGORY_DB "LC_MONETARY" | 216 | #define _CATEGORY_DB "LC_MONETARY" | |
217 | #define _CATEGORY_MAGIC _CITRUS_LC_MONETARY_MAGIC_1 | 217 | #define _CATEGORY_MAGIC _CITRUS_LC_MONETARY_MAGIC_1 | |
218 | 218 | |||
219 | #include "citrus_lc_template.h" | 219 | #include "citrus_lc_template.h" | |
220 | _LOCALE_CATEGORY_ENTRY(_citrus_LC_MONETARY_); |
--- src/lib/libc/citrus/citrus_lc_numeric.c 2010/06/13 04:14:57 1.4
+++ src/lib/libc/citrus/citrus_lc_numeric.c 2012/03/04 21:14:55 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: citrus_lc_numeric.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */ | 1 | /* $NetBSD: citrus_lc_numeric.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: citrus_lc_numeric.c,v 1.4 2010/06/13 04:14:57 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: citrus_lc_numeric.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include "namespace.h" | 34 | #include "namespace.h" | |
35 | #include "reentrant.h" | 35 | #include "reentrant.h" | |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> | |
37 | #include <sys/localedef.h> | 37 | #include <sys/localedef.h> | |
38 | #include <sys/queue.h> | 38 | #include <sys/queue.h> | |
39 | #include <assert.h> | 39 | #include <assert.h> | |
40 | #include <errno.h> | 40 | #include <errno.h> | |
41 | #include <langinfo.h> | 41 | #include <langinfo.h> | |
42 | #include <limits.h> | 42 | #include <limits.h> | |
43 | #define __SETLOCALE_SOURCE__ | 43 | #define __SETLOCALE_SOURCE__ | |
44 | #include <locale.h> | 44 | #include <locale.h> | |
@@ -156,14 +156,13 @@ _citrus_LC_NUMERIC_init_fallback(_Numeri | @@ -156,14 +156,13 @@ _citrus_LC_NUMERIC_init_fallback(_Numeri | |||
156 | 156 | |||
157 | fatal: | 157 | fatal: | |
158 | _citrus_LC_NUMERIC_uninit(data); | 158 | _citrus_LC_NUMERIC_uninit(data); | |
159 | return EFTYPE; | 159 | return EFTYPE; | |
160 | } | 160 | } | |
161 | 161 | |||
162 | /* | 162 | /* | |
163 | * macro required by citrus_lc_template.h | 163 | * macro required by citrus_lc_template.h | |
164 | */ | 164 | */ | |
165 | #define _CATEGORY_DB "LC_NUMERIC" | 165 | #define _CATEGORY_DB "LC_NUMERIC" | |
166 | #define _CATEGORY_MAGIC _CITRUS_LC_NUMERIC_MAGIC_1 | 166 | #define _CATEGORY_MAGIC _CITRUS_LC_NUMERIC_MAGIC_1 | |
167 | 167 | |||
168 | #include "citrus_lc_template.h" | 168 | #include "citrus_lc_template.h" | |
169 | _LOCALE_CATEGORY_ENTRY(_citrus_LC_NUMERIC_); |
--- src/lib/libc/citrus/citrus_lc_time.c 2010/06/13 04:14:57 1.5
+++ src/lib/libc/citrus/citrus_lc_time.c 2012/03/04 21:14:55 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: citrus_lc_time.c,v 1.5 2010/06/13 04:14:57 tnozaki Exp $ */ | 1 | /* $NetBSD: citrus_lc_time.c,v 1.6 2012/03/04 21:14:55 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: citrus_lc_time.c,v 1.5 2010/06/13 04:14:57 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: citrus_lc_time.c,v 1.6 2012/03/04 21:14:55 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include "namespace.h" | 34 | #include "namespace.h" | |
35 | #include "reentrant.h" | 35 | #include "reentrant.h" | |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> | |
37 | #include <sys/localedef.h> | 37 | #include <sys/localedef.h> | |
38 | #include <sys/queue.h> | 38 | #include <sys/queue.h> | |
39 | #include <assert.h> | 39 | #include <assert.h> | |
40 | #include <errno.h> | 40 | #include <errno.h> | |
41 | #include <langinfo.h> | 41 | #include <langinfo.h> | |
42 | #include <limits.h> | 42 | #include <limits.h> | |
43 | #define __SETLOCALE_SOURCE__ | 43 | #define __SETLOCALE_SOURCE__ | |
44 | #include <locale.h> | 44 | #include <locale.h> | |
@@ -201,14 +201,13 @@ _citrus_LC_TIME_init_fallback(_TimeLocal | @@ -201,14 +201,13 @@ _citrus_LC_TIME_init_fallback(_TimeLocal | |||
201 | 201 | |||
202 | fatal: | 202 | fatal: | |
203 | _citrus_LC_TIME_uninit(data); | 203 | _citrus_LC_TIME_uninit(data); | |
204 | return EFTYPE; | 204 | return EFTYPE; | |
205 | } | 205 | } | |
206 | 206 | |||
207 | /* | 207 | /* | |
208 | * macro required by citrus_lc_template.h | 208 | * macro required by citrus_lc_template.h | |
209 | */ | 209 | */ | |
210 | #define _CATEGORY_DB "LC_TIME" | 210 | #define _CATEGORY_DB "LC_TIME" | |
211 | #define _CATEGORY_MAGIC _CITRUS_LC_TIME_MAGIC_1 | 211 | #define _CATEGORY_MAGIC _CITRUS_LC_TIME_MAGIC_1 | |
212 | 212 | |||
213 | #include "citrus_lc_template.h" | 213 | #include "citrus_lc_template.h" | |
214 | _LOCALE_CATEGORY_ENTRY(_citrus_LC_TIME_); |
--- src/lib/libc/locale/dummy_lc_collate.c 2009/01/11 02:46:28 1.2
+++ src/lib/libc/locale/dummy_lc_collate.c 2012/03/04 21:14:56 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */ | 1 | /* $NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,37 +18,36 @@ | @@ -18,37 +18,36 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $"); | 31 | __RCSID("$NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> | |
35 | #include <assert.h> | 35 | #include <assert.h> | |
36 | #include <langinfo.h> | 36 | #include <langinfo.h> | |
37 | #define __SETLOCALE_SOURCE__ | 37 | #define __SETLOCALE_SOURCE__ | |
38 | #include <locale.h> | 38 | #include <locale.h> | |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> | |
40 | #include <stdio.h> | 40 | #include <stdio.h> | |
41 | #include <string.h> | 41 | #include <string.h> | |
42 | 42 | |||
43 | #include "setlocale_local.h" | 43 | #include "setlocale_local.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | * macro required by dummy_lc_template.h | 46 | * macro required by dummy_lc_template.h | |
47 | */ | 47 | */ | |
48 | #define _PREFIX(name) __CONCAT(_dummy_LC_COLLATE_,name) | 48 | #define _PREFIX(name) __CONCAT(_dummy_LC_COLLATE_,name) | |
49 | 49 | |||
50 | #define _CATEGORY_ID LC_COLLATE | 50 | #define _CATEGORY_ID LC_COLLATE | |
51 | #define _CATEGORY_NAME "LC_COLLATE" | 51 | #define _CATEGORY_NAME "LC_COLLATE" | |
52 | 52 | |||
53 | #include "dummy_lc_template.h" | 53 | #include "dummy_lc_template.h" | |
54 | _LOCALE_CATEGORY_ENTRY(_dummy_LC_COLLATE_); |
--- src/lib/libc/locale/dummy_lc_template.h 2009/01/11 02:46:28 1.2
+++ src/lib/libc/locale/dummy_lc_template.h 2012/03/04 21:14:56 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dummy_lc_template.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */ | 1 | /* $NetBSD: dummy_lc_template.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,36 +21,34 @@ | @@ -21,36 +21,34 @@ | |||
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _DUMMY_LC_TEMPLATE_H_ | 29 | #ifndef _DUMMY_LC_TEMPLATE_H_ | |
30 | #define _DUMMY_LC_TEMPLATE_H_ | 30 | #define _DUMMY_LC_TEMPLATE_H_ | |
31 | 31 | |||
32 | #include "generic_lc_template_decl.h" | 32 | #include "generic_lc_template_decl.h" | |
33 | 33 | |||
34 | static const char * | 34 | const char * | |
35 | _PREFIX(setlocale)(const char * __restrict name, | 35 | _PREFIX(setlocale)(const char * __restrict name, | |
36 | struct _locale_impl_t * __restrict locale) | 36 | struct _locale_impl_t * __restrict locale) | |
37 | { | 37 | { | |
38 | if (name != NULL) { | 38 | if (name != NULL) { | |
39 | if (*name == '\0') | 39 | if (*name == '\0') | |
40 | name = _get_locale_env(_CATEGORY_NAME); | 40 | name = _get_locale_env(_CATEGORY_NAME); | |
41 | if (strcmp(name, locale->part_name[(size_t)_CATEGORY_ID])) { | 41 | if (strcmp(name, locale->part_name[(size_t)_CATEGORY_ID])) { | |
42 | if (!strcmp(_C_LOCALE, name)) | 42 | if (!strcmp(_C_LOCALE, name)) | |
43 | name = _C_LOCALE; | 43 | name = _C_LOCALE; | |
44 | else if (!strcmp(_POSIX_LOCALE, name)) | 44 | else if (!strcmp(_POSIX_LOCALE, name)) | |
45 | name = _POSIX_LOCALE; | 45 | name = _POSIX_LOCALE; | |
46 | else | 46 | else | |
47 | return NULL; | 47 | return NULL; | |
48 | locale->part_name[(size_t)_CATEGORY_ID] = name; | 48 | locale->part_name[(size_t)_CATEGORY_ID] = name; | |
49 | } | 49 | } | |
50 | } | 50 | } | |
51 | return locale->part_name[(size_t)_CATEGORY_ID]; | 51 | return locale->part_name[(size_t)_CATEGORY_ID]; | |
52 | } | 52 | } | |
53 | 53 | |||
54 | #include "generic_lc_template.h" | |||
55 | ||||
56 | #endif /*_DUMMY_LC_TEMPLATE_H_*/ | 54 | #endif /*_DUMMY_LC_TEMPLATE_H_*/ |
--- src/lib/libc/locale/generic_lc_template_decl.h 2009/01/11 02:46:28 1.2
+++ src/lib/libc/locale/generic_lc_template_decl.h 2012/03/04 21:14:56 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: generic_lc_template_decl.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */ | 1 | /* $NetBSD: generic_lc_template_decl.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -19,17 +19,17 @@ | @@ -19,17 +19,17 @@ | |||
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _GENERIC_LC_TEMPLATE_DECL_H_ | 29 | #ifndef _GENERIC_LC_TEMPLATE_DECL_H_ | |
30 | #define _GENERIC_LC_TEMPLATE_DECL_H_ | 30 | #define _GENERIC_LC_TEMPLATE_DECL_H_ | |
31 | 31 | |||
32 | static const char * _PREFIX(setlocale)(const char * __restrict, | 32 | const char * _PREFIX(setlocale)(const char * __restrict, | |
33 | struct _locale_impl_t * __restrict); | 33 | struct _locale_impl_t * __restrict); | |
34 | 34 | |||
35 | #endif /*_GENERIC_LC_TEMPLATE_DECL_H_*/ | 35 | #endif /*_GENERIC_LC_TEMPLATE_DECL_H_*/ |
--- src/lib/libc/locale/generic_lc_all.c 2009/10/04 21:05:18 1.3
+++ src/lib/libc/locale/generic_lc_all.c 2012/03/04 21:14:56 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $ */ | 1 | /* $NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,107 +18,100 @@ | @@ -18,107 +18,100 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $"); | 31 | __RCSID("$NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> | |
35 | #include <assert.h> | 35 | #include <assert.h> | |
36 | #include <langinfo.h> | 36 | #include <langinfo.h> | |
37 | #define __SETLOCALE_SOURCE__ | 37 | #define __SETLOCALE_SOURCE__ | |
38 | #include <locale.h> | 38 | #include <locale.h> | |
39 | #include <stdio.h> | 39 | #include <stdio.h> | |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> | |
41 | #include <string.h> | 41 | #include <string.h> | |
42 | 42 | |||
43 | #include "setlocale_local.h" | 43 | #include "setlocale_local.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | * macro required by all template headers | 46 | * macro required by all template headers | |
47 | */ | 47 | */ | |
48 | #define _PREFIX(name) __CONCAT(_generic_LC_ALL_, name) | 48 | #define _PREFIX(name) __CONCAT(_generic_LC_ALL_, name) | |
49 | 49 | |||
50 | #include "generic_lc_template_decl.h" | 50 | #include "generic_lc_template_decl.h" | |
51 | 51 | |||
52 | const char * | 52 | const char * | |
53 | _generic_LC_ALL_setlocale(const char * __restrict name, | 53 | _generic_LC_ALL_setlocale(const char * __restrict name, | |
54 | struct _locale_impl_t * __restrict locale) | 54 | struct _locale_impl_t * __restrict locale) | |
55 | { | 55 | { | |
56 | _locale_category_t *l; | 56 | _locale_set_t sl; | |
57 | char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail; | 57 | char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail; | |
58 | const char *tokens[_LC_LAST], *s, *t; | 58 | const char *tokens[_LC_LAST], *s, *t; | |
59 | int load_locale_success, i, j; | 59 | int load_locale_success, i, j; | |
60 | 60 | |||
61 | l = _find_category(1); | 61 | sl = _find_category(1); | |
62 | _DIAGASSERT(l != NULL); | 62 | _DIAGASSERT(sl != NULL); | |
63 | load_locale_success = 0; | 63 | load_locale_success = 0; | |
64 | if (name != NULL) { | 64 | if (name != NULL) { | |
65 | strlcpy(&head[0], name, sizeof(head)); | 65 | strlcpy(&head[0], name, sizeof(head)); | |
66 | tokens[1] = &head[0]; | 66 | tokens[1] = &head[0]; | |
67 | tail = strchr(tokens[1], '/'); | 67 | tail = strchr(tokens[1], '/'); | |
68 | if (tail == NULL) { | 68 | if (tail == NULL) { | |
69 | for (i = 2; i < _LC_LAST; ++i) | 69 | for (i = 2; i < _LC_LAST; ++i) | |
70 | tokens[i] = tokens[1]; | 70 | tokens[i] = tokens[1]; | |
71 | } else { | 71 | } else { | |
72 | *tail++ = '\0'; | 72 | *tail++ = '\0'; | |
73 | for (i = 2; i < _LC_LAST - 1; ++i) { | 73 | for (i = 2; i < _LC_LAST - 1; ++i) { | |
74 | tokens[i] = (const char *)tail; | 74 | tokens[i] = (const char *)tail; | |
75 | tail = strchr(tokens[i], '/'); | 75 | tail = strchr(tokens[i], '/'); | |
76 | if (tail == NULL) | 76 | if (tail == NULL) | |
77 | return NULL; | 77 | return NULL; | |
78 | *tail++ = '\0'; | 78 | *tail++ = '\0'; | |
79 | } | 79 | } | |
80 | tokens[_LC_LAST - 1] = (const char *)tail; | 80 | tokens[_LC_LAST - 1] = (const char *)tail; | |
81 | tail = strchr(tokens[i], '/'); | 81 | tail = strchr(tokens[i], '/'); | |
82 | if (tail != NULL) | 82 | if (tail != NULL) | |
83 | return NULL; | 83 | return NULL; | |
84 | } | 84 | } | |
85 | if ((*l->setlocale)(tokens[1], locale) != NULL) | 85 | if ((*sl)(tokens[1], locale) != NULL) | |
86 | load_locale_success = 1; | 86 | load_locale_success = 1; | |
87 | } | 87 | } | |
88 | s = (*l->setlocale)(NULL, locale); | 88 | s = (*sl)(NULL, locale); | |
89 | _DIAGASSERT(s != NULL); | 89 | _DIAGASSERT(s != NULL); | |
90 | strlcpy(&locale->query[0], s, sizeof(locale->query)); | 90 | strlcpy(&locale->query[0], s, sizeof(locale->query)); | |
91 | for (i = 2, j = 0; i < _LC_LAST; ++i) { | 91 | for (i = 2, j = 0; i < _LC_LAST; ++i) { | |
92 | l = _find_category(i); | 92 | sl = _find_category(i); | |
93 | _DIAGASSERT(l != NULL); | 93 | _DIAGASSERT(sl != NULL); | |
94 | if (name != NULL) { | 94 | if (name != NULL) { | |
95 | if ((*l->setlocale)(tokens[i], locale) != NULL) | 95 | if ((*sl)(tokens[i], locale) != NULL) | |
96 | load_locale_success = 1; | 96 | load_locale_success = 1; | |
97 | } | 97 | } | |
98 | t = (*l->setlocale)(NULL, locale); | 98 | t = (*sl)(NULL, locale); | |
99 | _DIAGASSERT(t != NULL); | 99 | _DIAGASSERT(t != NULL); | |
100 | if (j == 0) { | 100 | if (j == 0) { | |
101 | if (!strcmp(s, t)) | 101 | if (!strcmp(s, t)) | |
102 | continue; | 102 | continue; | |
103 | for (j = 2; j < i; ++j) { | 103 | for (j = 2; j < i; ++j) { | |
104 | strlcat(&locale->query[0], "/", | 104 | strlcat(&locale->query[0], "/", | |
105 | sizeof(locale->query)); | 105 | sizeof(locale->query)); | |
106 | strlcat(&locale->query[0], s, | 106 | strlcat(&locale->query[0], s, | |
107 | sizeof(locale->query)); | 107 | sizeof(locale->query)); | |
108 | } | 108 | } | |
109 | } | 109 | } | |
110 | strlcat(&locale->query[0], "/", sizeof(locale->query)); | 110 | strlcat(&locale->query[0], "/", sizeof(locale->query)); | |
111 | strlcat(&locale->query[0], t, sizeof(locale->query)); | 111 | strlcat(&locale->query[0], t, sizeof(locale->query)); | |
112 | } | 112 | } | |
113 | if (name != NULL && !load_locale_success) | 113 | if (name != NULL && !load_locale_success) | |
114 | return NULL; | 114 | return NULL; | |
115 | return (const char *)&locale->query[0]; | 115 | return (const char *)&locale->query[0]; | |
116 | } | 116 | } | |
117 | 117 | |||
118 | /* | |||
119 | * macro requrired by generic_lc_template.h | |||
120 | */ | |||
121 | #define _CATEGORY_ID LC_ALL | |||
122 | ||||
123 | #include "generic_lc_template.h" | |||
124 | _LOCALE_CATEGORY_ENTRY(_generic_LC_ALL_); |
--- src/lib/libc/locale/nb_lc_template.h 2010/05/22 13:15:59 1.3
+++ src/lib/libc/locale/nb_lc_template.h 2012/03/04 21:14:56 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nb_lc_template.h,v 1.3 2010/05/22 13:15:59 tnozaki Exp $ */ | 1 | /* $NetBSD: nb_lc_template.h,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)1999, 2008 Citrus Project, | 4 | * Copyright (c)1999, 2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -204,27 +204,27 @@ do { \ | @@ -204,27 +204,27 @@ do { \ | |||
204 | aliaspath = (const char *)&path[0]; | 204 | aliaspath = (const char *)&path[0]; | |
205 | snprintf(&loccat[0], sizeof(loccat), | 205 | snprintf(&loccat[0], sizeof(loccat), | |
206 | "%s/" _CATEGORY_NAME, name); | 206 | "%s/" _CATEGORY_NAME, name); | |
207 | _LOAD_SUB_ALIAS((const char *)&loccat[0]); | 207 | _LOAD_SUB_ALIAS((const char *)&loccat[0]); | |
208 | 208 | |||
209 | /* (3) lookup locname type alias */ | 209 | /* (3) lookup locname type alias */ | |
210 | _LOAD_SUB_ALIAS(name); | 210 | _LOAD_SUB_ALIAS(name); | |
211 | 211 | |||
212 | done: | 212 | done: | |
213 | mutex_unlock(&_nb_mutex); | 213 | mutex_unlock(&_nb_mutex); | |
214 | return ret; | 214 | return ret; | |
215 | } | 215 | } | |
216 | 216 | |||
217 | static const char * | 217 | const char * | |
218 | _PREFIX(setlocale)(const char * __restrict name, | 218 | _PREFIX(setlocale)(const char * __restrict name, | |
219 | struct _locale_impl_t * __restrict locale) | 219 | struct _locale_impl_t * __restrict locale) | |
220 | { | 220 | { | |
221 | _nb_part_t *part; | 221 | _nb_part_t *part; | |
222 | 222 | |||
223 | /* name may be NULL */ | 223 | /* name may be NULL */ | |
224 | _DIAGASSERT(locale != NULL); | 224 | _DIAGASSERT(locale != NULL); | |
225 | 225 | |||
226 | if (name != NULL) { | 226 | if (name != NULL) { | |
227 | if (*name == '\0') | 227 | if (*name == '\0') | |
228 | name = _get_locale_env(_CATEGORY_NAME); | 228 | name = _get_locale_env(_CATEGORY_NAME); | |
229 | _DIAGASSERT(name != NULL); | 229 | _DIAGASSERT(name != NULL); | |
230 | _DIAGASSERT(locale->part_name[(size_t)_CATEGORY_ID] != NULL); | 230 | _DIAGASSERT(locale->part_name[(size_t)_CATEGORY_ID] != NULL); | |
@@ -233,16 +233,14 @@ _PREFIX(setlocale)(const char * __restri | @@ -233,16 +233,14 @@ _PREFIX(setlocale)(const char * __restri | |||
233 | return NULL; | 233 | return NULL; | |
234 | locale->part_name[(size_t)_CATEGORY_ID] | 234 | locale->part_name[(size_t)_CATEGORY_ID] | |
235 | = &part->name[0]; | 235 | = &part->name[0]; | |
236 | locale->part_impl[(size_t)_CATEGORY_ID] | 236 | locale->part_impl[(size_t)_CATEGORY_ID] | |
237 | = part->impl; | 237 | = part->impl; | |
238 | _PREFIX(build_cache)(locale->cache, part->impl); | 238 | _PREFIX(build_cache)(locale->cache, part->impl); | |
239 | if (locale == &_global_locale) | 239 | if (locale == &_global_locale) | |
240 | _PREFIX(fixup)(part->impl); | 240 | _PREFIX(fixup)(part->impl); | |
241 | } | 241 | } | |
242 | } | 242 | } | |
243 | return locale->part_name[(size_t)_CATEGORY_ID]; | 243 | return locale->part_name[(size_t)_CATEGORY_ID]; | |
244 | } | 244 | } | |
245 | 245 | |||
246 | #include "generic_lc_template.h" | |||
247 | ||||
248 | #endif /*_NB_LC_TEMPLATE_H_*/ | 246 | #endif /*_NB_LC_TEMPLATE_H_*/ |
--- src/lib/libc/locale/setlocale.c 2012/01/20 16:31:30 1.59
+++ src/lib/libc/locale/setlocale.c 2012/03/04 21:14:56 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: setlocale.c,v 1.59 2012/01/20 16:31:30 joerg Exp $ */ | 1 | /* $NetBSD: setlocale.c,v 1.60 2012/03/04 21:14:56 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,68 +18,56 @@ | @@ -18,68 +18,56 @@ | |||
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) | |
31 | __RCSID("$NetBSD: setlocale.c,v 1.59 2012/01/20 16:31:30 joerg Exp $"); | 31 | __RCSID("$NetBSD: setlocale.c,v 1.60 2012/03/04 21:14:56 tnozaki Exp $"); | |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> | |
35 | #include <locale.h> | 35 | #include <locale.h> | |
36 | #include <limits.h> | 36 | #include <limits.h> | |
37 | #include <paths.h> | 37 | #include <paths.h> | |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> | |
39 | #include <string.h> | 39 | #include <string.h> | |
40 | #include <unistd.h> | 40 | #include <unistd.h> | |
41 | 41 | |||
42 | #include "setlocale_local.h" | 42 | #include "setlocale_local.h" | |
43 | 43 | |||
44 | const char *_PathLocale = NULL; | 44 | const char *_PathLocale = NULL; | |
45 | 45 | |||
46 | __link_set_decl(all_categories, _locale_category_t); | 46 | static _locale_set_t all_categories[_LC_LAST] = { | |
47 | [LC_ALL ] = &_generic_LC_ALL_setlocale, | |||
48 | [LC_COLLATE ] = &_dummy_LC_COLLATE_setlocale, | |||
49 | [LC_CTYPE ] = &_citrus_LC_CTYPE_setlocale, | |||
50 | [LC_MONETARY] = &_citrus_LC_MONETARY_setlocale, | |||
51 | [LC_NUMERIC ] = &_citrus_LC_NUMERIC_setlocale, | |||
52 | [LC_TIME ] = &_citrus_LC_TIME_setlocale, | |||
53 | [LC_MESSAGES] = &_citrus_LC_MESSAGES_setlocale, | |||
54 | }; | |||
47 | 55 | |||
48 | extern const _locale_category_t _generic_LC_ALL_desc; | 56 | _locale_set_t | |
49 | extern const _locale_category_t _dummy_LC_COLLATE_desc; | |||
50 | extern const _locale_category_t _citrus_LC_CTYPE_desc; | |||
51 | extern const _locale_category_t _citrus_LC_MONETARY_desc; | |||
52 | extern const _locale_category_t _citrus_LC_NUMERIC_desc; | |||
53 | extern const _locale_category_t _citrus_LC_TIME_desc; | |||
54 | extern const _locale_category_t _citrus_LC_MESSAGES_desc; | |||
55 | ||||
56 | __link_set_add_data(all_categories, _generic_LC_ALL_desc); | |||
57 | __link_set_add_data(all_categories, _dummy_LC_COLLATE_desc); | |||
58 | __link_set_add_data(all_categories, _citrus_LC_CTYPE_desc); | |||
59 | __link_set_add_data(all_categories, _citrus_LC_MONETARY_desc); | |||
60 | __link_set_add_data(all_categories, _citrus_LC_NUMERIC_desc); | |||
61 | __link_set_add_data(all_categories, _citrus_LC_TIME_desc); | |||
62 | __link_set_add_data(all_categories, _citrus_LC_MESSAGES_desc); | |||
63 | ||||
64 | _locale_category_t * | |||
65 | _find_category(int category) | 57 | _find_category(int category) | |
66 | { | 58 | { | |
67 | _locale_category_t * const *p; | 59 | if (category >= LC_ALL && category < _LC_LAST) | |
68 | 60 | return all_categories[category]; | ||
69 | __link_set_foreach(p, all_categories) { | |||
70 | if ((*p)->category == category) | |||
71 | return *p; | |||
72 | } | |||
73 | return NULL; | 61 | return NULL; | |
74 | } | 62 | } | |
75 | 63 | |||
76 | const char * | 64 | const char * | |
77 | _get_locale_env(const char *category) | 65 | _get_locale_env(const char *category) | |
78 | { | 66 | { | |
79 | const char *name; | 67 | const char *name; | |
80 | 68 | |||
81 | /* 1. check LC_ALL */ | 69 | /* 1. check LC_ALL */ | |
82 | name = (const char *)getenv("LC_ALL"); | 70 | name = (const char *)getenv("LC_ALL"); | |
83 | if (name == NULL || *name == '\0') { | 71 | if (name == NULL || *name == '\0') { | |
84 | /* 2. check LC_* */ | 72 | /* 2. check LC_* */ | |
85 | name = (const char *)getenv(category); | 73 | name = (const char *)getenv(category); | |
@@ -87,39 +75,36 @@ _get_locale_env(const char *category) | @@ -87,39 +75,36 @@ _get_locale_env(const char *category) | |||
87 | /* 3. check LANG */ | 75 | /* 3. check LANG */ | |
88 | name = getenv("LANG"); | 76 | name = getenv("LANG"); | |
89 | } | 77 | } | |
90 | } | 78 | } | |
91 | if (name == NULL || *name == '\0' || strchr(name, '/')) | 79 | if (name == NULL || *name == '\0' || strchr(name, '/')) | |
92 | /* 4. if none is set, fall to "C" */ | 80 | /* 4. if none is set, fall to "C" */ | |
93 | name = _C_LOCALE; | 81 | name = _C_LOCALE; | |
94 | return name; | 82 | return name; | |
95 | } | 83 | } | |
96 | 84 | |||
97 | char * | 85 | char * | |
98 | __setlocale(int category, const char *name) | 86 | __setlocale(int category, const char *name) | |
99 | { | 87 | { | |
100 | _locale_category_t *l; | 88 | _locale_set_t sl; | |
101 | struct _locale_impl_t *impl; | 89 | struct _locale_impl_t *impl; | |
102 | 90 | |||
103 | if (category >= LC_ALL && category < _LC_LAST) { | 91 | sl = _find_category(category); | |
104 | l = _find_category(category); | 92 | if (sl == NULL) | |
105 | if (l != NULL) { | 93 | return NULL; | |
106 | if (issetugid() || ((_PathLocale == NULL && | 94 | if (issetugid() || ((_PathLocale == NULL && | |
107 | (_PathLocale = getenv("PATH_LOCALE")) == NULL) || | 95 | (_PathLocale = getenv("PATH_LOCALE")) == NULL) || | |
108 | *_PathLocale == '\0')) | 96 | *_PathLocale == '\0')) | |
109 | _PathLocale = _PATH_LOCALE; | 97 | _PathLocale = _PATH_LOCALE; | |
110 | impl = *_current_locale(); | 98 | impl = *_current_locale(); | |
111 | return __UNCONST((*l->setlocale)(name, impl)); | 99 | return __UNCONST((*sl)(name, impl)); | |
112 | } | |||
113 | } | |||
114 | return NULL; | |||
115 | } | 100 | } | |
116 | 101 | |||
117 | char * | 102 | char * | |
118 | setlocale(int category, const char *locale) | 103 | setlocale(int category, const char *locale) | |
119 | { | 104 | { | |
120 | 105 | |||
121 | /* locale may be NULL */ | 106 | /* locale may be NULL */ | |
122 | 107 | |||
123 | __mb_len_max_runtime = MB_LEN_MAX; | 108 | __mb_len_max_runtime = MB_LEN_MAX; | |
124 | return __setlocale(category, locale); | 109 | return __setlocale(category, locale); | |
125 | } | 110 | } |
--- src/lib/libc/locale/setlocale_local.h 2010/06/07 13:52:30 1.7
+++ src/lib/libc/locale/setlocale_local.h 2012/03/04 21:14:57 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: setlocale_local.h,v 1.7 2010/06/07 13:52:30 tnozaki Exp $ */ | 1 | /* $NetBSD: setlocale_local.h,v 1.8 2012/03/04 21:14:57 tnozaki Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c)2008 Citrus Project, | 4 | * Copyright (c)2008 Citrus Project, | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -48,36 +48,45 @@ struct _locale_cache_t { | @@ -48,36 +48,45 @@ struct _locale_cache_t { | |||
48 | const char **items; | 48 | const char **items; | |
49 | }; | 49 | }; | |
50 | 50 | |||
51 | struct _locale_impl_t { | 51 | struct _locale_impl_t { | |
52 | struct _locale_cache_t *cache; | 52 | struct _locale_cache_t *cache; | |
53 | char query[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)]; | 53 | char query[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)]; | |
54 | const char *part_name[_LC_LAST]; | 54 | const char *part_name[_LC_LAST]; | |
55 | _locale_part_t part_impl[_LC_LAST]; | 55 | _locale_part_t part_impl[_LC_LAST]; | |
56 | }; | 56 | }; | |
57 | 57 | |||
58 | typedef const char *(*_locale_set_t)(const char * __restrict, | 58 | typedef const char *(*_locale_set_t)(const char * __restrict, | |
59 | struct _locale_impl_t * __restrict); | 59 | struct _locale_impl_t * __restrict); | |
60 | 60 | |||
61 | typedef struct { | |||
62 | const char* name; | |||
63 | int category; | |||
64 | _locale_set_t setlocale; | |||
65 | } _locale_category_t; | |||
66 | ||||
67 | __BEGIN_DECLS | 61 | __BEGIN_DECLS | |
68 | _locale_category_t *_find_category(int); | 62 | _locale_set_t _find_category(int); | |
69 | const char *_get_locale_env(const char *); | 63 | const char *_get_locale_env(const char *); | |
70 | struct _locale_impl_t **_current_locale(void); | 64 | struct _locale_impl_t **_current_locale(void); | |
71 | char *__setlocale(int, const char *); | 65 | char *__setlocale(int, const char *); | |
66 | ||||
67 | const char *_generic_LC_ALL_setlocale( | |||
68 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
69 | const char *_dummy_LC_COLLATE_setlocale( | |||
70 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
71 | const char *_citrus_LC_CTYPE_setlocale( | |||
72 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
73 | const char *_citrus_LC_MONETARY_setlocale( | |||
74 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
75 | const char *_citrus_LC_NUMERIC_setlocale( | |||
76 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
77 | const char *_citrus_LC_TIME_setlocale( | |||
78 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
79 | const char *_citrus_LC_MESSAGES_setlocale( | |||
80 | const char * __restrict, struct _locale_impl_t * __restrict); | |||
72 | __END_DECLS | 81 | __END_DECLS | |
73 | 82 | |||
74 | static __inline struct _locale_cache_t * | 83 | static __inline struct _locale_cache_t * | |
75 | _current_cache(void) | 84 | _current_cache(void) | |
76 | { | 85 | { | |
77 | return (*_current_locale())->cache; | 86 | return (*_current_locale())->cache; | |
78 | } | 87 | } | |
79 | 88 | |||
80 | extern struct _locale_impl_t _global_locale; | 89 | extern struct _locale_impl_t _global_locale; | |
81 | extern size_t __mb_len_max_runtime; | 90 | extern size_t __mb_len_max_runtime; | |
82 | 91 | |||
83 | #endif /*_SETLOCALE_LOCAL_H_*/ | 92 | #endif /*_SETLOCALE_LOCAL_H_*/ |