]> granicus.if.org Git - php/commitdiff
Use recommended options for explicit UnicodeString constructors
authorAnatol Belski <ab@php.net>
Thu, 5 Apr 2018 10:53:24 +0000 (12:53 +0200)
committerAnatol Belski <ab@php.net>
Thu, 5 Apr 2018 11:09:42 +0000 (13:09 +0200)
acinclude.m4
ext/intl/config.w32
ext/intl/msgformat/msgformat_helpers.cpp

index 4e5f0552723f779bb1fac7f1e8706103a73c34bc..89910930bd2c53f9320eceb77b94824915512cde 100644 (file)
@@ -2239,6 +2239,9 @@ AC_DEFUN([PHP_SETUP_ICU],[
     PHP_EVAL_LIBLINE($ICU_LIBS, $1)
 
     ICU_EXTRA_FLAGS=`$ICU_CONFIG --cxxflags`
+    if test "$icu_version" -lt "49000"; then
+      ICU_EXTRA_FLAGS="$ICU_EXTRA_FLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
+    fi
   fi
 ])
 
index 2aa408fac08141960a66a52bfffc3bb0d9f48da3..1f527dc7da366b154ae2f557d28b61e6e423034c 100644 (file)
@@ -129,7 +129,7 @@ if (PHP_INTL != "no") {
                        ADD_FLAG("LIBS_INTL", "iculx.lib");
                }
 
-               ADD_FLAG("CFLAGS_INTL", "/EHsc");
+               ADD_FLAG("CFLAGS_INTL", "/EHsc /DUNISTR_FROM_CHAR_EXPLICIT=explicit /DUNISTR_FROM_STRING_EXPLICIT=explicit");
                AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
        } else {
                WARNING("intl not enabled; libraries and/or headers not found");
index 287139bb9338ddf8011cad279ac444f1ba211594..90d60acbd2fd5f4fa46a5d073fad3de513990869 100644 (file)
@@ -237,15 +237,16 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
                                        UnicodeString typeString = mp.getSubstring(type_part);
                                        /* This is all based on the rules in the docs for MessageFormat
                                         * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */
-                                       if (typeString == "number") {
+#define ASCII_LITERAL(s) UNICODE_STRING(s, sizeof(s)-1)
+                                       if (typeString == ASCII_LITERAL("number")) {
                                                MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */
                                                if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) {
                                                        UnicodeString styleString = mp.getSubstring(style_part);
-                                                       if (styleString == "integer") {
+                                                       if (styleString == ASCII_LITERAL("integer")) {
                                                                type = Formattable::kInt64;
-                                                       } else if (styleString == "currency") {
+                                                       } else if (styleString == ASCII_LITERAL("currency")) {
                                                                type = Formattable::kDouble;
-                                                       } else if (styleString == "percent") {
+                                                       } else if (styleString == ASCII_LITERAL("percent")) {
                                                                type = Formattable::kDouble;
                                                        } else { /* some style invalid/unknown to us */
                                                                type = Formattable::kDouble;
@@ -253,12 +254,13 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
                                                } else { // if missing style, part, make it a double
                                                        type = Formattable::kDouble;
                                                }
-                                       } else if ((typeString == "date") || (typeString == "time")) {
+                                       } else if ((typeString == ASCII_LITERAL("date")) || (typeString == ASCII_LITERAL("time"))) {
                                                type = Formattable::kDate;
-                                       } else if ((typeString == "spellout") || (typeString == "ordinal")
-                                                       || (typeString == "duration")) {
+                                       } else if ((typeString == ASCII_LITERAL("spellout")) || (typeString == ASCII_LITERAL("ordinal"))
+                                                       || (typeString == ASCII_LITERAL("duration"))) {
                                                type = Formattable::kDouble;
                                        }
+#undef ASCII_LITERAL
                                } else {
                                        /* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a
                                         * UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern