]> git.pld-linux.org Git - packages/php.git/blame - zend_operators_from_5.5.patch
- enable phar again on x32
[packages/php.git] / zend_operators_from_5.5.patch
CommitLineData
6dac47d5
WF
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
3@@ -2,7 +2,7 @@
4 +----------------------------------------------------------------------+
5 | Zend Engine |
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 |
12@@ -26,6 +26,10 @@
13 #include <math.h>
14 #include <assert.h>
15
16+#ifdef __GNUC__
17+#include <stddef.h>
18+#endif
19+
20 #ifdef HAVE_IEEEFP_H
21 #include <ieeefp.h>
22 #endif
23@@ -68,22 +72,40 @@
24
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)
30 {
31 if (d > LONG_MAX || d < LONG_MIN) {
32- return (long)(unsigned long)(zend_long64) d;
33+ double two_pow_32 = pow(2., 32.),
34+ dmod;
35+
36+ dmod = fmod(d, two_pow_32);
37+ if (dmod < 0) {
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;
41+ }
42+ return (long)(unsigned long)dmod;
43 }
44- return (long) d;
45+ return (long)d;
46 }
47 #else
48 static zend_always_inline long zend_dval_to_lval(double d)
49 {
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.),
55+ dmod;
56+
57+ dmod = fmod(d, two_pow_64);
58+ if (dmod < 0) {
59+ /* no need to call ceil; original double must have had no
60+ * fractional part, hence dmod does not have one either */
61+ dmod += two_pow_64;
62+ }
63+ return (long)(unsigned long)dmod;
64 }
65- return (long) d;
66+ return (long)d;
67 }
68 #endif
69 /* }}} */
70@@ -110,7 +132,7 @@
71 {
72 const char *ptr;
73 int base = 10, digits = 0, dp_or_e = 0;
74- double local_dval;
75+ double local_dval = 0.0;
76 zend_uchar type;
77
78 if (!length) {
79@@ -302,6 +324,7 @@
80 ZEND_API int decrement_function(zval *op2);
81
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);
87@@ -315,6 +338,7 @@
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); }
93
94 ZEND_API double zend_string_to_double(const char *number, zend_uint length);
95@@ -341,6 +365,7 @@
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);
100
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);
103@@ -474,6 +499,10 @@
104 #define zend_update_current_locale()
105 #endif
106
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))
110+
111 static zend_always_inline int fast_increment_function(zval *op1)
112 {
113 if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
114@@ -483,20 +512,26 @@
115 "jno 0f\n\t"
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"
120 "0:"
121 :
122- : "r"(op1));
123+ : "r"(&op1->value),
124+ "n"(IS_DOUBLE),
125+ "n"(ZVAL_OFFSETOF_TYPE)
126+ : "cc");
127 #elif defined(__GNUC__) && defined(__x86_64__)
128 __asm__(
129 "incq (%0)\n\t"
130 "jno 0f\n\t"
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"
135 "0:"
136 :
137- : "r"(op1));
138+ : "r"(&op1->value),
139+ "n"(IS_DOUBLE),
140+ "n"(ZVAL_OFFSETOF_TYPE)
141+ : "cc");
142 #else
143 if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) {
144 /* switch to double */
145@@ -520,20 +555,26 @@
146 "jno 0f\n\t"
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"
151 "0:"
152 :
153- : "r"(op1));
154+ : "r"(&op1->value),
155+ "n"(IS_DOUBLE),
156+ "n"(ZVAL_OFFSETOF_TYPE)
157+ : "cc");
158 #elif defined(__GNUC__) && defined(__x86_64__)
159 __asm__(
160 "decq (%0)\n\t"
161 "jno 0f\n\t"
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"
166 "0:"
167 :
168- : "r"(op1));
169+ : "r"(&op1->value),
170+ "n"(IS_DOUBLE),
171+ "n"(ZVAL_OFFSETOF_TYPE)
172+ : "cc");
173 #else
174 if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MIN)) {
175 /* switch to double */
176@@ -558,40 +599,46 @@
177 "addl (%2), %%eax\n\t"
178 "jo 0f\n\t"
179 "movl %%eax, (%0)\n\t"
180- "movb $0x1,0xc(%0)\n\t"
181+ "movb %3, %c5(%0)\n\t"
182 "jmp 1f\n"
183 "0:\n\t"
184 "fildl (%1)\n\t"
185 "fildl (%2)\n\t"
186 "faddp %%st, %%st(1)\n\t"
187- "movb $0x2,0xc(%0)\n\t"
188+ "movb %4, %c5(%0)\n\t"
189 "fstpl (%0)\n"
190 "1:"
191 :
192- : "r"(result),
193- "r"(op1),
194- "r"(op2)
195- : "eax");
196+ : "r"(&result->value),
197+ "r"(&op1->value),
198+ "r"(&op2->value),
199+ "n"(IS_LONG),
200+ "n"(IS_DOUBLE),
201+ "n"(ZVAL_OFFSETOF_TYPE)
202+ : "eax","cc");
203 #elif defined(__GNUC__) && defined(__x86_64__)
204 __asm__(
205 "movq (%1), %%rax\n\t"
206 "addq (%2), %%rax\n\t"
207 "jo 0f\n\t"
208 "movq %%rax, (%0)\n\t"
209- "movb $0x1,0x14(%0)\n\t"
210+ "movb %3, %c5(%0)\n\t"
211 "jmp 1f\n"
212 "0:\n\t"
213 "fildq (%1)\n\t"
214 "fildq (%2)\n\t"
215 "faddp %%st, %%st(1)\n\t"
216- "movb $0x2,0x14(%0)\n\t"
217+ "movb %4, %c5(%0)\n\t"
218 "fstpl (%0)\n"
219 "1:"
220 :
221- : "r"(result),
222- "r"(op1),
223- "r"(op2)
224- : "rax");
225+ : "r"(&result->value),
226+ "r"(&op1->value),
227+ "r"(&op2->value),
228+ "n"(IS_LONG),
229+ "n"(IS_DOUBLE),
230+ "n"(ZVAL_OFFSETOF_TYPE)
231+ : "rax","cc");
232 #else
233 /*
234 * 'result' may alias with op1 or op2, so we need to
235@@ -638,7 +685,7 @@
236 "subl (%2), %%eax\n\t"
237 "jo 0f\n\t"
238 "movl %%eax, (%0)\n\t"
239- "movb $0x1,0xc(%0)\n\t"
240+ "movb %3, %c5(%0)\n\t"
241 "jmp 1f\n"
242 "0:\n\t"
243 "fildl (%2)\n\t"
244@@ -648,21 +695,24 @@
245 #else
246 "fsubp %%st, %%st(1)\n\t"
247 #endif
248- "movb $0x2,0xc(%0)\n\t"
249+ "movb %4, %c5(%0)\n\t"
250 "fstpl (%0)\n"
251 "1:"
252 :
253- : "r"(result),
254- "r"(op1),
255- "r"(op2)
256- : "eax");
257+ : "r"(&result->value),
258+ "r"(&op1->value),
259+ "r"(&op2->value),
260+ "n"(IS_LONG),
261+ "n"(IS_DOUBLE),
262+ "n"(ZVAL_OFFSETOF_TYPE)
263+ : "eax","cc");
264 #elif defined(__GNUC__) && defined(__x86_64__)
265 __asm__(
266 "movq (%1), %%rax\n\t"
267 "subq (%2), %%rax\n\t"
268 "jo 0f\n\t"
269 "movq %%rax, (%0)\n\t"
270- "movb $0x1,0x14(%0)\n\t"
271+ "movb %3, %c5(%0)\n\t"
272 "jmp 1f\n"
273 "0:\n\t"
274 "fildq (%2)\n\t"
275@@ -672,14 +722,17 @@
276 #else
277 "fsubp %%st, %%st(1)\n\t"
278 #endif
279- "movb $0x2,0x14(%0)\n\t"
280+ "movb %4, %c5(%0)\n\t"
281 "fstpl (%0)\n"
282 "1:"
283 :
284- : "r"(result),
285- "r"(op1),
286- "r"(op2)
287- : "rax");
288+ : "r"(&result->value),
289+ "r"(&op1->value),
290+ "r"(&op2->value),
291+ "n"(IS_LONG),
292+ "n"(IS_DOUBLE),
293+ "n"(ZVAL_OFFSETOF_TYPE)
294+ : "rax","cc");
295 #else
296 Z_LVAL_P(result) = Z_LVAL_P(op1) - Z_LVAL_P(op2);
297
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
300@@ -2,7 +2,7 @@
301 +----------------------------------------------------------------------+
302 | Zend Engine |
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 |
309@@ -42,6 +42,43 @@
310
311 #define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2))
312
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
330+};
331+
332+#define zend_tolower_ascii(c) (tolower_map[(unsigned char)(c)])
333+
334+/**
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
345+ zend_str_tolower
346+ zend_binary_strcasecmp
347+ zend_binary_strncasecmp
348+ */
349+
350 ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */
351 {
352 int retval;
353@@ -535,6 +572,24 @@
354 }
355 /* }}} */
356
357+ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC) /* {{{ */
358+{
359+ double dval;
360+ switch (Z_TYPE_P(op)) {
361+ case IS_DOUBLE: {
362+ TSRMLS_FETCH();
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 */
366+ break;
367+ }
368+ default:
369+ _convert_to_string(op ZEND_FILE_LINE_CC);
370+ }
371+ Z_TYPE_P(op) = IS_STRING;
372+}
373+/* }}} */
374+
375 ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
376 {
377 long lval;
378@@ -1916,7 +1971,7 @@
379 register unsigned char *end = str + length;
380
381 while (str < end) {
382- *result++ = zend_tolower((int)*str++);
383+ *result++ = zend_tolower_ascii(*str++);
384 }
385 *result = '\0';
386
387@@ -1936,7 +1991,7 @@
388 register unsigned char *end = p + length;
389
390 while (p < end) {
391- *p = zend_tolower((int)*p);
392+ *p = zend_tolower_ascii(*p);
393 p++;
394 }
395 }
396@@ -1985,6 +2040,49 @@
397
398 len = MIN(len1, len2);
399 while (len--) {
400+ c1 = zend_tolower_ascii(*(unsigned char *)s1++);
401+ c2 = zend_tolower_ascii(*(unsigned char *)s2++);
402+ if (c1 != c2) {
403+ return c1 - c2;
404+ }
405+ }
406+
407+ return len1 - len2;
408+}
409+/* }}} */
410+
411+ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
412+{
413+ int len;
414+ int c1, c2;
415+
416+ if (s1 == s2) {
417+ return 0;
418+ }
419+ len = MIN(length, MIN(len1, len2));
420+ while (len--) {
421+ c1 = zend_tolower_ascii(*(unsigned char *)s1++);
422+ c2 = zend_tolower_ascii(*(unsigned char *)s2++);
423+ if (c1 != c2) {
424+ return c1 - c2;
425+ }
426+ }
427+
428+ return MIN(length, len1) - MIN(length, len2);
429+}
430+/* }}} */
431+
432+ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
433+{
434+ int len;
435+ int c1, c2;
436+
437+ if (s1 == s2) {
438+ return 0;
439+ }
440+
441+ len = MIN(len1, len2);
442+ while (len--) {
443 c1 = zend_tolower((int)*(unsigned char *)s1++);
444 c2 = zend_tolower((int)*(unsigned char *)s2++);
445 if (c1 != c2) {
446@@ -1996,7 +2094,7 @@
447 }
448 /* }}} */
449
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) /* {{{ */
452 {
453 int len;
454 int c1, c2;
455@@ -2031,13 +2129,13 @@
456
457 ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2) /* {{{ */
458 {
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));
461 }
462 /* }}} */
463
464 ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3) /* {{{ */
465 {
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));
468 }
469 /* }}} */
470
471@@ -2045,8 +2143,8 @@
472 {
473 int ret1, ret2;
474 int oflow1, oflow2;
475- long lval1, lval2;
476- double dval1, dval2;
477+ long lval1 = 0, lval2 = 0;
478+ double dval1 = 0.0, dval2 = 0.0;
479
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))) {
This page took 0.123197 seconds and 4 git commands to generate.