summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_exceptions.c3
-rw-r--r--ext/gettext/gettext.c4
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt21
-rw-r--r--ext/standard/string.c70
-rw-r--r--main/rfc1867.c9
-rw-r--r--win32/signal.h17
6 files changed, 46 insertions, 78 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index c6bef24346..cb8b79ece9 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -922,7 +922,6 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
zend_string_release(file);
zend_string_release(message);
- OBJ_RELEASE(ex);
} else if (instanceof_function(ce_exception, base_exception_ce)) {
zval tmp, rv;
zend_string *str, *file = NULL;
@@ -969,6 +968,8 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
} else {
zend_error(severity, "Uncaught exception '%s'", ce_exception->name->val);
}
+
+ OBJ_RELEASE(ex);
}
/* }}} */
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 90038fad5c..44502729e5 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -139,13 +139,13 @@ ZEND_GET_MODULE(php_gettext)
#define PHP_GETTEXT_MAX_MSGID_LENGTH 4096
#define PHP_GETTEXT_DOMAIN_LENGTH_CHECK \
- if (domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH) { \
+ if (UNEXPECTED(domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH)) { \
php_error_docref(NULL, E_WARNING, "domain passed too long"); \
RETURN_FALSE; \
}
#define PHP_GETTEXT_LENGTH_CHECK(check_name, check_len) \
- if (check_len > PHP_GETTEXT_MAX_MSGID_LENGTH) { \
+ if (UNEXPECTED(check_len > PHP_GETTEXT_MAX_MSGID_LENGTH)) { \
php_error_docref(NULL, E_WARNING, "%s passed too long", check_name); \
RETURN_FALSE; \
}
diff --git a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
index 876109001c..508f73ee55 100644
--- a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
@@ -9,7 +9,7 @@ var_dump($ext->getClasses());
?>
==DONE==
--EXPECT--
-array(12) {
+array(13) {
["ReflectionException"]=>
object(ReflectionClass)#2 (1) {
["name"]=>
@@ -35,38 +35,43 @@ array(12) {
["name"]=>
string(18) "ReflectionFunction"
}
- ["ReflectionParameter"]=>
+ ["ReflectionGenerator"]=>
object(ReflectionClass)#7 (1) {
["name"]=>
+ string(19) "ReflectionGenerator"
+ }
+ ["ReflectionParameter"]=>
+ object(ReflectionClass)#8 (1) {
+ ["name"]=>
string(19) "ReflectionParameter"
}
["ReflectionMethod"]=>
- object(ReflectionClass)#8 (1) {
+ object(ReflectionClass)#9 (1) {
["name"]=>
string(16) "ReflectionMethod"
}
["ReflectionClass"]=>
- object(ReflectionClass)#9 (1) {
+ object(ReflectionClass)#10 (1) {
["name"]=>
string(15) "ReflectionClass"
}
["ReflectionObject"]=>
- object(ReflectionClass)#10 (1) {
+ object(ReflectionClass)#11 (1) {
["name"]=>
string(16) "ReflectionObject"
}
["ReflectionProperty"]=>
- object(ReflectionClass)#11 (1) {
+ object(ReflectionClass)#12 (1) {
["name"]=>
string(18) "ReflectionProperty"
}
["ReflectionExtension"]=>
- object(ReflectionClass)#12 (1) {
+ object(ReflectionClass)#13 (1) {
["name"]=>
string(19) "ReflectionExtension"
}
["ReflectionZendExtension"]=>
- object(ReflectionClass)#13 (1) {
+ object(ReflectionClass)#14 (1) {
["name"]=>
string(23) "ReflectionZendExtension"
}
diff --git a/ext/standard/string.c b/ext/standard/string.c
index ee66e8a2af..3162533186 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2977,19 +2977,20 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
int num_keys = 0;
size_t minlen = 128*1024;
size_t maxlen = 0;
- HashTable str_hash, num_hash;
+ HashTable str_hash;
zval *entry, tmp, dummy;
char *key;
smart_str result = {0};
zend_ulong bitset[256/sizeof(zend_ulong)];
+ zend_ulong *num_bitset;
/* we will collect all possible key lengths */
ZVAL_NULL(&dummy);
- zend_hash_init(&num_hash, 8, NULL, NULL, 0);
+ num_bitset = ecalloc((slen + (sizeof(zend_ulong)-1)) / sizeof(zend_ulong), sizeof(zend_ulong));
memset(bitset, 0, sizeof(bitset));
/* check if original array has numeric keys */
- ZEND_HASH_FOREACH_KEY(pats, num_key, str_key) {
+ ZEND_HASH_FOREACH_STR_KEY(pats, str_key) {
if (UNEXPECTED(!str_key)) {
num_keys = 1;
} else {
@@ -3007,12 +3008,12 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
minlen = len;
}
/* remember possible key length */
- zend_hash_index_add(&num_hash, len, &dummy);
+ num_bitset[len / sizeof(zend_ulong)] |= Z_UL(1) << (len % sizeof(zend_ulong));
bitset[((unsigned char)str_key->val[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)str_key->val[0]) % sizeof(zend_ulong));
}
} ZEND_HASH_FOREACH_END();
- if (num_keys) {
+ if (UNEXPECTED(num_keys)) {
/* we have to rebuild HashTable with numeric keys */
zend_hash_init(&str_hash, zend_hash_num_elements(pats), NULL, NULL, 0);
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
@@ -3033,7 +3034,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
minlen = len;
}
/* remember possible key length */
- zend_hash_index_add(&num_hash, len, &dummy);
+ num_bitset[len / sizeof(zend_ulong)] |= Z_UL(1) << (len % sizeof(zend_ulong));
bitset[((unsigned char)str_key->val[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)str_key->val[0]) % sizeof(zend_ulong));
} else {
len = str_key->len;
@@ -3055,45 +3056,20 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
if (pats == &str_hash) {
zend_hash_destroy(&str_hash);
}
- zend_hash_destroy(&num_hash);
- RETURN_STRINGL(str, slen);
- }
- /* select smart or simple algorithm */
- // TODO: tune the condition ???
- len = zend_hash_num_elements(&num_hash);
- if ((maxlen - (minlen - 1) - len > 0) &&
- /* smart algorithm, sort key lengths first */
- zend_hash_sort(&num_hash, php_strtr_key_compare, 0) == SUCCESS) {
-
- old_pos = pos = 0;
- while (pos <= slen - minlen) {
- key = str + pos;
- ZEND_HASH_FOREACH_NUM_KEY(&num_hash, len) {
- if (len > slen - pos) continue;
- if ((bitset[((unsigned char)key[0]) / sizeof(zend_ulong)] & Z_UL(1) << (((unsigned char)key[0]) % sizeof(zend_ulong))) == 0) continue;
- entry = zend_hash_str_find(pats, key, len);
- if (entry != NULL) {
- zend_string *s = zval_get_string(entry);
- smart_str_appendl(&result, str + old_pos, pos - old_pos);
- smart_str_append(&result, s);
- old_pos = pos + len;
- pos = old_pos - 1;
- zend_string_release(s);
- break;
- }
- } ZEND_HASH_FOREACH_END();
- pos++;
- }
- } else {
- /* use simple algorithm */
- old_pos = pos = 0;
- while (pos <= slen - minlen) {
- if (maxlen > slen - pos) {
- maxlen = slen - pos;
+ efree(num_bitset);
+ RETURN_STR_COPY(input);
+ }
+
+ old_pos = pos = 0;
+ while (pos <= slen - minlen) {
+ key = str + pos;
+ if (bitset[((unsigned char)key[0]) / sizeof(zend_ulong)] & Z_UL(1) << (((unsigned char)key[0]) % sizeof(zend_ulong))) {
+ len = maxlen;
+ if (len > slen - pos) {
+ len = slen - pos;
}
- key = str + pos;
- for (len = maxlen; len >= minlen; len--) {
- if ((bitset[((unsigned char)key[0]) / sizeof(zend_ulong)] & Z_UL(1) << (((unsigned char)key[0]) % sizeof(zend_ulong))) == 0) continue;
+ while (len >= minlen) {
+ if (num_bitset[len / sizeof(zend_ulong)] & Z_UL(1) << (len % sizeof(zend_ulong)) == 0) continue;
entry = zend_hash_str_find(pats, key, len);
if (entry != NULL) {
zend_string *s = zval_get_string(entry);
@@ -3104,10 +3080,12 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
zend_string_release(s);
break;
}
+ len--;
}
- pos++;
}
+ pos++;
}
+
if (result.s) {
smart_str_appendl(&result, str + old_pos, slen - old_pos);
smart_str_0(&result);
@@ -3120,7 +3098,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
if (pats == &str_hash) {
zend_hash_destroy(&str_hash);
}
- zend_hash_destroy(&num_hash);
+ efree(num_bitset);
}
/* }}} */
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 3c1bfa6b4f..30457f3bca 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -420,8 +420,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
/* get lines of text, or CRLF_CRLF */
- while( (line = get_line(self)) && line[0] != '\0' )
- {
+ while ((line = get_line(self)) && line[0] != '\0') {
/* add header to table */
char *value = NULL;
@@ -435,7 +434,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
}
if (value) {
- if(buf_value.c && key) {
+ if (buf_value.c && key) {
/* new entry, add the old one to the list */
smart_string_0(&buf_value);
entry.key = key;
@@ -446,7 +445,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
}
*value = '\0';
- do { value++; } while(isspace(*value));
+ do { value++; } while (isspace(*value));
key = estrdup(line);
smart_string_appends(&buf_value, value);
@@ -457,7 +456,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
}
}
- if(buf_value.c && key) {
+ if (buf_value.c && key) {
/* add the last one to the list */
smart_string_0(&buf_value);
entry.key = key;
diff --git a/win32/signal.h b/win32/signal.h
index 8d4f411d21..ec739527ac 100644
--- a/win32/signal.h
+++ b/win32/signal.h
@@ -1,23 +1,8 @@
#ifndef PHP_WIN32_SIGNAL_H
#define PHP_WIN32_SIGNAL_H
-#if _MSC_VER >= 1900
#include <signal.h>
-#else
-/*
-** Change here: if you plan to use your own version of <signal.h>
-** the original "#include <signal.h>" produces an infinite reinclusion
-** of this file, instead of including the standard include-file.
-** Under MS Visual Studio, there are occurrences in the source where
-** <signal.h> gets included throughout the PHP sources, and this should
-** include THIS file, not the standard one which does not have the
-** additional signals defined below.
-** One way to remove the infinite reinclusion of this file (which is located
-** in ../win32), is to specify the parent directory in which the standard
-** include file is located.
-*/
-#include <../include/signal.h>
-#endif
+
#define SIGALRM 13
#define SIGVTALRM 26 /* virtual time alarm */
#define SIGPROF 27 /* profiling time alarm */