Cleanup: pass the buffer length into txt_insert_buf
Also remove redundant NULL check.
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
* This file extends the text editor with C/Python API methods and attributes.
|
||||
*/
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "DNA_text_types.h"
|
||||
@@ -103,9 +105,16 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args)
|
||||
|
||||
/* Parse the region range. */
|
||||
const char *buf;
|
||||
Py_ssize_t buf_len;
|
||||
TextRegion region;
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "s|((ii)(ii))", &buf, ®ion.curl, ®ion.curc, ®ion.sell, ®ion.selc)) {
|
||||
if (!PyArg_ParseTuple(args,
|
||||
"s#|((ii)(ii))",
|
||||
&buf,
|
||||
&buf_len,
|
||||
®ion.curl,
|
||||
®ion.curc,
|
||||
®ion.sell,
|
||||
®ion.selc)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -114,7 +123,7 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/* Set the selected text. */
|
||||
txt_insert_buf(text, buf);
|
||||
txt_insert_buf(text, buf, buf_len);
|
||||
/* Update the text editor. */
|
||||
WM_main_add_notifier(NC_TEXT | NA_EDITED, text);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user