add dev-lang/php-5.6.40
[portage-squeep] / dev-lang / php / files / php-7.2.13-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 @@ -33,6 +33,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 @@ -26,6 +26,9 @@ extern "C" {
68 #include "../intl_convertcpp.h"
69 #include "../intl_common.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 #include "../intl_common.h"
122 @@ -34,6 +36,11 @@ extern "C" {
123 #include "zend_exceptions.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 @@ -27,6 +27,9 @@ extern "C" {
137
138 #include "zend_portability.h"
139
140 +using icu::TimeZone;
141 +using icu::UnicodeString;
142 +
143 /* {{{ timezone_convert_datetimezone
144 * The timezone in DateTime and DateTimeZone is not unified. */
145 U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
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);
155 U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
156 intl_error *err, const char *func);
157 --- a/ext/intl/common/common_enum.h
158 +++ b/ext/intl/common/common_enum.h
159 @@ -75,6 +75,7 @@ U_CFUNC zval *zoi_with_current_get_current_data(zend_object_iterator *iter);
160 U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter);
161
162 #ifdef __cplusplus
163 +using icu::StringEnumeration;
164 U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object);
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 @@ -834,10 +835,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 - char *str_end = str + str_len;
239 + if ( !U8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
240 + unsigned char *str_end = str + str_len;
241
242 - while ( !UTF8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
243 + while ( !U8_IS_SINGLE(*pstr) && !U8_IS_LEAD(*pstr) ) {
244 pstr++;
245 if ( pstr >= str_end ) {
246 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
247 --- a/ext/intl/intl_convertcpp.h
248 +++ b/ext/intl/intl_convertcpp.h
249 @@ -26,6 +26,8 @@
250 #include <unicode/unistr.h>
251 #include <zend_types.h>
252
253 +using icu::UnicodeString;
254 +
255 int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
256
257 zend_string* intl_charFromString(const UnicodeString &from, UErrorCode *status);
258 --- a/ext/intl/msgformat/msgformat_helpers.cpp
259 +++ b/ext/intl/msgformat/msgformat_helpers.cpp
260 @@ -78,6 +78,16 @@ MessageFormatAdapter::getMessagePattern(MessageFormat* m) {
261 #endif
262 U_NAMESPACE_END
263
264 +using icu::Formattable;
265 +using icu::Format;
266 +using icu::DateFormat;
267 +using icu::MessageFormat;
268 +#ifdef HAS_MESSAGE_PATTERN
269 +using icu::MessagePattern;
270 +#endif
271 +using icu::MessageFormatAdapter;
272 +using icu::FieldPosition;
273 +
274 U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt)
275 {
276 int32_t fmt_count = 0;
277 @@ -229,15 +239,16 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
278 UnicodeString typeString = mp.getSubstring(type_part);
279 /* This is all based on the rules in the docs for MessageFormat
280 * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */
281 - if (typeString == "number") {
282 +#define ASCII_LITERAL(s) UNICODE_STRING(s, sizeof(s)-1)
283 + if (typeString == ASCII_LITERAL("number")) {
284 MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */
285 if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) {
286 UnicodeString styleString = mp.getSubstring(style_part);
287 - if (styleString == "integer") {
288 + if (styleString == ASCII_LITERAL("integer")) {
289 type = Formattable::kInt64;
290 - } else if (styleString == "currency") {
291 + } else if (styleString == ASCII_LITERAL("currency")) {
292 type = Formattable::kDouble;
293 - } else if (styleString == "percent") {
294 + } else if (styleString == ASCII_LITERAL("percent")) {
295 type = Formattable::kDouble;
296 } else { /* some style invalid/unknown to us */
297 type = Formattable::kDouble;
298 @@ -245,12 +256,13 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
299 } else { // if missing style, part, make it a double
300 type = Formattable::kDouble;
301 }
302 - } else if ((typeString == "date") || (typeString == "time")) {
303 + } else if ((typeString == ASCII_LITERAL("date")) || (typeString == ASCII_LITERAL("time"))) {
304 type = Formattable::kDate;
305 - } else if ((typeString == "spellout") || (typeString == "ordinal")
306 - || (typeString == "duration")) {
307 + } else if ((typeString == ASCII_LITERAL("spellout")) || (typeString == ASCII_LITERAL("ordinal"))
308 + || (typeString == ASCII_LITERAL("duration"))) {
309 type = Formattable::kDouble;
310 }
311 +#undef ASCII_LITERAL
312 } else {
313 /* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a
314 * UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern
315 --- a/ext/intl/normalizer/normalizer_normalize.c
316 +++ b/ext/intl/normalizer/normalizer_normalize.c
317 @@ -24,6 +24,7 @@
318 #include "normalizer_class.h"
319 #include "normalizer_normalize.h"
320 #include "intl_convert.h"
321 +#include <unicode/utf8.h>
322
323 /* {{{ proto string Normalizer::normalize( string $input [, string $form = FORM_C] )
324 * Normalize a string. }}} */
325 --- a/ext/intl/timezone/timezone_class.cpp
326 +++ b/ext/intl/timezone/timezone_class.cpp
327 @@ -37,6 +37,8 @@ extern "C" {
328 #include <ext/date/php_date.h>
329 }
330
331 +using icu::Calendar;
332 +
333 /* {{{ Global variables */
334 U_CDECL_BEGIN
335 zend_class_entry *TimeZone_ce_ptr = NULL;
336 --- a/ext/intl/timezone/timezone_class.h
337 +++ b/ext/intl/timezone/timezone_class.h
338 @@ -29,6 +29,8 @@
339
340 #ifndef USE_TIMEZONE_POINTER
341 typedef void TimeZone;
342 +#else
343 +using icu::TimeZone;
344 #endif
345
346 typedef struct {
347 --- a/ext/intl/timezone/timezone_methods.cpp
348 +++ b/ext/intl/timezone/timezone_methods.cpp
349 @@ -23,6 +23,7 @@
350 #include <unicode/locid.h>
351 #include <unicode/timezone.h>
352 #include <unicode/ustring.h>
353 +#include <unicode/calendar.h>
354 #include "intl_convertcpp.h"
355
356 #include "../common/common_date.h"
357 @@ -37,6 +38,9 @@ extern "C" {
358 }
359 #include "common/common_enum.h"
360
361 +using icu::Locale;
362 +using icu::Calendar;
363 +
364 U_CFUNC PHP_METHOD(IntlTimeZone, __construct)
365 {
366 zend_throw_exception( NULL,
367 --- a/ext/intl/uchar/uchar.c
368 +++ b/ext/intl/uchar/uchar.c
369 @@ -3,6 +3,7 @@
370 #include "intl_convert.h"
371
372 #include <unicode/uchar.h>
373 +#include <unicode/utf8.h>
374
375 #define IC_METHOD(mname) PHP_METHOD(IntlChar, mname)
376
377 --
378 2.19.2
379