]> granicus.if.org Git - icu/commitdiff
ICU-12766 aix/escaper: WIP.
authorSteven R. Loomis <srl@icu-project.org>
Wed, 15 Mar 2017 04:12:37 +0000 (04:12 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Wed, 15 Mar 2017 04:12:37 +0000 (04:12 +0000)
* 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

icu4c/source/common/unicode/char16ptr.h
icu4c/source/common/unicode/platform.h
icu4c/source/common/unicode/umachine.h
icu4c/source/common/unicode/unistr.h
icu4c/source/config/mh-aix-va
icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/tools/escapesrc/escapesrc.cpp
icu4c/source/tools/icuinfo/icuinfo.cpp

index 27efa5da2d03a7db2fcaa741beb99507ff4c3c97..018cb2e6d6056622bf436d792c82f49e4408a2aa 100644 (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; }
index e6d449b57abcc825b034209a900f3fbc59c71ee8..85371c9740cb93885b79bbc2464649050e835d1d 100644 (file)
 #   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.
index cc28e4b687e60ae9ac943d2d509c8321e68067bd..e43b215f68981ec33f3be12e85c2c1ea9793dfe3 100644 (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
 
 
index 42ef43b293ea058feaa01bb11c5209a473a0f977..e5132f19223039e948528fec4b985de0cb98a956 100644 (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
index b75dda4a17c94ebaa58dd5a4378865339bdfb8d2..1572466a550785c6d6c39346dfee81dabfd3d94f 100644 (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
index c33f61f4de5ea44e47350f6a7b4bfc2ebe283396..96964f00e7666043298fd2a3d3207d3ec1dd1552 100644 (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");
         }
index dde8a1de900abd905a5310cacd2a6d15f2b8ffa0..eba8c71f195148be662b371e20f698fe2e72685e 100644 (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());
index 1a1ce5d9e4b03df5cea3900a72e1eed73b23fc64..08bd87b85dbb677d59f50825a7b73a6a3edc8b48 100644 (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);