Skip to content

Commit 83542dc

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
By Gustavo André dos Santos Lopes (4) and others via Felipe Pena (1) and Xinchen Hui (1) * PHP-5.3: Remove unused codes based on microsoft's description,the direct convert from FILETIME struct to __int64 is unsafe. Fix ext/intl build on ICU < 4.8 Optimization in ext/intl/msgformat Fixed tests in ext/intl Changed XFAILed collator_get_sort_key.phpt
2 parents e118a07 + 6ecc9f1 commit 83542dc

11 files changed

+79
-245
lines changed

Diff for: ext/intl/msgformat/msgformat.c

+2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
6464
locale = INTL_G(default_locale);
6565
}
6666

67+
#ifdef MSG_FORMAT_QUOTE_APOS
6768
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
6869
INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
6970
}
71+
#endif
7072

7173
if ((mfo)->mf_data.orig_format) {
7274
msgformat_data_free(&mfo->mf_data TSRMLS_CC);

Diff for: ext/intl/msgformat/msgformat_attr.c

+2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ PHP_FUNCTION( msgfmt_set_pattern )
8282
intl_convert_utf8_to_utf16(&spattern, &spattern_len, value, value_len, &INTL_DATA_ERROR_CODE(mfo));
8383
INTL_METHOD_CHECK_STATUS(mfo, "Error converting pattern to UTF-16" );
8484

85+
#ifdef MSG_FORMAT_QUOTE_APOS
8586
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
8687
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
8788
"msgfmt_set_pattern: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
8889
RETURN_FALSE;
8990
}
91+
#endif
9092

9193
/* TODO: add parse error information */
9294
umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo));

Diff for: ext/intl/msgformat/msgformat_class.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
#include <php.h>
2121

22-
#include "intl_common.h"
23-
#include "intl_error.h"
24-
#include "intl_data.h"
22+
#include <unicode/uconfig.h>
23+
24+
#include "../intl_common.h"
25+
#include "../intl_error.h"
26+
#include "../intl_data.h"
2527
#include "msgformat_data.h"
2628

2729
typedef struct {
@@ -38,4 +40,8 @@ extern zend_class_entry *MessageFormatter_ce_ptr;
3840
#define MSG_FORMAT_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo)
3941
#define MSG_FORMAT_OBJECT(mfo) (mfo)->mf_data.umsgf
4042

43+
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM < 48
44+
# define MSG_FORMAT_QUOTE_APOS 1
45+
#endif
46+
4147
#endif // #ifndef MSG_FORMAT_CLASS_H

Diff for: ext/intl/msgformat/msgformat_data.c

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <unicode/ustring.h>
2222
#include "msgformat_data.h"
2323

24+
#include "msgformat_class.h"
25+
2426
/* {{{ void msgformat_data_init( msgformat_data* mf_data )
2527
* Initialize internals of msgformat_data.
2628
*/
@@ -69,6 +71,7 @@ msgformat_data* msgformat_data_create( TSRMLS_D )
6971
}
7072
/* }}} */
7173

74+
#ifdef MSG_FORMAT_QUOTE_APOS
7275
int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec)
7376
{
7477
if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
@@ -86,6 +89,7 @@ int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *e
8689
}
8790
return SUCCESS;
8891
}
92+
#endif
8993

9094

9195
/*

Diff for: ext/intl/msgformat/msgformat_data.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include <php.h>
2121

22-
#include <unicode/umsg.h>
22+
#include "../intl_error.h"
2323

24-
#include "intl_error.h"
24+
#include <unicode/umsg.h>
2525

2626
typedef struct {
2727
// error hangling
@@ -36,6 +36,9 @@ typedef struct {
3636
msgformat_data* msgformat_data_create( TSRMLS_D );
3737
void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC );
3838
void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC );
39+
40+
#ifdef MSG_FORMAT_QUOTE_APOS
3941
int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec);
42+
#endif
4043

4144
#endif // MSG_FORMAT_DATA_H

Diff for: ext/intl/msgformat/msgformat_format.c

+2
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ PHP_FUNCTION( msgfmt_format_message )
154154
slocale = INTL_G(default_locale);
155155
}
156156

157+
#ifdef MSG_FORMAT_QUOTE_APOS
157158
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
158159
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
159160
"msgfmt_format_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
160161
RETURN_FALSE;
161162
}
163+
#endif
162164

163165
/* Create an ICU message formatter. */
164166
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));

Diff for: ext/intl/msgformat/msgformat_parse.c

+2
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ PHP_FUNCTION( msgfmt_parse_message )
129129
slocale = INTL_G(default_locale);
130130
}
131131

132+
#ifdef MSG_FORMAT_QUOTE_APOS
132133
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
133134
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
134135
"msgfmt_parse_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
135136
RETURN_FALSE;
136137
}
138+
#endif
137139

138140
/* Create an ICU message formatter. */
139141
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));

Diff for: ext/intl/tests/collator_get_sort_key.phpt

+35-36
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
collator_get_sort_key()
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5-
--XFAIL--
6-
Sort keys are not fixed, comparing them to fixed strings doesn't work.
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
76
--FILE--
87
<?php
98

@@ -18,8 +17,8 @@ function sort_arrays( $locale, $data )
1817

1918
foreach($data as $value) {
2019
$res_val = ut_coll_get_sort_key( $coll, $value );
21-
$res_str .= "source: ".urlencode($value)."\n".
22-
"key: ".urlencode($res_val)."\n";
20+
$res_str .= "source: ".$value."\n".
21+
"key: ".bin2hex($res_val)."\n";
2322
}
2423

2524
return $res_str;
@@ -58,42 +57,42 @@ ut_run();
5857
?>
5958
--EXPECT--
6059
source: abc
61-
key: %29%2B-%01%07%01%07%00
60+
key: 27292b01070107
6261
source: abd
63-
key: %29%2B%2F%01%07%01%07%00
62+
key: 27292d01070107
6463
source: aaa
65-
key: %29%29%29%01%07%01%07%00
66-
source: %D0%B0%D0%B0
67-
key: _++%01%06%01%06%00
68-
source: %D0%B0
69-
key: _+%01%05%01%05%00
64+
key: 27272701070107
65+
source: аа
66+
key: 5c0a0a01060106
67+
source: а
68+
key: 5c0a01050105
7069
source: z
71-
key: %5B%01%05%01%05%00
72-
source:
73-
key: %01%01%00
74-
source:
75-
key: %01%01%00
70+
key: 5901050105
71+
source:
72+
key: 0101
73+
source:
74+
key: 0101
7675
source: 3
77-
key: %26%80%01%05%01%05%00
76+
key: 1801050105
7877
source: y
79-
key: Y%01%05%01%05%00
78+
key: 5701050105
8079
source: i
81-
key: 9%01%05%01%05%00
80+
key: 3701050105
8281
source: k
83-
key: %3D%01%05%01%05%00
84-
source: %D0%B0%D0%B1%D0%B3
85-
key: _+%2C0%01%07%01%07%00
86-
source: %D0%B0%D0%B1%D0%B2
87-
key: _+%2C.%01%07%01%07%00
88-
source: %D0%B6%D0%B6%D0%B6
89-
key: _LLL%01%07%01%07%00
90-
source: %D1%8D%D1%8E%D1%8F
91-
key: %60%05%09%0B%01%07%01%07%00
92-
source: %D0%B0%D0%B1%D0%B3
93-
key: _+%2C0%01%07%01%07%00
94-
source: %D0%B0%D0%B1%D0%B2
95-
key: _+%2C.%01%07%01%07%00
96-
source: %D0%B6%D0%B6%D0%B6
97-
key: _LLL%01%07%01%07%00
98-
source: %D1%8D%D1%8E%D1%8F
99-
key: %60%05%09%0B%01%07%01%07%00
82+
key: 3b01050105
83+
source: абг
84+
key: 5c0a161a01070107
85+
source: абв
86+
key: 5c0a161801070107
87+
source: жжж
88+
key: 5c3a3a3a01070107
89+
source: эюя
90+
key: 5d3b3f4501070107
91+
source: абг
92+
key: 5c0a161a01070107
93+
source: абв
94+
key: 5c0a161801070107
95+
source: жжж
96+
key: 5c3a3a3a01070107
97+
source: эюя
98+
key: 5d3b3f4501070107

Diff for: ext/intl/tests/formatter_get_set_attribute.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--TEST--
2-
numfmt_get/set_attribute() icu < 4.2
2+
numfmt_get/set_attribute()
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5-
<?php if(version_compare(INTL_ICU_VERSION, '4.2', '<') != 1) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.2', '<') != 1) print 'skip for ICU 4.4+'; ?>
66
--FILE--
77
<?php
88

@@ -29,7 +29,7 @@ function ut_main()
2929
'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 1, 12345.123456 ),
3030
'ROUNDING_INCREMENT' => array( NumberFormatter::ROUNDING_INCREMENT, (float)2, 12345.123456 ),
3131
'FORMAT_WIDTH' => array( NumberFormatter::FORMAT_WIDTH, 27, 12345.123456 ),
32-
'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 21, 12345.123456 ),
32+
'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 2, 12345.123456 ),
3333
'SECONDARY_GROUPING_SIZE' => array( NumberFormatter::SECONDARY_GROUPING_SIZE, 2, 12345.123456 ),
3434
'SIGNIFICANT_DIGITS_USED' => array( NumberFormatter::SIGNIFICANT_DIGITS_USED, 1, 12345.123456 ),
3535
'MIN_SIGNIFICANT_DIGITS' => array( NumberFormatter::MIN_SIGNIFICANT_DIGITS, 3, 1 ),
@@ -159,7 +159,7 @@ Setting attribute: ok
159159
New attribute value: 1 ; Format result: '0,012,345.12345' ; Parse result: 12345.12345
160160

161161
Attribute ROUNDING_INCREMENT
162-
Old attribute value: 1.0E-5 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
162+
Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
163163
Setting attribute: ok
164164
New attribute value: 2 ; Format result: '0,012,346.00000' ; Parse result: 12346
165165

@@ -171,7 +171,7 @@ New attribute value: 27 ; Format result: '************0,012,345.12346' ; Parse
171171
Attribute PADDING_POSITION
172172
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
173173
Setting attribute: ok
174-
New attribute value: 21 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
174+
New attribute value: 2 ; Format result: '0,012,345.12346************' ; Parse result: 12345.12346
175175

176176
Attribute SECONDARY_GROUPING_SIZE
177177
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346

0 commit comments

Comments
 (0)