Commit 85d9b64b authored by Stefan Behnel's avatar Stefan Behnel

cleanup, fix copy&paste error in generic unicode indexing

parent f9d67af3
...@@ -8426,19 +8426,11 @@ proto = ''' ...@@ -8426,19 +8426,11 @@ proto = '''
__Pyx_GetItemInt_Unicode_Generic(o, to_py_func(i))) __Pyx_GetItemInt_Unicode_Generic(o, to_py_func(i)))
static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i) { static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i) {
#ifdef CYTHON_PEP393_ENABLED const Py_ssize_t length = __Pyx_PyUnicode_GET_LENGTH(ustring);
if (likely((0 <= i) & (i < PyUnicode_GET_LENGTH(ustring)))) { if (likely((0 <= i) & (i < length))) {
return PyUnicode_READ_CHAR(ustring, i); return __Pyx_PyUnicode_READ_CHAR(ustring, i);
} else if ((-PyUnicode_GET_LENGTH(ustring) <= i) & (i < 0)) { } else if ((-length <= i) & (i < 0)) {
i += PyUnicode_GET_LENGTH(ustring); return __Pyx_PyUnicode_READ_CHAR(ustring, i + length);
return PyUnicode_READ_CHAR(ustring, i);
#else
if (likely((0 <= i) & (i < PyUnicode_GET_SIZE(ustring)))) {
return (Py_UCS4)PyUnicode_AS_UNICODE(ustring)[i];
} else if ((-PyUnicode_GET_SIZE(ustring) <= i) & (i < 0)) {
i += PyUnicode_GET_SIZE(ustring);
return (Py_UCS4)PyUnicode_AS_UNICODE(ustring)[i];
#endif
} else { } else {
PyErr_SetString(PyExc_IndexError, "string index out of range"); PyErr_SetString(PyExc_IndexError, "string index out of range");
return (Py_UCS4)-1; return (Py_UCS4)-1;
...@@ -8452,11 +8444,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring, ...@@ -8452,11 +8444,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring,
uchar_string = PyObject_GetItem(ustring, j); uchar_string = PyObject_GetItem(ustring, j);
Py_DECREF(j); Py_DECREF(j);
if (!uchar_string) return (Py_UCS4)-1; if (!uchar_string) return (Py_UCS4)-1;
#ifdef CYTHON_PEP393_ENABLED uchar = __Pyx_PyUnicode_READ_CHAR(uchar_string, 0);
uchar = PyUnicode_READ_CHAR(uchar_string, 0);
#else
uchar = (Py_UCS4)PyUnicode_AS_UNICODE(ustring)[0];
#endif
Py_DECREF(uchar_string); Py_DECREF(uchar_string);
return uchar; return uchar;
} }
......
...@@ -579,13 +579,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -579,13 +579,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#endif #endif
/* new Py3.3 unicode representation (PEP 393) */ /* new Py3.3 unicode representation (PEP 393) */
#ifdef PyUnicode_GET_LENGTH #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
#define CYTHON_PEP393_ENABLED #define CYTHON_PEP393_ENABLED
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else #else
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) (PyUnicode_AS_UNICODE(u)[i]) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#endif #endif
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment