From: Andrei Zmievski Date: Fri, 29 Sep 2006 20:59:26 +0000 (+0000) Subject: Fix off-by-one error. X-Git-Tag: RELEASE_1_0_0RC1~1507 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=966d8022b92943c44c72a7004d0738ba17533757;p=php Fix off-by-one error. --- diff --git a/Zend/zend.c b/Zend/zend.c index 057d52c910..02b8e470af 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -929,11 +929,26 @@ static void unicode_globals_ctor(zend_unicode_globals *unicode_globals TSRMLS_DC unicode_globals->to_error_mode = ZEND_CONV_ERROR_STOP; unicode_globals->conv_error_handler = NULL; + { + UErrorCode status = U_ZERO_ERROR; + + unicode_globals->root_collator = ucol_open("en_US", &status); + ucol_setStrength(unicode_globals->root_collator, UCOL_PRIMARY); + unicode_globals->root_search = usearch_openFromCollator(EMPTY_STR, 1, EMPTY_STR, 1, + unicode_globals->root_collator, NULL, &status); + } + zend_hash_init_ex(&unicode_globals->flex_compatible, 0, NULL, NULL, 1, 0); } static void unicode_globals_dtor(zend_unicode_globals *unicode_globals TSRMLS_DC) { + if (unicode_globals->root_collator) { + ucol_close(unicode_globals->root_collator); + } + if (unicode_globals->root_search) { + usearch_close(unicode_globals->root_search); + } if (unicode_globals->fallback_encoding_conv) { ucnv_close(unicode_globals->fallback_encoding_conv); } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 710e52f3b6..a9f14a93f3 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -37,6 +37,7 @@ #include #include +#include /* Define ZTS if you want a thread-safe Zend */ /*#undef ZTS*/ @@ -286,6 +287,8 @@ struct _zend_unicode_globals { char *default_locale; zend_collator *default_collator; + UCollator *root_collator; + UStringSearch *root_search; HashTable flex_compatible; /* table of flex-compatible encodings */ diff --git a/Zend/zend_unicode.c b/Zend/zend_unicode.c index 7a67e3785a..ac5d90aae8 100644 --- a/Zend/zend_unicode.c +++ b/Zend/zend_unicode.c @@ -741,7 +741,7 @@ ZEND_API void zend_case_fold_string(UChar **dest, int *dest_len, UChar *src, int while (1) { *status = U_ZERO_ERROR; buffer = eurealloc(buffer, buffer_len+1); - buffer_len = u_strFoldCase(buffer, buffer_len+1, src, src_len, options, status); + buffer_len = u_strFoldCase(buffer, buffer_len, src, src_len, options, status); if (*status != U_BUFFER_OVERFLOW_ERROR) { break; }