Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compilation for libicu 68. #47352

Merged
merged 3 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "pal_locale_internal.h"
Expand Down Expand Up @@ -126,8 +127,8 @@ int32_t GlobalizationNative_GetCalendars(
{
UErrorCode err = U_ZERO_ERROR;
char locale[ULOC_FULLNAME_CAPACITY];
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, FALSE, &err);
UEnumeration* pEnum = ucal_getKeywordValuesForLocale("calendar", locale, TRUE, &err);
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, false, &err);
UEnumeration* pEnum = ucal_getKeywordValuesForLocale("calendar", locale, true, &err);
int stringEnumeratorCount = uenum_count(pEnum, &err);
int calendarsReturned = 0;
for (int i = 0; i < stringEnumeratorCount && calendarsReturned < calendarsCapacity; i++)
Expand Down Expand Up @@ -197,7 +198,7 @@ ResultCode GlobalizationNative_GetCalendarInfo(
{
UErrorCode err = U_ZERO_ERROR;
char locale[ULOC_FULLNAME_CAPACITY];
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, FALSE, &err);
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, false, &err);

if (U_FAILURE(err))
return UnknownError;
Expand All @@ -209,7 +210,7 @@ ResultCode GlobalizationNative_GetCalendarInfo(
case CalendarData_MonthDay:
return GetMonthDayPattern(locale, result, resultCapacity);
default:
assert(FALSE);
assert(false);
return UnknownError;
}
}
Expand All @@ -230,19 +231,19 @@ static int InvokeCallbackForDatePattern(const char* locale,
UDateFormat* pFormat = udat_open(UDAT_NONE, style, locale, NULL, 0, NULL, 0, &err);

if (U_FAILURE(err))
return FALSE;
return false;

UErrorCode ignore = U_ZERO_ERROR;
int32_t patternLen = udat_toPattern(pFormat, FALSE, NULL, 0, &ignore) + 1;
int32_t patternLen = udat_toPattern(pFormat, false, NULL, 0, &ignore) + 1;

UChar* pattern = (UChar*)calloc((size_t)patternLen, sizeof(UChar));
if (pattern == NULL)
{
udat_close(pFormat);
return FALSE;
return false;
}

udat_toPattern(pFormat, FALSE, pattern, patternLen, &err);
udat_toPattern(pFormat, false, pattern, patternLen, &err);
udat_close(pFormat);

if (U_SUCCESS(err))
Expand Down Expand Up @@ -270,7 +271,7 @@ static int InvokeCallbackForDateTimePattern(const char* locale,
UDateTimePatternGenerator* pGenerator = udatpg_open(locale, &err);

if (U_FAILURE(err))
return FALSE;
return false;

UErrorCode ignore = U_ZERO_ERROR;
int32_t patternLen = udatpg_getBestPattern(pGenerator, patternSkeleton, -1, NULL, 0, &ignore) + 1;
Expand All @@ -279,7 +280,7 @@ static int InvokeCallbackForDateTimePattern(const char* locale,
if (bestPattern == NULL)
{
udatpg_close(pGenerator);
return FALSE;
return false;
}

udatpg_getBestPattern(pGenerator, patternSkeleton, -1, bestPattern, patternLen, &err);
Expand Down Expand Up @@ -312,7 +313,7 @@ static int32_t EnumSymbols(const char* locale,
UDateFormat* pFormat = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, locale, NULL, 0, NULL, 0, &err);

if (U_FAILURE(err))
return FALSE;
return false;

char localeWithCalendarName[ULOC_FULLNAME_CAPACITY];
STRING_COPY(localeWithCalendarName, sizeof(localeWithCalendarName), locale);
Expand All @@ -324,7 +325,7 @@ static int32_t EnumSymbols(const char* locale,
if (U_FAILURE(err))
{
udat_close(pFormat);
return FALSE;
return false;
}

udat_setCalendar(pFormat, pCalendar);
Expand Down Expand Up @@ -424,7 +425,7 @@ static int32_t EnumAbbrevEraNames(const char* locale,
char* parentNamePtr = parentNameBuf;
STRING_COPY(localeNamePtr, sizeof(localeNameBuf), locale);

while (TRUE)
while (true)
{
UErrorCode status = U_ZERO_ERROR;
const char* name = GetCalendarName(calendarId);
Expand All @@ -439,7 +440,7 @@ static int32_t EnumAbbrevEraNames(const char* locale,
{
EnumUResourceBundle(erasResBundle, callback, context);
CloseResBundle(rootResBundle, calResBundle, targetCalResBundle, erasColResBundle, erasResBundle);
return TRUE;
return true;
}

// Couldn't find the data we need for this locale, we should fallback.
Expand Down Expand Up @@ -492,10 +493,10 @@ int32_t GlobalizationNative_EnumCalendarInfo(EnumCalendarInfoCallback callback,
{
UErrorCode err = U_ZERO_ERROR;
char locale[ULOC_FULLNAME_CAPACITY];
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, FALSE, &err);
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, false, &err);

if (U_FAILURE(err))
return FALSE;
return false;

switch (dataType)
{
Expand Down Expand Up @@ -536,8 +537,8 @@ int32_t GlobalizationNative_EnumCalendarInfo(EnumCalendarInfoCallback callback,
case CalendarData_AbbrevEraNames:
return EnumAbbrevEraNames(locale, calendarId, callback, context);
default:
assert(FALSE);
return FALSE;
assert(false);
return false;
}
}

Expand Down Expand Up @@ -581,7 +582,7 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era,
UCalendar* pCal = ucal_open(NULL, 0, JAPANESE_LOCALE_AND_CALENDAR, UCAL_TRADITIONAL, &err);

if (U_FAILURE(err))
return FALSE;
return false;

ucal_set(pCal, UCAL_ERA, era);
ucal_set(pCal, UCAL_YEAR, 1);
Expand All @@ -591,7 +592,7 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era,
if (U_FAILURE(err))
{
ucal_close(pCal);
return FALSE;
return false;
}

// set the date to Jan 1
Expand Down Expand Up @@ -628,5 +629,5 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era,
}

ucal_close(pCal);
return FALSE;
return false;
}
19 changes: 10 additions & 9 deletions src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>

#include "pal_icushim_internal.h"
Expand Down Expand Up @@ -34,7 +35,7 @@ void GlobalizationNative_ChangeCase(
// compiler wasn't doing that optimization, and it results in an ~15-20% perf
// improvement on longer strings.)

UBool isError = FALSE;
UBool isError = false;
(void)isError; // only used for assert
int32_t srcIdx = 0, dstIdx = 0;
UChar32 srcCodepoint, dstCodepoint;
Expand All @@ -46,7 +47,7 @@ void GlobalizationNative_ChangeCase(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = u_toupper(srcCodepoint);
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
else
Expand All @@ -56,7 +57,7 @@ void GlobalizationNative_ChangeCase(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = u_tolower(srcCodepoint);
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
}
Expand All @@ -74,7 +75,7 @@ void GlobalizationNative_ChangeCaseInvariant(
{
// See algorithmic comment in ChangeCase.

UBool isError = FALSE;
UBool isError = false;
(void)isError; // only used for assert
int32_t srcIdx = 0, dstIdx = 0;
UChar32 srcCodepoint, dstCodepoint;
Expand All @@ -89,7 +90,7 @@ void GlobalizationNative_ChangeCaseInvariant(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = ((srcCodepoint == (UChar32)0x0131) ? (UChar32)0x0131 : u_toupper(srcCodepoint));
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
else
Expand All @@ -102,7 +103,7 @@ void GlobalizationNative_ChangeCaseInvariant(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = ((srcCodepoint == (UChar32)0x0130) ? (UChar32)0x0130 : u_tolower(srcCodepoint));
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
}
Expand All @@ -119,7 +120,7 @@ void GlobalizationNative_ChangeCaseTurkish(
{
// See algorithmic comment in ChangeCase.

UBool isError = FALSE;
UBool isError = false;
(void)isError; // only used for assert
int32_t srcIdx = 0, dstIdx = 0;
UChar32 srcCodepoint, dstCodepoint;
Expand All @@ -133,7 +134,7 @@ void GlobalizationNative_ChangeCaseTurkish(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = ((srcCodepoint == (UChar32)0x0069) ? (UChar32)0x0130 : u_toupper(srcCodepoint));
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
else
Expand All @@ -145,7 +146,7 @@ void GlobalizationNative_ChangeCaseTurkish(
U16_NEXT(lpSrc, srcIdx, cwSrcLength, srcCodepoint);
dstCodepoint = ((srcCodepoint == (UChar32)0x0049) ? (UChar32)0x0131 : u_tolower(srcCodepoint));
U16_APPEND(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == FALSE && srcIdx == dstIdx);
assert(isError == false && srcIdx == dstIdx);
}
}
}
Expand Down
Loading