sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Name : lnumeric.CPP
|
sl@0
|
15 |
// Part of : LIBC
|
sl@0
|
16 |
// Contains the source for LC_NUMERIC category
|
sl@0
|
17 |
// Version :
|
sl@0
|
18 |
// This material, including documentation and any related
|
sl@0
|
19 |
// computer programs, is protected by copyright controlled by
|
sl@0
|
20 |
// Nokia Corporation. All rights are reserved. Copying,
|
sl@0
|
21 |
// including reproducing, storing, adapting or translating, any
|
sl@0
|
22 |
// or all of this material requires the prior written consent of
|
sl@0
|
23 |
// Nokia Corporation. This material also contains confidential
|
sl@0
|
24 |
// information which may not be disclosed to others without the
|
sl@0
|
25 |
// prior written consent of Nokia Corporation.
|
sl@0
|
26 |
//
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <limits.h>
|
sl@0
|
29 |
#include <sys/cdefs.h>
|
sl@0
|
30 |
#include "localeinfo.h"
|
sl@0
|
31 |
#include "lnumeric.h"
|
sl@0
|
32 |
|
sl@0
|
33 |
#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
|
sl@0
|
34 |
#include "libc_wsd_defs.h"
|
sl@0
|
35 |
#endif
|
sl@0
|
36 |
__BEGIN_DECLS
|
sl@0
|
37 |
extern int __nlocale_changed;
|
sl@0
|
38 |
#ifdef EMULATOR
|
sl@0
|
39 |
int *GET_WSD_VAR_NAME(__nlocale_changed, g)();
|
sl@0
|
40 |
#define __nlocale_changed (*GET_WSD_VAR_NAME(__nlocale_changed, g)())
|
sl@0
|
41 |
#endif //EMULATOR
|
sl@0
|
42 |
__END_DECLS
|
sl@0
|
43 |
|
sl@0
|
44 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
45 |
extern unsigned char __clocale_set;
|
sl@0
|
46 |
#ifdef EMULATOR
|
sl@0
|
47 |
unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)();
|
sl@0
|
48 |
#define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)())
|
sl@0
|
49 |
#endif //EMULATOR
|
sl@0
|
50 |
#endif
|
sl@0
|
51 |
#ifndef EMULATOR
|
sl@0
|
52 |
int _numeric_using_locale;
|
sl@0
|
53 |
#else //EMULATOR
|
sl@0
|
54 |
|
sl@0
|
55 |
GET_GLOBAL_VAR_FROM_TLS(_numeric_using_locale, int)
|
sl@0
|
56 |
#define _numeric_using_locale (*GET_WSD_VAR_NAME(_numeric_using_locale, g)())
|
sl@0
|
57 |
#endif //EMULATOR
|
sl@0
|
58 |
|
sl@0
|
59 |
#ifndef EMULATOR
|
sl@0
|
60 |
static char numempty[] = { CHAR_MAX, '\0' };
|
sl@0
|
61 |
#else //EMULATOR
|
sl@0
|
62 |
static const char numempty[] = { CHAR_MAX, '\0'};
|
sl@0
|
63 |
#endif //EMULATOR
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
static const struct lc_numeric_T _C_numeric_locale = {
|
sl@0
|
67 |
".", /* decimal_point */
|
sl@0
|
68 |
"", /* thousands_sep */
|
sl@0
|
69 |
numempty /* grouping */
|
sl@0
|
70 |
};
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
int __numeric_load_locale(const char* localeName)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
//Get an instance of locale object
|
sl@0
|
76 |
CLocale* locale = CLocale::GetInstance();
|
sl@0
|
77 |
//Load numeric(LC_NUMERIC category) information
|
sl@0
|
78 |
if (locale->NumericLoadLocale(localeName) == -1)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
return -1;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
__nlocale_changed = 1;
|
sl@0
|
83 |
_numeric_using_locale = 1;
|
sl@0
|
84 |
|
sl@0
|
85 |
return 0;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
struct lc_numeric_T* __get_current_numeric_locale(void)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
//Retrieve numeric(LC_NUMERIC category) information
|
sl@0
|
91 |
if(_numeric_using_locale)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
return (CLocale::GetCurrentNumericLocale());
|
sl@0
|
94 |
}
|
sl@0
|
95 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
96 |
else if(__clocale_set)
|
sl@0
|
97 |
#endif
|
sl@0
|
98 |
//retrieve POSIX locale numeric(LC_NUMERIC category) information
|
sl@0
|
99 |
return ((struct lc_numeric_T *)&_C_numeric_locale);
|
sl@0
|
100 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
101 |
else
|
sl@0
|
102 |
{
|
sl@0
|
103 |
CLocale *l=CLocale::GetInstance();
|
sl@0
|
104 |
l->NumericLoadLocale(NULL);
|
sl@0
|
105 |
return (CLocale::GetCurrentNumericLocale());
|
sl@0
|
106 |
}
|
sl@0
|
107 |
#endif
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
#ifdef LOCALE_DEBUG
|
sl@0
|
111 |
void
|
sl@0
|
112 |
numericdebug(void) {
|
sl@0
|
113 |
printf( "decimal_point = %s\n"
|
sl@0
|
114 |
"thousands_sep = %s\n"
|
sl@0
|
115 |
"grouping = %s\n",
|
sl@0
|
116 |
_numeric_locale.decimal_point,
|
sl@0
|
117 |
_numeric_locale.thousands_sep,
|
sl@0
|
118 |
_numeric_locale.grouping
|
sl@0
|
119 |
);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
#endif /* LOCALE_DEBUG */
|