]> granicus.if.org Git - php/commitdiff
Fix off-by-one error.
authorAndrei Zmievski <andrei@php.net>
Fri, 29 Sep 2006 20:59:26 +0000 (20:59 +0000)
committerAndrei Zmievski <andrei@php.net>
Fri, 29 Sep 2006 20:59:26 +0000 (20:59 +0000)
Zend/zend.c
Zend/zend_globals.h
Zend/zend_unicode.c

index 057d52c9104c52fe6c5b790cac72f795da6d3b52..02b8e470afc83bd45ceda0528661ad254b2c73ff 100644 (file)
@@ -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);
        }
index 710e52f3b625656969e8e419ef67819fff73f76d..a9f14a93f31f639a958890e722b037732be971f9 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <unicode/ucnv.h>
 #include <unicode/ucol.h>
+#include <unicode/usearch.h>
 
 /* 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 */
 
index 7a67e3785ab36373d6473f83423dcac559c8d748..ac5d90aae8bc90fad98359c5860e14e76b386b65 100644 (file)
@@ -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;
                }