From b220df18d32605b1a061ead1c7efe9b7dded6f4e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Oct 2022 23:45:40 +0100 Subject: [PATCH] Update some comments after ANSI build removal No real changes, just correct outdated comments. --- src/common/string.cpp | 23 +++++++++-------------- src/common/strvararg.cpp | 5 ++--- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index 875a3f37c9..fbab1cce13 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -508,9 +508,9 @@ const wchar_t *wxString::AsWChar(const wxMBConv& conv) const // Same thing for mb_str() which returns a normal char pointer to string -// contents: this always requires converting it to the specified encoding in -// non-ANSI build except if we need to convert to UTF-8 and this is what we -// already use internally. +// contents: this always requires converting it to the specified encoding +// except if we need to convert to UTF-8 and this is what we already use +// internally. const char *wxString::AsChar(const wxMBConv& conv) const { #if wxUSE_UNICODE_UTF8 @@ -861,10 +861,10 @@ int wxString::compare(size_t nStart, size_t nLen, #if !wxUSE_STL_BASED_WXSTRING || wxUSE_UNICODE_UTF8 -// NB: All these functions are implemented with the argument being wxChar*, -// i.e. widechar string in any Unicode build, even though native string -// representation is char* in the UTF-8 build. This is because we couldn't -// use memchr() to determine if a character is in a set encoded as UTF-8. +// NB: All these functions are implemented with the argument always being +// wchar_t*, even in UTF-8 build in which the native string representation +// is char*. This is because we couldn't use memchr() to determine if a +// character is in a set encoded as UTF-8. size_t wxString::find_first_of(const wxChar* sz, size_t nStart) const { @@ -1943,13 +1943,8 @@ int wxString::DoPrintfUtf8(const char *format, ...) /* Uses wxVsnprintf and places the result into the this string. - In ANSI build, wxVsnprintf is effectively vsnprintf but in Unicode build - it is vswprintf. Due to a discrepancy between vsnprintf and vswprintf in - the ISO C99 (and thus SUSv3) standard the return value for the case of - an undersized buffer is inconsistent. For conforming vsnprintf - implementations the function must return the number of characters that - would have been printed had the buffer been large enough, which is useful. - Unfortunately, for conforming vswprintf implementations, the function must + wxVsnprintf() is effectively vswprintf() and, according to ISO C99 (and + thus SUSv3) standard, a conforming vswprintf implementations must just return a negative number and is not even required to set errno, which makes the standard behaviour totally useless as there is no way to determine if the error occurred due to a (fatal) problem with either the diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index 5c16483714..fa6fb40bdd 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -562,9 +562,8 @@ const char* wxFormatString::InputAsChar() if ( m_char ) return m_char.data(); - // in ANSI build, wx_str() returns char*, in UTF-8 build, this function - // is only called under UTF-8 locales, so we should return UTF-8 string, - // which is, again, what wx_str() returns: + // in this build, wx_str() returns UTF-8-encoded string and this function + // is only called under UTF-8 locales, so we can just return it directly if ( m_str ) return m_str->wx_str();