Mercurial > vim
comparison src/misc2.c @ 31728:238ca27dbfd2 v9.0.1196
patch 9.0.1196: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Jan 14 12:32:28 2023 +0000
patch 9.0.1196: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11813)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Jan 2023 13:45:04 +0100 |
parents | 6fa4f94aca5a |
children | 59c474f6715d |
comparison
equal
deleted
inserted
replaced
31727:2b50a7f0feec | 31728:238ca27dbfd2 |
---|---|
1128 { | 1128 { |
1129 int i; | 1129 int i; |
1130 int key0; | 1130 int key0; |
1131 int key1; | 1131 int key1; |
1132 | 1132 |
1133 if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)) | 1133 if (!(*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT))) |
1134 { | 1134 return key; |
1135 // TAB is a special case | 1135 |
1136 if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) | 1136 // TAB is a special case |
1137 { | 1137 if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) |
1138 *modifiers &= ~MOD_MASK_SHIFT; | 1138 { |
1139 return K_S_TAB; | 1139 *modifiers &= ~MOD_MASK_SHIFT; |
1140 } | 1140 return K_S_TAB; |
1141 key0 = KEY2TERMCAP0(key); | 1141 } |
1142 key1 = KEY2TERMCAP1(key); | 1142 key0 = KEY2TERMCAP0(key); |
1143 for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) | 1143 key1 = KEY2TERMCAP1(key); |
1144 if (key0 == modifier_keys_table[i + 3] | 1144 for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) |
1145 && key1 == modifier_keys_table[i + 4] | 1145 { |
1146 && (*modifiers & modifier_keys_table[i])) | 1146 if (key0 == modifier_keys_table[i + 3] |
1147 { | 1147 && key1 == modifier_keys_table[i + 4] |
1148 *modifiers &= ~modifier_keys_table[i]; | 1148 && (*modifiers & modifier_keys_table[i])) |
1149 return TERMCAP2KEY(modifier_keys_table[i + 1], | 1149 { |
1150 modifier_keys_table[i + 2]); | 1150 *modifiers &= ~modifier_keys_table[i]; |
1151 } | 1151 return TERMCAP2KEY(modifier_keys_table[i + 1], |
1152 modifier_keys_table[i + 2]); | |
1153 } | |
1152 } | 1154 } |
1153 return key; | 1155 return key; |
1154 } | 1156 } |
1155 | 1157 |
1156 /* | 1158 /* |
1535 * Returns the possibly adjusted key. | 1537 * Returns the possibly adjusted key. |
1536 */ | 1538 */ |
1537 int | 1539 int |
1538 may_adjust_key_for_ctrl(int modifiers, int key) | 1540 may_adjust_key_for_ctrl(int modifiers, int key) |
1539 { | 1541 { |
1540 if (modifiers & MOD_MASK_CTRL) | 1542 if (!(modifiers & MOD_MASK_CTRL)) |
1541 { | 1543 return key; |
1542 if (ASCII_ISALPHA(key)) | 1544 |
1543 { | 1545 if (ASCII_ISALPHA(key)) |
1546 { | |
1544 #ifdef FEAT_TERMINAL | 1547 #ifdef FEAT_TERMINAL |
1545 check_no_reduce_keys(); // may update the no_reduce_keys flag | 1548 check_no_reduce_keys(); // may update the no_reduce_keys flag |
1546 #endif | 1549 #endif |
1547 return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key; | 1550 return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key; |
1548 } | 1551 } |
1549 if (key == '2') | 1552 if (key == '2') |
1550 return '@'; | 1553 return '@'; |
1551 if (key == '6') | 1554 if (key == '6') |
1552 return '^'; | 1555 return '^'; |
1553 if (key == '-') | 1556 if (key == '-') |
1554 return '_'; | 1557 return '_'; |
1555 } | |
1556 return key; | 1558 return key; |
1557 } | 1559 } |
1558 | 1560 |
1559 /* | 1561 /* |
1560 * Some keys already have Shift included, pass them as normal keys. | 1562 * Some keys already have Shift included, pass them as normal keys. |
2818 int i; | 2820 int i; |
2819 int c; | 2821 int c; |
2820 | 2822 |
2821 // allocate memory | 2823 // allocate memory |
2822 str = alloc(cnt + 1); | 2824 str = alloc(cnt + 1); |
2823 if (str != NULL) | 2825 if (str == NULL) |
2824 { | 2826 return NULL; |
2825 // Read the string. Quit when running into the EOF. | 2827 |
2826 for (i = 0; i < cnt; ++i) | 2828 // Read the string. Quit when running into the EOF. |
2827 { | 2829 for (i = 0; i < cnt; ++i) |
2828 c = getc(fd); | 2830 { |
2829 if (c == EOF) | 2831 c = getc(fd); |
2830 { | 2832 if (c == EOF) |
2831 vim_free(str); | 2833 { |
2832 return NULL; | 2834 vim_free(str); |
2833 } | 2835 return NULL; |
2834 str[i] = c; | 2836 } |
2835 } | 2837 str[i] = c; |
2836 str[i] = NUL; | 2838 } |
2837 } | 2839 str[i] = NUL; |
2838 return str; | 2840 return str; |
2839 } | 2841 } |
2840 | 2842 |
2841 /* | 2843 /* |
2842 * Write a number to file "fd", MSB first, in "len" bytes. | 2844 * Write a number to file "fd", MSB first, in "len" bytes. |