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 <string.h> 12 #include <time.h> 13 14 #include <PosixCtype.h> 15 #include <PosixLanginfo.h> 16 #include <PosixLCTimeInfo.h> 17 #include <PosixLocaleConv.h> 18 19 20 extern locale_data* _nl_current_LC_NUMERIC; 21 22 23 namespace BPrivate { 24 namespace Libroot { 25 26 27 LocaleCtypeDataBridge::LocaleCtypeDataBridge() 28 : 29 addrOfClassInfoTable(&__ctype_b), 30 addrOfToLowerTable(&__ctype_tolower), 31 addrOfToUpperTable(&__ctype_toupper), 32 posixClassInfo(gPosixClassInfo), 33 posixToLowerMap(gPosixToLowerMap), 34 posixToUpperMap(gPosixToUpperMap) 35 { 36 } 37 38 39 void LocaleCtypeDataBridge::setMbCurMax(unsigned short mbCurMax) 40 { 41 __ctype_mb_cur_max = mbCurMax; 42 } 43 44 45 LocaleMessagesDataBridge::LocaleMessagesDataBridge() 46 : 47 posixLanginfo(gPosixLanginfo) 48 { 49 } 50 51 52 LocaleMonetaryDataBridge::LocaleMonetaryDataBridge() 53 : 54 posixLocaleConv(&gPosixLocaleConv) 55 { 56 } 57 58 59 LocaleNumericDataBridge::LocaleNumericDataBridge() 60 : 61 originalGlibcLocale(_nl_current_LC_NUMERIC), 62 posixLocaleConv(&gPosixLocaleConv) 63 { 64 memcpy(&glibcNumericLocale, _nl_current_LC_NUMERIC, 65 sizeof(glibcNumericLocale)); 66 _nl_current_LC_NUMERIC = (locale_data*)&glibcNumericLocale; 67 } 68 69 70 LocaleNumericDataBridge::~LocaleNumericDataBridge() 71 { 72 _nl_current_LC_NUMERIC = originalGlibcLocale; 73 } 74 75 76 LocaleTimeDataBridge::LocaleTimeDataBridge() 77 : 78 posixLCTimeInfo(&gPosixLCTimeInfo) 79 { 80 } 81 82 83 TimeConversionDataBridge::TimeConversionDataBridge() 84 : 85 addrOfDaylight(&daylight), 86 addrOfTimezone(&timezone), 87 addrOfTZName(tzname) 88 { 89 } 90 91 92 LocaleDataBridge::LocaleDataBridge() 93 : 94 posixLanginfo(gPosixLanginfo) 95 { 96 } 97 98 99 } // namespace Libroot 100 } // namespace BPrivate 101