From bf532b11068d2f203f2a6db573e73c7d6b5b7407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Jul 2020 17:19:13 +0200 Subject: Cleanup: Editors/Space/Text, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/space_text` module. No functional changes. --- source/blender/editors/space_text/space_text.c | 2 +- .../blender/editors/space_text/text_autocomplete.c | 19 +++++-------- source/blender/editors/space_text/text_draw.c | 22 +++++++-------- source/blender/editors/space_text/text_format.c | 7 +++-- .../blender/editors/space_text/text_format_lua.c | 2 +- .../blender/editors/space_text/text_format_osl.c | 2 +- .../blender/editors/space_text/text_format_pov.c | 2 +- .../editors/space_text/text_format_pov_ini.c | 2 +- source/blender/editors/space_text/text_format_py.c | 2 +- source/blender/editors/space_text/text_ops.c | 31 ++++++++++------------ 10 files changed, 39 insertions(+), 52 deletions(-) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 76d61193ce0..a2af99ee9f9 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -256,7 +256,7 @@ static int text_context(const bContext *C, const char *member, bContextDataResul CTX_data_dir_set(result, text_context_dir); return 1; } - else if (CTX_data_equals(member, "edit_text")) { + if (CTX_data_equals(member, "edit_text")) { if (st->text != NULL) { CTX_data_id_pointer_set(result, &st->text->id); } diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 1f034bdbd09..24c55e60513 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -319,15 +319,12 @@ static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent * ED_undo_push(C, op->type->name); return OPERATOR_FINISHED; } - else { - WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; - } - } - else { - text_autocomplete_free(C, op); - return OPERATOR_CANCELLED; + + WM_event_add_modal_handler(C, op); + return OPERATOR_RUNNING_MODAL; } + text_autocomplete_free(C, op); + return OPERATOR_CANCELLED; } static int doc_scroll = 0; @@ -590,10 +587,8 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e } return retval; } - else { - text_autocomplete_free(C, op); - return OPERATOR_FINISHED; - } + text_autocomplete_free(C, op); + return OPERATOR_FINISHED; } static void text_autocomplete_free(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index a0339b35c57..e9ac6946032 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -234,11 +234,10 @@ void wrap_offset( if (i - lines < 0) { break; } - else { - linep = linep->next; - (*offl) += lines - 1; - i -= lines; - } + + linep = linep->next; + (*offl) += lines - 1; + i -= lines; } max = wrap_width(st, region); @@ -849,9 +848,7 @@ int text_get_span_wrap(const SpaceText *st, ARegion *region, TextLine *from, Tex return ret; } - else { - return txt_get_span(from, to); - } + return txt_get_span(from, to); } int text_get_total_lines(SpaceText *st, ARegion *region) @@ -1612,11 +1609,10 @@ void draw_text_main(SpaceText *st, ARegion *region) wrap_skip = st->top - wraplinecount; break; } - else { - wraplinecount += lines; - tmp = tmp->next; - linecount++; - } + + wraplinecount += lines; + tmp = tmp->next; + linecount++; } else { tmp = tmp->next; diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c index bdbf55d9198..d099f2a20d8 100644 --- a/source/blender/editors/space_text/text_format.c +++ b/source/blender/editors/space_text/text_format.c @@ -222,10 +222,9 @@ TextFormatType *ED_text_format_get(Text *text) * the "default" text format */ return tft_lb.first; } - else { - /* Return the "default" text format */ - return tft_lb.first; - } + + /* Return the "default" text format */ + return tft_lb.first; } bool ED_text_is_syntax_highlight_supported(Text *text) diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index 42a52ce0f58..4f6d91451e0 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -226,7 +226,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ continue; } /* Handle continuations */ - else if (cont) { + if (cont) { /* Multi-line comments */ if (cont & FMT_CONT_COMMENT_C) { if (*str == ']' && *(str + 1) == ']') { diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index 53e38cfe870..b205996d1d2 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -252,7 +252,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ continue; } /* Handle continuations */ - else if (cont) { + if (cont) { /* C-Style comments */ if (cont & FMT_CONT_COMMENT_C) { if (*str == '*' && *(str + 1) == '/') { diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 52aaad034bf..96d9c234a40 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -825,7 +825,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ continue; } /* Handle continuations */ - else if (cont) { + if (cont) { /* C-Style comments */ if (cont & FMT_CONT_COMMENT_C) { if (*str == '*' && *(str + 1) == '/') { diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index df4f1e6b38c..8d6b877d3f7 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -410,7 +410,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool continue; } /* Handle continuations */ - else if (cont) { + if (cont) { /* Multi-line comments */ if (cont & FMT_CONT_COMMENT_C) { if (*str == ']' && *(str + 1) == ']') { diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 3858f7225ef..39985438462 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -376,7 +376,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n continue; } /* Handle continuations */ - else if (cont) { + if (cont) { /* Triple strings ("""...""" or '''...''') */ if (cont & FMT_CONT_TRIPLE) { find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\''; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index c0343900f8b..6be436cffb5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3012,7 +3012,7 @@ static void text_cursor_set_to_pos_wrapped( break; /* Exactly at the cursor */ } - else if (y == 0 && i - start <= x && i + columns - start > x) { + if (y == 0 && i - start <= x && i + columns - start > x) { /* current position could be wrapped to next line */ /* this should be checked when end of current line would be reached */ charp = curs = j; @@ -3471,21 +3471,20 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) if ((event->ctrl || event->oskey) && !event->utf8_buf[0]) { return OPERATOR_PASS_THROUGH; } - else { - char str[BLI_UTF8_MAX + 1]; - size_t len; - if (event->utf8_buf[0]) { - len = BLI_str_utf8_size_safe(event->utf8_buf); - memcpy(str, event->utf8_buf, len); - } - else { - /* in theory, ghost can set value to extended ascii here */ - len = BLI_str_utf8_from_unicode(event->ascii, str); - } - str[len] = '\0'; - RNA_string_set(op->ptr, "text", str); + char str[BLI_UTF8_MAX + 1]; + size_t len; + + if (event->utf8_buf[0]) { + len = BLI_str_utf8_size_safe(event->utf8_buf); + memcpy(str, event->utf8_buf, len); } + else { + /* in theory, ghost can set value to extended ascii here */ + len = BLI_str_utf8_from_unicode(event->ascii, str); + } + str[len] = '\0'; + RNA_string_set(op->ptr, "text", str); } ret = text_insert_exec(C, op); @@ -3673,9 +3672,7 @@ static int text_replace_exec(bContext *C, wmOperator *op) if (replace_all) { return text_replace_all(C); } - else { - return text_find_and_replace(C, op, TEXT_REPLACE); - } + return text_find_and_replace(C, op, TEXT_REPLACE); } void TEXT_OT_replace(wmOperatorType *ot) -- cgit v1.2.3