1 --- php-5.4.41/Zend/zend_operators.h 2015-05-12 19:38:38.000000000 +0000
2 +++ php-5.5.25/Zend/zend_operators.h 2015-05-14 00:02:08.000000000 +0000
4 +----------------------------------------------------------------------+
6 +----------------------------------------------------------------------+
7 - | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
8 + | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
9 +----------------------------------------------------------------------+
10 | This source file is subject to version 2.00 of the Zend license, |
11 | that is bundled with this package in the file LICENSE, and is |
25 #if ZEND_DVAL_TO_LVAL_CAST_OK
26 # define zend_dval_to_lval(d) ((long) (d))
27 -#elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64)
28 +#elif SIZEOF_LONG == 4
29 static zend_always_inline long zend_dval_to_lval(double d)
31 if (d > LONG_MAX || d < LONG_MIN) {
32 - return (long)(unsigned long)(zend_long64) d;
33 + double two_pow_32 = pow(2., 32.),
36 + dmod = fmod(d, two_pow_32);
38 + /* we're going to make this number positive; call ceil()
39 + * to simulate rounding towards 0 of the negative number */
40 + dmod = ceil(dmod) + two_pow_32;
42 + return (long)(unsigned long)dmod;
48 static zend_always_inline long zend_dval_to_lval(double d)
50 /* >= as (double)LONG_MAX is outside signed range */
51 - if (d >= LONG_MAX) {
52 - return (long)(unsigned long) d;
53 + if (d >= LONG_MAX || d < LONG_MIN) {
54 + double two_pow_64 = pow(2., 64.),
57 + dmod = fmod(d, two_pow_64);
59 + /* no need to call ceil; original double must have had no
60 + * fractional part, hence dmod does not have one either */
63 + return (long)(unsigned long)dmod;
73 int base = 10, digits = 0, dp_or_e = 0;
75 + double local_dval = 0.0;
80 ZEND_API int decrement_function(zval *op2);
82 ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC);
83 +ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC);
84 ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC);
85 ZEND_API void convert_to_long(zval *op);
86 ZEND_API void convert_to_double(zval *op);
88 ZEND_API void multi_convert_to_string_ex(int argc, ...);
89 ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2);
90 ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2);
91 +#define convert_to_cstring(op) if ((op)->type != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
92 #define convert_to_string(op) if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
94 ZEND_API double zend_string_to_double(const char *number, zend_uint length);
96 ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length);
97 ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2);
98 ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length);
99 +ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length);
101 ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
102 ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC);
104 #define zend_update_current_locale()
107 +/* The offset in bytes between the value and type fields of a zval */
108 +#define ZVAL_OFFSETOF_TYPE \
109 + (offsetof(zval,type) - offsetof(zval,value))
111 static zend_always_inline int fast_increment_function(zval *op1)
113 if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
114 @@ -483,20 +512,26 @@
116 "movl $0x0, (%0)\n\t"
117 "movl $0x41e00000, 0x4(%0)\n\t"
118 - "movb $0x2,0xc(%0)\n"
119 + "movb %1, %c2(%0)\n"
123 + : "r"(&op1->value),
125 + "n"(ZVAL_OFFSETOF_TYPE)
127 #elif defined(__GNUC__) && defined(__x86_64__)
131 "movl $0x0, (%0)\n\t"
132 "movl $0x43e00000, 0x4(%0)\n\t"
133 - "movb $0x2,0x14(%0)\n"
134 + "movb %1, %c2(%0)\n"
138 + : "r"(&op1->value),
140 + "n"(ZVAL_OFFSETOF_TYPE)
143 if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) {
144 /* switch to double */
145 @@ -520,20 +555,26 @@
147 "movl $0x00200000, (%0)\n\t"
148 "movl $0xc1e00000, 0x4(%0)\n\t"
149 - "movb $0x2,0xc(%0)\n"
150 + "movb %1,%c2(%0)\n"
154 + : "r"(&op1->value),
156 + "n"(ZVAL_OFFSETOF_TYPE)
158 #elif defined(__GNUC__) && defined(__x86_64__)
162 "movl $0x00000000, (%0)\n\t"
163 "movl $0xc3e00000, 0x4(%0)\n\t"
164 - "movb $0x2,0x14(%0)\n"
165 + "movb %1,%c2(%0)\n"
169 + : "r"(&op1->value),
171 + "n"(ZVAL_OFFSETOF_TYPE)
174 if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MIN)) {
175 /* switch to double */
176 @@ -558,40 +599,46 @@
177 "addl (%2), %%eax\n\t"
179 "movl %%eax, (%0)\n\t"
180 - "movb $0x1,0xc(%0)\n\t"
181 + "movb %3, %c5(%0)\n\t"
186 "faddp %%st, %%st(1)\n\t"
187 - "movb $0x2,0xc(%0)\n\t"
188 + "movb %4, %c5(%0)\n\t"
196 + : "r"(&result->value),
201 + "n"(ZVAL_OFFSETOF_TYPE)
203 #elif defined(__GNUC__) && defined(__x86_64__)
205 "movq (%1), %%rax\n\t"
206 "addq (%2), %%rax\n\t"
208 "movq %%rax, (%0)\n\t"
209 - "movb $0x1,0x14(%0)\n\t"
210 + "movb %3, %c5(%0)\n\t"
215 "faddp %%st, %%st(1)\n\t"
216 - "movb $0x2,0x14(%0)\n\t"
217 + "movb %4, %c5(%0)\n\t"
225 + : "r"(&result->value),
230 + "n"(ZVAL_OFFSETOF_TYPE)
234 * 'result' may alias with op1 or op2, so we need to
236 "subl (%2), %%eax\n\t"
238 "movl %%eax, (%0)\n\t"
239 - "movb $0x1,0xc(%0)\n\t"
240 + "movb %3, %c5(%0)\n\t"
244 @@ -648,21 +695,24 @@
246 "fsubp %%st, %%st(1)\n\t"
248 - "movb $0x2,0xc(%0)\n\t"
249 + "movb %4, %c5(%0)\n\t"
257 + : "r"(&result->value),
262 + "n"(ZVAL_OFFSETOF_TYPE)
264 #elif defined(__GNUC__) && defined(__x86_64__)
266 "movq (%1), %%rax\n\t"
267 "subq (%2), %%rax\n\t"
269 "movq %%rax, (%0)\n\t"
270 - "movb $0x1,0x14(%0)\n\t"
271 + "movb %3, %c5(%0)\n\t"
275 @@ -672,14 +722,17 @@
277 "fsubp %%st, %%st(1)\n\t"
279 - "movb $0x2,0x14(%0)\n\t"
280 + "movb %4, %c5(%0)\n\t"
288 + : "r"(&result->value),
293 + "n"(ZVAL_OFFSETOF_TYPE)
296 Z_LVAL_P(result) = Z_LVAL_P(op1) - Z_LVAL_P(op2);
298 --- php-5.4.41/Zend/zend_operators.c 2015-05-12 19:38:38.000000000 +0000
299 +++ php-5.5.25/Zend/zend_operators.c 2015-05-14 00:02:08.000000000 +0000
301 +----------------------------------------------------------------------+
303 +----------------------------------------------------------------------+
304 - | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
305 + | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
306 +----------------------------------------------------------------------+
307 | This source file is subject to version 2.00 of the Zend license, |
308 | that is bundled with this package in the file LICENSE, and is |
311 #define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2))
313 +static const unsigned char tolower_map[256] = {
314 +0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
315 +0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
316 +0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
317 +0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
318 +0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
319 +0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f,
320 +0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
321 +0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
322 +0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
323 +0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
324 +0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
325 +0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
326 +0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
327 +0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
328 +0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
329 +0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
332 +#define zend_tolower_ascii(c) (tolower_map[(unsigned char)(c)])
335 + * Functions using locale lowercase:
336 + zend_binary_strncasecmp_l
337 + zend_binary_strcasecmp_l
338 + zend_binary_zval_strcasecmp
339 + zend_binary_zval_strncasecmp
340 + string_compare_function_ex
341 + string_case_compare_function
342 + * Functions using ascii lowercase:
343 + zend_str_tolower_copy
344 + zend_str_tolower_dup
346 + zend_binary_strcasecmp
347 + zend_binary_strncasecmp
350 ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */
357 +ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC) /* {{{ */
360 + switch (Z_TYPE_P(op)) {
363 + dval = Z_DVAL_P(op);
364 + Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%.*H", (int) EG(precision), dval);
365 + /* %H already handles removing trailing zeros from the fractional part, yay */
369 + _convert_to_string(op ZEND_FILE_LINE_CC);
371 + Z_TYPE_P(op) = IS_STRING;
375 ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
378 @@ -1916,7 +1971,7 @@
379 register unsigned char *end = str + length;
382 - *result++ = zend_tolower((int)*str++);
383 + *result++ = zend_tolower_ascii(*str++);
387 @@ -1936,7 +1991,7 @@
388 register unsigned char *end = p + length;
391 - *p = zend_tolower((int)*p);
392 + *p = zend_tolower_ascii(*p);
396 @@ -1985,6 +2040,49 @@
398 len = MIN(len1, len2);
400 + c1 = zend_tolower_ascii(*(unsigned char *)s1++);
401 + c2 = zend_tolower_ascii(*(unsigned char *)s2++);
407 + return len1 - len2;
411 +ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
419 + len = MIN(length, MIN(len1, len2));
421 + c1 = zend_tolower_ascii(*(unsigned char *)s1++);
422 + c2 = zend_tolower_ascii(*(unsigned char *)s2++);
428 + return MIN(length, len1) - MIN(length, len2);
432 +ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
441 + len = MIN(len1, len2);
443 c1 = zend_tolower((int)*(unsigned char *)s1++);
444 c2 = zend_tolower((int)*(unsigned char *)s2++);
446 @@ -1996,7 +2094,7 @@
450 -ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
451 +ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
455 @@ -2031,13 +2129,13 @@
457 ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2) /* {{{ */
459 - return zend_binary_strcasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2));
460 + return zend_binary_strcasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2));
464 ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3) /* {{{ */
466 - return zend_binary_strncasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3));
467 + return zend_binary_strncasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3));
471 @@ -2045,8 +2143,8 @@
476 - double dval1, dval2;
477 + long lval1 = 0, lval2 = 0;
478 + double dval1 = 0.0, dval2 = 0.0;
480 if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRLEN_P(s1), &lval1, &dval1, 0, &oflow1)) &&
481 (ret2=is_numeric_string_ex(Z_STRVAL_P(s2), Z_STRLEN_P(s2), &lval2, &dval2, 0, &oflow2))) {