Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: sky/engine/wtf/unicode/icu/CollatorICU.cpp

Issue 709603006: Remove a bunch of OS(MACOSX) code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Even more Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 19 matching lines...) Expand all
30 #include "wtf/unicode/Collator.h" 30 #include "wtf/unicode/Collator.h"
31 31
32 #include "wtf/Assertions.h" 32 #include "wtf/Assertions.h"
33 #include "wtf/StringExtras.h" 33 #include "wtf/StringExtras.h"
34 #include "wtf/Threading.h" 34 #include "wtf/Threading.h"
35 #include "wtf/ThreadingPrimitives.h" 35 #include "wtf/ThreadingPrimitives.h"
36 #include <stdlib.h> 36 #include <stdlib.h>
37 #include <string.h> 37 #include <string.h>
38 #include <unicode/ucol.h> 38 #include <unicode/ucol.h>
39 39
40 #if OS(MACOSX)
41 #include "wtf/RetainPtr.h"
42 #include <CoreFoundation/CoreFoundation.h>
43 #endif
44
45 namespace WTF { 40 namespace WTF {
46 41
47 static UCollator* cachedCollator; 42 static UCollator* cachedCollator;
48 static Mutex& cachedCollatorMutex() 43 static Mutex& cachedCollatorMutex()
49 { 44 {
50 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 45 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
51 return mutex; 46 return mutex;
52 } 47 }
53 48
54 Collator::Collator(const char* locale) 49 Collator::Collator(const char* locale)
55 : m_collator(0) 50 : m_collator(0)
56 , m_locale(locale ? strdup(locale) : 0) 51 , m_locale(locale ? strdup(locale) : 0)
57 , m_lowerFirst(false) 52 , m_lowerFirst(false)
58 { 53 {
59 } 54 }
60 55
61 PassOwnPtr<Collator> Collator::userDefault() 56 PassOwnPtr<Collator> Collator::userDefault()
62 { 57 {
63 #if OS(MACOSX) && USE(CF)
64 // Mac OS X doesn't set UNIX locale to match user-selected one, so ICU defau lt doesn't work.
65 RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent());
66 CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get (), kCFLocaleCollatorIdentifier);
67 char buf[256];
68 if (!collationOrder)
69 return adoptPtr(new Collator(""));
70 CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII) ;
71 return adoptPtr(new Collator(buf));
72 #else
73 return adoptPtr(new Collator(0)); 58 return adoptPtr(new Collator(0));
74 #endif
75 } 59 }
76 60
77 Collator::~Collator() 61 Collator::~Collator()
78 { 62 {
79 releaseCollator(); 63 releaseCollator();
80 free(m_locale); 64 free(m_locale);
81 } 65 }
82 66
83 void Collator::setOrderLowerFirst(bool lowerFirst) 67 void Collator::setOrderLowerFirst(bool lowerFirst)
84 { 68 {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 { 121 {
138 Locker<Mutex> lock(cachedCollatorMutex()); 122 Locker<Mutex> lock(cachedCollatorMutex());
139 if (cachedCollator) 123 if (cachedCollator)
140 ucol_close(cachedCollator); 124 ucol_close(cachedCollator);
141 cachedCollator = m_collator; 125 cachedCollator = m_collator;
142 m_collator = 0; 126 m_collator = 0;
143 } 127 }
144 } 128 }
145 129
146 } // namespace WTF 130 } // namespace WTF
OLDNEW
« sky/engine/wtf/StringExtras.h ('K') | « sky/engine/wtf/text/ASCIIFastPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698