[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - bridges/Module_bridges.mk configure.ac distro-configs/LibreOfficeEmscripten.conf download.lst external/icu i18npool/qa i18npool/source include/osl include/sal sal/osl solenv/gbuild vcl/Library_vcl.mk

Eike Rathke erack at redhat.com
Mon Apr 24 09:02:58 UTC 2017


 bridges/Module_bridges.mk                               |    2 
 configure.ac                                            |   38 
 dev/null                                                |binary
 distro-configs/LibreOfficeEmscripten.conf               |   54 
 download.lst                                            |    2 
 external/icu/ExternalProject_icu.mk                     |   10 
 external/icu/UnpackedTarball_icu.mk                     |    9 
 external/icu/clang-cl.patch.0                           |   26 
 external/icu/icu-ubsan.patch.0                          |   11 
 external/icu/icu.changeset_36724.patch.1                |   39 
 external/icu/icu.changeset_36727.patch.1                |   55 
 external/icu/icu.changeset_36801.patch.1                | 1222 ++++++++++++++++
 external/icu/icu4c-changeset-39671.patch.1              |   77 -
 external/icu/icu4c-emscripten.patch.1                   |  116 -
 external/icu/icu4c-icu11451.patch.1                     |   11 
 external/icu/khmerbreakengine.patch                     | 1110 --------------
 i18npool/qa/cppunit/test_breakiterator.cxx              |   20 
 i18npool/source/breakiterator/breakiterator_unicode.cxx |    4 
 include/osl/endian.h                                    |   10 
 include/sal/alloca.h                                    |    2 
 include/sal/config.h                                    |   10 
 sal/osl/unx/socket.cxx                                  |    2 
 sal/osl/unx/system.hxx                                  |    5 
 solenv/gbuild/platform/EMSCRIPTEN_INTEL_emcc.mk         |   18 
 vcl/Library_vcl.mk                                      |    6 
 25 files changed, 1417 insertions(+), 1442 deletions(-)

New commits:
commit d6ca887de38b3989ec1759f69ebcb390af5b6c1d
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Apr 20 22:06:23 2017 +0200

    add ICU changeset-39671 fix for CVE-2017-7867 CVE-2017-7868
    
    http://bugs.icu-project.org/trac/changeset/39671
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=213
    https://bugzilla.redhat.com/show_bug.cgi?id=1444101
    
    Reviewed-on: https://gerrit.libreoffice.org/36754
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit c7de8233d15ed0c90fef6c49a54d60cf10119f58)
    
    Backported to older MSVC using the UGLY_SIZEOF_MAPTOUCHARS macro instead
    of sizeof(UTF8Buf::mapToUChars).
    
    Reviewed-on: https://gerrit.libreoffice.org/36776
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 91f5d002884cae1a60768e9caa9d182f41fb7be6)
    (cherry picked from commit 3cdac6bb2defce45342dff04400c7a37bb8a2453)
    
    Change-Id: I4e776ad4fe63c77057b0c823f8672a2b6703346f

diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk
index 09342893fc8c..f3d796dbf138 100644
--- a/external/icu/UnpackedTarball_icu.mk
+++ b/external/icu/UnpackedTarball_icu.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
 	external/icu/icu.changeset_36727.patch.1 \
 	external/icu/icu.changeset_36801.patch.1 \
 	$(if $(filter-out ANDROID,$(OS)),external/icu/icu4c-icudata-stdlibs.diff) \
+	external/icu/icu4c-changeset-39671.patch.1 \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/icu/icu4c-changeset-39671.patch.1 b/external/icu/icu4c-changeset-39671.patch.1
new file mode 100644
index 000000000000..abcf6ded85ac
--- /dev/null
+++ b/external/icu/icu4c-changeset-39671.patch.1
@@ -0,0 +1,208 @@
+diff -ur icu.org/source/common/utext.cpp icu/source/common/utext.cpp
+--- icu.org/source/common/utext.cpp	2017-04-24 10:40:07.408383999 +0200
++++ icu/source/common/utext.cpp	2017-04-24 10:47:27.868533934 +0200
+@@ -845,9 +845,15 @@
+ //------------------------------------------------------------------------------
+ 
+ // Chunk size.
+-//     Must be less than 85, because of byte mapping from UChar indexes to native indexes.
+-//     Worst case is three native bytes to one UChar.  (Supplemenaries are 4 native bytes
+-//     to two UChars.)
++//     Must be less than 42  (256/6), because of byte mapping from UChar indexes to native indexes.
++//     Worst case there are six UTF-8 bytes per UChar.
++//         obsolete 6 byte form fd + 5 trails maps to fffd
++//         obsolete 5 byte form fc + 4 trails maps to fffd
++//         non-shortest 4 byte forms maps to fffd
++//         normal supplementaries map to a pair of utf-16, two utf8 bytes per utf-16 unit
++//     mapToUChars array size must allow for the worst case, 6.
++//     This could be brought down to 4, by treating fd and fc as pure illegal,
++//     rather than obsolete lead bytes. But that is not compatible with the utf-8 access macros.
+ //
+ enum { UTF8_TEXT_CHUNK_SIZE=32 };
+ 
+@@ -864,6 +870,14 @@
+ //     the last character added being a supplementary, and thus requiring a surrogate
+ //     pair.  Doing this is simpler than checking for the edge case.
+ //
++// erAck: older MSVC used on libreoffice-5-3 and 5-2 bails out with
++// error C2070: 'unknown': illegal sizeof operand
++// for sizeof(UTF8Buf::mapToUChars)
++// so have an ugly workaround:
++// First define a macro of the original size expression, so a follow-up patch
++// on the original code would fail..
++#define UGLY_MAPTOUCHARS_SIZE (UTF8_TEXT_CHUNK_SIZE*6+6)
++#define UGLY_SIZEOF_MAPTOUCHARS (sizeof(uint8_t)*(UGLY_MAPTOUCHARS_SIZE))
+ 
+ struct UTF8Buf {
+     int32_t   bufNativeStart;                        // Native index of first char in UChar buf
+@@ -887,7 +901,7 @@
+                                                      //  Requires two extra slots,
+                                                      //    one for a supplementary starting in the last normal position,
+                                                      //    and one for an entry for the buffer limit position.
+-    uint8_t   mapToUChars[UTF8_TEXT_CHUNK_SIZE*3+6]; // Map native offset from bufNativeStart to
++    uint8_t   mapToUChars[UGLY_MAPTOUCHARS_SIZE];    // Map native offset from bufNativeStart to
+                                                      //   correspoding offset in filled part of buf.
+     int32_t   align;
+ };
+@@ -1030,6 +1044,7 @@
+             // Requested index is in this buffer.
+             u8b = (UTF8Buf *)ut->p;   // the current buffer
+             mapIndex = ix - u8b->toUCharsMapStart;
++            U_ASSERT(mapIndex < (int32_t)UGLY_SIZEOF_MAPTOUCHARS);
+             ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
+             return TRUE;
+ 
+@@ -1296,6 +1311,10 @@
+         // Can only do this if the incoming index is somewhere in the interior of the string.
+         //   If index is at the end, there is no character there to look at.
+         if (ix != ut->b) {
++            // Note: this function will only move the index back if it is on a trail byte
++            //       and there is a preceding lead byte and the sequence from the lead
++            //       through this trail could be part of a valid UTF-8 sequence
++            //       Otherwise the index remains unchanged.
+             U8_SET_CP_START(s8, 0, ix);
+         }
+ 
+@@ -1309,7 +1328,10 @@
+         UChar   *buf = u8b->buf;
+         uint8_t *mapToNative = u8b->mapToNative;
+         uint8_t *mapToUChars = u8b->mapToUChars;
+-        int32_t  toUCharsMapStart = ix - (UTF8_TEXT_CHUNK_SIZE*3 + 1);
++        int32_t  toUCharsMapStart = ix - UGLY_SIZEOF_MAPTOUCHARS + 1;
++        // Note that toUCharsMapStart can be negative. Happens when the remaining
++        // text from current position to the beginning is less than the buffer size.
++        // + 1 because mapToUChars must have a slot at the end for the bufNativeLimit entry.
+         int32_t  destIx = UTF8_TEXT_CHUNK_SIZE+2;   // Start in the overflow region
+                                                     //   at end of buffer to leave room
+                                                     //   for a surrogate pair at the
+@@ -1336,6 +1358,7 @@
+             if (c<0x80) {
+                 // Special case ASCII range for speed.
+                 buf[destIx] = (UChar)c;
++                U_ASSERT(toUCharsMapStart <= srcIx);
+                 mapToUChars[srcIx - toUCharsMapStart] = (uint8_t)destIx;
+                 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart);
+             } else {
+@@ -1365,6 +1388,7 @@
+                 do {
+                     mapToUChars[sIx-- - toUCharsMapStart] = (uint8_t)destIx;
+                 } while (sIx >= srcIx);
++                U_ASSERT(toUCharsMapStart <= (srcIx+1));
+ 
+                 // Set native indexing limit to be the current position.
+                 //   We are processing a non-ascii, non-native-indexing char now;
+@@ -1539,6 +1563,7 @@
+     U_ASSERT(index>=ut->chunkNativeStart+ut->nativeIndexingLimit);
+     U_ASSERT(index<=ut->chunkNativeLimit);
+     int32_t mapIndex = index - u8b->toUCharsMapStart;
++    U_ASSERT(mapIndex < (int32_t)UGLY_SIZEOF_MAPTOUCHARS);
+     int32_t offset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
+     U_ASSERT(offset>=0 && offset<=ut->chunkLength);
+     return offset;
+diff -ur icu.org/source/test/intltest/utxttest.cpp icu/source/test/intltest/utxttest.cpp
+--- icu.org/source/test/intltest/utxttest.cpp	2017-04-24 10:40:07.396383558 +0200
++++ icu/source/test/intltest/utxttest.cpp	2017-04-24 10:49:30.685028467 +0200
+@@ -61,6 +61,8 @@
+             if (exec) Ticket10562();  break;
+         case 6: name = "Ticket10983";
+             if (exec) Ticket10983();  break;
++        case 7: name = "Ticket12888";
++            if (exec) Ticket12888(); break;
+         default: name = "";          break;
+     }
+ }
+@@ -1501,3 +1503,64 @@
+ 
+     utext_close(ut);
+ }
++
++// Ticket 12888: bad handling of illegal utf-8 containing many instances of the archaic, now illegal,
++//               six byte utf-8 forms. Original implementation had an assumption that
++//               there would be at most three utf-8 bytes per UTF-16 code unit.
++//               The five and six byte sequences map to a single replacement character.
++
++void UTextTest::Ticket12888() {
++    const char *badString =
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
++            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80";
++
++    UErrorCode status = U_ZERO_ERROR;
++    LocalUTextPointer ut(utext_openUTF8(NULL, badString, -1, &status));
++    TEST_SUCCESS(status);
++    for (;;) {
++        UChar32 c = utext_next32(ut.getAlias());
++        if (c == U_SENTINEL) {
++            break;
++        }
++    }
++    int32_t endIdx = utext_getNativeIndex(ut.getAlias());
++    if (endIdx != (int32_t)strlen(badString)) {
++        errln("%s:%d expected=%d, actual=%d", __FILE__, __LINE__, strlen(badString), endIdx);
++        return;
++    }
++
++    for (int32_t prevIndex = endIdx; prevIndex>0;) {
++        UChar32 c = utext_previous32(ut.getAlias());
++        int32_t currentIndex = utext_getNativeIndex(ut.getAlias());
++        if (c != 0xfffd) {
++            errln("%s:%d (expected, actual, index) = (%d, %d, %d)\n",
++                    __FILE__, __LINE__, 0xfffd, c, currentIndex);
++            break;
++        }
++        if (currentIndex != prevIndex - 6) {
++            errln("%s:%d: wrong index. Expected, actual = %d, %d",
++                    __FILE__, __LINE__, prevIndex - 6, currentIndex);
++            break;
++        }
++        prevIndex = currentIndex;
++    }
++}
++
+diff -ur icu.org/source/test/intltest/utxttest.h icu/source/test/intltest/utxttest.h
+--- icu.org/source/test/intltest/utxttest.h	2017-04-24 10:40:07.396383558 +0200
++++ icu/source/test/intltest/utxttest.h	2017-04-24 10:50:09.738457001 +0200
+@@ -1,5 +1,5 @@
+ /********************************************************************
+- * COPYRIGHT: 
++ * COPYRIGHT:
+  * Copyright (c) 2005-2014, International Business Machines Corporation and
+  * others. All Rights Reserved.
+  ********************************************************************/
+@@ -35,6 +35,7 @@
+     void Ticket6847();
+     void Ticket10562();
+     void Ticket10983();
++    void Ticket12888();
+ 
+ private:
+     struct m {                              // Map between native indices & code points.
+@@ -49,9 +50,9 @@
+     void TestCopyMove(const UnicodeString &us, UText *ut, UBool move,
+                       int32_t nativeStart, int32_t nativeLimit, int32_t nativeDest,
+                       int32_t u16Start, int32_t u16Limit, int32_t u16Dest);
+-    void TestReplace(const UnicodeString &us,  // reference UnicodeString in which to do the replace 
++    void TestReplace(const UnicodeString &us,  // reference UnicodeString in which to do the replace
+             UText         *ut,                 // UnicodeText object under test.
+-            int32_t       nativeStart,         // Range to be replaced, in UText native units. 
++            int32_t       nativeStart,         // Range to be replaced, in UText native units.
+             int32_t       nativeLimit,
+             int32_t       u16Start,            // Range to be replaced, in UTF-16 units
+             int32_t       u16Limit,            //    for use in the reference UnicodeString.
commit b799279088353b38117171ea212c73af6ccae648
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Apr 24 10:55:47 2017 +0200

    Revert back to ICU 54, because MSP cannot be generated on Windows
    
    Change-Id: Ie0c857c9c8fd7091e115245c75d7490d46033426

diff --git a/bridges/Module_bridges.mk b/bridges/Module_bridges.mk
index a876f0b01deb..534efda6936b 100644
--- a/bridges/Module_bridges.mk
+++ b/bridges/Module_bridges.mk
@@ -24,7 +24,6 @@ $(eval $(call gb_Module_add_targets,bridges,\
 	) \
 ))
 
-ifneq ($(OS), EMSCRIPTEN)
 ifeq (,$(filter build,$(gb_Module_SKIPTARGETS)))
 ifeq ($(strip $(bridges_SELECTED_BRIDGE)),)
 $(call gb_Output_error,no bridge selected for build: bailing out)
@@ -32,6 +31,5 @@ else ifneq ($(words $(bridges_SELECTED_BRIDGE)),1)
 $(call gb_Output_error,multiple bridges selected for build: $(bridges_SELECTED_BRIDGE))
 endif
 endif
-endif
 
 # vim: set noet sw=4 ts=4:
diff --git a/configure.ac b/configure.ac
index ba2dd3408828..9714815911d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -792,27 +792,6 @@ linux-android*)
     BUILD_TYPE="$BUILD_TYPE FONTCONFIG FREETYPE"
     ;;
 
-emscripten*)
-    build_gstreamer_1_0=no
-    build_gstreamer_0_10=no
-    enable_lotuswordpro=no
-    enable_mpl_subset=yes
-    enable_coinmp=yes
-    enable_lpsolve=no
-    enable_report_builder=no
-    with_theme="tango"
-    test_cups=no
-    test_dbus=no
-    test_fontconfig=no
-    test_freetype=no
-    test_gtk=no
-    test_tde=no
-    test_kde4=no
-    test_randr=no
-    test_xrender=no
-    _os=Emscripten
-    ;;
-
 *)
     AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
     ;;
@@ -4318,17 +4297,6 @@ linux-android*)
     esac
     ;;
 
-emscripten*)
-    COM=emcc
-    USING_X11=
-    OS=EMSCRIPTEN
-    RTL_OS=Emscripten
-    P_SEP=:
-    CPUNAME=INTEL
-    RTL_ARCH=x86
-    PLATFORMID=linux_x86
-    ;;
-
 mingw*)
     COM=GCC
     GUIBASE=not-used
@@ -5394,7 +5362,7 @@ else
 fi
 
 dnl check for GNU C++ compiler version
-if test "$GXX" = "yes" -a $CXX != "emcc"; then
+if test "$GXX" = "yes"; then
     AC_MSG_CHECKING([the GNU C++ compiler version])
 
     _gpp_version=`$CXX -dumpversion`
@@ -8935,7 +8903,7 @@ SYSTEM_GENBRK=
 SYSTEM_GENCCODE=
 SYSTEM_GENCMN=
 
-ICU_MAJOR=57
+ICU_MAJOR=54
 ICU_MINOR=1
 ICU_RECLASSIFIED_CLOSE_PARENTHESIS="TRUE"
 ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
@@ -10015,7 +9983,7 @@ fi
 AC_SUBST(ENABLE_KDE4)
 
 ENABLE_HEADLESS=""
-if test "x$with_x" = "xno" -o $CXX = "emcc"; then
+if test "x$with_x" = "xno"; then
     ENABLE_HEADLESS="TRUE"
     SCPDEFS="$SCPDEFS -DLIBO_HEADLESS"
     R="headless"
diff --git a/distro-configs/LibreOfficeEmscripten.conf b/distro-configs/LibreOfficeEmscripten.conf
deleted file mode 100644
index 2678b929d7cc..000000000000
--- a/distro-configs/LibreOfficeEmscripten.conf
+++ /dev/null
@@ -1,54 +0,0 @@
-# Need to specify --host and --build to enable cross-compilation mode
-# See https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Hosts-and-Cross_002dCompilation.html
---host=asmjs-local-emscripten
---build=x86_64-unknown-linux-gnu
-
-# Disable unnecessary stuff
---disable-cairo-canvas
---disable-cups
---disable-gconf
---disable-dconf
---disable-gio
---disable-dbus
---disable-sdremote-bluetooth
---disable-gstreamer-0-10
---disable-gstreamer-1-0
---disable-liblangtag
---disable-lockdown
---disable-odk
---disable-postgresql-sdbc
---disable-firebird-sdbc
---disable-python
---disable-randr
---disable-randr-link
---disable-pdfimport
---disable-systray
---disable-gltf
---disable-collada
---disable-export
---disable-report-builder
---disable-lpsolve
---disable-coinmp
---disable-scripting
---disable-graphite
---disable-orcus
---without-fonts
---without-java
---without-junit
---without-helppack-integration
---without-system-dicts
---with-theme=no
---with-system-zlib=no
-
-# This helps spotting build errors
---with-parallelism=no
-
-# Emscripten doesn't support dynamic loading
---disable-dynamic-loading
-
-# Not sure whether we need this
-#--disable-ccache
-
-# Specify Emscripten compiler
-CC=emcc
-CXX=emcc
diff --git a/download.lst b/download.lst
index c993c7e81f6e..7afba25c9bbf 100644
--- a/download.lst
+++ b/download.lst
@@ -58,7 +58,7 @@ export HARFBUZZ_TARBALL := harfbuzz-0.9.40.tar.bz2
 export HSQLDB_TARBALL := 17410483b5b5f267aa18b7e00b65e6e0-hsqldb_1_8_0.zip
 export HUNSPELL_TARBALL := 4967da60b23413604c9e563beacc63b4-hunspell-1.3.3.tar.gz
 export HYPHEN_TARBALL := 5ade6ae2a99bc1e9e57031ca88d36dad-hyphen-2.8.8.tar.gz
-export ICU_TARBALL := 976734806026a4ef8bdd17937c8898b9-icu4c-57_1-src.tgz
+export ICU_TARBALL := e844caed8f2ca24c088505b0d6271bc0-icu4c-54_1-src.tgz
 export JFREEREPORT_FLOW_ENGINE_TARBALL := ba2930200c9f019c2d93a8c88c651a0f-flow-engine-0.9.4.zip
 export JFREEREPORT_FLUTE_TARBALL := d8bd5eed178db6e2b18eeed243f85aa8-flute-1.1.6.zip
 export JFREEREPORT_LIBBASE_TARBALL := eeb2c7ddf0d302fba4bfc6e97eac9624-libbase-1.1.6.zip
diff --git a/external/icu/ExternalProject_icu.mk b/external/icu/ExternalProject_icu.mk
index 0442997d869a..d302a7c0949e 100644
--- a/external/icu/ExternalProject_icu.mk
+++ b/external/icu/ExternalProject_icu.mk
@@ -22,7 +22,7 @@ ifeq ($(COM),MSC)
 $(call gb_ExternalProject_get_state_target,icu,build) :
 	$(call gb_ExternalProject_run,build,\
 		export LIB="$(ILIB)" \
-		&& CFLAGS="-FS -arch:SSE $(SOLARINC) $(gb_DEBUG_CFLAGS)" CPPFLAGS="$(SOLARINC)" CXXFLAGS="-FS -arch:SSE $(SOLARINC) $(gb_DEBUG_CFLAGS)" \
+		&& CFLAGS="-arch:SSE $(SOLARINC) $(gb_DEBUG_CFLAGS)" CPPFLAGS="$(SOLARINC)" CXXFLAGS="-arch:SSE $(SOLARINC) $(gb_DEBUG_CFLAGS)" \
 			INSTALL=`cygpath -m /usr/bin/install` \
 			./runConfigureICU \
 			$(if $(MSVC_USE_DEBUG_RUNTIME),--enable-debug --disable-release) \
@@ -55,14 +55,14 @@ icu_CFLAGS:=" \
 	$(if $(debug),$(gb_DEBUG_CFLAGS),$(gb_COMPILEROPTFLAGS)) \
 	$(if $(ENABLE_LTO),$(gb_LTOFLAGS)) \
 	$(if $(filter GCC,$(COM)),-fno-strict-aliasing) \
-	$(if $(filter $(true),$(gb_SYMBOL)),$(gb_DEBUGINFO_FLAGS)) \
+	$(if $(filter $(true),$(gb_SYMBOL)),-g) \
 	$(if $(filter ANDROID,$(OS)),-fvisibility=hidden -fno-omit-frame-pointer)"
-icu_CXXFLAGS:="$(CXXFLAGS) $(CXXFLAGS_CXX11) \
+icu_CXXFLAGS:="$(CXXFLAGS_CXX11) \
 	$(if $(filter IOS,$(OS)),-DUCONFIG_NO_FILE_IO) \
 	$(if $(debug),$(gb_DEBUG_CFLAGS),$(gb_COMPILEROPTFLAGS)) \
 	$(if $(ENABLE_LTO),$(gb_LTOFLAGS)) \
 	$(if $(filter GCC,$(COM)),-fno-strict-aliasing) \
-	$(if $(filter $(true),$(gb_SYMBOL)),$(gb_DEBUGINFO_FLAGS)) \
+	$(if $(filter $(true),$(gb_SYMBOL)),-g) \
 	$(if $(filter ANDROID,$(OS)),-fvisibility=hidden -fno-omit-frame-pointer)"
 icu_LDFLAGS:=" \
 	$(if $(ENABLE_LTO),$(gb_LTOFLAGS)) \
@@ -80,7 +80,7 @@ $(call gb_ExternalProject_get_state_target,icu,build) :
 			--disable-layout --disable-samples \
 			$(if $(CROSS_COMPILING),--disable-tools --disable-extras) \
 			$(if $(filter IOS ANDROID,$(OS)),--disable-dyload) \
-			$(if $(filter ANDROID EMSCRIPTEN,$(OS)),--disable-strict ac_cv_c_bigendian=no) \
+			$(if $(filter ANDROID,$(OS)),--disable-strict ac_cv_c_bigendian=no) \
 			$(if $(filter SOLARIS AIX,$(OS)),--disable-64bit-libs) \
 			$(if $(filter TRUE,$(DISABLE_DYNLOADING)),\
 				--enable-static --disable-shared,\
diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk
index 86369ef8e43b..09342893fc8c 100644
--- a/external/icu/UnpackedTarball_icu.mk
+++ b/external/icu/UnpackedTarball_icu.mk
@@ -23,14 +23,12 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
 	external/icu/icu-ubsan.patch.0 \
 	external/icu/icu4c-icu11100.patch.1 \
 	external/icu/icu4c-scriptrun.patch \
+	external/icu/icu4c-icu11451.patch.1 \
 	external/icu/rtti.patch.0 \
-	external/icu/clang-cl.patch.0 \
+	external/icu/icu.changeset_36724.patch.1 \
+	external/icu/icu.changeset_36727.patch.1 \
+	external/icu/icu.changeset_36801.patch.1 \
 	$(if $(filter-out ANDROID,$(OS)),external/icu/icu4c-icudata-stdlibs.diff) \
-	$(if $(filter EMSCRIPTEN,$(OS)),external/icu/icu4c-emscripten.patch.1) \
-	external/icu/khmerbreakengine.patch \
-	external/icu/icu4c-changeset-39671.patch.1 \
 ))
 
-$(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict))
-
 # vim: set noet sw=4 ts=4:
diff --git a/external/icu/clang-cl.patch.0 b/external/icu/clang-cl.patch.0
deleted file mode 100644
index 4df5d0f56c83..000000000000
--- a/external/icu/clang-cl.patch.0
+++ /dev/null
@@ -1,26 +0,0 @@
---- source/config/mh-cygwin-msvc
-+++ source/config/mh-cygwin-msvc
-@@ -51,8 +51,8 @@
- LDFLAGS+=-nologo
- 
- # Commands to compile
--COMPILE.c=	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
-+COMPILE.c=	true && $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
--COMPILE.cc=	$(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
-+COMPILE.cc=	true && $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
- 
- # Commands to link
- LINK.c=		LINK.EXE -subsystem:console $(LDFLAGS)
---- source/runConfigureICU
-+++ source/runConfigureICU
-@@ -259,8 +259,8 @@
-     Cygwin/MSVC)
-         THE_OS="Windows with Cygwin"
-         THE_COMP="Microsoft Visual C++"
--        CC=cl; export CC
--        CXX=cl; export CXX
-+        CC=${CC-cl}; export CC
-+        CXX=${CXX-cl}; export CXX
-         RELEASE_CFLAGS='-Gy -MD'
-         RELEASE_CXXFLAGS='-Gy -MD'
-         DEBUG_CFLAGS='-Zi -MDd'
diff --git a/external/icu/icu-ubsan.patch.0 b/external/icu/icu-ubsan.patch.0
index 6d1d3bcf5014..25efb5fec728 100644
--- a/external/icu/icu-ubsan.patch.0
+++ b/external/icu/icu-ubsan.patch.0
@@ -162,3 +162,14 @@
     }
     virtual UBool operator == (const CacheKeyBase &other) const {
         // reflexive
+--- source/common/uresbund.cpp
++++ source/common/uresbund.cpp
+@@ -53,7 +53,7 @@
+     UHashTok namekey, pathkey;
+     namekey.pointer = b->fName;
+     pathkey.pointer = b->fPath;
+-    return uhash_hashChars(namekey)+37*uhash_hashChars(pathkey);
++    return uhash_hashChars(namekey)+37U*uhash_hashChars(pathkey);
+ }
+ 
+ /* INTERNAL: compares two entries */
diff --git a/external/icu/icu.changeset_36724.patch.1 b/external/icu/icu.changeset_36724.patch.1
new file mode 100644
index 000000000000..82e0f21394b5
--- /dev/null
+++ b/external/icu/icu.changeset_36724.patch.1
@@ -0,0 +1,39 @@
+Index: icu/source/i18n/regexcmp.cpp
+===================================================================
+--- icu/source/i18n/regexcmp.cpp	(revision 36723)
++++ icu/source/i18n/regexcmp.cpp	(revision 36724)
+@@ -2136,4 +2136,8 @@
+             int32_t minML    = minMatchLength(fMatchOpenParen, patEnd);
+             int32_t maxML    = maxMatchLength(fMatchOpenParen, patEnd);
++            if (URX_TYPE(maxML) != 0) {
++                error(U_REGEX_LOOK_BEHIND_LIMIT);
++                break;
++            }
+             if (maxML == INT32_MAX) {
+                 error(U_REGEX_LOOK_BEHIND_LIMIT);
+@@ -2169,4 +2173,8 @@
+             int32_t minML    = minMatchLength(fMatchOpenParen, patEnd);
+             int32_t maxML    = maxMatchLength(fMatchOpenParen, patEnd);
++            if (URX_TYPE(maxML) != 0) {
++                error(U_REGEX_LOOK_BEHIND_LIMIT);
++                break;
++            }
+             if (maxML == INT32_MAX) {
+                 error(U_REGEX_LOOK_BEHIND_LIMIT);
+Index: icu/source/test/testdata/regextst.txt
+===================================================================
+--- icu/source/test/testdata/regextst.txt	(revision 36723)
++++ icu/source/test/testdata/regextst.txt	(revision 36724)
+@@ -1201,4 +1201,12 @@
+ "A|B|\U00012345"                "hello <0>\U00012345</0>"
+ "A|B|\U00010000"                "hello \ud800"
++
++# Bug 11370
++#   Max match length computation of look-behind expression gives result that is too big to fit in the
++#   in the 24 bit operand portion of the compiled code. Expressions should fail to compile
++#   (Look-behind match length must be bounded. This case is treated as unbounded, an error.)
++
++"(?<!(0123456789a){10000000})x"         E  "no match"
++"(?<!\\ubeaf(\\ubeaf{11000}){11000})"   E  "no match"
+ 
+ #  Random debugging, Temporary
diff --git a/external/icu/icu.changeset_36727.patch.1 b/external/icu/icu.changeset_36727.patch.1
new file mode 100644
index 000000000000..1b8e01edb98a
--- /dev/null
+++ b/external/icu/icu.changeset_36727.patch.1
@@ -0,0 +1,55 @@
+Index: icu/source/i18n/regexcmp.cpp
+===================================================================
+--- icu/source/i18n/regexcmp.cpp	(revision 36726)
++++ icu/source/i18n/regexcmp.cpp	(revision 36727)
+@@ -2340,5 +2340,13 @@
+     if (fIntervalUpper == 0) {
+         // Pathological case.  Attempt no matches, as if the block doesn't exist.
++        // Discard the generated code for the block.
++        // If the block included parens, discard the info pertaining to them as well.
+         fRXPat->fCompiledPat->setSize(topOfBlock);
++        if (fMatchOpenParen >= topOfBlock) {
++            fMatchOpenParen = -1;
++        }
++        if (fMatchCloseParen >= topOfBlock) {
++            fMatchCloseParen = -1;
++        }
+         return TRUE;
+     }
+Index: icu/source/i18n/regexcmp.h
+===================================================================
+--- icu/source/i18n/regexcmp.h	(revision 36726)
++++ icu/source/i18n/regexcmp.h	(revision 36727)
+@@ -188,5 +188,7 @@
+                                                      //   of the slot reserved for a state save
+                                                      //   at the start of the most recently processed
+-                                                     //   parenthesized block.
++                                                     //   parenthesized block. Updated when processing
++                                                     //   a close to the location for the corresponding open.
++
+     int32_t                       fMatchCloseParen;  // The position in the pattern of the first
+                                                      //   location after the most recently processed
+Index: icu/source/test/testdata/regextst.txt
+===================================================================
+--- icu/source/test/testdata/regextst.txt	(revision 36726)
++++ icu/source/test/testdata/regextst.txt	(revision 36727)
+@@ -1202,4 +1202,13 @@
+ "A|B|\U00010000"                "hello \ud800"
+ 
++# Bug 11369
++#   Incorrect optimization of patterns with a zero length quantifier {0}
++
++"(.|b)(|b){0}\$(?#xxx){3}(?>\D*)"   "AAAAABBBBBCCCCCDDDDEEEEE"
++"(|b)ab(c)"                     "<0><1></1>ab<2>c</2></0>"
++"(|b){0}a{3}(D*)"               "<0>aaa<2></2></0>"
++"(|b){0,1}a{3}(D*)"             "<0><1></1>aaa<2></2></0>"
++"((|b){0})a{3}(D*)"             "<0><1></1>aaa<3></3></0>"
++
+ # Bug 11370
+ #   Max match length computation of look-behind expression gives result that is too big to fit in the
+@@ -1209,4 +1218,5 @@
+ "(?<!(0123456789a){10000000})x"         E  "no match"
+ "(?<!\\ubeaf(\\ubeaf{11000}){11000})"   E  "no match"
++
+ 
+ #  Random debugging, Temporary
diff --git a/external/icu/icu.changeset_36801.patch.1 b/external/icu/icu.changeset_36801.patch.1
new file mode 100644
index 000000000000..4a926d9126ed
--- /dev/null
+++ b/external/icu/icu.changeset_36801.patch.1
@@ -0,0 +1,1222 @@
+diff -ru icu/source/common/unicode/utypes.h icu/source/common/unicode/utypes.h
+--- icu/source/common/unicode/utypes.h	2014-10-03 18:11:02.000000000 +0200
++++ icu/source/common/unicode/utypes.h	2015-04-10 15:28:06.149993491 +0200
+@@ -647,6 +647,7 @@
+     U_REGEX_STACK_OVERFLOW,               /**< Regular expression backtrack stack overflow.       */
+     U_REGEX_TIME_OUT,                     /**< Maximum allowed match time exceeded                */
+     U_REGEX_STOPPED_BY_CALLER,            /**< Matching operation aborted by user callback fn.    */
++    U_REGEX_PATTERN_TOO_BIG,              /**< Pattern exceeds limits on size or complexity.   @draft ICU 55   */
+     U_REGEX_ERROR_LIMIT,                  /**< This must always be the last value to indicate the limit for regexp errors */
+ 
+     /*
+diff -ru icu/source/common/utypes.c icu/source/common/utypes.c
+--- icu/source/common/utypes.c	2014-10-03 18:11:14.000000000 +0200
++++ icu/source/common/utypes.c	2015-04-10 15:28:06.149993491 +0200
+@@ -1,7 +1,7 @@
+ /*
+ ******************************************************************************
+ *
+-*   Copyright (C) 1997-2011, International Business Machines
++*   Copyright (C) 1997-2014, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ ******************************************************************************
+@@ -165,7 +165,8 @@
+     "U_REGEX_INVALID_RANGE",
+     "U_REGEX_STACK_OVERFLOW",
+     "U_REGEX_TIME_OUT",
+-    "U_REGEX_STOPPED_BY_CALLER"
++    "U_REGEX_STOPPED_BY_CALLER",
++    "U_REGEX_PATTERN_TOO_BIG"
+ };
+ 
+ static const char * const
+diff -ru icu/source/i18n/regexcmp.cpp icu/source/i18n/regexcmp.cpp
+--- icu/source/i18n/regexcmp.cpp	2015-04-10 15:27:31.369772849 +0200
++++ icu/source/i18n/regexcmp.cpp	2015-04-10 15:28:06.152993511 +0200
+@@ -301,7 +301,7 @@
+     //   present in the saved state:  the input string position (int64_t) and
+     //   the position in the compiled pattern.
+     //
+-    fRXPat->fFrameSize+=RESTACKFRAME_HDRCOUNT;
++    allocateStackData(RESTACKFRAME_HDRCOUNT);
+ 
+     //
+     // Optimization pass 1: NOPs, back-references, and case-folding
+@@ -367,9 +367,9 @@
+         //                    the start of an ( grouping.
+         //4   NOP             Resreved, will be replaced by a save if there are
+         //                    OR | operators at the top level
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_STATE_SAVE, 2), *fStatus);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_JMP,  3), *fStatus);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_FAIL, 0), *fStatus);
++        appendOp(URX_STATE_SAVE, 2);
++        appendOp(URX_JMP,  3);
++        appendOp(URX_FAIL, 0);
+ 
+         // Standard open nonCapture paren action emits the two NOPs and
+         //   sets up the paren stack frame.
+@@ -392,7 +392,7 @@
+         }
+ 
+         // add the END operation to the compiled pattern.
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_END, 0), *fStatus);
++        appendOp(URX_END, 0);
+ 
+         // Terminate the pattern compilation state machine.
+         returnVal = FALSE;
+@@ -414,14 +414,13 @@
+             int32_t savePosition = fParenStack.popi();
+             int32_t op = (int32_t)fRXPat->fCompiledPat->elementAti(savePosition);
+             U_ASSERT(URX_TYPE(op) == URX_NOP);  // original contents of reserved location
+-            op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+1);
++            op = buildOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+1);
+             fRXPat->fCompiledPat->setElementAt(op, savePosition);
+ 
+             // Append an JMP operation into the compiled pattern.  The operand for
+             //  the JMP will eventually be the location following the ')' for the
+             //  group.  This will be patched in later, when the ')' is encountered.
+-            op = URX_BUILD(URX_JMP, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_JMP, 0);
+ 
+             // Push the position of the newly added JMP op onto the parentheses stack.
+             // This registers if for fixup when this block's close paren is encountered.
+@@ -430,7 +429,7 @@
+             // Append a NOP to the compiled pattern.  This is the slot reserved
+             //   for a SAVE in the event that there is yet another '|' following
+             //   this one.
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
++            appendOp(URX_NOP, 0);
+             fParenStack.push(fRXPat->fCompiledPat->size()-1, *fStatus);
+         }
+         break;
+@@ -456,12 +455,10 @@
+         //      END_CAPTURE is encountered.
+         {
+             fixLiterals();
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
+-            int32_t  varsLoc    = fRXPat->fFrameSize;    // Reserve three slots in match stack frame.
+-            fRXPat->fFrameSize += 3;
+-            int32_t  cop        = URX_BUILD(URX_START_CAPTURE, varsLoc);
+-            fRXPat->fCompiledPat->addElement(cop, *fStatus);
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
++            appendOp(URX_NOP, 0);
++            int32_t  varsLoc = allocateStackData(3);    // Reserve three slots in match stack frame.
++            appendOp(URX_START_CAPTURE, varsLoc);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the two NOPs.  Depending on what follows in the pattern, the
+@@ -486,8 +483,8 @@
+         //             is an '|' alternation within the parens.
+         {
+             fixLiterals();
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
++            appendOp(URX_NOP, 0);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the two NOPs.
+@@ -509,12 +506,10 @@
+         //             is an '|' alternation within the parens.
+         {
+             fixLiterals();
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
+-            int32_t  varLoc    = fRXPat->fDataSize;    // Reserve a data location for saving the
+-            fRXPat->fDataSize += 1;                    //  state stack ptr.
+-            int32_t  stoOp     = URX_BUILD(URX_STO_SP, varLoc);
+-            fRXPat->fCompiledPat->addElement(stoOp, *fStatus);
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
++            appendOp(URX_NOP, 0);
++            int32_t  varLoc = allocateData(1);    // Reserve a data location for saving the state stack ptr.
++            appendOp(URX_STO_SP, varLoc);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the two NOPs.  Depending on what follows in the pattern, the
+@@ -557,26 +552,14 @@
+         //  Two data slots are reserved, for saving the stack ptr and the input position.
+         {
+             fixLiterals();
+-            int32_t dataLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize += 2;
+-            int32_t op = URX_BUILD(URX_LA_START, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_JMP, fRXPat->fCompiledPat->size()+ 3);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_LA_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_BACKTRACK, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_NOP, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            int32_t dataLoc = allocateData(2);
++            appendOp(URX_LA_START, dataLoc);
++            appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2);
++            appendOp(URX_JMP, fRXPat->fCompiledPat->size()+ 3);
++            appendOp(URX_LA_END, dataLoc);
++            appendOp(URX_BACKTRACK, 0);
++            appendOp(URX_NOP, 0);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the NOPs.
+@@ -601,16 +584,10 @@
+         //                                        an alternate (transparent) region.
+         {
+             fixLiterals();
+-            int32_t dataLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize += 2;
+-            int32_t op = URX_BUILD(URX_LA_START, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_STATE_SAVE, 0);    // dest address will be patched later.
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-
+-            op = URX_BUILD(URX_NOP, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            int32_t dataLoc = allocateData(2);
++            appendOp(URX_LA_START, dataLoc);
++            appendOp(URX_STATE_SAVE, 0);    // dest address will be patched later.
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the StateSave and NOP.
+@@ -648,23 +625,19 @@
+             fixLiterals();
+ 
+             // Allocate data space
+-            int32_t dataLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize += 4;
++            int32_t dataLoc = allocateData(4);
+ 
+             // Emit URX_LB_START
+-            int32_t op = URX_BUILD(URX_LB_START, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LB_START, dataLoc);
+ 
+             // Emit URX_LB_CONT
+-            op = URX_BUILD(URX_LB_CONT, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            fRXPat->fCompiledPat->addElement(0,  *fStatus);    // MinMatchLength.  To be filled later.
+-            fRXPat->fCompiledPat->addElement(0,  *fStatus);    // MaxMatchLength.  To be filled later.
+-
+-            // Emit the NOP
+-            op = URX_BUILD(URX_NOP, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LB_CONT, dataLoc);
++            appendOp(URX_RESERVED_OP, 0);    // MinMatchLength.  To be filled later.
++            appendOp(URX_RESERVED_OP, 0);    // MaxMatchLength.  To be filled later.
++
++            // Emit the NOPs
++            appendOp(URX_NOP, 0);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the URX_LB_CONT and the NOP.
+@@ -704,24 +677,20 @@
+             fixLiterals();
+ 
+             // Allocate data space
+-            int32_t dataLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize += 4;
++            int32_t dataLoc = allocateData(4);
+ 
+             // Emit URX_LB_START
+-            int32_t op = URX_BUILD(URX_LB_START, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LB_START, dataLoc);
+ 
+             // Emit URX_LBN_CONT
+-            op = URX_BUILD(URX_LBN_CONT, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            fRXPat->fCompiledPat->addElement(0,  *fStatus);    // MinMatchLength.  To be filled later.
+-            fRXPat->fCompiledPat->addElement(0,  *fStatus);    // MaxMatchLength.  To be filled later.
+-            fRXPat->fCompiledPat->addElement(0,  *fStatus);    // Continue Loc.    To be filled later.
+-
+-            // Emit the NOP
+-            op = URX_BUILD(URX_NOP, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LBN_CONT, dataLoc);
++            appendOp(URX_RESERVED_OP, 0);    // MinMatchLength.  To be filled later.
++            appendOp(URX_RESERVED_OP, 0);    // MaxMatchLength.  To be filled later.
++            appendOp(URX_RESERVED_OP, 0);    // Continue Loc.    To be filled later.
++
++            // Emit the NOPs
++            appendOp(URX_NOP, 0);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the URX_LB_CONT and the NOP.
+@@ -791,12 +760,9 @@
+ 
+                 if (URX_TYPE(repeatedOp) == URX_SETREF) {
+                     // Emit optimized code for [char set]+
+-                    int32_t loopOpI = URX_BUILD(URX_LOOP_SR_I, URX_VAL(repeatedOp));
+-                    fRXPat->fCompiledPat->addElement(loopOpI, *fStatus);
+-                    frameLoc = fRXPat->fFrameSize;
+-                    fRXPat->fFrameSize++;
+-                    int32_t loopOpC = URX_BUILD(URX_LOOP_C, frameLoc);
+-                    fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);
++                    appendOp(URX_LOOP_SR_I, URX_VAL(repeatedOp));
++                    frameLoc = allocateStackData(1);
++                    appendOp(URX_LOOP_C, frameLoc);
+                     break;
+                 }
+ 
+@@ -804,7 +770,7 @@
+                     URX_TYPE(repeatedOp) == URX_DOTANY_ALL ||
+                     URX_TYPE(repeatedOp) == URX_DOTANY_UNIX) {
+                     // Emit Optimized code for .+ operations.
+-                    int32_t loopOpI = URX_BUILD(URX_LOOP_DOT_I, 0);
++                    int32_t loopOpI = buildOp(URX_LOOP_DOT_I, 0);
+                     if (URX_TYPE(repeatedOp) == URX_DOTANY_ALL) {
+                         // URX_LOOP_DOT_I operand is a flag indicating ". matches any" mode.
+                         loopOpI |= 1;
+@@ -812,11 +778,9 @@
+                     if (fModeFlags & UREGEX_UNIX_LINES) {
+                         loopOpI |= 2;
+                     }
+-                    fRXPat->fCompiledPat->addElement(loopOpI, *fStatus);
+-                    frameLoc = fRXPat->fFrameSize;
+-                    fRXPat->fFrameSize++;
+-                    int32_t loopOpC = URX_BUILD(URX_LOOP_C, frameLoc);
+-                    fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);
++                    appendOp(loopOpI);
++                    frameLoc = allocateStackData(1);
++                    appendOp(URX_LOOP_C, frameLoc);
+                     break;
+                 }
+ 
+@@ -830,18 +794,15 @@
+                 // Zero length match is possible.
+                 // Emit the code sequence that can handle it.
+                 insertOp(topLoc);
+-                frameLoc =  fRXPat->fFrameSize;
+-                fRXPat->fFrameSize++;
++                frameLoc = allocateStackData(1);
+ 
+-                int32_t op = URX_BUILD(URX_STO_INP_LOC, frameLoc);
++                int32_t op = buildOp(URX_STO_INP_LOC, frameLoc);
+                 fRXPat->fCompiledPat->setElementAt(op, topLoc);
+ 
+-                op = URX_BUILD(URX_JMP_SAV_X, topLoc+1);
+-                fRXPat->fCompiledPat->addElement(op, *fStatus);
++                appendOp(URX_JMP_SAV_X, topLoc+1);
+             } else {
+                 // Simpler code when the repeated body must match something non-empty
+-                int32_t  jmpOp  = URX_BUILD(URX_JMP_SAV, topLoc);
+-                fRXPat->fCompiledPat->addElement(jmpOp, *fStatus);
++                appendOp(URX_JMP_SAV, topLoc);
+             }
+         }
+         break;
+@@ -853,8 +814,7 @@
+         //     3.   ...
+         {
+             int32_t topLoc      = blockTopLoc(FALSE);
+-            int32_t saveStateOp = URX_BUILD(URX_STATE_SAVE, topLoc);
+-            fRXPat->fCompiledPat->addElement(saveStateOp, *fStatus);
++            appendOp(URX_STATE_SAVE, topLoc);
+         }
+         break;
+ 
+@@ -868,7 +828,7 @@
+         // Insert the state save into the compiled pattern, and we're done.
+         {
+             int32_t   saveStateLoc = blockTopLoc(TRUE);
+-            int32_t   saveStateOp  = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size());
++            int32_t   saveStateOp  = buildOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size());
+             fRXPat->fCompiledPat->setElementAt(saveStateOp, saveStateLoc);
+         }
+         break;
+@@ -887,14 +847,12 @@
+             int32_t  jmp1_loc = blockTopLoc(TRUE);
+             int32_t  jmp2_loc = fRXPat->fCompiledPat->size();
+ 
+-            int32_t  jmp1_op  = URX_BUILD(URX_JMP, jmp2_loc+1);
++            int32_t  jmp1_op  = buildOp(URX_JMP, jmp2_loc+1);
+             fRXPat->fCompiledPat->setElementAt(jmp1_op, jmp1_loc);
+ 
+-            int32_t  jmp2_op  = URX_BUILD(URX_JMP, jmp2_loc+2);
+-            fRXPat->fCompiledPat->addElement(jmp2_op, *fStatus);
++            appendOp(URX_JMP, jmp2_loc+2);
+ 
+-            int32_t  save_op  = URX_BUILD(URX_STATE_SAVE, jmp1_loc+1);
+-            fRXPat->fCompiledPat->addElement(save_op, *fStatus);
++            appendOp(URX_STATE_SAVE, jmp1_loc+1);
+         }
+         break;
+ 
+@@ -934,12 +892,10 @@
+ 
+                 if (URX_TYPE(repeatedOp) == URX_SETREF) {
+                     // Emit optimized code for a [char set]*
+-                    int32_t loopOpI = URX_BUILD(URX_LOOP_SR_I, URX_VAL(repeatedOp));
++                    int32_t loopOpI = buildOp(URX_LOOP_SR_I, URX_VAL(repeatedOp));
+                     fRXPat->fCompiledPat->setElementAt(loopOpI, topLoc);
+-                    dataLoc = fRXPat->fFrameSize;
+-                    fRXPat->fFrameSize++;
+-                    int32_t loopOpC = URX_BUILD(URX_LOOP_C, dataLoc);
+-                    fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);
++                    dataLoc = allocateStackData(1);
++                    appendOp(URX_LOOP_C, dataLoc);
+                     break;
+                 }
+ 
+@@ -947,7 +903,7 @@
+                     URX_TYPE(repeatedOp) == URX_DOTANY_ALL ||
+                     URX_TYPE(repeatedOp) == URX_DOTANY_UNIX) {
+                     // Emit Optimized code for .* operations.
+-                    int32_t loopOpI = URX_BUILD(URX_LOOP_DOT_I, 0);
++                    int32_t loopOpI = buildOp(URX_LOOP_DOT_I, 0);
+                     if (URX_TYPE(repeatedOp) == URX_DOTANY_ALL) {
+                         // URX_LOOP_DOT_I operand is a flag indicating . matches any mode.
+                         loopOpI |= 1;
+@@ -956,10 +912,8 @@
+                         loopOpI |= 2;
+                     }
+                     fRXPat->fCompiledPat->setElementAt(loopOpI, topLoc);
+-                    dataLoc = fRXPat->fFrameSize;
+-                    fRXPat->fFrameSize++;
+-                    int32_t loopOpC = URX_BUILD(URX_LOOP_C, dataLoc);
+-                    fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);
++                    dataLoc = allocateStackData(1);
++                    appendOp(URX_LOOP_C, dataLoc);
+                     break;
+                 }
+             }
+@@ -968,30 +922,29 @@
+             // The optimizations did not apply.
+ 
+             int32_t   saveStateLoc = blockTopLoc(TRUE);
+-            int32_t   jmpOp        = URX_BUILD(URX_JMP_SAV, saveStateLoc+1);
++            int32_t   jmpOp        = buildOp(URX_JMP_SAV, saveStateLoc+1);
+ 
+             // Check for minimum match length of zero, which requires
+             //    extra loop-breaking code.
+             if (minMatchLength(saveStateLoc, fRXPat->fCompiledPat->size()-1) == 0) {
+                 insertOp(saveStateLoc);
+-                dataLoc =  fRXPat->fFrameSize;
+-                fRXPat->fFrameSize++;
++                dataLoc = allocateStackData(1);
+ 
+-                int32_t op = URX_BUILD(URX_STO_INP_LOC, dataLoc);
++                int32_t op = buildOp(URX_STO_INP_LOC, dataLoc);
+                 fRXPat->fCompiledPat->setElementAt(op, saveStateLoc+1);
+-                jmpOp      = URX_BUILD(URX_JMP_SAV_X, saveStateLoc+2);
++                jmpOp      = buildOp(URX_JMP_SAV_X, saveStateLoc+2);
+             }
+ 
+             // Locate the position in the compiled pattern where the match will continue
+             //   after completing the *.   (4 or 5 in the comment above)
+             int32_t continueLoc = fRXPat->fCompiledPat->size()+1;
+ 
+-            // Put together the save state op store it into the compiled code.
+-            int32_t saveStateOp = URX_BUILD(URX_STATE_SAVE, continueLoc);
++            // Put together the save state op and store it into the compiled code.
++            int32_t saveStateOp = buildOp(URX_STATE_SAVE, continueLoc);
+             fRXPat->fCompiledPat->setElementAt(saveStateOp, saveStateLoc);
+ 
+             // Append the URX_JMP_SAV or URX_JMPX operation to the compiled pattern.
+-            fRXPat->fCompiledPat->addElement(jmpOp, *fStatus);
++            appendOp(jmpOp);
+         }
+         break;
+ 
+@@ -1005,10 +958,9 @@
+         {
+             int32_t     jmpLoc  = blockTopLoc(TRUE);                   // loc  1.
+             int32_t     saveLoc = fRXPat->fCompiledPat->size();        // loc  3.
+-            int32_t     jmpOp   = URX_BUILD(URX_JMP, saveLoc);
+-            int32_t     stateSaveOp = URX_BUILD(URX_STATE_SAVE, jmpLoc+1);
++            int32_t     jmpOp   = buildOp(URX_JMP, saveLoc);
+             fRXPat->fCompiledPat->setElementAt(jmpOp, jmpLoc);
+-            fRXPat->fCompiledPat->addElement(stateSaveOp, *fStatus);
++            appendOp(URX_STATE_SAVE, jmpLoc+1);
+         }
+         break;
+ 
+@@ -1077,9 +1029,9 @@
+ 
+             // First the STO_SP before the start of the loop
+             insertOp(topLoc);
+-            int32_t  varLoc    = fRXPat->fDataSize;    // Reserve a data location for saving the
+-            fRXPat->fDataSize += 1;                    //  state stack ptr.
+-            int32_t  op        = URX_BUILD(URX_STO_SP, varLoc);
++
++            int32_t  varLoc = allocateData(1);   // Reserve a data location for saving the
++            int32_t  op     = buildOp(URX_STO_SP, varLoc);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc);
+ 
+             int32_t loopOp = (int32_t)fRXPat->fCompiledPat->popi();
+@@ -1088,8 +1040,7 @@
+             fRXPat->fCompiledPat->push(loopOp, *fStatus);
+ 
+             // Then the LD_SP after the end of the loop
+-            op = URX_BUILD(URX_LD_SP, varLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LD_SP, varLoc);
+         }
+ 
+         break;
+@@ -1125,55 +1076,49 @@
+         // scanned a ".",  match any single character.
+         {
+             fixLiterals(FALSE);
+-            int32_t   op;
+             if (fModeFlags & UREGEX_DOTALL) {
+-                op = URX_BUILD(URX_DOTANY_ALL, 0);
++                appendOp(URX_DOTANY_ALL, 0);
+             } else if (fModeFlags & UREGEX_UNIX_LINES) {
+-                op = URX_BUILD(URX_DOTANY_UNIX, 0);
++                appendOp(URX_DOTANY_UNIX, 0);
+             } else {
+-                op = URX_BUILD(URX_DOTANY, 0);
++                appendOp(URX_DOTANY, 0);
+             }
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+         }
+         break;
+ 
+     case doCaret:
+         {
+             fixLiterals(FALSE);
+-            int32_t op = 0;
+             if (       (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
+-                op = URX_CARET;
++                appendOp(URX_CARET, 0);
+             } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
+-                op = URX_CARET_M;
++                appendOp(URX_CARET_M, 0);
+             } else if ((fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {
+-                op = URX_CARET;   // Only testing true start of input.
++                appendOp(URX_CARET, 0);   // Only testing true start of input.
+             } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {
+-                op = URX_CARET_M_UNIX;
++                appendOp(URX_CARET_M_UNIX, 0);
+             }
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);
+         }
+         break;
+ 
+     case doDollar:
+         {
+             fixLiterals(FALSE);
+-            int32_t op = 0;
+             if (       (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
+-                op = URX_DOLLAR;
++                appendOp(URX_DOLLAR, 0);
+             } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
+-                op = URX_DOLLAR_M;
++                appendOp(URX_DOLLAR_M, 0);
+             } else if ((fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {
+-                op = URX_DOLLAR_D;
++                appendOp(URX_DOLLAR_D, 0);
+             } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {
+-                op = URX_DOLLAR_MD;
++                appendOp(URX_DOLLAR_MD, 0);
+             }
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);
+         }
+         break;
+ 
+     case doBackslashA:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_CARET, 0), *fStatus);
++        appendOp(URX_CARET, 0);
+         break;
+ 
+     case doBackslashB:
+@@ -1185,7 +1130,7 @@
+             #endif
+             fixLiterals(FALSE);
+             int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(op, 1), *fStatus);
++            appendOp(op, 1);
+         }
+         break;
+ 
+@@ -1198,63 +1143,59 @@
+             #endif
+             fixLiterals(FALSE);
+             int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);
++            appendOp(op, 0);
+         }
+         break;
+ 
+     case doBackslashD:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_D, 1), *fStatus);
++        appendOp(URX_BACKSLASH_D, 1);
+         break;
+ 
+     case doBackslashd:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_D, 0), *fStatus);
++        appendOp(URX_BACKSLASH_D, 0);
+         break;
+ 
+     case doBackslashG:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_G, 0), *fStatus);
++        appendOp(URX_BACKSLASH_G, 0);
+         break;
+ 
+     case doBackslashS:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(
+-            URX_BUILD(URX_STAT_SETREF_N, URX_ISSPACE_SET), *fStatus);
++        appendOp(URX_STAT_SETREF_N, URX_ISSPACE_SET);
+         break;
+ 
+     case doBackslashs:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(
+-            URX_BUILD(URX_STATIC_SETREF, URX_ISSPACE_SET), *fStatus);
++        appendOp(URX_STATIC_SETREF, URX_ISSPACE_SET);
+         break;
+ 
+     case doBackslashW:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(
+-            URX_BUILD(URX_STAT_SETREF_N, URX_ISWORD_SET), *fStatus);
++        appendOp(URX_STAT_SETREF_N, URX_ISWORD_SET);
+         break;
+ 
+     case doBackslashw:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(
+-            URX_BUILD(URX_STATIC_SETREF, URX_ISWORD_SET), *fStatus);
++        appendOp(URX_STATIC_SETREF, URX_ISWORD_SET);
+         break;
+ 
+     case doBackslashX:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_X, 0), *fStatus);
++        appendOp(URX_BACKSLASH_X, 0);
+         break;
+ 
+ 
+     case doBackslashZ:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_DOLLAR, 0), *fStatus);
++        appendOp(URX_DOLLAR, 0);
+         break;
+ 
+     case doBackslashz:
+         fixLiterals(FALSE);
+-        fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_Z, 0), *fStatus);
++        appendOp(URX_BACKSLASH_Z, 0);
+         break;
+ 
+     case doEscapeError:
+@@ -1314,13 +1255,11 @@
+             U_ASSERT(groupNum > 0);  // Shouldn't happen.  '\0' begins an octal escape sequence,
+                                      //    and shouldn't enter this code path at all.
+             fixLiterals(FALSE);
+-            int32_t  op;
+             if (fModeFlags & UREGEX_CASE_INSENSITIVE) {
+-                op = URX_BUILD(URX_BACKREF_I, groupNum);
++                appendOp(URX_BACKREF_I, groupNum);
+             } else {
+-                op = URX_BUILD(URX_BACKREF, groupNum);
++                appendOp(URX_BACKREF, groupNum);
+             }
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+         }
+         break;
+ 
+@@ -1341,22 +1280,18 @@
+         {
+             // Emit the STO_SP
+             int32_t   topLoc = blockTopLoc(TRUE);
+-            int32_t   stoLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize++;       // Reserve the data location for storing save stack ptr.
+-            int32_t   op     = URX_BUILD(URX_STO_SP, stoLoc);
++            int32_t   stoLoc = allocateData(1);  // Reserve the data location for storing save stack ptr.
++            int32_t   op     = buildOp(URX_STO_SP, stoLoc);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc);
+ 
+             // Emit the STATE_SAVE
+-            op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+2);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+2);
+ 
+             // Emit the JMP
+-            op = URX_BUILD(URX_JMP, topLoc+1);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_JMP, topLoc+1);
+ 
+             // Emit the LD_SP
+-            op = URX_BUILD(URX_LD_SP, stoLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LD_SP, stoLoc);
+         }
+         break;
+ 
+@@ -1376,23 +1311,20 @@
+             insertOp(topLoc);
+ 
+             // emit   STO_SP     loc
+-            int32_t   stoLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize++;       // Reserve the data location for storing save stack ptr.
+-            int32_t   op     = URX_BUILD(URX_STO_SP, stoLoc);
++            int32_t   stoLoc = allocateData(1);    // Reserve the data location for storing save stack ptr.
++            int32_t   op     = buildOp(URX_STO_SP, stoLoc);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc);
+ 
+             // Emit the SAVE_STATE   5
+             int32_t L7 = fRXPat->fCompiledPat->size()+1;
+-            op = URX_BUILD(URX_STATE_SAVE, L7);
++            op = buildOp(URX_STATE_SAVE, L7);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc+1);
+ 
+             // Append the JMP operation.
+-            op = URX_BUILD(URX_JMP, topLoc+1);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_JMP, topLoc+1);
+ 
+             // Emit the LD_SP       loc
+-            op = URX_BUILD(URX_LD_SP, stoLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LD_SP, stoLoc);
+         }
+         break;
+ 
+@@ -1411,19 +1343,17 @@
+             insertOp(topLoc);
+ 
+             // Emit the STO_SP
+-            int32_t   stoLoc = fRXPat->fDataSize;
+-            fRXPat->fDataSize++;       // Reserve the data location for storing save stack ptr.
+-            int32_t   op     = URX_BUILD(URX_STO_SP, stoLoc);
++            int32_t   stoLoc = allocateData(1);   // Reserve the data location for storing save stack ptr.
++            int32_t   op     = buildOp(URX_STO_SP, stoLoc);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc);
+ 
+             // Emit the SAVE_STATE
+             int32_t   continueLoc = fRXPat->fCompiledPat->size()+1;
+-            op = URX_BUILD(URX_STATE_SAVE, continueLoc);
++            op = buildOp(URX_STATE_SAVE, continueLoc);
+             fRXPat->fCompiledPat->setElementAt(op, topLoc+1);
+ 
+             // Emit the LD_SP
+-            op = URX_BUILD(URX_LD_SP, stoLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LD_SP, stoLoc);
+         }
+         break;
+ 
+@@ -1480,8 +1410,8 @@
+         //             is an '|' alternation within the parens.
+         {
+             fixLiterals(FALSE);
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);
++            appendOp(URX_NOP, 0);
++            appendOp(URX_NOP, 0);
+ 
+             // On the Parentheses stack, start a new frame and add the postions
+             //   of the two NOPs (a normal non-capturing () frame, except for the
+@@ -1818,7 +1748,6 @@
+ //
+ //------------------------------------------------------------------------------
+ void    RegexCompile::fixLiterals(UBool split) {
+-    int32_t  op = 0;                       // An op from/for the compiled pattern.
+ 
+     // If no literal characters have been scanned but not yet had code generated
+     //   for them, nothing needs to be done.
+@@ -1857,23 +1786,23 @@
+         // Single character, emit a URX_ONECHAR op to match it.
+         if ((fModeFlags & UREGEX_CASE_INSENSITIVE) &&
+                  u_hasBinaryProperty(lastCodePoint, UCHAR_CASE_SENSITIVE)) {
+-            op = URX_BUILD(URX_ONECHAR_I, lastCodePoint);
++            appendOp(URX_ONECHAR_I, lastCodePoint);
+         } else {
+-            op = URX_BUILD(URX_ONECHAR, lastCodePoint);
++            appendOp(URX_ONECHAR, lastCodePoint);
+         }
+-        fRXPat->fCompiledPat->addElement(op, *fStatus);
+     } else {
+         // Two or more chars, emit a URX_STRING to match them.
++        if (fLiteralChars.length() > 0x00ffffff || fRXPat->fLiteralText.length() > 0x00ffffff) {
++            error(U_REGEX_PATTERN_TOO_BIG);
++        }
+         if (fModeFlags & UREGEX_CASE_INSENSITIVE) {
+-            op = URX_BUILD(URX_STRING_I, fRXPat->fLiteralText.length());
++            appendOp(URX_STRING_I, fRXPat->fLiteralText.length());
+         } else {
+             // TODO here:  add optimization to split case sensitive strings of length two
+             //             into two single char ops, for efficiency.
+-            op = URX_BUILD(URX_STRING, fRXPat->fLiteralText.length());
++            appendOp(URX_STRING, fRXPat->fLiteralText.length());
+         }
+-        fRXPat->fCompiledPat->addElement(op, *fStatus);
+-        op = URX_BUILD(URX_STRING_LEN, fLiteralChars.length());
+-        fRXPat->fCompiledPat->addElement(op, *fStatus);
++        appendOp(URX_STRING_LEN, fLiteralChars.length());
+ 
+         // Add this string into the accumulated strings of the compiled pattern.
+         fRXPat->fLiteralText.append(fLiteralChars);
+@@ -1883,8 +1812,58 @@
+ }
+ 
+ 
++int32_t RegexCompile::buildOp(int32_t type, int32_t val) {
++    if (U_FAILURE(*fStatus)) {
++        return 0;
++    }
++    if (type < 0 || type > 255) {
++        U_ASSERT(FALSE);
++        error(U_REGEX_INTERNAL_ERROR);
++        type = URX_RESERVED_OP;
++    }
++    if (val > 0x00ffffff) {
++        U_ASSERT(FALSE);
++        error(U_REGEX_INTERNAL_ERROR);
++        val = 0;
++    }
++    if (val < 0) {
++        if (!(type == URX_RESERVED_OP_N || type == URX_RESERVED_OP)) {
++            U_ASSERT(FALSE);
++            error(U_REGEX_INTERNAL_ERROR);
++            return -1;
++        }
++        if (URX_TYPE(val) != 0xff) {
++            U_ASSERT(FALSE);
++            error(U_REGEX_INTERNAL_ERROR);
++            return -1;
++        }
++        type = URX_RESERVED_OP_N;
++    }
++    return (type << 24) | val;
++}
++
+ 
++//------------------------------------------------------------------------------
++//
++//   appendOp()             Append a new instruction onto the compiled pattern
++//                          Includes error checking, limiting the size of the
++//                          pattern to lengths that can be represented in the
++//                          24 bit operand field of an instruction.
++//
++//------------------------------------------------------------------------------
++void RegexCompile::appendOp(int32_t op) {
++    if (U_FAILURE(*fStatus)) {
++        return;
++    }
++    fRXPat->fCompiledPat->addElement(op, *fStatus);
++    if ((fRXPat->fCompiledPat->size() > 0x00fffff0) && U_SUCCESS(*fStatus)) {
++        error(U_REGEX_PATTERN_TOO_BIG);
++    }
++}
+ 
++void RegexCompile::appendOp(int32_t type, int32_t val) {
++    appendOp(buildOp(type, val));
++}
+ 
+ 
+ //------------------------------------------------------------------------------
+@@ -1900,7 +1879,7 @@
+     UVector64 *code = fRXPat->fCompiledPat;
+     U_ASSERT(where>0 && where < code->size());
+ 
+-    int32_t  nop = URX_BUILD(URX_NOP, 0);
++    int32_t  nop = buildOp(URX_NOP, 0);
+     code->insertElementAt(nop, where, *fStatus);
+ 
+     // Walk through the pattern, looking for any ops with targets that
+@@ -1921,7 +1900,7 @@
+             // Target location for this opcode is after the insertion point and
+             //   needs to be incremented to adjust for the insertion.
+             opValue++;
+-            op = URX_BUILD(opType, opValue);
++            op = buildOp(opType, opValue);
+             code->setElementAt(op, loc);
+         }
+     }
+@@ -1946,6 +1925,58 @@
+ }
+ 
+ 
++//------------------------------------------------------------------------------
++//
++//   allocateData()        Allocate storage in the matcher's static data area.
++//                         Return the index for the newly allocated data.
++//                         The storage won't actually exist until we are running a match
++//                         operation, but the storage indexes are inserted into various
++//                         opcodes while compiling the pattern.
++//
++//------------------------------------------------------------------------------
++int32_t RegexCompile::allocateData(int32_t size) {
++    if (U_FAILURE(*fStatus)) {
++        return 0;
++    }
++    if (size <= 0 || size > 0x100 || fRXPat->fDataSize < 0) {
++        error(U_REGEX_INTERNAL_ERROR);
++        return 0;
++    }
++    int32_t dataIndex = fRXPat->fDataSize;
++    fRXPat->fDataSize += size;
++    if (fRXPat->fDataSize >= 0x00fffff0) {
++        error(U_REGEX_INTERNAL_ERROR);
++    }
++    return dataIndex;
++}
++
++
++//------------------------------------------------------------------------------
++//
++//   allocateStackData()   Allocate space in the back-tracking stack frame.
++//                         Return the index for the newly allocated data.
++//                         The frame indexes are inserted into various
++//                         opcodes while compiling the pattern, meaning that frame
++//                         size must be restricted to the size that will fit
++//                         as an operand (24 bits).
++//
++//------------------------------------------------------------------------------
++int32_t RegexCompile::allocateStackData(int32_t size) {
++    if (U_FAILURE(*fStatus)) {
++        return 0;
++    }
++    if (size <= 0 || size > 0x100 || fRXPat->fFrameSize < 0) {
++        error(U_REGEX_INTERNAL_ERROR);
++        return 0;
++    }
++    int32_t dataIndex = fRXPat->fFrameSize;
++    fRXPat->fFrameSize += size;
++    if (fRXPat->fFrameSize >= 0x00fffff0) {
++        error(U_REGEX_PATTERN_TOO_BIG);
++    }
++    return dataIndex;
++}
++
+ 
+ //------------------------------------------------------------------------------
+ //
+@@ -1988,7 +2019,7 @@
+             theLoc--;
+         }
+         if (reserveLoc) {
+-            int32_t  nop = URX_BUILD(URX_NOP, 0);
++            int32_t  nop = buildOp(URX_NOP, 0);
+             fRXPat->fCompiledPat->insertElementAt(nop, theLoc, *fStatus);
+         }
+     }
+@@ -2063,8 +2094,7 @@
+             U_ASSERT(URX_TYPE(captureOp) == URX_START_CAPTURE);
+ 
+             int32_t   frameVarLocation = URX_VAL(captureOp);
+-            int32_t   endCaptureOp = URX_BUILD(URX_END_CAPTURE, frameVarLocation);
+-            fRXPat->fCompiledPat->addElement(endCaptureOp, *fStatus);
++            appendOp(URX_END_CAPTURE, frameVarLocation);
+         }
+         break;
+     case atomic:
+@@ -2075,8 +2105,7 @@
+             int32_t   stoOp = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen+1);
+             U_ASSERT(URX_TYPE(stoOp) == URX_STO_SP);
+             int32_t   stoLoc = URX_VAL(stoOp);
+-            int32_t   ldOp   = URX_BUILD(URX_LD_SP, stoLoc);
+-            fRXPat->fCompiledPat->addElement(ldOp, *fStatus);
++            appendOp(URX_LD_SP, stoLoc);
+         }
+         break;
+ 
+@@ -2085,8 +2114,7 @@
+             int32_t  startOp = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen-5);
+             U_ASSERT(URX_TYPE(startOp) == URX_LA_START);
+             int32_t dataLoc  = URX_VAL(startOp);
+-            int32_t op       = URX_BUILD(URX_LA_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LA_END, dataLoc);
+         }
+         break;
+ 
+@@ -2096,19 +2124,16 @@
+             int32_t  startOp = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen-1);
+             U_ASSERT(URX_TYPE(startOp) == URX_LA_START);
+             int32_t dataLoc  = URX_VAL(startOp);
+-            int32_t op       = URX_BUILD(URX_LA_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            op               = URX_BUILD(URX_BACKTRACK, 0);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-            op               = URX_BUILD(URX_LA_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LA_END, dataLoc);
++            appendOp(URX_BACKTRACK, 0);
++            appendOp(URX_LA_END, dataLoc);
+ 
+             // Patch the URX_SAVE near the top of the block.
+             // The destination of the SAVE is the final LA_END that was just added.
+             int32_t saveOp   = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen);
+             U_ASSERT(URX_TYPE(saveOp) == URX_STATE_SAVE);
+             int32_t dest     = fRXPat->fCompiledPat->size()-1;
+-            saveOp           = URX_BUILD(URX_STATE_SAVE, dest);
++            saveOp           = buildOp(URX_STATE_SAVE, dest);
+             fRXPat->fCompiledPat->setElementAt(saveOp, fMatchOpenParen);
+         }
+         break;
+@@ -2121,10 +2146,8 @@
+             int32_t  startOp = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen-4);
+             U_ASSERT(URX_TYPE(startOp) == URX_LB_START);
+             int32_t dataLoc  = URX_VAL(startOp);
+-            int32_t op       = URX_BUILD(URX_LB_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
+-                    op       = URX_BUILD(URX_LA_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LB_END, dataLoc);
++            appendOp(URX_LA_END, dataLoc);
+ 
+             // Determine the min and max bounds for the length of the
+             //  string that the pattern can match.
+@@ -2160,8 +2183,7 @@
+             int32_t  startOp = (int32_t)fRXPat->fCompiledPat->elementAti(fMatchOpenParen-5);
+             U_ASSERT(URX_TYPE(startOp) == URX_LB_START);
+             int32_t dataLoc  = URX_VAL(startOp);
+-            int32_t op       = URX_BUILD(URX_LBN_END, dataLoc);
+-            fRXPat->fCompiledPat->addElement(op, *fStatus);
++            appendOp(URX_LBN_END, dataLoc);
+ 
+             // Determine the min and max bounds for the length of the
+             //  string that the pattern can match.
+@@ -2186,7 +2208,7 @@
+ 
+             // Insert the pattern location to continue at after a successful match
+             //  as the last operand of the URX_LBN_CONT
+-            op = URX_BUILD(URX_RELOC_OPRND, fRXPat->fCompiledPat->size());
++            int32_t op = buildOp(URX_RELOC_OPRND, fRXPat->fCompiledPat->size());
+             fRXPat->fCompiledPat->setElementAt(op,  fMatchOpenParen-1);
+         }
+         break;
+@@ -2227,7 +2249,7 @@
+     case 0:
+         {
+             // Set of no elements.   Always fails to match.
+-            fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKTRACK, 0), *fStatus);
++            appendOp(URX_BACKTRACK, 0);
+             delete theSet;
+         }
+         break;
+@@ -2248,8 +2270,7 @@
+             //  Put it into the compiled pattern as a set.
+             int32_t setNumber = fRXPat->fSets->size();
+             fRXPat->fSets->addElement(theSet, *fStatus);
+-            int32_t setOp = URX_BUILD(URX_SETREF, setNumber);
+-            fRXPat->fCompiledPat->addElement(setOp, *fStatus);
++            appendOp(URX_SETREF, setNumber);
+         }
+     }
+ }
+@@ -2288,13 +2309,10 @@
+     //        counterLoc   -->  Loop counter
+     //               +1    -->  Input index (for breaking non-progressing loops)
+     //                          (Only present if unbounded upper limit on loop)
+-    int32_t   counterLoc = fRXPat->fFrameSize;
+-    fRXPat->fFrameSize++;
+-    if (fIntervalUpper < 0) {
+-        fRXPat->fFrameSize++;
+-    }
++    int32_t   dataSize = fIntervalUpper < 0 ? 2 : 1;
++    int32_t   counterLoc = allocateStackData(dataSize);
+ 
+-    int32_t   op = URX_BUILD(InitOp, counterLoc);
++    int32_t   op = buildOp(InitOp, counterLoc);
+     fRXPat->fCompiledPat->setElementAt(op, topOfBlock);
+ 
+     // The second operand of CTR_INIT is the location following the end of the loop.
+@@ -2302,7 +2320,7 @@
+     //   compilation of something later on causes the code to grow and the target
+     //   position to move.
+     int32_t loopEnd = fRXPat->fCompiledPat->size();
+-    op = URX_BUILD(URX_RELOC_OPRND, loopEnd);
++    op = buildOp(URX_RELOC_OPRND, loopEnd);
+     fRXPat->fCompiledPat->setElementAt(op, topOfBlock+1);
+ 
+     // Followed by the min and max counts.
+@@ -2311,8 +2329,7 @@
+ 
+     // Apend the CTR_LOOP op.  The operand is the location of the CTR_INIT op.
+     //   Goes at end of the block being looped over, so just append to the code so far.
+-    op = URX_BUILD(LoopOp, topOfBlock);
+-    fRXPat->fCompiledPat->addElement(op, *fStatus);
++    appendOp(LoopOp, topOfBlock);
+ 
+     if ((fIntervalLow & 0xff000000) != 0 ||
+         (fIntervalUpper > 0 && (fIntervalUpper & 0xff000000) != 0)) {
+@@ -2365,7 +2382,7 @@
+     //
+     int32_t endOfSequenceLoc = fRXPat->fCompiledPat->size()-1
+                                 + fIntervalUpper + (fIntervalUpper-fIntervalLow);
+-    int32_t saveOp = URX_BUILD(URX_STATE_SAVE, endOfSequenceLoc);
++    int32_t saveOp = buildOp(URX_STATE_SAVE, endOfSequenceLoc);
+     if (fIntervalLow == 0) {
+         insertOp(topOfBlock);
+         fRXPat->fCompiledPat->setElementAt(saveOp, topOfBlock);
+@@ -2378,13 +2395,10 @@
+     //    it was put there when it was originally encountered.
+     int32_t i;
+     for (i=1; i<fIntervalUpper; i++ ) {
+-        if (i == fIntervalLow) {
+-            fRXPat->fCompiledPat->addElement(saveOp, *fStatus);
+-        }
+-        if (i > fIntervalLow) {
+-            fRXPat->fCompiledPat->addElement(saveOp, *fStatus);
++        if (i >= fIntervalLow) {
++            appendOp(saveOp);
+         }
+-        fRXPat->fCompiledPat->addElement(op, *fStatus);
++        appendOp(op);
+     }
+     return TRUE;
+ }
+@@ -3603,7 +3617,7 @@
+                 int32_t  operandAddress = URX_VAL(op);
+                 U_ASSERT(operandAddress>=0 && operandAddress<deltas.size());
+                 int32_t fixedOperandAddress = operandAddress - deltas.elementAti(operandAddress);
+-                op = URX_BUILD(opType, fixedOperandAddress);
++                op = buildOp(opType, fixedOperandAddress);
+                 fRXPat->fCompiledPat->setElementAt(op, dst);
+                 dst++;
+                 break;
+@@ -3618,7 +3632,7 @@
+                     break;
+                 }
+                 where = fRXPat->fGroupMap->elementAti(where-1);
+-                op    = URX_BUILD(opType, where);
++                op    = buildOp(opType, where);
+                 fRXPat->fCompiledPat->setElementAt(op, dst);
+                 dst++;
+ 
+@@ -3970,7 +3984,7 @@
+ //------------------------------------------------------------------------------
+ //
+ //  scanNamedChar
+- //            Get a UChar32 from a \N{UNICODE CHARACTER NAME} in the pattern.
++//            Get a UChar32 from a \N{UNICODE CHARACTER NAME} in the pattern.
+ //
+ //             The scan position will be at the 'N'.  On return
+ //             the scan position should be just after the '}'
+diff -ru icu/source/i18n/regexcmp.h icu/source/i18n/regexcmp.h
+--- icu/source/i18n/regexcmp.h	2015-04-10 15:27:31.370772856 +0200
++++ icu/source/i18n/regexcmp.h	2015-04-10 15:28:06.152993511 +0200
+@@ -104,6 +104,13 @@
+     void        fixLiterals(UBool split=FALSE);      // Generate code for pending literal characters.
+     void        insertOp(int32_t where);             // Open up a slot for a new op in the
+                                                      //   generated code at the specified location.
++    void        appendOp(int32_t op);                // Append a new op to the compiled pattern.
++    void        appendOp(int32_t type, int32_t val); // Build & append a new op to the compiled pattern.
++    int32_t     buildOp(int32_t type, int32_t val);  // Construct a new pcode instruction.
++    int32_t     allocateData(int32_t size);          // Allocate space in the matcher data area.
++                                                     //   Return index of the newly allocated data.
++    int32_t     allocateStackData(int32_t size);     // Allocate space in the match back-track stack frame.
++                                                     //   Return offset index in the frame.
+     int32_t     minMatchLength(int32_t start,
+                                int32_t end);
+     int32_t     maxMatchLength(int32_t start,
+diff -ru icu/source/i18n/regeximp.h icu/source/i18n/regeximp.h
+--- icu/source/i18n/regeximp.h	2014-10-03 18:10:44.000000000 +0200
++++ icu/source/i18n/regeximp.h	2015-04-10 15:28:06.153993517 +0200
+@@ -1,5 +1,5 @@
+ //
+-//   Copyright (C) 2002-2013 International Business Machines Corporation
++//   Copyright (C) 2002-2014 International Business Machines Corporation
+ //   and others. All rights reserved.
+ //
+ //   file:  regeximp.h
+@@ -241,7 +241,6 @@
+ //
+ //  Convenience macros for assembling and disassembling a compiled operation.
+ //
+-#define URX_BUILD(type, val) (int32_t)((type << 24) | (val))
+ #define URX_TYPE(x)          ((uint32_t)(x) >> 24)
+ #define URX_VAL(x)           ((x) & 0xffffff)
+ 
+diff -ru icu/source/test/intltest/regextst.cpp icu/source/test/intltest/regextst.cpp
+--- icu/source/test/intltest/regextst.cpp	2014-10-03 18:09:44.000000000 +0200
++++ icu/source/test/intltest/regextst.cpp	2015-04-10 15:28:06.154993523 +0200
+@@ -144,6 +144,9 @@
+         case 24: name = "TestBug11049";
+             if (exec) TestBug11049();
+             break;
++        case 25: name = "TestBug11371";
++            if (exec) TestBug11371();
++            break;
+         default: name = "";
+             break; //needed to end loop
+     }
+@@ -5367,6 +5370,49 @@
+ }
+ 
+ 
++void RegexTest::TestBug11371() {
++    if (quick) {
++        logln("Skipping test. Runs in exhuastive mode only.");
++        return;
++    }
++    UErrorCode status = U_ZERO_ERROR;
++    UnicodeString patternString;
++
++    for (int i=0; i<8000000; i++) {
++        patternString.append(UnicodeString("()"));
++    }
++    LocalPointer<RegexPattern> compiledPat(RegexPattern::compile(patternString, 0, status));
++    if (status != U_REGEX_PATTERN_TOO_BIG) {
++        errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
++              __FILE__, __LINE__, u_errorName(status));
++    }
++
++    status = U_ZERO_ERROR;
++    patternString = "(";
++    for (int i=0; i<20000000; i++) {
++        patternString.append(UnicodeString("A++"));
++    }
++    patternString.append(UnicodeString("){0}B++"));
++    LocalPointer<RegexPattern> compiledPat2(RegexPattern::compile(patternString, 0, status));
++    if (status != U_REGEX_PATTERN_TOO_BIG) {
++        errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
++              __FILE__, __LINE__, u_errorName(status));
++    }
++
++    // Pattern with too much string data, such that string indexes overflow operand data field size
++    // in compiled instruction.
++    status = U_ZERO_ERROR;
++    patternString = "";
++    while (patternString.length() < 0x00ffffff) {
++        patternString.append(UnicodeString("stuff and things dont you know, these are a few of my favorite strings\n"));
++    }
++    patternString.append(UnicodeString("X? trailing string"));
++    LocalPointer<RegexPattern> compiledPat3(RegexPattern::compile(patternString, 0, status));
++    if (status != U_REGEX_PATTERN_TOO_BIG) {
++        errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
++              __FILE__, __LINE__, u_errorName(status));
++    }
++}
+ 
+ #endif  /* !UCONFIG_NO_REGULAR_EXPRESSIONS  */
+ 
+diff -ru icu/source/test/intltest/regextst.h icu/source/test/intltest/regextst.h
+--- icu/source/test/intltest/regextst.h	2014-10-03 18:09:40.000000000 +0200
++++ icu/source/test/intltest/regextst.h	2015-04-10 15:28:06.154993523 +0200
+@@ -50,6 +50,7 @@
+     virtual void Bug10459();
+     virtual void TestCaseInsensitiveStarters();
+     virtual void TestBug11049();
++    virtual void TestBug11371();
+     
+     // The following functions are internal to the regexp tests.
+     virtual void assertUText(const char *expected, UText *actual, const char *file, int line);
diff --git a/external/icu/icu4c-changeset-39671.patch.1 b/external/icu/icu4c-changeset-39671.patch.1
deleted file mode 100644
index b8ac1385364e..000000000000
--- a/external/icu/icu4c-changeset-39671.patch.1
+++ /dev/null
@@ -1,189 +0,0 @@
-diff -ur icu.org/source/common/utext.cpp icu/source/common/utext.cpp
---- icu.org/source/common/utext.cpp	2016-06-15 20:58:17.000000000 +0200
-+++ icu/source/common/utext.cpp	2017-04-21 16:38:15.993398034 +0200
-@@ -847,9 +847,15 @@
- //------------------------------------------------------------------------------
- 
- // Chunk size.
--//     Must be less than 85, because of byte mapping from UChar indexes to native indexes.
--//     Worst case is three native bytes to one UChar.  (Supplemenaries are 4 native bytes
--//     to two UChars.)
-+//     Must be less than 42  (256/6), because of byte mapping from UChar indexes to native indexes.
-+//     Worst case there are six UTF-8 bytes per UChar.
-+//         obsolete 6 byte form fd + 5 trails maps to fffd
-+//         obsolete 5 byte form fc + 4 trails maps to fffd
-+//         non-shortest 4 byte forms maps to fffd
-+//         normal supplementaries map to a pair of utf-16, two utf8 bytes per utf-16 unit
-+//     mapToUChars array size must allow for the worst case, 6.
-+//     This could be brought down to 4, by treating fd and fc as pure illegal,
-+//     rather than obsolete lead bytes. But that is not compatible with the utf-8 access macros.
- //
- enum { UTF8_TEXT_CHUNK_SIZE=32 };
- 
-@@ -867,6 +873,15 @@
- //     pair.  Doing this is simpler than checking for the edge case.
- //
- 
-+// erAck: older MSVC used on libreoffice-5-3 and 5-2 bails out with
-+// error C2070: 'unknown': illegal sizeof operand
-+// for sizeof(UTF8Buf::mapToUChars)
-+// so have an ugly workaround:
-+// First define a macro of the original size expression, so a follow-up patch
-+// on the original code would fail..
-+#define UGLY_MAPTOUCHARS_SIZE (UTF8_TEXT_CHUNK_SIZE*6+6)
-+#define UGLY_SIZEOF_MAPTOUCHARS (sizeof(uint8_t)*(UGLY_MAPTOUCHARS_SIZE))
-+
- struct UTF8Buf {
-     int32_t   bufNativeStart;                        // Native index of first char in UChar buf
-     int32_t   bufNativeLimit;                        // Native index following last char in buf.
-@@ -889,7 +904,7 @@
-                                                      //  Requires two extra slots,
-                                                      //    one for a supplementary starting in the last normal position,
-                                                      //    and one for an entry for the buffer limit position.
--    uint8_t   mapToUChars[UTF8_TEXT_CHUNK_SIZE*3+6]; // Map native offset from bufNativeStart to
-+    uint8_t   mapToUChars[UGLY_MAPTOUCHARS_SIZE];    // Map native offset from bufNativeStart to
-                                                      //   correspoding offset in filled part of buf.
-     int32_t   align;
- };
-@@ -1032,6 +1047,7 @@
-             // Requested index is in this buffer.
-             u8b = (UTF8Buf *)ut->p;   // the current buffer
-             mapIndex = ix - u8b->toUCharsMapStart;
-+            U_ASSERT(mapIndex < (int32_t)UGLY_SIZEOF_MAPTOUCHARS);
-             ut->chunkOffset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
-             return TRUE;
- 
-@@ -1298,6 +1314,10 @@
-         // Can only do this if the incoming index is somewhere in the interior of the string.
-         //   If index is at the end, there is no character there to look at.
-         if (ix != ut->b) {
-+            // Note: this function will only move the index back if it is on a trail byte
-+            //       and there is a preceding lead byte and the sequence from the lead 
-+            //       through this trail could be part of a valid UTF-8 sequence
-+            //       Otherwise the index remains unchanged.
-             U8_SET_CP_START(s8, 0, ix);
-         }
- 
-@@ -1311,7 +1331,10 @@
-         UChar   *buf = u8b->buf;
-         uint8_t *mapToNative = u8b->mapToNative;
-         uint8_t *mapToUChars = u8b->mapToUChars;
--        int32_t  toUCharsMapStart = ix - (UTF8_TEXT_CHUNK_SIZE*3 + 1);
-+        int32_t  toUCharsMapStart = ix - UGLY_SIZEOF_MAPTOUCHARS + 1;
-+        // Note that toUCharsMapStart can be negative. Happens when the remaining
-+        // text from current position to the beginning is less than the buffer size.
-+        // + 1 because mapToUChars must have a slot at the end for the bufNativeLimit entry.
-         int32_t  destIx = UTF8_TEXT_CHUNK_SIZE+2;   // Start in the overflow region
-                                                     //   at end of buffer to leave room
-                                                     //   for a surrogate pair at the
-@@ -1338,6 +1361,7 @@
-             if (c<0x80) {
-                 // Special case ASCII range for speed.
-                 buf[destIx] = (UChar)c;
-+                U_ASSERT(toUCharsMapStart <= srcIx);
-                 mapToUChars[srcIx - toUCharsMapStart] = (uint8_t)destIx;
-                 mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart);
-             } else {
-@@ -1367,6 +1391,7 @@
-                 do {
-                     mapToUChars[sIx-- - toUCharsMapStart] = (uint8_t)destIx;
-                 } while (sIx >= srcIx);
-+                U_ASSERT(toUCharsMapStart <= (srcIx+1));
- 
-                 // Set native indexing limit to be the current position.
-                 //   We are processing a non-ascii, non-native-indexing char now;
-@@ -1541,6 +1566,7 @@
-     U_ASSERT(index>=ut->chunkNativeStart+ut->nativeIndexingLimit);
-     U_ASSERT(index<=ut->chunkNativeLimit);
-     int32_t mapIndex = index - u8b->toUCharsMapStart;
-+    U_ASSERT(mapIndex < (int32_t)UGLY_SIZEOF_MAPTOUCHARS);
-     int32_t offset = u8b->mapToUChars[mapIndex] - u8b->bufStartIdx;
-     U_ASSERT(offset>=0 && offset<=ut->chunkLength);
-     return offset;
-diff -ur icu.org/source/test/intltest/utxttest.cpp icu/source/test/intltest/utxttest.cpp
---- icu.org/source/test/intltest/utxttest.cpp	2016-06-15 20:58:17.000000000 +0200
-+++ icu/source/test/intltest/utxttest.cpp	2017-04-21 16:14:57.383814739 +0200
-@@ -67,6 +67,8 @@
-             if (exec) Ticket10983();  break;
-         case 7: name = "Ticket12130";
-             if (exec) Ticket12130(); break;
-+        case 8: name = "Ticket12888";
-+            if (exec) Ticket12888(); break;
-         default: name = "";          break;
-     }
- }
-@@ -1583,3 +1585,63 @@
-     }
-     utext_close(&ut);
- }
-+
-+// Ticket 12888: bad handling of illegal utf-8 containing many instances of the archaic, now illegal,
-+//               six byte utf-8 forms. Original implementation had an assumption that
-+//               there would be at most three utf-8 bytes per UTF-16 code unit.
-+//               The five and six byte sequences map to a single replacement character.
-+
-+void UTextTest::Ticket12888() {
-+    const char *badString = 
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80"
-+            "\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80\xfd\x80\x80\x80\x80\x80";
-+
-+    UErrorCode status = U_ZERO_ERROR;
-+    LocalUTextPointer ut(utext_openUTF8(NULL, badString, -1, &status));
-+    TEST_SUCCESS(status);
-+    for (;;) {
-+        UChar32 c = utext_next32(ut.getAlias());
-+        if (c == U_SENTINEL) {
-+            break;
-+        }
-+    }
-+    int32_t endIdx = utext_getNativeIndex(ut.getAlias());
-+    if (endIdx != (int32_t)strlen(badString)) {
-+        errln("%s:%d expected=%d, actual=%d", __FILE__, __LINE__, strlen(badString), endIdx);
-+        return;
-+    }
-+
-+    for (int32_t prevIndex = endIdx; prevIndex>0;) {
-+        UChar32 c = utext_previous32(ut.getAlias());
-+        int32_t currentIndex = utext_getNativeIndex(ut.getAlias());
-+        if (c != 0xfffd) {
-+            errln("%s:%d (expected, actual, index) = (%d, %d, %d)\n",
-+                    __FILE__, __LINE__, 0xfffd, c, currentIndex);
-+            break;
-+        }
-+        if (currentIndex != prevIndex - 6) {
-+            errln("%s:%d: wrong index. Expected, actual = %d, %d",
-+                    __FILE__, __LINE__, prevIndex - 6, currentIndex);
-+            break;
-+        }
-+        prevIndex = currentIndex;
-+    }
-+}
-diff -ur icu.org/source/test/intltest/utxttest.h icu/source/test/intltest/utxttest.h
---- icu.org/source/test/intltest/utxttest.h	2016-06-15 20:58:17.000000000 +0200
-+++ icu/source/test/intltest/utxttest.h	2017-04-21 16:14:57.383814739 +0200
-@@ -38,6 +38,7 @@
-     void Ticket10562();
-     void Ticket10983();
-     void Ticket12130();
-+    void Ticket12888();
- 
- private:
-     struct m {                              // Map between native indices & code points.
diff --git a/external/icu/icu4c-emscripten.patch.1 b/external/icu/icu4c-emscripten.patch.1
deleted file mode 100644
index 3ce6d527b5cd..000000000000
--- a/external/icu/icu4c-emscripten.patch.1
+++ /dev/null
@@ -1,116 +0,0 @@
---- icu.org/source/config/mh-unknown	2015-10-06 11:35:03.212459286 +0200
-+++ icu/source/config/mh-unknown	2015-10-06 12:01:00.497972406 +0200
-@@ -1,27 +1,90 @@
- ## -*-makefile-*-
--## Copyright (c) 2003, International Business Machines Corporation and
-+## Emscripten-specific setup
-+## Copyright (c) 1999-2013, International Business Machines Corporation and
- ## others. All Rights Reserved.
--##
- 
--# Note, this is not a real mh- file. You got here because configure
--# (specifically, aclocal.m4) could not determine a suitable mh- file.
--#
--# Perhaps your platform wasn't detected- try changing aclocal.m4 and
--# re-running autoconf. 
--#
--# If your platform is truly new/different:
--# As a start, try copying mh-linux (which is fairly generic) over this
--# file, and re-run config.status.
--
--%.$(STATIC_O) %.o %.$(STATIC_O) %.o ../data/%.o %.d %.d %.$(SO).$(SO_TARGET_VERSION_MAJOR) %.$(SO):
--	@echo 
--	@echo 
--	@echo "*** ERROR - configure could not detect your platform"
--	@echo "*** see the readme.html"
--	@echo "*** or, try copying icu/source/config/mh-linux to mh-unknown"
--	@echo "***   and editing it."
--	@echo 
--	@echo 
--	exit 1
-+## Commands to generate dependency files
-+GEN_DEPS.c=  $(CC) -E -MM $(DEFS) $(CPPFLAGS)
-+GEN_DEPS.cc= $(CXX) -E -MM $(DEFS) $(CPPFLAGS) $(CXXFLAGS)
- 
-+## Flags for position independent code
-+SHAREDLIBCFLAGS = -fPIC
-+SHAREDLIBCXXFLAGS = -fPIC
-+SHAREDLIBCPPFLAGS = -DPIC
- 
-+## Additional flags when building libraries and with threads
-+THREADSCPPFLAGS = -D_REENTRANT
-+LIBCPPFLAGS =
-+
-+## Compiler switch to embed a runtime search path
-+LD_RPATH= -Wl,-zorigin,-rpath,'$$'ORIGIN
-+LD_RPATH_PRE = -Wl,-rpath,
-+
-+## Force RPATH=$ORIGIN to locate own dependencies w/o need for LD_LIBRARY_PATH:
-+ENABLE_RPATH=YES
-+RPATHLDFLAGS=${LD_RPATH_PRE}'$$ORIGIN'
-+
-+## These are the library specific LDFLAGS
-+#LDFLAGSICUDT=-nodefaultlibs -nostdlib
-+# Debian change: linking icudata as data only causes too many problems.
-+LDFLAGSICUDT=
-+
-+## Compiler switch to embed a library name
-+# The initial tab in the next line is to prevent icu-config from reading it.
-+	LD_SONAME = -Wl,-soname -Wl,$(notdir $(MIDDLE_SO_TARGET))
-+#SH# # We can't depend on MIDDLE_SO_TARGET being set.
-+#SH# LD_SONAME=
-+
-+## Shared library options
-+LD_SOOPTIONS= -Wl,-Bsymbolic-functions
-+
-+## Shared object suffix
-+SO = so
-+## Non-shared intermediate object suffix
-+STATIC_O = ao
-+
-+## Compilation rules
-+%.$(STATIC_O): $(srcdir)/%.c
-+	$(call SILENT_COMPILE,$(strip $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS)) -o $@ $<)
-+%.o: $(srcdir)/%.c
-+	$(call SILENT_COMPILE,$(strip $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS)) -o $@ $<)
-+
-+%.$(STATIC_O): $(srcdir)/%.cpp
-+	$(call SILENT_COMPILE,$(strip $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS)) -o $@ $<)
-+%.o: $(srcdir)/%.cpp
-+	$(call SILENT_COMPILE,$(strip $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS)) -o $@ $<)
-+
-+
-+## Dependency rules
-+%.d: $(srcdir)/%.c
-+	$(call ICU_MSG,(deps)) $<
-+	@$(SHELL) -ec '$(GEN_DEPS.c) $< \
-+		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
-+		[ -s $@ ] || rm -f $@'
-+
-+%.d: $(srcdir)/%.cpp
-+	$(call ICU_MSG,(deps)) $<
-+	@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
-+		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
-+		[ -s $@ ] || rm -f $@'
-+
-+## Versioned libraries rules
-+
-+%.$(SO).$(SO_TARGET_VERSION_MAJOR): %.$(SO).$(SO_TARGET_VERSION)
-+	$(RM) $@ && ln -s ${<F} $@
-+%.$(SO): %.$(SO).$(SO_TARGET_VERSION_MAJOR)
-+	$(RM) $@ && ln -s ${*F}.$(SO).$(SO_TARGET_VERSION) $@
-+
-+##  Bind internal references
-+
-+# LDflags that pkgdata will use
-+BIR_LDFLAGS= -Wl,-Bsymbolic
-+
-+# Dependencies [i.e. map files] for the final library
-+BIR_DEPS=
-+
-+## Remove shared library 's'
-+STATIC_PREFIX_WHEN_USED =
-+STATIC_PREFIX =
-+
-+## End Linux-specific setup
-
diff --git a/external/icu/icu4c-icu11451.patch.1 b/external/icu/icu4c-icu11451.patch.1
new file mode 100644
index 000000000000..b15185a4dbb0
--- /dev/null
+++ b/external/icu/icu4c-icu11451.patch.1
@@ -0,0 +1,11 @@
+--- icu/source/common/ubidi.c.orig	2014-12-19 10:23:38.103928414 +0000
++++ icu/source/common/ubidi.c	2014-12-19 10:26:58.370071527 +0000
+@@ -2146,7 +2146,7 @@
+     /* The isolates[] entries contain enough information to
+        resume the bidi algorithm in the same state as it was
+        when it was interrupted by an isolate sequence. */
+-    if(dirProps[start]==PDI) {
++    if(dirProps[start]==PDI && pBiDi->isolateCount >= 0) {
+         levState.startON=pBiDi->isolates[pBiDi->isolateCount].startON;
+         start1=pBiDi->isolates[pBiDi->isolateCount].start1;
+         stateImp=pBiDi->isolates[pBiDi->isolateCount].stateImp;
diff --git a/external/icu/khmerbreakengine.patch b/external/icu/khmerbreakengine.patch
deleted file mode 100644
index 8f81f315da3e..000000000000
--- a/external/icu/khmerbreakengine.patch
+++ /dev/null
@@ -1,1110 +0,0 @@
-diff --git a/source/common/dictbe.cpp b/source/common/dictbe.cpp
-index f1c874d..3ad1b3f 100644
---- misc/icu/source/common/dictbe.cpp
-+++ build/icu/source/common/dictbe.cpp
-@@ -27,8 +27,17 @@ U_NAMESPACE_BEGIN
-  ******************************************************************
-  */
- 
--DictionaryBreakEngine::DictionaryBreakEngine(uint32_t breakTypes) {
-+DictionaryBreakEngine::DictionaryBreakEngine(uint32_t breakTypes) :
-+    clusterLimit(3)
-+{
-+    UErrorCode status = U_ZERO_ERROR;
-     fTypes = breakTypes;
-+    fViramaSet.applyPattern(UNICODE_STRING_SIMPLE("[[:ccc=VR:]]"), status);
-+
-+    // note Skip Sets contain fIgnoreSet characters too.

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list