mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Fix find_in_memoryview()
This commit is contained in:
@@ -395,10 +395,10 @@ replace_c0_codes_except_nl_space_tab(PyObject *self UNUSED, PyObject *obj) {
|
|||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
find_in_memoryview(PyObject *self UNUSED, PyObject *args) {
|
find_in_memoryview(PyObject *self UNUSED, PyObject *args) {
|
||||||
const char *buf; Py_ssize_t sz;
|
|
||||||
unsigned char q;
|
unsigned char q;
|
||||||
if (!PyArg_ParseTuple(args, "y#b", &buf, &sz, &q)) return NULL;
|
RAII_PY_BUFFER(view);
|
||||||
const char *p = memchr(buf, q, sz);
|
if (!PyArg_ParseTuple(args, "y*b", &view, &q)) return NULL;
|
||||||
|
const char *buf = view.buf, *p = memchr(buf, q, view.len);
|
||||||
Py_ssize_t ans = -1;
|
Py_ssize_t ans = -1;
|
||||||
if (p) ans = p - buf;
|
if (p) ans = p - buf;
|
||||||
return PyLong_FromSsize_t(ans);
|
return PyLong_FromSsize_t(ans);
|
||||||
|
|||||||
Reference in New Issue
Block a user