Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
31530:4f57d68cd1c6 | 31531:6e24001000ed |
---|---|
1679 } | 1679 } |
1680 ++dp; | 1680 ++dp; |
1681 } | 1681 } |
1682 | 1682 |
1683 // Add a new digraph to the table. | 1683 // Add a new digraph to the table. |
1684 if (ga_grow(&user_digraphs, 1) == OK) | 1684 if (ga_grow(&user_digraphs, 1) != OK) |
1685 { | 1685 return; |
1686 dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len; | 1686 |
1687 dp->char1 = char1; | 1687 dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len; |
1688 dp->char2 = char2; | 1688 dp->char1 = char1; |
1689 dp->result = n; | 1689 dp->char2 = char2; |
1690 ++user_digraphs.ga_len; | 1690 dp->result = n; |
1691 } | 1691 ++user_digraphs.ga_len; |
1692 } | 1692 } |
1693 | 1693 |
1694 /* | 1694 /* |
1695 * Check the characters are valid for a digraph. | 1695 * Check the characters are valid for a digraph. |
1696 * If they are valid, returns TRUE; otherwise, give an error message and | 1696 * If they are valid, returns TRUE; otherwise, give an error message and |
1946 if ((dy_flags & DY_UHEX) || has_mbyte) | 1946 if ((dy_flags & DY_UHEX) || has_mbyte) |
1947 list_width = 13; | 1947 list_width = 13; |
1948 else | 1948 else |
1949 list_width = 11; | 1949 list_width = 11; |
1950 | 1950 |
1951 if (dp->result != 0) | 1951 if (dp->result == 0) |
1952 { | 1952 return; |
1953 | |
1953 #if defined(USE_UNICODE_DIGRAPHS) | 1954 #if defined(USE_UNICODE_DIGRAPHS) |
1954 if (previous != NULL) | 1955 if (previous != NULL) |
1955 { | 1956 { |
1956 int i; | 1957 int i; |
1957 | 1958 |
1958 for (i = 0; header_table[i].dg_header != NULL; ++i) | 1959 for (i = 0; header_table[i].dg_header != NULL; ++i) |
1959 if (*previous < header_table[i].dg_start | 1960 if (*previous < header_table[i].dg_start |
1960 && dp->result >= header_table[i].dg_start | 1961 && dp->result >= header_table[i].dg_start |
1961 && dp->result < header_table[i + 1].dg_start) | 1962 && dp->result < header_table[i + 1].dg_start) |
1962 { | 1963 { |
1963 digraph_header(_(header_table[i].dg_header)); | 1964 digraph_header(_(header_table[i].dg_header)); |
1964 break; | 1965 break; |
1965 } | 1966 } |
1966 *previous = dp->result; | 1967 *previous = dp->result; |
1967 } | 1968 } |
1968 #endif | 1969 #endif |
1969 if (msg_col > Columns - list_width) | 1970 if (msg_col > Columns - list_width) |
1970 msg_putchar('\n'); | 1971 msg_putchar('\n'); |
1971 if (msg_col) | 1972 if (msg_col) |
1972 while (msg_col % list_width != 0) | 1973 while (msg_col % list_width != 0) |
1973 msg_putchar(' '); | 1974 msg_putchar(' '); |
1974 | 1975 |
1975 p = buf; | 1976 p = buf; |
1976 *p++ = dp->char1; | 1977 *p++ = dp->char1; |
1977 *p++ = dp->char2; | 1978 *p++ = dp->char2; |
1979 *p++ = ' '; | |
1980 *p = NUL; | |
1981 msg_outtrans(buf); | |
1982 p = buf; | |
1983 if (has_mbyte) | |
1984 { | |
1985 // add a space to draw a composing char on | |
1986 if (enc_utf8 && utf_iscomposing(dp->result)) | |
1987 *p++ = ' '; | |
1988 p += (*mb_char2bytes)(dp->result, p); | |
1989 } | |
1990 else | |
1991 *p++ = (char_u)dp->result; | |
1992 *p = NUL; | |
1993 msg_outtrans_attr(buf, HL_ATTR(HLF_8)); | |
1994 p = buf; | |
1995 if (char2cells(dp->result) == 1) | |
1978 *p++ = ' '; | 1996 *p++ = ' '; |
1979 *p = NUL; | 1997 vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result); |
1980 msg_outtrans(buf); | 1998 msg_outtrans(buf); |
1981 p = buf; | |
1982 if (has_mbyte) | |
1983 { | |
1984 // add a space to draw a composing char on | |
1985 if (enc_utf8 && utf_iscomposing(dp->result)) | |
1986 *p++ = ' '; | |
1987 p += (*mb_char2bytes)(dp->result, p); | |
1988 } | |
1989 else | |
1990 *p++ = (char_u)dp->result; | |
1991 *p = NUL; | |
1992 msg_outtrans_attr(buf, HL_ATTR(HLF_8)); | |
1993 p = buf; | |
1994 if (char2cells(dp->result) == 1) | |
1995 *p++ = ' '; | |
1996 vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result); | |
1997 msg_outtrans(buf); | |
1998 } | |
1999 } | 1999 } |
2000 | 2000 |
2001 # ifdef FEAT_EVAL | 2001 # ifdef FEAT_EVAL |
2002 /* | 2002 /* |
2003 * Get the two digraph characters from a typval. | 2003 * Get the two digraph characters from a typval. |