Merge pull request #20821 from dundargoc/refactor/clang-tidy

refactor: fix clang-tidy warnings
This commit is contained in:
bfredl 2022-11-08 09:48:48 +01:00 committed by GitHub
commit fae7540732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 558 additions and 555 deletions

View File

@ -1,5 +1,3 @@
---
Checks: > Checks: >
-*, -*,
@ -16,8 +14,6 @@ Checks: >
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result, -bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses, -bugprone-macro-parentheses,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
-bugprone-narrowing-conversions, -bugprone-narrowing-conversions,
-bugprone-not-null-terminated-result, -bugprone-not-null-terminated-result,
-bugprone-reserved-identifier, -bugprone-reserved-identifier,
@ -32,6 +28,7 @@ Checks: >
-misc-unused-parameters, -misc-unused-parameters,
-modernize-macro-to-enum, -modernize-macro-to-enum,
-performance-no-int-to-ptr, -performance-no-int-to-ptr,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements, -readability-braces-around-statements,
-readability-else-after-return, -readability-else-after-return,
-readability-function-cognitive-complexity, -readability-function-cognitive-complexity,
@ -43,8 +40,3 @@ Checks: >
-readability-redundant-declaration, -readability-redundant-declaration,
-readability-redundant-function-ptr-dereference, -readability-redundant-function-ptr-dereference,
-readability-suspicious-call-argument, -readability-suspicious-call-argument,
WarningsAsErrors: ''
HeaderFilterRegex: "(src/[cjson|klib|mpack|unicode|xdiff]/).*\\.h$"
...

View File

@ -833,9 +833,8 @@ uint32_t src2ns(Integer *src_id)
} }
if (*src_id < 0) { if (*src_id < 0) {
return (((uint32_t)1) << 31) - 1; return (((uint32_t)1) << 31) - 1;
} else {
return (uint32_t)(*src_id);
} }
return (uint32_t)(*src_id);
} }
/// Adds a highlight to buffer. /// Adds a highlight to buffer.

View File

@ -110,7 +110,7 @@ Window nvim_tabpage_get_win(Tabpage tabpage, Error *err)
if (tab == curtab) { if (tab == curtab) {
return nvim_get_current_win(); return nvim_get_current_win();
} else { }
FOR_ALL_WINDOWS_IN_TAB(wp, tab) { FOR_ALL_WINDOWS_IN_TAB(wp, tab) {
if (wp == tab->tp_curwin) { if (wp == tab->tp_curwin) {
return wp->handle; return wp->handle;
@ -118,7 +118,6 @@ Window nvim_tabpage_get_win(Tabpage tabpage, Error *err)
} }
// There should always be a current window for a tabpage // There should always be a current window for a tabpage
abort(); abort();
}
} }
/// Gets the tabpage number /// Gets the tabpage number

View File

@ -532,7 +532,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, E
kv_drop(ast_conv_stack, 1); kv_drop(ast_conv_stack, 1);
} else { } else {
if (cur_item.ret_node_p->type == kObjectTypeNil) { if (cur_item.ret_node_p->type == kObjectTypeNil) {
size_t items_size = (size_t)(3 // "type", "start" and "len" size_t items_size = (size_t)(3 // "type", "start" and "len" // NOLINT(bugprone-misplaced-widening-cast)
+ (node->children != NULL) // "children" + (node->children != NULL) // "children"
+ (node->type == kExprNodeOption + (node->type == kExprNodeOption
|| node->type == kExprNodePlainIdentifier) // "scope" || node->type == kExprNodePlainIdentifier) // "scope"

View File

@ -27,70 +27,72 @@
#include "nvim/vim.h" #include "nvim/vim.h"
// Unicode values for Arabic characters. // Unicode values for Arabic characters.
#define a_HAMZA 0x0621 enum {
#define a_ALEF_MADDA 0x0622 a_HAMZA = 0x0621,
#define a_ALEF_HAMZA_ABOVE 0x0623 a_ALEF_MADDA = 0x0622,
#define a_WAW_HAMZA 0x0624 a_ALEF_HAMZA_ABOVE = 0x0623,
#define a_ALEF_HAMZA_BELOW 0x0625 a_WAW_HAMZA = 0x0624,
#define a_YEH_HAMZA 0x0626 a_ALEF_HAMZA_BELOW = 0x0625,
#define a_ALEF 0x0627 a_YEH_HAMZA = 0x0626,
#define a_BEH 0x0628 a_ALEF = 0x0627,
#define a_TEH_MARBUTA 0x0629 a_BEH = 0x0628,
#define a_TEH 0x062a a_TEH_MARBUTA = 0x0629,
#define a_THEH 0x062b a_TEH = 0x062a,
#define a_JEEM 0x062c a_THEH = 0x062b,
#define a_HAH 0x062d a_JEEM = 0x062c,
#define a_KHAH 0x062e a_HAH = 0x062d,
#define a_DAL 0x062f a_KHAH = 0x062e,
#define a_THAL 0x0630 a_DAL = 0x062f,
#define a_REH 0x0631 a_THAL = 0x0630,
#define a_ZAIN 0x0632 a_REH = 0x0631,
#define a_SEEN 0x0633 a_ZAIN = 0x0632,
#define a_SHEEN 0x0634 a_SEEN = 0x0633,
#define a_SAD 0x0635 a_SHEEN = 0x0634,
#define a_DAD 0x0636 a_SAD = 0x0635,
#define a_TAH 0x0637 a_DAD = 0x0636,
#define a_ZAH 0x0638 a_TAH = 0x0637,
#define a_AIN 0x0639 a_ZAH = 0x0638,
#define a_GHAIN 0x063a a_AIN = 0x0639,
#define a_TATWEEL 0x0640 a_GHAIN = 0x063a,
#define a_FEH 0x0641 a_TATWEEL = 0x0640,
#define a_QAF 0x0642 a_FEH = 0x0641,
#define a_KAF 0x0643 a_QAF = 0x0642,
#define a_LAM 0x0644 a_KAF = 0x0643,
#define a_MEEM 0x0645 a_LAM = 0x0644,
#define a_NOON 0x0646 a_MEEM = 0x0645,
#define a_HEH 0x0647 a_NOON = 0x0646,
#define a_WAW 0x0648 a_HEH = 0x0647,
#define a_ALEF_MAKSURA 0x0649 a_WAW = 0x0648,
#define a_YEH 0x064a a_ALEF_MAKSURA = 0x0649,
#define a_FATHATAN 0x064b a_YEH = 0x064a,
#define a_DAMMATAN 0x064c a_FATHATAN = 0x064b,
#define a_KASRATAN 0x064d a_DAMMATAN = 0x064c,
#define a_FATHA 0x064e a_KASRATAN = 0x064d,
#define a_DAMMA 0x064f a_FATHA = 0x064e,
#define a_KASRA 0x0650 a_DAMMA = 0x064f,
#define a_SHADDA 0x0651 a_KASRA = 0x0650,
#define a_SUKUN 0x0652 a_SHADDA = 0x0651,
#define a_MADDA_ABOVE 0x0653 a_SUKUN = 0x0652,
#define a_HAMZA_ABOVE 0x0654 a_MADDA_ABOVE = 0x0653,
#define a_HAMZA_BELOW 0x0655 a_HAMZA_ABOVE = 0x0654,
a_HAMZA_BELOW = 0x0655,
#define a_PEH 0x067e a_PEH = 0x067e,
#define a_TCHEH 0x0686 a_TCHEH = 0x0686,
#define a_JEH 0x0698 a_JEH = 0x0698,
#define a_FKAF 0x06a9 a_FKAF = 0x06a9,
#define a_GAF 0x06af a_GAF = 0x06af,
#define a_FYEH 0x06cc a_FYEH = 0x06cc,
#define a_s_LAM_ALEF_MADDA_ABOVE 0xfef5 a_s_LAM_ALEF_MADDA_ABOVE = 0xfef5,
#define a_f_LAM_ALEF_MADDA_ABOVE 0xfef6 a_f_LAM_ALEF_MADDA_ABOVE = 0xfef6,
#define a_s_LAM_ALEF_HAMZA_ABOVE 0xfef7 a_s_LAM_ALEF_HAMZA_ABOVE = 0xfef7,
#define a_f_LAM_ALEF_HAMZA_ABOVE 0xfef8 a_f_LAM_ALEF_HAMZA_ABOVE = 0xfef8,
#define a_s_LAM_ALEF_HAMZA_BELOW 0xfef9 a_s_LAM_ALEF_HAMZA_BELOW = 0xfef9,
#define a_f_LAM_ALEF_HAMZA_BELOW 0xfefa a_f_LAM_ALEF_HAMZA_BELOW = 0xfefa,
#define a_s_LAM_ALEF 0xfefb a_s_LAM_ALEF = 0xfefb,
#define a_f_LAM_ALEF 0xfefc a_f_LAM_ALEF = 0xfefc,
};
static struct achar { static struct achar {
unsigned c; unsigned c;

View File

@ -169,13 +169,12 @@ Decoration get_decor(mtkey_t mark)
{ {
if (mark.decor_full) { if (mark.decor_full) {
return *mark.decor_full; return *mark.decor_full;
} else { }
Decoration fake = DECORATION_INIT; Decoration fake = DECORATION_INIT;
fake.hl_id = mark.hl_id; fake.hl_id = mark.hl_id;
fake.priority = mark.priority; fake.priority = mark.priority;
fake.hl_eol = (mark.flags & MT_FLAG_HL_EOL); fake.hl_eol = (mark.flags & MT_FLAG_HL_EOL);
return fake; return fake;
}
} }
/// @return true if decor has a virtual position (virtual text or ui_watched) /// @return true if decor has a virtual position (virtual text or ui_watched)

View File

@ -1133,7 +1133,7 @@ static int diff_file(diffio_T *dio)
// Use xdiff for generating the diff. // Use xdiff for generating the diff.
if (dio->dio_internal) { if (dio->dio_internal) {
return diff_file_internal(dio); return diff_file_internal(dio);
} else { }
const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff) const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
+ strlen(p_srr) + 27); + strlen(p_srr) + 27);
char *const cmd = xmalloc(len); char *const cmd = xmalloc(len);
@ -1163,7 +1163,6 @@ static int diff_file(diffio_T *dio)
unblock_autocmds(); unblock_autocmds();
xfree(cmd); xfree(cmd);
return OK; return OK;
}
} }
/// Create a new version of a file from the current buffer and a diff file. /// Create a new version of a file from the current buffer and a diff file.

View File

@ -87,10 +87,12 @@ typedef struct insert_state {
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "edit.c.generated.h" # include "edit.c.generated.h"
#endif #endif
#define BACKSPACE_CHAR 1 enum {
#define BACKSPACE_WORD 2 BACKSPACE_CHAR = 1,
#define BACKSPACE_WORD_NOT_SPACE 3 BACKSPACE_WORD = 2,
#define BACKSPACE_LINE 4 BACKSPACE_WORD_NOT_SPACE = 3,
BACKSPACE_LINE = 4,
};
/// Set when doing something for completion that may call edit() recursively, /// Set when doing something for completion that may call edit() recursively,
/// which is not allowed. /// which is not allowed.
@ -1227,9 +1229,8 @@ bool edit(int cmdchar, bool startln, long count)
restart_edit = 'i'; restart_edit = 'i';
force_restart_edit = true; force_restart_edit = true;
return false; return false;
} else {
return terminal_enter();
} }
return terminal_enter();
} }
// Don't allow inserting in the sandbox. // Don't allow inserting in the sandbox.

View File

@ -1927,11 +1927,10 @@ bool next_for_item(void *fi_void, char *arg)
listitem_T *item = fi->fi_lw.lw_item; listitem_T *item = fi->fi_lw.lw_item;
if (item == NULL) { if (item == NULL) {
return false; return false;
} else { }
fi->fi_lw.lw_item = TV_LIST_ITEM_NEXT(fi->fi_list, item); fi->fi_lw.lw_item = TV_LIST_ITEM_NEXT(fi->fi_list, item);
return (ex_let_vars(arg, TV_LIST_ITEM_TV(item), true, return (ex_let_vars(arg, TV_LIST_ITEM_TV(item), true,
fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK); fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK);
}
} }
// TODO(ZyX-I): move to eval/ex_cmds // TODO(ZyX-I): move to eval/ex_cmds
@ -7178,9 +7177,8 @@ int check_luafunc_name(const char *const str, const bool paren)
const char *const p = skip_luafunc_name(str); const char *const p = skip_luafunc_name(str);
if (*p != (paren ? '(' : NUL)) { if (*p != (paren ? '(' : NUL)) {
return 0; return 0;
} else {
return (int)(p - str);
} }
return (int)(p - str);
} }
/// Handle: /// Handle:
@ -7926,9 +7924,8 @@ static var_flavour_T var_flavour(char *varname)
} }
} }
return VAR_FLAVOUR_SHADA; return VAR_FLAVOUR_SHADA;
} else {
return VAR_FLAVOUR_DEFAULT;
} }
return VAR_FLAVOUR_DEFAULT;
} }
/// Iterate over global variables /// Iterate over global variables

View File

@ -284,13 +284,12 @@ typval_T decode_string(const char *const s, const size_t len, const TriState has
} }
} }
return tv; return tv;
} else { }
return (typval_T) { return (typval_T) {
.v_type = VAR_STRING, .v_type = VAR_STRING,
.v_lock = VAR_UNLOCKED, .v_lock = VAR_UNLOCKED,
.vval = { .v_string = ((s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) }, .vval = { .v_string = ((s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) },
}; };
}
} }
/// Parse JSON double-quoted string /// Parse JSON double-quoted string

View File

@ -5240,12 +5240,11 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
xfree(failed_dir); xfree(failed_dir);
rettv->vval.v_number = FAIL; rettv->vval.v_number = FAIL;
return; return;
} else { }
rettv->vval.v_number = OK; rettv->vval.v_number = OK;
return; return;
} }
} }
}
rettv->vval.v_number = vim_mkdir_emsg(dir, prot); rettv->vval.v_number = vim_mkdir_emsg(dir, prot);
} }
@ -7485,9 +7484,8 @@ static void f_serverstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (argvars[0].v_type != VAR_STRING) { if (argvars[0].v_type != VAR_STRING) {
emsg(_(e_invarg)); emsg(_(e_invarg));
return; return;
} else {
address = xstrdup(tv_get_string(argvars));
} }
address = xstrdup(tv_get_string(argvars));
} else { } else {
address = server_address_new(NULL); address = server_address_new(NULL);
} }

View File

@ -1747,9 +1747,8 @@ static bool tv_dict_watcher_matches(DictWatcher *watcher, const char *const key)
const size_t len = watcher->key_pattern_len; const size_t len = watcher->key_pattern_len;
if (len && watcher->key_pattern[len - 1] == '*') { if (len && watcher->key_pattern[len - 1] == '*') {
return strncmp(key, watcher->key_pattern, len - 1) == 0; return strncmp(key, watcher->key_pattern, len - 1) == 0;
} else {
return strcmp(key, watcher->key_pattern) == 0;
} }
return strcmp(key, watcher->key_pattern) == 0;
} }
/// Send a change notification to all dictionary watchers that match given key /// Send a change notification to all dictionary watchers that match given key

View File

@ -2051,9 +2051,8 @@ void ex_function(exarg_T *eap)
} }
xfree(fudi.fd_newkey); xfree(fudi.fd_newkey);
return; return;
} else {
eap->skip = true;
} }
eap->skip = true;
} }
// An error in a function call during evaluation of an expression in magic // An error in a function call during evaluation of an expression in magic

View File

@ -380,9 +380,8 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
} }
} }
return p + 1; return p + 1;
} else {
return skip_var_one((char *)arg);
} }
return skip_var_one((char *)arg);
} }
/// Skip one (assignable) variable name, including @r, $VAR, &option, d.key, /// Skip one (assignable) variable name, including @r, $VAR, &option, d.key,
@ -891,9 +890,8 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
lp->ll_n1++; lp->ll_n1++;
if (lp->ll_li == NULL || (!lp->ll_empty2 && lp->ll_n2 < lp->ll_n1)) { if (lp->ll_li == NULL || (!lp->ll_empty2 && lp->ll_n2 < lp->ll_n1)) {
break; break;
} else {
last_li = lp->ll_li;
} }
last_li = lp->ll_li;
} }
tv_list_remove_items(lp->ll_list, first_li, last_li); tv_list_remove_items(lp->ll_list, first_li, last_li);
} else { } else {

View File

@ -2159,9 +2159,8 @@ static int check_readonly(int *forceit, buf_T *buf)
// Set forceit, to force the writing of a readonly file // Set forceit, to force the writing of a readonly file
*forceit = true; *forceit = true;
return false; return false;
} else {
return true;
} }
return true;
} else if (buf->b_p_ro) { } else if (buf->b_p_ro) {
emsg(_(e_readonly)); emsg(_(e_readonly));
} else { } else {

View File

@ -4364,9 +4364,8 @@ char *check_nextcmd(char *p)
if (*s == '|' || *s == '\n') { if (*s == '|' || *s == '\n') {
return s + 1; return s + 1;
} else {
return NULL;
} }
return NULL;
} }
/// - if there are more files to edit /// - if there are more files to edit
@ -4765,9 +4764,8 @@ static void ex_only(exarg_T *eap)
for (wp = firstwin; --wnr > 0;) { for (wp = firstwin; --wnr > 0;) {
if (wp->w_next == NULL) { if (wp->w_next == NULL) {
break; break;
} else {
wp = wp->w_next;
} }
wp = wp->w_next;
} }
} else { } else {
wp = curwin; wp = curwin;

View File

@ -72,15 +72,17 @@
#endif #endif
#define HAS_BW_FLAGS #define HAS_BW_FLAGS
#define FIO_LATIN1 0x01 // convert Latin1 enum {
#define FIO_UTF8 0x02 // convert UTF-8 FIO_LATIN1 = 0x01, // convert Latin1
#define FIO_UCS2 0x04 // convert UCS-2 FIO_UTF8 = 0x02, // convert UTF-8
#define FIO_UCS4 0x08 // convert UCS-4 FIO_UCS2 = 0x04, // convert UCS-2
#define FIO_UTF16 0x10 // convert UTF-16 FIO_UCS4 = 0x08, // convert UCS-4
#define FIO_ENDIAN_L 0x80 // little endian FIO_UTF16 = 0x10, // convert UTF-16
#define FIO_NOCONVERT 0x2000 // skip encoding conversion FIO_ENDIAN_L = 0x80, // little endian
#define FIO_UCSBOM 0x4000 // check for BOM at start of file FIO_NOCONVERT = 0x2000, // skip encoding conversion
#define FIO_ALL (-1) // allow all formats FIO_UCSBOM = 0x4000, // check for BOM at start of file
FIO_ALL = -1, // allow all formats
};
// When converting, a read() or write() may leave some bytes to be converted // When converting, a read() or write() may leave some bytes to be converted
// for the next call. The value is guessed... // for the next call. The value is guessed...
@ -498,7 +500,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
return FAIL; return FAIL;
} }
return OK; // a new file is not an error return OK; // a new file is not an error
} else { }
filemess(curbuf, sfname, ((fd == UV_EFBIG) ? _("[File too big]") : filemess(curbuf, sfname, ((fd == UV_EFBIG) ? _("[File too big]") :
#if defined(UNIX) && defined(EOVERFLOW) #if defined(UNIX) && defined(EOVERFLOW)
// libuv only returns -errno // libuv only returns -errno
@ -509,7 +511,6 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
#endif #endif
_("[Permission Denied]")), 0); _("[Permission Denied]")), 0);
curbuf->b_p_ro = true; // must use "w!" now curbuf->b_p_ro = true; // must use "w!" now
}
return FAIL; return FAIL;
} }
@ -5232,11 +5233,10 @@ static void vim_mktempdir(void)
if (vim_settempdir(path)) { if (vim_settempdir(path)) {
// Successfully created and set temporary directory so stop trying. // Successfully created and set temporary directory so stop trying.
break; break;
} else { }
// Couldn't set `vim_tempdir` to `path` so remove created directory. // Couldn't set `vim_tempdir` to `path` so remove created directory.
os_rmdir(path); os_rmdir(path);
} }
}
(void)umask(umask_save); (void)umask(umask_save);
} }

View File

@ -57,9 +57,11 @@ typedef struct {
// folds too // folds too
} fold_T; } fold_T;
#define FD_OPEN 0 // fold is open (nested ones can be closed) enum {
#define FD_CLOSED 1 // fold is closed FD_OPEN = 0, // fold is open (nested ones can be closed)
#define FD_LEVEL 2 // depends on 'foldlevel' (nested folds too) FD_CLOSED = 1, // fold is closed
FD_LEVEL = 2, // depends on 'foldlevel' (nested folds too)
};
#define MAX_LEVEL 20 // maximum fold depth #define MAX_LEVEL 20 // maximum fold depth
@ -1772,7 +1774,7 @@ char *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo
} }
} }
if (text == NULL) { if (text == NULL) {
unsigned long count = (unsigned long)(lnume - lnum + 1); unsigned long count = (unsigned long)(lnume - lnum + 1); // NOLINT(bugprone-misplaced-widening-cast)
vim_snprintf(buf, FOLD_TEXT_LEN, vim_snprintf(buf, FOLD_TEXT_LEN,
NGETTEXT("+--%3ld line folded", NGETTEXT("+--%3ld line folded",
@ -3115,7 +3117,7 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
return FAIL; return FAIL;
} }
if (fprintf(fd, "%" PRId64 ",%" PRId64 "fold", if (fprintf(fd, "%" PRId64 ",%" PRId64 "fold",
(int64_t)(fp->fd_top + off), (int64_t)fp->fd_top + off,
(int64_t)(fp->fd_top + off + fp->fd_len - 1)) < 0 (int64_t)(fp->fd_top + off + fp->fd_len - 1)) < 0
|| put_eol(fd) == FAIL) { || put_eol(fd) == FAIL) {
return FAIL; return FAIL;
@ -3136,7 +3138,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
if (fp->fd_flags != FD_LEVEL) { if (fp->fd_flags != FD_LEVEL) {
if (!GA_EMPTY(&fp->fd_nested)) { if (!GA_EMPTY(&fp->fd_nested)) {
// open nested folds while this fold is open // open nested folds while this fold is open
if (fprintf(fd, "%" PRId64, (int64_t)(fp->fd_top + off)) < 0 if (fprintf(fd, "%" PRId64, (int64_t)fp->fd_top + off) < 0
|| put_eol(fd) == FAIL || put_eol(fd) == FAIL
|| put_line(fd, "normal! zo") == FAIL) { || put_line(fd, "normal! zo") == FAIL) {
return FAIL; return FAIL;

View File

@ -122,8 +122,10 @@ static const uint32_t cterm_color_16[16] = {
static int current_syn_id; static int current_syn_id;
#define PRCOLOR_BLACK 0 enum {
#define PRCOLOR_WHITE 0xffffff PRCOLOR_BLACK = 0,
PRCOLOR_WHITE = 0xffffff,
};
static TriState curr_italic; static TriState curr_italic;
static TriState curr_bold; static TriState curr_bold;
@ -132,13 +134,15 @@ static uint32_t curr_bg;
static uint32_t curr_fg; static uint32_t curr_fg;
static int page_count; static int page_count;
#define OPT_MBFONT_USECOURIER 0 enum {
#define OPT_MBFONT_ASCII 1 OPT_MBFONT_USECOURIER = 0,
#define OPT_MBFONT_REGULAR 2 OPT_MBFONT_ASCII = 1,
#define OPT_MBFONT_BOLD 3 OPT_MBFONT_REGULAR = 2,
#define OPT_MBFONT_OBLIQUE 4 OPT_MBFONT_BOLD = 3,
#define OPT_MBFONT_BOLDOBLIQUE 5 OPT_MBFONT_OBLIQUE = 4,
#define OPT_MBFONT_NUM_OPTIONS 6 OPT_MBFONT_BOLDOBLIQUE = 5,
OPT_MBFONT_NUM_OPTIONS = 6,
};
static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] = { static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] = {
{ "c", false, 0, NULL, 0, false }, { "c", false, 0, NULL, 0, false },
@ -935,8 +939,10 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
// Some of these documents can be found in PDF form on Adobe's web site - // Some of these documents can be found in PDF form on Adobe's web site -
// http://www.adobe.com // http://www.adobe.com
#define PRT_PS_DEFAULT_DPI (72) // Default user space resolution enum {
#define PRT_PS_DEFAULT_FONTSIZE (10) PRT_PS_DEFAULT_DPI = 72, // Default user space resolution
PRT_PS_DEFAULT_FONTSIZE = 10,
};
#define PRT_MEDIASIZE_LEN ARRAY_SIZE(prt_mediasize) #define PRT_MEDIASIZE_LEN ARRAY_SIZE(prt_mediasize)
@ -957,10 +963,12 @@ static struct prt_mediasize_S prt_mediasize[] = {
{ "tabloid", 792.0, 1224.0 } { "tabloid", 792.0, 1224.0 }
}; };
#define PRT_PS_FONT_ROMAN (0) enum {
#define PRT_PS_FONT_BOLD (1) PRT_PS_FONT_ROMAN = 0,
#define PRT_PS_FONT_OBLIQUE (2) PRT_PS_FONT_BOLD = 1,
#define PRT_PS_FONT_BOLDOBLIQUE (3) PRT_PS_FONT_OBLIQUE = 2,
PRT_PS_FONT_BOLDOBLIQUE = 3,
};
// Standard font metrics for Courier family // Standard font metrics for Courier family
static struct prt_ps_font_S prt_ps_courier_font = { static struct prt_ps_font_S prt_ps_courier_font = {
@ -981,14 +989,16 @@ static struct prt_ps_font_S prt_ps_mb_font = {
// Pointer to current font set being used // Pointer to current font set being used
static struct prt_ps_font_S *prt_ps_font; static struct prt_ps_font_S *prt_ps_font;
#define CS_JIS_C_1978 (0x01) enum {
#define CS_JIS_X_1983 (0x02) CS_JIS_C_1978 = 0x01,
#define CS_JIS_X_1990 (0x04) CS_JIS_X_1983 = 0x02,
#define CS_NEC (0x08) CS_JIS_X_1990 = 0x04,
#define CS_MSWINDOWS (0x10) CS_NEC = 0x08,
#define CS_CP932 (0x20) CS_MSWINDOWS = 0x10,
#define CS_KANJITALK6 (0x40) CS_CP932 = 0x20,
#define CS_KANJITALK7 (0x80) CS_KANJITALK6 = 0x40,
CS_KANJITALK7 = 0x80,
};
// Japanese encodings and charsets // Japanese encodings and charsets
static struct prt_ps_encoding_S j_encodings[] = { static struct prt_ps_encoding_S j_encodings[] = {
@ -1012,13 +1022,15 @@ static struct prt_ps_charset_S j_charsets[] = {
{ "KANJITALK7", "90pv", CS_KANJITALK7 } { "KANJITALK7", "90pv", CS_KANJITALK7 }
}; };
#define CS_GB_2312_80 (0x01) enum {
#define CS_GBT_12345_90 (0x02) CS_GB_2312_80 = 0x01,
#define CS_GBK2K (0x04) CS_GBT_12345_90 = 0x02,
#define CS_SC_MAC (0x08) CS_GBK2K = 0x04,
#define CS_GBT_90_MAC (0x10) CS_SC_MAC = 0x08,
#define CS_GBK (0x20) CS_GBT_90_MAC = 0x10,
#define CS_SC_ISO10646 (0x40) CS_GBK = 0x20,
CS_SC_ISO10646 = 0x40,
};
// Simplified Chinese encodings and charsets // Simplified Chinese encodings and charsets
static struct prt_ps_encoding_S sc_encodings[] = { static struct prt_ps_encoding_S sc_encodings[] = {
@ -1040,19 +1052,21 @@ static struct prt_ps_charset_S sc_charsets[] = {
{ "ISO10646", "UniGB", CS_SC_ISO10646 } { "ISO10646", "UniGB", CS_SC_ISO10646 }
}; };
#define CS_CNS_PLANE_1 (0x01) enum {
#define CS_CNS_PLANE_2 (0x02) CS_CNS_PLANE_1 = 0x01,
#define CS_CNS_PLANE_1_2 (0x04) CS_CNS_PLANE_2 = 0x02,
#define CS_B5 (0x08) CS_CNS_PLANE_1_2 = 0x04,
#define CS_ETEN (0x10) CS_B5 = 0x08,
#define CS_HK_GCCS (0x20) CS_ETEN = 0x10,
#define CS_HK_SCS (0x40) CS_HK_GCCS = 0x20,
#define CS_HK_SCS_ETEN (0x80) CS_HK_SCS = 0x40,
#define CS_MTHKL (0x100) CS_HK_SCS_ETEN = 0x80,
#define CS_MTHKS (0x200) CS_MTHKL = 0x100,
#define CS_DLHKL (0x400) CS_MTHKS = 0x200,
#define CS_DLHKS (0x800) CS_DLHKL = 0x400,
#define CS_TC_ISO10646 (0x1000) CS_DLHKS = 0x800,
CS_TC_ISO10646 = 0x1000,
};
// Traditional Chinese encodings and charsets // Traditional Chinese encodings and charsets
static struct prt_ps_encoding_S tc_encodings[] = { static struct prt_ps_encoding_S tc_encodings[] = {
@ -1084,10 +1098,12 @@ static struct prt_ps_charset_S tc_charsets[] = {
{ "ISO10646", "UniCNS", CS_TC_ISO10646 } { "ISO10646", "UniCNS", CS_TC_ISO10646 }
}; };
#define CS_KR_X_1992 (0x01) enum {
#define CS_KR_MAC (0x02) CS_KR_X_1992 = 0x01,
#define CS_KR_X_1992_MS (0x04) CS_KR_MAC = 0x02,
#define CS_KR_ISO10646 (0x08) CS_KR_X_1992_MS = 0x04,
CS_KR_ISO10646 = 0x08,
};
// Korean encodings and charsets // Korean encodings and charsets
static struct prt_ps_encoding_S k_encodings[] = { static struct prt_ps_encoding_S k_encodings[] = {
@ -1166,10 +1182,12 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] = {
// Data for table based DSC comment recognition, easy to extend if VIM needs to // Data for table based DSC comment recognition, easy to extend if VIM needs to
// read more comments. // read more comments.
#define PRT_DSC_MISC_TYPE (-1) enum {
#define PRT_DSC_TITLE_TYPE (1) PRT_DSC_MISC_TYPE = -1,
#define PRT_DSC_VERSION_TYPE (2) PRT_DSC_TITLE_TYPE = 1,
#define PRT_DSC_ENDCOMMENTS_TYPE (3) PRT_DSC_VERSION_TYPE = 2,
PRT_DSC_ENDCOMMENTS_TYPE = 3,
};
#define PRT_DSC_TITLE "%%Title:" #define PRT_DSC_TITLE "%%Title:"
#define PRT_DSC_VERSION "%%Version:" #define PRT_DSC_VERSION "%%Version:"

View File

@ -141,10 +141,9 @@ int hl_get_syn_attr(int ns_id, int idx, HlAttrs at_en)
|| at_en.rgb_ae_attr != 0 || ns_id != 0) { || at_en.rgb_ae_attr != 0 || ns_id != 0) {
return get_attr_entry((HlEntry){ .attr = at_en, .kind = kHlSyntax, return get_attr_entry((HlEntry){ .attr = at_en, .kind = kHlSyntax,
.id1 = idx, .id2 = ns_id }); .id1 = idx, .id2 = ns_id });
} else { }
// If all the fields are cleared, clear the attr field back to default value // If all the fields are cleared, clear the attr field back to default value
return 0; return 0;
}
} }
void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id, Dict(highlight) *dict) void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id, Dict(highlight) *dict)
@ -238,12 +237,11 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
if (link) { if (link) {
if (it.attr_id >= 0) { if (it.attr_id >= 0) {
return 0; return 0;
} else { }
if (it.link_global) { if (it.link_global) {
*ns_hl = 0; *ns_hl = 0;
} }
return it.link_id; return it.link_id;
}
} else { } else {
return it.attr_id; return it.attr_id;
} }

View File

@ -23,9 +23,11 @@
/// \addtogroup SG_SET /// \addtogroup SG_SET
/// @{ /// @{
#define SG_CTERM 2 // cterm has been set enum {
#define SG_GUI 4 // gui has been set SG_CTERM = 2, // cterm has been set
#define SG_LINK 8 // link has been set SG_GUI = 4, // gui has been set
SG_LINK = 8, // link has been set
};
/// @} /// @}
#define MAX_SYN_NAME 200 #define MAX_SYN_NAME 200
@ -1730,9 +1732,8 @@ int syn_name2id(const char *name)
if (name[0] == '@') { if (name[0] == '@') {
// if we look up @aaa.bbb, we have to consider @aaa as well // if we look up @aaa.bbb, we have to consider @aaa as well
return syn_check_group(name, strlen(name)); return syn_check_group(name, strlen(name));
} else {
return syn_name2id_len(name, strlen(name));
} }
return syn_name2id_len(name, strlen(name));
} }
/// Lookup a highlight group name and return its ID. /// Lookup a highlight group name and return its ID.

View File

@ -896,9 +896,8 @@ int inindent(int extra)
if (col >= curwin->w_cursor.col + extra) { if (col >= curwin->w_cursor.col + extra) {
return true; return true;
} else {
return false;
} }
return false;
} }
/// @return true if the conditions are OK for smart indenting. /// @return true if the conditions are OK for smart indenting.

View File

@ -458,9 +458,8 @@ bool cin_iscase(const char_u *s, bool strict)
// JS etc. // JS etc.
if (strict) { if (strict) {
return false; // stop at string return false; // stop at string
} else {
return true;
} }
return true;
} }
} }
return false; return false;
@ -2877,7 +2876,7 @@ int get_c_indent(void)
// Line below current line is the one that starts a // Line below current line is the one that starts a
// (possibly broken) line ending in a comma. // (possibly broken) line ending in a comma.
break; break;
} else { }
amount = get_indent(); amount = get_indent();
if (curwin->w_cursor.lnum - 1 == ourscope) { if (curwin->w_cursor.lnum - 1 == ourscope) {
// line above is start of the scope, thus current // line above is start of the scope, thus current
@ -2886,7 +2885,6 @@ int get_c_indent(void)
break; break;
} }
} }
}
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
&& terminated == ',')) { && terminated == ',')) {

View File

@ -56,24 +56,26 @@
#define CTRL_X_WANT_IDENT 0x100 #define CTRL_X_WANT_IDENT 0x100
#define CTRL_X_NORMAL 0 ///< CTRL-N CTRL-P completion, default enum {
#define CTRL_X_NOT_DEFINED_YET 1 CTRL_X_NORMAL = 0, ///< CTRL-N CTRL-P completion, default
#define CTRL_X_SCROLL 2 CTRL_X_NOT_DEFINED_YET = 1,
#define CTRL_X_WHOLE_LINE 3 CTRL_X_SCROLL = 2,
#define CTRL_X_FILES 4 CTRL_X_WHOLE_LINE = 3,
#define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT) CTRL_X_FILES = 4,
#define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT) CTRL_X_TAGS = (5 + CTRL_X_WANT_IDENT),
#define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT) CTRL_X_PATH_PATTERNS = (6 + CTRL_X_WANT_IDENT),
#define CTRL_X_FINISHED 8 CTRL_X_PATH_DEFINES = (7 + CTRL_X_WANT_IDENT),
#define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT) CTRL_X_FINISHED = 8,
#define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT) CTRL_X_DICTIONARY = (9 + CTRL_X_WANT_IDENT),
#define CTRL_X_CMDLINE 11 CTRL_X_THESAURUS = (10 + CTRL_X_WANT_IDENT),
#define CTRL_X_FUNCTION 12 CTRL_X_CMDLINE = 11,
#define CTRL_X_OMNI 13 CTRL_X_FUNCTION = 12,
#define CTRL_X_SPELL 14 CTRL_X_OMNI = 13,
#define CTRL_X_LOCAL_MSG 15 ///< only used in "ctrl_x_msgs" CTRL_X_SPELL = 14,
#define CTRL_X_EVAL 16 ///< for builtin function complete() CTRL_X_LOCAL_MSG = 15, ///< only used in "ctrl_x_msgs"
#define CTRL_X_CMDLINE_CTRL_X 17 ///< CTRL-X typed in CTRL_X_CMDLINE CTRL_X_EVAL = 16, ///< for builtin function complete()
CTRL_X_CMDLINE_CTRL_X = 17, ///< CTRL-X typed in CTRL_X_CMDLINE
};
#define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] #define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]

View File

@ -906,9 +906,8 @@ Float nlua_pop_Float(lua_State *lstate, Error *err)
lua_pop(lstate, 1); lua_pop(lstate, 1);
if (table_props.type != kObjectTypeFloat) { if (table_props.type != kObjectTypeFloat) {
return 0; return 0;
} else {
return (Float)table_props.val;
} }
return (Float)table_props.val;
} }
/// Convert lua table to array without determining whether it is array /// Convert lua table to array without determining whether it is array

View File

@ -378,7 +378,7 @@ int nlua_setvar(lua_State *lstate)
if (di == NULL) { if (di == NULL) {
// Doesn't exist, nothing to do // Doesn't exist, nothing to do
return 0; return 0;
} else { }
// Notify watchers // Notify watchers
if (watched) { if (watched) {
tv_dict_watcher_notify(dict, key.data, NULL, &di->di_tv); tv_dict_watcher_notify(dict, key.data, NULL, &di->di_tv);
@ -386,7 +386,6 @@ int nlua_setvar(lua_State *lstate)
// Delete the entry // Delete the entry
tv_dict_item_remove(dict, di); tv_dict_item_remove(dict, di);
}
} else { } else {
// Update the key // Update the key
typval_T tv; typval_T tv;

View File

@ -88,16 +88,20 @@
#include "nvim/api/extmark.h" #include "nvim/api/extmark.h"
// values for "window_layout" // values for "window_layout"
#define WIN_HOR 1 // "-o" horizontally split windows enum {
#define WIN_VER 2 // "-O" vertically split windows WIN_HOR = 1, // "-o" horizontally split windows
#define WIN_TABS 3 // "-p" windows on tab pages WIN_VER = 2, // "-O" vertically split windows
WIN_TABS = 3, // "-p" windows on tab pages
};
// Values for edit_type. // Values for edit_type.
#define EDIT_NONE 0 // no edit type yet enum {
#define EDIT_FILE 1 // file name argument[s] given, use argument list EDIT_NONE = 0, // no edit type yet
#define EDIT_STDIN 2 // read file from stdin EDIT_FILE = 1, // file name argument[s] given, use argument list
#define EDIT_TAG 3 // tag name argument given, use tagname EDIT_STDIN = 2, // read file from stdin
#define EDIT_QF 4 // start in quickfix mode EDIT_TAG = 3, // tag name argument given, use tagname
EDIT_QF = 4, // start in quickfix mode
};
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "main.c.generated.h" # include "main.c.generated.h"

View File

@ -1479,9 +1479,8 @@ const void *mark_jumplist_iter(const void *const iter, const win_T *const win, x
*fm = *iter_mark; *fm = *iter_mark;
if (iter_mark == &(win->w_jumplist[win->w_jumplistlen - 1])) { if (iter_mark == &(win->w_jumplist[win->w_jumplistlen - 1])) {
return NULL; return NULL;
} else {
return iter_mark + 1;
} }
return iter_mark + 1;
} }
/// Iterate over global marks /// Iterate over global marks

View File

@ -805,7 +805,7 @@ bool get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol)
|| (prevcol > (long)search_hl->startcol || (prevcol > (long)search_hl->startcol
&& search_hl->endcol == MAXCOL))) { && search_hl->endcol == MAXCOL))) {
return true; return true;
} else { }
cur = wp->w_match_head; cur = wp->w_match_head;
while (cur != NULL) { while (cur != NULL) {
if (!cur->mit_hl.is_addpos && (prevcol == (long)cur->mit_hl.startcol if (!cur->mit_hl.is_addpos && (prevcol == (long)cur->mit_hl.startcol
@ -815,7 +815,7 @@ bool get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol)
} }
cur = cur->mit_next; cur = cur->mit_next;
} }
}
return false; return false;
} }

View File

@ -1186,9 +1186,8 @@ static int utf_convert(int a, const convertStruct *const table, size_t n_items)
&& a <= table[start].rangeEnd && a <= table[start].rangeEnd
&& (a - table[start].rangeStart) % table[start].step == 0) { && (a - table[start].rangeStart) % table[start].step == 0) {
return a + table[start].offset; return a + table[start].offset;
} else {
return a;
} }
return a;
} }
// Return the folded-case equivalent of "a", which is a UCS-4 character. Uses // Return the folded-case equivalent of "a", which is a UCS-4 character. Uses

View File

@ -815,8 +815,10 @@ static bool mf_do_open(memfile_T *mfp, char *fname, int flags)
/// The number of buckets in the hashtable is increased by a factor of /// The number of buckets in the hashtable is increased by a factor of
/// MHT_GROWTH_FACTOR when the average number of items per bucket /// MHT_GROWTH_FACTOR when the average number of items per bucket
/// exceeds 2 ^ MHT_LOG_LOAD_FACTOR. /// exceeds 2 ^ MHT_LOG_LOAD_FACTOR.
#define MHT_LOG_LOAD_FACTOR 6 enum {
#define MHT_GROWTH_FACTOR 2 // must be a power of two MHT_LOG_LOAD_FACTOR = 6,
MHT_GROWTH_FACTOR = 2, // must be a power of two
};
/// Initialize an empty hash table. /// Initialize an empty hash table.
static void mf_hash_init(mf_hashtab_T *mht) static void mf_hash_init(mf_hashtab_T *mht)

View File

@ -83,10 +83,12 @@ typedef struct pointer_block PTR_BL; // contents of a pointer block
typedef struct data_block DATA_BL; // contents of a data block typedef struct data_block DATA_BL; // contents of a data block
typedef struct pointer_entry PTR_EN; // block/line-count pair typedef struct pointer_entry PTR_EN; // block/line-count pair
#define DATA_ID (('d' << 8) + 'a') // data block id enum {
#define PTR_ID (('p' << 8) + 't') // pointer block id DATA_ID = (('d' << 8) + 'a'), // data block id
#define BLOCK0_ID0 'b' // block 0 id 0 PTR_ID = (('p' << 8) + 't'), // pointer block id
#define BLOCK0_ID1 '0' // block 0 id 1 BLOCK0_ID0 = 'b', // block 0 id 0
BLOCK0_ID1 = '0', // block 0 id 1
};
// pointer to a block, used in a pointer block // pointer to a block, used in a pointer block
struct pointer_entry { struct pointer_entry {
@ -134,18 +136,22 @@ struct data_block {
#define INDEX_SIZE (sizeof(unsigned)) // size of one db_index entry #define INDEX_SIZE (sizeof(unsigned)) // size of one db_index entry
#define HEADER_SIZE (sizeof(DATA_BL) - INDEX_SIZE) // size of data block header #define HEADER_SIZE (sizeof(DATA_BL) - INDEX_SIZE) // size of data block header
#define B0_FNAME_SIZE_ORG 900 // what it was in older versions enum {
#define B0_FNAME_SIZE_NOCRYPT 898 // 2 bytes used for other things B0_FNAME_SIZE_ORG = 900, // what it was in older versions
#define B0_FNAME_SIZE_CRYPT 890 // 10 bytes used for other things B0_FNAME_SIZE_NOCRYPT = 898, // 2 bytes used for other things
#define B0_UNAME_SIZE 40 B0_FNAME_SIZE_CRYPT = 890, // 10 bytes used for other things
#define B0_HNAME_SIZE 40 B0_UNAME_SIZE = 40,
B0_HNAME_SIZE = 40,
};
// Restrict the numbers to 32 bits, otherwise most compilers will complain. // Restrict the numbers to 32 bits, otherwise most compilers will complain.
// This won't detect a 64 bit machine that only swaps a byte in the top 32 // This won't detect a 64 bit machine that only swaps a byte in the top 32
// bits, but that is crazy anyway. // bits, but that is crazy anyway.
#define B0_MAGIC_LONG 0x30313233L enum {
#define B0_MAGIC_INT 0x20212223L B0_MAGIC_LONG = 0x30313233L,
#define B0_MAGIC_SHORT 0x10111213L B0_MAGIC_INT = 0x20212223L,
#define B0_MAGIC_CHAR 0x55 B0_MAGIC_SHORT = 0x10111213L,
B0_MAGIC_CHAR = 0x55,
};
// Block zero holds all info about the swap file. // Block zero holds all info about the swap file.
// //
@ -205,10 +211,12 @@ struct block0 {
static linenr_T lowest_marked = 0; static linenr_T lowest_marked = 0;
// arguments for ml_find_line() // arguments for ml_find_line()
#define ML_DELETE 0x11 // delete line enum {
#define ML_INSERT 0x12 // insert line ML_DELETE = 0x11, // delete line
#define ML_FIND 0x13 // just find the line ML_INSERT = 0x12, // insert line
#define ML_FLUSH 0x02 // flush locked block ML_FIND = 0x13, // just find the line
ML_FLUSH = 0x02, // flush locked block
};
#define ML_SIMPLE(x) ((x) & 0x10) // DEL, INS or FIND #define ML_SIMPLE(x) ((x) & 0x10) // DEL, INS or FIND
// argument for ml_upd_block0() // argument for ml_upd_block0()
@ -271,7 +279,7 @@ int ml_open(buf_T *buf)
b0p->b0_id[0] = BLOCK0_ID0; b0p->b0_id[0] = BLOCK0_ID0;
b0p->b0_id[1] = BLOCK0_ID1; b0p->b0_id[1] = BLOCK0_ID1;
b0p->b0_magic_long = B0_MAGIC_LONG; b0p->b0_magic_long = B0_MAGIC_LONG;
b0p->b0_magic_int = (int)B0_MAGIC_INT; b0p->b0_magic_int = B0_MAGIC_INT;
b0p->b0_magic_short = (int16_t)B0_MAGIC_SHORT; b0p->b0_magic_short = (int16_t)B0_MAGIC_SHORT;
b0p->b0_magic_char = B0_MAGIC_CHAR; b0p->b0_magic_char = B0_MAGIC_CHAR;
xstrlcpy(xstpcpy((char *)b0p->b0_version, "VIM "), Version, 6); xstrlcpy(xstpcpy((char *)b0p->b0_version, "VIM "), Version, 6);
@ -3375,7 +3383,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
static int b0_magic_wrong(ZERO_BL *b0p) static int b0_magic_wrong(ZERO_BL *b0p)
{ {
return b0p->b0_magic_long != B0_MAGIC_LONG return b0p->b0_magic_long != B0_MAGIC_LONG
|| b0p->b0_magic_int != (int)B0_MAGIC_INT || b0p->b0_magic_int != B0_MAGIC_INT
|| b0p->b0_magic_short != (int16_t)B0_MAGIC_SHORT || b0p->b0_magic_short != (int16_t)B0_MAGIC_SHORT
|| b0p->b0_magic_char != B0_MAGIC_CHAR; || b0p->b0_magic_char != B0_MAGIC_CHAR;
} }
@ -3525,8 +3533,10 @@ void ml_setflags(buf_T *buf)
} }
} }
#define MLCS_MAXL 800 // max no of lines in chunk enum {
#define MLCS_MINL 400 // should be half of MLCS_MAXL MLCS_MAXL = 800, // max no of lines in chunk
MLCS_MINL = 400, // should be half of MLCS_MAXL
};
/// Keep information for finding byte offset of a line /// Keep information for finding byte offset of a line
/// ///

View File

@ -439,9 +439,8 @@ char *xstrdupnul(const char *const str)
{ {
if (str == NULL) { if (str == NULL) {
return xmallocz(0); return xmallocz(0);
} else {
return xstrdup(str);
} }
return xstrdup(str);
} }
/// A version of memchr that starts the search at `src + len`. /// A version of memchr that starts the search at `src + len`.

View File

@ -59,8 +59,10 @@ struct msgchunk_S {
}; };
// Magic chars used in confirm dialog strings // Magic chars used in confirm dialog strings
#define DLG_BUTTON_SEP '\n' enum {
#define DLG_HOTKEY_CHAR '&' DLG_BUTTON_SEP = '\n',
DLG_HOTKEY_CHAR = '&',
};
static int confirm_msg_used = false; // displaying confirm_msg static int confirm_msg_used = false; // displaying confirm_msg
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -1179,17 +1179,15 @@ retnomove:
// Don't use start_arrow() if we're in the same window // Don't use start_arrow() if we're in the same window
if (curwin == old_curwin) { if (curwin == old_curwin) {
return IN_STATUS_LINE; return IN_STATUS_LINE;
} else {
return IN_STATUS_LINE | CURSOR_MOVED;
} }
return IN_STATUS_LINE | CURSOR_MOVED;
} }
if (sep_line_offset) { // In (or below) status line if (sep_line_offset) { // In (or below) status line
// Don't use start_arrow() if we're in the same window // Don't use start_arrow() if we're in the same window
if (curwin == old_curwin) { if (curwin == old_curwin) {
return IN_SEP_LINE; return IN_SEP_LINE;
} else {
return IN_SEP_LINE | CURSOR_MOVED;
} }
return IN_SEP_LINE | CURSOR_MOVED;
} }
curwin->w_cursor.lnum = curwin->w_topline; curwin->w_cursor.lnum = curwin->w_topline;

View File

@ -4299,9 +4299,8 @@ static void nv_brackets(cmdarg_T *cap)
cap->nchar == 's', false, NULL) == 0) { cap->nchar == 's', false, NULL) == 0) {
clearopbeep(cap->oap); clearopbeep(cap->oap);
break; break;
} else {
curwin->w_set_curswant = true;
} }
curwin->w_set_curswant = true;
} }
if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) { if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) {
foldOpenCursor(); foldOpenCursor();

View File

@ -2960,15 +2960,13 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o
if (p->indir & PV_WIN) { if (p->indir & PV_WIN) {
if (opt_type == SREQ_BUF) { if (opt_type == SREQ_BUF) {
return 0; // Requested buffer-local, not window-local option return 0; // Requested buffer-local, not window-local option
} else {
rv |= SOPT_WIN;
} }
rv |= SOPT_WIN;
} else if (p->indir & PV_BUF) { } else if (p->indir & PV_BUF) {
if (opt_type == SREQ_WIN) { if (opt_type == SREQ_WIN) {
return 0; // Requested window-local, not buffer-local option return 0; // Requested window-local, not buffer-local option
} else {
rv |= SOPT_BUF;
} }
rv |= SOPT_BUF;
} }
} }
@ -2979,9 +2977,8 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o
if (opt_type == SREQ_GLOBAL) { if (opt_type == SREQ_GLOBAL) {
if (p->var == VAR_WIN) { if (p->var == VAR_WIN) {
return 0; return 0;
} else {
varp = p->var;
} }
varp = p->var;
} else { } else {
if (opt_type == SREQ_BUF) { if (opt_type == SREQ_BUF) {
// Special case: 'modified' is b_changed, but we also want to // Special case: 'modified' is b_changed, but we also want to
@ -3104,9 +3101,8 @@ char *set_option_value(const char *const name, const long number, const char *co
} }
if (flags & P_NUM) { if (flags & P_NUM) {
return set_num_option(opt_idx, varp, numval, NULL, 0, opt_flags); return set_num_option(opt_idx, varp, numval, NULL, 0, opt_flags);
} else {
return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
} }
return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
} }
} }
return NULL; return NULL;

View File

@ -837,10 +837,9 @@ const void *vim_env_iter(const char delim, const char *const val, const void *co
if (dirend == NULL) { if (dirend == NULL) {
*len = strlen(varval); *len = strlen(varval);
return NULL; return NULL;
} else { }
*len = (size_t)(dirend - varval); *len = (size_t)(dirend - varval);
return dirend + 1; return dirend + 1;
}
} }
/// Iterates $PATH-like delimited list `val` in reverse order. /// Iterates $PATH-like delimited list `val` in reverse order.
@ -870,11 +869,10 @@ const void *vim_env_iter_rev(const char delim, const char *const val, const void
*len = varlen; *len = varlen;
*dir = val; *dir = val;
return NULL; return NULL;
} else { }
*dir = colon + 1; *dir = colon + 1;
*len = (size_t)(varend - colon); *len = (size_t)(varend - colon);
return colon - 1; return colon - 1;
}
} }
/// @param[out] exe_name should be at least MAXPATHL in size /// @param[out] exe_name should be at least MAXPATHL in size

View File

@ -121,9 +121,8 @@ bool os_isrealdir(const char *name)
fs_loop_unlock(); fs_loop_unlock();
if (S_ISLNK(request.statbuf.st_mode)) { if (S_ISLNK(request.statbuf.st_mode)) {
return false; return false;
} else {
return S_ISDIR(request.statbuf.st_mode);
} }
return S_ISDIR(request.statbuf.st_mode);
} }
/// Check if the given path exists and is a directory. /// Check if the given path exists and is a directory.
@ -249,9 +248,8 @@ bool os_can_exe(const char *name, char **abspath, bool use_path)
&& is_executable(name, abspath)) { && is_executable(name, abspath)) {
#endif #endif
return true; return true;
} else {
return false;
} }
return false;
} }
return is_executable_in_path(name, abspath); return is_executable_in_path(name, abspath);
@ -756,9 +754,8 @@ int32_t os_getperm(const char *name)
int stat_result = os_stat(name, &statbuf); int stat_result = os_stat(name, &statbuf);
if (stat_result == kLibuvSuccess) { if (stat_result == kLibuvSuccess) {
return (int32_t)statbuf.st_mode; return (int32_t)statbuf.st_mode;
} else {
return stat_result;
} }
return stat_result;
} }
/// Set the permission of a file. /// Set the permission of a file.

View File

@ -469,9 +469,8 @@ static InbufPollResult inbuf_poll(int ms, MultiQueue *events)
if (input_ready(events)) { if (input_ready(events)) {
return kInputAvail; return kInputAvail;
} else {
return input_eof ? kInputEof : kInputNone;
} }
return input_eof ? kInputEof : kInputNone;
} }
void input_done(void) void input_done(void)

View File

@ -33,8 +33,10 @@
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/window.h" #include "nvim/window.h"
#define URL_SLASH 1 // path_is_url() has found ":/" enum {
#define URL_BACKSLASH 2 // path_is_url() has found ":\\" URL_SLASH = 1, // path_is_url() has found ":/"
URL_BACKSLASH = 2, // path_is_url() has found ":\\"
};
#ifdef gen_expand_wildcards #ifdef gen_expand_wildcards
# undef gen_expand_wildcards # undef gen_expand_wildcards

View File

@ -238,9 +238,8 @@ int win_chartabsize(win_T *wp, char *p, colnr_T col)
buf_T *buf = wp->w_buffer; buf_T *buf = wp->w_buffer;
if (*p == TAB && (!wp->w_p_list || wp->w_p_lcs_chars.tab1)) { if (*p == TAB && (!wp->w_p_list || wp->w_p_lcs_chars.tab1)) {
return tabstop_padding(col, buf->b_p_ts, buf->b_p_vts_array); return tabstop_padding(col, buf->b_p_ts, buf->b_p_vts_array);
} else {
return ptr2cells(p);
} }
return ptr2cells(p);
} }
/// Return the number of characters the string 's' will take on the screen, /// Return the number of characters the string 's' will take on the screen,

View File

@ -762,13 +762,12 @@ static bool pum_set_selected(int n, int repeat)
if (e == NULL) { if (e == NULL) {
ml_append(lnum++, (char *)p, 0, false); ml_append(lnum++, (char *)p, 0, false);
break; break;
} else { }
*e = NUL; *e = NUL;
ml_append(lnum++, (char *)p, (int)(e - p + 1), false); ml_append(lnum++, (char *)p, (int)(e - p + 1), false);
*e = '\n'; *e = '\n';
p = e + 1; p = e + 1;
} }
}
// Increase the height of the preview window to show the // Increase the height of the preview window to show the
// text, but no more than 'previewheight' lines. // text, but no more than 'previewheight' lines.

View File

@ -2153,12 +2153,11 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
if ((*stackptr)->dirname != NULL) { if ((*stackptr)->dirname != NULL) {
return (*stackptr)->dirname; return (*stackptr)->dirname;
} else { }
ds_ptr = *stackptr; ds_ptr = *stackptr;
*stackptr = (*stackptr)->next; *stackptr = (*stackptr)->next;
xfree(ds_ptr); xfree(ds_ptr);
return NULL; return NULL;
}
} }
// pop dirbuf from the directory stack and return previous directory or NULL if // pop dirbuf from the directory stack and return previous directory or NULL if
@ -2706,11 +2705,10 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int
if (!can_abandon(curbuf, forceit)) { if (!can_abandon(curbuf, forceit)) {
no_write_message(); no_write_message();
return FAIL; return FAIL;
} else { }
retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
ECMD_HIDE + ECMD_SET_HELP, ECMD_HIDE + ECMD_SET_HELP,
prev_winid == curwin->handle ? curwin : NULL); prev_winid == curwin->handle ? curwin : NULL);
}
} else { } else {
retval = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1, retval = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1,
GETF_SETMARK | GETF_SWITCH, forceit); GETF_SETMARK | GETF_SWITCH, forceit);
@ -5140,12 +5138,11 @@ static bool vgr_qflist_valid(win_T *wp, qf_info_T *qi, unsigned qfid, char *titl
// An autocmd has freed the location list // An autocmd has freed the location list
emsg(_(e_current_location_list_was_changed)); emsg(_(e_current_location_list_was_changed));
return false; return false;
} else { }
// Quickfix list is not found, create a new one. // Quickfix list is not found, create a new one.
qf_new_list(qi, title); qf_new_list(qi, title);
return true; return true;
} }
}
if (qf_restore_list(qi, qfid) == FAIL) { if (qf_restore_list(qi, qfid) == FAIL) {
return false; return false;
} }

View File

@ -3017,10 +3017,9 @@ shada_write_file_open: {}
assert(sd_reader.close != NULL); assert(sd_reader.close != NULL);
sd_reader.close(&sd_reader); sd_reader.close(&sd_reader);
return FAIL; return FAIL;
} else { }
(*wp)++; (*wp)++;
goto shada_write_file_open; goto shada_write_file_open;
}
} else { } else {
semsg(_(SERR "System error while opening temporary ShaDa file %s " semsg(_(SERR "System error while opening temporary ShaDa file %s "
"for writing: %s"), tempname, os_strerror(error)); "for writing: %s"), tempname, os_strerror(error));
@ -3260,14 +3259,13 @@ static ShaDaReadResult fread_len(ShaDaReadDef *const sd_reader, char *const buff
semsg(_(SERR "System error while reading ShaDa file: %s"), semsg(_(SERR "System error while reading ShaDa file: %s"),
sd_reader->error); sd_reader->error);
return kSDReadStatusReadError; return kSDReadStatusReadError;
} else { }
semsg(_(RCERR "Error while reading ShaDa file: " semsg(_(RCERR "Error while reading ShaDa file: "
"last entry specified that it occupies %" PRIu64 " bytes, " "last entry specified that it occupies %" PRIu64 " bytes, "
"but file ended earlier"), "but file ended earlier"),
(uint64_t)length); (uint64_t)length);
return kSDReadStatusNotShaDa; return kSDReadStatusNotShaDa;
} }
}
return kSDReadStatusSuccess; return kSDReadStatusSuccess;
} }
@ -3579,7 +3577,7 @@ shada_read_next_item_start:
entry->type = kSDItemMissing; entry->type = kSDItemMissing;
} }
return spm_ret; return spm_ret;
} else { }
entry->data.unknown_item.contents = xmalloc(length); entry->data.unknown_item.contents = xmalloc(length);
const ShaDaReadResult fl_ret = const ShaDaReadResult fl_ret =
fread_len(sd_reader, entry->data.unknown_item.contents, length); fread_len(sd_reader, entry->data.unknown_item.contents, length);
@ -3589,7 +3587,6 @@ shada_read_next_item_start:
} }
return fl_ret; return fl_ret;
} }
}
msgpack_unpacked unpacked; msgpack_unpacked unpacked;
char *buf = NULL; char *buf = NULL;

View File

@ -112,11 +112,13 @@
#include "nvim/vim.h" // for curwin, strlen, STRLCPY, STRNCMP #include "nvim/vim.h" // for curwin, strlen, STRLCPY, STRNCMP
// Result values. Lower number is accepted over higher one. // Result values. Lower number is accepted over higher one.
#define SP_BANNED (-1) enum {
#define SP_RARE 0 SP_BANNED = -1,
#define SP_OK 1 SP_RARE = 0,
#define SP_LOCAL 2 SP_OK = 1,
#define SP_BAD 3 SP_LOCAL = 2,
SP_BAD = 3,
};
// First language that is loaded, start of the linked list of loaded // First language that is loaded, start of the linked list of loaded
// languages. // languages.

View File

@ -258,50 +258,55 @@
// Special byte values for <byte>. Some are only used in the tree for // Special byte values for <byte>. Some are only used in the tree for
// postponed prefixes, some only in the other trees. This is a bit messy... // postponed prefixes, some only in the other trees. This is a bit messy...
#define BY_NOFLAGS 0 // end of word without flags or region; for enum {
// postponed prefix: no <pflags> BY_NOFLAGS = 0, // end of word without flags or region; for postponed prefix: no <pflags>
#define BY_INDEX 1 // child is shared, index follows BY_INDEX = 1, // child is shared, index follows
#define BY_FLAGS 2 // end of word, <flags> byte follows; for BY_FLAGS = 2, // end of word, <flags> byte follows; for postponed prefix: <pflags> follows
// postponed prefix: <pflags> follows BY_FLAGS2 = 3, // end of word, <flags> and <flags2> bytes follow; never used in prefix tree
#define BY_FLAGS2 3 // end of word, <flags> and <flags2> bytes BY_SPECIAL = BY_FLAGS2, // highest special byte value
// follow; never used in prefix tree };
#define BY_SPECIAL BY_FLAGS2 // highest special byte value
#define ZERO_FLAG 65009 // used when flag is zero: "0" #define ZERO_FLAG 65009 // used when flag is zero: "0"
// Flags used in .spl file for soundsalike flags. // Flags used in .spl file for soundsalike flags.
#define SAL_F0LLOWUP 1 enum {
#define SAL_COLLAPSE 2 SAL_F0LLOWUP = 1,
#define SAL_REM_ACCENTS 4 SAL_COLLAPSE = 2,
SAL_REM_ACCENTS = 4,
};
#define VIMSPELLMAGIC "VIMspell" // string at start of Vim spell file #define VIMSPELLMAGIC "VIMspell" // string at start of Vim spell file
#define VIMSPELLMAGICL (sizeof(VIMSPELLMAGIC) - 1) #define VIMSPELLMAGICL (sizeof(VIMSPELLMAGIC) - 1)
#define VIMSPELLVERSION 50 #define VIMSPELLVERSION 50
// Section IDs. Only renumber them when VIMSPELLVERSION changes! // Section IDs. Only renumber them when VIMSPELLVERSION changes!
#define SN_REGION 0 // <regionname> section enum {
#define SN_CHARFLAGS 1 // charflags section SN_REGION = 0, // <regionname> section
#define SN_MIDWORD 2 // <midword> section SN_CHARFLAGS = 1, // charflags section
#define SN_PREFCOND 3 // <prefcond> section SN_MIDWORD = 2, // <midword> section
#define SN_REP 4 // REP items section SN_PREFCOND = 3, // <prefcond> section
#define SN_SAL 5 // SAL items section SN_REP = 4, // REP items section
#define SN_SOFO 6 // soundfolding section SN_SAL = 5, // SAL items section
#define SN_MAP 7 // MAP items section SN_SOFO = 6, // soundfolding section
#define SN_COMPOUND 8 // compound words section SN_MAP = 7, // MAP items section
#define SN_SYLLABLE 9 // syllable section SN_COMPOUND = 8, // compound words section
#define SN_NOBREAK 10 // NOBREAK section SN_SYLLABLE = 9, // syllable section
#define SN_SUGFILE 11 // timestamp for .sug file SN_NOBREAK = 10, // NOBREAK section
#define SN_REPSAL 12 // REPSAL items section SN_SUGFILE = 11, // timestamp for .sug file
#define SN_WORDS 13 // common words SN_REPSAL = 12, // REPSAL items section
#define SN_NOSPLITSUGS 14 // don't split word for suggestions SN_WORDS = 13, // common words
#define SN_INFO 15 // info section SN_NOSPLITSUGS = 14, // don't split word for suggestions
#define SN_NOCOMPOUNDSUGS 16 // don't compound for suggestions SN_INFO = 15, // info section
#define SN_END 255 // end of sections SN_NOCOMPOUNDSUGS = 16, // don't compound for suggestions
SN_END = 255, // end of sections
};
#define SNF_REQUIRED 1 // <sectionflags>: required section #define SNF_REQUIRED 1 // <sectionflags>: required section
#define CF_WORD 0x01 enum {
#define CF_UPPER 0x02 CF_WORD = 0x01,
CF_UPPER = 0x02,
};
static char *e_spell_trunc = N_("E758: Truncated spell file"); static char *e_spell_trunc = N_("E758: Truncated spell file");
static char *e_illegal_character_in_word = N_("E1280: Illegal character in word"); static char *e_illegal_character_in_word = N_("E1280: Illegal character in word");

View File

@ -91,45 +91,55 @@ typedef struct {
#define SUG_MAX_COUNT(su) (SUG_CLEAN_COUNT(su) + 50) #define SUG_MAX_COUNT(su) (SUG_CLEAN_COUNT(su) + 50)
// score for various changes // score for various changes
#define SCORE_SPLIT 149 // split bad word enum {
#define SCORE_SPLIT_NO 249 // split bad word with NOSPLITSUGS SCORE_SPLIT = 149, // split bad word
#define SCORE_ICASE 52 // slightly different case SCORE_SPLIT_NO = 249, // split bad word with NOSPLITSUGS
#define SCORE_REGION 200 // word is for different region SCORE_ICASE = 52, // slightly different case
#define SCORE_RARE 180 // rare word SCORE_REGION = 200, // word is for different region
#define SCORE_SWAP 75 // swap two characters SCORE_RARE = 180, // rare word
#define SCORE_SWAP3 110 // swap two characters in three SCORE_SWAP = 75, // swap two characters
#define SCORE_REP 65 // REP replacement SCORE_SWAP3 = 110, // swap two characters in three
#define SCORE_SUBST 93 // substitute a character SCORE_REP = 65, // REP replacement
#define SCORE_SIMILAR 33 // substitute a similar character SCORE_SUBST = 93, // substitute a character
#define SCORE_SUBCOMP 33 // substitute a composing character SCORE_SIMILAR = 33, // substitute a similar character
#define SCORE_DEL 94 // delete a character SCORE_SUBCOMP = 33, // substitute a composing character
#define SCORE_DELDUP 66 // delete a duplicated character SCORE_DEL = 94, // delete a character
#define SCORE_DELCOMP 28 // delete a composing character SCORE_DELDUP = 66, // delete a duplicated character
#define SCORE_INS 96 // insert a character SCORE_DELCOMP = 28, // delete a composing character
#define SCORE_INSDUP 67 // insert a duplicate character SCORE_INS = 96, // insert a character
#define SCORE_INSCOMP 30 // insert a composing character SCORE_INSDUP = 67, // insert a duplicate character
#define SCORE_NONWORD 103 // change non-word to word char SCORE_INSCOMP = 30, // insert a composing character
SCORE_NONWORD = 103, // change non-word to word char
};
#define SCORE_FILE 30 // suggestion from a file enum {
#define SCORE_MAXINIT 350 // Initial maximum score: higher == slower. SCORE_FILE = 30, // suggestion from a file
SCORE_MAXINIT = 350, // Initial maximum score: higher == slower.
// 350 allows for about three changes. // 350 allows for about three changes.
};
#define SCORE_COMMON1 30 // subtracted for words seen before enum {
#define SCORE_COMMON2 40 // subtracted for words often seen SCORE_COMMON1 = 30, // subtracted for words seen before
#define SCORE_COMMON3 50 // subtracted for words very often seen SCORE_COMMON2 = 40, // subtracted for words often seen
#define SCORE_THRES2 10 // word count threshold for COMMON2 SCORE_COMMON3 = 50, // subtracted for words very often seen
#define SCORE_THRES3 100 // word count threshold for COMMON3 SCORE_THRES2 = 10, // word count threshold for COMMON2
SCORE_THRES3 = 100, // word count threshold for COMMON3
};
// When trying changed soundfold words it becomes slow when trying more than // When trying changed soundfold words it becomes slow when trying more than
// two changes. With less than two changes it's slightly faster but we miss a // two changes. With less than two changes it's slightly faster but we miss a
// few good suggestions. In rare cases we need to try three of four changes. // few good suggestions. In rare cases we need to try three of four changes.
#define SCORE_SFMAX1 200 // maximum score for first try enum {
#define SCORE_SFMAX2 300 // maximum score for second try SCORE_SFMAX1 = 200, // maximum score for first try
#define SCORE_SFMAX3 400 // maximum score for third try SCORE_SFMAX2 = 300, // maximum score for second try
SCORE_SFMAX3 = 400, // maximum score for third try
};
#define SCORE_BIG (SCORE_INS * 3) // big difference #define SCORE_BIG (SCORE_INS * 3) // big difference
#define SCORE_MAXMAX 999999 // accept any score enum {
#define SCORE_LIMITMAX 350 // for spell_edit_score_limit() SCORE_MAXMAX = 999999, // accept any score
SCORE_LIMITMAX = 350, // for spell_edit_score_limit()
};
// for spell_edit_score_limit() we need to know the minimum value of // for spell_edit_score_limit() we need to know the minimum value of
// SCORE_ICASE, SCORE_SWAP, SCORE_DEL, SCORE_SIMILAR and SCORE_INS // SCORE_ICASE, SCORE_SWAP, SCORE_DEL, SCORE_SIMILAR and SCORE_INS
@ -186,19 +196,25 @@ typedef struct trystate_S {
} trystate_T; } trystate_T;
// values for ts_isdiff // values for ts_isdiff
#define DIFF_NONE 0 // no different byte (yet) enum {
#define DIFF_YES 1 // different byte found DIFF_NONE = 0, // no different byte (yet)
#define DIFF_INSERT 2 // inserting character DIFF_YES = 1, // different byte found
DIFF_INSERT = 2, // inserting character
};
// values for ts_flags // values for ts_flags
#define TSF_PREFIXOK 1 // already checked that prefix is OK enum {
#define TSF_DIDSPLIT 2 // tried split at this point TSF_PREFIXOK = 1, // already checked that prefix is OK
#define TSF_DIDDEL 4 // did a delete, "ts_delidx" has index TSF_DIDSPLIT = 2, // tried split at this point
TSF_DIDDEL = 4, // did a delete, "ts_delidx" has index
};
// special values ts_prefixdepth // special values ts_prefixdepth
#define PFD_NOPREFIX 0xff // not using prefixes enum {
#define PFD_PREFIXTREE 0xfe // walking through the prefix tree PFD_NOPREFIX = 0xff, // not using prefixes
#define PFD_NOTSPECIAL 0xfd // highest value that's not special PFD_PREFIXTREE = 0xfe, // walking through the prefix tree
PFD_NOTSPECIAL = 0xfd, // highest value that's not special
};
static long spell_suggest_timeout = 5000; static long spell_suggest_timeout = 5000;
@ -341,9 +357,11 @@ static int bytes2offset(char_u **pp)
} }
// values for sps_flags // values for sps_flags
#define SPS_BEST 1 enum {
#define SPS_FAST 2 SPS_BEST = 1,
#define SPS_DOUBLE 4 SPS_FAST = 2,
SPS_DOUBLE = 4,
};
static int sps_flags = SPS_BEST; ///< flags from 'spellsuggest' static int sps_flags = SPS_BEST; ///< flags from 'spellsuggest'
static int sps_limit = 9999; ///< max nr of suggestions given static int sps_limit = 9999; ///< max nr of suggestions given

View File

@ -604,10 +604,9 @@ static const void *tv_ptr(const typval_T *const tvs, int *const idxp)
if (tvs[idx].v_type == VAR_UNKNOWN) { if (tvs[idx].v_type == VAR_UNKNOWN) {
emsg(_(e_printf)); emsg(_(e_printf));
return NULL; return NULL;
} else { }
(*idxp)++; (*idxp)++;
return tvs[idx].vval.v_string; return tvs[idx].vval.v_string;
}
} }
/// Get float argument from idxp entry in tvs /// Get float argument from idxp entry in tvs

View File

@ -3122,22 +3122,20 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
if (id == 0) { if (id == 0) {
semsg(_("E391: No such syntax cluster: %s"), arg); semsg(_("E391: No such syntax cluster: %s"), arg);
break; break;
} else { }
// We can't physically delete a cluster without changing // We can't physically delete a cluster without changing
// the IDs of other clusters, so we do the next best thing // the IDs of other clusters, so we do the next best thing
// and make it empty. // and make it empty.
int scl_id = id - SYNID_CLUSTER; int scl_id = id - SYNID_CLUSTER;
XFREE_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); XFREE_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list);
}
} else { } else {
id = syn_name2id_len(arg, (size_t)(arg_end - arg)); id = syn_name2id_len(arg, (size_t)(arg_end - arg));
if (id == 0) { if (id == 0) {
semsg(_(e_nogroup), arg); semsg(_(e_nogroup), arg);
break; break;
} else {
syn_clear_one(id, syncing);
} }
syn_clear_one(id, syncing);
} }
arg = skipwhite(arg_end); arg = skipwhite(arg_end);
} }

View File

@ -81,14 +81,16 @@ typedef struct {
// ht_match[] is used to find duplicates, ga_match[] to keep them in sequence. // ht_match[] is used to find duplicates, ga_match[] to keep them in sequence.
// At the end, the matches from ga_match[] are concatenated, to make a list // At the end, the matches from ga_match[] are concatenated, to make a list
// sorted on priority. // sorted on priority.
#define MT_ST_CUR 0 // static match in current file enum {
#define MT_GL_CUR 1 // global match in current file MT_ST_CUR = 0, // static match in current file
#define MT_GL_OTH 2 // global match in other file MT_GL_CUR = 1, // global match in current file
#define MT_ST_OTH 3 // static match in other file MT_GL_OTH = 2, // global match in other file
#define MT_IC_OFF 4 // add for icase match MT_ST_OTH = 3, // static match in other file
#define MT_RE_OFF 8 // add for regexp match MT_IC_OFF = 4, // add for icase match
#define MT_MASK 7 // mask for printing priority MT_RE_OFF = 8, // add for regexp match
#define MT_COUNT 16 MT_MASK = 7, // mask for printing priority
MT_COUNT = 16,
};
static char *mt_names[MT_COUNT/2] = static char *mt_names[MT_COUNT/2] =
{ "FSC", "F C", "F ", "FS ", " SC", " C", " ", " S " }; { "FSC", "F C", "F ", "FS ", " SC", " C", " ", " S " };
@ -1657,9 +1659,8 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
- search_info.low_offset) / 2); - search_info.low_offset) / 2);
if (offset == search_info.curr_offset) { if (offset == search_info.curr_offset) {
break; // End the binary search without a match. break; // End the binary search without a match.
} else {
search_info.curr_offset = offset;
} }
search_info.curr_offset = offset;
} else if (state == TS_SKIP_BACK) { } else if (state == TS_SKIP_BACK) {
// Skipping back (after a match during binary search). // Skipping back (after a match during binary search).
search_info.curr_offset -= lbuf_size * 2; search_info.curr_offset -= lbuf_size * 2;

View File

@ -324,7 +324,7 @@ static void forward_simple_utf8(TermInput *input, TermKeyKey *key)
&& map_has(KittyKey, cstr_t)(&kitty_key_map, (KittyKey)key->code.codepoint)) { && map_has(KittyKey, cstr_t)(&kitty_key_map, (KittyKey)key->code.codepoint)) {
handle_kitty_key_protocol(input, key); handle_kitty_key_protocol(input, key);
return; return;
} else { }
while (*ptr) { while (*ptr) {
if (*ptr == '<') { if (*ptr == '<') {
len += (size_t)snprintf(buf + len, sizeof(buf) - len, "<lt>"); len += (size_t)snprintf(buf + len, sizeof(buf) - len, "<lt>");
@ -333,7 +333,6 @@ static void forward_simple_utf8(TermInput *input, TermKeyKey *key)
} }
ptr++; ptr++;
} }
}
tinput_enqueue(input, buf, len); tinput_enqueue(input, buf, len);
} }
@ -355,7 +354,7 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key)
(KittyKey)key->code.codepoint)) { (KittyKey)key->code.codepoint)) {
handle_kitty_key_protocol(input, key); handle_kitty_key_protocol(input, key);
return; return;
} else { }
// Termkey doesn't include the S- modifier for ASCII characters (e.g., // Termkey doesn't include the S- modifier for ASCII characters (e.g.,
// ctrl-shift-l is <C-L> instead of <C-S-L>. Vim, on the other hand, // ctrl-shift-l is <C-L> instead of <C-S-L>. Vim, on the other hand,
// treats <C-L> and <C-l> the same, requiring the S- modifier. // treats <C-L> and <C-l> the same, requiring the S- modifier.
@ -371,7 +370,6 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key)
len += 2; len += 2;
} }
} }
}
tinput_enqueue(input, buf, len); tinput_enqueue(input, buf, len);
} }

View File

@ -1651,9 +1651,8 @@ static void out(void *ctx, const char *str, size_t len)
// Called by unibi_format(): avoid flush_buf() halfway an escape sequence. // Called by unibi_format(): avoid flush_buf() halfway an escape sequence.
data->overflow = true; data->overflow = true;
return; return;
} else {
flush_buf(ui);
} }
flush_buf(ui);
} }
memcpy(data->buf + data->bufpos, str, len); memcpy(data->buf + data->bufpos, str, len);

View File

@ -2713,9 +2713,8 @@ void ex_undojoin(exarg_T *eap)
} }
if (get_undolevel(curbuf) < 0) { if (get_undolevel(curbuf) < 0) {
return; // no entries, nothing to do return; // no entries, nothing to do
} else {
curbuf->b_u_synced = false; // Append next change to last entry
} }
curbuf->b_u_synced = false; // Append next change to last entry
} }
/// Called after writing or reloading the file and setting b_changed to false. /// Called after writing or reloading the file and setting b_changed to false.

View File

@ -343,9 +343,8 @@ static char *get_command_complete(int arg)
{ {
if (arg >= (int)(ARRAY_SIZE(command_complete))) { if (arg >= (int)(ARRAY_SIZE(command_complete))) {
return NULL; return NULL;
} else {
return (char *)command_complete[arg];
} }
return (char *)command_complete[arg];
} }
/// Function given to ExpandGeneric() to obtain the list of values for -complete. /// Function given to ExpandGeneric() to obtain the list of values for -complete.
@ -357,9 +356,8 @@ char *get_user_cmd_complete(expand_T *xp, int idx)
char *cmd_compl = get_command_complete(idx); char *cmd_compl = get_command_complete(idx);
if (cmd_compl == NULL) { if (cmd_compl == NULL) {
return ""; return "";
} else {
return cmd_compl;
} }
return cmd_compl;
} }
int cmdcomplete_str_to_type(const char *complete_str) int cmdcomplete_str_to_type(const char *complete_str)

View File

@ -271,9 +271,8 @@ newwindow:
for (wp = firstwin; --Prenum > 0;) { for (wp = firstwin; --Prenum > 0;) {
if (wp->w_next == NULL) { if (wp->w_next == NULL) {
break; break;
} else {
wp = wp->w_next;
} }
wp = wp->w_next;
} }
} else { } else {
if (nchar == 'W') { // go to previous window if (nchar == 'W') { // go to previous window
@ -873,9 +872,8 @@ int win_fdccol_count(win_T *wp)
const int fdccol = fdc[4] == ':' ? fdc[5] - '0' : 1; const int fdccol = fdc[4] == ':' ? fdc[5] - '0' : 1;
int needed_fdccols = getDeepestNesting(wp); int needed_fdccols = getDeepestNesting(wp);
return MIN(fdccol, needed_fdccols); return MIN(fdccol, needed_fdccols);
} else {
return fdc[0] - '0';
} }
return fdc[0] - '0';
} }
void ui_ext_win_position(win_T *wp, bool validate) void ui_ext_win_position(win_T *wp, bool validate)
@ -4870,14 +4868,13 @@ win_T *buf_jump_open_win(buf_T *buf)
if (curwin->w_buffer == buf) { if (curwin->w_buffer == buf) {
win_enter(curwin, false); win_enter(curwin, false);
return curwin; return curwin;
} else { }
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_buffer == buf) { if (wp->w_buffer == buf) {
win_enter(wp, false); win_enter(wp, false);
return wp; return wp;
} }
} }
}
return NULL; return NULL;
} }
@ -6646,12 +6643,11 @@ static bool resize_frame_for_winbar(frame_T *fr)
if (fp == NULL || fp == fr) { if (fp == NULL || fp == fr) {
emsg(_(e_noroom)); emsg(_(e_noroom));
return false; return false;
} else { }
frame_new_height(fp, fp->fr_height - 1, false, false); frame_new_height(fp, fp->fr_height - 1, false, false);
win_new_height(wp, wp->w_height + 1); win_new_height(wp, wp->w_height + 1);
frame_fix_height(wp); frame_fix_height(wp);
(void)win_comp_pos(); (void)win_comp_pos();
}
return true; return true;
} }