From e51757f6de9db71b7ee0a6cbf7dde62e9f146804 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 12 Jan 2012 21:10:29 -0500 Subject: move do_title to a better place --- Objects/unicodeobject.c | 56 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 034c691..471d98b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9576,6 +9576,34 @@ do_lower(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar return do_upper_or_lower(kind, data, length, res, maxchar, 1); } +static Py_ssize_t +do_title(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar) +{ + Py_ssize_t i, k = 0; + int previous_is_cased; + + previous_is_cased = 0; + for (i = 0; i < length; i++) { + const Py_UCS4 c = PyUnicode_READ(kind, data, i); + Py_UCS4 mapped[3]; + int n_res, j; + + if (previous_is_cased) + n_res = lower_ucs4(kind, data, length, i, c, mapped); + else + n_res = _PyUnicode_ToTitleFull(c, mapped); + + for (j = 0; j < n_res; j++) { + if (mapped[j] > *maxchar) + *maxchar = mapped[j]; + res[k++] = mapped[j]; + } + + previous_is_cased = _PyUnicode_IsCased(c); + } + return k; +} + static PyObject * case_operation(PyObject *self, Py_ssize_t (*perform)(int, void *, Py_ssize_t, Py_UCS4 *, Py_UCS4 *)) @@ -9621,34 +9649,6 @@ case_operation(PyObject *self, return res; } -static Py_ssize_t -do_title(int kind, void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *maxchar) -{ - Py_ssize_t i, k = 0; - int previous_is_cased; - - previous_is_cased = 0; - for (i = 0; i < length; i++) { - const Py_UCS4 c = PyUnicode_READ(kind, data, i); - Py_UCS4 mapped[3]; - int n_res, j; - - if (previous_is_cased) - n_res = lower_ucs4(kind, data, length, i, c, mapped); - else - n_res = _PyUnicode_ToTitleFull(c, mapped); - - for (j = 0; j < n_res; j++) { - if (mapped[j] > *maxchar) - *maxchar = mapped[j]; - res[k++] = mapped[j]; - } - - previous_is_cased = _PyUnicode_IsCased(c); - } - return k; -} - PyObject * PyUnicode_Join(PyObject *separator, PyObject *seq) { -- cgit v0.12