From ce3b78c73a7ccc16fdccf7decedb5d1578dfdf0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Mar 2019 21:16:47 +1100 Subject: Cleanup: style, use braces for editor/spaces --- source/blender/editors/space_console/console_ops.c | 75 +++++++++++++++------- 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'source/blender/editors/space_console/console_ops.c') diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 46d22df2609..d4489337847 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -87,10 +87,13 @@ static void console_scrollback_limit(SpaceConsole *sc) { int tot; - if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults + if (U.scrollback < 32) { + U.scrollback = 256; // XXX - save in user defaults + } - for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) + for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) { console_scrollback_free(sc, sc->scrollback.first); + } } static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore) @@ -98,11 +101,13 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons ConsoleLine *cl; for (cl = sc->history.last; cl; cl = cl->prev) { - if (cl == cl_ignore) + if (cl == cl_ignore) { continue; + } - if (STREQ(str, cl->line)) + if (STREQ(str, cl->line)) { return cl; + } } return NULL; @@ -113,9 +118,15 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor) { int cursor_new; - if (cursor < 0) cursor_new = 0; - else if (cursor > cl->len) cursor_new = cl->len; - else cursor_new = cursor; + if (cursor < 0) { + cursor_new = 0; + } + else if (cursor > cl->len) { + cursor_new = cl->len; + } + else { + cursor_new = cursor; + } if (cursor_new == cl->cursor) { return false; @@ -184,8 +195,12 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own) { ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - if (own) ci->line = str; - else ci->line = BLI_strdup(str); + if (own) { + ci->line = str; + } + else { + ci->line = BLI_strdup(str); + } ci->len = ci->len_alloc = strlen(str); @@ -207,8 +222,9 @@ ConsoleLine *console_history_verify(const bContext *C) { SpaceConsole *sc = CTX_wm_space_console(C); ConsoleLine *ci = sc->history.last; - if (ci == NULL) + if (ci == NULL) { ci = console_history_add(sc, NULL); + } return ci; } @@ -242,8 +258,9 @@ static int console_line_insert(ConsoleLine *ci, char *str) len--; } - if (len == 0) + if (len == 0) { return 0; + } console_line_verify_length(ci, len + ci->len); @@ -480,8 +497,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op)) int len; for (spaces = 0; spaces < ci->len; spaces++) { - if (ci->line[spaces] != ' ') + if (ci->line[spaces] != ' ') { break; + } } len = TAB_LENGTH - spaces % TAB_LENGTH; @@ -524,16 +542,19 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op)) int len; for (spaces = 0; spaces < ci->len; spaces++) { - if (ci->line[spaces] != ' ') + if (ci->line[spaces] != ' ') { break; + } } - if (spaces == 0) + if (spaces == 0) { return OPERATOR_CANCELLED; + } len = spaces % TAB_LENGTH; - if (len == 0) + if (len == 0) { len = TAB_LENGTH; + } console_line_verify_length(ci, ci->len - len); @@ -701,13 +722,15 @@ static int console_clear_exec(bContext *C, wmOperator *op) /*ConsoleLine *ci = */ console_history_verify(C); if (scrollback) { /* last item in mistory */ - while (sc->scrollback.first) + while (sc->scrollback.first) { console_scrollback_free(sc, sc->scrollback.first); + } } if (history) { - while (sc->history.first) + while (sc->history.first) { console_history_free(sc, sc->history.first); + } console_history_verify(C); } @@ -751,8 +774,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) if (ci->prev) { ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; - if (STREQ(ci->line, ci_prev->line)) + if (STREQ(ci->line, ci_prev->line)) { console_history_free(sc, ci_prev); + } } if (reverse) { /* last item in history */ @@ -768,8 +792,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) { /* add a duplicate of the new arg and remove all other instances */ ConsoleLine *cl; - while ((cl = console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) { console_history_free(sc, cl); + } console_history_add(sc, (ConsoleLine *)sc->history.last); } @@ -818,8 +843,9 @@ static int console_history_append_exec(bContext *C, wmOperator *op) if (rem_dupes) { ConsoleLine *cl; - while ((cl = console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) { console_history_free(sc, cl); + } if (STREQ(str, ci->line)) { MEM_freeN(str); @@ -928,8 +954,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) ConsoleLine cl_dummy = {NULL}; - if (sc->sel_start == sc->sel_end) + if (sc->sel_start == sc->sel_end) { return OPERATOR_CANCELLED; + } console_scrollback_prompt_begin(sc, &cl_dummy); @@ -952,8 +979,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) int sta = max_ii(sel[0], 0); int end = min_ii(sel[1], cl->len); - if (BLI_dynstr_get_len(buf_dyn)) + if (BLI_dynstr_get_len(buf_dyn)) { BLI_dynstr_append(buf_dyn, "\n"); + } BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta); } @@ -998,8 +1026,9 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op)) char *buf_str = WM_clipboard_text_get(false, &buf_len); char *buf_step, *buf_next; - if (buf_str == NULL) + if (buf_str == NULL) { return OPERATOR_CANCELLED; + } buf_step = buf_str; -- cgit v1.2.3