refactor: follow style guide

- reduce variable scope
- prefer initialization over declaration and assignment
This commit is contained in:
dundargoc
2023-11-13 23:40:37 +01:00
committed by dundargoc
parent 1798a4b5e9
commit ac1113ded5
52 changed files with 713 additions and 1269 deletions

View File

@@ -2492,14 +2492,13 @@ bool has_nvim_version(const char *const version_str)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
const char *p = version_str;
int major = 0;
int minor = 0;
int patch = 0;
if (!ascii_isdigit(*p)) {
return false;
}
major = atoi(p);
int major = atoi(p);
p = strchr(p, '.'); // Find the next dot.
if (p) {
@@ -2618,8 +2617,7 @@ void list_in_columns(char **items, int size, int current)
int width = 0;
// Find the length of the longest item, use that + 1 as the column width.
int i;
for (i = 0; size < 0 ? items[i] != NULL : i < size; i++) {
for (int i = 0; size < 0 ? items[i] != NULL : i < size; i++) {
int l = vim_strsize(items[i]) + (i == current ? 2 : 0);
if (l > width) {
@@ -2631,7 +2629,7 @@ void list_in_columns(char **items, int size, int current)
if (Columns < width) {
// Not enough screen columns - show one per line
for (i = 0; i < item_count; i++) {
for (int i = 0; i < item_count; i++) {
version_msg_wrap(items[i], i == current);
if (msg_col > 0 && i < item_count - 1) {
msg_putchar('\n');
@@ -2647,7 +2645,7 @@ void list_in_columns(char **items, int size, int current)
int cur_row = 1;
// "i" counts columns then rows. "idx" counts rows then columns.
for (i = 0; !got_int && i < nrow * ncol; i++) {
for (int i = 0; !got_int && i < nrow * ncol; i++) {
int idx = (i / ncol) + (i % ncol) * nrow;
if (idx < item_count) {
int last_col = (i + 1) % ncol == 0;