From: Markus Scherer Date: Sat, 4 Mar 2017 00:06:17 +0000 (+0000) Subject: ICU-12736 assume in some places that we always have std::string; merge r39687 & r3970... X-Git-Tag: release-59-rc~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a32c1b17ece410605413d71bce1dd8a230269168;p=icu ICU-12736 assume in some places that we always have std::string; merge r39687 & r39704 from dev branch X-SVN-Rev: 39731 --- diff --git a/icu4c/source/common/filteredbrk.cpp b/icu4c/source/common/filteredbrk.cpp index fcc3fb49b24..1ab1ca65f6d 100644 --- a/icu4c/source/common/filteredbrk.cpp +++ b/icu4c/source/common/filteredbrk.cpp @@ -702,4 +702,4 @@ FilteredBreakIteratorBuilder::createInstance(UErrorCode& status) { U_NAMESPACE_END -#endif //#if !UCONFIG_NO_BREAK_ITERATION && U_HAVE_STD_STRING && !UCONFIG_NO_FILTERED_BREAK_ITERATION +#endif //#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION diff --git a/icu4c/source/common/unicode/std_string.h b/icu4c/source/common/unicode/std_string.h index 9b78f61f662..729c5639950 100644 --- a/icu4c/source/common/unicode/std_string.h +++ b/icu4c/source/common/unicode/std_string.h @@ -27,13 +27,11 @@ #include "unicode/utypes.h" -#if U_HAVE_STD_STRING - +// Workaround for a libstdc++ bug before libstdc++4.6 (2011). +// https://bugs.llvm.org/show_bug.cgi?id=13364 #if defined(__GLIBCXX__) -namespace std { class type_info; } // WORKAROUND: http://llvm.org/bugs/show_bug.cgi?id=13364 +namespace std { class type_info; } #endif #include -#endif // U_HAVE_STD_STRING - #endif // __STD_STRING_H__ diff --git a/icu4c/source/common/unicode/stringpiece.h b/icu4c/source/common/unicode/stringpiece.h index 283f40f3213..b0887effa52 100644 --- a/icu4c/source/common/unicode/stringpiece.h +++ b/icu4c/source/common/unicode/stringpiece.h @@ -68,14 +68,12 @@ class U_COMMON_API StringPiece : public UMemory { * @stable ICU 4.2 */ StringPiece(const char* str); -#if U_HAVE_STD_STRING /** * Constructs from a std::string. * @stable ICU 4.2 */ StringPiece(const std::string& str) : ptr_(str.data()), length_(static_cast(str.size())) { } -#endif /** * Constructs from a const char * pointer and a specified length. * @param offset a const char * pointer (need not be terminated) diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index 270229b849a..0d215d67bb0 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -1710,8 +1710,6 @@ public: */ void toUTF8(ByteSink &sink) const; -#if U_HAVE_STD_STRING - /** * Convert the UnicodeString to UTF-8 and append the result * to a standard string. @@ -1731,8 +1729,6 @@ public: return result; } -#endif - /** * Convert the UnicodeString to UTF-32. * Unpaired surrogates are replaced with U+FFFD. diff --git a/icu4c/source/common/uposixdefs.h b/icu4c/source/common/uposixdefs.h index bd488692c4e..b6ee427891a 100644 --- a/icu4c/source/common/uposixdefs.h +++ b/icu4c/source/common/uposixdefs.h @@ -54,7 +54,7 @@ * * z/OS needs this definition for timeval and to get usleep. */ -#if !defined(_XOPEN_SOURCE_EXTENDED) +#if !defined(_XOPEN_SOURCE_EXTENDED) && defined(__TOS_MVS__) # define _XOPEN_SOURCE_EXTENDED 1 #endif @@ -68,7 +68,7 @@ */ #if (U_PLATFORM == U_PF_AIX && !defined(__GNUC__)) || (U_PLATFORM == U_PF_SOLARIS && defined(__GNUC__)) # if _XOPEN_SOURCE_EXTENDED && !defined(U_HAVE_STD_STRING) -# define U_HAVE_STD_STRING 0 +// TODO: conflicts with unconditional use of std::string # define U_HAVE_STD_STRING 0 # endif #endif diff --git a/icu4c/source/test/intltest/strcase.cpp b/icu4c/source/test/intltest/strcase.cpp index bf33bed3ca3..eb06ca1b0df 100644 --- a/icu4c/source/test/intltest/strcase.cpp +++ b/icu4c/source/test/intltest/strcase.cpp @@ -702,7 +702,8 @@ StringCaseTest::assertGreekUpper(const char *s, const char *expected) { expectedErrorCode = U_STRING_NOT_TERMINATED_WARNING; } else { expectedErrorCode = U_ZERO_ERROR; - assertEquals(msg + cap + " NUL", 0, dest8b[length]); + // Casts to int32_t to avoid matching UBool. + assertEquals(msg + cap + " NUL", (int32_t)0, (int32_t)dest8b[length]); } assertEquals(msg + cap + " errorCode", expectedErrorCode, errorCode); if (cap >= expected8Length) { diff --git a/icu4c/source/test/intltest/strtest.cpp b/icu4c/source/test/intltest/strtest.cpp index 25bcca88a2d..ccc618a5544 100644 --- a/icu4c/source/test/intltest/strtest.cpp +++ b/icu4c/source/test/intltest/strtest.cpp @@ -212,14 +212,12 @@ StringTest::TestStringPiece() { if(abcd.empty() || abcd.data()!=abcdefg_chars || abcd.length()!=4 || abcd.size()!=4) { errln("StringPiece(abcdefg_chars, 4) failed"); } -#if U_HAVE_STD_STRING // Construct from std::string. std::string uvwxyz_string("uvwxyz"); StringPiece uvwxyz(uvwxyz_string); if(uvwxyz.empty() || uvwxyz.data()!=uvwxyz_string.data() || uvwxyz.length()!=6 || uvwxyz.size()!=6) { errln("StringPiece(uvwxyz_string) failed"); } -#endif // Substring constructor with pos. StringPiece sp(abcd, -1); if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) { @@ -463,7 +461,6 @@ StringTest::TestCheckedArrayByteSink() { void StringTest::TestStringByteSink() { -#if U_HAVE_STD_STRING // Not much to test because only the constructor and Append() // are implemented, and trivially so. std::string result("abc"); // std::string @@ -472,7 +469,6 @@ StringTest::TestStringByteSink() { if(result != "abcdef") { errln("StringByteSink did not Append() as expected"); } -#endif } #if defined(_MSC_VER) diff --git a/icu4c/source/test/intltest/ustrtest.cpp b/icu4c/source/test/intltest/ustrtest.cpp index df579456515..e92131c7536 100644 --- a/icu4c/source/test/intltest/ustrtest.cpp +++ b/icu4c/source/test/intltest/ustrtest.cpp @@ -1888,13 +1888,11 @@ UnicodeStringTest::TestUTF8() { if(from8 != expected) { errln("UnicodeString::fromUTF8(StringPiece) did not create the expected string."); } -#if U_HAVE_STD_STRING std::string utf8_string((const char *)utf8, sizeof(utf8)); UnicodeString from8b = UnicodeString::fromUTF8(utf8_string); if(from8b != expected) { errln("UnicodeString::fromUTF8(std::string) did not create the expected string."); } -#endif static const UChar utf16[] = { 0x41, 0xd900, 0x61, 0xdc00, 0x5a, 0xd900, 0xdc00, 0x7a, 0xd800, 0xdc00, 0xdbff, 0xdfff @@ -1916,7 +1914,6 @@ UnicodeStringTest::TestUTF8() { if(!sink.calledFlush) { errln("UnicodeString::toUTF8(sink) did not sink.Flush()."); } -#if U_HAVE_STD_STRING // Initial contents for testing that toUTF8String() appends. std::string result8 = "-->"; std::string expected8 = "-->" + std::string((const char *)expected_utf8, sizeof(expected_utf8)); @@ -1925,7 +1922,6 @@ UnicodeStringTest::TestUTF8() { if(result8r != expected8 || &result8r != &result8) { errln("UnicodeString::toUTF8String() did not create the expected string."); } -#endif } // Test if this compiler supports Return Value Optimization of unnamed temporary objects. diff --git a/icu4c/source/tools/pkgdata/pkgdata.cpp b/icu4c/source/tools/pkgdata/pkgdata.cpp index 8bd56855201..432552160b6 100644 --- a/icu4c/source/tools/pkgdata/pkgdata.cpp +++ b/icu4c/source/tools/pkgdata/pkgdata.cpp @@ -26,7 +26,7 @@ #include "putilimp.h" #if U_HAVE_POPEN -#if (U_PF_MINGW <= U_PLATFORM || U_PLATFORM <= U_PF_CYGWIN) && defined(__STRICT_ANSI__) +#if (U_PF_MINGW <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN) && defined(__STRICT_ANSI__) /* popen/pclose aren't defined in strict ANSI on Cygwin and MinGW */ #undef __STRICT_ANSI__ #endif