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
#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__
* @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)
*/
void toUTF8(ByteSink &sink) const;
-#if U_HAVE_STD_STRING
-
/**
* Convert the UnicodeString to UTF-8 and append the result
* to a standard string.
return result;
}
-#endif
-
/**
* Convert the UnicodeString to UTF-32.
* Unpaired surrogates are replaced with U+FFFD.
*
* 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
*/
#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
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) {
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) {
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
if(result != "abcdef") {
errln("StringByteSink did not Append() as expected");
}
-#endif
}
#if defined(_MSC_VER)
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
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));
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.
#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