Skip to content

Commit 08178ed

Browse files
committed
Use recommended options for explicit UnicodeString constructors
1 parent a9ab5d4 commit 08178ed

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

acinclude.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,9 @@ AC_DEFUN([PHP_SETUP_ICU],[
22392239
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
22402240
22412241
ICU_EXTRA_FLAGS=`$ICU_CONFIG --cxxflags`
2242+
if test "$icu_version" -lt "49000"; then
2243+
ICU_EXTRA_FLAGS="$ICU_EXTRA_FLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
2244+
fi
22422245
fi
22432246
])
22442247

ext/intl/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ if (PHP_INTL != "no") {
129129
ADD_FLAG("LIBS_INTL", "iculx.lib");
130130
}
131131

132-
ADD_FLAG("CFLAGS_INTL", "/EHsc");
132+
ADD_FLAG("CFLAGS_INTL", "/EHsc /DUNISTR_FROM_CHAR_EXPLICIT=explicit /DUNISTR_FROM_STRING_EXPLICIT=explicit");
133133
AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
134134
} else {
135135
WARNING("intl not enabled; libraries and/or headers not found");

ext/intl/msgformat/msgformat_helpers.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,28 +237,30 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
237237
UnicodeString typeString = mp.getSubstring(type_part);
238238
/* This is all based on the rules in the docs for MessageFormat
239239
* @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */
240-
if (typeString == "number") {
240+
#define ASCII_LITERAL(s) UNICODE_STRING(s, sizeof(s)-1)
241+
if (typeString == ASCII_LITERAL("number")) {
241242
MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */
242243
if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) {
243244
UnicodeString styleString = mp.getSubstring(style_part);
244-
if (styleString == "integer") {
245+
if (styleString == ASCII_LITERAL("integer")) {
245246
type = Formattable::kInt64;
246-
} else if (styleString == "currency") {
247+
} else if (styleString == ASCII_LITERAL("currency")) {
247248
type = Formattable::kDouble;
248-
} else if (styleString == "percent") {
249+
} else if (styleString == ASCII_LITERAL("percent")) {
249250
type = Formattable::kDouble;
250251
} else { /* some style invalid/unknown to us */
251252
type = Formattable::kDouble;
252253
}
253254
} else { // if missing style, part, make it a double
254255
type = Formattable::kDouble;
255256
}
256-
} else if ((typeString == "date") || (typeString == "time")) {
257+
} else if ((typeString == ASCII_LITERAL("date")) || (typeString == ASCII_LITERAL("time"))) {
257258
type = Formattable::kDate;
258-
} else if ((typeString == "spellout") || (typeString == "ordinal")
259-
|| (typeString == "duration")) {
259+
} else if ((typeString == ASCII_LITERAL("spellout")) || (typeString == ASCII_LITERAL("ordinal"))
260+
|| (typeString == ASCII_LITERAL("duration"))) {
260261
type = Formattable::kDouble;
261262
}
263+
#undef ASCII_LITERAL
262264
} else {
263265
/* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a
264266
* UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern

0 commit comments

Comments
 (0)