]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Objects/stringlib/count.h
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Objects / stringlib / count.h
CommitLineData
4710c53d 1/* stringlib: count implementation */\r
2\r
3#ifndef STRINGLIB_COUNT_H\r
4#define STRINGLIB_COUNT_H\r
5\r
6#ifndef STRINGLIB_FASTSEARCH_H\r
7#error must include "stringlib/fastsearch.h" before including this module\r
8#endif\r
9\r
10Py_LOCAL_INLINE(Py_ssize_t)\r
11stringlib_count(const STRINGLIB_CHAR* str, Py_ssize_t str_len,\r
12 const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,\r
13 Py_ssize_t maxcount)\r
14{\r
15 Py_ssize_t count;\r
16\r
17 if (str_len < 0)\r
18 return 0; /* start > len(str) */\r
19 if (sub_len == 0)\r
20 return (str_len < maxcount) ? str_len + 1 : maxcount;\r
21\r
22 count = fastsearch(str, str_len, sub, sub_len, maxcount, FAST_COUNT);\r
23\r
24 if (count < 0)\r
25 return 0; /* no match */\r
26\r
27 return count;\r
28}\r
29\r
30#endif\r