diff options
Diffstat (limited to 'Objects/stringlib/partition.h')
-rw-r--r-- | Objects/stringlib/partition.h | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h index ed32a6f..0170bdd 100644 --- a/Objects/stringlib/partition.h +++ b/Objects/stringlib/partition.h @@ -1,11 +1,14 @@ /* stringlib: partition implementation */ +#ifndef STRINGLIB_PARTITION_H +#define STRINGLIB_PARTITION_H + #ifndef STRINGLIB_FASTSEARCH_H #error must include "stringlib/fastsearch.h" before including this module #endif Py_LOCAL_INLINE(PyObject*) -STRINGLIB(partition)(PyObject* str_obj, +stringlib_partition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) @@ -22,18 +25,13 @@ STRINGLIB(partition)(PyObject* str_obj, if (!out) return NULL; - pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); + pos = fastsearch(str, str_len, sep, sep_len, -1, FAST_SEARCH); if (pos < 0) { #if STRINGLIB_MUTABLE PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); - - if (PyErr_Occurred()) { - Py_DECREF(out); - return NULL; - } #else Py_INCREF(str_obj); PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); @@ -60,7 +58,7 @@ STRINGLIB(partition)(PyObject* str_obj, } Py_LOCAL_INLINE(PyObject*) -STRINGLIB(rpartition)(PyObject* str_obj, +stringlib_rpartition(PyObject* str_obj, const STRINGLIB_CHAR* str, Py_ssize_t str_len, PyObject* sep_obj, const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) @@ -77,18 +75,13 @@ STRINGLIB(rpartition)(PyObject* str_obj, if (!out) return NULL; - pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); + pos = fastsearch(str, str_len, sep, sep_len, -1, FAST_RSEARCH); if (pos < 0) { #if STRINGLIB_MUTABLE PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); - - if (PyErr_Occurred()) { - Py_DECREF(out); - return NULL; - } #else Py_INCREF(STRINGLIB_EMPTY); PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); @@ -114,3 +107,4 @@ STRINGLIB(rpartition)(PyObject* str_obj, return out; } +#endif |