mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-12736 assume in some places that we always have std::string; merge r39687 & r39704 from dev branch
X-SVN-Rev: 39731
This commit is contained in:
parent
04c115425d
commit
a32c1b17ec
9 changed files with 9 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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 <string>
|
||||
|
||||
#endif // U_HAVE_STD_STRING
|
||||
|
||||
#endif // __STD_STRING_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<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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue