Copy the remaining icu46 patches to preserve the history
BUG=132145
TEST=NONE
Review URL: https://codereview.chromium.org/224133003
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/icu52@261498 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/patches/breakiterator.patch b/patches/breakiterator.patch
new file mode 100644
index 0000000..59ad7d8
--- /dev/null
+++ b/patches/breakiterator.patch
@@ -0,0 +1,140 @@
+Index: README.chromium
+diff --git a/README.chromium b/README.chromium
+index 76acd4b06530827413286a72fed86771147c88d8..7e85c4949f1b52bbbda26e2d90b49852aaff7563 100644
+--- a/README.chromium
++++ b/README.chromium
+@@ -255,5 +255,5 @@ This directory contains the source code of ICU 4.6 for C/C++
+ - patches/csetdet.patch
+ - upstream bug: http://bugs.icu-project.org/trac/ticket/10318
+
+-
+-
++26. Add BreakIterator::getRuleStatus
++ - Copy and paste BreakIterator::getRuleStatus API from icu 52
+Index: patches/breakiterator.patch
+diff --git a/patches/breakiterator.patch b/patches/breakiterator.patch
+new file mode 100644
+index 0000000000000000000000000000000000000000..f1b36a34d0b408940a9c528fa0c796e2db6cb457
+--- /dev/null
++++ b/patches/breakiterator.patch
+@@ -0,0 +1,74 @@
++From c795f7766bd4f650a2396c834bc2a07768781ae8 Mon Sep 17 00:00:00 2001
++From: Igor Oliveira <igor.o@sisa.samsung.com>
++Date: Tue, 17 Sep 2013 14:43:07 -0700
++Subject: [PATCH] The CL https://codereview.chromium.org/23618052/ depends of
++ an API that will be added by libicu 5.2,
++ BreakIterator::getRuleStatus. This patch is just a copy and
++ paste of the libicu 5.2 API into chromium libicu.
++
++---
++ README.chromium | 3 +++
++ source/common/brkiter.cpp | 7 +++++++
++ source/common/unicode/brkiter.h | 15 +++++++++++++++
++ 3 files changed, 25 insertions(+)
++
++diff --git a/README.chromium b/README.chromium
++index 76acd4b..eaf2e81 100644
++--- a/README.chromium
+++++ b/README.chromium
++@@ -255,5 +255,8 @@ This directory contains the source code of ICU 4.6 for C/C++
++ - patches/csetdet.patch
++ - upstream bug: http://bugs.icu-project.org/trac/ticket/10318
++
+++26. Add BreakIterator::getRuleStatus
+++ - Copy and paste BreakIterator::getRuleStatus API from icu 5.2
+++
++
++
++diff --git a/source/common/brkiter.cpp b/source/common/brkiter.cpp
++index 26f7b6a..41da826 100644
++--- a/source/common/brkiter.cpp
+++++ b/source/common/brkiter.cpp
++@@ -436,6 +436,13 @@ BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
++ return locBased.getLocaleID(type, status);
++ }
++
+++// This implementation of getRuleStatus is a do-nothing stub, here to
+++// provide a default implementation for any derived BreakIterator classes that
+++// do not implement it themselves.
+++int32_t BreakIterator::getRuleStatus() const {
+++ return 0;
+++}
+++
++ U_NAMESPACE_END
++
++ #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
++diff --git a/source/common/unicode/brkiter.h b/source/common/unicode/brkiter.h
++index bdd3cc7..1800336 100644
++--- a/source/common/unicode/brkiter.h
+++++ b/source/common/unicode/brkiter.h
++@@ -284,6 +284,21 @@ public:
++ virtual int32_t next(int32_t n) = 0;
++
++ /**
+++ * For RuleBasedBreakIterators, return the status tag from the
+++ * break rule that determined the most recently
+++ * returned break position.
+++ * <p>
+++ * For break iterator types that do not support a rule status,
+++ * a default value of 0 is returned.
+++ * <p>
+++ * @return the status from the break rule that determined the most recently
+++ * returned break position.
+++ * @see RuleBaseBreakIterator::getRuleStatus()
+++ * @see UWordBreak
+++ */
+++ virtual int32_t getRuleStatus() const;
+++
+++ /**
++ * Create BreakIterator for word-breaks using the given locale.
++ * Returns an instance of a BreakIterator implementing word breaks.
++ * WordBreak is useful for word selection (ex. double click)
++--
++1.7.12.4 (Apple Git-37)
++
+Index: source/common/brkiter.cpp
+diff --git a/source/common/brkiter.cpp b/source/common/brkiter.cpp
+index 26f7b6a82e8b8981dce42a08d8fca6a2a42e81cc..41da826748370ad5caff57191e8c0f2f0da12c3e 100644
+--- a/source/common/brkiter.cpp
++++ b/source/common/brkiter.cpp
+@@ -436,6 +436,13 @@ BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
+ return locBased.getLocaleID(type, status);
+ }
+
++// This implementation of getRuleStatus is a do-nothing stub, here to
++// provide a default implementation for any derived BreakIterator classes that
++// do not implement it themselves.
++int32_t BreakIterator::getRuleStatus() const {
++ return 0;
++}
++
+ U_NAMESPACE_END
+
+ #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+Index: source/common/unicode/brkiter.h
+diff --git a/source/common/unicode/brkiter.h b/source/common/unicode/brkiter.h
+index bdd3cc700f46e62e56f1fa84bfe0a6dcf18406da..180033661b12fa135782f23a6fa72ff8efb07878 100644
+--- a/source/common/unicode/brkiter.h
++++ b/source/common/unicode/brkiter.h
+@@ -284,6 +284,21 @@ public:
+ virtual int32_t next(int32_t n) = 0;
+
+ /**
++ * For RuleBasedBreakIterators, return the status tag from the
++ * break rule that determined the most recently
++ * returned break position.
++ * <p>
++ * For break iterator types that do not support a rule status,
++ * a default value of 0 is returned.
++ * <p>
++ * @return the status from the break rule that determined the most recently
++ * returned break position.
++ * @see RuleBaseBreakIterator::getRuleStatus()
++ * @see UWordBreak
++ */
++ virtual int32_t getRuleStatus() const;
++
++ /**
+ * Create BreakIterator for word-breaks using the given locale.
+ * Returns an instance of a BreakIterator implementing word breaks.
+ * WordBreak is useful for word selection (ex. double click)
diff --git a/patches/csetdet.patch b/patches/csetdet.patch
new file mode 100644
index 0000000..73df253
--- /dev/null
+++ b/patches/csetdet.patch
@@ -0,0 +1,35 @@
+Index: source/i18n/csrucode.cpp
+===================================================================
+--- source/i18n/csrucode.cpp (revision 214189)
++++ source/i18n/csrucode.cpp (working copy)
+@@ -31,8 +31,9 @@
+ int32_t CharsetRecog_UTF_16_BE::match(InputText* textIn)
+ {
+ const uint8_t *input = textIn->fRawInput;
++ int32_t length = textIn->fRawLength;
+
+- if (input[0] == 0xFE && input[1] == 0xFF) {
++ if (length >=2 && input[0] == 0xFE && input[1] == 0xFF) {
+ return 100;
+ }
+
+@@ -53,8 +54,9 @@
+ int32_t CharsetRecog_UTF_16_LE::match(InputText* textIn)
+ {
+ const uint8_t *input = textIn->fRawInput;
++ int32_t length = textIn->fRawLength;
+
+- if (input[0] == 0xFF && input[1] == 0xFE && (input[2] != 0x00 || input[3] != 0x00)) {
++ if (length >= 4 && input[0] == 0xFF && input[1] == 0xFE && (input[2] != 0x00 || input[3] != 0x00)) {
+ return 100;
+ }
+
+@@ -76,7 +78,7 @@
+ bool hasBOM = FALSE;
+ int32_t confidence = 0;
+
+- if (getChar(input, 0) == 0x0000FEFFUL) {
++ if (limit > 0 && getChar(input, 0) == 0x0000FEFFUL) {
+ hasBOM = TRUE;
+ }
+
diff --git a/patches/declspec.patch b/patches/declspec.patch
new file mode 100644
index 0000000..a0ad086
--- /dev/null
+++ b/patches/declspec.patch
@@ -0,0 +1,13 @@
+Index: source/common/unicode/utypes.h
+===================================================================
+--- source/common/unicode/utypes.h (revision 241384)
++++ source/common/unicode/utypes.h (working copy)
+@@ -448,7 +448,7 @@
+ #define U_IO_API
+ #define U_TOOLUTIL_API
+ #elif defined(U_COMMON_IMPLEMENTATION)
+-#define U_DATA_API U_IMPORT
++#define U_DATA_API U_EXPORT
+ #define U_COMMON_API U_EXPORT
+ #define U_I18N_API U_IMPORT
+ #define U_LAYOUT_API U_IMPORT
diff --git a/patches/platform.qnx.patch b/patches/platform.qnx.patch
new file mode 100644
index 0000000..5542472
--- /dev/null
+++ b/patches/platform.qnx.patch
@@ -0,0 +1,113 @@
+--- source/common/unicode/pqnx.h 2014-01-23 14:52:38.889798542 -0800
++++ source/common/unicode/pqnx.h 2014-03-18 11:24:27.335797876 -0700
+@@ -24,8 +24,8 @@
+ #define _PLATFORM_H
+
+ /**
+- * \file
+- * \brief Basic types for the platform
++ * \file
++ * \brief Basic types for the platform
+ */
+
+ /* This file should be included before uvernum.h. */
+@@ -34,7 +34,7 @@
+ #endif
+
+ /**
+- * Determine wheter to enable auto cleanup of libraries.
++ * Determine wheter to enable auto cleanup of libraries.
+ * @internal
+ */
+ #ifndef UCLN_NO_AUTO_CLEANUP
+@@ -45,13 +45,13 @@
+ #ifndef CYGWINMSVC
+
+ /** Define the platform we're on. */
+-#ifndef U_LINUX
+-#define U_LINUX
++#ifndef U_QNX
++#define U_QNX
+ #endif
+
+ /**
+ * \def U_HAVE_DIRENT_H
+- * Define whether dirent.h is available
++ * Define whether dirent.h is available
+ * @internal
+ */
+ #ifndef U_HAVE_DIRENT_H
+@@ -147,7 +147,7 @@
+ #endif
+
+ /* 1 or 0 to enable or disable threads. If undefined, default is: enable threads. */
+-#ifndef ICU_USE_THREADS
++#ifndef ICU_USE_THREADS
+ #define ICU_USE_THREADS 1
+ #endif
+
+@@ -272,7 +272,7 @@
+ /*===========================================================================*/
+
+ #ifndef U_HAVE_NL_LANGINFO_CODESET
+-#define U_HAVE_NL_LANGINFO_CODESET 1
++#define U_HAVE_NL_LANGINFO_CODESET 0
+ #endif
+
+ #ifndef U_NL_LANGINFO_CODESET
+@@ -282,8 +282,8 @@
+ #if 1
+ #define U_TZSET tzset
+ #endif
+-#if !defined(__UCLIBC__)
+-#define U_TIMEZONE __timezone
++#if 1
++#define U_TIMEZONE timezone
+ #endif
+ #if 1
+ #define U_TZNAME tzname
+@@ -303,7 +303,7 @@
+ #elif 1
+ #define U_EXPORT __attribute__((visibility("default")))
+ #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
+- || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
++ || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
+ #define U_EXPORT __global
+ /*#elif defined(__HP_aCC) || defined(__HP_cc)
+ #define U_EXPORT __declspec(dllexport)*/
+@@ -318,7 +318,7 @@
+ #if defined(U_CYGWIN) && !defined(__GNUC__)
+ #define U_IMPORT __declspec(dllimport)
+ #else
+-#define U_IMPORT
++#define U_IMPORT
+ #endif
+
+ /* @} */
+@@ -336,7 +336,7 @@
+ #endif
+
+ #ifndef U_ALIGN_CODE
+-#define U_ALIGN_CODE(n)
++#define U_ALIGN_CODE(n)
+ #endif
+
+ /** @} */
+@@ -379,7 +379,7 @@
+ * Define the library suffix with C syntax.
+ * @internal
+ */
+-# define U_LIB_SUFFIX_C_NAME
++# define U_LIB_SUFFIX_C_NAME
+ /**
+ * Define the library suffix as a string with C syntax
+ * @internal
+@@ -394,7 +394,7 @@
+ #if U_HAVE_LIB_SUFFIX
+ # ifndef U_ICU_ENTRY_POINT_RENAME
+ /* Renaming pattern: u_strcpy_41_suffix */
+-# define U_ICU_ENTRY_POINT_RENAME(x) x ## _ ## 46 ##
++# define U_ICU_ENTRY_POINT_RENAME(x) x ## _ ## 46 ##
+ # define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt####major##minor##_dat
+
+ # endif
diff --git a/patches/pnacl.h.patch b/patches/pnacl.h.patch
new file mode 100644
index 0000000..0d96c0f
--- /dev/null
+++ b/patches/pnacl.h.patch
@@ -0,0 +1,14 @@
+--- a/source/common/unicode/pnacl.h
++++ b/source/common/unicode/pnacl.h
+@@ -282,8 +282,10 @@
+ #if 1
+ #define U_TZSET tzset
+ #endif
+-#if 1
++#if defined(__GLIBC__)
+ #define U_TIMEZONE __timezone
++#else
++#define U_TIMEZONE _timezone
+ #endif
+ #if 1
+ #define U_TZNAME tzname
diff --git a/patches/si_value.undef.patch b/patches/si_value.undef.patch
new file mode 100644
index 0000000..988872a
--- /dev/null
+++ b/patches/si_value.undef.patch
@@ -0,0 +1,14 @@
+--- source/common/ucnvmbcs.c
++++ source/common/ucnvmbcs.c
+@@ -56,6 +56,11 @@
+ #include "cmemory.h"
+ #include "cstring.h"
+
++/* si_value is defined as a macro in some POSIX implementations' standard headers. */
++#ifdef si_value
++#undef si_value
++#endif
++
+ /* control optimizations according to the platform */
+ #define MBCS_UNROLL_SINGLE_TO_BMP 1
+ #define MBCS_UNROLL_SINGLE_FROM_BMP 0
diff --git a/patches/ubrk.patch b/patches/ubrk.patch
new file mode 100644
index 0000000..51213fd
--- /dev/null
+++ b/patches/ubrk.patch
@@ -0,0 +1,32 @@
+Index: source/common/ubrk.cpp
+===================================================================
+--- source/common/ubrk.cpp (revision 120256)
++++ source/common/ubrk.cpp (working copy)
+@@ -166,6 +166,13 @@
+ int32_t textLength,
+ UErrorCode* status)
+ {
++ if (bi == NULL) {
++ if (U_SUCCESS(*status)) {
++ *status = U_ILLEGAL_ARGUMENT_ERROR;
++ }
++ return;
++ }
++
+ BreakIterator *brit = (BreakIterator *)bi;
+ UText ut = UTEXT_INITIALIZER;
+ utext_openUChars(&ut, text, textLength, status);
+@@ -181,6 +188,13 @@
+ UText *text,
+ UErrorCode *status)
+ {
++ if (bi == NULL) {
++ if (U_SUCCESS(*status)) {
++ *status = U_ILLEGAL_ARGUMENT_ERROR;
++ }
++ return;
++ }
++
+ RuleBasedBreakIterator *brit = (RuleBasedBreakIterator *)bi;
+ brit->RuleBasedBreakIterator::setText(text, *status);
+ }
diff --git a/patches/utext.patch b/patches/utext.patch
new file mode 100644
index 0000000..d92347f
--- /dev/null
+++ b/patches/utext.patch
@@ -0,0 +1,76 @@
+Index: test/cintltst/utexttst.c
+===================================================================
+--- test/cintltst/utexttst.c (revision 29355)
++++ test/cintltst/utexttst.c (revision 29356)
+@@ -1,6 +1,6 @@
+ /********************************************************************
+ * COPYRIGHT:
+- * Copyright (c) 2005-2009, International Business Machines Corporation and
++ * Copyright (c) 2005-2011, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ ********************************************************************/
+ /*
+@@ -210,6 +210,10 @@
+ UChar uString[] = {0x41, 0x42, 0x43, 0};
+ UChar buf[100];
+ int32_t i;
++ /* Test pinning of input bounds */
++ UChar uString2[] = {0x41, 0x42, 0x43, 0x44, 0x45,
++ 0x46, 0x47, 0x48, 0x49, 0x4A, 0};
++ UChar * uString2Ptr = uString2 + 5;
+
+ status = U_ZERO_ERROR;
+ uta = utext_openUChars(NULL, uString, -1, &status);
+@@ -228,6 +232,20 @@
+ i = u_strcmp(uString, buf);
+ TEST_ASSERT(i == 0);
+ utext_close(uta);
++
++ /* Test pinning of input bounds */
++ status = U_ZERO_ERROR;
++ uta = utext_openUChars(NULL, uString2Ptr, -1, &status);
++ TEST_SUCCESS(status);
++
++ status = U_ZERO_ERROR;
++ memset(buf, 0, sizeof(buf));
++ i = utext_extract(uta, -3, 20, buf, 100, &status);
++ TEST_SUCCESS(status);
++ TEST_ASSERT(i == u_strlen(uString2Ptr));
++ i = u_strcmp(uString2Ptr, buf);
++ TEST_ASSERT(i == 0);
++ utext_close(uta);
+ }
+
+ {
+Index: common/utext.cpp
+===================================================================
+--- common/utext.cpp (revision 29355)
++++ common/utext.cpp (revision 29356)
+@@ -1,7 +1,7 @@
+ /*
+ *******************************************************************************
+ *
+-* Copyright (C) 2005-2010, International Business Machines
++* Copyright (C) 2005-2011, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ *******************************************************************************
+@@ -2846,7 +2846,6 @@
+ return 0;
+ }
+
+- const UChar *s=(const UChar *)ut->context;
+ int32_t si, di;
+
+ int32_t start32;
+@@ -2856,8 +2855,8 @@
+ // Pins 'start' to the length of the string, if it came in out-of-bounds.
+ // Snaps 'start' to the beginning of a code point.
+ ucstrTextAccess(ut, start, TRUE);
+- U_ASSERT(start <= INT32_MAX);
+- start32 = (int32_t)start;
++ const UChar *s=ut->chunkContents;
++ start32 = ut->chunkOffset;
+
+ int32_t strLength=(int32_t)ut->a;
+ if (strLength >= 0) {
diff --git a/patches/vs2012.patch b/patches/vs2012.patch
new file mode 100644
index 0000000..e5a58e8
--- /dev/null
+++ b/patches/vs2012.patch
@@ -0,0 +1,29 @@
+Index: source/common/stringpiece.cpp
+===================================================================
+--- source/common/stringpiece.cpp (revision 158118)
++++ source/common/stringpiece.cpp (working copy)
+@@ -75,7 +75,7 @@
+ * Visual Studios 9.0.
+ * Cygwin with MSVC 9.0 also complains here about redefinition.
+ */
+-#if (!defined(_MSC_VER) || (_MSC_VER > 1600)) && !defined(CYGWINMSVC)
++#if (!defined(_MSC_VER) || (_MSC_VER > 1800)) && !defined(CYGWINMSVC)
+ const int32_t StringPiece::npos;
+ #endif
+
+Index: source/common/unicode/pwin32.h
+===================================================================
+--- source/common/unicode/pwin32.h (revision 158118)
++++ source/common/unicode/pwin32.h (working copy)
+@@ -26,6 +26,10 @@
+ #define U_WINDOWS
+ #endif
+
++#if _MSC_VER >= 1600
++#include <stdint.h>
++#endif
++
+ #if defined(__BORLANDC__)
+ #define U_HAVE_PLACEMENT_NEW 0
+ #define __STDC_CONSTANT_MACROS
+
diff --git a/patches/xopen_source.patch b/patches/xopen_source.patch
new file mode 100644
index 0000000..964951c
--- /dev/null
+++ b/patches/xopen_source.patch
@@ -0,0 +1,28 @@
+--- source/common/putil.c
++++ source/common/putil.c
+@@ -37,15 +37,17 @@
+ ******************************************************************************
+ */
+
+-/* Define _XOPEN_SOURCE for Solaris and friends. */
+-/* NetBSD needs it to be >= 4 */
+-#if !defined(_XOPEN_SOURCE)
+-#if __STDC_VERSION__ >= 199901L
+-/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 on Solaris */
+-#define _XOPEN_SOURCE 600
++/* Define _XOPEN_SOURCE for access to POSIX functions. */
++#ifdef _XOPEN_SOURCE
++ /* Use the predefined value. */
+ #else
+-#define _XOPEN_SOURCE 4
+-#endif
++ /*
++ * Version 6.0:
++ * The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
++ * also known as
++ * SUSv3 = Open Group Single UNIX Specification, Version 3 (UNIX03)
++ */
++# define _XOPEN_SOURCE 600
+ #endif
+
+ /* Make sure things like readlink and such functions work.