diff options
-rw-r--r-- | CMakeLists.txt | 24 | ||||
-rwxr-xr-x | src/nvim/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 19 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 183 | ||||
-rw-r--r-- | src/nvim/event/process.c | 2 | ||||
-rw-r--r-- | src/nvim/event/rstream.c | 18 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
-rw-r--r-- | src/nvim/ex_session.c | 50 | ||||
-rw-r--r-- | src/nvim/extmark.c | 30 | ||||
-rw-r--r-- | src/nvim/file_search.c | 101 | ||||
-rw-r--r-- | src/nvim/fileio.c | 156 | ||||
-rw-r--r-- | src/nvim/getchar.c | 8 | ||||
-rw-r--r-- | src/nvim/keymap.c | 15 | ||||
-rw-r--r-- | src/nvim/log.c | 1 | ||||
-rw-r--r-- | src/nvim/main.c | 1 | ||||
-rw-r--r-- | src/nvim/os/input.c | 1 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_eval_stuff.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_regex_char_classes.vim | 104 | ||||
-rw-r--r-- | src/nvim/testdir/test_substitute.vim | 56 | ||||
-rw-r--r-- | src/nvim/ui_client.c | 1 | ||||
-rw-r--r-- | src/nvim/window.c | 2 | ||||
-rw-r--r-- | test/functional/legacy/eval_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/input_spec.lua | 45 |
25 files changed, 428 insertions, 404 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 767bd797bc..2aed7d8b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,9 @@ if(MSVC) else() add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion + -Wdouble-promotion + -Wmissing-noreturn + -Wmissing-format-attribute -Wmissing-prototypes) check_c_compiler_flag(-Wimplicit-fallthrough HAVE_WIMPLICIT_FALLTHROUGH_FLAG) @@ -291,6 +294,27 @@ else() add_compile_options(-Wimplicit-fallthrough) endif() + # Clang doesn't have -Wsuggest-attribute so check for each one. + check_c_compiler_flag(-Wsuggest-attribute=pure HAVE_WSUGGEST_ATTRIBUTE_PURE) + if(HAVE_WSUGGEST_ATTRIBUTE_PURE) + add_compile_options(-Wsuggest-attribute=pure) + endif() + + check_c_compiler_flag(-Wsuggest-attribute=const HAVE_WSUGGEST_ATTRIBUTE_CONST) + if(HAVE_WSUGGEST_ATTRIBUTE_CONST) + add_compile_options(-Wsuggest-attribute=const) + endif() + + check_c_compiler_flag(-Wsuggest-attribute=malloc HAVE_WSUGGEST_ATTRIBUTE_MALLOC) + if(HAVE_WSUGGEST_ATTRIBUTE_MALLOC) + add_compile_options(-Wsuggest-attribute=malloc) + endif() + + check_c_compiler_flag(-Wsuggest-attribute=cold HAVE_WSUGGEST_ATTRIBUTE_COLD) + if(HAVE_WSUGGEST_ATTRIBUTE_COLD) + add_compile_options(-Wsuggest-attribute=cold) + endif() + # On FreeBSD 64 math.h uses unguarded C11 extension, which taints clang # 3.4.1 used there. if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND CMAKE_C_COMPILER_ID MATCHES "Clang") diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 8e17f94abc..b7f9292de1 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -182,12 +182,15 @@ foreach(sfile ${CONV_SOURCES}) message(FATAL_ERROR "${sfile} doesn't exist (it was added to CONV_SOURCES)") endif() endforeach() -# xdiff, mpack, lua-cjson: inlined external project, we don't maintain it. #9306 -list(APPEND CONV_SOURCES ${EXTERNAL_SOURCES}) if(NOT MSVC) set_source_files_properties( ${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion") + + # xdiff, mpack, lua-cjson: inlined external project, we don't maintain it. #9306 + set_source_files_properties( + ${EXTERNAL_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion -Wno-missing-noreturn -Wno-missing-format-attribute -Wno-double-promotion") + # gperf generates ANSI-C with incorrect linkage, ignore it. check_c_compiler_flag(-Wstatic-in-inline HAS_WSTATIC_IN_INLINE) if(HAS_WSTATIC_IN_INLINE) diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bdeac1a9f4..7c7ada55a2 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1328,7 +1328,7 @@ Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err) if (!cancel && !(State & CMDLINE)) { // Dot-repeat. for (size_t i = 0; i < lines.size; i++) { String s = lines.items[i].data.string; - assert(data.size <= INT_MAX); + assert(s.size <= INT_MAX); AppendToRedobuffLit((char_u *)s.data, (int)s.size); // readfile()-style: "\n" is indicated by presence of N+1 item. if (i + 1 < lines.size) { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7f937a3137..fbbc543893 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3976,18 +3976,11 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string) f1 = f1 * f2; } else if (op == '/') { // Division by zero triggers error from AddressSanitizer - f1 = (f2 == 0 - ? ( + f1 = (f2 == 0 ? ( #ifdef NAN - f1 == 0 - ? NAN - : + f1 == 0 ? (float_T)NAN : #endif - (f1 > 0 - ? INFINITY - : -INFINITY) - ) - : f1 / f2); + (f1 > 0 ? (float_T)INFINITY : (float_T)-INFINITY)) : f1 / f2); } else { emsg(_("E804: Cannot use '%' with Float")); return FAIL; @@ -5842,15 +5835,15 @@ size_t string2float(const char *const text, float_T *const ret_value) // MS-Windows does not deal with "inf" and "nan" properly if (STRNICMP(text, "inf", 3) == 0) { - *ret_value = INFINITY; + *ret_value = (float_T)INFINITY; return 3; } if (STRNICMP(text, "-inf", 3) == 0) { - *ret_value = -INFINITY; + *ret_value = (float_T)-INFINITY; return 4; } if (STRNICMP(text, "nan", 3) == 0) { - *ret_value = NAN; + *ret_value = (float_T)NAN; return 3; } *ret_value = strtod(text, &s); diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 471c4092fe..eb5c6e503a 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -201,7 +201,7 @@ static void register_closure(ufunc_T *fp) } -/// Get a name for a lambda. Returned in static memory. +/// @return a name for a lambda. Returned in static memory. char_u *get_lambda_name(void) { static char_u name[30]; @@ -544,7 +544,8 @@ static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf } /// Find a function by name, return pointer to it in ufuncs. -/// @return NULL for unknown function. +/// +/// @return NULL for unknown function. ufunc_T *find_func(const char_u *name) { hashitem_T *hi; @@ -556,11 +557,9 @@ ufunc_T *find_func(const char_u *name) return NULL; } -/* - * Copy the function name of "fp" to buffer "buf". - * "buf" must be able to hold the function name plus three bytes. - * Takes care of script-local function names. - */ +/// Copy the function name of "fp" to buffer "buf". +/// "buf" must be able to hold the function name plus three bytes. +/// Takes care of script-local function names. static void cat_func_name(char_u *buf, ufunc_T *fp) { if (fp->uf_name[0] == K_SPECIAL) { @@ -571,9 +570,7 @@ static void cat_func_name(char_u *buf, ufunc_T *fp) } } -/* - * Add a number variable "name" to dict "dp" with value "nr". - */ +/// Add a number variable "name" to dict "dp" with value "nr". static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr) { #ifndef __clang_analyzer__ @@ -586,7 +583,7 @@ static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr) v->di_tv.vval.v_number = nr; } -// Free "fc" +/// Free "fc" static void free_funccal(funccall_T *fc) { for (int i = 0; i < fc->fc_funcs.ga_len; i++) { @@ -606,9 +603,9 @@ static void free_funccal(funccall_T *fc) xfree(fc); } -// Free "fc" and what it contains. -// Can be called only when "fc" is kept beyond the period of it called, -// i.e. after cleanup_function_call(fc). +/// Free "fc" and what it contains. +/// Can be called only when "fc" is kept beyond the period of it called, +/// i.e. after cleanup_function_call(fc). static void free_funccal_contents(funccall_T *fc) { // Free all l: variables. @@ -757,7 +754,7 @@ static void func_clear_items(ufunc_T *fp) /// Free all things that a function contains. Does not free the function /// itself, use func_free() for that. /// -/// param[in] force When true, we are exiting. +/// @param[in] force When true, we are exiting. static void func_clear(ufunc_T *fp, bool force) { if (fp->uf_cleared) { @@ -773,7 +770,7 @@ static void func_clear(ufunc_T *fp, bool force) /// Free a function and remove it from the list of functions. Does not free /// what a function contains, call func_clear() first. /// -/// param[in] fp The function to free. +/// @param[in] fp The function to free. static void func_free(ufunc_T *fp) { // only remove it when not done already, otherwise we would remove a newer @@ -786,7 +783,7 @@ static void func_free(ufunc_T *fp) /// Free all things that a function contains and free the function itself. /// -/// param[in] force When true, we are exiting. +/// @param[in] force When true, we are exiting. static void func_clear_free(ufunc_T *fp, bool force) { func_clear(fp, force); @@ -795,13 +792,13 @@ static void func_clear_free(ufunc_T *fp, bool force) /// Call a user function /// -/// @param fp Function to call. -/// @param[in] argcount Number of arguments. -/// @param argvars Arguments. -/// @param[out] rettv Return value. -/// @param[in] firstline First line of range. -/// @param[in] lastline Last line of range. -/// @param selfdict Dictionary for "self" for dictionary functions. +/// @param fp Function to call. +/// @param[in] argcount Number of arguments. +/// @param argvars Arguments. +/// @param[out] rettv Return value. +/// @param[in] firstline First line of range. +/// @param[in] lastline Last line of range. +/// @param selfdict Dictionary for "self" for dictionary functions. void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, linenr_T firstline, linenr_T lastline, dict_T *selfdict) FUNC_ATTR_NONNULL_ARG(1, 3, 4) @@ -1230,8 +1227,8 @@ static bool func_name_refcount(char_u *name) static funccal_entry_T *funccal_stack = NULL; -// Save the current function call pointer, and set it to NULL. -// Used when executing autocommands and for ":source". +/// Save the current function call pointer, and set it to NULL. +/// Used when executing autocommands and for ":source". void save_funccal(funccal_entry_T *entry) { entry->top_funccal = current_funccal; @@ -1384,8 +1381,8 @@ func_call_skip_call: return r; } -// Give an error message for the result of a function. -// Nothing if "error" is FCERR_NONE. +/// Give an error message for the result of a function. +/// Nothing if "error" is FCERR_NONE. static void user_func_error(int error, const char_u *name) FUNC_ATTR_NONNULL_ALL { @@ -1902,9 +1899,7 @@ theend: return name; } -/* - * ":function" - */ +/// ":function" void ex_function(exarg_T *eap) { char_u *theline; @@ -2595,11 +2590,9 @@ ret_free: } } // NOLINT(readability/fn_size) -/* - * Return 5 if "p" starts with "<SID>" or "<SNR>" (ignoring case). - * Return 2 if "p" starts with "s:". - * Return 0 otherwise. - */ +/// @return 5 if "p" starts with "<SID>" or "<SNR>" (ignoring case). +/// 2 if "p" starts with "s:". +/// 0 otherwise. int eval_fname_script(const char *const p) { // Use mb_strnicmp() because in Turkish comparing the "I" may not work with @@ -2625,10 +2618,10 @@ bool translated_function_exists(const char *name) /// Check whether function with the given name exists /// -/// @param[in] name Function name. -/// @param[in] no_deref Whether to dereference a Funcref. +/// @param[in] name Function name. +/// @param[in] no_deref Whether to dereference a Funcref. /// -/// @return True if it exists, false otherwise. +/// @return true if it exists, false otherwise. bool function_exists(const char *const name, bool no_deref) { const char_u *nm = (const char_u *)name; @@ -2651,10 +2644,8 @@ bool function_exists(const char *const name, bool no_deref) return n; } -/* - * Function given to ExpandGeneric() to obtain the list of user defined - * function names. - */ +/// Function given to ExpandGeneric() to obtain the list of user defined +/// function names. char_u *get_user_func_name(expand_T *xp, int idx) { static size_t done; @@ -2771,10 +2762,8 @@ void ex_delfunction(exarg_T *eap) } } -/* - * Unreference a Function: decrement the reference count and free it when it - * becomes zero. - */ +/// Unreference a Function: decrement the reference count and free it when it +/// becomes zero. void func_unref(char_u *name) { ufunc_T *fp = NULL; @@ -2868,9 +2857,7 @@ static int can_free_funccal(funccall_T *fc, int copyID) && fc->fc_copyID != copyID; } -/* - * ":return [expr]" - */ +/// ":return [expr]" void ex_return(exarg_T *eap) { char_u *arg = eap->arg; @@ -2921,9 +2908,7 @@ void ex_return(exarg_T *eap) // TODO(ZyX-I): move to eval/ex_cmds -/* - * ":1,25call func(arg1, arg2)" function call. - */ +/// ":1,25call func(arg1, arg2)" function call. void ex_call(exarg_T *eap) { char_u *arg = eap->arg; @@ -3050,14 +3035,16 @@ end: xfree(tofree); } -/* - * Return from a function. Possibly makes the return pending. Also called - * for a pending return at the ":endtry" or after returning from an extra - * do_cmdline(). "reanimate" is used in the latter case. "is_cmd" is set - * when called due to a ":return" command. "rettv" may point to a typval_T - * with the return rettv. Returns TRUE when the return can be carried out, - * FALSE when the return gets pending. - */ +/// Return from a function. Possibly makes the return pending. Also called +/// for a pending return at the ":endtry" or after returning from an extra +/// do_cmdline(). "reanimate" is used in the latter case. +/// +/// @param reanimate used after returning from an extra do_cmdline(). +/// @param is_cmd set when called due to a ":return" command. +/// @param rettv may point to a typval_T with the return rettv. +/// +/// @return TRUE when the return can be carried out, +/// FALSE when the return gets pending. int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv) { int idx; @@ -3068,12 +3055,10 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv) current_funccal->returned = false; } - // // Cleanup (and deactivate) conditionals, but stop when a try conditional // not in its finally clause (which then is to be executed next) is found. // In this case, make the ":return" pending for execution at the ":endtry". // Otherwise, return normally. - // idx = cleanup_conditionals(eap->cstack, 0, true); if (idx >= 0) { cstack->cs_pending[idx] = CSTP_RETURN; @@ -3126,10 +3111,8 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv) return idx < 0; } -/* - * Generate a return command for producing the value of "rettv". The result - * is an allocated string. Used by report_pending() for verbose messages. - */ +/// Generate a return command for producing the value of "rettv". The result +/// is an allocated string. Used by report_pending() for verbose messages. char_u *get_return_cmd(void *rettv) { char_u *s = NULL; @@ -3151,11 +3134,10 @@ char_u *get_return_cmd(void *rettv) return vim_strsave(IObuff); } -/* - * Get next function line. - * Called by do_cmdline() to get the next line. - * Returns allocated string, or NULL for end of function. - */ +/// Get next function line. +/// Called by do_cmdline() to get the next line. +/// +/// @return allocated string, or NULL for end of function. char_u *get_func_line(int c, void *cookie, int indent, bool do_concat) { funccall_T *fcp = (funccall_T *)cookie; @@ -3206,10 +3188,8 @@ char_u *get_func_line(int c, void *cookie, int indent, bool do_concat) return retval; } -/* - * Return TRUE if the currently active function should be ended, because a - * return was encountered or an error occurred. Used inside a ":while". - */ +/// @return TRUE if the currently active function should be ended, because a +/// return was encountered or an error occurred. Used inside a ":while". int func_has_ended(void *cookie) { funccall_T *fcp = (funccall_T *)cookie; @@ -3220,9 +3200,7 @@ int func_has_ended(void *cookie) || fcp->returned; } -/* - * return TRUE if cookie indicates a function which "abort"s on errors. - */ +/// @return TRUE if cookie indicates a function which "abort"s on errors. int func_has_abort(void *cookie) { return ((funccall_T *)cookie)->func->uf_flags & FC_ABORT; @@ -3289,41 +3267,31 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv) } } -/* - * Return the name of the executed function. - */ +/// @return the name of the executed function. char_u *func_name(void *cookie) { return ((funccall_T *)cookie)->func->uf_name; } -/* - * Return the address holding the next breakpoint line for a funccall cookie. - */ +/// @return the address holding the next breakpoint line for a funccall cookie. linenr_T *func_breakpoint(void *cookie) { return &((funccall_T *)cookie)->breakpoint; } -/* - * Return the address holding the debug tick for a funccall cookie. - */ +/// @return the address holding the debug tick for a funccall cookie. int *func_dbg_tick(void *cookie) { return &((funccall_T *)cookie)->dbg_tick; } -/* - * Return the nesting level for a funccall cookie. - */ +/// @return the nesting level for a funccall cookie. int func_level(void *cookie) { return ((funccall_T *)cookie)->level; } -/* - * Return TRUE when a function was ended by a ":return" command. - */ +/// @return TRUE when a function was ended by a ":return" command. int current_func_returned(void) { return current_funccal->returned; @@ -3372,8 +3340,8 @@ funccall_T *get_funccal(void) return funccal; } -/// Return the hashtable used for local variables in the current funccal. -/// Return NULL if there is no current funccal. +/// @return hashtable used for local variables in the current funccal or +/// NULL if there is no current funccal. hashtab_T *get_funccal_local_ht(void) { if (current_funccal == NULL) { @@ -3382,8 +3350,8 @@ hashtab_T *get_funccal_local_ht(void) return &get_funccal()->l_vars.dv_hashtab; } -/// Return the l: scope variable. -/// Return NULL if there is no current funccal. +/// @return the l: scope variable or +/// NULL if there is no current funccal. dictitem_T *get_funccal_local_var(void) { if (current_funccal == NULL) { @@ -3392,8 +3360,8 @@ dictitem_T *get_funccal_local_var(void) return (dictitem_T *)&get_funccal()->l_vars_var; } -/// Return the hashtable used for argument in the current funccal. -/// Return NULL if there is no current funccal. +/// @return the hashtable used for argument in the current funccal or +/// NULL if there is no current funccal. hashtab_T *get_funccal_args_ht(void) { if (current_funccal == NULL) { @@ -3402,8 +3370,8 @@ hashtab_T *get_funccal_args_ht(void) return &get_funccal()->l_avars.dv_hashtab; } -/// Return the a: scope variable. -/// Return NULL if there is no current funccal. +/// @return the a: scope variable or +/// NULL if there is no current funccal. dictitem_T *get_funccal_args_var(void) { if (current_funccal == NULL) { @@ -3412,9 +3380,7 @@ dictitem_T *get_funccal_args_var(void) return (dictitem_T *)¤t_funccal->l_avars_var; } -/* - * List function variables, if there is a function. - */ +/// List function variables, if there is a function. void list_func_vars(int *first) { if (current_funccal != NULL) { @@ -3423,9 +3389,8 @@ void list_func_vars(int *first) } } -/// If "ht" is the hashtable for local variables in the current funccal, return -/// the dict that contains it. -/// Otherwise return NULL. +/// @return if "ht" is the hashtable for local variables in the current +/// funccal, return the dict that contains it. Otherwise return NULL. dict_T *get_current_funccal_dict(hashtab_T *ht) { if (current_funccal != NULL && ht == ¤t_funccal->l_vars.dv_hashtab) { @@ -3589,7 +3554,7 @@ bool set_ref_in_func_args(int copyID) /// "list_stack" is used to add lists to be marked. Can be NULL. /// "ht_stack" is used to add hashtabs to be marked. Can be NULL. /// -/// @return true if setting references failed somehow. +/// @return true if setting references failed somehow. bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID) { ufunc_T *fp = fp_in; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index dae4dad16d..653fffae1c 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -237,7 +237,7 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL KILL_TIMEOUT_MS, 0); } -// Frees process-owned resources. +/// Frees process-owned resources. void process_free(Process *proc) FUNC_ATTR_NONNULL_ALL { if (proc->argv != NULL) { diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index e51689543f..26b5ce3b75 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -85,7 +85,7 @@ static void on_rbuffer_nonfull(RBuffer *buf, void *data) // Callbacks used by libuv -// Called by libuv to allocate memory for reading. +/// Called by libuv to allocate memory for reading. static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) { Stream *stream = handle->data; @@ -95,9 +95,9 @@ static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) buf->len = UV_BUF_LEN(write_count); } -// Callback invoked by libuv after it copies the data into the buffer provided -// by `alloc_cb`. This is also called on EOF or when `alloc_cb` returns a -// 0-length buffer. +/// Callback invoked by libuv after it copies the data into the buffer provided +/// by `alloc_cb`. This is also called on EOF or when `alloc_cb` returns a +/// 0-length buffer. static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) { Stream *stream = uvstream->data; @@ -134,11 +134,11 @@ static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) invoke_read_cb(stream, nread, false); } -// Called by the by the 'idle' handle to emulate a reading event -// -// Idle callbacks are invoked once per event loop: -// - to perform some very low priority activity. -// - to keep the loop "alive" (so there is always an event to process) +/// Called by the by the 'idle' handle to emulate a reading event +/// +/// Idle callbacks are invoked once per event loop: +/// - to perform some very low priority activity. +/// - to keep the loop "alive" (so there is always an event to process) static void fread_idle_cb(uv_idle_t *handle) { uv_fs_t req; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index dab17fc3a4..0dbc9d6b14 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6629,6 +6629,7 @@ static void ex_quit(exarg_T *eap) /// ":cquit". static void ex_cquit(exarg_T *eap) + FUNC_ATTR_NORETURN { // this does not always pass on the exit code to the Manx compiler. why? getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 0e2b7c0ece..39ff75d8c2 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -98,10 +98,11 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) return OK; } -// Write commands to "fd" to recursively create windows for frame "fr", -// horizontally and vertically split. -// After the commands the last window in the frame is the current window. -// Returns FAIL when writing the commands to "fd" fails. +/// Write commands to "fd" to recursively create windows for frame "fr", +/// horizontally and vertically split. +/// After the commands the last window in the frame is the current window. +/// +/// @return FAIL when writing the commands to "fd" fails. static int ses_win_rec(FILE *fd, frame_T *fr) { frame_T *frc; @@ -144,8 +145,9 @@ static int ses_win_rec(FILE *fd, frame_T *fr) return OK; } -// Skip frames that don't contain windows we want to save in the Session. -// Returns NULL when there none. +/// Skip frames that don't contain windows we want to save in the Session. +/// +/// @return NULL when there none. static frame_T *ses_skipframe(frame_T *fr) { frame_T *frc; @@ -158,8 +160,8 @@ static frame_T *ses_skipframe(frame_T *fr) return frc; } -// Return true if frame "fr" has a window somewhere that we want to save in -// the Session. +/// @return true if frame "fr" has a window somewhere that we want to save in +/// the Session. static bool ses_do_frame(const frame_T *fr) FUNC_ATTR_NONNULL_ARG(1) { @@ -176,7 +178,7 @@ static bool ses_do_frame(const frame_T *fr) return false; } -/// Return non-zero if window "wp" is to be stored in the Session. +/// @return non-zero if window "wp" is to be stored in the Session. static int ses_do_win(win_T *wp) { if (wp->w_buffer->b_fname == NULL @@ -229,7 +231,7 @@ static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigne return OK; } -/// Gets the buffer name for `buf`. +/// @return the buffer name for `buf`. static char *ses_get_fname(buf_T *buf, unsigned *flagp) { // Use the short file name if the current directory is known at the time @@ -249,7 +251,8 @@ static char *ses_get_fname(buf_T *buf, unsigned *flagp) /// Write a buffer name to the session file. /// Also ends the line, if "add_eol" is true. -/// Returns FAIL if writing fails. +/// +/// @return FAIL if writing fails. static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) { char *name = ses_get_fname(buf, flagp); @@ -260,11 +263,11 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) return OK; } -// Escapes a filename for session writing. -// Takes care of "slash" flag in 'sessionoptions' and escapes special -// characters. -// -// Returns allocated string or NULL. +/// Escapes a filename for session writing. +/// Takes care of "slash" flag in 'sessionoptions' and escapes special +/// characters. +/// +/// @return allocated string or NULL. static char *ses_escape_fname(char *name, unsigned *flagp) { char *p; @@ -283,10 +286,11 @@ static char *ses_escape_fname(char *name, unsigned *flagp) return p; } -// Write a file name to the session file. -// Takes care of the "slash" option in 'sessionoptions' and escapes special -// characters. -// Returns FAIL if writing fails. +/// Write a file name to the session file. +/// Takes care of the "slash" option in 'sessionoptions' and escapes special +/// characters. +/// +/// @return FAIL if writing fails. static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) { char *p = ses_escape_fname((char *)name, flagp); @@ -1052,7 +1056,7 @@ void ex_mkrc(exarg_T *eap) xfree(viewFile); } -/// Get the name of the view file for the current buffer. +/// @return the name of the view file for the current buffer. static char *get_view_file(int c) { if (curbuf->b_ffname == NULL) { @@ -1100,7 +1104,7 @@ static char *get_view_file(int c) return retval; } -// TODO(justinmk): remove this, not needed after 5ba3cecb68cd. +/// TODO(justinmk): remove this, not needed after 5ba3cecb68cd. int put_eol(FILE *fd) { if (putc('\n', fd) < 0) { @@ -1109,7 +1113,7 @@ int put_eol(FILE *fd) return OK; } -// TODO(justinmk): remove this, not needed after 5ba3cecb68cd. +/// TODO(justinmk): remove this, not needed after 5ba3cecb68cd. int put_line(FILE *fd, char *s) { if (fprintf(fd, "%s\n", s) < 0) { diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 6b879f5139..a3fcc7d784 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -175,8 +175,9 @@ static bool extmark_setraw(buf_T *buf, uint64_t mark, int row, colnr_T col) return true; } -// Remove an extmark -// Returns 0 on missing id +/// Remove an extmark +/// +/// @return 0 on missing id bool extmark_del(buf_T *buf, uint32_t ns_id, uint32_t id) { MarkTreeIter itr[1] = { 0 }; @@ -203,8 +204,8 @@ bool extmark_del(buf_T *buf, uint32_t ns_id, uint32_t id) return true; } -// Free extmarks in a ns between lines -// if ns = 0, it means clear all namespaces +/// Free extmarks in a ns between lines +/// if ns = 0, it means clear all namespaces bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_row, colnr_T u_col) { if (!map_size(buf->b_extmark_ns)) { @@ -287,12 +288,13 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r return marks_cleared; } -// Returns the position of marks between a range, -// marks found at the start or end index will be included, -// if upper_lnum or upper_col are negative the buffer -// will be searched to the start, or end -// dir can be set to control the order of the array -// amount = amount of marks to find or -1 for all +/// @return the position of marks between a range, +/// marks found at the start or end index will be included. +/// +/// if upper_lnum or upper_col are negative the buffer +/// will be searched to the start, or end +/// dir can be set to control the order of the array +/// amount = amount of marks to find or -1 for all ExtmarkInfoArray extmark_get(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_row, colnr_T u_col, int64_t amount, bool reverse) { @@ -334,7 +336,7 @@ next_mark: return array; } -// Lookup an extmark by id +/// Lookup an extmark by id ExtmarkInfo extmark_from_id(buf_T *buf, uint32_t ns_id, uint32_t id) { ExtmarkInfo ret = { 0, 0, -1, -1, -1, -1, false, false, DECORATION_INIT }; @@ -359,7 +361,7 @@ ExtmarkInfo extmark_from_id(buf_T *buf, uint32_t ns_id, uint32_t id) } -// free extmarks from the buffer +/// free extmarks from the buffer void extmark_free_all(buf_T *buf) { if (!map_size(buf->b_extmark_ns)) { @@ -389,7 +391,7 @@ void extmark_free_all(buf_T *buf) } -// Save info for undo/redo of set marks +/// Save info for undo/redo of set marks static void u_extmark_set(buf_T *buf, uint64_t mark, int row, colnr_T col) { u_header_T *uhp = u_force_get_undo_header(buf); @@ -499,7 +501,7 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo) } -// Adjust extmark row for inserted/deleted rows (columns stay fixed). +/// Adjust extmark row for inserted/deleted rows (columns stay fixed). void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, long amount_after, ExtmarkOp undo) { diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index d0f7a91d6c..15f1d3d065 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -529,9 +529,7 @@ error_return: return NULL; } -/* - * Get the stopdir string. Check that ';' is not escaped. - */ +/// @return the stopdir string. Check that ';' is not escaped. char_u *vim_findfile_stopdir(char_u *buf) { char_u *r_ptr = buf; @@ -554,9 +552,7 @@ char_u *vim_findfile_stopdir(char_u *buf) return r_ptr; } -/* - * Clean up the given search context. Can handle a NULL pointer. - */ +/// Clean up the given search context. Can handle a NULL pointer. void vim_findfile_cleanup(void *ctx) { if (ctx == NULL) { @@ -568,18 +564,19 @@ void vim_findfile_cleanup(void *ctx) xfree(ctx); } -/* - * Find a file in a search context. - * The search context was created with vim_findfile_init() above. - * Return a pointer to an allocated file name or NULL if nothing found. - * To get all matching files call this function until you get NULL. - * - * If the passed search_context is NULL, NULL is returned. - * - * The search algorithm is depth first. To change this replace the - * stack with a list (don't forget to leave partly searched directories on the - * top of the list). - */ +/// Find a file in a search context. +/// The search context was created with vim_findfile_init() above. +/// +/// To get all matching files call this function until you get NULL. +/// +/// If the passed search_context is NULL, NULL is returned. +/// +/// The search algorithm is depth first. To change this replace the +/// stack with a list (don't forget to leave partly searched directories on the +/// top of the list). +/// +/// @return a pointer to an allocated file name or, +/// NULL if nothing found. char_u *vim_findfile(void *search_ctx_arg) { char_u *file_path; @@ -999,10 +996,8 @@ fail: return NULL; } -/* - * Free the list of lists of visited files and directories - * Can handle it if the passed search_context is NULL; - */ +/// Free the list of lists of visited files and directories +/// Can handle it if the passed search_context is NULL; void vim_findfile_free_visited(void *search_ctx_arg) { ff_search_ctx_T *search_ctx; @@ -1044,10 +1039,8 @@ static void ff_free_visited_list(ff_visited_T *vl) vl = NULL; } -/* - * Returns the already visited list for the given filename. If none is found it - * allocates a new one. - */ +/// @return the already visited list for the given filename. If none is found it +/// allocates a new one. static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, ff_visited_list_hdr_T **list_headp) { @@ -1094,13 +1087,13 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, return retptr; } -// Check if two wildcard paths are equal. -// They are equal if: -// - both paths are NULL -// - they have the same length -// - char by char comparison is OK -// - the only differences are in the counters behind a '**', so -// '**\20' is equal to '**\24' +/// Check if two wildcard paths are equal. +/// They are equal if: +/// - both paths are NULL +/// - they have the same length +/// - char by char comparison is OK +/// - the only differences are in the counters behind a '**', so +/// '**\20' is equal to '**\24' static bool ff_wc_equal(char_u *s1, char_u *s2) { int i, j; @@ -1134,11 +1127,10 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) return s1[i] == s2[j]; } -/* - * maintains the list of already visited files and dirs - * returns FAIL if the given file/dir is already in the list - * returns OK if it is newly added - */ +/// maintains the list of already visited files and dirs +/// +/// @return FAIL if the given file/dir is already in the list or, +/// OK if it is newly added static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *wc_path) { ff_visited_T *vp; @@ -1196,9 +1188,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u * return OK; } -/* - * create stack element from given path pieces - */ +/// create stack element from given path pieces static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, int level, int star_star_empty) { @@ -1226,9 +1216,7 @@ static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, in return new; } -/* - * Push a dir on the directory stack. - */ +/// Push a dir on the directory stack. static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr) { /* check for NULL pointer, not to return an error to the user, but @@ -1239,10 +1227,9 @@ static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr) } } -/* - * Pop a dir from the directory stack. - * Returns NULL if stack is empty. - */ +/// Pop a dir from the directory stack. +/// +/// @return NULL if stack is empty. static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx) { ff_stack_T *sptr; @@ -1255,9 +1242,7 @@ static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx) return sptr; } -/* - * free the given stack element - */ +/// free the given stack element static void ff_free_stack_element(ff_stack_T *const stack_ptr) { if (stack_ptr == NULL) { @@ -1275,9 +1260,7 @@ static void ff_free_stack_element(ff_stack_T *const stack_ptr) xfree(stack_ptr); } -/* - * Clear the search context, but NOT the visited list. - */ +/// Clear the search context, but NOT the visited list. static void ff_clear(ff_search_ctx_T *search_ctx) { ff_stack_T *sptr; @@ -1311,10 +1294,9 @@ static void ff_clear(ff_search_ctx_T *search_ctx) search_ctx->ffsc_level = 0; } -/* - * check if the given path is in the stopdirs - * returns TRUE if yes else FALSE - */ +/// check if the given path is in the stopdirs +/// +/// @return TRUE if yes else FALSE static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v) { int i = 0; @@ -1670,7 +1652,8 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre /// Change to a file's directory. /// Caller must call shorten_fnames()! -/// @return OK or FAIL +/// +/// @return OK or FAIL int vim_chdirfile(char_u *fname, CdCause cause) { char dir[MAXPATHL]; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 41e67e5b3b..fe61a2fc90 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2033,9 +2033,7 @@ void prep_exarg(exarg_T *eap, const buf_T *buf) eap->forceit = FALSE; } -/* - * Set default or forced 'fileformat' and 'binary'. - */ +/// Set default or forced 'fileformat' and 'binary'. void set_file_options(int set_options, exarg_T *eap) { // set default 'fileformat' @@ -2056,9 +2054,7 @@ void set_file_options(int set_options, exarg_T *eap) } } -/* - * Set forced 'fileencoding'. - */ +/// Set forced 'fileencoding'. void set_forced_fenc(exarg_T *eap) { if (eap->force_enc != 0) { @@ -2068,12 +2064,12 @@ void set_forced_fenc(exarg_T *eap) } } -// Find next fileencoding to use from 'fileencodings'. -// "pp" points to fenc_next. It's advanced to the next item. -// When there are no more items, an empty string is returned and *pp is set to -// NULL. -// When *pp is not set to NULL, the result is in allocated memory and "alloced" -// is set to true. +/// Find next fileencoding to use from 'fileencodings'. +/// "pp" points to fenc_next. It's advanced to the next item. +/// When there are no more items, an empty string is returned and *pp is set to +/// NULL. +/// When *pp is not set to NULL, the result is in allocated memory and "alloced" +/// is set to true. static char_u *next_fenc(char_u **pp, bool *alloced) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { @@ -2149,10 +2145,8 @@ static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp) } -/* - * Read marks for the current buffer from the ShaDa file, when we support - * buffer marks and the buffer has a name. - */ +/// Read marks for the current buffer from the ShaDa file, when we support +/// buffer marks and the buffer has a name. static void check_marks_read(void) { if (!curbuf->b_marks_read && get_shada_parameter('\'') > 0 @@ -3761,10 +3755,8 @@ nofail: #undef SET_ERRMSG_NUM } -/* - * Set the name of the current buffer. Use when the buffer doesn't have a - * name and a ":r" or ":w" command with a file name is used. - */ +/// Set the name of the current buffer. Use when the buffer doesn't have a +/// name and a ":r" or ":w" command with a file name is used. static int set_rw_fname(char_u *fname, char_u *sfname) { buf_T *buf = curbuf; @@ -3854,9 +3846,7 @@ static bool msg_add_fileformat(int eol_type) return false; } -/* - * Append line and character count to IObuff. - */ +/// Append line and character count to IObuff. void msg_add_lines(int insert_space, long lnum, off_T nchars) { char_u *p; @@ -3880,20 +3870,16 @@ void msg_add_lines(int insert_space, long lnum, off_T nchars) } } -/* - * Append message for missing line separator to IObuff. - */ +/// Append message for missing line separator to IObuff. static void msg_add_eol(void) { STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]")); } -/* - * Check modification time of file, before writing to it. - * The size isn't checked, because using a tool like "gzip" takes care of - * using the same timestamp but can't set the size. - */ +/// Check modification time of file, before writing to it. +/// The size isn't checked, because using a tool like "gzip" takes care of +/// using the same timestamp but can't set the size. static int check_mtime(buf_T *buf, FileInfo *file_info) { if (buf->b_mtime_read != 0 @@ -3925,12 +3911,10 @@ static bool time_differs(const FileInfo *file_info, long mtime, long mtime_ns) F #endif } -/* - * Call write() to write a number of bytes to the file. - * Handles 'encoding' conversion. - * - * Return FAIL for failure, OK otherwise. - */ +/// Call write() to write a number of bytes to the file. +/// Handles 'encoding' conversion. +/// +/// @return FAIL for failure, OK otherwise. static int buf_write_bytes(struct bw_info *ip) { int wlen; @@ -4258,12 +4242,11 @@ static int get_fio_flags(const char_u *name) } -/* - * Check for a Unicode BOM (Byte Order Mark) at the start of p[size]. - * "size" must be at least 2. - * Return the name of the encoding and set "*lenp" to the length. - * Returns NULL when no BOM found. - */ +/// Check for a Unicode BOM (Byte Order Mark) at the start of p[size]. +/// "size" must be at least 2. +/// +/// @return the name of the encoding and set "*lenp" to the length or, +/// NULL when no BOM found. static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags) { char *name = NULL; @@ -4304,10 +4287,9 @@ static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags) return (char_u *)name; } -/* - * Generate a BOM in "buf[4]" for encoding "name". - * Return the length of the BOM (zero when no BOM). - */ +/// Generate a BOM in "buf[4]" for encoding "name". +/// +/// @return the length of the BOM (zero when no BOM). static int make_bom(char_u *buf, char_u *name) { int flags; @@ -4332,10 +4314,12 @@ static int make_bom(char_u *buf, char_u *name) } /// Shorten filename of a buffer. -/// When "force" is TRUE: Use full path from now on for files currently being -/// edited, both for file name and swap file name. Try to shorten the file -/// names a bit, if safe to do so. -/// When "force" is FALSE: Only try to shorten absolute file names. +/// +/// @param force when TRUE: Use full path from now on for files currently being +/// edited, both for file name and swap file name. Try to shorten the file +/// names a bit, if safe to do so. +/// when FALSE: Only try to shorten absolute file names. +/// /// For buffers that have buftype "nofile" or "scratch": never change the file /// name. void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) @@ -4513,7 +4497,8 @@ bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL } /// Read 2 bytes from "fd" and turn them into an int, MSB first. -/// Returns -1 when encountering EOF. +/// +/// @return -1 when encountering EOF. int get2c(FILE *fd) { const int n = getc(fd); @@ -4528,7 +4513,8 @@ int get2c(FILE *fd) } /// Read 3 bytes from "fd" and turn them into an int, MSB first. -/// Returns -1 when encountering EOF. +/// +/// @return -1 when encountering EOF. int get3c(FILE *fd) { int n = getc(fd); @@ -4548,7 +4534,8 @@ int get3c(FILE *fd) } /// Read 4 bytes from "fd" and turn them into an int, MSB first. -/// Returns -1 when encountering EOF. +/// +/// @return -1 when encountering EOF. int get4c(FILE *fd) { // Use unsigned rather than int otherwise result is undefined @@ -4579,7 +4566,8 @@ int get4c(FILE *fd) } /// Read 8 bytes from `fd` and turn them into a time_t, MSB first. -/// Returns -1 when encountering EOF. +/// +/// @return -1 when encountering EOF. time_t get8ctime(FILE *fd) { time_t n = 0; @@ -4595,7 +4583,8 @@ time_t get8ctime(FILE *fd) } /// Reads a string of length "cnt" from "fd" into allocated memory. -/// @return pointer to the string or NULL when unable to read that many bytes. +/// +/// @return pointer to the string or NULL when unable to read that many bytes. char *read_string(FILE *fd, size_t cnt) { char *str = xmallocz(cnt); @@ -4611,7 +4600,8 @@ char *read_string(FILE *fd, size_t cnt) } /// Writes a number to file "fd", most significant bit first, in "len" bytes. -/// @returns false in case of an error. +/// +/// @return false in case of an error. bool put_bytes(FILE *fd, uintmax_t number, size_t len) { assert(len > 0); @@ -4624,7 +4614,8 @@ bool put_bytes(FILE *fd, uintmax_t number, size_t len) } /// Writes time_t to file "fd" in 8 bytes. -/// @returns FAIL when the write failed. +/// +/// @return FAIL when the write failed. int put_time(FILE *fd, time_t time_) { uint8_t buf[8]; @@ -4635,7 +4626,7 @@ int put_time(FILE *fd, time_t time_) /// os_rename() only works if both files are on the same file system, this /// function will (attempts to?) copy the file across if rename fails -- webb /// -/// @return -1 for failure, 0 for success +/// @return -1 for failure, 0 for success int vim_rename(const char_u *from, const char_u *to) FUNC_ATTR_NONNULL_ALL { @@ -4860,11 +4851,10 @@ int check_timestamps(int focus) return didit; } -/* - * Move all the lines from buffer "frombuf" to buffer "tobuf". - * Return OK or FAIL. When FAIL "tobuf" is incomplete and/or "frombuf" is not - * empty. - */ +/// Move all the lines from buffer "frombuf" to buffer "tobuf". +/// +/// @return OK or FAIL. +/// When FAIL "tobuf" is incomplete and/or "frombuf" is not empty. static int move_lines(buf_T *frombuf, buf_T *tobuf) { buf_T *tbuf = curbuf; @@ -4903,9 +4893,10 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf) /// Check if buffer "buf" has been changed. /// Also check if the file for a new buffer unexpectedly appeared. -/// return 1 if a changed buffer was found. -/// return 2 if a message has been displayed. -/// return 0 otherwise. +/// +/// @return 1 if a changed buffer was found or, +/// 2 if a message has been displayed or, +/// 0 otherwise. int buf_check_timestamp(buf_T *buf) FUNC_ATTR_NONNULL_ALL { @@ -5280,10 +5271,8 @@ void buf_store_file_info(buf_T *buf, FileInfo *file_info) buf->b_orig_mode = (int)file_info->stat.st_mode; } -/* - * Adjust the line with missing eol, used for the next write. - * Used for do_filter(), when the input lines for the filter are deleted. - */ +/// Adjust the line with missing eol, used for the next write. +/// Used for do_filter(), when the input lines for the filter are deleted. void write_lnum_adjust(linenr_T offset) { if (curbuf->b_no_eol_lnum != 0) { // only if there is a missing eol @@ -5355,8 +5344,10 @@ static void vim_maketempdir(void) } /// Delete "name" and everything in it, recursively. +/// /// @param name The path which should be deleted. -/// @return 0 for success, -1 if some file was not deleted. +/// +/// @return 0 for success, -1 if some file was not deleted. int delete_recursive(const char *name) { int result = 0; @@ -5400,8 +5391,8 @@ void vim_deltempdir(void) } } -/// Get the name of temp directory. This directory would be created on the first -/// call to this function. +/// @return the name of temp directory. This directory would be created on the first +/// call to this function. char_u *vim_gettempdir(void) { if (vim_tempdir == NULL) { @@ -5435,8 +5426,8 @@ static bool vim_settempdir(char *tempdir) /// /// @note The temp file is NOT created. /// -/// @return pointer to the temp file name or NULL if Neovim can't create -/// temporary directory for its own temporary files. +/// @return pointer to the temp file name or NULL if Neovim can't create +/// temporary directory for its own temporary files. char_u *vim_tempname(void) { // Temp filename counter. @@ -5747,10 +5738,9 @@ char_u *file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allo } #if defined(EINTR) -/* - * Version of read() that retries when interrupted by EINTR (possibly - * by a SIGWINCH). - */ + +/// Version of read() that retries when interrupted by EINTR (possibly +/// by a SIGWINCH). long read_eintr(int fd, void *buf, size_t bufsize) { long ret; @@ -5764,10 +5754,8 @@ long read_eintr(int fd, void *buf, size_t bufsize) return ret; } -/* - * Version of write() that retries when interrupted by EINTR (possibly - * by a SIGWINCH). - */ +/// Version of write() that retries when interrupted by EINTR (possibly +/// by a SIGWINCH). long write_eintr(int fd, void *buf, size_t bufsize) { long ret = 0; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 3ec5d24753..c10172cc52 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1583,6 +1583,14 @@ int vgetc(void) c = utf_ptr2char(buf); } + if ((mod_mask & MOD_MASK_CTRL) && (c >= '?' && c <= '_')) { + c = Ctrl_chr(c); + mod_mask &= ~MOD_MASK_CTRL; + if (c == 0) { // <C-@> is <Nul> + c = K_ZERO; + } + } + // If mappings are enabled (i.e., not Ctrl-v) and the user directly typed // something with a meta- or alt- modifier that was not mapped, interpret // <M-x> as <Esc>x rather than as an unbound meta keypress. #8213 diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 32f2158d7b..9ad9640834 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -744,12 +744,15 @@ static int extract_modifiers(int key, int *modp) modifiers &= ~MOD_MASK_SHIFT; } } - if ((modifiers & MOD_MASK_CTRL) - && ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) { - key = Ctrl_chr(key); - modifiers &= ~MOD_MASK_CTRL; - if (key == 0) { // <C-@> is <Nul> - key = K_ZERO; + if ((modifiers & MOD_MASK_CTRL) && ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) { + key = TOUPPER_ASC(key); + int new_key = Ctrl_chr(key); + if (new_key != TAB && new_key != CAR && new_key != ESC) { + key = new_key; + modifiers &= ~MOD_MASK_CTRL; + if (key == 0) { // <C-@> is <Nul> + key = K_ZERO; + } } } diff --git a/src/nvim/log.c b/src/nvim/log.c index 5539e3d6c5..7d50ecf69e 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -282,6 +282,7 @@ static bool do_log_to_file(FILE *log_file, int log_level, const char *context, static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context, const char *func_name, int line_num, bool eol, const char *fmt, va_list args) + FUNC_ATTR_PRINTF(7, 0) { static const char *log_levels[] = { [DEBUG_LOG_LEVEL] = "DEBUG", diff --git a/src/nvim/main.c b/src/nvim/main.c index dec1ae93e7..afb9313cba 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2099,6 +2099,7 @@ static bool file_owned(const char *fname) /// @param errstr string containing an error message /// @param str string to append to the primary error message, or NULL static void mainerr(const char *errstr, const char *str) + FUNC_ATTR_NORETURN { char *prgname = (char *)path_tail((char_u *)argv0); diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 54cfaee80a..c6c4990334 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -522,6 +522,7 @@ static bool input_ready(MultiQueue *events) // Exit because of an input read error. static void read_error_exit(void) + FUNC_ATTR_NORETURN { if (silent_mode) { // Normal way to exit for "nvim -es". getout(0); diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index a8bf68a1a2..327ab6bc48 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -152,6 +152,7 @@ static char *signal_name(int signum) // NOTE: Avoid unsafe functions, such as allocating memory, they can result in // a deadlock. static void deadly_signal(int signum) + FUNC_ATTR_NORETURN { // Set the v:dying variable. set_vim_var_nr(VV_DYING, 1); diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 95eccde35c..12febfeb93 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -185,7 +185,7 @@ func Test_let_register() call Assert_reg('"', 'v', "abc", "['abc']", "abc", "['abc']") let @" = "abc\n" call Assert_reg('"', 'V', "abc\n", "['abc']", "abc\n", "['abc']") - let @" = "abc\<C-m>" + let @" = "abc\r" call Assert_reg('"', 'V', "abc\r\n", "['abc\r']", "abc\r\n", "['abc\r']") let @= = '"abc"' call Assert_reg('=', 'v', "abc", "['abc']", '"abc"', "['\"abc\"']") diff --git a/src/nvim/testdir/test_regex_char_classes.vim b/src/nvim/testdir/test_regex_char_classes.vim index c1a4202c2b..b0d76a15e2 100644 --- a/src/nvim/testdir/test_regex_char_classes.vim +++ b/src/nvim/testdir/test_regex_char_classes.vim @@ -66,22 +66,22 @@ func Test_regex_char_classes() let save_enc = &encoding set encoding=utf-8 - let input = "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱" + let input = "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱" " Format is [cmd_to_run, expected_output] let tests = [ \ [':s/\%#=0\d//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\d//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\d//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[0-9]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[0-9]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[0-9]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\D//g', \ "0123456789"], \ [':s/\%#=1\D//g', @@ -95,17 +95,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^0-9]//g', \ "0123456789"], \ [':s/\%#=0\o//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\o//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\o//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[0-7]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[0-7]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[0-7]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./89:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\O//g', \ "01234567"], \ [':s/\%#=1\O//g', @@ -119,17 +119,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^0-7]//g', \ "01234567"], \ [':s/\%#=0\x//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\x//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\x//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[0-9A-Fa-f]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[0-9A-Fa-f]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[0-9A-Fa-f]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@GHIXYZ[\]^_`ghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\X//g', \ "0123456789ABCDEFabcdef"], \ [':s/\%#=1\X//g', @@ -143,17 +143,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^0-9A-Fa-f]//g', \ "0123456789ABCDEFabcdef"], \ [':s/\%#=0\w//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\w//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\w//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[0-9A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[0-9A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[0-9A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\W//g', \ "0123456789ABCDEFGHIXYZ_abcdefghiwxyz"], \ [':s/\%#=1\W//g', @@ -167,17 +167,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^0-9A-Za-z_]//g', \ "0123456789ABCDEFGHIXYZ_abcdefghiwxyz"], \ [':s/\%#=0\h//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\h//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\h//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[A-Za-z_]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\H//g', \ "ABCDEFGHIXYZ_abcdefghiwxyz"], \ [':s/\%#=1\H//g', @@ -191,17 +191,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^A-Za-z_]//g', \ "ABCDEFGHIXYZ_abcdefghiwxyz"], \ [':s/\%#=0\a//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\a//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\a//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[A-Za-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[A-Za-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[A-Za-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\A//g', \ "ABCDEFGHIXYZabcdefghiwxyz"], \ [':s/\%#=1\A//g', @@ -215,17 +215,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^A-Za-z]//g', \ "ABCDEFGHIXYZabcdefghiwxyz"], \ [':s/\%#=0\l//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\l//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\l//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[a-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[a-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[a-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\L//g', \ "abcdefghiwxyz"], \ [':s/\%#=1\L//g', @@ -239,17 +239,17 @@ func Test_regex_char_classes() \ [':s/\%#=2[^a-z]//g', \ "abcdefghiwxyz"], \ [':s/\%#=0\u//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1\u//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2\u//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[A-Z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[A-Z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[A-Z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./0123456789:;<=>?@[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0\U//g', \ "ABCDEFGHIXYZ"], \ [':s/\%#=1\U//g', @@ -269,11 +269,11 @@ func Test_regex_char_classes() \ [':s/\%#=2\%' . line('.') . 'l^\t...//g', \ "!\"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[0-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=1[0-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=2[0-z]//g', - \ "\t\<C-L>\<C-M> !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], + \ "\t\<C-L>\r !\"#$%&'()#+'-./{|}~\<C-?>\u0080\u0082\u0090\u009bΡ记娱"], \ [':s/\%#=0[^0-z]//g', \ "0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz"], \ [':s/\%#=1[^0-z]//g', diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index dbb792d2b0..9710a7ab84 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -177,9 +177,9 @@ func Test_sub_cmd_1() \ ['I', 's/I/\lII/', ['iI']], \ ['J', 's/J/\LJ\EJ/', ['jJ']], \ ['K', 's/K/\Uk\ek/', ['Kk']], - \ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']], + \ ['lLl', "s/L/\<C-V>\r/", ["l\<C-V>", 'l']], \ ['mMm', 's/M/\r/', ['m', 'm']], - \ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']], + \ ['nNn', "s/N/\\\<C-V>\r/", ["n\<C-V>", 'n']], \ ['oOo', 's/O/\n/', ["o\no"]], \ ['pPp', 's/P/\b/', ["p\<C-H>p"]], \ ['qQq', 's/Q/\t/', ["q\tq"]], @@ -208,9 +208,9 @@ func Test_sub_cmd_2() \ ['I', 's/I/\lII/', ['iI']], \ ['J', 's/J/\LJ\EJ/', ['jJ']], \ ['K', 's/K/\Uk\ek/', ['Kk']], - \ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']], + \ ['lLl', "s/L/\<C-V>\r/", ["l\<C-V>", 'l']], \ ['mMm', 's/M/\r/', ['m', 'm']], - \ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']], + \ ['nNn', "s/N/\\\<C-V>\r/", ["n\<C-V>", 'n']], \ ['oOo', 's/O/\n/', ["o\no"]], \ ['pPp', 's/P/\b/', ["p\<C-H>p"]], \ ['qQq', 's/Q/\t/', ["q\tq"]], @@ -230,9 +230,9 @@ func Test_sub_cmd_3() " List entry format: [input, cmd, output] let tests = [['aAa', "s/A/\\='\\'/", ['a\a']], \ ['bBb', "s/B/\\='\\\\'/", ['b\\b']], - \ ['cCc', "s/C/\\='\<C-V>\<C-M>'/", ["c\<C-V>", 'c']], - \ ['dDd', "s/D/\\='\\\<C-V>\<C-M>'/", ["d\\\<C-V>", 'd']], - \ ['eEe', "s/E/\\='\\\\\<C-V>\<C-M>'/", ["e\\\\\<C-V>", 'e']], + \ ['cCc', "s/C/\\='\<C-V>\r'/", ["c\<C-V>", 'c']], + \ ['dDd', "s/D/\\='\\\<C-V>\r'/", ["d\\\<C-V>", 'd']], + \ ['eEe', "s/E/\\='\\\\\<C-V>\r'/", ["e\\\\\<C-V>", 'e']], \ ['fFf', "s/F/\\='\r'/", ['f', 'f']], \ ['gGg', "s/G/\\='\<C-V>\<C-J>'/", ["g\<C-V>", 'g']], \ ['hHh', "s/H/\\='\\\<C-V>\<C-J>'/", ["h\\\<C-V>", 'h']], @@ -254,11 +254,11 @@ func Test_sub_cmd_4() \ ['a\a']], \ ['bBb', "s/B/\\=substitute(submatch(0), '.', '\\', '')/", \ ['b\b']], - \ ['cCc', "s/C/\\=substitute(submatch(0), '.', '\<C-V>\<C-M>', '')/", + \ ['cCc', "s/C/\\=substitute(submatch(0), '.', '\<C-V>\r', '')/", \ ["c\<C-V>", 'c']], - \ ['dDd', "s/D/\\=substitute(submatch(0), '.', '\\\<C-V>\<C-M>', '')/", + \ ['dDd', "s/D/\\=substitute(submatch(0), '.', '\\\<C-V>\r', '')/", \ ["d\<C-V>", 'd']], - \ ['eEe', "s/E/\\=substitute(submatch(0), '.', '\\\\\<C-V>\<C-M>', '')/", + \ ['eEe', "s/E/\\=substitute(submatch(0), '.', '\\\\\<C-V>\r', '')/", \ ["e\\\<C-V>", 'e']], \ ['fFf', "s/F/\\=substitute(submatch(0), '.', '\\r', '')/", \ ['f', 'f']], @@ -316,7 +316,7 @@ func Test_sub_cmd_7() set cpo& " List entry format: [input, cmd, output] - let tests = [ ["A\<C-V>\<C-M>A", 's/A./\=submatch(0)/', ['A', 'A']], + let tests = [ ["A\<C-V>\rA", 's/A./\=submatch(0)/', ['A', 'A']], \ ["B\<C-V>\<C-J>B", 's/B./\=submatch(0)/', ['B', 'B']], \ ["C\<C-V>\<C-J>C", 's/C./\=strtrans(string(submatch(0, 1)))/', [strtrans("['C\<C-J>']C")]], \ ["D\<C-V>\<C-J>\nD", 's/D.\nD/\=strtrans(string(submatch(0, 1)))/', [strtrans("['D\<C-J>', 'D']")]], @@ -467,11 +467,11 @@ func Test_sub_replace_1() call assert_equal('iI', substitute('I', 'I', '\lII', '')) call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', '')) call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', '')) - call assert_equal("l\<C-V>\<C-M>l", - \ substitute('lLl', 'L', "\<C-V>\<C-M>", '')) - call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', '')) - call assert_equal("n\<C-V>\<C-M>n", - \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", '')) + call assert_equal("l\<C-V>\rl", + \ substitute('lLl', 'L', "\<C-V>\r", '')) + call assert_equal("m\rm", substitute('mMm', 'M', '\r', '')) + call assert_equal("n\<C-V>\rn", + \ substitute('nNn', 'N', "\\\<C-V>\r", '')) call assert_equal("o\no", substitute('oOo', 'O', '\n', '')) call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', '')) call assert_equal("q\tq", substitute('qQq', 'Q', '\t', '')) @@ -480,7 +480,7 @@ func Test_sub_replace_1() call assert_equal("u\nu", substitute('uUu', 'U', "\n", '')) call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", '')) call assert_equal("w\\w", substitute('wWw', 'W', "\\", '')) - call assert_equal("x\<C-M>x", substitute('xXx', 'X', "\r", '')) + call assert_equal("x\rx", substitute('xXx', 'X', "\r", '')) call assert_equal("YyyY", substitute('Y', 'Y', '\L\uyYy\l\EY', '')) call assert_equal("zZZz", substitute('Z', 'Z', '\U\lZzZ\u\Ez', '')) endfunc @@ -500,17 +500,17 @@ func Test_sub_replace_2() call assert_equal('iI', substitute('I', 'I', '\lII', '')) call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', '')) call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', '')) - call assert_equal("l\<C-V>\<C-M>l", - \ substitute('lLl', 'L', "\<C-V>\<C-M>", '')) - call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', '')) - call assert_equal("n\<C-V>\<C-M>n", - \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", '')) + call assert_equal("l\<C-V>\rl", + \ substitute('lLl', 'L', "\<C-V>\r", '')) + call assert_equal("m\rm", substitute('mMm', 'M', '\r', '')) + call assert_equal("n\<C-V>\rn", + \ substitute('nNn', 'N', "\\\<C-V>\r", '')) call assert_equal("o\no", substitute('oOo', 'O', '\n', '')) call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', '')) call assert_equal("q\tq", substitute('qQq', 'Q', '\t', '')) call assert_equal('r\r', substitute('rRr', 'R', '\\', '')) call assert_equal('scs', substitute('sSs', 'S', '\c', '')) - call assert_equal("t\<C-M>t", substitute('tTt', 'T', "\r", '')) + call assert_equal("t\rt", substitute('tTt', 'T', "\r", '')) call assert_equal("u\nu", substitute('uUu', 'U', "\n", '')) call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", '')) call assert_equal('w\w', substitute('wWw', 'W', "\\", '')) @@ -528,7 +528,7 @@ func Test_sub_replace_3() call assert_equal("e\\\\\re", substitute('eEe', 'E', "\\=\"\\\\\\\\\r\"", '')) call assert_equal('f\rf', substitute('fFf', 'F', '\="\\r"', '')) call assert_equal('j\nj', substitute('jJj', 'J', '\="\\n"', '')) - call assert_equal("k\<C-M>k", substitute('kKk', 'K', '\="\r"', '')) + call assert_equal("k\rk", substitute('kKk', 'K', '\="\r"', '')) call assert_equal("l\nl", substitute('lLl', 'L', '\="\n"', '')) endfunc @@ -540,10 +540,10 @@ func Test_sub_replace_4() \ '\=substitute(submatch(0), ".", "\\", "")', '')) call assert_equal('b\b', substitute('bBb', 'B', \ '\=substitute(submatch(0), ".", "\\\\", "")', '')) - call assert_equal("c\<C-V>\<C-M>c", substitute('cCc', 'C', '\=substitute(submatch(0), ".", "\<C-V>\<C-M>", "")', '')) - call assert_equal("d\<C-V>\<C-M>d", substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\\<C-V>\<C-M>", "")', '')) - call assert_equal("e\\\<C-V>\<C-M>e", substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\\<C-V>\<C-M>", "")', '')) - call assert_equal("f\<C-M>f", substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '')) + call assert_equal("c\<C-V>\rc", substitute('cCc', 'C', '\=substitute(submatch(0), ".", "\<C-V>\r", "")', '')) + call assert_equal("d\<C-V>\rd", substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\\<C-V>\r", "")', '')) + call assert_equal("e\\\<C-V>\re", substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\\<C-V>\r", "")', '')) + call assert_equal("f\rf", substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '')) call assert_equal("j\nj", substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '')) call assert_equal("k\rk", substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '')) call assert_equal("l\nl", substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '')) diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 6e45a28e89..e723a30d32 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -87,6 +87,7 @@ Object ui_client_handle_redraw(uint64_t channel_id, Array args, Error *error) /// /// This is just a stub. the full version will handle input, resizing, etc void ui_client_execute(uint64_t chan) + FUNC_ATTR_NORETURN { while (true) { loop_poll_events(&main_loop, -1); diff --git a/src/nvim/window.c b/src/nvim/window.c index fb7878c2f4..fa71a08b94 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -836,7 +836,7 @@ void ui_ext_win_position(win_T *wp) FloatConfig c = wp->w_float_config; if (!c.external) { ScreenGrid *grid = &default_grid; - float row = c.row, col = c.col; + Float row = c.row, col = c.col; if (c.relative == kFloatRelativeWindow) { Error dummy = ERROR_INIT; win_T *win = find_window_by_handle(c.window, &dummy); diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua index 05d853622e..d3c0b4b938 100644 --- a/test/functional/legacy/eval_spec.lua +++ b/test/functional/legacy/eval_spec.lua @@ -46,7 +46,7 @@ describe('eval', function() command('AR "') command([[let @" = "abc\n"]]) source('AR "') - command([[let @" = "abc\<C-m>"]]) + command([[let @" = "abc\r"]]) command('AR "') command([[let @= = '"abc"']]) command('AR =') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 7000505909..f5ae228b1e 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -3,6 +3,7 @@ local clear, feed_command = helpers.clear, helpers.feed_command local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq local command = helpers.command local expect = helpers.expect +local curbuf_contents = helpers.curbuf_contents local meths = helpers.meths local exec_lua = helpers.exec_lua local write_file = helpers.write_file @@ -159,6 +160,50 @@ describe('input split utf sequences', function() end) end) +describe('input pairs', function() + describe('<tab> / <c-i>', function() + it('ok', function() + feed('i<tab><c-i><esc>') + eq('\t\t', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <tab> TAB!') + command('inoremap <c-i> CTRL-I!') + feed('i<tab><c-i><esc>') + eq('TAB!CTRL-I!', curbuf_contents()) + end) + end) + + describe('<cr> / <c-m>', function() + it('ok', function() + feed('iunos<c-m>dos<cr>tres<esc>') + eq('unos\ndos\ntres', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <c-m> SNIPPET!') + command('inoremap <cr> , and then<cr>') + feed('iunos<c-m>dos<cr>tres<esc>') + eq('unosSNIPPET!dos, and then\ntres', curbuf_contents()) + end) + end) + + describe('<esc> / <c-[>', function() + it('ok', function() + feed('2adouble<c-[>asingle<esc>') + eq('doubledoublesingle', curbuf_contents()) + end) + + it('can be mapped', function() + command('inoremap <c-[> HALLOJ!') + command('inoremap <esc> ,<esc>') + feed('2adubbel<c-[>upp<esc>') + eq('dubbelHALLOJ!upp,dubbelHALLOJ!upp,', curbuf_contents()) + end) + end) +end) + describe('input non-printable chars', function() after_each(function() os.remove('Xtest-overwrite') |