Cleanup: return success from python_script_error_jump
Relying on checks for the assignment of return arguments isn't so clear especially when there are multiple return arguments.
This commit is contained in:
@@ -39,8 +39,7 @@ static void python_script_error_jump_text(Text *text, const char *filepath)
|
|||||||
{
|
{
|
||||||
int lineno, lineno_end;
|
int lineno, lineno_end;
|
||||||
int offset, offset_end;
|
int offset, offset_end;
|
||||||
python_script_error_jump(filepath, &lineno, &offset, &lineno_end, &offset_end);
|
if (python_script_error_jump(filepath, &lineno, &offset, &lineno_end, &offset_end)) {
|
||||||
if (lineno != -1) {
|
|
||||||
/* Start at the end so cursor motion that looses the selection,
|
/* Start at the end so cursor motion that looses the selection,
|
||||||
* leaves the cursor from the most useful place.
|
* leaves the cursor from the most useful place.
|
||||||
* Also, the end can't always be set, so don't give it priority. */
|
* Also, the end can't always be set, so don't give it priority. */
|
||||||
|
|||||||
@@ -162,9 +162,10 @@ finally:
|
|||||||
}
|
}
|
||||||
/* end copied function! */
|
/* end copied function! */
|
||||||
|
|
||||||
void python_script_error_jump(
|
bool python_script_error_jump(
|
||||||
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end)
|
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
PyObject *exception, *value;
|
PyObject *exception, *value;
|
||||||
PyTracebackObject *tb;
|
PyTracebackObject *tb;
|
||||||
|
|
||||||
@@ -176,7 +177,7 @@ void python_script_error_jump(
|
|||||||
|
|
||||||
PyErr_Fetch(&exception, &value, (PyObject **)&tb);
|
PyErr_Fetch(&exception, &value, (PyObject **)&tb);
|
||||||
if (exception == NULL) {
|
if (exception == NULL) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
if (PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
||||||
@@ -200,14 +201,8 @@ void python_script_error_jump(
|
|||||||
/* python adds a '/', prefix, so check for both */
|
/* python adds a '/', prefix, so check for both */
|
||||||
if ((BLI_path_cmp(filepath_exc, filepath) == 0) ||
|
if ((BLI_path_cmp(filepath_exc, filepath) == 0) ||
|
||||||
(ELEM(filepath_exc[0], '\\', '/') && BLI_path_cmp(filepath_exc + 1, filepath) == 0)) {
|
(ELEM(filepath_exc[0], '\\', '/') && BLI_path_cmp(filepath_exc + 1, filepath) == 0)) {
|
||||||
/* good */
|
success = true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
*r_lineno = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*r_lineno = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||||
@@ -228,9 +223,12 @@ void python_script_error_jump(
|
|||||||
Py_DECREF(coerce);
|
Py_DECREF(coerce);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
success = true;
|
||||||
*r_lineno = *r_lineno_end = tb->tb_lineno;
|
*r_lineno = *r_lineno_end = tb->tb_lineno;
|
||||||
/* used to break here, but better find the inner most line */
|
/* used to break here, but better find the inner most line */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void python_script_error_jump(
|
bool python_script_error_jump(
|
||||||
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end);
|
const char *filepath, int *r_lineno, int *r_offset, int *r_lineno_end, int *r_offset_end);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user