Browse Source

Use recommended options for explicit UnicodeString constructors

pull/3207/merge
Anatol Belski 8 years ago
parent
commit
08178ed231
  1. 3
      acinclude.m4
  2. 2
      ext/intl/config.w32
  3. 16
      ext/intl/msgformat/msgformat_helpers.cpp

3
acinclude.m4

@ -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
])

2
ext/intl/config.w32

@ -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");

16
ext/intl/msgformat/msgformat_helpers.cpp

@ -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

Loading…
Cancel
Save