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

Side by Side Diff: Source/wtf/unicode/icu/CollatorICU.cpp

Issue 14107015: Rename OS(DARWIN) to OS(MACOSX). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 3 months 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(DARWIN) 40 #if OS(MACOSX)
41 #include "wtf/RetainPtr.h" 41 #include "wtf/RetainPtr.h"
42 #include <CoreFoundation/CoreFoundation.h> 42 #include <CoreFoundation/CoreFoundation.h>
43 #endif 43 #endif
44 44
45 namespace WTF { 45 namespace WTF {
46 46
47 static UCollator* cachedCollator; 47 static UCollator* cachedCollator;
48 static Mutex& cachedCollatorMutex() 48 static Mutex& cachedCollatorMutex()
49 { 49 {
50 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 50 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
51 return mutex; 51 return mutex;
52 } 52 }
53 53
54 Collator::Collator(const char* locale) 54 Collator::Collator(const char* locale)
55 : m_collator(0) 55 : m_collator(0)
56 , m_locale(locale ? strdup(locale) : 0) 56 , m_locale(locale ? strdup(locale) : 0)
57 , m_lowerFirst(false) 57 , m_lowerFirst(false)
58 { 58 {
59 } 59 }
60 60
61 PassOwnPtr<Collator> Collator::userDefault() 61 PassOwnPtr<Collator> Collator::userDefault()
62 { 62 {
63 #if OS(DARWIN) && USE(CF) 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. 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()); 65 RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent());
66 CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get (), kCFLocaleCollatorIdentifier); 66 CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get (), kCFLocaleCollatorIdentifier);
67 char buf[256]; 67 char buf[256];
68 if (!collationOrder) 68 if (!collationOrder)
69 return adoptPtr(new Collator("")); 69 return adoptPtr(new Collator(""));
70 CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII) ; 70 CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII) ;
71 return adoptPtr(new Collator(buf)); 71 return adoptPtr(new Collator(buf));
72 #else 72 #else
73 return adoptPtr(new Collator(0)); 73 return adoptPtr(new Collator(0));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 { 137 {
138 Locker<Mutex> lock(cachedCollatorMutex()); 138 Locker<Mutex> lock(cachedCollatorMutex());
139 if (cachedCollator) 139 if (cachedCollator)
140 ucol_close(cachedCollator); 140 ucol_close(cachedCollator);
141 cachedCollator = m_collator; 141 cachedCollator = m_collator;
142 m_collator = 0; 142 m_collator = 0;
143 } 143 }
144 } 144 }
145 145
146 } // namespace WTF 146 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698