From 6a32e3f59130a2519fb1b31fd8a5133c3b32d6f6 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Fri, 26 Feb 2016 18:51:13 +0000 Subject: [PATCH] ICU-12139 Fix uconfig test errors for 57 X-SVN-Rev: 38383 --- icu4c/source/common/cstr.cpp | 6 ++--- icu4c/source/i18n/dtptngen.cpp | 19 ++++++++++++++++ icu4c/source/i18n/unicode/dtptngen.h | 16 +++++++++----- icu4c/source/i18n/unicode/ufieldpositer.h | 22 +++++++++---------- icu4c/source/test/cintltst/cformtst.c | 2 ++ .../test/intltest/simpleformattertest.cpp | 2 ++ 6 files changed, 47 insertions(+), 20 deletions(-) diff --git a/icu4c/source/common/cstr.cpp b/icu4c/source/common/cstr.cpp index c34b212dc27..0c96f79c0d6 100644 --- a/icu4c/source/common/cstr.cpp +++ b/icu4c/source/common/cstr.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2015, International Business Machines +* Copyright (C) 2015-2016, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: charstr.cpp @@ -15,11 +15,11 @@ U_NAMESPACE_BEGIN CStr::CStr(const UnicodeString &in) { UErrorCode status = U_ZERO_ERROR; - int32_t length = in.extract(0, in.length(), NULL, (uint32_t)0); + int32_t length = in.extract(0, in.length(), NULL, (uint32_t)0, US_INV); int32_t resultCapacity = 0; char *buf = s.getAppendBuffer(length, length, resultCapacity, status); if (U_SUCCESS(status)) { - in.extract(0, in.length(), buf, resultCapacity); + in.extract(0, in.length(), buf, resultCapacity, US_INV); s.append(buf, length, status); } } diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index c5a3bcc7938..6a410d461d7 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -398,6 +398,16 @@ DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status) { setDecimalSymbols(locale, status); } // DateTimePatternGenerator::initData +UnicodeString +DateTimePatternGenerator::getSkeleton(const UnicodeString& pattern, UErrorCode& +/*status*/) { + FormatParser fp; + DateTimeMatcher matcher; + PtnSkeleton localSkeleton; + matcher.set(pattern, &fp, localSkeleton); + return localSkeleton.getSkeleton(); +} + UnicodeString DateTimePatternGenerator::staticGetSkeleton( const UnicodeString& pattern, UErrorCode& /*status*/) { @@ -408,6 +418,15 @@ DateTimePatternGenerator::staticGetSkeleton( return localSkeleton.getSkeleton(); } +UnicodeString +DateTimePatternGenerator::getBaseSkeleton(const UnicodeString& pattern, UErrorCode& /*status*/) { + FormatParser fp; + DateTimeMatcher matcher; + PtnSkeleton localSkeleton; + matcher.set(pattern, &fp, localSkeleton); + return localSkeleton.getBaseSkeleton(); +} + UnicodeString DateTimePatternGenerator::staticGetBaseSkeleton( const UnicodeString& pattern, UErrorCode& /*status*/) { diff --git a/icu4c/source/i18n/unicode/dtptngen.h b/icu4c/source/i18n/unicode/dtptngen.h index 4a14377a256..39d1055a858 100644 --- a/icu4c/source/i18n/unicode/dtptngen.h +++ b/icu4c/source/i18n/unicode/dtptngen.h @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2007-2015, International Business Machines Corporation and +* Copyright (C) 2007-2016, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -142,9 +142,12 @@ public: * @return skeleton such as "MMMdd" * @stable ICU 3.8 */ - UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status) { + UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { + The function is commented out because it is a stable API calling a draft API. + After staticGetSkeleton becomes stable, staticGetSkeleton can be used and + these comments and the definition of getSkeleton in dtptngen.cpp should be removed. return staticGetSkeleton(pattern, status); - } + }*/ #ifndef U_HIDE_DRAFT_API /** @@ -178,9 +181,12 @@ public: * @return base skeleton, such as "MMMd" * @stable ICU 3.8 */ - UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status) { + UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { + The function is commented out because it is a stable API calling a draft API. + After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and + these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed. return staticGetBaseSkeleton(pattern, status); - } + }*/ /** * Adds a pattern to the generator. If the pattern has the same skeleton as diff --git a/icu4c/source/i18n/unicode/ufieldpositer.h b/icu4c/source/i18n/unicode/ufieldpositer.h index 6cc9ffada49..836bfdf279d 100644 --- a/icu4c/source/i18n/unicode/ufieldpositer.h +++ b/icu4c/source/i18n/unicode/ufieldpositer.h @@ -1,6 +1,6 @@ /* ***************************************************************************************** -* Copyright (C) 2015, International Business Machines +* Copyright (C) 2015-2016, International Business Machines * Corporation and others. All Rights Reserved. ***************************************************************************************** */ @@ -11,7 +11,6 @@ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING -#ifndef U_HIDE_DRAFT_API #include "unicode/localpointer.h" @@ -37,10 +36,10 @@ /** * Opaque UFieldPositionIterator object for use in C. - * @draft ICU 55 + * @stable ICU 55 */ struct UFieldPositionIterator; -typedef struct UFieldPositionIterator UFieldPositionIterator; /**< C typedef for struct UFieldPositionIterator. @draft ICU 55 */ +typedef struct UFieldPositionIterator UFieldPositionIterator; /**< C typedef for struct UFieldPositionIterator. @stable ICU 55 */ /** * Open a new, unset UFieldPositionIterator object. @@ -49,18 +48,18 @@ typedef struct UFieldPositionIterator UFieldPositionIterator; /**< C typedef fo * @return * A pointer to an empty (unset) UFieldPositionIterator object, * or NULL if an error occurred. - * @draft ICU 55 + * @stable ICU 55 */ -U_DRAFT UFieldPositionIterator* U_EXPORT2 +U_STABLE UFieldPositionIterator* U_EXPORT2 ufieldpositer_open(UErrorCode* status); /** * Close a UFieldPositionIterator object. Once closed it may no longer be used. * @param fpositer * A pointer to the UFieldPositionIterator object to close. - * @draft ICU 55 + * @stable ICU 55 */ -U_DRAFT void U_EXPORT2 +U_STABLE void U_EXPORT2 ufieldpositer_close(UFieldPositionIterator *fpositer); @@ -75,7 +74,7 @@ U_NAMESPACE_BEGIN * * @see LocalPointerBase * @see LocalPointer - * @draft ICU 55 + * @stable ICU 55 */ U_DEFINE_LOCAL_OPEN_POINTER(LocalUFieldPositionIteratorPointer, UFieldPositionIterator, ufieldpositer_close); @@ -109,13 +108,12 @@ U_NAMESPACE_END * descriptions of format functions that take a UFieldPositionIterator* * parameter, such as {@link #udat_formatForFields}. * - * @draft ICU 55 + * @stable ICU 55 */ -U_DRAFT int32_t U_EXPORT2 +U_STABLE int32_t U_EXPORT2 ufieldpositer_next(UFieldPositionIterator *fpositer, int32_t *beginIndex, int32_t *endIndex); -#endif /* U_HIDE_DRAFT_API */ #endif /* #if !UCONFIG_NO_FORMATTING */ #endif diff --git a/icu4c/source/test/cintltst/cformtst.c b/icu4c/source/test/cintltst/cformtst.c index 4fe5c0f7697..819bf8d92cf 100644 --- a/icu4c/source/test/cintltst/cformtst.c +++ b/icu4c/source/test/cintltst/cformtst.c @@ -46,7 +46,9 @@ void addFormatTest(TestNode** root) addDateForTest(root); addDateTimePatternGeneratorTest(root); addDateIntervalFormatTest(root); +#if !UCONFIG_NO_BREAK_ITERATION addRelativeDateFormatTest(root); +#endif /* !UCONFIG_NO_BREAK_ITERATION */ addNumForTest(root); addNumFrDepTest(root); addMsgForTest(root); diff --git a/icu4c/source/test/intltest/simpleformattertest.cpp b/icu4c/source/test/intltest/simpleformattertest.cpp index 361462c3f70..efe030c96ba 100644 --- a/icu4c/source/test/intltest/simpleformattertest.cpp +++ b/icu4c/source/test/intltest/simpleformattertest.cpp @@ -498,6 +498,7 @@ void SimpleFormatterTest::TestFormatReplaceNoOptimizationNoOffsets() { } void SimpleFormatterTest::TestQuotingLikeMessageFormat() { +#if !UCONFIG_NO_FORMATTING UErrorCode status = U_ZERO_ERROR; UnicodeString pattern = "{0} don't can''t '{5}''}{a' again '}'{1} to the '{end"; SimpleFormatter spf(pattern, status); @@ -509,6 +510,7 @@ void SimpleFormatterTest::TestQuotingLikeMessageFormat() { FieldPosition ignore(FieldPosition::DONT_CARE); assertEquals("MessageFormat", expected, mf.format(values, 2, result, ignore, status)); assertEquals("SimpleFormatter", expected, spf.format(x, y, result.remove(), status)); +#endif /* !UCONFIG_NO_FORMATTING */ } void SimpleFormatterTest::verifyOffsets( -- 2.40.0