mirror of https://github.com/python/cpython
Strip trailing spaces in unicodeobject.[ch]
This commit is contained in:
parent
6c7a52a46f
commit
157f83fcfc
|
@ -356,13 +356,13 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
|
||||||
#define PyUnicode_IS_COMPACT(op) \
|
#define PyUnicode_IS_COMPACT(op) \
|
||||||
(((PyASCIIObject*)(op))->state.compact)
|
(((PyASCIIObject*)(op))->state.compact)
|
||||||
|
|
||||||
/* Return one of the PyUnicode_*_KIND values defined above. */
|
/* Return one of the PyUnicode_*_KIND values defined above. */
|
||||||
#define PyUnicode_KIND(op) \
|
#define PyUnicode_KIND(op) \
|
||||||
(assert(PyUnicode_Check(op)), \
|
(assert(PyUnicode_Check(op)), \
|
||||||
assert(PyUnicode_IS_READY(op)), \
|
assert(PyUnicode_IS_READY(op)), \
|
||||||
((PyASCIIObject *)(op))->state.kind)
|
((PyASCIIObject *)(op))->state.kind)
|
||||||
|
|
||||||
/* Return a void pointer to the raw unicode buffer. */
|
/* Return a void pointer to the raw unicode buffer. */
|
||||||
#define _PyUnicode_COMPACT_DATA(op) \
|
#define _PyUnicode_COMPACT_DATA(op) \
|
||||||
(PyUnicode_IS_COMPACT_ASCII(op) ? \
|
(PyUnicode_IS_COMPACT_ASCII(op) ? \
|
||||||
((void*)((PyASCIIObject*)(op) + 1)) : \
|
((void*)((PyASCIIObject*)(op) + 1)) : \
|
||||||
|
@ -509,7 +509,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_New(
|
||||||
|
|
||||||
/* Initializes the canonical string representation from a the deprected
|
/* Initializes the canonical string representation from a the deprected
|
||||||
wstr/Py_UNICODE representation. This function is used to convert
|
wstr/Py_UNICODE representation. This function is used to convert
|
||||||
unicode objects which were created using the old API to the new flexible
|
unicode objects which were created using the old API to the new flexible
|
||||||
format introduced with PEP 393. The PyUnicode_READY() macro can be
|
format introduced with PEP 393. The PyUnicode_READY() macro can be
|
||||||
more efficient if the string is already ready. */
|
more efficient if the string is already ready. */
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
|
@ -641,7 +641,7 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength(
|
||||||
PyObject *unicode
|
PyObject *unicode
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Get the number of Py_UNICODE units in the
|
/* Get the number of Py_UNICODE units in the
|
||||||
string representation. */
|
string representation. */
|
||||||
|
|
||||||
PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
|
PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
|
||||||
|
@ -857,7 +857,7 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
|
||||||
|
|
||||||
In case of an error, no *size is set.
|
In case of an error, no *size is set.
|
||||||
|
|
||||||
This funcation caches the UTF-8 encoded string in the unicodeobject
|
This funcation caches the UTF-8 encoded string in the unicodeobject
|
||||||
and subsequent calls will return the same string. The memory is relased
|
and subsequent calls will return the same string. The memory is relased
|
||||||
when the unicodeobject is deallocated.
|
when the unicodeobject is deallocated.
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
|
||||||
PyUnicode_KIND_SIZE(to_kind, how_many));
|
PyUnicode_KIND_SIZE(to_kind, how_many));
|
||||||
return how_many;
|
return how_many;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_kind > to_kind) {
|
if (from_kind > to_kind) {
|
||||||
/* slow path to check for character overflow */
|
/* slow path to check for character overflow */
|
||||||
const Py_UCS4 to_maxchar = PyUnicode_MAX_CHAR_VALUE(to);
|
const Py_UCS4 to_maxchar = PyUnicode_MAX_CHAR_VALUE(to);
|
||||||
|
@ -678,7 +678,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
|
||||||
);
|
);
|
||||||
return how_many;
|
return how_many;
|
||||||
}
|
}
|
||||||
else if (from_kind == PyUnicode_1BYTE_KIND
|
else if (from_kind == PyUnicode_1BYTE_KIND
|
||||||
&& to_kind == PyUnicode_4BYTE_KIND)
|
&& to_kind == PyUnicode_4BYTE_KIND)
|
||||||
{
|
{
|
||||||
_PyUnicode_CONVERT_BYTES(
|
_PyUnicode_CONVERT_BYTES(
|
||||||
|
@ -703,7 +703,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
"Cannot copy UCS%u characters "
|
"Cannot copy UCS%u characters "
|
||||||
"into a string of UCS%u characters",
|
"into a string of UCS%u characters",
|
||||||
1 << (from_kind - 1),
|
1 << (from_kind - 1),
|
||||||
1 << (to_kind -1));
|
1 << (to_kind -1));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -8155,8 +8155,8 @@ fixup(PyUnicodeObject *self,
|
||||||
/* If the maxchar increased so that the kind changed, not all
|
/* If the maxchar increased so that the kind changed, not all
|
||||||
characters are representable anymore and we need to fix the
|
characters are representable anymore and we need to fix the
|
||||||
string again. This only happens in very few cases. */
|
string again. This only happens in very few cases. */
|
||||||
if (PyUnicode_CopyCharacters(v, 0,
|
if (PyUnicode_CopyCharacters(v, 0,
|
||||||
(PyObject*)self, 0,
|
(PyObject*)self, 0,
|
||||||
PyUnicode_GET_LENGTH(self)) < 0)
|
PyUnicode_GET_LENGTH(self)) < 0)
|
||||||
{
|
{
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
|
@ -8166,8 +8166,8 @@ fixup(PyUnicodeObject *self,
|
||||||
assert(maxchar_old > 0 && maxchar_old <= maxchar_new);
|
assert(maxchar_old > 0 && maxchar_old <= maxchar_new);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (PyUnicode_CopyCharacters(v, 0,
|
if (PyUnicode_CopyCharacters(v, 0,
|
||||||
u, 0,
|
u, 0,
|
||||||
PyUnicode_GET_LENGTH(self)) < 0)
|
PyUnicode_GET_LENGTH(self)) < 0)
|
||||||
{
|
{
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
|
@ -8558,8 +8558,8 @@ pad(PyUnicodeObject *self,
|
||||||
FILL(kind, data, fill, 0, left);
|
FILL(kind, data, fill, 0, left);
|
||||||
if (right)
|
if (right)
|
||||||
FILL(kind, data, fill, left + _PyUnicode_LENGTH(self), right);
|
FILL(kind, data, fill, left + _PyUnicode_LENGTH(self), right);
|
||||||
if (PyUnicode_CopyCharacters(u, left,
|
if (PyUnicode_CopyCharacters(u, left,
|
||||||
(PyObject*)self, 0,
|
(PyObject*)self, 0,
|
||||||
_PyUnicode_LENGTH(self)) < 0)
|
_PyUnicode_LENGTH(self)) < 0)
|
||||||
{
|
{
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
|
@ -9479,7 +9479,7 @@ PyUnicode_Concat(PyObject *left, PyObject *right)
|
||||||
goto onError;
|
goto onError;
|
||||||
if (PyUnicode_CopyCharacters(w, 0, u, 0, PyUnicode_GET_LENGTH(u)) < 0)
|
if (PyUnicode_CopyCharacters(w, 0, u, 0, PyUnicode_GET_LENGTH(u)) < 0)
|
||||||
goto onError;
|
goto onError;
|
||||||
if (PyUnicode_CopyCharacters(w, PyUnicode_GET_LENGTH(u),
|
if (PyUnicode_CopyCharacters(w, PyUnicode_GET_LENGTH(u),
|
||||||
v, 0,
|
v, 0,
|
||||||
PyUnicode_GET_LENGTH(v)) < 0)
|
PyUnicode_GET_LENGTH(v)) < 0)
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
Loading…
Reference in New Issue