Commit 97374e0bd8e for php
commit 97374e0bd8e54907dc80b0cd73d543f67bdffbd2
Author: Gina Peter Banyard <girgias@php.net>
Date: Fri Oct 16 21:51:47 2026 +0100
intl: refactor intl_convertcpp.cpp
diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp
index e8ad587c268..d22dc994f80 100644
--- a/ext/intl/intl_convertcpp.cpp
+++ b/ext/intl/intl_convertcpp.cpp
@@ -16,10 +16,11 @@
#include "intl_convertcpp.h"
#include <unicode/ustring.h>
-#include <php.h>
+#include <zend_types.h>
+#include <zend_string.h>
/* {{{ intl_stringFromChar */
-int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
+zend_result intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
{
if(UNEXPECTED(str_len > INT32_MAX)) {
*status = U_BUFFER_OVERFLOW_ERROR;
@@ -55,14 +56,14 @@ zend_string* intl_charFromString(const UnicodeString &from, UErrorCode *status)
zend_string *u8res;
if (UNEXPECTED(from.isBogus())) {
- return NULL;
+ return nullptr;
}
//the number of UTF-8 code units is not larger than that of UTF-16 code
//units * 3
if (UNEXPECTED(from.length() > INT32_MAX / 3)) {
*status = U_BUFFER_OVERFLOW_ERROR;
- return NULL;
+ return nullptr;
}
int32_t capacity = from.length() * 3;
@@ -75,11 +76,11 @@ zend_string* intl_charFromString(const UnicodeString &from, UErrorCode *status)
const UChar *utf16buf = from.getBuffer();
int32_t actual_len;
u_strToUTF8WithSub(ZSTR_VAL(u8res), capacity + 1, &actual_len, utf16buf, from.length(),
- U_SENTINEL, NULL, status);
+ U_SENTINEL, nullptr, status);
if (U_FAILURE(*status)) {
zend_string_free(u8res);
- return NULL;
+ return nullptr;
}
u8res = zend_string_truncate(u8res, actual_len, 0);
diff --git a/ext/intl/intl_convertcpp.h b/ext/intl/intl_convertcpp.h
index ef4310bac4f..d3bb6c8cf07 100644
--- a/ext/intl/intl_convertcpp.h
+++ b/ext/intl/intl_convertcpp.h
@@ -24,7 +24,7 @@
using icu::UnicodeString;
-int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
+zend_result intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
zend_string* intl_charFromString(const UnicodeString &from, UErrorCode *status);