1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 
24 /*
25  * localeconv() intercept
26  */
27 
28 #include "lclib.h"
29 
30 #undef	localeconv
31 
32 static char	null[] = "";
33 
34 static struct lconv	debug_lconv =
35 {
36 	",",
37 	".",
38 	&null[0],
39 	&null[0],
40 	&null[0],
41 	&null[0],
42 	&null[0],
43 	&null[0],
44 	&null[0],
45 	&null[0],
46 	CHAR_MAX,
47 	CHAR_MAX,
48 	CHAR_MAX,
49 	CHAR_MAX,
50 	CHAR_MAX,
51 	CHAR_MAX,
52 	CHAR_MAX,
53 	CHAR_MAX,
54 };
55 
56 static struct lconv	default_lconv =
57 {
58 	".",
59 	&null[0],
60 	&null[0],
61 	&null[0],
62 	&null[0],
63 	&null[0],
64 	&null[0],
65 	&null[0],
66 	&null[0],
67 	&null[0],
68 	CHAR_MAX,
69 	CHAR_MAX,
70 	CHAR_MAX,
71 	CHAR_MAX,
72 	CHAR_MAX,
73 	CHAR_MAX,
74 	CHAR_MAX,
75 	CHAR_MAX,
76 };
77 
78 #if !_lib_localeconv
79 
80 struct lconv*
localeconv(void)81 localeconv(void)
82 {
83 	return &default_lconv;
84 }
85 
86 #endif
87 
88 /*
89  * localeconv() intercept
90  */
91 
92 struct lconv*
_ast_localeconv(void)93 _ast_localeconv(void)
94 {
95 	if ((locales[AST_LC_MONETARY]->flags | locales[AST_LC_NUMERIC]->flags) & LC_debug)
96 		return &debug_lconv;
97 	if ((locales[AST_LC_NUMERIC]->flags & (LC_default|LC_local)) == LC_local)
98 		return locales[AST_LC_NUMERIC]->territory == &lc_territories[0] ? &default_lconv : &debug_lconv;
99 	return localeconv();
100 }
101