1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/libc/src/lnumeric.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,121 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Name : lnumeric.CPP
1.18 +// Part of : LIBC
1.19 +// Contains the source for LC_NUMERIC category
1.20 +// Version :
1.21 +// This material, including documentation and any related
1.22 +// computer programs, is protected by copyright controlled by
1.23 +// Nokia Corporation. All rights are reserved. Copying,
1.24 +// including reproducing, storing, adapting or translating, any
1.25 +// or all of this material requires the prior written consent of
1.26 +// Nokia Corporation. This material also contains confidential
1.27 +// information which may not be disclosed to others without the
1.28 +// prior written consent of Nokia Corporation.
1.29 +//
1.30 +
1.31 +#include <limits.h>
1.32 +#include <sys/cdefs.h>
1.33 +#include "localeinfo.h"
1.34 +#include "lnumeric.h"
1.35 +
1.36 +#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
1.37 +#include "libc_wsd_defs.h"
1.38 +#endif
1.39 +__BEGIN_DECLS
1.40 +extern int __nlocale_changed;
1.41 +#ifdef EMULATOR
1.42 +int *GET_WSD_VAR_NAME(__nlocale_changed, g)();
1.43 +#define __nlocale_changed (*GET_WSD_VAR_NAME(__nlocale_changed, g)())
1.44 +#endif //EMULATOR
1.45 +__END_DECLS
1.46 +
1.47 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.48 +extern unsigned char __clocale_set;
1.49 +#ifdef EMULATOR
1.50 +unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)();
1.51 +#define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)())
1.52 +#endif //EMULATOR
1.53 +#endif
1.54 +#ifndef EMULATOR
1.55 +int _numeric_using_locale;
1.56 +#else //EMULATOR
1.57 +
1.58 +GET_GLOBAL_VAR_FROM_TLS(_numeric_using_locale, int)
1.59 +#define _numeric_using_locale (*GET_WSD_VAR_NAME(_numeric_using_locale, g)())
1.60 +#endif //EMULATOR
1.61 +
1.62 +#ifndef EMULATOR
1.63 +static char numempty[] = { CHAR_MAX, '\0' };
1.64 +#else //EMULATOR
1.65 +static const char numempty[] = { CHAR_MAX, '\0'};
1.66 +#endif //EMULATOR
1.67 +
1.68 +
1.69 +static const struct lc_numeric_T _C_numeric_locale = {
1.70 + ".", /* decimal_point */
1.71 + "", /* thousands_sep */
1.72 + numempty /* grouping */
1.73 +};
1.74 +
1.75 +
1.76 +int __numeric_load_locale(const char* localeName)
1.77 +{
1.78 + //Get an instance of locale object
1.79 + CLocale* locale = CLocale::GetInstance();
1.80 + //Load numeric(LC_NUMERIC category) information
1.81 + if (locale->NumericLoadLocale(localeName) == -1)
1.82 + {
1.83 + return -1;
1.84 + }
1.85 + __nlocale_changed = 1;
1.86 + _numeric_using_locale = 1;
1.87 +
1.88 + return 0;
1.89 +}
1.90 +
1.91 +struct lc_numeric_T* __get_current_numeric_locale(void)
1.92 +{
1.93 + //Retrieve numeric(LC_NUMERIC category) information
1.94 + if(_numeric_using_locale)
1.95 + {
1.96 + return (CLocale::GetCurrentNumericLocale());
1.97 + }
1.98 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.99 + else if(__clocale_set)
1.100 +#endif
1.101 + //retrieve POSIX locale numeric(LC_NUMERIC category) information
1.102 + return ((struct lc_numeric_T *)&_C_numeric_locale);
1.103 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
1.104 + else
1.105 + {
1.106 + CLocale *l=CLocale::GetInstance();
1.107 + l->NumericLoadLocale(NULL);
1.108 + return (CLocale::GetCurrentNumericLocale());
1.109 + }
1.110 +#endif
1.111 +}
1.112 +
1.113 +#ifdef LOCALE_DEBUG
1.114 +void
1.115 +numericdebug(void) {
1.116 +printf( "decimal_point = %s\n"
1.117 + "thousands_sep = %s\n"
1.118 + "grouping = %s\n",
1.119 + _numeric_locale.decimal_point,
1.120 + _numeric_locale.thousands_sep,
1.121 + _numeric_locale.grouping
1.122 +);
1.123 +}
1.124 +#endif /* LOCALE_DEBUG */