[php-src] master: intl: refactor intl_convertcpp.cpp

From: Date: Sat, 24 Oct 2026 14:44:32 +0000
Subject: [php-src] master: intl: refactor intl_convertcpp.cpp
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142680@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-10-24T15:43:59+01:00 Commit: https://github.com/php/php-src/commit/97374e0bd8e54907dc80b0cd73d543f67bdffbd2 Raw diff: https://github.com/php/php-src/commit/97374e0bd8e54907dc80b0cd73d543f67bdffbd2.diff intl: refactor intl_convertcpp.cpp Changed paths: M ext/intl/intl_convertcpp.cpp M ext/intl/intl_convertcpp.h Diff: diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp index e8ad587c2689..d22dc994f80a 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 ef4310bac4ff..d3bb6c8cf07e 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);

« previous php.cvs (#142680) next »