refactor: remove use of reserved c++ keywords

libnvim couldn't be easily used in C++ due to the use of reserved keywords.

Additionally, add explicit casts to *alloc function calls used in inline
functions, as C++ doesn't allow implicit casts from void pointers.
This commit is contained in:
ii14 2023-04-06 22:39:50 +02:00 committed by GitHub
parent 0bc3238504
commit 7190dba017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 152 additions and 154 deletions

View File

@ -38,7 +38,7 @@
kmptype_t **buf; \ kmptype_t **buf; \
} kmp_##name##_t; \ } kmp_##name##_t; \
static inline kmp_##name##_t *kmp_init_##name(void) { \ static inline kmp_##name##_t *kmp_init_##name(void) { \
return xcalloc(1, sizeof(kmp_##name##_t)); \ return (kmp_##name##_t *)xcalloc(1, sizeof(kmp_##name##_t)); \
} \ } \
static inline void kmp_destroy_##name(kmp_##name##_t *mp) \ static inline void kmp_destroy_##name(kmp_##name##_t *mp) \
REAL_FATTR_UNUSED; \ REAL_FATTR_UNUSED; \
@ -52,7 +52,7 @@
static inline kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \ static inline kmptype_t *kmp_alloc_##name(kmp_##name##_t *mp) { \
mp->cnt++; \ mp->cnt++; \
if (mp->n == 0) { \ if (mp->n == 0) { \
return xcalloc(1, sizeof(kmptype_t)); \ return (kmptype_t *)xcalloc(1, sizeof(kmptype_t)); \
} \ } \
return mp->buf[--mp->n]; \ return mp->buf[--mp->n]; \
} \ } \
@ -60,7 +60,7 @@
mp->cnt--; \ mp->cnt--; \
if (mp->n == mp->max) { \ if (mp->n == mp->max) { \
mp->max = mp->max ? (mp->max << 1) : 16; \ mp->max = mp->max ? (mp->max << 1) : 16; \
mp->buf = xrealloc(mp->buf, sizeof(kmptype_t *) * mp->max); \ mp->buf = (kmptype_t **)xrealloc(mp->buf, sizeof(kmptype_t *) * mp->max); \
} \ } \
mp->buf[mp->n++] = p; \ mp->buf[mp->n++] = p; \
} }
@ -84,7 +84,7 @@
size_t size; \ size_t size; \
} kl_##name##_t; \ } kl_##name##_t; \
static inline kl_##name##_t *kl_init_##name(void) { \ static inline kl_##name##_t *kl_init_##name(void) { \
kl_##name##_t *kl = xcalloc(1, sizeof(kl_##name##_t)); \ kl_##name##_t *kl = (kl_##name##_t *)xcalloc(1, sizeof(kl_##name##_t)); \
kl->mp = kmp_init(name); \ kl->mp = kmp_init(name); \
kl->head = kl->tail = kmp_alloc(name, kl->mp); \ kl->head = kl->tail = kmp_alloc(name, kl->mp); \
kl->head->next = 0; \ kl->head->next = 0; \

View File

@ -1015,7 +1015,7 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
uint32_t argt = 0; uint32_t argt = 0;
int64_t def = -1; int64_t def = -1;
cmd_addr_T addr_type_arg = ADDR_NONE; cmd_addr_T addr_type_arg = ADDR_NONE;
int compl = EXPAND_NOTHING; int context = EXPAND_NOTHING;
char *compl_arg = NULL; char *compl_arg = NULL;
const char *rep = NULL; const char *rep = NULL;
LuaRef luaref = LUA_NOREF; LuaRef luaref = LUA_NOREF;
@ -1161,11 +1161,11 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
} }
if (opts->complete.type == kObjectTypeLuaRef) { if (opts->complete.type == kObjectTypeLuaRef) {
compl = EXPAND_USER_LUA; context = EXPAND_USER_LUA;
compl_luaref = api_new_luaref(opts->complete.data.luaref); compl_luaref = api_new_luaref(opts->complete.data.luaref);
} else if (opts->complete.type == kObjectTypeString) { } else if (opts->complete.type == kObjectTypeString) {
VALIDATE_S(OK == parse_compl_arg(opts->complete.data.string.data, VALIDATE_S(OK == parse_compl_arg(opts->complete.data.string.data,
(int)opts->complete.data.string.size, &compl, &argt, (int)opts->complete.data.string.size, &context, &argt,
&compl_arg), &compl_arg),
"complete", opts->complete.data.string.data, { "complete", opts->complete.data.string.data, {
goto err; goto err;
@ -1204,8 +1204,8 @@ void create_user_command(uint64_t channel_id, String name, Object command, Dict(
} }
WITH_SCRIPT_CONTEXT(channel_id, { WITH_SCRIPT_CONTEXT(channel_id, {
if (uc_add_command(name.data, name.size, rep, argt, def, flags, compl, compl_arg, compl_luaref, if (uc_add_command(name.data, name.size, rep, argt, def, flags, context, compl_arg,
preview_luaref, addr_type_arg, luaref, force) != OK) { compl_luaref, preview_luaref, addr_type_arg, luaref, force) != OK) {
api_set_error(err, kErrorTypeException, "Failed to create user command"); api_set_error(err, kErrorTypeException, "Failed to create user command");
// Do not goto err, since uc_add_command now owns luaref, compl_luaref, and compl_arg // Do not goto err, since uc_add_command now owns luaref, compl_luaref, and compl_arg
} }

View File

@ -939,10 +939,10 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit)
xfree(envpat); xfree(envpat);
} }
void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool delete, int group) void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool del, int group)
{ {
FOR_ALL_AUEVENTS(event) { FOR_ALL_AUEVENTS(event) {
if (do_autocmd_event(event, pat, once, nested, cmd, delete, group) if (do_autocmd_event(event, pat, once, nested, cmd, del, group)
== FAIL) { == FAIL) {
return; return;
} }
@ -956,12 +956,12 @@ void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool del
// If *cmd == NUL: show entries. // If *cmd == NUL: show entries.
// If forceit == true: delete entries. // If forceit == true: delete entries.
// If group is not AUGROUP_ALL: only use this group. // If group is not AUGROUP_ALL: only use this group.
int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd, bool delete, int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd, bool del,
int group) int group)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
// Cannot be used to show all patterns. See au_show_for_event or au_show_for_all_events // Cannot be used to show all patterns. See au_show_for_event or au_show_for_all_events
assert(*pat != NUL || delete); assert(*pat != NUL || del);
AutoPat *ap; AutoPat *ap;
AutoPat **prev_ap; AutoPat **prev_ap;
@ -978,7 +978,7 @@ int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd,
} }
// Delete all aupat for an event. // Delete all aupat for an event.
if (*pat == NUL && delete) { if (*pat == NUL && del) {
aupat_del_for_event_and_group(event, findgroup); aupat_del_for_event_and_group(event, findgroup);
return OK; return OK;
} }
@ -999,7 +999,7 @@ int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd,
patlen = (int)strlen(buflocal_pat); patlen = (int)strlen(buflocal_pat);
} }
if (delete) { if (del) {
assert(*pat != NUL); assert(*pat != NUL);
// Find AutoPat entries with this pattern. // Find AutoPat entries with this pattern.

View File

@ -399,13 +399,13 @@ void changed_bytes(linenr_T lnum, colnr_T col)
/// insert/delete bytes at column /// insert/delete bytes at column
/// ///
/// Like changed_bytes() but also adjust extmark for "new" bytes. /// Like changed_bytes() but also adjust extmark for "new" bytes.
void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new) void inserted_bytes(linenr_T lnum, colnr_T start_col, int old_col, int new_col)
{ {
if (curbuf_splice_pending == 0) { if (curbuf_splice_pending == 0) {
extmark_splice_cols(curbuf, (int)lnum - 1, col, old, new, kExtmarkUndo); extmark_splice_cols(curbuf, (int)lnum - 1, start_col, old_col, new_col, kExtmarkUndo);
} }
changed_bytes(lnum, col); changed_bytes(lnum, start_col);
} }
/// Appended "count" lines below line "lnum" in the current buffer. /// Appended "count" lines below line "lnum" in the current buffer.

View File

@ -831,13 +831,12 @@ static void term_close(void *data)
multiqueue_put(chan->events, term_delayed_free, 1, data); multiqueue_put(chan->events, term_delayed_free, 1, data);
} }
void channel_info_changed(Channel *chan, bool new) void channel_info_changed(Channel *chan, bool new_chan)
{ {
event_T event = new ? EVENT_CHANOPEN : EVENT_CHANINFO; event_T event = new_chan ? EVENT_CHANOPEN : EVENT_CHANINFO;
if (has_event(event)) { if (has_event(event)) {
channel_incref(chan); channel_incref(chan);
multiqueue_put(main_loop.events, set_info_event, multiqueue_put(main_loop.events, set_info_event, 2, chan, event);
2, chan, event);
} }
} }

View File

@ -121,7 +121,7 @@ EXTERN Callback on_print INIT(= CALLBACK_INIT);
/// @returns Channel with the id or NULL if not found /// @returns Channel with the id or NULL if not found
static inline Channel *find_channel(uint64_t id) static inline Channel *find_channel(uint64_t id)
{ {
return pmap_get(uint64_t)(&channels, id); return (Channel *)pmap_get(uint64_t)(&channels, id);
} }
static inline Stream *channel_instream(Channel *chan) static inline Stream *channel_instream(Channel *chan)

View File

@ -3996,7 +3996,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
if (!clear_env) { if (!clear_env) {
typval_T temp_env = TV_INITIAL_VALUE; typval_T temp_env = TV_INITIAL_VALUE;
f_environ(NULL, &temp_env, (EvalFuncData){ .nullptr = NULL }); f_environ(NULL, &temp_env, (EvalFuncData){ .null = NULL });
tv_dict_extend(env, temp_env.vval.v_dict, "force"); tv_dict_extend(env, temp_env.vval.v_dict, "force");
tv_dict_free(temp_env.vval.v_dict); tv_dict_free(temp_env.vval.v_dict);

View File

@ -112,13 +112,13 @@ static MultiQueue *multiqueue_new(MultiQueue *parent, PutCallback put_cb, void *
return rv; return rv;
} }
void multiqueue_free(MultiQueue *this) void multiqueue_free(MultiQueue *self)
{ {
assert(this); assert(self);
QUEUE *q; QUEUE *q;
QUEUE_FOREACH(q, &this->headtail, { QUEUE_FOREACH(q, &self->headtail, {
MultiQueueItem *item = multiqueue_node_data(q); MultiQueueItem *item = multiqueue_node_data(q);
if (this->parent) { if (self->parent) {
QUEUE_REMOVE(&item->data.item.parent_item->node); QUEUE_REMOVE(&item->data.item.parent_item->node);
xfree(item->data.item.parent_item); xfree(item->data.item.parent_item);
} }
@ -126,29 +126,29 @@ void multiqueue_free(MultiQueue *this)
xfree(item); xfree(item);
}) })
xfree(this); xfree(self);
} }
/// Removes the next item and returns its Event. /// Removes the next item and returns its Event.
Event multiqueue_get(MultiQueue *this) Event multiqueue_get(MultiQueue *self)
{ {
return multiqueue_empty(this) ? NILEVENT : multiqueue_remove(this); return multiqueue_empty(self) ? NILEVENT : multiqueue_remove(self);
} }
void multiqueue_put_event(MultiQueue *this, Event event) void multiqueue_put_event(MultiQueue *self, Event event)
{ {
assert(this); assert(self);
multiqueue_push(this, event); multiqueue_push(self, event);
if (this->parent && this->parent->put_cb) { if (self->parent && self->parent->put_cb) {
this->parent->put_cb(this->parent, this->parent->data); self->parent->put_cb(self->parent, self->parent->data);
} }
} }
void multiqueue_process_events(MultiQueue *this) void multiqueue_process_events(MultiQueue *self)
{ {
assert(this); assert(self);
while (!multiqueue_empty(this)) { while (!multiqueue_empty(self)) {
Event event = multiqueue_remove(this); Event event = multiqueue_remove(self);
if (event.handler) { if (event.handler) {
event.handler(event.argv); event.handler(event.argv);
} }
@ -156,30 +156,30 @@ void multiqueue_process_events(MultiQueue *this)
} }
/// Removes all events without processing them. /// Removes all events without processing them.
void multiqueue_purge_events(MultiQueue *this) void multiqueue_purge_events(MultiQueue *self)
{ {
assert(this); assert(self);
while (!multiqueue_empty(this)) { while (!multiqueue_empty(self)) {
(void)multiqueue_remove(this); (void)multiqueue_remove(self);
} }
} }
bool multiqueue_empty(MultiQueue *this) bool multiqueue_empty(MultiQueue *self)
{ {
assert(this); assert(self);
return QUEUE_EMPTY(&this->headtail); return QUEUE_EMPTY(&self->headtail);
} }
void multiqueue_replace_parent(MultiQueue *this, MultiQueue *new_parent) void multiqueue_replace_parent(MultiQueue *self, MultiQueue *new_parent)
{ {
assert(multiqueue_empty(this)); assert(multiqueue_empty(self));
this->parent = new_parent; self->parent = new_parent;
} }
/// Gets the count of all events currently in the queue. /// Gets the count of all events currently in the queue.
size_t multiqueue_size(MultiQueue *this) size_t multiqueue_size(MultiQueue *self)
{ {
return this->size; return self->size;
} }
/// Gets an Event from an item. /// Gets an Event from an item.
@ -213,35 +213,35 @@ static Event multiqueueitem_get_event(MultiQueueItem *item, bool remove)
return ev; return ev;
} }
static Event multiqueue_remove(MultiQueue *this) static Event multiqueue_remove(MultiQueue *self)
{ {
assert(!multiqueue_empty(this)); assert(!multiqueue_empty(self));
QUEUE *h = QUEUE_HEAD(&this->headtail); QUEUE *h = QUEUE_HEAD(&self->headtail);
QUEUE_REMOVE(h); QUEUE_REMOVE(h);
MultiQueueItem *item = multiqueue_node_data(h); MultiQueueItem *item = multiqueue_node_data(h);
assert(!item->link || !this->parent); // Only a parent queue has link-nodes assert(!item->link || !self->parent); // Only a parent queue has link-nodes
Event ev = multiqueueitem_get_event(item, true); Event ev = multiqueueitem_get_event(item, true);
this->size--; self->size--;
xfree(item); xfree(item);
return ev; return ev;
} }
static void multiqueue_push(MultiQueue *this, Event event) static void multiqueue_push(MultiQueue *self, Event event)
{ {
MultiQueueItem *item = xmalloc(sizeof(MultiQueueItem)); MultiQueueItem *item = xmalloc(sizeof(MultiQueueItem));
item->link = false; item->link = false;
item->data.item.event = event; item->data.item.event = event;
item->data.item.parent_item = NULL; item->data.item.parent_item = NULL;
QUEUE_INSERT_TAIL(&this->headtail, &item->node); QUEUE_INSERT_TAIL(&self->headtail, &item->node);
if (this->parent) { if (self->parent) {
// push link node to the parent queue // push link node to the parent queue
item->data.item.parent_item = xmalloc(sizeof(MultiQueueItem)); item->data.item.parent_item = xmalloc(sizeof(MultiQueueItem));
item->data.item.parent_item->link = true; item->data.item.parent_item->link = true;
item->data.item.parent_item->data.queue = this; item->data.item.parent_item->data.queue = self;
QUEUE_INSERT_TAIL(&this->parent->headtail, QUEUE_INSERT_TAIL(&self->parent->headtail,
&item->data.item.parent_item->node); &item->data.item.parent_item->node);
} }
this->size++; self->size++;
} }
static MultiQueueItem *multiqueue_node_data(QUEUE *q) static MultiQueueItem *multiqueue_node_data(QUEUE *q)

View File

@ -1117,28 +1117,28 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p
static ff_stack_T *ff_create_stack_element(char *fix_part, char *wc_part, int level, static ff_stack_T *ff_create_stack_element(char *fix_part, char *wc_part, int level,
int star_star_empty) int star_star_empty)
{ {
ff_stack_T *new = xmalloc(sizeof(ff_stack_T)); ff_stack_T *stack = xmalloc(sizeof(ff_stack_T));
new->ffs_prev = NULL; stack->ffs_prev = NULL;
new->ffs_filearray = NULL; stack->ffs_filearray = NULL;
new->ffs_filearray_size = 0; stack->ffs_filearray_size = 0;
new->ffs_filearray_cur = 0; stack->ffs_filearray_cur = 0;
new->ffs_stage = 0; stack->ffs_stage = 0;
new->ffs_level = level; stack->ffs_level = level;
new->ffs_star_star_empty = star_star_empty; stack->ffs_star_star_empty = star_star_empty;
// the following saves NULL pointer checks in vim_findfile // the following saves NULL pointer checks in vim_findfile
if (fix_part == NULL) { if (fix_part == NULL) {
fix_part = ""; fix_part = "";
} }
new->ffs_fix_path = xstrdup(fix_part); stack->ffs_fix_path = xstrdup(fix_part);
if (wc_part == NULL) { if (wc_part == NULL) {
wc_part = ""; wc_part = "";
} }
new->ffs_wc_path = xstrdup(wc_part); stack->ffs_wc_path = xstrdup(wc_part);
return new; return stack;
} }
/// Push a dir on the directory stack. /// Push a dir on the directory stack.

View File

@ -5428,10 +5428,9 @@ char *vim_tempname(void)
// There is no need to check if the file exists, because we own the directory // There is no need to check if the file exists, because we own the directory
// and nobody else creates a file in it. // and nobody else creates a file in it.
char template[TEMP_FILE_PATH_MAXLEN]; char templ[TEMP_FILE_PATH_MAXLEN];
snprintf(template, TEMP_FILE_PATH_MAXLEN, snprintf(templ, TEMP_FILE_PATH_MAXLEN, "%s%" PRIu64, tempdir, temp_count++);
"%s%" PRIu64, tempdir, temp_count++); return xstrdup(templ);
return xstrdup(template);
} }
/// Tries matching a filename with a "pattern" ("prog" is NULL), or use the /// Tries matching a filename with a "pattern" ("prog" is NULL), or use the

View File

@ -94,12 +94,12 @@ for _, name in ipairs(neworder) do
end end
local base = def.base or "BASE_NONE" local base = def.base or "BASE_NONE"
local func = def.func or ('f_' .. name) local func = def.func or ('f_' .. name)
local data = def.data or "{ .nullptr = NULL }" local data = def.data or "{ .null = NULL }"
local fast = def.fast and 'true' or 'false' local fast = def.fast and 'true' or 'false'
hashpipe:write((' { "%s", %s, %s, %s, %s, &%s, %s },\n') hashpipe:write((' { "%s", %s, %s, %s, %s, &%s, %s },\n')
:format(name, args[1], args[2], base, fast, func, data)) :format(name, args[1], args[2], base, fast, func, data))
end end
hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .nullptr = NULL } },\n') hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .null = NULL } },\n')
hashpipe:write("};\n\n") hashpipe:write("};\n\n")
hashpipe:write(hashfun) hashpipe:write(hashfun)
hashpipe:close() hashpipe:close()

View File

@ -657,22 +657,22 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid) void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
{ {
int new_row; int new_row;
ScreenGrid new = *grid; ScreenGrid ngrid = *grid;
assert(rows >= 0 && columns >= 0); assert(rows >= 0 && columns >= 0);
size_t ncells = (size_t)rows * (size_t)columns; size_t ncells = (size_t)rows * (size_t)columns;
new.chars = xmalloc(ncells * sizeof(schar_T)); ngrid.chars = xmalloc(ncells * sizeof(schar_T));
new.attrs = xmalloc(ncells * sizeof(sattr_T)); ngrid.attrs = xmalloc(ncells * sizeof(sattr_T));
new.line_offset = xmalloc((size_t)rows * sizeof(*new.line_offset)); ngrid.line_offset = xmalloc((size_t)rows * sizeof(*ngrid.line_offset));
new.line_wraps = xmalloc((size_t)rows * sizeof(*new.line_wraps)); ngrid.line_wraps = xmalloc((size_t)rows * sizeof(*ngrid.line_wraps));
new.rows = rows; ngrid.rows = rows;
new.cols = columns; ngrid.cols = columns;
for (new_row = 0; new_row < new.rows; new_row++) { for (new_row = 0; new_row < ngrid.rows; new_row++) {
new.line_offset[new_row] = (size_t)new_row * (size_t)new.cols; ngrid.line_offset[new_row] = (size_t)new_row * (size_t)ngrid.cols;
new.line_wraps[new_row] = false; ngrid.line_wraps[new_row] = false;
grid_clear_line(&new, new.line_offset[new_row], columns, valid); grid_clear_line(&ngrid, ngrid.line_offset[new_row], columns, valid);
if (copy) { if (copy) {
// If the screen is not going to be cleared, copy as much as // If the screen is not going to be cleared, copy as much as
@ -680,18 +680,18 @@ void grid_alloc(ScreenGrid *grid, int rows, int columns, bool copy, bool valid)
// (used when resizing the window at the "--more--" prompt or when // (used when resizing the window at the "--more--" prompt or when
// executing an external command, for the GUI). // executing an external command, for the GUI).
if (new_row < grid->rows && grid->chars != NULL) { if (new_row < grid->rows && grid->chars != NULL) {
int len = MIN(grid->cols, new.cols); int len = MIN(grid->cols, ngrid.cols);
memmove(new.chars + new.line_offset[new_row], memmove(ngrid.chars + ngrid.line_offset[new_row],
grid->chars + grid->line_offset[new_row], grid->chars + grid->line_offset[new_row],
(size_t)len * sizeof(schar_T)); (size_t)len * sizeof(schar_T));
memmove(new.attrs + new.line_offset[new_row], memmove(ngrid.attrs + ngrid.line_offset[new_row],
grid->attrs + grid->line_offset[new_row], grid->attrs + grid->line_offset[new_row],
(size_t)len * sizeof(sattr_T)); (size_t)len * sizeof(sattr_T));
} }
} }
} }
grid_free(grid); grid_free(grid);
*grid = new; *grid = ngrid;
// Share a single scratch buffer for all grids, by // Share a single scratch buffer for all grids, by
// ensuring it is as wide as the widest grid. // ensuring it is as wide as the widest grid.

View File

@ -1067,14 +1067,14 @@ static bool pum_enough_matches(void)
{ {
// Don't display the popup menu if there are no matches or there is only // Don't display the popup menu if there are no matches or there is only
// one (ignoring the original text). // one (ignoring the original text).
compl_T *compl = compl_first_match; compl_T *comp = compl_first_match;
int i = 0; int i = 0;
do { do {
if (compl == NULL || (!match_at_original_text(compl) && ++i == 2)) { if (comp == NULL || (!match_at_original_text(comp) && ++i == 2)) {
break; break;
} }
compl = compl->cp_next; comp = comp->cp_next;
} while (!is_first_match(compl)); } while (!is_first_match(comp));
if (strstr(p_cot, "menuone") != NULL) { if (strstr(p_cot, "menuone") != NULL) {
return i >= 1; return i >= 1;
@ -1138,7 +1138,7 @@ static int ins_compl_build_pum(void)
{ {
// Need to build the popup menu list. // Need to build the popup menu list.
compl_match_arraysize = 0; compl_match_arraysize = 0;
compl_T *compl = compl_first_match; compl_T *comp = compl_first_match;
// If it's user complete function and refresh_always, // If it's user complete function and refresh_always,
// do not use "compl_leader" as prefix filter. // do not use "compl_leader" as prefix filter.
@ -1149,13 +1149,13 @@ static int ins_compl_build_pum(void)
const int lead_len = compl_leader != NULL ? (int)strlen(compl_leader) : 0; const int lead_len = compl_leader != NULL ? (int)strlen(compl_leader) : 0;
do { do {
if (!match_at_original_text(compl) if (!match_at_original_text(comp)
&& (compl_leader == NULL && (compl_leader == NULL
|| ins_compl_equal(compl, compl_leader, (size_t)lead_len))) { || ins_compl_equal(comp, compl_leader, (size_t)lead_len))) {
compl_match_arraysize++; compl_match_arraysize++;
} }
compl = compl->cp_next; comp = comp->cp_next;
} while (compl != NULL && !is_first_match(compl)); } while (comp != NULL && !is_first_match(comp));
if (compl_match_arraysize == 0) { if (compl_match_arraysize == 0) {
return -1; return -1;
@ -1172,46 +1172,46 @@ static int ins_compl_build_pum(void)
bool did_find_shown_match = false; bool did_find_shown_match = false;
int cur = -1; int cur = -1;
int i = 0; int i = 0;
compl = compl_first_match; comp = compl_first_match;
do { do {
if (!match_at_original_text(compl) if (!match_at_original_text(comp)
&& (compl_leader == NULL && (compl_leader == NULL
|| ins_compl_equal(compl, compl_leader, (size_t)lead_len))) { || ins_compl_equal(comp, compl_leader, (size_t)lead_len))) {
if (!shown_match_ok) { if (!shown_match_ok) {
if (compl == compl_shown_match || did_find_shown_match) { if (comp == compl_shown_match || did_find_shown_match) {
// This item is the shown match or this is the // This item is the shown match or this is the
// first displayed item after the shown match. // first displayed item after the shown match.
compl_shown_match = compl; compl_shown_match = comp;
did_find_shown_match = true; did_find_shown_match = true;
shown_match_ok = true; shown_match_ok = true;
} else { } else {
// Remember this displayed match for when the // Remember this displayed match for when the
// shown match is just below it. // shown match is just below it.
shown_compl = compl; shown_compl = comp;
} }
cur = i; cur = i;
} }
if (compl->cp_text[CPT_ABBR] != NULL) { if (comp->cp_text[CPT_ABBR] != NULL) {
compl_match_array[i].pum_text = compl->cp_text[CPT_ABBR]; compl_match_array[i].pum_text = comp->cp_text[CPT_ABBR];
} else { } else {
compl_match_array[i].pum_text = compl->cp_str; compl_match_array[i].pum_text = comp->cp_str;
} }
compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND]; compl_match_array[i].pum_kind = comp->cp_text[CPT_KIND];
compl_match_array[i].pum_info = compl->cp_text[CPT_INFO]; compl_match_array[i].pum_info = comp->cp_text[CPT_INFO];
if (compl->cp_text[CPT_MENU] != NULL) { if (comp->cp_text[CPT_MENU] != NULL) {
compl_match_array[i++].pum_extra = compl->cp_text[CPT_MENU]; compl_match_array[i++].pum_extra = comp->cp_text[CPT_MENU];
} else { } else {
compl_match_array[i++].pum_extra = compl->cp_fname; compl_match_array[i++].pum_extra = comp->cp_fname;
} }
} }
if (compl == compl_shown_match) { if (comp == compl_shown_match) {
did_find_shown_match = true; did_find_shown_match = true;
// When the original text is the shown match don't set // When the original text is the shown match don't set
// compl_shown_match. // compl_shown_match.
if (match_at_original_text(compl)) { if (match_at_original_text(comp)) {
shown_match_ok = true; shown_match_ok = true;
} }
@ -1222,8 +1222,8 @@ static int ins_compl_build_pum(void)
shown_match_ok = true; shown_match_ok = true;
} }
} }
compl = compl->cp_next; comp = comp->cp_next;
} while (compl != NULL && !is_first_match(compl)); } while (comp != NULL && !is_first_match(comp));
if (!shown_match_ok) { // no displayed match at all if (!shown_match_ok) { // no displayed match at all
cur = -1; cur = -1;

View File

@ -1053,7 +1053,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
static struct clinterval { static struct clinterval {
unsigned int first; unsigned int first;
unsigned int last; unsigned int last;
unsigned int class; unsigned int cls;
} classes[] = { } classes[] = {
{ 0x037e, 0x037e, 1 }, // Greek question mark { 0x037e, 0x037e, 1 }, // Greek question mark
{ 0x0387, 0x0387, 1 }, // Greek ano teleia { 0x0387, 0x0387, 1 }, // Greek ano teleia
@ -1154,7 +1154,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
} else if (classes[mid].first > (unsigned int)c) { } else if (classes[mid].first > (unsigned int)c) {
top = mid - 1; top = mid - 1;
} else { } else {
return (int)classes[mid].class; return (int)classes[mid].cls;
} }
} }

View File

@ -1014,17 +1014,17 @@ int os_file_mkdir(char *fname, int32_t mode)
/// Create a unique temporary directory. /// Create a unique temporary directory.
/// ///
/// @param[in] template Template of the path to the directory with XXXXXX /// @param[in] templ Template of the path to the directory with XXXXXX
/// which would be replaced by random chars. /// which would be replaced by random chars.
/// @param[out] path Path to created directory for success, undefined for /// @param[out] path Path to created directory for success, undefined for
/// failure. /// failure.
/// @return `0` for success, non-zero for failure. /// @return `0` for success, non-zero for failure.
int os_mkdtemp(const char *template, char *path) int os_mkdtemp(const char *templ, char *path)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
uv_fs_t request; uv_fs_t request;
fs_loop_lock(); fs_loop_lock();
int result = uv_fs_mkdtemp(&fs_loop, &request, template, NULL); int result = uv_fs_mkdtemp(&fs_loop, &request, templ, NULL);
fs_loop_unlock(); fs_loop_unlock();
if (result == kLibuvSuccess) { if (result == kLibuvSuccess) {
xstrlcpy(path, request.path, TEMP_FILE_PATH_MAXLEN); xstrlcpy(path, request.path, TEMP_FILE_PATH_MAXLEN);

View File

@ -5252,9 +5252,9 @@ static regsubs_T *addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *su
} }
// Check character class "class" against current character c. // Check character class "class" against current character c.
static int check_char_class(int class, int c) static int check_char_class(int cls, int c)
{ {
switch (class) { switch (cls) {
case NFA_CLASS_ALNUM: case NFA_CLASS_ALNUM:
if (c >= 1 && c < 128 && isalnum(c)) { if (c >= 1 && c < 128 && isalnum(c)) {
return OK; return OK;
@ -5353,7 +5353,7 @@ static int check_char_class(int class, int c)
default: default:
// should not be here :P // should not be here :P
siemsg(_(e_ill_char_class), (int64_t)class); siemsg(_(e_ill_char_class), (int64_t)cls);
return FAIL; return FAIL;
} }
return FAIL; return FAIL;

View File

@ -896,13 +896,13 @@ static int term_moverect(VTermRect dest, VTermRect src, void *data)
return 1; return 1;
} }
static int term_movecursor(VTermPos new, VTermPos old, int visible, void *data) static int term_movecursor(VTermPos new_pos, VTermPos old_pos, int visible, void *data)
{ {
Terminal *term = data; Terminal *term = data;
term->cursor.row = new.row; term->cursor.row = new_pos.row;
term->cursor.col = new.col; term->cursor.col = new_pos.col;
invalidate_terminal(term, old.row, old.row + 1); invalidate_terminal(term, old_pos.row, old_pos.row + 1);
invalidate_terminal(term, new.row, new.row + 1); invalidate_terminal(term, new_pos.row, new_pos.row + 1);
return 1; return 1;
} }

View File

@ -634,7 +634,7 @@ static bool paragraph_start(linenr_T lnum)
void auto_format(bool trailblank, bool prev_line) void auto_format(bool trailblank, bool prev_line)
{ {
colnr_T len; colnr_T len;
char *new, *pnew; char *linep, *plinep;
int cc; int cc;
if (!has_format_option(FO_AUTO)) { if (!has_format_option(FO_AUTO)) {
@ -705,13 +705,13 @@ void auto_format(bool trailblank, bool prev_line)
// need to add a space when 'w' is in 'formatoptions' to keep a paragraph // need to add a space when 'w' is in 'formatoptions' to keep a paragraph
// formatted. // formatted.
if (!wasatend && has_format_option(FO_WHITE_PAR)) { if (!wasatend && has_format_option(FO_WHITE_PAR)) {
new = get_cursor_line_ptr(); linep = get_cursor_line_ptr();
len = (colnr_T)strlen(new); len = (colnr_T)strlen(linep);
if (curwin->w_cursor.col == len) { if (curwin->w_cursor.col == len) {
pnew = xstrnsave(new, (size_t)len + 2); plinep = xstrnsave(linep, (size_t)len + 2);
pnew[len] = ' '; plinep[len] = ' ';
pnew[len + 1] = NUL; plinep[len + 1] = NUL;
ml_replace(curwin->w_cursor.lnum, pnew, false); ml_replace(curwin->w_cursor.lnum, plinep, false);
// remove the space later // remove the space later
did_add_space = true; did_add_space = true;
} else { } else {

View File

@ -26,7 +26,7 @@ typedef struct MsgpackRpcRequestHandler MsgpackRpcRequestHandler;
typedef union { typedef union {
float_T (*float_func)(float_T); float_T (*float_func)(float_T);
const MsgpackRpcRequestHandler *api_handler; const MsgpackRpcRequestHandler *api_handler;
void *nullptr; void *null;
} EvalFuncData; } EvalFuncData;
typedef handle_T NS; typedef handle_T NS;

View File

@ -861,7 +861,7 @@ char *uc_validate_name(char *name)
/// ///
/// @return OK if the command is created, FAIL otherwise. /// @return OK if the command is created, FAIL otherwise.
int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt, int64_t def, int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt, int64_t def,
int flags, int compl, char *compl_arg, LuaRef compl_luaref, int flags, int context, char *compl_arg, LuaRef compl_luaref,
LuaRef preview_luaref, cmd_addr_T addr_type, LuaRef luaref, bool force) LuaRef preview_luaref, cmd_addr_T addr_type, LuaRef luaref, bool force)
FUNC_ATTR_NONNULL_ARG(1, 3) FUNC_ATTR_NONNULL_ARG(1, 3)
{ {
@ -944,7 +944,7 @@ int uc_add_command(char *name, size_t name_len, const char *rep, uint32_t argt,
cmd->uc_rep = rep_buf; cmd->uc_rep = rep_buf;
cmd->uc_argt = argt; cmd->uc_argt = argt;
cmd->uc_def = def; cmd->uc_def = def;
cmd->uc_compl = compl; cmd->uc_compl = context;
cmd->uc_script_ctx = current_sctx; cmd->uc_script_ctx = current_sctx;
cmd->uc_script_ctx.sc_lnum += SOURCING_LNUM; cmd->uc_script_ctx.sc_lnum += SOURCING_LNUM;
nlua_set_sctx(&cmd->uc_script_ctx); nlua_set_sctx(&cmd->uc_script_ctx);
@ -974,7 +974,7 @@ void ex_command(exarg_T *eap)
uint32_t argt = 0; uint32_t argt = 0;
long def = -1; long def = -1;
int flags = 0; int flags = 0;
int compl = EXPAND_NOTHING; int context = EXPAND_NOTHING;
char *compl_arg = NULL; char *compl_arg = NULL;
cmd_addr_T addr_type_arg = ADDR_NONE; cmd_addr_T addr_type_arg = ADDR_NONE;
int has_attr = (eap->arg[0] == '-'); int has_attr = (eap->arg[0] == '-');
@ -986,7 +986,7 @@ void ex_command(exarg_T *eap)
while (*p == '-') { while (*p == '-') {
p++; p++;
end = skiptowhite(p); end = skiptowhite(p);
if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, &compl_arg, if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &context, &compl_arg,
&addr_type_arg) == FAIL) { &addr_type_arg) == FAIL) {
goto theend; goto theend;
} }
@ -1011,10 +1011,10 @@ void ex_command(exarg_T *eap)
emsg(_("E183: User defined commands must start with an uppercase letter")); emsg(_("E183: User defined commands must start with an uppercase letter"));
} else if (name_len <= 4 && strncmp(name, "Next", name_len) == 0) { } else if (name_len <= 4 && strncmp(name, "Next", name_len) == 0) {
emsg(_("E841: Reserved name, cannot be used for user defined command")); emsg(_("E841: Reserved name, cannot be used for user defined command"));
} else if (compl > 0 && (argt & EX_EXTRA) == 0) { } else if (context > 0 && (argt & EX_EXTRA) == 0) {
emsg(_(e_complete_used_without_allowing_arguments)); emsg(_(e_complete_used_without_allowing_arguments));
} else { } else {
uc_add_command(name, name_len, p, argt, def, flags, compl, compl_arg, LUA_NOREF, LUA_NOREF, uc_add_command(name, name_len, p, argt, def, flags, context, compl_arg, LUA_NOREF, LUA_NOREF,
addr_type_arg, LUA_NOREF, eap->forceit); addr_type_arg, LUA_NOREF, eap->forceit);
return; // success return; // success

View File

@ -7,13 +7,13 @@
#include "multiqueue.h" #include "multiqueue.h"
void ut_multiqueue_put(MultiQueue *this, const char *str) void ut_multiqueue_put(MultiQueue *self, const char *str)
{ {
multiqueue_put(this, NULL, 1, str); multiqueue_put(self, NULL, 1, str);
} }
const char *ut_multiqueue_get(MultiQueue *this) const char *ut_multiqueue_get(MultiQueue *self)
{ {
Event event = multiqueue_get(this); Event event = multiqueue_get(self);
return event.argv[0]; return event.argv[0];
} }