1560b10ffSOliver Tappe /*
2c894d186SOliver Tappe * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
3560b10ffSOliver Tappe * Distributed under the terms of the MIT License.
4560b10ffSOliver Tappe */
5560b10ffSOliver Tappe
6560b10ffSOliver Tappe
7560b10ffSOliver Tappe #include "ICUTimeData.h"
8560b10ffSOliver Tappe
9560b10ffSOliver Tappe #include <langinfo.h>
103aeed660SJérôme Duval #include <string.h>
11560b10ffSOliver Tappe #include <strings.h>
12560b10ffSOliver Tappe
13560b10ffSOliver Tappe #include <unicode/dtfmtsym.h>
14560b10ffSOliver Tappe #include <unicode/gregocal.h>
15560b10ffSOliver Tappe #include <unicode/smpdtfmt.h>
16560b10ffSOliver Tappe
17560b10ffSOliver Tappe #include <AutoDeleter.h>
18560b10ffSOliver Tappe
191e1278f4SOliver Tappe #include "ICUMessagesData.h"
20560b10ffSOliver Tappe
211bad1ff3SAdrien Destugues
221bad1ff3SAdrien Destugues U_NAMESPACE_USE
231bad1ff3SAdrien Destugues
241bad1ff3SAdrien Destugues
25560b10ffSOliver Tappe namespace BPrivate {
2625dc253dSIngo Weinhold namespace Libroot {
27560b10ffSOliver Tappe
28560b10ffSOliver Tappe
ICUTimeData(pthread_key_t tlsKey,struct lc_time_t & lcTimeInfo,const ICUMessagesData & messagesData)291e1278f4SOliver Tappe ICUTimeData::ICUTimeData(pthread_key_t tlsKey, struct lc_time_t& lcTimeInfo,
301e1278f4SOliver Tappe const ICUMessagesData& messagesData)
31560b10ffSOliver Tappe :
32bf5ff480SOliver Tappe inherited(tlsKey),
33560b10ffSOliver Tappe fLCTimeInfo(lcTimeInfo),
341e1278f4SOliver Tappe fDataBridge(NULL),
351e1278f4SOliver Tappe fMessagesData(messagesData)
36560b10ffSOliver Tappe {
37560b10ffSOliver Tappe for (int i = 0; i < 12; ++i) {
38560b10ffSOliver Tappe fLCTimeInfo.mon[i] = fMon[i];
39560b10ffSOliver Tappe fLCTimeInfo.month[i] = fMonth[i];
40560b10ffSOliver Tappe fLCTimeInfo.alt_month[i] = fAltMonth[i];
41560b10ffSOliver Tappe }
42560b10ffSOliver Tappe for (int i = 0; i < 7; ++i) {
43560b10ffSOliver Tappe fLCTimeInfo.wday[i] = fWday[i];
44560b10ffSOliver Tappe fLCTimeInfo.weekday[i] = fWeekday[i];
45560b10ffSOliver Tappe }
46560b10ffSOliver Tappe fLCTimeInfo.X_fmt = fTimeFormat;
47560b10ffSOliver Tappe fLCTimeInfo.x_fmt = fDateFormat;
48560b10ffSOliver Tappe fLCTimeInfo.c_fmt = fDateTimeFormat;
49560b10ffSOliver Tappe fLCTimeInfo.am = fAm;
50560b10ffSOliver Tappe fLCTimeInfo.pm = fPm;
51560b10ffSOliver Tappe fLCTimeInfo.date_fmt = fDateTimeZoneFormat;
52560b10ffSOliver Tappe fLCTimeInfo.md_order = fMonthDayOrder;
53560b10ffSOliver Tappe fLCTimeInfo.ampm_fmt = fAmPmFormat;
54560b10ffSOliver Tappe }
55560b10ffSOliver Tappe
56560b10ffSOliver Tappe
~ICUTimeData()57560b10ffSOliver Tappe ICUTimeData::~ICUTimeData()
58560b10ffSOliver Tappe {
59560b10ffSOliver Tappe }
60560b10ffSOliver Tappe
61560b10ffSOliver Tappe
62560b10ffSOliver Tappe void
Initialize(LocaleTimeDataBridge * dataBridge)63560b10ffSOliver Tappe ICUTimeData::Initialize(LocaleTimeDataBridge* dataBridge)
64560b10ffSOliver Tappe {
65560b10ffSOliver Tappe fDataBridge = dataBridge;
66560b10ffSOliver Tappe }
67560b10ffSOliver Tappe
68560b10ffSOliver Tappe
69560b10ffSOliver Tappe status_t
SetTo(const Locale & locale,const char * posixLocaleName)70560b10ffSOliver Tappe ICUTimeData::SetTo(const Locale& locale, const char* posixLocaleName)
71560b10ffSOliver Tappe {
72560b10ffSOliver Tappe status_t result = inherited::SetTo(locale, posixLocaleName);
73560b10ffSOliver Tappe if (result != B_OK)
74560b10ffSOliver Tappe return result;
75560b10ffSOliver Tappe
76560b10ffSOliver Tappe UErrorCode icuStatus = U_ZERO_ERROR;
77ec17468fSOliver Tappe DateFormatSymbols formatSymbols(ICULocaleForStrings(), icuStatus);
78560b10ffSOliver Tappe if (!U_SUCCESS(icuStatus))
79560b10ffSOliver Tappe return B_UNSUPPORTED;
80560b10ffSOliver Tappe
81560b10ffSOliver Tappe int count = 0;
82560b10ffSOliver Tappe const UnicodeString* strings = formatSymbols.getShortMonths(count);
83560b10ffSOliver Tappe result = _SetLCTimeEntries(strings, fMon[0], sizeof(fMon[0]), count, 12);
84560b10ffSOliver Tappe
85560b10ffSOliver Tappe if (result == B_OK) {
86560b10ffSOliver Tappe strings = formatSymbols.getMonths(count);
87560b10ffSOliver Tappe result = _SetLCTimeEntries(strings, fMonth[0], sizeof(fMonth[0]), count,
88560b10ffSOliver Tappe 12);
89560b10ffSOliver Tappe }
90560b10ffSOliver Tappe
91560b10ffSOliver Tappe if (result == B_OK) {
92560b10ffSOliver Tappe strings = formatSymbols.getShortWeekdays(count);
93560b10ffSOliver Tappe if (count == 8 && strings[0].length() == 0) {
94560b10ffSOliver Tappe // ICUs weekday arrays are 1-based
95560b10ffSOliver Tappe strings++;
96560b10ffSOliver Tappe count = 7;
97560b10ffSOliver Tappe }
98560b10ffSOliver Tappe result
99560b10ffSOliver Tappe = _SetLCTimeEntries(strings, fWday[0], sizeof(fWday[0]), count, 7);
100560b10ffSOliver Tappe }
101560b10ffSOliver Tappe
102560b10ffSOliver Tappe if (result == B_OK) {
103560b10ffSOliver Tappe strings = formatSymbols.getWeekdays(count);
104560b10ffSOliver Tappe if (count == 8 && strings[0].length() == 0) {
105560b10ffSOliver Tappe // ICUs weekday arrays are 1-based
106560b10ffSOliver Tappe strings++;
107560b10ffSOliver Tappe count = 7;
108560b10ffSOliver Tappe }
109560b10ffSOliver Tappe result = _SetLCTimeEntries(strings, fWeekday[0], sizeof(fWeekday[0]),
110560b10ffSOliver Tappe count, 7);
111560b10ffSOliver Tappe }
112560b10ffSOliver Tappe
113560b10ffSOliver Tappe if (result == B_OK) {
114560b10ffSOliver Tappe try {
115560b10ffSOliver Tappe DateFormat* format = DateFormat::createTimeInstance(
116560b10ffSOliver Tappe DateFormat::kDefault, fLocale);
117560b10ffSOliver Tappe result = _SetLCTimePattern(format, fTimeFormat, sizeof(fTimeFormat));
118560b10ffSOliver Tappe delete format;
119560b10ffSOliver Tappe } catch(...) {
120560b10ffSOliver Tappe result = B_NO_MEMORY;
121560b10ffSOliver Tappe }
122560b10ffSOliver Tappe }
123560b10ffSOliver Tappe
124560b10ffSOliver Tappe if (result == B_OK) {
125560b10ffSOliver Tappe try {
126560b10ffSOliver Tappe DateFormat* format = DateFormat::createDateInstance(
127560b10ffSOliver Tappe DateFormat::kDefault, fLocale);
128560b10ffSOliver Tappe result = _SetLCTimePattern(format, fDateFormat, sizeof(fDateFormat));
129560b10ffSOliver Tappe delete format;
130560b10ffSOliver Tappe } catch(...) {
131560b10ffSOliver Tappe result = B_NO_MEMORY;
132560b10ffSOliver Tappe }
133560b10ffSOliver Tappe }
134560b10ffSOliver Tappe
135560b10ffSOliver Tappe if (result == B_OK) {
136560b10ffSOliver Tappe try {
137560b10ffSOliver Tappe DateFormat* format = DateFormat::createDateTimeInstance(
138*4dcd6008SAugustin Cavalier DateFormat::kDefault, DateFormat::kDefault, fLocale);
139560b10ffSOliver Tappe result = _SetLCTimePattern(format, fDateTimeFormat,
140560b10ffSOliver Tappe sizeof(fDateTimeFormat));
141560b10ffSOliver Tappe delete format;
142560b10ffSOliver Tappe } catch(...) {
143560b10ffSOliver Tappe result = B_NO_MEMORY;
144560b10ffSOliver Tappe }
145560b10ffSOliver Tappe }
146560b10ffSOliver Tappe
147560b10ffSOliver Tappe if (result == B_OK) {
148560b10ffSOliver Tappe strings = formatSymbols.getAmPmStrings(count);
149560b10ffSOliver Tappe result = _SetLCTimeEntries(strings, fAm, sizeof(fAm), 1, 1);
150560b10ffSOliver Tappe if (result == B_OK)
151560b10ffSOliver Tappe result = _SetLCTimeEntries(&strings[1], fPm, sizeof(fPm), 1, 1);
152560b10ffSOliver Tappe }
153560b10ffSOliver Tappe
154560b10ffSOliver Tappe if (result == B_OK) {
155560b10ffSOliver Tappe strings = formatSymbols.getMonths(count, DateFormatSymbols::STANDALONE,
156560b10ffSOliver Tappe DateFormatSymbols::WIDE);
157560b10ffSOliver Tappe result = _SetLCTimeEntries(strings, fAltMonth[0], sizeof(fAltMonth[0]),
158560b10ffSOliver Tappe count, 12);
159560b10ffSOliver Tappe }
160560b10ffSOliver Tappe
161560b10ffSOliver Tappe strcpy(fAmPmFormat, fDataBridge->posixLCTimeInfo->ampm_fmt);
162560b10ffSOliver Tappe // ICU does not provide anything for this (and that makes sense, too)
163560b10ffSOliver Tappe
164560b10ffSOliver Tappe return result;
165560b10ffSOliver Tappe }
166560b10ffSOliver Tappe
167560b10ffSOliver Tappe
168560b10ffSOliver Tappe status_t
SetToPosix()169560b10ffSOliver Tappe ICUTimeData::SetToPosix()
170560b10ffSOliver Tappe {
171560b10ffSOliver Tappe status_t result = inherited::SetToPosix();
172560b10ffSOliver Tappe
173560b10ffSOliver Tappe if (result == B_OK) {
174560b10ffSOliver Tappe for (int i = 0; i < 12; ++i) {
175560b10ffSOliver Tappe strcpy(fMon[i], fDataBridge->posixLCTimeInfo->mon[i]);
176560b10ffSOliver Tappe strcpy(fMonth[i], fDataBridge->posixLCTimeInfo->month[i]);
177560b10ffSOliver Tappe strcpy(fAltMonth[i], fDataBridge->posixLCTimeInfo->alt_month[i]);
178560b10ffSOliver Tappe }
179560b10ffSOliver Tappe for (int i = 0; i < 7; ++i) {
180560b10ffSOliver Tappe strcpy(fWday[i], fDataBridge->posixLCTimeInfo->wday[i]);
181560b10ffSOliver Tappe strcpy(fWeekday[i], fDataBridge->posixLCTimeInfo->weekday[i]);
182560b10ffSOliver Tappe }
183560b10ffSOliver Tappe strcpy(fTimeFormat, fDataBridge->posixLCTimeInfo->X_fmt);
184560b10ffSOliver Tappe strcpy(fDateFormat, fDataBridge->posixLCTimeInfo->x_fmt);
185560b10ffSOliver Tappe strcpy(fDateTimeFormat, fDataBridge->posixLCTimeInfo->c_fmt);
186560b10ffSOliver Tappe strcpy(fAm, fDataBridge->posixLCTimeInfo->am);
187560b10ffSOliver Tappe strcpy(fPm, fDataBridge->posixLCTimeInfo->pm);
188560b10ffSOliver Tappe strcpy(fDateTimeZoneFormat, fDataBridge->posixLCTimeInfo->date_fmt);
189560b10ffSOliver Tappe strcpy(fMonthDayOrder, fDataBridge->posixLCTimeInfo->md_order);
190560b10ffSOliver Tappe strcpy(fAmPmFormat, fDataBridge->posixLCTimeInfo->ampm_fmt);
191560b10ffSOliver Tappe }
192560b10ffSOliver Tappe
193560b10ffSOliver Tappe return result;
194560b10ffSOliver Tappe }
195560b10ffSOliver Tappe
196560b10ffSOliver Tappe
197560b10ffSOliver Tappe const char*
GetLanginfo(int index)198560b10ffSOliver Tappe ICUTimeData::GetLanginfo(int index)
199560b10ffSOliver Tappe {
200560b10ffSOliver Tappe switch(index) {
201560b10ffSOliver Tappe case D_T_FMT:
202560b10ffSOliver Tappe return fDateTimeFormat;
203560b10ffSOliver Tappe case D_FMT:
204560b10ffSOliver Tappe return fDateFormat;
205560b10ffSOliver Tappe case T_FMT:
206560b10ffSOliver Tappe return fTimeFormat;
207560b10ffSOliver Tappe case T_FMT_AMPM:
208560b10ffSOliver Tappe return fAmPmFormat;
209560b10ffSOliver Tappe case AM_STR:
210560b10ffSOliver Tappe return fAm;
211560b10ffSOliver Tappe case PM_STR:
212560b10ffSOliver Tappe return fPm;
213560b10ffSOliver Tappe
214560b10ffSOliver Tappe case DAY_1:
215560b10ffSOliver Tappe case DAY_2:
216560b10ffSOliver Tappe case DAY_3:
217560b10ffSOliver Tappe case DAY_4:
218560b10ffSOliver Tappe case DAY_5:
219560b10ffSOliver Tappe case DAY_6:
220560b10ffSOliver Tappe case DAY_7:
221560b10ffSOliver Tappe return fWeekday[index - DAY_1];
222560b10ffSOliver Tappe
223560b10ffSOliver Tappe case ABDAY_1:
224560b10ffSOliver Tappe case ABDAY_2:
225560b10ffSOliver Tappe case ABDAY_3:
226560b10ffSOliver Tappe case ABDAY_4:
227560b10ffSOliver Tappe case ABDAY_5:
228560b10ffSOliver Tappe case ABDAY_6:
229560b10ffSOliver Tappe case ABDAY_7:
230560b10ffSOliver Tappe return fWday[index - ABDAY_1];
231560b10ffSOliver Tappe
232560b10ffSOliver Tappe case MON_1:
233560b10ffSOliver Tappe case MON_2:
234560b10ffSOliver Tappe case MON_3:
235560b10ffSOliver Tappe case MON_4:
236560b10ffSOliver Tappe case MON_5:
237560b10ffSOliver Tappe case MON_6:
238560b10ffSOliver Tappe case MON_7:
239560b10ffSOliver Tappe case MON_8:
240560b10ffSOliver Tappe case MON_9:
241560b10ffSOliver Tappe case MON_10:
242560b10ffSOliver Tappe case MON_11:
243560b10ffSOliver Tappe case MON_12:
244560b10ffSOliver Tappe return fMonth[index - MON_1];
245560b10ffSOliver Tappe
246560b10ffSOliver Tappe case ABMON_1:
247560b10ffSOliver Tappe case ABMON_2:
248560b10ffSOliver Tappe case ABMON_3:
249560b10ffSOliver Tappe case ABMON_4:
250560b10ffSOliver Tappe case ABMON_5:
251560b10ffSOliver Tappe case ABMON_6:
252560b10ffSOliver Tappe case ABMON_7:
253560b10ffSOliver Tappe case ABMON_8:
254560b10ffSOliver Tappe case ABMON_9:
255560b10ffSOliver Tappe case ABMON_10:
256560b10ffSOliver Tappe case ABMON_11:
257560b10ffSOliver Tappe case ABMON_12:
258560b10ffSOliver Tappe return fMon[index - ABMON_1];
259560b10ffSOliver Tappe
260560b10ffSOliver Tappe default:
261560b10ffSOliver Tappe return "";
262560b10ffSOliver Tappe }
263560b10ffSOliver Tappe }
264560b10ffSOliver Tappe
265560b10ffSOliver Tappe
266ec17468fSOliver Tappe const Locale&
ICULocaleForStrings() const267ec17468fSOliver Tappe ICUTimeData::ICULocaleForStrings() const
268ec17468fSOliver Tappe {
269ec17468fSOliver Tappe // check if the date strings should be taken from the messages-locale
270ec17468fSOliver Tappe // or from the time-locale (default)
271ec17468fSOliver Tappe UErrorCode icuStatus = U_ZERO_ERROR;
272ec17468fSOliver Tappe char stringsValue[16];
273ec17468fSOliver Tappe fLocale.getKeywordValue("strings", stringsValue, sizeof(stringsValue),
274ec17468fSOliver Tappe icuStatus);
275ec17468fSOliver Tappe if (U_SUCCESS(icuStatus) && strcasecmp(stringsValue, "messages") == 0)
276ec17468fSOliver Tappe return fMessagesData.ICULocale();
277ec17468fSOliver Tappe else
278ec17468fSOliver Tappe return fLocale;
279ec17468fSOliver Tappe }
280ec17468fSOliver Tappe
281ec17468fSOliver Tappe
282560b10ffSOliver Tappe status_t
_SetLCTimeEntries(const UnicodeString * strings,char * destination,int entrySize,int count,int maxCount)283560b10ffSOliver Tappe ICUTimeData::_SetLCTimeEntries(const UnicodeString* strings, char* destination,
284560b10ffSOliver Tappe int entrySize, int count, int maxCount)
285560b10ffSOliver Tappe {
286560b10ffSOliver Tappe if (strings == NULL)
287560b10ffSOliver Tappe return B_ERROR;
288560b10ffSOliver Tappe
289560b10ffSOliver Tappe status_t result = B_OK;
290560b10ffSOliver Tappe if (count > maxCount)
291560b10ffSOliver Tappe count = maxCount;
292560b10ffSOliver Tappe for (int32 i = 0; result == B_OK && i < count; ++i) {
293560b10ffSOliver Tappe result = _ConvertUnicodeStringToLocaleconvEntry(strings[i], destination,
294560b10ffSOliver Tappe entrySize);
295560b10ffSOliver Tappe destination += entrySize;
296560b10ffSOliver Tappe }
297560b10ffSOliver Tappe
298560b10ffSOliver Tappe return result;
299560b10ffSOliver Tappe }
300560b10ffSOliver Tappe
301560b10ffSOliver Tappe
302560b10ffSOliver Tappe status_t
_SetLCTimePattern(DateFormat * format,char * destination,int destinationSize)303560b10ffSOliver Tappe ICUTimeData::_SetLCTimePattern(DateFormat* format, char* destination,
304560b10ffSOliver Tappe int destinationSize)
305560b10ffSOliver Tappe {
306560b10ffSOliver Tappe SimpleDateFormat* simpleFormat = dynamic_cast<SimpleDateFormat*>(format);
307560b10ffSOliver Tappe if (!simpleFormat)
308560b10ffSOliver Tappe return B_BAD_TYPE;
309560b10ffSOliver Tappe
310560b10ffSOliver Tappe // convert ICU-type pattern to posix (i.e. strftime()) format string
311560b10ffSOliver Tappe UnicodeString icuPattern;
312560b10ffSOliver Tappe simpleFormat->toPattern(icuPattern);
313560b10ffSOliver Tappe UnicodeString posixPattern;
314560b10ffSOliver Tappe if (icuPattern.length() > 0) {
315560b10ffSOliver Tappe UChar lastCharSeen = 0;
316560b10ffSOliver Tappe int lastCharCount = 1;
317560b10ffSOliver Tappe bool inSingleQuotes = false;
318560b10ffSOliver Tappe bool inDoubleQuotes = false;
319560b10ffSOliver Tappe // we loop one character past the end on purpose, which will result in a
320560b10ffSOliver Tappe // final -1 char to be processed, which in turn will let us handle the
321560b10ffSOliver Tappe // last character (via lastCharSeen)
322560b10ffSOliver Tappe for (int i = 0; i <= icuPattern.length(); ++i) {
323560b10ffSOliver Tappe UChar currChar = icuPattern.charAt(i);
324560b10ffSOliver Tappe if (lastCharSeen != 0 && currChar == lastCharSeen) {
325560b10ffSOliver Tappe lastCharCount++;
326560b10ffSOliver Tappe continue;
327560b10ffSOliver Tappe }
328560b10ffSOliver Tappe
329560b10ffSOliver Tappe if (!inSingleQuotes && !inDoubleQuotes) {
330560b10ffSOliver Tappe switch (lastCharSeen) {
331560b10ffSOliver Tappe case L'a':
332560b10ffSOliver Tappe posixPattern.append(UnicodeString("%p", ""));
333560b10ffSOliver Tappe break;
334560b10ffSOliver Tappe case L'd':
335560b10ffSOliver Tappe if (lastCharCount == 2)
336560b10ffSOliver Tappe posixPattern.append(UnicodeString("%d", ""));
337560b10ffSOliver Tappe else
338560b10ffSOliver Tappe posixPattern.append(UnicodeString("%e", ""));
339560b10ffSOliver Tappe break;
340560b10ffSOliver Tappe case L'D':
341560b10ffSOliver Tappe posixPattern.append(UnicodeString("%j", ""));
342560b10ffSOliver Tappe break;
343560b10ffSOliver Tappe case L'c':
344560b10ffSOliver Tappe // fall through, to handle 'c' the same as 'e'
345560b10ffSOliver Tappe case L'e':
346560b10ffSOliver Tappe if (lastCharCount == 4)
347560b10ffSOliver Tappe posixPattern.append(UnicodeString("%A", ""));
348560b10ffSOliver Tappe else if (lastCharCount <= 2)
349560b10ffSOliver Tappe posixPattern.append(UnicodeString("%u", ""));
350560b10ffSOliver Tappe else
351560b10ffSOliver Tappe posixPattern.append(UnicodeString("%a", ""));
352560b10ffSOliver Tappe break;
353560b10ffSOliver Tappe case L'E':
354560b10ffSOliver Tappe if (lastCharCount == 4)
355560b10ffSOliver Tappe posixPattern.append(UnicodeString("%A", ""));
356560b10ffSOliver Tappe else
357560b10ffSOliver Tappe posixPattern.append(UnicodeString("%a", ""));
358560b10ffSOliver Tappe break;
359560b10ffSOliver Tappe case L'k':
360560b10ffSOliver Tappe // fall through, to handle 'k' the same as 'h'
361560b10ffSOliver Tappe case L'h':
362560b10ffSOliver Tappe if (lastCharCount == 2)
363560b10ffSOliver Tappe posixPattern.append(UnicodeString("%I", ""));
364560b10ffSOliver Tappe else
365560b10ffSOliver Tappe posixPattern.append(UnicodeString("%l", ""));
366560b10ffSOliver Tappe break;
367560b10ffSOliver Tappe case L'H':
368560b10ffSOliver Tappe if (lastCharCount == 2)
369560b10ffSOliver Tappe posixPattern.append(UnicodeString("%H", ""));
370560b10ffSOliver Tappe else
371560b10ffSOliver Tappe posixPattern.append(UnicodeString("%k", ""));
372560b10ffSOliver Tappe break;
373560b10ffSOliver Tappe case L'm':
374560b10ffSOliver Tappe posixPattern.append(UnicodeString("%M", ""));
375560b10ffSOliver Tappe break;
376560b10ffSOliver Tappe case L'L':
377560b10ffSOliver Tappe // fall through, to handle 'L' the same as 'M'
378560b10ffSOliver Tappe case L'M':
379560b10ffSOliver Tappe if (lastCharCount == 4)
380560b10ffSOliver Tappe posixPattern.append(UnicodeString("%B", ""));
381560b10ffSOliver Tappe else if (lastCharCount == 3)
382560b10ffSOliver Tappe posixPattern.append(UnicodeString("%b", ""));
383560b10ffSOliver Tappe else
384560b10ffSOliver Tappe posixPattern.append(UnicodeString("%m", ""));
385560b10ffSOliver Tappe break;
386560b10ffSOliver Tappe case L's':
387560b10ffSOliver Tappe posixPattern.append(UnicodeString("%S", ""));
388560b10ffSOliver Tappe break;
389560b10ffSOliver Tappe case L'w':
390560b10ffSOliver Tappe posixPattern.append(UnicodeString("%V", ""));
391560b10ffSOliver Tappe break;
392560b10ffSOliver Tappe case L'y':
393560b10ffSOliver Tappe if (lastCharCount == 2)
394560b10ffSOliver Tappe posixPattern.append(UnicodeString("%y", ""));
395560b10ffSOliver Tappe else
396560b10ffSOliver Tappe posixPattern.append(UnicodeString("%Y", ""));
397560b10ffSOliver Tappe break;
398560b10ffSOliver Tappe case L'Y':
399560b10ffSOliver Tappe posixPattern.append(UnicodeString("%G", ""));
400560b10ffSOliver Tappe break;
401560b10ffSOliver Tappe case L'z':
402560b10ffSOliver Tappe posixPattern.append(UnicodeString("%Z", ""));
403560b10ffSOliver Tappe break;
404560b10ffSOliver Tappe case L'Z':
405560b10ffSOliver Tappe posixPattern.append(UnicodeString("%z", ""));
406560b10ffSOliver Tappe break;
407560b10ffSOliver Tappe default:
408560b10ffSOliver Tappe if (lastCharSeen != 0)
409560b10ffSOliver Tappe posixPattern.append(lastCharSeen);
410560b10ffSOliver Tappe }
411560b10ffSOliver Tappe } else {
412560b10ffSOliver Tappe if (lastCharSeen != 0)
413560b10ffSOliver Tappe posixPattern.append(lastCharSeen);
414560b10ffSOliver Tappe }
415560b10ffSOliver Tappe
416560b10ffSOliver Tappe if (currChar == L'"') {
417560b10ffSOliver Tappe inDoubleQuotes = !inDoubleQuotes;
418560b10ffSOliver Tappe lastCharSeen = 0;
419560b10ffSOliver Tappe } else if (currChar == L'\'') {
420560b10ffSOliver Tappe inSingleQuotes = !inSingleQuotes;
421560b10ffSOliver Tappe lastCharSeen = 0;
422560b10ffSOliver Tappe } else
423560b10ffSOliver Tappe lastCharSeen = currChar;
424560b10ffSOliver Tappe
425560b10ffSOliver Tappe lastCharCount = 1;
426560b10ffSOliver Tappe }
427560b10ffSOliver Tappe }
428560b10ffSOliver Tappe
429560b10ffSOliver Tappe return _ConvertUnicodeStringToLocaleconvEntry(posixPattern, destination,
430560b10ffSOliver Tappe destinationSize);
431560b10ffSOliver Tappe }
432560b10ffSOliver Tappe
433560b10ffSOliver Tappe
43425dc253dSIngo Weinhold } // namespace Libroot
435560b10ffSOliver Tappe } // namespace BPrivate
436