From 157f83fcfc7384952a5db5526daf85fbd6e4ab5e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 28 Sep 2011 21:41:31 +0200 Subject: [PATCH] Strip trailing spaces in unicodeobject.[ch] --- Include/unicodeobject.h | 10 +++++----- Objects/unicodeobject.c | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 3538f1a0589..b57c1e5268c 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -356,13 +356,13 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; #define PyUnicode_IS_COMPACT(op) \ (((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) \ (assert(PyUnicode_Check(op)), \ assert(PyUnicode_IS_READY(op)), \ ((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) \ (PyUnicode_IS_COMPACT_ASCII(op) ? \ ((void*)((PyASCIIObject*)(op) + 1)) : \ @@ -509,7 +509,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_New( /* Initializes the canonical string representation from a the deprected 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 more efficient if the string is already ready. */ #ifndef Py_LIMITED_API @@ -641,7 +641,7 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength( PyObject *unicode ); -/* Get the number of Py_UNICODE units in the +/* Get the number of Py_UNICODE units in the string representation. */ 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. - 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 when the unicodeobject is deallocated. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index f9974da4262..ff3d4b6e0a6 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -643,7 +643,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, PyUnicode_KIND_SIZE(to_kind, how_many)); return how_many; } - + if (from_kind > to_kind) { /* slow path to check for character overflow */ 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; } - else if (from_kind == PyUnicode_1BYTE_KIND + else if (from_kind == PyUnicode_1BYTE_KIND && to_kind == PyUnicode_4BYTE_KIND) { _PyUnicode_CONVERT_BYTES( @@ -703,7 +703,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, PyErr_Format(PyExc_ValueError, "Cannot copy UCS%u characters " "into a string of UCS%u characters", - 1 << (from_kind - 1), + 1 << (from_kind - 1), 1 << (to_kind -1)); return -1; } @@ -8155,8 +8155,8 @@ fixup(PyUnicodeObject *self, /* If the maxchar increased so that the kind changed, not all characters are representable anymore and we need to fix the string again. This only happens in very few cases. */ - if (PyUnicode_CopyCharacters(v, 0, - (PyObject*)self, 0, + if (PyUnicode_CopyCharacters(v, 0, + (PyObject*)self, 0, PyUnicode_GET_LENGTH(self)) < 0) { Py_DECREF(u); @@ -8166,8 +8166,8 @@ fixup(PyUnicodeObject *self, assert(maxchar_old > 0 && maxchar_old <= maxchar_new); } else { - if (PyUnicode_CopyCharacters(v, 0, - u, 0, + if (PyUnicode_CopyCharacters(v, 0, + u, 0, PyUnicode_GET_LENGTH(self)) < 0) { Py_DECREF(u); @@ -8558,8 +8558,8 @@ pad(PyUnicodeObject *self, FILL(kind, data, fill, 0, left); if (right) FILL(kind, data, fill, left + _PyUnicode_LENGTH(self), right); - if (PyUnicode_CopyCharacters(u, left, - (PyObject*)self, 0, + if (PyUnicode_CopyCharacters(u, left, + (PyObject*)self, 0, _PyUnicode_LENGTH(self)) < 0) { Py_DECREF(u); @@ -9479,7 +9479,7 @@ PyUnicode_Concat(PyObject *left, PyObject *right) goto onError; if (PyUnicode_CopyCharacters(w, 0, u, 0, PyUnicode_GET_LENGTH(u)) < 0) goto onError; - if (PyUnicode_CopyCharacters(w, PyUnicode_GET_LENGTH(u), + if (PyUnicode_CopyCharacters(w, PyUnicode_GET_LENGTH(u), v, 0, PyUnicode_GET_LENGTH(v)) < 0) goto onError;