]> granicus.if.org Git - icu/commitdiff
ICU-12736 assume in some places that we always have std::string; merge r39687 & r3970...
authorMarkus Scherer <markus.icu@gmail.com>
Sat, 4 Mar 2017 00:06:17 +0000 (00:06 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Sat, 4 Mar 2017 00:06:17 +0000 (00:06 +0000)
X-SVN-Rev: 39731

icu4c/source/common/filteredbrk.cpp
icu4c/source/common/unicode/std_string.h
icu4c/source/common/unicode/stringpiece.h
icu4c/source/common/unicode/unistr.h
icu4c/source/common/uposixdefs.h
icu4c/source/test/intltest/strcase.cpp
icu4c/source/test/intltest/strtest.cpp
icu4c/source/test/intltest/ustrtest.cpp
icu4c/source/tools/pkgdata/pkgdata.cpp

index fcc3fb49b24f309d0d6a50c29d439f95127f13c7..1ab1ca65f6d21c54a8ef8c8b256c4d69204fd78b 100644 (file)
@@ -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
index 9b78f61f6620eac5094947fcc361f08ec2efb1b0..729c56399506eb38b2c9edc1c6420e5abbe5d897 100644 (file)
 
 #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 <string>
 
-#endif  // U_HAVE_STD_STRING
-
 #endif  // __STD_STRING_H__
index 283f40f32138659212fac36a4ba7658296e239e9..b0887effa52585601897b2a8420177ad58843e9e 100644 (file)
@@ -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<int32_t>(str.size())) { }
-#endif
   /**
    * Constructs from a const char * pointer and a specified length.
    * @param offset a const char * pointer (need not be terminated)
index 270229b849aa01465260ae9662775c49ec5ad56e..0d215d67bb04cbee7a10b6628c6d1abb81f49908 100644 (file)
@@ -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.
index bd488692c4e0a69a3e69554edbd0e1e7964be548..b6ee427891ad5224f13836085289d2dff17e2e98 100644 (file)
@@ -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
 
index bf33bed3ca35e20c503878b0bd6074debabef7e3..eb06ca1b0df7574c8a5f11ba37183d2bb4e25d33 100644 (file)
@@ -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) {
index 25bcca88a2d17b106aedd9d75876e25ff379204f..ccc618a55444ad6fd72b046153b46b42053c864b 100644 (file)
@@ -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)
index df579456515c682a955d8f19a636bcfc9a60f768..e92131c75363f814ed4ab4ef41c67b8692e8ea3c 100644 (file)
@@ -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.
index 8bd56855201efb340d5b87abd23e975fe50c9149..432552160b611bd9fdbba5549a834aab2bc8b472 100644 (file)
@@ -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