bf2fec
From f247f08e370626bbb427acd8f4a400fd875350a3 Mon Sep 17 00:00:00 2001
bf2fec
Message-Id: <f247f08e370626bbb427acd8f4a400fd875350a3.1531842113.git.erack@redhat.com>
bf2fec
From: Eike Rathke <erack@redhat.com>
bf2fec
Date: Tue, 17 Apr 2018 20:13:52 +0200
bf2fec
Subject: [PATCH] Upgrade to ICU 61.1
bf2fec
MIME-Version: 1.0
bf2fec
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts"
bf2fec
bf2fec
This is a multi-part message in MIME format.
bf2fec
--------------erAck-patch-parts
bf2fec
Content-Type: text/plain; charset=UTF-8; format=fixed
bf2fec
Content-Transfer-Encoding: 8bit
bf2fec
bf2fec
bf2fec
Change-Id: I89c1c3d13d85decc72576744de2a16d20471d29d
bf2fec
Reviewed-on: https://gerrit.libreoffice.org/53064
bf2fec
Tested-by: Jenkins <ci@libreoffice.org>
bf2fec
Reviewed-by: Eike Rathke <erack@redhat.com>
bf2fec
---
bf2fec
 configure.ac                                  |   4 +-
bf2fec
 download.lst                                  |   8 +-
bf2fec
 external/icu/UnpackedTarball_icu.mk           |   3 +-
bf2fec
 ...patch.1 => icu4c-61-werror-shadow.patch.1} |  30 ++-
bf2fec
 external/icu/icu4c-khmerbreakengine.patch.1   | 246 +++++++++---------
bf2fec
 external/icu/icu4c-ubsan.patch.1              |  91 -------
bf2fec
 6 files changed, 147 insertions(+), 235 deletions(-)
bf2fec
 rename external/icu/{icu4c-59-werror-shadow.patch.1 => icu4c-61-werror-shadow.patch.1} (50%)
bf2fec
 delete mode 100644 external/icu/icu4c-ubsan.patch.1
bf2fec
bf2fec
bf2fec
--------------erAck-patch-parts
bf2fec
Content-Type: text/x-patch; name="0001-Upgrade-to-ICU-61.1.patch"
bf2fec
Content-Transfer-Encoding: 8bit
bf2fec
Content-Disposition: attachment; filename="0001-Upgrade-to-ICU-61.1.patch"
bf2fec
bf2fec
diff --git a/configure.ac b/configure.ac
bf2fec
index bdc374699cb9..458f9f3c2735 100644
bf2fec
--- a/configure.ac
bf2fec
+++ b/configure.ac
bf2fec
@@ -9001,8 +9001,8 @@ SYSTEM_GENBRK=
bf2fec
 SYSTEM_GENCCODE=
bf2fec
 SYSTEM_GENCMN=
bf2fec
 
bf2fec
-ICU_MAJOR=60
bf2fec
-ICU_MINOR=2
bf2fec
+ICU_MAJOR=61
bf2fec
+ICU_MINOR=1
bf2fec
 ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
bf2fec
 ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
bf2fec
 ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
bf2fec
diff --git a/download.lst b/download.lst
bf2fec
index 0a1fa65396d1..76f067bff4d7 100644
bf2fec
--- a/download.lst
bf2fec
+++ b/download.lst
bf2fec
@@ -102,10 +102,10 @@ export HUNSPELL_SHA256SUM := 3cd9ceb062fe5814f668e4f22b2fa6e3ba0b339b921739541ce
bf2fec
 export HUNSPELL_TARBALL := hunspell-1.6.2.tar.gz
bf2fec
 export HYPHEN_SHA256SUM := 304636d4eccd81a14b6914d07b84c79ebb815288c76fe027b9ebff6ff24d5705
bf2fec
 export HYPHEN_TARBALL := 5ade6ae2a99bc1e9e57031ca88d36dad-hyphen-2.8.8.tar.gz
bf2fec
-export ICU_SHA256SUM := f073ea8f35b926d70bb33e6577508aa642a8b316a803f11be20af384811db418
bf2fec
-export ICU_TARBALL := icu4c-60_2-src.tgz
bf2fec
-export ICU_DATA_SHA256SUM := 68f42ad0c9e0a5a5af8eba0577ba100833912288bad6e4d1f42ff480bbcfd4a9
bf2fec
-export ICU_DATA_TARBALL := icu4c-60_2-data.zip
bf2fec
+export ICU_SHA256SUM := d007f89ae8a2543a53525c74359b65b36412fa84b3349f1400be6dcf409fafef
bf2fec
+export ICU_TARBALL := icu4c-61_1-src.tgz
bf2fec
+export ICU_DATA_SHA256SUM := d149ed0985b5a6e16a9d8ed66f105dd58fd334c276779f74241cfa656ed2830a
bf2fec
+export ICU_DATA_TARBALL := icu4c-61_1-data.zip
bf2fec
 export JFREEREPORT_FLOW_ENGINE_SHA256SUM := 233f66e8d25c5dd971716d4200203a612a407649686ef3b52075d04b4c9df0dd
bf2fec
 export JFREEREPORT_FLOW_ENGINE_TARBALL := ba2930200c9f019c2d93a8c88c651a0f-flow-engine-0.9.4.zip
bf2fec
 export JFREEREPORT_FLUTE_SHA256SUM := 1b5b24f7bc543c0362b667692f78db8bab4ed6dafc6172f104d0bd3757d8a133
bf2fec
diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk
bf2fec
index a4d0b16ecb36..b81cdaab6242 100644
bf2fec
--- a/external/icu/UnpackedTarball_icu.mk
bf2fec
+++ b/external/icu/UnpackedTarball_icu.mk
bf2fec
@@ -27,15 +27,14 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
bf2fec
 	external/icu/icu4c-solarisgcc.patch.1 \
bf2fec
 	external/icu/icu4c-mkdir.patch.1 \
bf2fec
 	external/icu/icu4c-$(if $(filter ANDROID,$(OS)),android,rpath).patch.1 \
bf2fec
-	external/icu/icu4c-ubsan.patch.1 \
bf2fec
 	external/icu/icu4c-icu11100.patch.1 \
bf2fec
 	external/icu/icu4c-scriptrun.patch.1 \
bf2fec
 	external/icu/icu4c-rtti.patch.1 \
bf2fec
 	external/icu/icu4c-clang-cl.patch.1 \
bf2fec
 	$(if $(filter-out ANDROID,$(OS)),external/icu/icu4c-icudata-stdlibs.patch.1) \
bf2fec
 	external/icu/icu4c-khmerbreakengine.patch.1 \
bf2fec
-	external/icu/icu4c-59-werror-shadow.patch.1 \
bf2fec
 	external/icu/ofz4860.patch.2 \
bf2fec
+	external/icu/icu4c-61-werror-shadow.patch.1 \
bf2fec
 ))
bf2fec
 
bf2fec
 $(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict))
bf2fec
diff --git a/external/icu/icu4c-59-werror-shadow.patch.1 b/external/icu/icu4c-61-werror-shadow.patch.1
bf2fec
similarity index 50%
bf2fec
rename from external/icu/icu4c-59-werror-shadow.patch.1
bf2fec
rename to external/icu/icu4c-61-werror-shadow.patch.1
bf2fec
index fb88244aff13..b00f76317eff 100644
bf2fec
--- a/external/icu/icu4c-59-werror-shadow.patch.1
bf2fec
+++ b/external/icu/icu4c-61-werror-shadow.patch.1
bf2fec
@@ -1,33 +1,35 @@
bf2fec
+# https://ssl.icu-project.org/trac/ticket/13709
bf2fec
+# Werror=shadow fails for unistr.h
bf2fec
 diff -ur icu.org/source/common/unicode/unistr.h icu/source/common/unicode/unistr.h
bf2fec
---- icu.org/source/common/unicode/unistr.h	2017-03-29 06:44:37.000000000 +0200
bf2fec
-+++ icu/source/common/unicode/unistr.h	2017-04-24 11:59:51.782076511 +0200
bf2fec
-@@ -3080,11 +3080,11 @@
bf2fec
+--- icu.org/source/common/unicode/unistr.h	2018-03-26 15:38:29.000000000 +0200
bf2fec
++++ icu/source/common/unicode/unistr.h	2018-04-18 10:44:16.321188314 +0200
bf2fec
+@@ -3053,11 +3053,11 @@
bf2fec
     * uint16_t * constructor.
bf2fec
     * Delegates to UnicodeString(const char16_t *, int32_t).
bf2fec
     * @param text UTF-16 string
bf2fec
 -   * @param length string length
bf2fec
-+   * @param length_ string length
bf2fec
-    * @draft ICU 59
bf2fec
++   * @param textLength string length
bf2fec
+    * @stable ICU 59
bf2fec
     */
bf2fec
 -  UnicodeString(const uint16_t *text, int32_t length) :
bf2fec
 -      UnicodeString(ConstChar16Ptr(text), length) {}
bf2fec
-+  UnicodeString(const uint16_t *text, int32_t length_) :
bf2fec
-+      UnicodeString(ConstChar16Ptr(text), length_) {}
bf2fec
++  UnicodeString(const uint16_t *text, int32_t textLength) :
bf2fec
++      UnicodeString(ConstChar16Ptr(text), textLength) {}
bf2fec
  #endif
bf2fec
  
bf2fec
-   /*
bf2fec
-@@ -3097,11 +3097,11 @@
bf2fec
+ #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
bf2fec
+@@ -3066,11 +3066,11 @@
bf2fec
     * (Only defined if U_SIZEOF_WCHAR_T==2.)
bf2fec
     * Delegates to UnicodeString(const char16_t *, int32_t).
bf2fec
     * @param text NUL-terminated UTF-16 string
bf2fec
 -   * @param length string length
bf2fec
-+   * @param length_ string length
bf2fec
-    * @draft ICU 59
bf2fec
++   * @param textLength string length
bf2fec
+    * @stable ICU 59
bf2fec
     */
bf2fec
 -  UnicodeString(const wchar_t *text, int32_t length) :
bf2fec
 -      UnicodeString(ConstChar16Ptr(text), length) {}
bf2fec
-+  UnicodeString(const wchar_t *text, int32_t length_) :
bf2fec
-+      UnicodeString(ConstChar16Ptr(text), length_) {}
bf2fec
++  UnicodeString(const wchar_t *text, int32_t textLength) :
bf2fec
++      UnicodeString(ConstChar16Ptr(text), textLength) {}
bf2fec
  #endif
bf2fec
  
bf2fec
-   /*
bf2fec
+   /**
bf2fec
diff --git a/external/icu/icu4c-khmerbreakengine.patch.1 b/external/icu/icu4c-khmerbreakengine.patch.1
bf2fec
index 6b45b3743611..9f134dd961b1 100644
bf2fec
--- a/external/icu/icu4c-khmerbreakengine.patch.1
bf2fec
+++ b/external/icu/icu4c-khmerbreakengine.patch.1
bf2fec
@@ -1,16 +1,18 @@
bf2fec
 diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
---- icu.org/source/common/dictbe.cpp	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/dictbe.cpp	2017-04-21 23:14:23.845894374 +0200
bf2fec
-@@ -29,8 +29,17 @@
bf2fec
+--- icu.org/source/common/dictbe.cpp	2018-03-26 15:38:30.000000000 +0200
bf2fec
++++ icu/source/common/dictbe.cpp	2018-04-17 17:55:38.620944919 +0200
bf2fec
+@@ -29,7 +29,19 @@
bf2fec
   ******************************************************************
bf2fec
   */
bf2fec
  
bf2fec
--DictionaryBreakEngine::DictionaryBreakEngine(uint32_t breakTypes) {
bf2fec
-+DictionaryBreakEngine::DictionaryBreakEngine(uint32_t breakTypes) :
bf2fec
-+    clusterLimit(3)
bf2fec
-+{
bf2fec
+-DictionaryBreakEngine::DictionaryBreakEngine() {
bf2fec
++DictionaryBreakEngine::DictionaryBreakEngine()
bf2fec
++    : fTypes(0), clusterLimit(0) {
bf2fec
++}
bf2fec
++
bf2fec
++DictionaryBreakEngine::DictionaryBreakEngine(uint32_t breakTypes)
bf2fec
++    : fTypes(breakTypes), clusterLimit(3) {
bf2fec
 +    UErrorCode status = U_ZERO_ERROR;
bf2fec
-     fTypes = breakTypes;
bf2fec
 +    fViramaSet.applyPattern(UNICODE_STRING_SIMPLE("[[:ccc=VR:]]"), status);
bf2fec
 +
bf2fec
 +    // note Skip Sets contain fIgnoreSet characters too.
bf2fec
@@ -20,16 +22,7 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
  }
bf2fec
  
bf2fec
  DictionaryBreakEngine::~DictionaryBreakEngine() {
bf2fec
-@@ -92,7 +101,7 @@
bf2fec
-         result = divideUpDictionaryRange(text, rangeStart, rangeEnd, foundBreaks);
bf2fec
-         utext_setNativeIndex(text, current);
bf2fec
-     }
bf2fec
--    
bf2fec
-+
bf2fec
-     return result;
bf2fec
- }
bf2fec
- 
bf2fec
-@@ -103,6 +112,169 @@
bf2fec
+@@ -76,6 +88,169 @@
bf2fec
      fSet.compact();
bf2fec
  }
bf2fec
  
bf2fec
@@ -199,7 +192,7 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
  /*
bf2fec
   ******************************************************************
bf2fec
   * PossibleWord
bf2fec
-@@ -130,35 +302,35 @@
bf2fec
+@@ -103,35 +278,35 @@
bf2fec
  public:
bf2fec
      PossibleWord() : count(0), prefix(0), offset(-1), mark(0), current(0) {};
bf2fec
      ~PossibleWord() {};
bf2fec
@@ -244,7 +237,7 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
          // Dictionary leaves text after longest prefix, not longest word. Back up.
bf2fec
          if (count <= 0) {
bf2fec
              utext_setNativeIndex(text, start);
bf2fec
-@@ -830,51 +1002,28 @@
bf2fec
+@@ -803,51 +978,28 @@
bf2fec
   * KhmerBreakEngine
bf2fec
   */
bf2fec
  
bf2fec
@@ -265,7 +258,8 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -static const int32_t KHMER_MIN_WORD_SPAN = KHMER_MIN_WORD * 2;
bf2fec
 -
bf2fec
  KhmerBreakEngine::KhmerBreakEngine(DictionaryMatcher *adoptDictionary, UErrorCode &status)
bf2fec
-     : DictionaryBreakEngine((1 << UBRK_WORD) | (1 << UBRK_LINE)),
bf2fec
+-    : DictionaryBreakEngine(),
bf2fec
++    : DictionaryBreakEngine((1 << UBRK_WORD) | (1 << UBRK_LINE)),
bf2fec
        fDictionary(adoptDictionary)
bf2fec
  {
bf2fec
 -    fKhmerWordSet.applyPattern(UNICODE_STRING_SIMPLE("[[:Khmr:]&[:LineBreak=SA:]]"), status);
bf2fec
@@ -301,13 +295,13 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -    fEndWordSet.compact();
bf2fec
 -    fBeginWordSet.compact();
bf2fec
 -//    fSuffixSet.compact();
bf2fec
-+	fIgnoreSet.compact();
bf2fec
-+	fBaseSet.compact();
bf2fec
-+	fPuncSet.compact();
bf2fec
++    fIgnoreSet.compact();
bf2fec
++    fBaseSet.compact();
bf2fec
++    fPuncSet.compact();
bf2fec
  }
bf2fec
  
bf2fec
  KhmerBreakEngine::~KhmerBreakEngine() {
bf2fec
-@@ -886,180 +1035,204 @@
bf2fec
+@@ -859,180 +1011,204 @@
bf2fec
                                                  int32_t rangeStart,
bf2fec
                                                  int32_t rangeEnd,
bf2fec
                                                  UVector32 &foundBreaks ) const {
bf2fec
@@ -350,17 +344,6 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 +            foundBreaks.push(rangeEnd, status);
bf2fec
 +        return foundBreaks.size() - wordsFound;
bf2fec
 +    }
bf2fec
-+
bf2fec
-+    scanStart = rangeStart;
bf2fec
-+    scanWJ(text, scanStart, rangeEnd, before, after);
bf2fec
-+    if (startZwsp || initAfter >= before) {
bf2fec
-+        after = initAfter;
bf2fec
-+        before = 0;
bf2fec
-+    }
bf2fec
-+    if (!endZwsp && after > finalBefore && after < rangeEnd)
bf2fec
-+        endZwsp = true;
bf2fec
-+    if (endZwsp && before > finalBefore)
bf2fec
-+        before = finalBefore;
bf2fec
  
bf2fec
 -    while (U_SUCCESS(status) && (current = (int32_t)utext_getNativeIndex(text)) < rangeEnd) {
bf2fec
 -        cuWordLength = 0;
bf2fec
@@ -375,7 +358,17 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -            cpWordLength = words[wordsFound % KHMER_LOOKAHEAD].markedCPLength();
bf2fec
 -            wordsFound += 1;
bf2fec
 -        }
bf2fec
--
bf2fec
++    scanStart = rangeStart;
bf2fec
++    scanWJ(text, scanStart, rangeEnd, before, after);
bf2fec
++    if (startZwsp || initAfter >= before) {
bf2fec
++        after = initAfter;
bf2fec
++        before = 0;
bf2fec
++    }
bf2fec
++    if (!endZwsp && after > finalBefore && after < rangeEnd)
bf2fec
++        endZwsp = true;
bf2fec
++    if (endZwsp && before > finalBefore)
bf2fec
++        before = finalBefore;
bf2fec
+ 
bf2fec
 -        // If there was more than one, see which one can take us forward the most words
bf2fec
 -        else if (candidates > 1) {
bf2fec
 -            // If we're already at the end of the range, we're done
bf2fec
@@ -390,22 +383,6 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -                        words[wordsFound % KHMER_LOOKAHEAD].markCurrent();
bf2fec
 -                        wordsMatched = 2;
bf2fec
 -                    }
bf2fec
--
bf2fec
--                    // If we're already at the end of the range, we're done
bf2fec
--                    if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) {
bf2fec
--                        goto foundBest;
bf2fec
--                    }
bf2fec
--
bf2fec
--                    // See if any of the possible second words is followed by a third word
bf2fec
--                    do {
bf2fec
--                        // If we find a third word, stop right away
bf2fec
--                        if (words[(wordsFound + 2) % KHMER_LOOKAHEAD].candidates(text, fDictionary, rangeEnd)) {
bf2fec
--                            words[wordsFound % KHMER_LOOKAHEAD].markCurrent();
bf2fec
--                            goto foundBest;
bf2fec
--                        }
bf2fec
--                    }
bf2fec
--                    while (words[(wordsFound + 1) % KHMER_LOOKAHEAD].backUp(text));
bf2fec
--                }
bf2fec
 +    utext_setNativeIndex(text, rangeStart);
bf2fec
 +    int32_t numCodePts = rangeEnd - rangeStart;
bf2fec
 +    // bestSnlp[i] is the snlp of the best segmentation of the first i
bf2fec
@@ -415,7 +392,11 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 +    for(int32_t i = 1; i <= numCodePts; i++) {
bf2fec
 +        bestSnlp.addElement(kuint32max, status);
bf2fec
 +    }
bf2fec
-+
bf2fec
+ 
bf2fec
+-                    // If we're already at the end of the range, we're done
bf2fec
+-                    if ((int32_t)utext_getNativeIndex(text) >= rangeEnd) {
bf2fec
+-                        goto foundBest;
bf2fec
+-                    }
bf2fec
 +    // prev[i] is the index of the last code point in the previous word in
bf2fec
 +    // the best segmentation of the first i characters. Note negative implies
bf2fec
 +	// that the code point is part of an unknown word.
bf2fec
@@ -423,7 +404,17 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 +    for(int32_t i = 0; i <= numCodePts; i++) {
bf2fec
 +        prev.addElement(kuint32max, status);
bf2fec
 +    }
bf2fec
-+
bf2fec
+ 
bf2fec
+-                    // See if any of the possible second words is followed by a third word
bf2fec
+-                    do {
bf2fec
+-                        // If we find a third word, stop right away
bf2fec
+-                        if (words[(wordsFound + 2) % KHMER_LOOKAHEAD].candidates(text, fDictionary, rangeEnd)) {
bf2fec
+-                            words[wordsFound % KHMER_LOOKAHEAD].markCurrent();
bf2fec
+-                            goto foundBest;
bf2fec
+-                        }
bf2fec
+-                    }
bf2fec
+-                    while (words[(wordsFound + 1) % KHMER_LOOKAHEAD].backUp(text));
bf2fec
+-                }
bf2fec
 +    const int32_t maxWordSize = 20;
bf2fec
 +    UVector32 values(maxWordSize, status);
bf2fec
 +    values.setSize(maxWordSize);
bf2fec
@@ -528,27 +519,17 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -                if (cuWordLength <= 0) {
bf2fec
 -                    wordsFound += 1;
bf2fec
 -                }
bf2fec
--
bf2fec
--                // Update the length with the passed-over characters
bf2fec
--                cuWordLength += chars;
bf2fec
--            }
bf2fec
--            else {
bf2fec
--                // Back up to where we were for next iteration
bf2fec
--                utext_setNativeIndex(text, current+cuWordLength);
bf2fec
 +                } while (fMarkSet.contains(c) || fIgnoreSet.contains(c));
bf2fec
 +                values.setElementAt(BADSNLP, count);
bf2fec
 +                lengths.setElementAt(utext_getNativeIndex(text) - currix, count++);
bf2fec
 +            } else {
bf2fec
 +                values.setElementAt(BADSNLP, count);
bf2fec
 +                lengths.setElementAt(1, count++);
bf2fec
-             }
bf2fec
-         }
bf2fec
++            }
bf2fec
++        }
bf2fec
  
bf2fec
--        // Never stop before a combining mark.
bf2fec
--        int32_t currPos;
bf2fec
--        while ((currPos = (int32_t)utext_getNativeIndex(text)) < rangeEnd && fMarkSet.contains(utext_current32(text))) {
bf2fec
--            utext_next32(text);
bf2fec
--            cuWordLength += (int32_t)utext_getNativeIndex(text) - currPos;
bf2fec
+-                // Update the length with the passed-over characters
bf2fec
+-                cuWordLength += chars;
bf2fec
 +        for (int32_t j = 0; j < count; j++) {
bf2fec
 +            uint32_t v = values.elementAti(j);
bf2fec
 +            int32_t newSnlp = bestSnlp.elementAti(i) + v;
bf2fec
@@ -559,7 +540,10 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 +                ++ln;
bf2fec
 +                utext_next32(text);
bf2fec
 +                c = utext_current32(text);
bf2fec
-+            }
bf2fec
+             }
bf2fec
+-            else {
bf2fec
+-                // Back up to where we were for next iteration
bf2fec
+-                utext_setNativeIndex(text, current+cuWordLength);
bf2fec
 +            int32_t ln_j_i = ln + i;   // yes really i!
bf2fec
 +            if (newSnlp < bestSnlp.elementAti(ln_j_i)) {
bf2fec
 +                if (v == BADSNLP) {
bf2fec
@@ -572,9 +556,38 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 +                else
bf2fec
 +                    prev.setElementAt(i, ln_j_i);
bf2fec
 +                bestSnlp.setElementAt(newSnlp, ln_j_i);
bf2fec
-+            }
bf2fec
+             }
bf2fec
          }
bf2fec
 -
bf2fec
+-        // Never stop before a combining mark.
bf2fec
+-        int32_t currPos;
bf2fec
+-        while ((currPos = (int32_t)utext_getNativeIndex(text)) < rangeEnd && fMarkSet.contains(utext_current32(text))) {
bf2fec
+-            utext_next32(text);
bf2fec
+-            cuWordLength += (int32_t)utext_getNativeIndex(text) - currPos;
bf2fec
++    }
bf2fec
++    // Start pushing the optimal offset index into t_boundary (t for tentative).
bf2fec
++    // prev[numCodePts] is guaranteed to be meaningful.
bf2fec
++    // We'll first push in the reverse order, i.e.,
bf2fec
++    // t_boundary[0] = numCodePts, and afterwards do a swap.
bf2fec
++    UVector32 t_boundary(numCodePts+1, status);
bf2fec
++
bf2fec
++    int32_t numBreaks = 0;
bf2fec
++    // No segmentation found, set boundary to end of range
bf2fec
++    while (numCodePts >= 0 && (uint32_t)bestSnlp.elementAti(numCodePts) == kuint32max) {
bf2fec
++        --numCodePts;
bf2fec
++    }
bf2fec
++    if (numCodePts < 0) {
bf2fec
++        t_boundary.addElement(numCodePts, status);
bf2fec
++        numBreaks++;
bf2fec
++    } else {
bf2fec
++        for (int32_t i = numCodePts; (uint32_t)i != kuint32max; i = prev.elementAti(i)) {
bf2fec
++            if (i < 0) i = -i;
bf2fec
++            t_boundary.addElement(i, status);
bf2fec
++            numBreaks++;
bf2fec
+         }
bf2fec
++        U_ASSERT(prev.elementAti(t_boundary.elementAti(numBreaks - 1)) == 0);
bf2fec
++    }
bf2fec
+ 
bf2fec
 -        // Look ahead for possible suffixes if a dictionary word does not follow.
bf2fec
 -        // We do this in code rather than using a rule so that the heuristic
bf2fec
 -        // resynch continues to function. For example, one of the suffix characters
bf2fec
@@ -616,30 +629,6 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
 -        // Did we find a word on this iteration? If so, push it on the break stack
bf2fec
 -        if (cuWordLength > 0) {
bf2fec
 -            foundBreaks.push((current+cuWordLength), status);
bf2fec
-+    }
bf2fec
-+    // Start pushing the optimal offset index into t_boundary (t for tentative).
bf2fec
-+    // prev[numCodePts] is guaranteed to be meaningful.
bf2fec
-+    // We'll first push in the reverse order, i.e.,
bf2fec
-+    // t_boundary[0] = numCodePts, and afterwards do a swap.
bf2fec
-+    UVector32 t_boundary(numCodePts+1, status);
bf2fec
-+
bf2fec
-+    int32_t numBreaks = 0;
bf2fec
-+    // No segmentation found, set boundary to end of range
bf2fec
-+    while (numCodePts >= 0 && (uint32_t)bestSnlp.elementAti(numCodePts) == kuint32max) {
bf2fec
-+        --numCodePts;
bf2fec
-+    }
bf2fec
-+    if (numCodePts < 0) {
bf2fec
-+        t_boundary.addElement(numCodePts, status);
bf2fec
-+        numBreaks++;
bf2fec
-+    } else {
bf2fec
-+        for (int32_t i = numCodePts; (uint32_t)i != kuint32max; i = prev.elementAti(i)) {
bf2fec
-+            if (i < 0) i = -i;
bf2fec
-+            t_boundary.addElement(i, status);
bf2fec
-+            numBreaks++;
bf2fec
-+        }
bf2fec
-+        U_ASSERT(prev.elementAti(t_boundary.elementAti(numBreaks - 1)) == 0);
bf2fec
-+    }
bf2fec
-+
bf2fec
 +    // Now that we're done, convert positions in t_boundary[] (indices in
bf2fec
 +    // the normalized input string) back to indices in the original input UText
bf2fec
 +    // while reversing t_boundary and pushing values to foundBreaks.
bf2fec
@@ -669,38 +658,35 @@ diff -ur icu.org/source/common/dictbe.cpp icu/source/common/dictbe.cpp
bf2fec
  
bf2fec
  #if !UCONFIG_NO_NORMALIZATION
bf2fec
 diff -ur icu.org/source/common/dictbe.h icu/source/common/dictbe.h
bf2fec
---- icu.org/source/common/dictbe.h	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/dictbe.h	2017-04-21 23:14:23.845894374 +0200
bf2fec
-@@ -34,6 +34,15 @@
bf2fec
+--- icu.org/source/common/dictbe.h	2018-03-26 15:38:30.000000000 +0200
bf2fec
++++ icu/source/common/dictbe.h	2018-04-17 14:55:33.307639865 +0200
bf2fec
+@@ -34,7 +34,8 @@
bf2fec
+  * threads without synchronization.

bf2fec
   */
bf2fec
  class DictionaryBreakEngine : public LanguageBreakEngine {
bf2fec
-  private:
bf2fec
-+
bf2fec
-+  /**
bf2fec
-+   * 

Default constructor.

bf2fec
-+   *
bf2fec
-+   */
bf2fec
-+  DictionaryBreakEngine();
bf2fec
-+
bf2fec
+- private:
bf2fec
 + protected:
bf2fec
 +
bf2fec
      /**
bf2fec
       * The set of characters handled by this engine
bf2fec
       * @internal
bf2fec
-@@ -48,11 +57,63 @@
bf2fec
+@@ -42,14 +43,84 @@
bf2fec
  
bf2fec
-   uint32_t      fTypes;
bf2fec
+   UnicodeSet    fSet;
bf2fec
  
bf2fec
 +  const int32_t WJ   = 0x2060;
bf2fec
 +  const int32_t ZWSP = 0x200B;
bf2fec
 +
bf2fec
-   /**
bf2fec
--   * 

Default constructor.

bf2fec
--   *
bf2fec
++  /**
bf2fec
++   * The break types it was constructed with
bf2fec
++   * @internal
bf2fec
++   */
bf2fec
++  uint32_t      fTypes;
bf2fec
++
bf2fec
++  /**
bf2fec
 +   * A Unicode set of all viramas
bf2fec
 +   * @internal
bf2fec
-    */
bf2fec
--  DictionaryBreakEngine();
bf2fec
++   */
bf2fec
 +  UnicodeSet    fViramaSet;
bf2fec
 +
bf2fec
 +  /**
bf2fec
@@ -751,10 +737,26 @@ diff -ur icu.org/source/common/dictbe.h icu/source/common/dictbe.h
bf2fec
 +  bool scanAfterEnd(UText *text, int32_t rangeEnd, int32_t& end, bool &doBreak) const;
bf2fec
 +  void scanBackClusters(UText *text, int32_t textStart, int32_t& start) const;
bf2fec
 +  void scanFwdClusters(UText *text, int32_t textEnd, int32_t& end) const;
bf2fec
- 
bf2fec
++
bf2fec
   public:
bf2fec
  
bf2fec
-@@ -83,7 +144,7 @@
bf2fec
+   /**
bf2fec
+-   * 

Constructor

bf2fec
++   * 

Default constructor.

bf2fec
++   *
bf2fec
+    */
bf2fec
+   DictionaryBreakEngine();
bf2fec
+ 
bf2fec
+   /**
bf2fec
++   * 

Constructor with break types.

bf2fec
++   */
bf2fec
++  explicit DictionaryBreakEngine(uint32_t breakTypes);
bf2fec
++
bf2fec
++  /**
bf2fec
+    * 

Virtual destructor.

bf2fec
+    */
bf2fec
+   virtual ~DictionaryBreakEngine();
bf2fec
+@@ -68,7 +139,7 @@
bf2fec
     * 

Find any breaks within a run in the supplied text.

bf2fec
     *
bf2fec
     * @param text A UText representing the text. The iterator is left at
bf2fec
@@ -763,7 +765,7 @@ diff -ur icu.org/source/common/dictbe.h icu/source/common/dictbe.h
bf2fec
     * that starts from the first character in the range.
bf2fec
     * @param startPos The start of the run within the supplied text.
bf2fec
     * @param endPos The end of the run within the supplied text.
bf2fec
-@@ -245,118 +306,120 @@
bf2fec
+@@ -218,118 +289,120 @@
bf2fec
  
bf2fec
  };
bf2fec
  
bf2fec
@@ -997,8 +999,8 @@ diff -ur icu.org/source/common/dictbe.h icu/source/common/dictbe.h
bf2fec
  
bf2fec
  /*******************************************************************
bf2fec
 diff -ur icu.org/source/common/dictionarydata.cpp icu/source/common/dictionarydata.cpp
bf2fec
---- icu.org/source/common/dictionarydata.cpp	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/dictionarydata.cpp	2017-04-21 23:14:23.846894372 +0200
bf2fec
+--- icu.org/source/common/dictionarydata.cpp	2018-03-26 15:38:30.000000000 +0200
bf2fec
++++ icu/source/common/dictionarydata.cpp	2018-04-17 14:04:50.775567214 +0200
bf2fec
 @@ -44,7 +44,7 @@
bf2fec
  
bf2fec
  int32_t UCharsDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t limit,
bf2fec
@@ -1046,8 +1048,8 @@ diff -ur icu.org/source/common/dictionarydata.cpp icu/source/common/dictionaryda
bf2fec
                  if (values != NULL) {
bf2fec
                      values[wordCount] = bt.getValue();
bf2fec
 diff -ur icu.org/source/common/dictionarydata.h icu/source/common/dictionarydata.h
bf2fec
---- icu.org/source/common/dictionarydata.h	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/dictionarydata.h	2017-04-21 23:14:23.846894372 +0200
bf2fec
+--- icu.org/source/common/dictionarydata.h	2018-03-26 15:38:30.000000000 +0200
bf2fec
++++ icu/source/common/dictionarydata.h	2018-04-17 14:04:50.775567214 +0200
bf2fec
 @@ -21,6 +21,7 @@
bf2fec
  #include "unicode/utext.h"
bf2fec
  #include "unicode/udata.h"
bf2fec
@@ -1084,8 +1086,8 @@ diff -ur icu.org/source/common/dictionarydata.h icu/source/common/dictionarydata
bf2fec
  private:
bf2fec
      UChar32 transform(UChar32 c) const;
bf2fec
 diff -ur icu.org/source/data/Makefile.in icu/source/data/Makefile.in
bf2fec
---- icu.org/source/data/Makefile.in	2017-04-21 23:13:03.248087545 +0200
bf2fec
-+++ icu/source/data/Makefile.in	2017-04-21 23:14:23.846894372 +0200
bf2fec
+--- icu.org/source/data/Makefile.in	2018-04-17 12:28:37.098707466 +0200
bf2fec
++++ icu/source/data/Makefile.in	2018-04-17 14:04:50.775567214 +0200
bf2fec
 @@ -183,7 +183,7 @@
bf2fec
  endif
bf2fec
  endif
bf2fec
diff --git a/external/icu/icu4c-ubsan.patch.1 b/external/icu/icu4c-ubsan.patch.1
bf2fec
deleted file mode 100644
bf2fec
index 9f6aa3fbc9f8..000000000000
bf2fec
--- a/external/icu/icu4c-ubsan.patch.1
bf2fec
+++ /dev/null
bf2fec
@@ -1,91 +0,0 @@
bf2fec
-diff -ur icu.org/source/common/rbbidata.h icu/source/common/rbbidata.h
bf2fec
---- icu.org/source/common/rbbidata.h	2017-02-03 19:57:23.000000000 +0100
bf2fec
-+++ icu/source/common/rbbidata.h	2017-04-21 22:46:25.371651160 +0200
bf2fec
-@@ -115,7 +115,7 @@
bf2fec
-                                     /*     StatusTable of the set of matching             */
bf2fec
-                                     /*     tags (rule status values)                      */
bf2fec
-     int16_t          fReserved;
bf2fec
--    uint16_t         fNextState[2]; /*  Next State, indexed by char category.             */
bf2fec
-+    uint16_t         fNextState[1]; /*  Next State, indexed by char category.             */
bf2fec
-                                     /*  This array does not have two elements             */
bf2fec
-                                     /*    Array Size is actually fData->fHeader->fCatCount         */
bf2fec
-                                     /*    CAUTION:  see RBBITableBuilder::getTableSize()  */
bf2fec
-@@ -128,7 +128,7 @@
bf2fec
-     uint32_t         fRowLen;       /*  Length of a state table row, in bytes.            */
bf2fec
-     uint32_t         fFlags;        /*  Option Flags for this state table                 */
bf2fec
-     uint32_t         fReserved;     /*  reserved                                          */
bf2fec
--    char             fTableData[4]; /*  First RBBIStateTableRow begins here.              */
bf2fec
-+    char             fTableData[1]; /*  First RBBIStateTableRow begins here.              */
bf2fec
-                                     /*    (making it char[] simplifies ugly address       */
bf2fec
-                                     /*     arithmetic for indexing variable length rows.) */
bf2fec
- };
bf2fec
-diff -ur icu.org/source/common/rbbitblb.cpp icu/source/common/rbbitblb.cpp
bf2fec
---- icu.org/source/common/rbbitblb.cpp	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/rbbitblb.cpp	2017-04-21 22:46:25.373651159 +0200
bf2fec
-@@ -1095,15 +1095,15 @@
bf2fec
-         return 0;
bf2fec
-     }
bf2fec
- 
bf2fec
--    size    = sizeof(RBBIStateTable) - 4;    // The header, with no rows to the table.
bf2fec
-+    size    = offsetof(RBBIStateTable, fTableData);    // The header, with no rows to the table.
bf2fec
- 
bf2fec
-     numRows = fDStates->size();
bf2fec
-     numCols = fRB->fSetBuilder->getNumCharCategories();
bf2fec
- 
bf2fec
--    //  Note  The declaration of RBBIStateTableRow is for a table of two columns.
bf2fec
--    //        Therefore we subtract two from numCols when determining
bf2fec
-+    //  Note  The declaration of RBBIStateTableRow is for a table of one columns.
bf2fec
-+    //        Therefore we subtract one from numCols when determining
bf2fec
-     //        how much storage to add to a row for the total columns.
bf2fec
--    rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-2);
bf2fec
-+    rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-1);
bf2fec
-     size   += numRows * rowSize;
bf2fec
-     return size;
bf2fec
- }
bf2fec
-@@ -1133,7 +1133,7 @@
bf2fec
-     }
bf2fec
- 
bf2fec
-     table->fRowLen    = sizeof(RBBIStateTableRow) +
bf2fec
--                            sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 2);
bf2fec
-+                            sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 1);
bf2fec
-     table->fNumStates = fDStates->size();
bf2fec
-     table->fFlags     = 0;
bf2fec
-     if (fRB->fLookAheadHardBreak) {
bf2fec
-diff -ur icu.org/source/common/ubidiimp.h icu/source/common/ubidiimp.h
bf2fec
---- icu.org/source/common/ubidiimp.h	2017-02-03 19:57:23.000000000 +0100
bf2fec
-+++ icu/source/common/ubidiimp.h	2017-04-21 22:46:25.374651159 +0200
bf2fec
-@@ -198,8 +198,8 @@
bf2fec
- /* in a Run, logicalStart will get this bit set if the run level is odd */
bf2fec
- #define INDEX_ODD_BIT (1UL<<31)
bf2fec
- 
bf2fec
--#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)(level)<<31))
bf2fec
--#define ADD_ODD_BIT_FROM_LEVEL(x, level)  ((x)|=((int32_t)(level)<<31))
bf2fec
-+#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((uint32_t)(level)<<31))
bf2fec
-+#define ADD_ODD_BIT_FROM_LEVEL(x, level)  ((x)|=((uint32_t)(level)<<31))
bf2fec
- #define REMOVE_ODD_BIT(x)                 ((x)&=~INDEX_ODD_BIT)
bf2fec
- 
bf2fec
- #define GET_INDEX(x)   ((x)&~INDEX_ODD_BIT)
bf2fec
-diff -ur icu.org/source/common/ucmndata.cpp icu/source/common/ucmndata.cpp
bf2fec
---- icu.org/source/common/ucmndata.cpp	2017-03-08 16:34:47.000000000 +0100
bf2fec
-+++ icu/source/common/ucmndata.cpp	2017-04-21 22:46:25.376651159 +0200
bf2fec
-@@ -77,7 +77,7 @@
bf2fec
- typedef struct  {
bf2fec
-     uint32_t          count;
bf2fec
-     uint32_t          reserved;
bf2fec
--    PointerTOCEntry   entry[2];   /* Actual size is from count. */
bf2fec
-+    PointerTOCEntry   entry[1];   /* Actual size is from count. */
bf2fec
- }  PointerTOC;
bf2fec
- 
bf2fec
- 
bf2fec
-diff -ur icu.org/source/common/ucmndata.h icu/source/common/ucmndata.h
bf2fec
---- icu.org/source/common/ucmndata.h	2017-01-20 01:20:31.000000000 +0100
bf2fec
-+++ icu/source/common/ucmndata.h	2017-04-21 22:46:25.377651159 +0200
bf2fec
-@@ -52,7 +52,7 @@
bf2fec
- 
bf2fec
- typedef struct {
bf2fec
-     uint32_t count;
bf2fec
--    UDataOffsetTOCEntry entry[2];    /* Actual size of array is from count. */
bf2fec
-+    UDataOffsetTOCEntry entry[1];    /* Actual size of array is from count. */
bf2fec
- } UDataOffsetTOC;
bf2fec
- 
bf2fec
- /**
bf2fec
bf2fec
--------------erAck-patch-parts--
bf2fec
bf2fec