diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-01-13 02:10:29 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-01-13 02:10:29 (GMT) |
commit | e51757f6de9db71b7ee0a6cbf7dde62e9f146804 (patch) | |
tree | 8682a85618189136e77583e0d8616010bb4eec36 | |
parent | 3a5d4cb940d9f06505b0b65916fd9a844bed13e3 (diff) | |
download | cpython-e51757f6de9db71b7ee0a6cbf7dde62e9f146804.zip cpython-e51757f6de9db71b7ee0a6cbf7dde62e9f146804.tar.gz cpython-e51757f6de9db71b7ee0a6cbf7dde62e9f146804.tar.bz2 |
move do_title to a better place
-rw-r--r-- | Objects/unicodeobject.c | 56 |
1 files 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) { |