/home/mdboom/Work/builds/cpython/Objects/stringlib/partition.h
Line | Count | Source (jump to first uncovered line) |
1 | /* stringlib: partition implementation */ |
2 | |
3 | #ifndef STRINGLIB_FASTSEARCH_H |
4 | # error must include "stringlib/fastsearch.h" before including this module |
5 | #endif |
6 | |
7 | #if !STRINGLIB_MUTABLE && !defined(STRINGLIB_GET_EMPTY) |
8 | # error "STRINGLIB_GET_EMPTY must be defined if STRINGLIB_MUTABLE is zero" |
9 | #endif |
10 | |
11 | |
12 | Py_LOCAL_INLINE(PyObject*) |
13 | STRINGLIB(partition)(PyObject* str_obj, |
14 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
15 | PyObject* sep_obj, |
16 | const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) |
17 | { |
18 | PyObject* out; |
19 | Py_ssize_t pos; |
20 | |
21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 5]
Branch (21:9): [True: 0, False: 882]
Branch (21:9): [True: 2, False: 75.9k]
Branch (21:9): [True: 0, False: 2.16k]
Branch (21:9): [True: 0, False: 65]
Branch (21:9): [True: 0, False: 16]
|
22 | PyErr_SetString(PyExc_ValueError, "empty separator"); |
23 | return NULL; |
24 | } |
25 | |
26 | out = PyTuple_New(3); |
27 | if (!out) Branch (27:9): [True: 0, False: 5]
Branch (27:9): [True: 0, False: 882]
Branch (27:9): [True: 0, False: 75.9k]
Branch (27:9): [True: 0, False: 2.16k]
Branch (27:9): [True: 0, False: 65]
Branch (27:9): [True: 0, False: 16]
|
28 | return NULL; |
29 | |
30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); |
31 | |
32 | if (pos < 0) { Branch (32:9): [True: 4, False: 1]
Branch (32:9): [True: 427, False: 455]
Branch (32:9): [True: 24.7k, False: 51.1k]
Branch (32:9): [True: 214, False: 1.95k]
Branch (32:9): [True: 12, False: 53]
Branch (32:9): [True: 6, False: 10]
|
33 | #if STRINGLIB_MUTABLE |
34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); |
35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); |
36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); |
37 | |
38 | if (PyErr_Occurred()) { Branch (38:13): [True: 0, False: 4]
|
39 | Py_DECREF(out); |
40 | return NULL; |
41 | } |
42 | #else |
43 | Py_INCREF(str_obj); |
44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); |
45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); |
46 | assert(empty != NULL); |
47 | Py_INCREF(empty); |
48 | PyTuple_SET_ITEM(out, 1, empty); |
49 | Py_INCREF(empty); |
50 | PyTuple_SET_ITEM(out, 2, empty); |
51 | #endif |
52 | return out; |
53 | } |
54 | |
55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); |
56 | Py_INCREF(sep_obj); |
57 | PyTuple_SET_ITEM(out, 1, sep_obj); |
58 | pos += sep_len; |
59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); |
60 | |
61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 1]
Branch (61:9): [True: 0, False: 455]
Branch (61:9): [True: 0, False: 51.1k]
Branch (61:9): [True: 0, False: 1.95k]
Branch (61:9): [True: 0, False: 53]
Branch (61:9): [True: 0, False: 10]
|
62 | Py_DECREF(out); |
63 | return NULL; |
64 | } |
65 | |
66 | return out; |
67 | } bytearrayobject.c:stringlib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 5]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 5]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 4, False: 1]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { Branch (38:13): [True: 0, False: 4]
| 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 1]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
bytesobject.c:stringlib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 882]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 882]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 427, False: 455]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { | 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 455]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
unicodeobject.c:asciilib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 2, False: 75.9k]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 75.9k]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 24.7k, False: 51.1k]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { | 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 51.1k]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
unicodeobject.c:ucs1lib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 2.16k]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 2.16k]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 214, False: 1.95k]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { | 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 1.95k]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
unicodeobject.c:ucs2lib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 65]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 65]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 12, False: 53]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { | 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 53]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
unicodeobject.c:ucs4lib_partition Line | Count | Source | 17 | { | 18 | PyObject* out; | 19 | Py_ssize_t pos; | 20 | | 21 | if (sep_len == 0) { Branch (21:9): [True: 0, False: 16]
| 22 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 23 | return NULL; | 24 | } | 25 | | 26 | out = PyTuple_New(3); | 27 | if (!out) Branch (27:9): [True: 0, False: 16]
| 28 | return NULL; | 29 | | 30 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_SEARCH); | 31 | | 32 | if (pos < 0) { Branch (32:9): [True: 6, False: 10]
| 33 | #if STRINGLIB_MUTABLE | 34 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); | 35 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 36 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); | 37 | | 38 | if (PyErr_Occurred()) { | 39 | Py_DECREF(out); | 40 | return NULL; | 41 | } | 42 | #else | 43 | Py_INCREF(str_obj); | 44 | PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); | 45 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 46 | assert(empty != NULL); | 47 | Py_INCREF(empty); | 48 | PyTuple_SET_ITEM(out, 1, empty); | 49 | Py_INCREF(empty); | 50 | PyTuple_SET_ITEM(out, 2, empty); | 51 | #endif | 52 | return out; | 53 | } | 54 | | 55 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 56 | Py_INCREF(sep_obj); | 57 | PyTuple_SET_ITEM(out, 1, sep_obj); | 58 | pos += sep_len; | 59 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 60 | | 61 | if (PyErr_Occurred()) { Branch (61:9): [True: 0, False: 10]
| 62 | Py_DECREF(out); | 63 | return NULL; | 64 | } | 65 | | 66 | return out; | 67 | } |
|
68 | |
69 | Py_LOCAL_INLINE(PyObject*) |
70 | STRINGLIB(rpartition)(PyObject* str_obj, |
71 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
72 | PyObject* sep_obj, |
73 | const STRINGLIB_CHAR* sep, Py_ssize_t sep_len) |
74 | { |
75 | PyObject* out; |
76 | Py_ssize_t pos; |
77 | |
78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 6]
Branch (78:9): [True: 0, False: 341]
Branch (78:9): [True: 2, False: 140k]
Branch (78:9): [True: 0, False: 490]
Branch (78:9): [True: 0, False: 70]
Branch (78:9): [True: 0, False: 16]
|
79 | PyErr_SetString(PyExc_ValueError, "empty separator"); |
80 | return NULL; |
81 | } |
82 | |
83 | out = PyTuple_New(3); |
84 | if (!out) Branch (84:9): [True: 0, False: 6]
Branch (84:9): [True: 0, False: 341]
Branch (84:9): [True: 0, False: 140k]
Branch (84:9): [True: 0, False: 490]
Branch (84:9): [True: 0, False: 70]
Branch (84:9): [True: 0, False: 16]
|
85 | return NULL; |
86 | |
87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); |
88 | |
89 | if (pos < 0) { Branch (89:9): [True: 4, False: 2]
Branch (89:9): [True: 315, False: 26]
Branch (89:9): [True: 89.3k, False: 51.5k]
Branch (89:9): [True: 94, False: 396]
Branch (89:9): [True: 64, False: 6]
Branch (89:9): [True: 6, False: 10]
|
90 | #if STRINGLIB_MUTABLE |
91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); |
92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); |
93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); |
94 | |
95 | if (PyErr_Occurred()) { Branch (95:13): [True: 0, False: 4]
|
96 | Py_DECREF(out); |
97 | return NULL; |
98 | } |
99 | #else |
100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); |
101 | assert(empty != NULL); |
102 | Py_INCREF(empty); |
103 | PyTuple_SET_ITEM(out, 0, empty); |
104 | Py_INCREF(empty); |
105 | PyTuple_SET_ITEM(out, 1, empty); |
106 | Py_INCREF(str_obj); |
107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); |
108 | #endif |
109 | return out; |
110 | } |
111 | |
112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); |
113 | Py_INCREF(sep_obj); |
114 | PyTuple_SET_ITEM(out, 1, sep_obj); |
115 | pos += sep_len; |
116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); |
117 | |
118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 2]
Branch (118:9): [True: 0, False: 26]
Branch (118:9): [True: 0, False: 51.5k]
Branch (118:9): [True: 0, False: 396]
Branch (118:9): [True: 0, False: 6]
Branch (118:9): [True: 0, False: 10]
|
119 | Py_DECREF(out); |
120 | return NULL; |
121 | } |
122 | |
123 | return out; |
124 | } bytearrayobject.c:stringlib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 6]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 6]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 4, False: 2]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { Branch (95:13): [True: 0, False: 4]
| 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 2]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
bytesobject.c:stringlib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 341]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 341]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 315, False: 26]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { | 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 26]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
unicodeobject.c:asciilib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 2, False: 140k]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 140k]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 89.3k, False: 51.5k]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { | 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 51.5k]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
unicodeobject.c:ucs1lib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 490]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 490]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 94, False: 396]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { | 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 396]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
unicodeobject.c:ucs2lib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 70]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 70]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 64, False: 6]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { | 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 6]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
unicodeobject.c:ucs4lib_rpartition Line | Count | Source | 74 | { | 75 | PyObject* out; | 76 | Py_ssize_t pos; | 77 | | 78 | if (sep_len == 0) { Branch (78:9): [True: 0, False: 16]
| 79 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 80 | return NULL; | 81 | } | 82 | | 83 | out = PyTuple_New(3); | 84 | if (!out) Branch (84:9): [True: 0, False: 16]
| 85 | return NULL; | 86 | | 87 | pos = FASTSEARCH(str, str_len, sep, sep_len, -1, FAST_RSEARCH); | 88 | | 89 | if (pos < 0) { Branch (89:9): [True: 6, False: 10]
| 90 | #if STRINGLIB_MUTABLE | 91 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); | 92 | PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); | 93 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); | 94 | | 95 | if (PyErr_Occurred()) { | 96 | Py_DECREF(out); | 97 | return NULL; | 98 | } | 99 | #else | 100 | PyObject *empty = (PyObject*)STRINGLIB_GET_EMPTY(); | 101 | assert(empty != NULL); | 102 | Py_INCREF(empty); | 103 | PyTuple_SET_ITEM(out, 0, empty); | 104 | Py_INCREF(empty); | 105 | PyTuple_SET_ITEM(out, 1, empty); | 106 | Py_INCREF(str_obj); | 107 | PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); | 108 | #endif | 109 | return out; | 110 | } | 111 | | 112 | PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, pos)); | 113 | Py_INCREF(sep_obj); | 114 | PyTuple_SET_ITEM(out, 1, sep_obj); | 115 | pos += sep_len; | 116 | PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str + pos, str_len - pos)); | 117 | | 118 | if (PyErr_Occurred()) { Branch (118:9): [True: 0, False: 10]
| 119 | Py_DECREF(out); | 120 | return NULL; | 121 | } | 122 | | 123 | return out; | 124 | } |
|
125 | |