From 6e0a9a397d23f5f1e842dc400ff7b34915f49ec6 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Wed, 2 Apr 2014 19:17:11 +0000 Subject: [PATCH] ICU-10816 DateFormat::setLenient to set boolean attribute properly. X-SVN-Rev: 35572 --- icu4c/source/i18n/datefmt.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index dab4354b0e8..e205bf755f3 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -502,10 +502,10 @@ DateFormat::setLenient(UBool lenient) { if (fCalendar != NULL) { fCalendar->setLenient(lenient); - UErrorCode status = U_ZERO_ERROR; - setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, true, status); - setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, true, status); } + UErrorCode status = U_ZERO_ERROR; + setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, lenient, status); + setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, lenient, status); } //---------------------------------------------------------------------- @@ -513,14 +513,14 @@ DateFormat::setLenient(UBool lenient) UBool DateFormat::isLenient() const { + UBool lenient = TRUE; if (fCalendar != NULL) { - UErrorCode status = U_ZERO_ERROR; - return fCalendar->isLenient() - && getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status) - && getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status); + lenient = fCalendar->isLenient(); } - // fCalendar is rarely null - return FALSE; + UErrorCode status = U_ZERO_ERROR; + return lenient + && getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status) + && getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status); } void