gh-139353: Rename formatter_unicode.c to unicode_formatter.c (#139723)
* Move Python/formatter_unicode.c to Objects/unicode_formatter.c. * Move Objects/stringlib/localeutil.h content into unicode_formatter.c. Remove localeutil.h. * Move _PyUnicode_InsertThousandsGrouping() to unicode_formatter.c and mark the function as static. * Rename unicode_fill() to _PyUnicode_Fill() and export it in pycore_unicodeobject.h. * Move MAX_UNICODE to pycore_unicodeobject.h as _Py_MAX_UNICODE.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "pycore_fileutils.h" // fileutils definitions
|
||||
#include "pycore_runtime.h" // _PyRuntime
|
||||
#include "pycore_pystate.h" // _Py_AssertHoldsTstate()
|
||||
#include "pycore_unicodeobject.h" // _Py_MAX_UNICODE
|
||||
#include "osdefs.h" // SEP
|
||||
|
||||
#include <stdlib.h> // mbstowcs()
|
||||
@@ -50,9 +51,6 @@ extern int winerror_to_errno(int);
|
||||
int _Py_open_cloexec_works = -1;
|
||||
#endif
|
||||
|
||||
// The value must be the same in unicodeobject.c.
|
||||
#define MAX_UNICODE 0x10ffff
|
||||
|
||||
// mbstowcs() and mbrtowc() errors
|
||||
static const size_t DECODE_ERROR = ((size_t)-1);
|
||||
#ifdef HAVE_MBRTOWC
|
||||
@@ -123,7 +121,7 @@ is_valid_wide_char(wchar_t ch)
|
||||
{
|
||||
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
|
||||
/* Oracle Solaris doesn't use Unicode code points as wchar_t encoding
|
||||
for non-Unicode locales, which makes values higher than MAX_UNICODE
|
||||
for non-Unicode locales, which makes values higher than _Py_MAX_UNICODE
|
||||
possibly valid. */
|
||||
return 1;
|
||||
#endif
|
||||
@@ -132,7 +130,7 @@ is_valid_wide_char(wchar_t ch)
|
||||
return 0;
|
||||
}
|
||||
#if SIZEOF_WCHAR_T > 2
|
||||
if (ch > MAX_UNICODE) {
|
||||
if (ch > _Py_MAX_UNICODE) {
|
||||
// bpo-35883: Reject characters outside [U+0000; U+10ffff] range.
|
||||
// The glibc mbstowcs() UTF-8 decoder does not respect the RFC 3629,
|
||||
// it creates characters outside the [U+0000; U+10ffff] range:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user