Coverage Report

Created: 2025-07-11 06:59

/src/Python-3.8.3/Objects/stringlib/count.h
Line
Count
Source (jump to first uncovered line)
1
/* stringlib: count implementation */
2
3
#ifndef STRINGLIB_FASTSEARCH_H
4
#error must include "stringlib/fastsearch.h" before including this module
5
#endif
6
7
Py_LOCAL_INLINE(Py_ssize_t)
8
STRINGLIB(count)(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
9
                const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
10
                Py_ssize_t maxcount)
11
2
{
12
2
    Py_ssize_t count;
13
14
2
    if (str_len < 0)
15
0
        return 0; /* start > len(str) */
16
2
    if (sub_len == 0)
17
0
        return (str_len < maxcount) ? str_len + 1 : maxcount;
18
19
2
    count = FASTSEARCH(str, str_len, sub, sub_len, maxcount, FAST_COUNT);
20
21
2
    if (count < 0)
22
0
        return 0; /* no match */
23
24
2
    return count;
25
2
}
Unexecuted instantiation: bytearrayobject.c:stringlib_count
Unexecuted instantiation: bytesobject.c:stringlib_count
unicodeobject.c:asciilib_count
Line
Count
Source
11
2
{
12
2
    Py_ssize_t count;
13
14
2
    if (str_len < 0)
15
0
        return 0; /* start > len(str) */
16
2
    if (sub_len == 0)
17
0
        return (str_len < maxcount) ? str_len + 1 : maxcount;
18
19
2
    count = FASTSEARCH(str, str_len, sub, sub_len, maxcount, FAST_COUNT);
20
21
2
    if (count < 0)
22
0
        return 0; /* no match */
23
24
2
    return count;
25
2
}
Unexecuted instantiation: unicodeobject.c:ucs1lib_count
Unexecuted instantiation: unicodeobject.c:ucs2lib_count
Unexecuted instantiation: unicodeobject.c:ucs4lib_count
Unexecuted instantiation: unicodeobject.c:stringlib_count
Unexecuted instantiation: bytes_methods.c:stringlib_count
26
27