Mercurial > vim
diff src/digraph.c @ 31531:6e24001000ed v9.0.1098
patch 9.0.1098: code uses too much indent
Commit: https://github.com/vim/vim/commit/465de3a57b815f1188c707e7c083950c81652536
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Dec 26 12:50:04 2022 +0000
patch 9.0.1098: code uses too much indent
Problem: Code uses too much indent.
Solution: Use an early return. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11747)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Dec 2022 14:00:07 +0100 |
parents | c7983f593fa7 |
children | b89cfd86e18e |
line wrap: on
line diff
--- a/src/digraph.c +++ b/src/digraph.c @@ -1681,14 +1681,14 @@ registerdigraph(int char1, int char2, in } // Add a new digraph to the table. - if (ga_grow(&user_digraphs, 1) == OK) - { - dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len; - dp->char1 = char1; - dp->char2 = char2; - dp->result = n; - ++user_digraphs.ga_len; - } + if (ga_grow(&user_digraphs, 1) != OK) + return; + + dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len; + dp->char1 = char1; + dp->char2 = char2; + dp->result = n; + ++user_digraphs.ga_len; } /* @@ -1948,54 +1948,54 @@ printdigraph(digr_T *dp, result_T *previ else list_width = 11; - if (dp->result != 0) - { -#if defined(USE_UNICODE_DIGRAPHS) - if (previous != NULL) - { - int i; + if (dp->result == 0) + return; - for (i = 0; header_table[i].dg_header != NULL; ++i) - if (*previous < header_table[i].dg_start - && dp->result >= header_table[i].dg_start - && dp->result < header_table[i + 1].dg_start) - { - digraph_header(_(header_table[i].dg_header)); - break; - } - *previous = dp->result; - } -#endif - if (msg_col > Columns - list_width) - msg_putchar('\n'); - if (msg_col) - while (msg_col % list_width != 0) - msg_putchar(' '); +#if defined(USE_UNICODE_DIGRAPHS) + if (previous != NULL) + { + int i; - p = buf; - *p++ = dp->char1; - *p++ = dp->char2; + for (i = 0; header_table[i].dg_header != NULL; ++i) + if (*previous < header_table[i].dg_start + && dp->result >= header_table[i].dg_start + && dp->result < header_table[i + 1].dg_start) + { + digraph_header(_(header_table[i].dg_header)); + break; + } + *previous = dp->result; + } +#endif + if (msg_col > Columns - list_width) + msg_putchar('\n'); + if (msg_col) + while (msg_col % list_width != 0) + msg_putchar(' '); + + p = buf; + *p++ = dp->char1; + *p++ = dp->char2; + *p++ = ' '; + *p = NUL; + msg_outtrans(buf); + p = buf; + if (has_mbyte) + { + // add a space to draw a composing char on + if (enc_utf8 && utf_iscomposing(dp->result)) + *p++ = ' '; + p += (*mb_char2bytes)(dp->result, p); + } + else + *p++ = (char_u)dp->result; + *p = NUL; + msg_outtrans_attr(buf, HL_ATTR(HLF_8)); + p = buf; + if (char2cells(dp->result) == 1) *p++ = ' '; - *p = NUL; - msg_outtrans(buf); - p = buf; - if (has_mbyte) - { - // add a space to draw a composing char on - if (enc_utf8 && utf_iscomposing(dp->result)) - *p++ = ' '; - p += (*mb_char2bytes)(dp->result, p); - } - else - *p++ = (char_u)dp->result; - *p = NUL; - msg_outtrans_attr(buf, HL_ATTR(HLF_8)); - p = buf; - if (char2cells(dp->result) == 1) - *p++ = ' '; - vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result); - msg_outtrans(buf); - } + vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result); + msg_outtrans(buf); } # ifdef FEAT_EVAL