diff options
| author | Jakub Zelenka <bukka@php.net> | 2015-01-10 15:31:06 +0000 |
|---|---|---|
| committer | Jakub Zelenka <bukka@php.net> | 2015-01-10 15:31:06 +0000 |
| commit | 1e49e9691707b55982053c5cc85119147460ff52 (patch) | |
| tree | d9ba284a3790c78b02f54301f31d910ad10b96fe /ext/standard/string.c | |
| parent | 1119c4d2b210730e6c26f034e9769d116b26ceb1 (diff) | |
| parent | dbd02ad23bfbe0b0dc703c68774e397fc0a8b1ef (diff) | |
| download | php-git-1e49e9691707b55982053c5cc85119147460ff52.tar.gz | |
Merge branch 'master' into jsond
Diffstat (limited to 'ext/standard/string.c')
| -rw-r--r-- | ext/standard/string.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index c57885fff1..483e8b4f1d 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4343,27 +4343,31 @@ PHP_FUNCTION(setlocale) if (retval) { if (loc) { /* Remember if locale was changed */ - size_t len; + size_t len = strlen(retval); - if (BG(locale_string)) { - zend_string_release(BG(locale_string)); - } - len = strlen(retval); - if (len == loc->len && !memcmp(loc->val, retval, len)) { - BG(locale_string) = zend_string_copy(loc); - } else { - BG(locale_string) = zend_string_init(retval, len, 0); + BG(locale_changed) = 1; + if (cat == LC_CTYPE || cat == LC_ALL) { + if (BG(locale_string)) { + zend_string_release(BG(locale_string)); + } + if (len == loc->len && !memcmp(loc->val, retval, len)) { + BG(locale_string) = zend_string_copy(loc); + RETURN_STR(BG(locale_string)); + } else { + BG(locale_string) = zend_string_init(retval, len, 0); + zend_string_release(loc); + RETURN_STR(BG(locale_string)); + } + } else if (len == loc->len && !memcmp(loc->val, retval, len)) { + RETURN_STR(loc); } - zend_string_release(loc); } - if (BG(locale_string)) { - RETURN_STR(zend_string_copy(BG(locale_string))); - } else { - RETURN_EMPTY_STRING(); - } + RETURN_STRING(retval); + } + if (loc) { + zend_string_release(loc); } - zend_string_release(loc); if (Z_TYPE(args[0]) == IS_ARRAY) { if (zend_hash_move_forward_ex(Z_ARRVAL(args[0]), &pos) == FAILURE) break; |
