From 6df7babc289f9de3597247cd053f3addf0c2f8fb Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 23 Aug 2013 15:51:30 -0400 Subject: [PATCH] Bug 784739 - Switch from NULL to nullptr in intl/. r=ehsan --- intl/locale/src/mac/nsCollationMacUC.cpp | 8 ++++---- intl/locale/src/mac/nsDateTimeFormatMac.cpp | 16 ++++++++++------ intl/locale/src/nsLocaleService.cpp | 2 +- intl/locale/src/os2/nsCollationOS2.cpp | 9 ++++++--- intl/locale/src/os2/nsDateTimeFormatOS2.cpp | 2 +- intl/locale/src/os2/nsOS2Locale.cpp | 2 +- intl/locale/src/windows/nsCollationWin.cpp | 2 +- intl/locale/src/windows/nsDateTimeFormatWin.cpp | 8 ++++---- intl/lwbrk/src/nsCarbonBreaker.cpp | 5 ++++- intl/lwbrk/src/nsUniscribeBreaker.cpp | 3 ++- 10 files changed, 34 insertions(+), 23 deletions(-) diff --git a/intl/locale/src/mac/nsCollationMacUC.cpp b/intl/locale/src/mac/nsCollationMacUC.cpp index 97c353fc1ba5..46c1a1d98b29 100644 --- a/intl/locale/src/mac/nsCollationMacUC.cpp +++ b/intl/locale/src/mac/nsCollationMacUC.cpp @@ -13,9 +13,9 @@ NS_IMPL_ISUPPORTS1(nsCollationMacUC, nsICollation) nsCollationMacUC::nsCollationMacUC() : mInit(false) , mHasCollator(false) - , mLocale(NULL) + , mLocale(nullptr) , mLastStrength(-1) - , mCollator(NULL) + , mCollator(nullptr) , mBuffer(nullptr) , mBufferLen(1) { @@ -174,7 +174,7 @@ NS_IMETHODIMP nsCollationMacUC::CompareString(int32_t strength, const nsAString& err = ::UCCompareText(mCollator, (const UniChar *) PromiseFlatString(string1).get(), (UniCharCount) string1.Length(), (const UniChar *) PromiseFlatString(string2).get(), (UniCharCount) string2.Length(), - NULL, (SInt32*) result); + nullptr, (SInt32*) result); NS_ENSURE_TRUE((err == noErr), NS_ERROR_FAILURE); return NS_OK; @@ -193,7 +193,7 @@ NS_IMETHODIMP nsCollationMacUC::CompareRawSortKey(const uint8_t* key1, uint32_t OSStatus err; err = ::UCCompareCollationKeys((const UCCollationValue*) key1, (ItemCount) len1, (const UCCollationValue*) key2, (ItemCount) len2, - NULL, (SInt32*) result); + nullptr, (SInt32*) result); NS_ENSURE_TRUE((err == noErr), NS_ERROR_FAILURE); diff --git a/intl/locale/src/mac/nsDateTimeFormatMac.cpp b/intl/locale/src/mac/nsDateTimeFormatMac.cpp index dc4b526cc096..585cc937c037 100644 --- a/intl/locale/src/mac/nsDateTimeFormatMac.cpp +++ b/intl/locale/src/mac/nsDateTimeFormatMac.cpp @@ -113,8 +113,10 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, if (!locale) { formatterLocale = CFLocaleCopyCurrent(); } else { - CFStringRef localeStr = CFStringCreateWithCharacters(NULL, mLocale.get(), mLocale.Length()); - formatterLocale = CFLocaleCreate(NULL, localeStr); + CFStringRef localeStr = CFStringCreateWithCharacters(nullptr, + mLocale.get(), + mLocale.Length()); + formatterLocale = CFLocaleCreate(nullptr, localeStr); CFRelease(localeStr); } @@ -162,7 +164,7 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, // Create the formatter and fix up its formatting as necessary: CFDateFormatterRef formatter = - CFDateFormatterCreate(NULL, formatterLocale, dateStyle, timeStyle); + CFDateFormatterCreate(nullptr, formatterLocale, dateStyle, timeStyle); CFRelease(formatterLocale); @@ -172,7 +174,7 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, dateFormatSelector == kDateFormatYearMonth ? CFSTR("yyyy/MM ") : CFSTR("EEE "); CFStringRef oldFormat = CFDateFormatterGetFormat(formatter); - CFMutableStringRef newFormat = CFStringCreateMutableCopy(NULL, 0, oldFormat); + CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat); CFStringInsert(newFormat, 0, dateFormat); CFDateFormatterSetFormat(formatter, newFormat); CFRelease(newFormat); // note we don't own oldFormat @@ -182,7 +184,7 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, timeFormatSelector == kTimeFormatNoSecondsForce24Hour) { // Replace "h" with "H", and remove "a": CFStringRef oldFormat = CFDateFormatterGetFormat(formatter); - CFMutableStringRef newFormat = CFStringCreateMutableCopy(NULL, 0, oldFormat); + CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat); CFIndex replaceCount = CFStringFindAndReplace(newFormat, CFSTR("h"), CFSTR("H"), CFRangeMake(0, CFStringGetLength(newFormat)), @@ -210,7 +212,9 @@ nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, CFAbsoluteTime absTime = CFGregorianDateGetAbsoluteTime(date, timeZone); CFRelease(timeZone); - CFStringRef formattedDate = CFDateFormatterCreateStringWithAbsoluteTime(NULL, formatter, absTime); + CFStringRef formattedDate = CFDateFormatterCreateStringWithAbsoluteTime(nullptr, + formatter, + absTime); CFIndex stringLen = CFStringGetLength(formattedDate); diff --git a/intl/locale/src/nsLocaleService.cpp b/intl/locale/src/nsLocaleService.cpp index 127155528042..b302b41d21a6 100644 --- a/intl/locale/src/nsLocaleService.cpp +++ b/intl/locale/src/nsLocaleService.cpp @@ -176,7 +176,7 @@ nsLocaleService::nsLocaleService(void) nsRefPtr resultLocale(new nsLocale()); - LocaleObject locale_object = NULL; + LocaleObject locale_object = nullptr; int result = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locale_object); if (result != ULS_SUCCESS) { diff --git a/intl/locale/src/os2/nsCollationOS2.cpp b/intl/locale/src/os2/nsCollationOS2.cpp index f020fa7a0fce..da8cc1ac5ebb 100644 --- a/intl/locale/src/os2/nsCollationOS2.cpp +++ b/intl/locale/src/os2/nsCollationOS2.cpp @@ -71,7 +71,7 @@ nsresult nsCollationOS2::CompareString(int32_t strength, stringNormalized2 = string2; } - LocaleObject locObj = NULL; + LocaleObject locObj = nullptr; int ret = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locObj); if (ret != ULS_SUCCESS) UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"C", &locObj); @@ -98,13 +98,16 @@ nsresult nsCollationOS2::AllocateRawSortKey(int32_t strength, stringNormalized = stringIn; } - LocaleObject locObj = NULL; + LocaleObject locObj = nullptr; int ret = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locObj); if (ret != ULS_SUCCESS) UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"C", &locObj); res = NS_ERROR_FAILURE; // From here on out assume failure... - int length = UniStrxfrm(locObj, NULL, reinterpret_cast(stringNormalized.get()),0); + int length = UniStrxfrm(locObj, + nullptr, + reinterpret_cast(stringNormalized.get()), + 0); if (length >= 0) { length += 5; // Allow for the "extra" chars UniStrxfrm() // will out put (overrunning the buffer if diff --git a/intl/locale/src/os2/nsDateTimeFormatOS2.cpp b/intl/locale/src/os2/nsDateTimeFormatOS2.cpp index b3cc5584c736..d5bfe91e951d 100644 --- a/intl/locale/src/os2/nsDateTimeFormatOS2.cpp +++ b/intl/locale/src/os2/nsDateTimeFormatOS2.cpp @@ -34,7 +34,7 @@ nsresult nsDateTimeFormatOS2::FormatTMTime(nsILocale* locale, UniChar uFmtD[NSDATETIME_FORMAT_BUFFER_LEN] = { 0 }; UniChar uFmtT[NSDATETIME_FORMAT_BUFFER_LEN] = { 0 }; UniChar *pString = nullptr; - LocaleObject locObj = NULL; + LocaleObject locObj = nullptr; int ret = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locObj); if (ret != ULS_SUCCESS) UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"C", &locObj); diff --git a/intl/locale/src/os2/nsOS2Locale.cpp b/intl/locale/src/os2/nsOS2Locale.cpp index 28c3a267f9da..3ca7ed6400a4 100644 --- a/intl/locale/src/os2/nsOS2Locale.cpp +++ b/intl/locale/src/os2/nsOS2Locale.cpp @@ -52,7 +52,7 @@ nsOS2Locale::~nsOS2Locale(void) NS_IMETHODIMP nsOS2Locale::GetPlatformLocale(const nsAString& locale, PULONG os2Codepage) { - LocaleObject locObj = NULL; + LocaleObject locObj = nullptr; int codePage; nsAutoString tempLocale(locale); tempLocale.ReplaceChar('-', '_'); diff --git a/intl/locale/src/windows/nsCollationWin.cpp b/intl/locale/src/windows/nsCollationWin.cpp index 8114a0bf43a7..45b64ff4b0c1 100644 --- a/intl/locale/src/windows/nsCollationWin.cpp +++ b/intl/locale/src/windows/nsCollationWin.cpp @@ -125,7 +125,7 @@ nsresult nsCollationWin::AllocateRawSortKey(int32_t strength, byteLen = LCMapStringW(mLCID, dwMapFlags, (LPCWSTR) PromiseFlatString(stringIn).get(), - -1, NULL, 0); + -1, nullptr, 0); buffer = PR_Malloc(byteLen); if (!buffer) { res = NS_ERROR_OUT_OF_MEMORY; diff --git a/intl/locale/src/windows/nsDateTimeFormatWin.cpp b/intl/locale/src/windows/nsDateTimeFormatWin.cpp index 44ddb7d1ec1b..adae99c0cd4e 100644 --- a/intl/locale/src/windows/nsDateTimeFormatWin.cpp +++ b/intl/locale/src/windows/nsDateTimeFormatWin.cpp @@ -155,7 +155,7 @@ nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale, dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN); } else { - dateLen = nsGetDateFormatW(dwFlags_Date, &system_time, NULL, + dateLen = nsGetDateFormatW(dwFlags_Date, &system_time, nullptr, dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN); } if (dateLen != 0) { @@ -168,7 +168,7 @@ nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale, timeLen = 0; } else { - timeLen = nsGetTimeFormatW(dwFlags_Time, &system_time, NULL, + timeLen = nsGetTimeFormatW(dwFlags_Time, &system_time, nullptr, timeBuffer, NSDATETIMEFORMAT_BUFFER_LEN); if (timeLen != 0) { timeLen--; // Since the count includes the terminating null. @@ -239,7 +239,7 @@ int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTim format ? const_cast (NS_ConvertASCIItoUTF16(format).get()) : - NULL, + nullptr, (LPWSTR) timeStr, cchTime); return len; } @@ -252,7 +252,7 @@ int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDat format ? const_cast (NS_ConvertASCIItoUTF16(format).get()) : - NULL, + nullptr, (LPWSTR) dateStr, cchDate); return len; } diff --git a/intl/lwbrk/src/nsCarbonBreaker.cpp b/intl/lwbrk/src/nsCarbonBreaker.cpp index 725231c33542..fa3aa2f29820 100644 --- a/intl/lwbrk/src/nsCarbonBreaker.cpp +++ b/intl/lwbrk/src/nsCarbonBreaker.cpp @@ -15,7 +15,10 @@ NS_GetComplexLineBreaks(const PRUnichar* aText, uint32_t aLength, memset(aBreakBefore, false, aLength * sizeof(uint8_t)); - OSStatus status = UCCreateTextBreakLocator(NULL, 0, kUCTextBreakLineMask, &breakLocator); + OSStatus status = UCCreateTextBreakLocator(nullptr, + 0, + kUCTextBreakLineMask, + &breakLocator); if (status != noErr) return; diff --git a/intl/lwbrk/src/nsUniscribeBreaker.cpp b/intl/lwbrk/src/nsUniscribeBreaker.cpp index 6e53e8956eb5..04dacdb262aa 100644 --- a/intl/lwbrk/src/nsUniscribeBreaker.cpp +++ b/intl/lwbrk/src/nsUniscribeBreaker.cpp @@ -29,7 +29,8 @@ NS_GetComplexLineBreaks(const PRUnichar* aText, uint32_t aLength, return; do { - result = ScriptItemize(aText, aLength, items.Length(), NULL, NULL, items.Elements(), &outItems); + result = ScriptItemize(aText, aLength, items.Length(), nullptr, nullptr, + items.Elements(), &outItems); if (result == E_OUTOFMEMORY) { if (!items.AppendElements(items.Length()))