mirror of https://github.com/python/cpython
bpo-46848: Move _PyBytes_Find() to internal C API (GH-31642)
Move _PyBytes_Find() and _PyBytes_ReverseFind() functions to the internal C API. bytesobject.c now includes pycore_bytesobject.h.
This commit is contained in:
parent
03642df1a1
commit
b6b711a1aa
|
@ -116,22 +116,3 @@ PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
|
||||||
void *str,
|
void *str,
|
||||||
const void *bytes,
|
const void *bytes,
|
||||||
Py_ssize_t size);
|
Py_ssize_t size);
|
||||||
|
|
||||||
/* Substring Search.
|
|
||||||
|
|
||||||
Returns the index of the first occurence of
|
|
||||||
a substring ("needle") in a larger text ("haystack").
|
|
||||||
If the needle is not found, return -1.
|
|
||||||
If the needle is found, add offset to the index.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PyAPI_FUNC(Py_ssize_t)
|
|
||||||
_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
|
|
||||||
const char *needle, Py_ssize_t len_needle,
|
|
||||||
Py_ssize_t offset);
|
|
||||||
|
|
||||||
/* Same as above, but search right-to-left */
|
|
||||||
PyAPI_FUNC(Py_ssize_t)
|
|
||||||
_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
|
|
||||||
const char *needle, Py_ssize_t len_needle,
|
|
||||||
Py_ssize_t offset);
|
|
||||||
|
|
|
@ -14,6 +14,25 @@ extern "C" {
|
||||||
extern PyStatus _PyBytes_InitTypes(PyInterpreterState *);
|
extern PyStatus _PyBytes_InitTypes(PyInterpreterState *);
|
||||||
|
|
||||||
|
|
||||||
|
/* Substring Search.
|
||||||
|
|
||||||
|
Returns the index of the first occurence of
|
||||||
|
a substring ("needle") in a larger text ("haystack").
|
||||||
|
If the needle is not found, return -1.
|
||||||
|
If the needle is found, add offset to the index.
|
||||||
|
*/
|
||||||
|
|
||||||
|
PyAPI_FUNC(Py_ssize_t)
|
||||||
|
_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
|
||||||
|
const char *needle, Py_ssize_t len_needle,
|
||||||
|
Py_ssize_t offset);
|
||||||
|
|
||||||
|
/* Same as above, but search right-to-left */
|
||||||
|
PyAPI_FUNC(Py_ssize_t)
|
||||||
|
_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
|
||||||
|
const char *needle, Py_ssize_t len_needle,
|
||||||
|
Py_ssize_t offset);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include "pycore_bytesobject.h" // _PyBytes_Find()
|
||||||
#include "pycore_fileutils.h" // _Py_stat_struct
|
#include "pycore_fileutils.h" // _Py_stat_struct
|
||||||
#include "structmember.h" // PyMemberDef
|
#include "structmember.h" // PyMemberDef
|
||||||
#include <stddef.h> // offsetof()
|
#include <stddef.h> // offsetof()
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_abstract.h" // _PyIndex_Check()
|
#include "pycore_abstract.h" // _PyIndex_Check()
|
||||||
|
#include "pycore_bytesobject.h" // _PyBytes_Find()
|
||||||
#include "pycore_bytes_methods.h" // _Py_bytes_startswith()
|
#include "pycore_bytes_methods.h" // _Py_bytes_startswith()
|
||||||
#include "pycore_call.h" // _PyObject_CallNoArgs()
|
#include "pycore_call.h" // _PyObject_CallNoArgs()
|
||||||
#include "pycore_format.h" // F_LJUST
|
#include "pycore_format.h" // F_LJUST
|
||||||
|
|
Loading…
Reference in New Issue