From 933e73b1d266a707fa51a43d540cc3abfc6efd3d Mon Sep 17 00:00:00 2001 From: Alexey Gousev Date: Wed, 25 Aug 2010 22:28:32 +0000 Subject: [PATCH] ICU-7066 merging trunk X-SVN-Rev: 28531 --- icu4c/source/i18n/smpdtfmt.cpp | 14 +++++----- icu4c/source/i18n/unicode/smpdtfmt.h | 3 +- icu4c/source/i18n/uspoof_conf.cpp | 42 +++++++++++++++------------- icu4c/source/io/unicode/ustream.h | 8 ++++-- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index c23383e02b5..06814babbff 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -1056,7 +1056,7 @@ SimpleDateFormat::formatGMTDefault(NumberFormat *currentNumberFormat,UnicodeStri int32_t SimpleDateFormat::parseGMTDefault(const UnicodeString &text, ParsePosition &pos) const { int32_t start = pos.getIndex(); - NumberFormat *currentNumberFormat = getNumberFormat(UDAT_TIMEZONE_RFC_FIELD); + NumberFormat *currentNumberFormat = getNumberFormatByIndex(UDAT_TIMEZONE_RFC_FIELD); if (start + kUtLen + 1 >= text.length()) { pos.setErrorIndex(start); @@ -1469,7 +1469,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, return; } - currentNumberFormat = getNumberFormat(patternCharIndex); + currentNumberFormat = getNumberFormatByIndex(patternCharIndex); switch (patternCharIndex) { // for any "G" symbol, write out the appropriate era string @@ -1734,7 +1734,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, //---------------------------------------------------------------------- NumberFormat * -SimpleDateFormat::getNumberFormat(UDateFormatField index) const { +SimpleDateFormat::getNumberFormatByIndex(UDateFormatField index) const { if (fNumberFormatters != NULL) { return fNumberFormatters[index]; } else { @@ -1910,7 +1910,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition& if (i+1 < fPattern.length()) { // move to next pattern character UChar ch = fPattern.charAt(i+1); - + // check for whitespace if (uprv_isRuleWhiteSpace(ch)) { i++; @@ -1967,7 +1967,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition& ( u_isUWhiteSpace(text.charAt(pos)) || uprv_isRuleWhiteSpace(text.charAt(pos)))) { ++pos; } - + // Must see at least one white space char in input if (pos > s) { continue; @@ -2388,7 +2388,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC } patternCharIndex = (UDateFormatField)(patternCharPtr - DateFormatSymbols::getPatternUChars()); - currentNumberFormat = getNumberFormat(patternCharIndex); + currentNumberFormat = getNumberFormatByIndex(patternCharIndex); UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex]; // If there are any spaces here, skip over them. If we hit the end @@ -2471,7 +2471,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC } // check return position, if it equals -start, then matchString error - // special case the return code so we don't necessarily fail out until we + // special case the return code so we don't necessarily fail out until we // verify no year information also if (ps == -start) ps--; diff --git a/icu4c/source/i18n/unicode/smpdtfmt.h b/icu4c/source/i18n/unicode/smpdtfmt.h index e5ef68f68d4..54d4a569821 100644 --- a/icu4c/source/i18n/unicode/smpdtfmt.h +++ b/icu4c/source/i18n/unicode/smpdtfmt.h @@ -1021,8 +1021,7 @@ private: /** * Get the numbering system to be used for a particular field. */ - using DateFormat::getNumberFormat; // Do not hide visibility of base class function - NumberFormat * getNumberFormat(UDateFormatField index) const; + NumberFormat * getNumberFormatByIndex(UDateFormatField index) const; /** * Parse the given override string and set up structures for number formats diff --git a/icu4c/source/i18n/uspoof_conf.cpp b/icu4c/source/i18n/uspoof_conf.cpp index 4f8c12bfa33..7a8f2070764 100644 --- a/icu4c/source/i18n/uspoof_conf.cpp +++ b/icu4c/source/i18n/uspoof_conf.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2008-2009, International Business Machines +* Copyright (C) 2008-2010, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -18,7 +18,7 @@ #include "unicode/utypes.h" #include "unicode/uspoof.h" -#if !UCONFIG_NO_REGULAR_EXPRESSIONS +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #if !UCONFIG_NO_NORMALIZATION #include "unicode/unorm.h" @@ -106,8 +106,10 @@ SPUString *SPUStringPool::getByIndex(int32_t index) { // Conforms to the type signature for a USortComparator in uvector.h static int8_t U_CALLCONV SPUStringCompare(UHashTok left, UHashTok right) { - const SPUString *sL = static_cast(left.pointer); - const SPUString *sR = static_cast(right.pointer); + const SPUString *sL = const_cast( + static_cast(left.pointer)); + const SPUString *sR = const_cast( + static_cast(right.pointer)); int32_t lenL = sL->fStr->length(); int32_t lenR = sR->fStr->length(); if (lenL < lenR) { @@ -142,10 +144,10 @@ ConfusabledataBuilder::ConfusabledataBuilder(SpoofImpl *spImpl, UErrorCode &stat fSpoofImpl(spImpl), fInput(NULL), fSLTable(NULL), - fSATable(NULL), + fSATable(NULL), fMLTable(NULL), fMATable(NULL), - fKeySet(NULL), + fKeySet(NULL), fKeyVec(NULL), fValueVec(NULL), fStringTable(NULL), @@ -239,7 +241,7 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL "|^([ \\t]*(?:#.*?)?)$" // OR match empty lines or lines with only a #comment "|^(.*?)$", // OR match any line, which catches illegal lines. 0, NULL, &status); - + // Regular expression for parsing a hex number out of a space-separated list of them. // Capture group 1 gets the number, with spaces removed. fParseHexNum = uregex_openC("\\s*([0-9A-F]+)", 0, NULL, &status); @@ -268,11 +270,11 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL // put them into the appropriate mapping table. UChar32 keyChar = SpoofImpl::ScanHex(fInput, uregex_start(fParseLine, 1, &status), uregex_end(fParseLine, 1, &status), status); - + int32_t mapStringStart = uregex_start(fParseLine, 2, &status); int32_t mapStringLength = uregex_end(fParseLine, 2, &status) - mapStringStart; uregex_setText(fParseHexNum, &fInput[mapStringStart], mapStringLength, &status); - + UnicodeString *mapString = new UnicodeString(); if (mapString == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -284,11 +286,11 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL mapString->append(c); } U_ASSERT(mapString->length() >= 1); - + // Put the map (value) string into the string pool // This a little like a Java intern() - any duplicates will be eliminated. SPUString *smapString = stringPool->addString(mapString, status); - + // Add the UChar32 -> string mapping to the appropriate table. UHashtable *table = uregex_start(fParseLine, 3, &status) >= 0 ? fSLTable : uregex_start(fParseLine, 4, &status) >= 0 ? fSATable : @@ -379,7 +381,7 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL outputData(status); // All of the intermediate allocated data belongs to the ConfusabledataBuilder - // object (this), and is deleted in the destructor. + // object (this), and is deleted in the destructor. return; } @@ -395,11 +397,11 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL void ConfusabledataBuilder::outputData(UErrorCode &status) { U_ASSERT(fSpoofImpl->fSpoofData->fDataOwned == TRUE); - + // The Key Table // While copying the keys to the runtime array, // also sanity check that they are sorted. - + int32_t numKeys = fKeyVec->size(); int32_t *keys = static_cast(fSpoofImpl->fSpoofData->reserveSpace(numKeys*sizeof(int32_t), status)); @@ -440,7 +442,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { fSpoofImpl->fSpoofData->fCFUValues = values; // The Strings Table. - + uint32_t stringsLength = fStringTable->length(); // Reserve an extra space so the string will be nul-terminated. This is // only a convenience, for when debugging; it is not needed otherwise. @@ -455,7 +457,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { rawData->fCFUStringTable = (int32_t)((char *)strings - (char *)rawData); rawData->fCFUStringTableLen = stringsLength; fSpoofImpl->fSpoofData->fCFUStrings = strings; - + // The String Lengths Table // While copying into the runtime array do some sanity checks on the values // Each complete entry contains two fields, an index and an offset. @@ -489,7 +491,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { } - + // addKeyEntry Construction of the confusable Key and Mapping Values tables. // This is an intermediate point in the building process. // We already have the mappings in the hash tables fSLTable, etc. @@ -509,7 +511,7 @@ void ConfusabledataBuilder::addKeyEntry( // is seen anywhere, so this no entry cases are very much expected.) return; } - + // Check whether there is already an entry with the correct mapping. // If so, simply set the flag in the keyTable saying that the existing entry // applies to the table that we're doing now. @@ -546,7 +548,7 @@ void ConfusabledataBuilder::addKeyEntry( adjustedMappingLength = 3; } newKey |= adjustedMappingLength << USPOOF_KEY_LENGTH_SHIFT; - + int32_t newData = targetMapping->fStrTableIndex; fKeyVec->addElement(newKey, status); @@ -594,5 +596,5 @@ UnicodeString ConfusabledataBuilder::getMapping(int32_t index) { } #endif -#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS diff --git a/icu4c/source/io/unicode/ustream.h b/icu4c/source/io/unicode/ustream.h index 36ffec0bca2..43509ff79c7 100644 --- a/icu4c/source/io/unicode/ustream.h +++ b/icu4c/source/io/unicode/ustream.h @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2001-2007 International Business Machines +* Copyright (C) 2001-2010 International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * FILE NAME : ustream.h @@ -11,7 +11,7 @@ * 06/25/2001 grhoten Move iostream from unistr.h ****************************************************************************** */ - + #ifndef USTREAM_H #define USTREAM_H @@ -27,8 +27,12 @@ */ #if U_IOSTREAM_SOURCE >= 199711 +#if (__GNUC__ == 2) +#include +#else #include #include +#endif U_NAMESPACE_BEGIN