1 /* 2 * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "LocaleBackend.h" 8 9 #include <ctype.h> 10 #include <langinfo.h> 11 #include <time.h> 12 13 #include <PosixCtype.h> 14 #include <PosixLanginfo.h> 15 #include <PosixLCTimeInfo.h> 16 #include <PosixLocaleConv.h> 17 18 19 // struct used by glibc to access locale info 20 struct locale_data 21 { 22 const char* name; 23 const char* filedata; 24 off_t filesize; 25 int mmaped; 26 unsigned int usage_count; 27 int use_translit; 28 const char *options; 29 unsigned int nstrings; 30 union locale_data_value 31 { 32 const uint32_t* wstr; 33 const char* string; 34 unsigned int word; 35 } 36 values[]; 37 }; 38 extern struct locale_data _nl_C_LC_NUMERIC; 39 40 41 namespace BPrivate { 42 43 44 LocaleCtypeDataBridge::LocaleCtypeDataBridge() 45 : 46 addrOfClassInfoTable(&__ctype_b), 47 addrOfToLowerTable(&__ctype_tolower), 48 addrOfToUpperTable(&__ctype_toupper), 49 posixClassInfo(gPosixClassInfo), 50 posixToLowerMap(gPosixToLowerMap), 51 posixToUpperMap(gPosixToUpperMap) 52 { 53 } 54 55 56 LocaleMessagesDataBridge::LocaleMessagesDataBridge() 57 : 58 posixLanginfo(gPosixLanginfo) 59 { 60 } 61 62 63 LocaleMonetaryDataBridge::LocaleMonetaryDataBridge() 64 : 65 posixLocaleConv(&gPosixLocaleConv) 66 { 67 } 68 69 70 LocaleNumericDataBridge::LocaleNumericDataBridge() 71 : 72 addrOfGlibcDecimalPoint(&_nl_C_LC_NUMERIC.values[0].string), 73 addrOfGlibcThousandsSep(&_nl_C_LC_NUMERIC.values[1].string), 74 addrOfGlibcGrouping(&_nl_C_LC_NUMERIC.values[2].string), 75 addrOfGlibcWCDecimalPoint(&_nl_C_LC_NUMERIC.values[3].word), 76 addrOfGlibcWCThousandsSep(&_nl_C_LC_NUMERIC.values[4].word), 77 posixLocaleConv(&gPosixLocaleConv) 78 { 79 } 80 81 82 LocaleTimeDataBridge::LocaleTimeDataBridge() 83 : 84 posixLCTimeInfo(&gPosixLCTimeInfo) 85 { 86 } 87 88 89 TimeConversionDataBridge::TimeConversionDataBridge() 90 : 91 addrOfDaylight(&daylight), 92 addrOfTimezone(&timezone), 93 addrOfTZName(tzname) 94 { 95 } 96 97 98 LocaleDataBridge::LocaleDataBridge() 99 : 100 posixLanginfo(gPosixLanginfo) 101 { 102 } 103 104 105 } // namespace BPrivate 106