add dev-lang/php-5.6.40
[portage-squeep] / dev-lang / php / files / php-5.6-intl-use-icu-namespace.patch
1 Based on the following upstream commits:
2
3 https://github.com/php/php-src/commit/8d35a423838eb462cd39ee535c5d003073cc5f22
4 https://github.com/php/php-src/commit/d8200e48857aeaf09f7127751efc5632ef7660a7
5 https://github.com/php/php-src/commit/9a8e7b571896f39f83cb000fdb7c466b6d328d52
6
7 --- a/ext/intl/breakiterator/breakiterator_class.cpp
8 +++ b/ext/intl/breakiterator/breakiterator_class.cpp
9 @@ -38,6 +38,7 @@ extern "C" {
10 }
11
12 using PHP::CodePointBreakIterator;
13 +using icu::RuleBasedBreakIterator;
14
15 /* {{{ Global variables */
16 zend_class_entry *BreakIterator_ce_ptr;
17 --- a/ext/intl/breakiterator/breakiterator_class.h
18 +++ b/ext/intl/breakiterator/breakiterator_class.h
19 @@ -26,6 +26,8 @@
20
21 #ifndef USE_BREAKITERATOR_POINTER
22 typedef void BreakIterator;
23 +#else
24 +using icu::BreakIterator;
25 #endif
26
27 typedef struct {
28 --- a/ext/intl/breakiterator/breakiterator_methods.cpp
29 +++ b/ext/intl/breakiterator/breakiterator_methods.cpp
30 @@ -32,6 +32,8 @@ extern "C" {
31 }
32
33 using PHP::CodePointBreakIterator;
34 +using icu::BreakIterator;
35 +using icu::Locale;
36
37 U_CFUNC PHP_METHOD(BreakIterator, __construct)
38 {
39 --- a/ext/intl/breakiterator/codepointiterator_internal.cpp
40 +++ b/ext/intl/breakiterator/codepointiterator_internal.cpp
41 @@ -31,6 +31,8 @@ typedef union {
42
43 using namespace PHP;
44
45 +using icu::UCharCharacterIterator;
46 +
47 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CodePointBreakIterator);
48
49 CodePointBreakIterator::CodePointBreakIterator()
50 --- a/ext/intl/breakiterator/codepointiterator_internal.h
51 +++ b/ext/intl/breakiterator/codepointiterator_internal.h
52 @@ -18,8 +18,11 @@
53 #define CODEPOINTITERATOR_INTERNAL_H
54
55 #include <unicode/brkiter.h>
56 +#include <unicode/unistr.h>
57
58 -using U_ICU_NAMESPACE::BreakIterator;
59 +using icu::BreakIterator;
60 +using icu::CharacterIterator;
61 +using icu::UnicodeString;
62
63 namespace PHP {
64
65 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
66 +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
67 @@ -25,6 +25,9 @@ extern "C" {
68
69 #include "../intl_convertcpp.h"
70
71 +using icu::RuleBasedBreakIterator;
72 +using icu::Locale;
73 +
74 static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) {
75 return (RuleBasedBreakIterator*)bio->biter;
76 }
77 --- a/ext/intl/calendar/calendar_class.cpp
78 +++ b/ext/intl/calendar/calendar_class.cpp
79 @@ -34,6 +34,9 @@ extern "C" {
80 #include <assert.h>
81 }
82
83 +using icu::GregorianCalendar;
84 +using icu::Locale;
85 +
86 /* {{{ Global variables */
87 zend_class_entry *Calendar_ce_ptr;
88 zend_class_entry *GregorianCalendar_ce_ptr;
89 --- a/ext/intl/calendar/calendar_class.h
90 +++ b/ext/intl/calendar/calendar_class.h
91 @@ -26,6 +26,8 @@
92
93 #ifndef USE_CALENDAR_POINTER
94 typedef void Calendar;
95 +#else
96 +using icu::Calendar;
97 #endif
98
99 typedef struct {
100 --- a/ext/intl/calendar/calendar_methods.cpp
101 +++ b/ext/intl/calendar/calendar_methods.cpp
102 @@ -40,6 +40,8 @@ extern "C" {
103 }
104 #include "../common/common_enum.h"
105
106 +using icu::Locale;
107 +
108 U_CFUNC PHP_METHOD(IntlCalendar, __construct)
109 {
110 zend_throw_exception( NULL,
111 --- a/ext/intl/calendar/gregoriancalendar_methods.cpp
112 +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
113 @@ -23,6 +23,8 @@
114 #include <unicode/locid.h>
115 #include <unicode/calendar.h>
116 #include <unicode/gregocal.h>
117 +#include <unicode/ustring.h>
118 +
119 extern "C" {
120 #include "../php_intl.h"
121 #define USE_TIMEZONE_POINTER 1
122 @@ -32,6 +34,11 @@ extern "C" {
123 #include <ext/date/php_date.h>
124 }
125
126 +using icu::GregorianCalendar;
127 +using icu::Locale;
128 +using icu::UnicodeString;
129 +using icu::StringPiece;
130 +
131 static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
132 return (GregorianCalendar*)co->ucal;
133 }
134 --- a/ext/intl/common/common_date.cpp
135 +++ b/ext/intl/common/common_date.cpp
136 @@ -25,6 +25,9 @@ extern "C" {
137 #include <ext/date/php_date.h>
138 }
139
140 +using icu::TimeZone;
141 +using icu::UnicodeString;
142 +
143 #ifndef INFINITY
144 #define INFINITY (DBL_MAX+DBL_MAX)
145 #endif
146 --- a/ext/intl/common/common_date.h
147 +++ b/ext/intl/common/common_date.h
148 @@ -28,6 +28,8 @@ U_CDECL_END
149
150 #include <unicode/timezone.h>
151
152 +using icu::TimeZone;
153 +
154 U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func TSRMLS_DC);
155 U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
156 intl_error *err, const char *func TSRMLS_DC);
157 --- a/ext/intl/common/common_enum.h
158 +++ b/ext/intl/common/common_enum.h
159 @@ -69,6 +69,7 @@ U_CFUNC void zoi_with_current_get_current_data(zend_object_iterator *iter, zval
160 U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC);
161
162 #ifdef __cplusplus
163 +using icu::StringEnumeration;
164 U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC);
165 #endif
166
167 --- a/ext/intl/converter/converter.c
168 +++ b/ext/intl/converter/converter.c
169 @@ -18,6 +18,8 @@
170 #include "zend_exceptions.h"
171
172 #include <unicode/utypes.h>
173 +#include <unicode/utf8.h>
174 +#include <unicode/utf16.h>
175 #include <unicode/ucnv.h>
176 #include <unicode/ustring.h>
177
178 --- a/ext/intl/dateformat/dateformat_format_object.cpp
179 +++ b/ext/intl/dateformat/dateformat_format_object.cpp
180 @@ -33,6 +33,12 @@ extern "C" {
181 #include "../common/common_date.h"
182 }
183
184 +using icu::Locale;
185 +using icu::DateFormat;
186 +using icu::GregorianCalendar;
187 +using icu::StringPiece;
188 +using icu::SimpleDateFormat;
189 +
190 static const DateFormat::EStyle valid_styles[] = {
191 DateFormat::kNone,
192 DateFormat::kFull,
193 --- a/ext/intl/dateformat/dateformat_helpers.cpp
194 +++ b/ext/intl/dateformat/dateformat_helpers.cpp
195 @@ -28,6 +28,8 @@ extern "C" {
196 #include "../calendar/calendar_class.h"
197 }
198
199 +using icu::GregorianCalendar;
200 +
201 int datefmt_process_calendar_arg(zval* calendar_zv,
202 Locale const& locale,
203 const char *func_name,
204 --- a/ext/intl/dateformat/dateformat_helpers.h
205 +++ b/ext/intl/dateformat/dateformat_helpers.h
206 @@ -22,11 +22,16 @@
207 #endif
208
209 #include <unicode/calendar.h>
210 +#include <unicode/datefmt.h>
211
212 extern "C" {
213 #include "../php_intl.h"
214 }
215
216 +using icu::Locale;
217 +using icu::Calendar;
218 +using icu::DateFormat;
219 +
220 int datefmt_process_calendar_arg(zval* calendar_zv,
221 Locale const& locale,
222 const char *func_name,
223 --- a/ext/intl/grapheme/grapheme_string.c
224 +++ b/ext/intl/grapheme/grapheme_string.c
225 @@ -24,6 +24,7 @@
226 #include "grapheme_util.h"
227
228 #include <unicode/utypes.h>
229 +#include <unicode/utf8.h>
230 #include <unicode/ucol.h>
231 #include <unicode/ustring.h>
232 #include <unicode/ubrk.h>
233 @@ -860,10 +861,10 @@ PHP_FUNCTION(grapheme_extract)
234 pstr = str + start;
235
236 /* just in case pstr points in the middle of a character, move forward to the start of the next char */
237 - if ( !UTF8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
238 + if ( !U8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
239 unsigned char *str_end = str + str_len;
240
241 - while ( !UTF8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
242 + while ( !U8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
243 pstr++;
244 if ( pstr >= str_end ) {
245 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
246 --- a/ext/intl/intl_convertcpp.h
247 +++ b/ext/intl/intl_convertcpp.h
248 @@ -25,6 +25,8 @@
249
250 #include <unicode/unistr.h>
251
252 +using icu::UnicodeString;
253 +
254 int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status);
255
256 int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status);
257 --- a/ext/intl/msgformat/msgformat_helpers.cpp
258 +++ b/ext/intl/msgformat/msgformat_helpers.cpp
259 @@ -76,6 +76,16 @@ MessageFormatAdapter::getMessagePattern(MessageFormat* m) {
260 #endif
261 U_NAMESPACE_END
262
263 +using icu::Formattable;
264 +using icu::Format;
265 +using icu::DateFormat;
266 +using icu::MessageFormat;
267 +#ifdef HAS_MESSAGE_PATTERN
268 +using icu::MessagePattern;
269 +#endif
270 +using icu::MessageFormatAdapter;
271 +using icu::FieldPosition;
272 +
273 U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt)
274 {
275 int32_t fmt_count = 0;
276 @@ -227,15 +237,16 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
277 UnicodeString typeString = mp.getSubstring(type_part);
278 /* This is all based on the rules in the docs for MessageFormat
279 * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */
280 - if (typeString == "number") {
281 +#define ASCII_LITERAL(s) UNICODE_STRING(s, sizeof(s)-1)
282 + if (typeString == ASCII_LITERAL("number")) {
283 MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */
284 if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) {
285 UnicodeString styleString = mp.getSubstring(style_part);
286 - if (styleString == "integer") {
287 + if (styleString == ASCII_LITERAL("integer")) {
288 type = Formattable::kInt64;
289 - } else if (styleString == "currency") {
290 + } else if (styleString == ASCII_LITERAL("currency")) {
291 type = Formattable::kDouble;
292 - } else if (styleString == "percent") {
293 + } else if (styleString == ASCII_LITERAL("percent")) {
294 type = Formattable::kDouble;
295 } else { /* some style invalid/unknown to us */
296 type = Formattable::kDouble;
297 @@ -243,12 +254,13 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
298 } else { // if missing style, part, make it a double
299 type = Formattable::kDouble;
300 }
301 - } else if ((typeString == "date") || (typeString == "time")) {
302 + } else if ((typeString == ASCII_LITERAL("date")) || (typeString == ASCII_LITERAL("time"))) {
303 type = Formattable::kDate;
304 - } else if ((typeString == "spellout") || (typeString == "ordinal")
305 - || (typeString == "duration")) {
306 + } else if ((typeString == ASCII_LITERAL("spellout")) || (typeString == ASCII_LITERAL("ordinal"))
307 + || (typeString == ASCII_LITERAL("duration"))) {
308 type = Formattable::kDouble;
309 }
310 +#undef ASCII_LITERAL
311 } else {
312 /* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a
313 * UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern
314 --- a/ext/intl/normalizer/normalizer_normalize.c
315 +++ b/ext/intl/normalizer/normalizer_normalize.c
316 @@ -24,6 +24,7 @@
317 #include "normalizer_class.h"
318 #include "normalizer_normalize.h"
319 #include "intl_convert.h"
320 +#include <unicode/utf8.h>
321
322 /* {{{ proto string Normalizer::normalize( string $input [, string $form = FORM_C] )
323 * Normalize a string. }}} */
324 --- a/ext/intl/timezone/timezone_class.cpp
325 +++ b/ext/intl/timezone/timezone_class.cpp
326 @@ -37,6 +37,8 @@ extern "C" {
327 #include <ext/date/php_date.h>
328 }
329
330 +using icu::Calendar;
331 +
332 /* {{{ Global variables */
333 U_CDECL_BEGIN
334 zend_class_entry *TimeZone_ce_ptr = NULL;
335 --- a/ext/intl/timezone/timezone_class.h
336 +++ b/ext/intl/timezone/timezone_class.h
337 @@ -29,6 +29,8 @@
338
339 #ifndef USE_TIMEZONE_POINTER
340 typedef void TimeZone;
341 +#else
342 +using icu::TimeZone;
343 #endif
344
345 typedef struct {
346 --- a/ext/intl/timezone/timezone_methods.cpp
347 +++ b/ext/intl/timezone/timezone_methods.cpp
348 @@ -23,6 +23,7 @@
349 #include <unicode/locid.h>
350 #include <unicode/timezone.h>
351 #include <unicode/ustring.h>
352 +#include <unicode/calendar.h>
353 #include "intl_convertcpp.h"
354
355 #include "../common/common_date.h"
356 @@ -37,6 +38,9 @@ extern "C" {
357 }
358 #include "common/common_enum.h"
359
360 +using icu::Locale;
361 +using icu::Calendar;
362 +
363 U_CFUNC PHP_METHOD(IntlTimeZone, __construct)
364 {
365 zend_throw_exception( NULL,