mirror of
https://github.com/python/cpython.git
synced 2025-09-22 08:23:36 +00:00
Fix #4846 (Py_UNICODE_ISSPACE causes linker error) by moving the declaration
into the extern "C" section. Add a few more comments and apply some minor edits to make the file contents fit the original structure again.
This commit is contained in:
parent
f99b0110a8
commit
3741bfdd3c
1 changed files with 28 additions and 10 deletions
|
@ -130,6 +130,10 @@ typedef unsigned int Py_UCS4;
|
||||||
typedef unsigned long Py_UCS4;
|
typedef unsigned long Py_UCS4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Py_UNICODE is the native Unicode storage format (code unit) used by
|
||||||
|
Python and represents a single Unicode element in the Unicode
|
||||||
|
type. */
|
||||||
|
|
||||||
typedef PY_UNICODE_TYPE Py_UNICODE;
|
typedef PY_UNICODE_TYPE Py_UNICODE;
|
||||||
|
|
||||||
/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
|
/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
|
||||||
|
@ -350,12 +354,12 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Since splitting on whitespace is an important use case, and whitespace
|
/* Since splitting on whitespace is an important use case, and
|
||||||
in most situations is solely ASCII whitespace, we optimize for the common
|
whitespace in most situations is solely ASCII whitespace, we
|
||||||
case by using a quick look-up table with an inlined check.
|
optimize for the common case by using a quick look-up table
|
||||||
*/
|
_Py_ascii_whitespace (see below) with an inlined check.
|
||||||
PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
|
|
||||||
|
|
||||||
|
*/
|
||||||
#define Py_UNICODE_ISSPACE(ch) \
|
#define Py_UNICODE_ISSPACE(ch) \
|
||||||
((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
|
((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
|
||||||
|
|
||||||
|
@ -389,13 +393,14 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
|
||||||
#define Py_UNICODE_COPY(target, source, length) \
|
#define Py_UNICODE_COPY(target, source, length) \
|
||||||
Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE))
|
Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE))
|
||||||
|
|
||||||
#define Py_UNICODE_FILL(target, value, length) do\
|
#define Py_UNICODE_FILL(target, value, length) \
|
||||||
{Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
|
do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
|
||||||
for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
|
for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* check if substring matches at given offset. the offset must be
|
/* Check if substring matches at given offset. the offset must be
|
||||||
valid, and the substring must not be empty */
|
valid, and the substring must not be empty */
|
||||||
|
|
||||||
#define Py_UNICODE_MATCH(string, offset, substring) \
|
#define Py_UNICODE_MATCH(string, offset, substring) \
|
||||||
((*((string)->str + (offset)) == *((substring)->str)) && \
|
((*((string)->str + (offset)) == *((substring)->str)) && \
|
||||||
((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
|
((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
|
||||||
|
@ -405,8 +410,6 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
|
|
||||||
|
|
||||||
/* --- Unicode Type ------------------------------------------------------- */
|
/* --- Unicode Type ------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -605,6 +608,17 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal);
|
PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal);
|
||||||
|
|
||||||
|
/* --- Free-list management ----------------------------------------------- */
|
||||||
|
|
||||||
|
/* Clear the free list used by the Unicode implementation.
|
||||||
|
|
||||||
|
This can be used to release memory used for objects on the free
|
||||||
|
list back to the Python memory allocator.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
|
||||||
|
|
||||||
/* === Builtin Codecs =====================================================
|
/* === Builtin Codecs =====================================================
|
||||||
|
|
||||||
Many of these APIs take two arguments encoding and errors. These
|
Many of these APIs take two arguments encoding and errors. These
|
||||||
|
@ -1323,6 +1337,10 @@ PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
|
||||||
|
|
||||||
/* === Characters Type APIs =============================================== */
|
/* === Characters Type APIs =============================================== */
|
||||||
|
|
||||||
|
/* Helper array used by Py_UNICODE_ISSPACE(). */
|
||||||
|
|
||||||
|
PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
|
||||||
|
|
||||||
/* These should not be used directly. Use the Py_UNICODE_IS* and
|
/* These should not be used directly. Use the Py_UNICODE_IS* and
|
||||||
Py_UNICODE_TO* macros instead.
|
Py_UNICODE_TO* macros instead.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue