ICU-12766 aix/escaper: WIP.

* work around some c++11 issues
* fix some literals in rbbitst.cpp
* update escaper
* add mh-aix-va for using escaping
* work around nullptr and uchar16 issues
* revert bad icuinfo.cpp checkin

this commit still fails.

X-SVN-Rev: 39812
This commit is contained in:
Steven R. Loomis 2017-03-15 04:12:37 +00:00
parent 383d3eead1
commit 394e842e60
8 changed files with 80 additions and 14 deletions

View file

@ -42,12 +42,14 @@ public:
* @draft ICU 59
*/
inline Char16Ptr(char16_t *p);
#if !U_CHAR16_IS_TYPEDEF
/**
* Converts the pointer to char16_t *.
* @param p pointer to be converted
* @draft ICU 59
*/
inline Char16Ptr(uint16_t *p);
#endif
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
* Converts the pointer to char16_t *.
@ -57,12 +59,14 @@ public:
*/
inline Char16Ptr(wchar_t *p);
#endif
#if !U_NO_NULLPTR_T
/**
* nullptr constructor.
* @param p nullptr
* @draft ICU 59
*/
inline Char16Ptr(std::nullptr_t p);
#endif
/**
* Destructor.
* @draft ICU 59
@ -104,11 +108,15 @@ private:
#ifdef U_ALIASING_BARRIER
Char16Ptr::Char16Ptr(char16_t *p) : p(p) {}
#if !U_CHAR16_IS_TYPEDEF
Char16Ptr::Char16Ptr(uint16_t *p) : p(cast(p)) {}
#endif
#if U_SIZEOF_WCHAR_T==2
Char16Ptr::Char16Ptr(wchar_t *p) : p(cast(p)) {}
#endif
#if !U_NO_NULLPTR_T
Char16Ptr::Char16Ptr(std::nullptr_t p) : p(p) {}
#endif
Char16Ptr::~Char16Ptr() {
U_ALIASING_BARRIER(p);
}
@ -118,11 +126,15 @@ char16_t *Char16Ptr::get() const { return p; }
#else
Char16Ptr::Char16Ptr(char16_t *p) { u.cp = p; }
#if !U_CHAR16_IS_TYPEDEF
Char16Ptr::Char16Ptr(uint16_t *p) { u.up = p; }
#endif
#if U_SIZEOF_WCHAR_T==2
Char16Ptr::Char16Ptr(wchar_t *p) { u.wp = p; }
#endif
#if !U_NO_NULLPTR_T
Char16Ptr::Char16Ptr(std::nullptr_t p) { u.cp = p; }
#endif
Char16Ptr::~Char16Ptr() {}
char16_t *Char16Ptr::get() const { return u.cp; }
@ -141,12 +153,14 @@ public:
* @draft ICU 59
*/
inline ConstChar16Ptr(const char16_t *p);
#if !U_CHAR16_IS_TYPEDEF
/**
* Converts the pointer to char16_t *.
* @param p pointer to be converted
* @draft ICU 59
*/
inline ConstChar16Ptr(const uint16_t *p);
#endif
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
* Converts the pointer to char16_t *.
@ -156,12 +170,14 @@ public:
*/
inline ConstChar16Ptr(const wchar_t *p);
#endif
#if !U_NO_NULLPTR_T
/**
* nullptr constructor.
* @param p nullptr
* @draft ICU 59
*/
inline ConstChar16Ptr(const std::nullptr_t p);
#endif
/**
* Destructor.
* @draft ICU 59
@ -203,11 +219,15 @@ private:
#ifdef U_ALIASING_BARRIER
ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) : p(p) {}
#if !U_CHAR16_IS_TYPEDEF
ConstChar16Ptr::ConstChar16Ptr(const uint16_t *p) : p(cast(p)) {}
#endif
#if U_SIZEOF_WCHAR_T==2
ConstChar16Ptr::ConstChar16Ptr(const wchar_t *p) : p(cast(p)) {}
#endif
#if !U_NO_NULLPTR_T
ConstChar16Ptr::ConstChar16Ptr(const std::nullptr_t p) : p(p) {}
#endif
ConstChar16Ptr::~ConstChar16Ptr() {
U_ALIASING_BARRIER(p);
}
@ -217,11 +237,15 @@ const char16_t *ConstChar16Ptr::get() const { return p; }
#else
ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) { u.cp = p; }
#if !U_CHAR16_IS_TYPEDEF
ConstChar16Ptr::ConstChar16Ptr(const uint16_t *p) { u.up = p; }
#endif
#if U_SIZEOF_WCHAR_T==2
ConstChar16Ptr::ConstChar16Ptr(const wchar_t *p) { u.wp = p; }
#endif
#if !U_NO_NULLPTR_T
ConstChar16Ptr::ConstChar16Ptr(const std::nullptr_t p) { u.cp = p; }
#endif
ConstChar16Ptr::~ConstChar16Ptr() {}
const char16_t *ConstChar16Ptr::get() const { return u.cp; }

View file

@ -486,6 +486,12 @@
# define U_CPLUSPLUS_VERSION 1
#endif
#if (U_PLATFORM == U_PF_AIX) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
# define U_NO_NULLPTR_T 1
#else
# define U_NO_NULLPTR_T 0
#endif
/**
* \def U_HAVE_RVALUE_REFERENCES
* Set to 1 if the compiler supports rvalue references.

View file

@ -295,6 +295,9 @@ typedef int8_t UBool;
*/
#if (U_PLATFORM == U_PF_AIX) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
# include <uchar.h>
# define U_CHAR16_IS_TYPEDEF 1
#else
# define U_CHAR16_IS_TYPEDEF 0
#endif

View file

@ -3002,6 +3002,7 @@ public:
*/
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char16_t *text);
#if !U_CHAR16_IS_TYPEDEF
/**
* uint16_t * constructor.
* Delegates to UnicodeString(const char16_t *).
@ -3014,6 +3015,7 @@ public:
*/
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const uint16_t *text) :
UnicodeString(ConstChar16Ptr(text)) {}
#endif
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
@ -3031,6 +3033,7 @@ public:
UnicodeString(ConstChar16Ptr(text)) {}
#endif
#if !U_NO_NULLPTR_T
/**
* nullptr_t constructor.
* Effectively the same as the default constructor, makes an empty string object.
@ -3042,6 +3045,7 @@ public:
* @draft ICU 59
*/
UNISTR_FROM_STRING_EXPLICIT inline UnicodeString(const std::nullptr_t text);
#endif
/**
* char16_t* constructor.
@ -3053,6 +3057,7 @@ public:
UnicodeString(const char16_t *text,
int32_t textLength);
#if !U_CHAR16_IS_TYPEDEF
/**
* uint16_t * constructor.
* Delegates to UnicodeString(const char16_t *, int32_t).
@ -3062,6 +3067,7 @@ public:
*/
UnicodeString(const uint16_t *text, int32_t length) :
UnicodeString(ConstChar16Ptr(text), length) {}
#endif
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
@ -3076,6 +3082,7 @@ public:
UnicodeString(ConstChar16Ptr(text), length) {}
#endif
#if !U_NO_NULLPTR_T
/**
* nullptr_t constructor.
* Effectively the same as the default constructor, makes an empty string object.
@ -3084,7 +3091,7 @@ public:
* @draft ICU 59
*/
inline UnicodeString(const std::nullptr_t text, int32_t length);
#endif
/**
* Readonly-aliasing char16_t* constructor.
* The text will be used for the UnicodeString object, but
@ -3131,6 +3138,7 @@ public:
*/
UnicodeString(char16_t *buffer, int32_t buffLength, int32_t buffCapacity);
#if !U_CHAR16_IS_TYPEDEF
/**
* Writable-aliasing uint16_t * constructor.
* Delegates to UnicodeString(const char16_t *, int32_t, int32_t).
@ -3141,6 +3149,7 @@ public:
*/
UnicodeString(uint16_t *buffer, int32_t buffLength, int32_t buffCapacity) :
UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
#endif
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
@ -3156,6 +3165,7 @@ public:
UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
#endif
#if !U_NO_NULLPTR_T
/**
* Writable-aliasing nullptr_t constructor.
* Effectively the same as the default constructor, makes an empty string object.
@ -3165,6 +3175,7 @@ public:
* @draft ICU 59
*/
inline UnicodeString(std::nullptr_t buffer, int32_t buffLength, int32_t buffCapacity);
#endif
#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
@ -3878,6 +3889,7 @@ UnicodeString::UnicodeString() {
fUnion.fStackFields.fLengthAndFlags=kShortString;
}
#if !U_NO_NULLPTR_T
inline UnicodeString::UnicodeString(const std::nullptr_t /*text*/) {
fUnion.fStackFields.fLengthAndFlags=kShortString;
}
@ -3889,6 +3901,7 @@ inline UnicodeString::UnicodeString(const std::nullptr_t /*text*/, int32_t /*len
inline UnicodeString::UnicodeString(std::nullptr_t /*buffer*/, int32_t /*buffLength*/, int32_t /*buffCapacity*/) {
fUnion.fStackFields.fLengthAndFlags=kShortString;
}
#endif
//========================================
// Read-only implementation methods

View file

@ -111,11 +111,31 @@ $(LIBDIR)/%.a : %.so
%.o: $(srcdir)/%.c
$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $<
%.$(STATIC_O): $(srcdir)/%.cpp
$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
## C++ compilation rules.
# This causes escapesrc to be built before other ICU targets.
NEED_ESCAPING=YES
ifneq ($(SKIP_ESCAPING),)
# no escaping - bootstrap
%.o: $(srcdir)/%.cpp
$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
else
# convert *.cpp files to _*.cpp with \u / \U escaping
CLEANFILES += _*.cpp
# the actual escaping
_%.cpp: $(srcdir)/%.cpp
@$(BINDIR)/escapesrc$(EXEEXT) $< $@
# compilation for static obj
%.$(STATIC_O): _%.cpp
$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
# compilation for dynamic obj
%.o: _%.cpp
$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
endif
## Dependency rules
%.d : %.u

View file

@ -1682,18 +1682,22 @@ void RBBITest::TestUnicodeFiles() {
UBool RBBITest::testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName) {
static const UChar *badTestCases[] = { // Line Numbers from Unicode 7.0.0 file.
u"\u200B\u0020\u007D", // Line 5198
u"\u200B\u0020\u0029", // Line 5202
u"\u200B\u0020\u0021", // Line 5214
u"\u200B\u0020\u002c", // Line 5246
u"\u200B\u0020\u002f", // Line 5298
u"\u200B\u0020}", // Line 5198
u"\u200B\u0020)", // Line 5202
u"\u200B\u0020!", // Line 5214
u"\u200B\u0020,", // Line 5246
u"\u200B\u0020/", // Line 5298
u"\u200B\u0020\u2060" // Line 5302
};
if (strcmp(fileName, "LineBreakTest.txt") != 0) {
return FALSE;
}
#if (U_CPLUSPLUS_VERSION >= 11)
for (const UChar *badCase: badTestCases) {
#else
for (const UChar *badCase = badTestCases[0]; badCase < badTestCases[UPRV_LENGTHOF(badTestCases)]; badCase++) {
#endif
if (testCase == UnicodeString(badCase)) {
return logKnownIssue("7270");
}

View file

@ -197,7 +197,7 @@ int convert(const std::string &infile, const std::string &outfile) {
std::ifstream inf;
inf.open(infile, std::ios::in);
inf.open(infile.c_str(), std::ios::in);
if(!inf.is_open()) {
fprintf(stderr, "%s: could not open input file %s\n", prog.c_str(), infile.c_str());
@ -207,7 +207,7 @@ int convert(const std::string &infile, const std::string &outfile) {
std::ofstream outf;
outf.open(outfile, std::ios::out);
outf.open(outfile.c_str(), std::ios::out);
if(!outf.is_open()) {
fprintf(stderr, "%s: could not open output file %s\n", prog.c_str(), outfile.c_str());

View file

@ -1,7 +1,5 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
char16_t CH = u'';
/*
*******************************************************************************
*
@ -219,8 +217,6 @@ extern int
main(int argc, char* argv[]) {
UErrorCode errorCode = U_ZERO_ERROR;
UBool didSomething = FALSE;
printf("U+%lx\n", CH); return 0;
/* preset then read command line options */
argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);