aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/charset.c14
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/digraph.c2
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/eval/userfunc.c2
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--src/nvim/ex_getln.c6
-rw-r--r--src/nvim/file_search.c735
-rw-r--r--src/nvim/fileio.c4
-rw-r--r--src/nvim/garray.c23
-rw-r--r--src/nvim/getchar.c729
-rw-r--r--src/nvim/hardcopy.c730
-rw-r--r--src/nvim/hashtab.c16
-rw-r--r--src/nvim/highlight.c132
-rw-r--r--src/nvim/indent.c23
-rw-r--r--src/nvim/keymap.c197
-rw-r--r--src/nvim/log.c25
-rw-r--r--src/nvim/lua/treesitter.c2
-rw-r--r--src/nvim/mbyte.c12
-rw-r--r--src/nvim/os/env.c2
-rw-r--r--src/nvim/os/signal.c2
-rw-r--r--src/nvim/syntax.c2
-rw-r--r--src/nvim/window.c4
26 files changed, 1417 insertions, 1267 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 1893bdba0c..2b5325a917 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2938,8 +2938,8 @@ buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum)
* Get alternate file name for current window.
* Return NULL if there isn't any, and give error message if requested.
*/
-char_u * getaltfname(bool errmsg // give error message
- )
+char_u *getaltfname(bool errmsg // give error message
+ )
{
char_u *fname;
linenr_T dummy;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 21e04128dc..0ad7dddd33 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -417,7 +417,7 @@ char *transstr(const char *const s)
///
/// When "buf" is NULL, return an allocated string.
/// Otherwise, put the result in buf, limited by buflen, and return buf.
-char_u * str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
+char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
FUNC_ATTR_NONNULL_RET
{
garray_T ga;
@@ -1209,7 +1209,7 @@ char_u *skipdigits(const char_u *q)
/// @param q pointer to string
///
/// @return Pointer to the character after the skipped digits.
-const char * skipbin(const char *q)
+const char *skipbin(const char *q)
FUNC_ATTR_PURE
FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET
@@ -1228,7 +1228,7 @@ const char * skipbin(const char *q)
///
/// @return Pointer to the character after the skipped digits and hex
/// characters.
-char_u * skiphex(char_u *q)
+char_u *skiphex(char_u *q)
{
char_u *p = q;
while (ascii_isxdigit(*p)) {
@@ -1243,7 +1243,7 @@ char_u * skiphex(char_u *q)
/// @param q
///
/// @return Pointer to the digit or (NUL after the string).
-char_u * skiptodigit(char_u *q)
+char_u *skiptodigit(char_u *q)
{
char_u *p = q;
while (*p != NUL && !ascii_isdigit(*p)) {
@@ -1258,7 +1258,7 @@ char_u * skiptodigit(char_u *q)
/// @param q pointer to string
///
/// @return Pointer to the binary character or (NUL after the string).
-const char * skiptobin(const char *q)
+const char *skiptobin(const char *q)
FUNC_ATTR_PURE
FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET
@@ -1276,7 +1276,7 @@ const char * skiptobin(const char *q)
/// @param q
///
/// @return Pointer to the hex character or (NUL after the string).
-char_u * skiptohex(char_u *q)
+char_u *skiptohex(char_u *q)
{
char_u *p = q;
while (*p != NUL && !ascii_isxdigit(*p)) {
@@ -1305,7 +1305,7 @@ char_u *skiptowhite(const char_u *p)
/// @param p
///
/// @return Pointer to the next whitespace character.
-char_u * skiptowhite_esc(char_u *p) {
+char_u *skiptowhite_esc(char_u *p) {
while (*p != ' ' && *p != '\t' && *p != NUL) {
if (((*p == '\\') || (*p == Ctrl_V)) && (*(p + 1) != NUL)) {
++p;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 62af6a6393..1d70145209 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -507,7 +507,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T
/// @param dp
///
/// @return The new diff block.
-static diff_T * diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
+static diff_T *diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
{
diff_T *dnew = xmalloc(sizeof(*dnew));
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index abca7cb905..b0fc4ee463 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1821,7 +1821,7 @@ typedef struct {
/// @return NULL if OK, an error message for failure. This only needs to be
/// used when setting the option, not later when the value has already
/// been checked.
-char_u * keymap_init(void)
+char_u *keymap_init(void)
{
curbuf->b_kmap_state &= ~KEYMAP_INIT;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index aeab1cdad4..20dc3cd06b 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3327,7 +3327,7 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
}
// Return Insert completion mode name string
-static char_u * ins_compl_mode(void)
+static char_u *ins_compl_mode(void)
{
if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || compl_started) {
return (char_u *)ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT];
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 1a9af639a3..ae64732eb9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6367,7 +6367,7 @@ int assert_match_common(typval_T *argvars, assert_type_T atype)
/// Find a window: When using a Window ID in any tab page, when using a number
/// in the current tab page.
-win_T * find_win_by_nr_or_id(typval_T *vp)
+win_T *find_win_by_nr_or_id(typval_T *vp)
{
int nr = (int)tv_get_number_chk(vp, NULL);
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index b17b462ed0..e7fb6ed504 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -803,7 +803,7 @@ buf_T *tv_get_buf_from_arg(typval_T *const tv) FUNC_ATTR_NONNULL_ALL
/// Get the buffer from "arg" and give an error and return NULL if it is not
/// valid.
-buf_T * get_buf_arg(typval_T *arg)
+buf_T *get_buf_arg(typval_T *arg)
{
buf_T *buf;
@@ -1081,7 +1081,7 @@ static void f_cindent(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
-static win_T * get_optional_window(typval_T *argvars, int idx)
+static win_T *get_optional_window(typval_T *argvars, int idx)
{
win_T *win = curwin;
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 2137804fdd..77297f9ffa 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -203,7 +203,7 @@ static void register_closure(ufunc_T *fp)
/// Get a name for a lambda. Returned in static memory.
-char_u * get_lambda_name(void)
+char_u *get_lambda_name(void)
{
static char_u name[30];
static int lambda_no = 0;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 1f11b6b9ef..68dd039278 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1030,7 +1030,7 @@ int getline_equal(LineGetter fgetline, void *cookie, LineGetter func)
/// getline function. Otherwise return "cookie".
///
/// @param cookie argument for fgetline()
-void * getline_cookie(LineGetter fgetline, void *cookie)
+void *getline_cookie(LineGetter fgetline, void *cookie)
{
LineGetter gp;
struct loop_cookie *cp;
@@ -1250,8 +1250,8 @@ static char_u *skip_colon_white(const char_u *p, bool skipleadingwhite)
/// This function may be called recursively!
///
/// @param cookie argument for fgetline()
-static char_u * do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGetter fgetline,
- void *cookie)
+static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGetter fgetline,
+ void *cookie)
{
char_u *p;
linenr_T lnum;
@@ -2905,7 +2905,7 @@ int cmd_exists(const char *const name)
/// probably won't change that much -- webb.
///
/// @param buff buffer for command string
-const char * set_one_cmd_context(expand_T *xp, const char *buff)
+const char *set_one_cmd_context(expand_T *xp, const char *buff)
{
size_t len = 0;
exarg_T ea;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 098a009728..ddf60eac18 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2401,7 +2401,7 @@ void text_locked_msg(void)
EMSG(_(get_text_locked_msg()));
}
-char_u * get_text_locked_msg(void) {
+char_u *get_text_locked_msg(void) {
if (cmdwin_type != 0) {
return e_cmdwin;
} else {
@@ -5218,8 +5218,8 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int
/// Call "user_expand_func()" to invoke a user defined Vim script function and
/// return the result (either a string, a List or NULL).
-static void * call_user_expand_func(user_expand_func_T user_expand_func, expand_T *xp,
- int *num_file, char_u ***file)
+static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T *xp, int *num_file,
+ char_u ***file)
FUNC_ATTR_NONNULL_ALL
{
char_u keep = 0;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 8beba38509..d364895ea4 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -44,50 +44,50 @@
// functions.
#include <assert.h>
-#include <string.h>
-#include <stdbool.h>
#include <inttypes.h>
#include <limits.h>
+#include <stdbool.h>
+#include <string.h>
-#include "nvim/vim.h"
-#include "nvim/eval.h"
#include "nvim/ascii.h"
-#include "nvim/file_search.h"
#include "nvim/charset.h"
+#include "nvim/eval.h"
+#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
+#include "nvim/os/fs_defs.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/os/os.h"
-#include "nvim/os/input.h"
-#include "nvim/os/fs_defs.h"
-static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
+static char_u *ff_expand_buffer = NULL; // used for expanding filenames
/*
* type for the directory search stack
*/
typedef struct ff_stack {
- struct ff_stack *ffs_prev;
+ struct ff_stack *ffs_prev;
/* the fix part (no wildcards) and the part containing the wildcards
* of the search path
*/
- char_u *ffs_fix_path;
- char_u *ffs_wc_path;
+ char_u *ffs_fix_path;
+ char_u *ffs_wc_path;
/* files/dirs found in the above directory, matched by the first wildcard
* of wc_part
*/
- char_u **ffs_filearray;
+ char_u **ffs_filearray;
int ffs_filearray_size;
- char_u ffs_filearray_cur; /* needed for partly handled dirs */
+ char_u ffs_filearray_cur; // needed for partly handled dirs
/* to store status of partly handled directories
* 0: we work on this directory for the first time
@@ -100,7 +100,7 @@ typedef struct ff_stack {
*/
int ffs_level;
- /* Did we already expand '**' to an empty string? */
+ // Did we already expand '**' to an empty string?
int ffs_star_star_empty;
} ff_stack_T;
@@ -108,19 +108,19 @@ typedef struct ff_stack {
* type for already visited directories or files.
*/
typedef struct ff_visited {
- struct ff_visited *ffv_next;
+ struct ff_visited *ffv_next;
/* Visited directories are different if the wildcard string are
* different. So we have to save it.
*/
- char_u *ffv_wc_path;
+ char_u *ffv_wc_path;
// use FileID for comparison (needed because of links), else use filename.
bool file_id_valid;
FileID file_id;
/* The memory for this struct is allocated according to the length of
* ffv_fname.
*/
- char_u ffv_fname[1]; /* actually longer */
+ char_u ffv_fname[1]; // actually longer
} ff_visited_T;
/*
@@ -138,13 +138,12 @@ typedef struct ff_visited {
* visited lists.
*/
typedef struct ff_visited_list_hdr {
- struct ff_visited_list_hdr *ffvl_next;
+ struct ff_visited_list_hdr *ffvl_next;
- /* the filename the attached visited list is for */
- char_u *ffvl_filename;
-
- ff_visited_T *ffvl_visited_list;
+ // the filename the attached visited list is for
+ char_u *ffvl_filename;
+ ff_visited_T *ffvl_visited_list;
} ff_visited_list_hdr_T;
@@ -156,38 +155,38 @@ typedef struct ff_visited_list_hdr {
/*
* The search context:
- * ffsc_stack_ptr: the stack for the dirs to search
+ * ffsc_stack_ptr: the stack for the dirs to search
* ffsc_visited_list: the currently active visited list
* ffsc_dir_visited_list: the currently active visited list for search dirs
* ffsc_visited_lists_list: the list of all visited lists
* ffsc_dir_visited_lists_list: the list of all visited lists for search dirs
* ffsc_file_to_search: the file to search for
- * ffsc_start_dir: the starting directory, if search path was relative
- * ffsc_fix_path: the fix part of the given path (without wildcards)
- * Needed for upward search.
- * ffsc_wc_path: the part of the given path containing wildcards
- * ffsc_level: how many levels of dirs to search downwards
- * ffsc_stopdirs_v: array of stop directories for upward search
- * ffsc_find_what: FINDFILE_BOTH, FINDFILE_DIR or FINDFILE_FILE
- * ffsc_tagfile: searching for tags file, don't use 'suffixesadd'
+ * ffsc_start_dir: the starting directory, if search path was relative
+ * ffsc_fix_path: the fix part of the given path (without wildcards)
+ * Needed for upward search.
+ * ffsc_wc_path: the part of the given path containing wildcards
+ * ffsc_level: how many levels of dirs to search downwards
+ * ffsc_stopdirs_v: array of stop directories for upward search
+ * ffsc_find_what: FINDFILE_BOTH, FINDFILE_DIR or FINDFILE_FILE
+ * ffsc_tagfile: searching for tags file, don't use 'suffixesadd'
*/
typedef struct ff_search_ctx_T {
- ff_stack_T *ffsc_stack_ptr;
- ff_visited_list_hdr_T *ffsc_visited_list;
- ff_visited_list_hdr_T *ffsc_dir_visited_list;
- ff_visited_list_hdr_T *ffsc_visited_lists_list;
- ff_visited_list_hdr_T *ffsc_dir_visited_lists_list;
- char_u *ffsc_file_to_search;
- char_u *ffsc_start_dir;
- char_u *ffsc_fix_path;
- char_u *ffsc_wc_path;
+ ff_stack_T *ffsc_stack_ptr;
+ ff_visited_list_hdr_T *ffsc_visited_list;
+ ff_visited_list_hdr_T *ffsc_dir_visited_list;
+ ff_visited_list_hdr_T *ffsc_visited_lists_list;
+ ff_visited_list_hdr_T *ffsc_dir_visited_lists_list;
+ char_u *ffsc_file_to_search;
+ char_u *ffsc_start_dir;
+ char_u *ffsc_fix_path;
+ char_u *ffsc_wc_path;
int ffsc_level;
- char_u **ffsc_stopdirs_v;
+ char_u **ffsc_stopdirs_v;
int ffsc_find_what;
int ffsc_tagfile;
} ff_search_ctx_T;
-/* locally needed functions */
+// locally needed functions
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "file_search.c.generated.h"
@@ -195,104 +194,98 @@ typedef struct ff_search_ctx_T {
static char_u e_pathtoolong[] = N_("E854: path too long for completion");
-/*
- * Initialization routine for vim_findfile().
- *
- * Returns the newly allocated search context or NULL if an error occurred.
- *
- * Don't forget to clean up by calling vim_findfile_cleanup() if you are done
- * with the search context.
- *
- * Find the file 'filename' in the directory 'path'.
- * The parameter 'path' may contain wildcards. If so only search 'level'
- * directories deep. The parameter 'level' is the absolute maximum and is
- * not related to restricts given to the '**' wildcard. If 'level' is 100
- * and you use '**200' vim_findfile() will stop after 100 levels.
- *
- * 'filename' cannot contain wildcards! It is used as-is, no backslashes to
- * escape special characters.
- *
- * If 'stopdirs' is not NULL and nothing is found downward, the search is
- * restarted on the next higher directory level. This is repeated until the
- * start-directory of a search is contained in 'stopdirs'. 'stopdirs' has the
- * format ";*<dirname>*\(;<dirname>\)*;\=$".
- *
- * If the 'path' is relative, the starting dir for the search is either VIM's
- * current dir or if the path starts with "./" the current files dir.
- * If the 'path' is absolute, the starting dir is that part of the path before
- * the first wildcard.
- *
- * Upward search is only done on the starting dir.
- *
- * If 'free_visited' is TRUE the list of already visited files/directories is
- * cleared. Set this to FALSE if you just want to search from another
- * directory, but want to be sure that no directory from a previous search is
- * searched again. This is useful if you search for a file at different places.
- * The list of visited files/dirs can also be cleared with the function
- * vim_findfile_free_visited().
- *
- * Set the parameter 'find_what' to FINDFILE_DIR if you want to search for
- * directories only, FINDFILE_FILE for files only, FINDFILE_BOTH for both.
- *
- * A search context returned by a previous call to vim_findfile_init() can be
- * passed in the parameter "search_ctx_arg". This context is reused and
- * reinitialized with the new parameters. The list of already visited
- * directories from this context is only deleted if the parameter
- * "free_visited" is true. Be aware that the passed "search_ctx_arg" is freed
- * if the reinitialization fails.
- *
- * If you don't have a search context from a previous call "search_ctx_arg"
- * must be NULL.
- *
- * This function silently ignores a few errors, vim_findfile() will have
- * limited functionality then.
- */
-void *
-vim_findfile_init (
- char_u *path,
- char_u *filename,
- char_u *stopdirs,
- int level,
- int free_visited,
- int find_what,
- void *search_ctx_arg,
- int tagfile, /* expanding names of tags files */
- char_u *rel_fname /* file name to use for "." */
-)
+/// Initialization routine for vim_findfile().
+///
+/// Returns the newly allocated search context or NULL if an error occurred.
+///
+/// Don't forget to clean up by calling vim_findfile_cleanup() if you are done
+/// with the search context.
+///
+/// Find the file 'filename' in the directory 'path'.
+/// The parameter 'path' may contain wildcards. If so only search 'level'
+/// directories deep. The parameter 'level' is the absolute maximum and is
+/// not related to restricts given to the '**' wildcard. If 'level' is 100
+/// and you use '**200' vim_findfile() will stop after 100 levels.
+///
+/// 'filename' cannot contain wildcards! It is used as-is, no backslashes to
+/// escape special characters.
+///
+/// If 'stopdirs' is not NULL and nothing is found downward, the search is
+/// restarted on the next higher directory level. This is repeated until the
+/// start-directory of a search is contained in 'stopdirs'. 'stopdirs' has the
+/// format ";*<dirname>*\(;<dirname>\)*;\=$".
+///
+/// If the 'path' is relative, the starting dir for the search is either VIM's
+/// current dir or if the path starts with "./" the current files dir.
+/// If the 'path' is absolute, the starting dir is that part of the path before
+/// the first wildcard.
+///
+/// Upward search is only done on the starting dir.
+///
+/// If 'free_visited' is TRUE the list of already visited files/directories is
+/// cleared. Set this to FALSE if you just want to search from another
+/// directory, but want to be sure that no directory from a previous search is
+/// searched again. This is useful if you search for a file at different places.
+/// The list of visited files/dirs can also be cleared with the function
+/// vim_findfile_free_visited().
+///
+/// Set the parameter 'find_what' to FINDFILE_DIR if you want to search for
+/// directories only, FINDFILE_FILE for files only, FINDFILE_BOTH for both.
+///
+/// A search context returned by a previous call to vim_findfile_init() can be
+/// passed in the parameter "search_ctx_arg". This context is reused and
+/// reinitialized with the new parameters. The list of already visited
+/// directories from this context is only deleted if the parameter
+/// "free_visited" is true. Be aware that the passed "search_ctx_arg" is freed
+/// if the reinitialization fails.
+///
+/// If you don't have a search context from a previous call "search_ctx_arg"
+/// must be NULL.
+///
+/// This function silently ignores a few errors, vim_findfile() will have
+/// limited functionality then.
+///
+/// @param tagfile expanding names of tags files
+/// @param rel_fname file name to use for "."
+void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int level,
+ int free_visited, int find_what, void *search_ctx_arg, int tagfile,
+ char_u *rel_fname)
{
- char_u *wc_part;
- ff_stack_T *sptr;
- ff_search_ctx_T *search_ctx;
+ char_u *wc_part;
+ ff_stack_T *sptr;
+ ff_search_ctx_T *search_ctx;
/* If a search context is given by the caller, reuse it, else allocate a
* new one.
*/
- if (search_ctx_arg != NULL)
+ if (search_ctx_arg != NULL) {
search_ctx = search_ctx_arg;
- else {
+ } else {
search_ctx = xcalloc(1, sizeof(ff_search_ctx_T));
}
search_ctx->ffsc_find_what = find_what;
search_ctx->ffsc_tagfile = tagfile;
- /* clear the search context, but NOT the visited lists */
+ // clear the search context, but NOT the visited lists
ff_clear(search_ctx);
- /* clear visited list if wanted */
- if (free_visited == TRUE)
+ // clear visited list if wanted
+ if (free_visited == TRUE) {
vim_findfile_free_visited(search_ctx);
- else {
+ } else {
/* Reuse old visited lists. Get the visited list for the given
* filename. If no list for the current filename exists, creates a new
* one. */
search_ctx->ffsc_visited_list = ff_get_visited_list(filename,
- &search_ctx->ffsc_visited_lists_list);
- if (search_ctx->ffsc_visited_list == NULL)
+ &search_ctx->ffsc_visited_lists_list);
+ if (search_ctx->ffsc_visited_list == NULL) {
goto error_return;
+ }
search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename,
- &search_ctx->ffsc_dir_visited_lists_list);
- if (search_ctx->ffsc_dir_visited_list == NULL)
+ &search_ctx->ffsc_dir_visited_lists_list);
+ if (search_ctx->ffsc_dir_visited_list == NULL) {
goto error_return;
+ }
}
if (ff_expand_buffer == NULL) {
@@ -308,16 +301,18 @@ vim_findfile_init (
size_t len = (size_t)(path_tail(rel_fname) - rel_fname);
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
- /* Make the start dir an absolute path name. */
+ // Make the start dir an absolute path name.
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
search_ctx->ffsc_start_dir = (char_u *)FullName_save((char *)ff_expand_buffer, FALSE);
- } else
+ } else {
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
- if (*++path != NUL)
+ }
+ if (*++path != NUL) {
++path;
+ }
} else if (*path == NUL || !vim_isAbsName(path)) {
#ifdef BACKSLASH_IN_FILENAME
- /* "c:dir" needs "c:" to be expanded, otherwise use current dir */
+ // "c:dir" needs "c:" to be expanded, otherwise use current dir
if (*path != NUL && path[1] == ':') {
char_u drive[3];
@@ -332,8 +327,9 @@ vim_findfile_init (
path += 2;
} else
#endif
- if (os_dirname(ff_expand_buffer, MAXPATHL) == FAIL)
+ if (os_dirname(ff_expand_buffer, MAXPATHL) == FAIL) {
goto error_return;
+ }
search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer);
@@ -342,8 +338,9 @@ vim_findfile_init (
* directory (but not for "//machine/dir"). Only use the drive name. */
if ((*path == '/' || *path == '\\')
&& path[1] != path[0]
- && search_ctx->ffsc_start_dir[1] == ':')
+ && search_ctx->ffsc_start_dir[1] == ':') {
search_ctx->ffsc_start_dir[2] = NUL;
+ }
#endif
}
@@ -357,21 +354,22 @@ vim_findfile_init (
* ff_path_in_stoplist() for details.
*/
if (stopdirs != NULL) {
- char_u *walker = stopdirs;
+ char_u *walker = stopdirs;
- while (*walker == ';')
+ while (*walker == ';') {
walker++;
+ }
size_t dircount = 1;
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
do {
- char_u *helper;
- void *ptr;
+ char_u *helper;
+ void *ptr;
helper = walker;
ptr = xrealloc(search_ctx->ffsc_stopdirs_v,
- (dircount + 1) * sizeof(char_u *));
+ (dircount + 1) * sizeof(char_u *));
search_ctx->ffsc_stopdirs_v = ptr;
walker = vim_strchr(walker, ';');
if (walker) {
@@ -379,15 +377,15 @@ vim_findfile_init (
search_ctx->ffsc_stopdirs_v[dircount-1] =
vim_strnsave(helper, (size_t)(walker - helper));
walker++;
- } else
+ } else {
/* this might be "", which means ascent till top
* of directory tree.
*/
search_ctx->ffsc_stopdirs_v[dircount-1] =
vim_strsave(helper);
+ }
dircount++;
-
} while (walker != NULL);
search_ctx->ffsc_stopdirs_v[dircount-1] = NULL;
}
@@ -402,9 +400,9 @@ vim_findfile_init (
if (wc_part != NULL) {
int64_t llevel;
int len;
- char *errpt;
+ char *errpt;
- /* save the fix part of the path */
+ // save the fix part of the path
assert(wc_part - path >= 0);
search_ctx->ffsc_fix_path = vim_strnsave(path, (size_t)(wc_part - path));
@@ -428,27 +426,30 @@ vim_findfile_init (
ff_expand_buffer[len++] = *wc_part++;
llevel = strtol((char *)wc_part, &errpt, 10);
- if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255)
+ if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) {
ff_expand_buffer[len++] = (char_u)llevel;
- else if ((char_u *)errpt != wc_part && llevel == 0)
- /* restrict is 0 -> remove already added '**' */
+ } else if ((char_u *)errpt != wc_part && llevel == 0) {
+ // restrict is 0 -> remove already added '**'
len -= 2;
- else
+ } else {
ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND;
+ }
wc_part = (char_u *)errpt;
if (*wc_part != NUL && !vim_ispathsep(*wc_part)) {
EMSG2(_(
- "E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."),
- PATHSEPSTR);
+ "E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."),
+ PATHSEPSTR);
goto error_return;
}
- } else
+ } else {
ff_expand_buffer[len++] = *wc_part++;
+ }
}
ff_expand_buffer[len] = NUL;
search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer);
- } else
+ } else {
search_ctx->ffsc_fix_path = vim_strsave(path);
+ }
if (search_ctx->ffsc_start_dir == NULL) {
/* store the fix part as startdir.
@@ -458,7 +459,7 @@ vim_findfile_init (
search_ctx->ffsc_fix_path[0] = NUL;
}
- /* create an absolute path */
+ // create an absolute path
if (STRLEN(search_ctx->ffsc_start_dir)
+ STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) {
EMSG(_(e_pathtoolong));
@@ -505,8 +506,8 @@ vim_findfile_init (
}
sptr = ff_create_stack_element(ff_expand_buffer,
- search_ctx->ffsc_wc_path,
- level, 0);
+ search_ctx->ffsc_wc_path,
+ level, 0);
ff_push(search_ctx, sptr);
search_ctx->ffsc_file_to_search = vim_strsave(filename);
@@ -527,7 +528,7 @@ error_return:
*/
char_u *vim_findfile_stopdir(char_u *buf)
{
- char_u *r_ptr = buf;
+ char_u *r_ptr = buf;
while (*r_ptr != NUL && *r_ptr != ';') {
if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
@@ -541,8 +542,9 @@ char_u *vim_findfile_stopdir(char_u *buf)
if (*r_ptr == ';') {
*r_ptr = 0;
r_ptr++;
- } else if (*r_ptr == NUL)
+ } else if (*r_ptr == NUL) {
r_ptr = NULL;
+ }
return r_ptr;
}
@@ -551,8 +553,9 @@ char_u *vim_findfile_stopdir(char_u *buf)
*/
void vim_findfile_cleanup(void *ctx)
{
- if (ctx == NULL)
+ if (ctx == NULL) {
return;
+ }
vim_findfile_free_visited(ctx);
ff_clear(ctx);
@@ -573,17 +576,18 @@ void vim_findfile_cleanup(void *ctx)
*/
char_u *vim_findfile(void *search_ctx_arg)
{
- char_u *file_path;
- char_u *rest_of_wildcards;
- char_u *path_end = NULL;
- ff_stack_T *stackp = NULL;
+ char_u *file_path;
+ char_u *rest_of_wildcards;
+ char_u *path_end = NULL;
+ ff_stack_T *stackp = NULL;
size_t len;
- char_u *p;
- char_u *suf;
+ char_u *p;
+ char_u *suf;
ff_search_ctx_T *search_ctx;
- if (search_ctx_arg == NULL)
+ if (search_ctx_arg == NULL) {
return NULL;
+ }
search_ctx = (ff_search_ctx_T *)search_ctx_arg;
@@ -593,24 +597,27 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
file_path = xmalloc(MAXPATHL);
- /* store the end of the start dir -- needed for upward search */
- if (search_ctx->ffsc_start_dir != NULL)
+ // store the end of the start dir -- needed for upward search
+ if (search_ctx->ffsc_start_dir != NULL) {
path_end = &search_ctx->ffsc_start_dir[
- STRLEN(search_ctx->ffsc_start_dir)];
+ STRLEN(search_ctx->ffsc_start_dir)];
+ }
- /* upward search loop */
+ // upward search loop
for (;; ) {
- /* downward search loop */
+ // downward search loop
for (;; ) {
- /* check if user user wants to stop the search*/
+ // check if user user wants to stop the search
os_breakcheck();
- if (got_int)
+ if (got_int) {
break;
+ }
- /* get directory to work on from stack */
+ // get directory to work on from stack
stackp = ff_pop(search_ctx);
- if (stackp == NULL)
+ if (stackp == NULL) {
break;
+ }
/*
* TODO: decide if we leave this test in
@@ -633,10 +640,10 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
if (stackp->ffs_filearray == NULL
&& ff_check_visited(&search_ctx->ffsc_dir_visited_list
- ->ffvl_visited_list,
- stackp->ffs_fix_path
- , stackp->ffs_wc_path
- ) == FAIL) {
+ ->ffvl_visited_list,
+ stackp->ffs_fix_path
+ , stackp->ffs_wc_path
+ ) == FAIL) {
#ifdef FF_VERBOSE
if (p_verbose >= 5) {
verbose_enter_scroll();
@@ -659,7 +666,7 @@ char_u *vim_findfile(void *search_ctx_arg)
}
#endif
- /* check depth */
+ // check depth
if (stackp->ffs_level <= 0) {
ff_free_stack_element(stackp);
continue;
@@ -725,13 +732,14 @@ char_u *vim_findfile(void *search_ctx_arg)
}
if (*p == 0) {
- /* remove '**<numb> from wildcards */
+ // remove '**<numb> from wildcards
STRMOVE(rest_of_wildcards, rest_of_wildcards + 3);
- } else
+ } else {
rest_of_wildcards += 3;
+ }
if (stackp->ffs_star_star_empty == 0) {
- /* if not done before, expand '**' to empty */
+ // if not done before, expand '**' to empty
stackp->ffs_star_star_empty = 1;
dirptrs[1] = stackp->ffs_fix_path;
}
@@ -754,8 +762,9 @@ char_u *vim_findfile(void *search_ctx_arg)
}
file_path[len] = NUL;
- if (vim_ispathsep(*rest_of_wildcards))
+ if (vim_ispathsep(*rest_of_wildcards)) {
rest_of_wildcards++;
+ }
}
/*
@@ -766,23 +775,25 @@ char_u *vim_findfile(void *search_ctx_arg)
stackp->ffs_filearray = xmalloc(sizeof(char *));
stackp->ffs_filearray[0] = vim_strsave(dirptrs[0]);
stackp->ffs_filearray_size = 1;
- } else
+ } else {
/* Add EW_NOTWILD because the expanded path may contain
* wildcard characters that are to be taken literally.
* This is a bit of a hack. */
expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs,
- &stackp->ffs_filearray_size,
- &stackp->ffs_filearray,
- EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD);
+ &stackp->ffs_filearray_size,
+ &stackp->ffs_filearray,
+ EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD);
+ }
stackp->ffs_filearray_cur = 0;
stackp->ffs_stage = 0;
- } else
+ } else {
rest_of_wildcards = &stackp->ffs_wc_path[
- STRLEN(stackp->ffs_wc_path)];
+ STRLEN(stackp->ffs_wc_path)];
+ }
if (stackp->ffs_stage == 0) {
- /* this is the first time we work on this directory */
+ // this is the first time we work on this directory
if (*rest_of_wildcards == NUL) {
/*
* We don't have further wildcards to expand, so we have to
@@ -791,9 +802,9 @@ char_u *vim_findfile(void *search_ctx_arg)
for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
if (!path_with_url((char *)stackp->ffs_filearray[i])
- && !os_isdir(stackp->ffs_filearray[i]))
- continue; /* not a directory */
-
+ && !os_isdir(stackp->ffs_filearray[i])) {
+ continue; // not a directory
+ }
// prepare the filename to be checked for existence below
if (STRLEN(stackp->ffs_filearray[i]) + 1
+ STRLEN(search_ctx->ffsc_file_to_search) >= MAXPATHL) {
@@ -812,12 +823,13 @@ char_u *vim_findfile(void *search_ctx_arg)
* from 'suffixesadd'.
*/
len = STRLEN(file_path);
- if (search_ctx->ffsc_tagfile)
+ if (search_ctx->ffsc_tagfile) {
suf = (char_u *)"";
- else
+ } else {
suf = curbuf->b_p_sua;
+ }
for (;; ) {
- /* if file exists and we didn't already find it */
+ // if file exists and we didn't already find it
if ((path_with_url((char *)file_path)
|| (os_path_exists(file_path)
&& (search_ctx->ffsc_find_what
@@ -826,19 +838,17 @@ char_u *vim_findfile(void *search_ctx_arg)
== FINDFILE_DIR)
== os_isdir(file_path)))))
#ifndef FF_VERBOSE
- && (ff_check_visited(
- &search_ctx->ffsc_visited_list->ffvl_visited_list,
- file_path
- , (char_u *)""
- ) == OK)
+ && (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list,
+ file_path
+ , (char_u *)""
+ ) == OK)
#endif
) {
#ifdef FF_VERBOSE
- if (ff_check_visited(
- &search_ctx->ffsc_visited_list->ffvl_visited_list,
- file_path
- , (char_u *)""
- ) == FAIL) {
+ if (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list,
+ file_path
+ , (char_u *)""
+ ) == FAIL) {
if (p_verbose >= 5) {
verbose_enter_scroll();
smsg("Already: %s", file_path);
@@ -849,19 +859,21 @@ char_u *vim_findfile(void *search_ctx_arg)
}
#endif
- /* push dir to examine rest of subdirs later */
+ // push dir to examine rest of subdirs later
assert(i < UCHAR_MAX - 1);
stackp->ffs_filearray_cur = (char_u)(i + 1);
ff_push(search_ctx, stackp);
- if (!path_with_url((char *)file_path))
+ if (!path_with_url((char *)file_path)) {
simplify_filename(file_path);
+ }
if (os_dirname(ff_expand_buffer, MAXPATHL)
== OK) {
p = path_shorten_fname(file_path,
- ff_expand_buffer);
- if (p != NULL)
+ ff_expand_buffer);
+ if (p != NULL) {
STRMOVE(file_path, p);
+ }
}
#ifdef FF_VERBOSE
if (p_verbose >= 5) {
@@ -874,12 +886,13 @@ char_u *vim_findfile(void *search_ctx_arg)
return file_path;
}
- /* Not found or found already, try next suffix. */
- if (*suf == NUL)
+ // Not found or found already, try next suffix.
+ if (*suf == NUL) {
break;
+ }
assert(MAXPATHL >= len);
copy_option_part(&suf, file_path + len,
- MAXPATHL - len, ",");
+ MAXPATHL - len, ",");
}
}
} else {
@@ -889,14 +902,13 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
- if (!os_isdir(stackp->ffs_filearray[i]))
- continue; /* not a directory */
-
+ if (!os_isdir(stackp->ffs_filearray[i])) {
+ continue; // not a directory
+ }
ff_push(search_ctx,
- ff_create_stack_element(
- stackp->ffs_filearray[i],
- rest_of_wildcards,
- stackp->ffs_level - 1, 0));
+ ff_create_stack_element(stackp->ffs_filearray[i],
+ rest_of_wildcards,
+ stackp->ffs_level - 1, 0));
}
}
stackp->ffs_filearray_cur = 0;
@@ -911,19 +923,20 @@ char_u *vim_findfile(void *search_ctx_arg)
for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
if (fnamecmp(stackp->ffs_filearray[i],
- stackp->ffs_fix_path) == 0)
- continue; /* don't repush same directory */
- if (!os_isdir(stackp->ffs_filearray[i]))
- continue; /* not a directory */
+ stackp->ffs_fix_path) == 0) {
+ continue; // don't repush same directory
+ }
+ if (!os_isdir(stackp->ffs_filearray[i])) {
+ continue; // not a directory
+ }
ff_push(search_ctx,
- ff_create_stack_element(stackp->ffs_filearray[i],
- stackp->ffs_wc_path, stackp->ffs_level - 1, 1));
+ ff_create_stack_element(stackp->ffs_filearray[i],
+ stackp->ffs_wc_path, stackp->ffs_level - 1, 1));
}
}
- /* we are done with the current directory */
+ // we are done with the current directory
ff_free_stack_element(stackp);
-
}
/* If we reached this, we didn't find anything downwards.
@@ -931,26 +944,30 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
if (search_ctx->ffsc_start_dir
&& search_ctx->ffsc_stopdirs_v != NULL && !got_int) {
- ff_stack_T *sptr;
+ ff_stack_T *sptr;
- /* is the last starting directory in the stop list? */
+ // is the last starting directory in the stop list?
if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
- (int)(path_end - search_ctx->ffsc_start_dir),
- search_ctx->ffsc_stopdirs_v) == TRUE)
+ (int)(path_end - search_ctx->ffsc_start_dir),
+ search_ctx->ffsc_stopdirs_v) == TRUE) {
break;
+ }
- /* cut of last dir */
+ // cut of last dir
while (path_end > search_ctx->ffsc_start_dir
- && vim_ispathsep(*path_end))
+ && vim_ispathsep(*path_end)) {
path_end--;
+ }
while (path_end > search_ctx->ffsc_start_dir
- && !vim_ispathsep(path_end[-1]))
+ && !vim_ispathsep(path_end[-1])) {
path_end--;
+ }
*path_end = 0;
path_end--;
- if (*search_ctx->ffsc_start_dir == 0)
+ if (*search_ctx->ffsc_start_dir == 0) {
break;
+ }
if (STRLEN(search_ctx->ffsc_start_dir) + 1
+ STRLEN(search_ctx->ffsc_fix_path) >= MAXPATHL) {
@@ -962,12 +979,13 @@ char_u *vim_findfile(void *search_ctx_arg)
}
STRCAT(file_path, search_ctx->ffsc_fix_path);
- /* create a new stack entry */
+ // create a new stack entry
sptr = ff_create_stack_element(file_path,
- search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0);
+ search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0);
ff_push(search_ctx, sptr);
- } else
+ } else {
break;
+ }
}
fail:
@@ -983,8 +1001,9 @@ void vim_findfile_free_visited(void *search_ctx_arg)
{
ff_search_ctx_T *search_ctx;
- if (search_ctx_arg == NULL)
+ if (search_ctx_arg == NULL) {
return;
+ }
search_ctx = (ff_search_ctx_T *)search_ctx_arg;
vim_findfile_free_visited_list(&search_ctx->ffsc_visited_lists_list);
@@ -1023,11 +1042,12 @@ static void ff_free_visited_list(ff_visited_T *vl)
* Returns 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)
+static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename,
+ ff_visited_list_hdr_T **list_headp)
{
- ff_visited_list_hdr_T *retptr = NULL;
+ ff_visited_list_hdr_T *retptr = NULL;
- /* check if a visited list for the given filename exists */
+ // check if a visited list for the given filename exists
if (*list_headp != NULL) {
retptr = *list_headp;
while (retptr != NULL) {
@@ -1115,7 +1135,7 @@ static bool ff_wc_equal(char_u *s1, char_u *s2)
*/
static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *wc_path)
{
- ff_visited_T *vp;
+ ff_visited_T *vp;
bool url = false;
FileID file_id;
@@ -1131,7 +1151,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
}
}
- /* check against list of already visited files */
+ // check against list of already visited files
for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) {
if ((url && fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0)
|| (!url && vp->file_id_valid
@@ -1158,10 +1178,11 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
STRCPY(vp->ffv_fname, ff_expand_buffer);
}
- if (wc_path != NULL)
+ if (wc_path != NULL) {
vp->ffv_wc_path = vim_strsave(wc_path);
- else
+ } else {
vp->ffv_wc_path = NULL;
+ }
vp->ffv_next = *visited_list;
*visited_list = vp;
@@ -1172,7 +1193,8 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
/*
* 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)
+static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, int level,
+ int star_star_empty)
{
ff_stack_T *new = xmalloc(sizeof(ff_stack_T));
@@ -1184,13 +1206,15 @@ static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, in
new->ffs_level = level;
new->ffs_star_star_empty = star_star_empty;
- /* the following saves NULL pointer checks in vim_findfile */
- if (fix_part == NULL)
+ // the following saves NULL pointer checks in vim_findfile
+ if (fix_part == NULL) {
fix_part = (char_u *)"";
+ }
new->ffs_fix_path = vim_strsave(fix_part);
- if (wc_part == NULL)
+ if (wc_part == NULL) {
wc_part = (char_u *)"";
+ }
new->ffs_wc_path = vim_strsave(wc_part);
return new;
@@ -1215,11 +1239,12 @@ static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr)
*/
static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx)
{
- ff_stack_T *sptr;
+ ff_stack_T *sptr;
sptr = search_ctx->ffsc_stack_ptr;
- if (search_ctx->ffsc_stack_ptr != NULL)
+ if (search_ctx->ffsc_stack_ptr != NULL) {
search_ctx->ffsc_stack_ptr = search_ctx->ffsc_stack_ptr->ffs_prev;
+ }
return sptr;
}
@@ -1249,11 +1274,12 @@ static void ff_free_stack_element(ff_stack_T *const stack_ptr)
*/
static void ff_clear(ff_search_ctx_T *search_ctx)
{
- ff_stack_T *sptr;
+ ff_stack_T *sptr;
- /* clear up stack */
- while ((sptr = ff_pop(search_ctx)) != NULL)
+ // clear up stack
+ while ((sptr = ff_pop(search_ctx)) != NULL) {
ff_free_stack_element(sptr);
+ }
xfree(search_ctx->ffsc_file_to_search);
xfree(search_ctx->ffsc_start_dir);
@@ -1271,7 +1297,7 @@ static void ff_clear(ff_search_ctx_T *search_ctx)
}
search_ctx->ffsc_stopdirs_v = NULL;
- /* reset everything */
+ // reset everything
search_ctx->ffsc_file_to_search = NULL;
search_ctx->ffsc_start_dir = NULL;
search_ctx->ffsc_fix_path = NULL;
@@ -1287,13 +1313,15 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
{
int i = 0;
- /* eat up trailing path separators, except the first */
- while (path_len > 1 && vim_ispathsep(path[path_len - 1]))
+ // eat up trailing path separators, except the first
+ while (path_len > 1 && vim_ispathsep(path[path_len - 1])) {
path_len--;
+ }
- /* if no path consider it as match */
- if (path_len == 0)
+ // if no path consider it as match
+ if (path_len == 0) {
return TRUE;
+ }
for (i = 0; stopdirs_v[i] != NULL; i++) {
if ((int)STRLEN(stopdirs_v[i]) > path_len) {
@@ -1302,49 +1330,46 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
* '/home/r' would also match '/home/rks'
*/
if (fnamencmp(stopdirs_v[i], path, path_len) == 0
- && vim_ispathsep(stopdirs_v[i][path_len]))
+ && vim_ispathsep(stopdirs_v[i][path_len])) {
return TRUE;
+ }
} else {
- if (fnamecmp(stopdirs_v[i], path) == 0)
+ if (fnamecmp(stopdirs_v[i], path) == 0) {
return TRUE;
+ }
}
}
return FALSE;
}
-/*
- * Find the file name "ptr[len]" in the path. Also finds directory names.
- *
- * On the first call set the parameter 'first' to TRUE to initialize
- * the search. For repeating calls to FALSE.
- *
- * Repeating calls will return other files called 'ptr[len]' from the path.
- *
- * Only on the first call 'ptr' and 'len' are used. For repeating calls they
- * don't need valid values.
- *
- * If nothing found on the first call the option FNAME_MESS will issue the
- * message:
- * 'Can't find file "<file>" in path'
- * On repeating calls:
- * 'No more file "<file>" found in path'
- *
- * options:
- * FNAME_MESS give error message when not found
- *
- * Uses NameBuff[]!
- *
- * Returns an allocated string for the file name. NULL for error.
- *
- */
-char_u *
-find_file_in_path (
- char_u *ptr, /* file name */
- size_t len, /* length of file name */
- int options,
- int first, /* use count'th matching file name */
- char_u *rel_fname /* file name searching relative to */
-)
+/// Find the file name "ptr[len]" in the path. Also finds directory names.
+///
+/// On the first call set the parameter 'first' to TRUE to initialize
+/// the search. For repeating calls to FALSE.
+///
+/// Repeating calls will return other files called 'ptr[len]' from the path.
+///
+/// Only on the first call 'ptr' and 'len' are used. For repeating calls they
+/// don't need valid values.
+///
+/// If nothing found on the first call the option FNAME_MESS will issue the
+/// message:
+/// 'Can't find file "<file>" in path'
+/// On repeating calls:
+/// 'No more file "<file>" found in path'
+///
+/// options:
+/// FNAME_MESS give error message when not found
+///
+/// Uses NameBuff[]!
+///
+/// @param ptr file name
+/// @param len length of file name
+/// @param first use count'th matching file name
+/// @param rel_fname file name searching relative to
+///
+/// @return an allocated string for the file name. NULL for error.
+char_u *find_file_in_path(char_u *ptr, size_t len, int options, int first, char_u *rel_fname)
{
return find_file_in_path_option(ptr, len, options, first,
(*curbuf->b_p_path == NUL
@@ -1353,8 +1378,8 @@ find_file_in_path (
FINDFILE_BOTH, rel_fname, curbuf->b_p_sua);
}
-static char_u *ff_file_to_find = NULL;
-static void *fdip_search_ctx = NULL;
+static char_u *ff_file_to_find = NULL;
+static void *fdip_search_ctx = NULL;
#if defined(EXITFREE)
void free_findfile(void)
@@ -1366,46 +1391,41 @@ void free_findfile(void)
#endif
-/*
- * Find the directory name "ptr[len]" in the path.
- *
- * options:
- * FNAME_MESS give error message when not found
- * FNAME_UNESC unescape backslashes
- *
- * Uses NameBuff[]!
- *
- * Returns an allocated string for the file name. NULL for error.
- */
-char_u *
-find_directory_in_path (
- char_u *ptr, /* file name */
- size_t len, /* length of file name */
- int options,
- char_u *rel_fname /* file name searching relative to */
-)
+/// Find the directory name "ptr[len]" in the path.
+///
+/// options:
+/// FNAME_MESS give error message when not found
+/// FNAME_UNESC unescape backslashes
+///
+/// Uses NameBuff[]!
+///
+/// @param ptr file name
+/// @param len length of file name
+/// @param rel_fname file name searching relative to
+///
+/// @return an allocated string for the file name. NULL for error.
+char_u *find_directory_in_path(char_u *ptr, size_t len, int options, char_u *rel_fname)
{
return find_file_in_path_option(ptr, len, options, TRUE, p_cdpath,
FINDFILE_DIR, rel_fname, (char_u *)"");
}
-char_u *
-find_file_in_path_option (
- char_u *ptr, /* file name */
- size_t len, /* length of file name */
- int options,
- int first, /* use count'th matching file name */
- char_u *path_option, /* p_path or p_cdpath */
- int find_what, /* FINDFILE_FILE, _DIR or _BOTH */
- char_u *rel_fname, /* file name we are looking relative to. */
- char_u *suffixes /* list of suffixes, 'suffixesadd' option */
-)
+/// @param ptr file name
+/// @param len length of file name
+/// @param first use count'th matching file name
+/// @param path_option p_path or p_cdpath
+/// @param find_what FINDFILE_FILE, _DIR or _BOTH
+/// @param rel_fname file name we are looking relative to.
+/// @param suffixes list of suffixes, 'suffixesadd' option
+char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first,
+ char_u *path_option, int find_what, char_u *rel_fname,
+ char_u *suffixes)
{
- static char_u *dir;
+ static char_u *dir;
static int did_findfile_init = FALSE;
char_u save_char;
- char_u *file_name = NULL;
- char_u *buf = NULL;
+ char_u *file_name = NULL;
+ char_u *buf = NULL;
int rel_to_curdir;
if (rel_fname != NULL && path_with_url((const char *)rel_fname)) {
@@ -1414,7 +1434,7 @@ find_file_in_path_option (
}
if (first == TRUE) {
- /* copy file name into NameBuff, expanding environment variables */
+ // copy file name into NameBuff, expanding environment variables
save_char = ptr[len];
ptr[len] = NUL;
expand_env_esc(ptr, NameBuff, MAXPATHL, false, true, NULL);
@@ -1485,11 +1505,12 @@ find_file_in_path_option (
&& (find_what == FINDFILE_BOTH
|| ((find_what == FINDFILE_DIR)
== os_isdir(NameBuff))))) {
- file_name = vim_strsave(NameBuff);
- goto theend;
+ file_name = vim_strsave(NameBuff);
+ goto theend;
}
- if (*buf == NUL)
+ if (*buf == NUL) {
break;
+ }
assert(MAXPATHL >= l);
copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ",");
}
@@ -1502,7 +1523,7 @@ find_file_in_path_option (
* Otherwise continue to find the next match.
*/
if (first == TRUE) {
- /* vim_findfile_free_visited can handle a possible NULL pointer */
+ // vim_findfile_free_visited can handle a possible NULL pointer
vim_findfile_free_visited(fdip_search_ctx);
dir = path_option;
did_findfile_init = FALSE;
@@ -1511,12 +1532,13 @@ find_file_in_path_option (
for (;; ) {
if (did_findfile_init) {
file_name = vim_findfile(fdip_search_ctx);
- if (file_name != NULL)
+ if (file_name != NULL) {
break;
+ }
did_findfile_init = FALSE;
} else {
- char_u *r_ptr;
+ char_u *r_ptr;
if (dir == NULL || *dir == NUL) {
/* We searched all paths of the option, now we can
@@ -1528,36 +1550,39 @@ find_file_in_path_option (
buf = xmalloc(MAXPATHL);
- /* copy next path */
+ // copy next path
buf[0] = 0;
copy_option_part(&dir, buf, MAXPATHL, " ,");
- /* get the stopdir string */
+ // get the stopdir string
r_ptr = vim_findfile_stopdir(buf);
fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
- r_ptr, 100, FALSE, find_what,
- fdip_search_ctx, FALSE, rel_fname);
- if (fdip_search_ctx != NULL)
+ r_ptr, 100, FALSE, find_what,
+ fdip_search_ctx, FALSE, rel_fname);
+ if (fdip_search_ctx != NULL) {
did_findfile_init = TRUE;
+ }
xfree(buf);
}
}
}
if (file_name == NULL && (options & FNAME_MESS)) {
if (first == TRUE) {
- if (find_what == FINDFILE_DIR)
+ if (find_what == FINDFILE_DIR) {
EMSG2(_("E344: Can't find directory \"%s\" in cdpath"),
- ff_file_to_find);
- else
+ ff_file_to_find);
+ } else {
EMSG2(_("E345: Can't find file \"%s\" in path"),
- ff_file_to_find);
+ ff_file_to_find);
+ }
} else {
- if (find_what == FINDFILE_DIR)
+ if (find_what == FINDFILE_DIR) {
EMSG2(_("E346: No more directory \"%s\" found in cdpath"),
- ff_file_to_find);
- else
+ ff_file_to_find);
+ } else {
EMSG2(_("E347: No more file \"%s\" found in path"),
- ff_file_to_find);
+ ff_file_to_find);
+ }
}
}
@@ -1581,22 +1606,18 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, bool changed_window)
char buf[8];
switch (scope) {
- case kCdScopeGlobal: {
- snprintf(buf, sizeof(buf), "global");
- break;
- }
- case kCdScopeTab: {
- snprintf(buf, sizeof(buf), "tab");
- break;
- }
- case kCdScopeWindow: {
- snprintf(buf, sizeof(buf), "window");
- break;
- }
- case kCdScopeInvalid: {
- // Should never happen.
- abort();
- }
+ case kCdScopeGlobal:
+ snprintf(buf, sizeof(buf), "global");
+ break;
+ case kCdScopeTab:
+ snprintf(buf, sizeof(buf), "tab");
+ break;
+ case kCdScopeWindow:
+ snprintf(buf, sizeof(buf), "window");
+ break;
+ case kCdScopeInvalid:
+ // Should never happen.
+ abort();
}
tv_dict_add_str(dict, S_LEN("scope"), buf); // -V614
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index b7dbda3d99..31af47999b 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5538,8 +5538,8 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname)
/// @param no_bslash Don't use a backward slash as pathsep
///
/// @return NULL on failure.
-char_u * file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allow_dirs,
- int no_bslash)
+char_u *file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allow_dirs,
+ int no_bslash)
FUNC_ATTR_NONNULL_ARG(1)
{
const char_u *endp;
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index 1cfc2b6176..bc3b7211c9 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -5,16 +5,16 @@
///
/// Functions for handling growing arrays.
-#include <string.h>
#include <inttypes.h>
+#include <string.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
+#include "nvim/garray.h"
#include "nvim/log.h"
#include "nvim/memory.h"
#include "nvim/path.h"
-#include "nvim/garray.h"
#include "nvim/strings.h"
+#include "nvim/vim.h"
// #include "nvim/globals.h"
#include "nvim/memline.h"
@@ -146,11 +146,11 @@ void ga_remove_duplicate_strings(garray_T *gap)
char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
FUNC_ATTR_NONNULL_RET
{
- const size_t nelem = (size_t) gap->ga_len;
+ const size_t nelem = (size_t)gap->ga_len;
const char **strings = gap->ga_data;
if (nelem == 0) {
- return (char_u *) xstrdup("");
+ return (char_u *)xstrdup("");
}
size_t len = 0;
@@ -169,7 +169,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
}
strcpy(s, strings[nelem - 1]);
- return (char_u *) ret;
+ return (char_u *)ret;
}
/// For a growing array that contains a list of strings: concatenate all the
@@ -178,7 +178,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
/// @param gap
///
/// @returns the concatenated strings
-char_u* ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
+char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
{
return ga_concat_strings_sep(gap, ",");
}
@@ -198,7 +198,7 @@ void ga_concat(garray_T *gap, const char_u *restrict s)
return;
}
- ga_concat_len(gap, (const char *restrict) s, strlen((char *) s));
+ ga_concat_len(gap, (const char *restrict)s, strlen((char *)s));
}
/// Concatenate a string to a growarray which contains characters
@@ -206,15 +206,14 @@ void ga_concat(garray_T *gap, const char_u *restrict s)
/// @param[out] gap Growarray to modify.
/// @param[in] s String to concatenate.
/// @param[in] len String length.
-void ga_concat_len(garray_T *const gap, const char *restrict s,
- const size_t len)
+void ga_concat_len(garray_T *const gap, const char *restrict s, const size_t len)
FUNC_ATTR_NONNULL_ALL
{
if (len) {
- ga_grow(gap, (int) len);
+ ga_grow(gap, (int)len);
char *data = gap->ga_data;
memcpy(data + gap->ga_len, s, len);
- gap->ga_len += (int) len;
+ gap->ga_len += (int)len;
}
}
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 3bf9d92696..beb4ff4da6 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -11,22 +11,25 @@
*/
#include <assert.h>
+#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
-#include <inttypes.h>
-#include "nvim/assert.h"
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/getchar.h"
+#include "nvim/assert.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
+#include "nvim/event/loop.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
+#include "nvim/ex_session.h"
#include "nvim/func_attr.h"
+#include "nvim/garray.h"
+#include "nvim/getchar.h"
+#include "nvim/keymap.h"
#include "nvim/lua/executor.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -34,24 +37,21 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/plines.h"
-#include "nvim/keymap.h"
-#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/os/fileio.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
+#include "nvim/plines.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
-#include "nvim/ex_session.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
-#include "nvim/event/loop.h"
-#include "nvim/os/input.h"
-#include "nvim/os/os.h"
-#include "nvim/os/fileio.h"
+#include "nvim/vim.h"
/// Index in scriptin
@@ -163,7 +163,7 @@ static size_t last_recorded_len = 0; // number of last recorded chars
*/
void free_buff(buffheader_T *buf)
{
- buffblock_T *p, *np;
+ buffblock_T *p, *np;
for (p = buf->bh_first.b_next; p != NULL; p = np) {
np = p->b_next;
@@ -172,17 +172,15 @@ void free_buff(buffheader_T *buf)
buf->bh_first.b_next = NULL;
}
-/*
- * Return the contents of a buffer as a single string.
- * K_SPECIAL and CSI in the returned string are escaped.
- */
-static char_u *get_buffcont(buffheader_T *buffer,
- int dozero // count == zero is not an error
- )
+/// Return the contents of a buffer as a single string.
+/// K_SPECIAL and CSI in the returned string are escaped.
+///
+/// @param dozero count == zero is not an error
+static char_u *get_buffcont(buffheader_T *buffer, int dozero)
{
size_t count = 0;
- char_u *p = NULL;
- char_u *p2;
+ char_u *p = NULL;
+ char_u *p2;
// compute the total length of the string
for (const buffblock_T *bp = buffer->bh_first.b_next;
@@ -211,7 +209,7 @@ static char_u *get_buffcont(buffheader_T *buffer,
*/
char_u *get_recorded(void)
{
- char_u *p;
+ char_u *p;
size_t len;
p = get_buffcont(&recordbuff, TRUE);
@@ -231,8 +229,9 @@ char_u *get_recorded(void)
* When stopping recording from Insert mode with CTRL-O q, also remove the
* CTRL-O.
*/
- if (len > 0 && restart_edit != 0 && p[len - 1] == Ctrl_O)
+ if (len > 0 && restart_edit != 0 && p[len - 1] == Ctrl_O) {
p[len - 1] = NUL;
+ }
return p;
}
@@ -253,8 +252,7 @@ char_u *get_inserted(void)
/// @param[out] buf Buffer to add to.
/// @param[in] s String to add.
/// @param[in] slen String length or -1 for NUL-terminated string.
-static void add_buff(buffheader_T *const buf, const char *const s,
- ptrdiff_t slen)
+static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t slen)
{
if (slen < 0) {
slen = (ptrdiff_t)strlen(s);
@@ -354,8 +352,9 @@ static int read_readbuffers(int advance)
int c;
c = read_readbuf(&readbuf1, advance);
- if (c == NUL)
+ if (c == NUL) {
c = read_readbuf(&readbuf2, advance);
+ }
return c;
}
@@ -583,8 +582,9 @@ void AppendToRedobuffLit(const char_u *str, int len)
*/
void AppendCharToRedobuff(int c)
{
- if (!block_redo)
+ if (!block_redo) {
add_char_buff(&redobuff, c);
+ }
}
/*
@@ -592,8 +592,9 @@ void AppendCharToRedobuff(int c)
*/
void AppendNumberToRedobuff(long n)
{
- if (!block_redo)
+ if (!block_redo) {
add_num_buff(&redobuff, n);
+ }
}
/*
@@ -865,10 +866,9 @@ void init_default_mappings(void)
// If silent is true, cmd_silent is set when the characters are obtained.
//
// return FAIL for failure, OK otherwise
-int ins_typebuf(char_u *str, int noremap, int offset,
- bool nottyped, bool silent)
+int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent)
{
- char_u *s1, *s2;
+ char_u *s1, *s2;
int newlen;
int addlen;
int i;
@@ -877,8 +877,9 @@ int ins_typebuf(char_u *str, int noremap, int offset,
int nrm;
init_typebuf();
- if (++typebuf.tb_change_cnt == 0)
+ if (++typebuf.tb_change_cnt == 0) {
typebuf.tb_change_cnt = 1;
+ }
addlen = (int)STRLEN(str);
@@ -924,12 +925,13 @@ int ins_typebuf(char_u *str, int noremap, int offset,
typebuf.tb_buf = s1;
memmove(s2 + newoff, typebuf.tb_noremap + typebuf.tb_off,
- (size_t)offset);
+ (size_t)offset);
memmove(s2 + newoff + offset + addlen,
- typebuf.tb_noremap + typebuf.tb_off + offset,
- (size_t)(typebuf.tb_len - offset));
- if (typebuf.tb_noremap != noremapbuf_init)
+ typebuf.tb_noremap + typebuf.tb_off + offset,
+ (size_t)(typebuf.tb_len - offset));
+ if (typebuf.tb_noremap != noremapbuf_init) {
xfree(typebuf.tb_noremap);
+ }
typebuf.tb_noremap = s2;
typebuf.tb_off = newoff;
@@ -948,26 +950,29 @@ int ins_typebuf(char_u *str, int noremap, int offset,
/*
* Adjust typebuf.tb_noremap[] for the new characters:
* If noremap == REMAP_NONE or REMAP_SCRIPT: new characters are
- * (sometimes) not remappable
+ * (sometimes) not remappable
* If noremap == REMAP_YES: all the new characters are mappable
* If noremap > 0: "noremap" characters are not remappable, the rest
- * mappable
+ * mappable
*/
- if (noremap == REMAP_SKIP)
+ if (noremap == REMAP_SKIP) {
nrm = 1;
- else if (noremap < 0)
+ } else if (noremap < 0) {
nrm = addlen;
- else
+ } else {
nrm = noremap;
- for (i = 0; i < addlen; ++i)
+ }
+ for (i = 0; i < addlen; ++i) {
typebuf.tb_noremap[typebuf.tb_off + i + offset] =
- (char_u)((--nrm >= 0) ? val : RM_YES);
+ (char_u)((--nrm >= 0) ? val : RM_YES);
+ }
/* tb_maplen and tb_silent only remember the length of mapped and/or
* silent mappings at the start of the buffer, assuming that a mapped
* sequence doesn't result in typed characters. */
- if (nottyped || typebuf.tb_maplen > offset)
+ if (nottyped || typebuf.tb_maplen > offset) {
typebuf.tb_maplen += addlen;
+ }
if (silent || typebuf.tb_silent > offset) {
typebuf.tb_silent += addlen;
cmd_silent = true;
@@ -999,18 +1004,16 @@ void ins_char_typebuf(int c)
(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
}
-/*
- * Return TRUE if the typeahead buffer was changed (while waiting for a
- * character to arrive). Happens when a message was received from a client or
- * from feedkeys().
- * But check in a more generic way to avoid trouble: When "typebuf.tb_buf"
- * changed it was reallocated and the old pointer can no longer be used.
- * Or "typebuf.tb_off" may have been changed and we would overwrite characters
- * that was just added.
- */
-bool typebuf_changed(
- int tb_change_cnt // old value of typebuf.tb_change_cnt
-)
+/// Return TRUE if the typeahead buffer was changed (while waiting for a
+/// character to arrive). Happens when a message was received from a client or
+/// from feedkeys().
+/// But check in a more generic way to avoid trouble: When "typebuf.tb_buf"
+/// changed it was reallocated and the old pointer can no longer be used.
+/// Or "typebuf.tb_off" may have been changed and we would overwrite characters
+/// that was just added.
+///
+/// @param tb_change_cnt old value of typebuf.tb_change_cnt
+bool typebuf_changed(int tb_change_cnt)
{
return tb_change_cnt != 0 && (typebuf.tb_change_cnt != tb_change_cnt
|| typebuf_was_filled
@@ -1051,8 +1054,9 @@ void del_typebuf(int len, int offset)
* Easy case: Just increase typebuf.tb_off.
*/
if (offset == 0 && typebuf.tb_buflen - (typebuf.tb_off + len)
- >= 3 * MAXMAPLEN + 3)
+ >= 3 * MAXMAPLEN + 3) {
typebuf.tb_off += len;
+ }
/*
* Have to move the characters in typebuf.tb_buf[] and typebuf.tb_noremap[]
*/
@@ -1063,9 +1067,9 @@ void del_typebuf(int len, int offset)
*/
if (typebuf.tb_off > MAXMAPLEN) {
memmove(typebuf.tb_buf + MAXMAPLEN,
- typebuf.tb_buf + typebuf.tb_off, (size_t)offset);
+ typebuf.tb_buf + typebuf.tb_off, (size_t)offset);
memmove(typebuf.tb_noremap + MAXMAPLEN,
- typebuf.tb_noremap + typebuf.tb_off, (size_t)offset);
+ typebuf.tb_noremap + typebuf.tb_off, (size_t)offset);
typebuf.tb_off = MAXMAPLEN;
}
// adjust typebuf.tb_buf (include the NUL at the end)
@@ -1075,8 +1079,8 @@ void del_typebuf(int len, int offset)
typebuf.tb_buf + i + len, (size_t)bytes);
// adjust typebuf.tb_noremap[]
memmove(typebuf.tb_noremap + typebuf.tb_off + offset,
- typebuf.tb_noremap + i + len,
- (size_t)(typebuf.tb_len - offset));
+ typebuf.tb_noremap + i + len,
+ (size_t)(typebuf.tb_len - offset));
}
if (typebuf.tb_maplen > offset) { // adjust tb_maplen
@@ -1168,8 +1172,9 @@ static void gotchars(const char_u *chars, size_t len)
void may_sync_undo(void)
{
if ((!(State & (INSERT + CMDLINE)) || arrow_used)
- && scriptin[curscript] == NULL)
+ && scriptin[curscript] == NULL) {
u_sync(false);
+ }
}
/*
@@ -1185,8 +1190,9 @@ void alloc_typebuf(void)
typebuf.tb_maplen = 0;
typebuf.tb_silent = 0;
typebuf.tb_no_abbr_cnt = 0;
- if (++typebuf.tb_change_cnt == 0)
+ if (++typebuf.tb_change_cnt == 0) {
typebuf.tb_change_cnt = 1;
+ }
}
/*
@@ -1264,13 +1270,10 @@ void restore_typeahead(tasave_T *tp)
readbuf2 = tp->save_readbuf2;
}
-/*
- * Open a new script file for the ":source!" command.
- */
-void openscript(
- char_u *name,
- bool directly // when true execute directly
-)
+/// Open a new script file for the ":source!" command.
+///
+/// @param directly when true execute directly
+void openscript(char_u *name, bool directly)
{
if (curscript + 1 == NSCRIPT) {
EMSG(_(e_nesting));
@@ -1351,15 +1354,17 @@ static void closescript(void)
file_free(scriptin[curscript], false);
scriptin[curscript] = NULL;
- if (curscript > 0)
+ if (curscript > 0) {
--curscript;
+ }
}
#if defined(EXITFREE)
void close_all_scripts(void)
{
- while (scriptin[0] != NULL)
+ while (scriptin[0] != NULL) {
closescript();
+ }
}
#endif
@@ -1460,60 +1465,81 @@ int vgetc(void)
continue;
}
c = TO_SPECIAL(c2, c);
-
}
// a keypad or special function key was not mapped, use it like
// its ASCII equivalent
switch (c) {
- case K_KPLUS: c = '+'; break;
- case K_KMINUS: c = '-'; break;
- case K_KDIVIDE: c = '/'; break;
- case K_KMULTIPLY: c = '*'; break;
- case K_KENTER: c = CAR; break;
- case K_KPOINT: c = '.'; break;
- case K_KCOMMA: c = ','; break;
- case K_KEQUAL: c = '='; break;
- case K_K0: c = '0'; break;
- case K_K1: c = '1'; break;
- case K_K2: c = '2'; break;
- case K_K3: c = '3'; break;
- case K_K4: c = '4'; break;
- case K_K5: c = '5'; break;
- case K_K6: c = '6'; break;
- case K_K7: c = '7'; break;
- case K_K8: c = '8'; break;
- case K_K9: c = '9'; break;
-
- case K_XHOME:
- case K_ZHOME:
- if (mod_mask == MOD_MASK_SHIFT) {
- c = K_S_HOME;
- mod_mask = 0;
- } else if (mod_mask == MOD_MASK_CTRL) {
- c = K_C_HOME;
- mod_mask = 0;
- } else {
- c = K_HOME;
- }
- break;
- case K_XEND:
- case K_ZEND:
- if (mod_mask == MOD_MASK_SHIFT) {
- c = K_S_END;
- mod_mask = 0;
- } else if (mod_mask == MOD_MASK_CTRL) {
- c = K_C_END;
- mod_mask = 0;
- } else {
- c = K_END;
- }
- break;
+ case K_KPLUS:
+ c = '+'; break;
+ case K_KMINUS:
+ c = '-'; break;
+ case K_KDIVIDE:
+ c = '/'; break;
+ case K_KMULTIPLY:
+ c = '*'; break;
+ case K_KENTER:
+ c = CAR; break;
+ case K_KPOINT:
+ c = '.'; break;
+ case K_KCOMMA:
+ c = ','; break;
+ case K_KEQUAL:
+ c = '='; break;
+ case K_K0:
+ c = '0'; break;
+ case K_K1:
+ c = '1'; break;
+ case K_K2:
+ c = '2'; break;
+ case K_K3:
+ c = '3'; break;
+ case K_K4:
+ c = '4'; break;
+ case K_K5:
+ c = '5'; break;
+ case K_K6:
+ c = '6'; break;
+ case K_K7:
+ c = '7'; break;
+ case K_K8:
+ c = '8'; break;
+ case K_K9:
+ c = '9'; break;
+
+ case K_XHOME:
+ case K_ZHOME:
+ if (mod_mask == MOD_MASK_SHIFT) {
+ c = K_S_HOME;
+ mod_mask = 0;
+ } else if (mod_mask == MOD_MASK_CTRL) {
+ c = K_C_HOME;
+ mod_mask = 0;
+ } else {
+ c = K_HOME;
+ }
+ break;
+ case K_XEND:
+ case K_ZEND:
+ if (mod_mask == MOD_MASK_SHIFT) {
+ c = K_S_END;
+ mod_mask = 0;
+ } else if (mod_mask == MOD_MASK_CTRL) {
+ c = K_C_END;
+ mod_mask = 0;
+ } else {
+ c = K_END;
+ }
+ break;
- case K_XUP: c = K_UP; break;
- case K_XDOWN: c = K_DOWN; break;
- case K_XLEFT: c = K_LEFT; break;
- case K_XRIGHT: c = K_RIGHT; break;
+ case K_XUP:
+ c = K_UP; break;
+ case K_XDOWN:
+ c = K_DOWN; break;
+ case K_XLEFT:
+ c = K_LEFT; break;
+ case K_XRIGHT:
+ c = K_RIGHT; break;
}
// For a multi-byte character get all the bytes and return the
@@ -1608,8 +1634,9 @@ int plain_vgetc(void)
*/
int vpeekc(void)
{
- if (old_char != -1)
+ if (old_char != -1) {
return old_char;
+ }
return vgetorpeek(false);
}
@@ -1623,8 +1650,9 @@ int vpeekc_any(void)
int c;
c = vpeekc();
- if (c == NUL && typebuf.tb_len > 0)
+ if (c == NUL && typebuf.tb_len > 0) {
c = ESC;
+ }
return c;
}
@@ -1678,10 +1706,10 @@ static int vgetorpeek(bool advance)
{
int c, c1;
int keylen;
- char_u *s;
- mapblock_T *mp;
- mapblock_T *mp2;
- mapblock_T *mp_match;
+ char_u *s;
+ mapblock_T *mp;
+ mapblock_T *mp2;
+ mapblock_T *mp_match;
int mp_match_len = 0;
bool timedout = false; // waited for more than 1 second
// for mapping to complete
@@ -1700,7 +1728,7 @@ static int vgetorpeek(bool advance)
/*
* This function doesn't work very well when called recursively. This may
* happen though, because of:
- * 1. The call to add_to_showcmd(). char_avail() is then used to check if
+ * 1. The call to add_to_showcmd(). char_avail() is then used to check if
* there is a character available, which calls this function. In that
* case we must return NUL, to indicate no character is available.
* 2. A GUI callback function writes to the screen, causing a
@@ -1709,16 +1737,17 @@ static int vgetorpeek(bool advance)
* thus it should be OK. But don't get a key from the user then.
*/
if (vgetc_busy > 0
- && ex_normal_busy == 0
- )
+ && ex_normal_busy == 0) {
return NUL;
+ }
local_State = get_real_state();
++vgetc_busy;
- if (advance)
+ if (advance) {
KeyStuffed = FALSE;
+ }
init_typebuf();
start_stuff();
@@ -1731,8 +1760,9 @@ static int vgetorpeek(bool advance)
*/
if (typeahead_char != 0) {
c = typeahead_char;
- if (advance)
+ if (advance) {
typeahead_char = 0;
+ }
} else {
c = read_readbuffers(advance);
}
@@ -1802,7 +1832,7 @@ static int vgetorpeek(bool advance)
* - typebuf.tb_buf[typebuf.tb_off] should not be remapped
* - in insert or cmdline mode and 'paste' option set
* - waiting for "hit return to continue" and CR or SPACE
- * typed
+ * typed
* - waiting for a char with --more--
* - in Ctrl-X mode, and we get a valid char for that mode
*/
@@ -1821,8 +1851,8 @@ static int vgetorpeek(bool advance)
&& State != CONFIRM
&& !((ctrl_x_mode_not_default() && vim_is_ctrl_x_key(c1))
|| ((compl_cont_status & CONT_LOCAL)
- && (c1 == Ctrl_N || c1 == Ctrl_P)))
- ) {
+ && (c1 == Ctrl_N ||
+ c1 == Ctrl_P)))) {
if (c1 == K_SPECIAL) {
nolmaplen = 2;
} else {
@@ -1864,14 +1894,16 @@ static int vgetorpeek(bool advance)
// find the match length of this mapping
for (mlen = 1; mlen < typebuf.tb_len; mlen++) {
c2 = typebuf.tb_buf[typebuf.tb_off + mlen];
- if (nomap > 0)
+ if (nomap > 0) {
--nomap;
- else if (c2 == K_SPECIAL)
+ } else if (c2 == K_SPECIAL) {
nomap = 2;
- else
+ } else {
LANGMAP_ADJUST(c2, TRUE);
- if (mp->m_keys[mlen] != c2)
+ }
+ if (mp->m_keys[mlen] != c2) {
break;
+ }
}
/* Don't allow mapping the first byte(s) of a
@@ -1902,17 +1934,21 @@ static int vgetorpeek(bool advance)
&& (mp->m_keys[0] != K_SPECIAL
|| mp->m_keys[1] != KS_EXTRA
|| mp->m_keys[2]
- != (int)KE_SNR))
+ != (int)KE_SNR)) {
continue;
+ }
/*
* If one of the typed keys cannot be
* remapped, skip the entry.
*/
- for (n = mlen; --n >= 0; )
- if (*s++ & (RM_NONE|RM_ABBR))
+ for (n = mlen; --n >= 0; ) {
+ if (*s++ & (RM_NONE|RM_ABBR)) {
break;
- if (n >= 0)
+ }
+ }
+ if (n >= 0) {
continue;
+ }
if (keylen > typebuf.tb_len) {
if (!timedout && !(mp_match != NULL
@@ -2030,10 +2066,11 @@ static int vgetorpeek(bool advance)
*/
if (++mapdepth >= p_mmd) {
EMSG(_("E223: recursive mapping"));
- if (State & CMDLINE)
+ if (State & CMDLINE) {
redrawcmdline();
- else
+ } else {
setcursor();
+ }
flush_buffers(FLUSH_MINIMAL);
mapdepth = 0; // for next one
c = -1;
@@ -2090,9 +2127,9 @@ static int vgetorpeek(bool advance)
* If m_noremap is set, don't remap the whole 'to'
* part.
*/
- if (s == NULL)
+ if (s == NULL) {
i = FAIL;
- else {
+ } else {
int noremap;
// If this is a LANGMAP mapping, then we didn't record the keys
@@ -2101,20 +2138,22 @@ static int vgetorpeek(bool advance)
gotchars(s, STRLEN(s));
}
- if (save_m_noremap != REMAP_YES)
+ if (save_m_noremap != REMAP_YES) {
noremap = save_m_noremap;
- else if (
- STRNCMP(s, save_m_keys != NULL
+ } else if (
+ STRNCMP(s, save_m_keys != NULL
? save_m_keys : mp->m_keys,
- (size_t)keylen)
- != 0)
+ (size_t)keylen)
+ != 0) {
noremap = REMAP_YES;
- else
+ } else {
noremap = REMAP_SKIP;
+ }
i = ins_typebuf(s, noremap,
- 0, TRUE, cmd_silent || save_m_silent);
- if (save_m_expr)
+ 0, TRUE, cmd_silent || save_m_silent);
+ if (save_m_expr) {
xfree(s);
+ }
}
xfree(save_m_keys);
xfree(save_m_str);
@@ -2152,7 +2191,7 @@ static int vgetorpeek(bool advance)
&& (c = inchar(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len,
3, 25L)) == 0) {
colnr_T col = 0, vcol;
- char_u *ptr;
+ char_u *ptr;
if (mode_displayed) {
unshowmode(true);
@@ -2299,11 +2338,13 @@ static int vgetorpeek(bool advance)
curwin->w_wcol = new_wcol;
curwin->w_wrow = new_wrow;
push_showcmd();
- if (typebuf.tb_len > SHOWCMD_COLS)
+ if (typebuf.tb_len > SHOWCMD_COLS) {
i = typebuf.tb_len - SHOWCMD_COLS;
- while (i < typebuf.tb_len)
+ }
+ while (i < typebuf.tb_len) {
(void)add_to_showcmd(typebuf.tb_buf[typebuf.tb_off
+ i++]);
+ }
curwin->w_wcol = old_wcol;
curwin->w_wrow = old_wrow;
}
@@ -2346,8 +2387,9 @@ static int vgetorpeek(bool advance)
typebuf.tb_buflen - typebuf.tb_off - typebuf.tb_len - 1,
wait_time);
- if (i != 0)
+ if (i != 0) {
pop_showcmd();
+ }
if (c1 == 1) {
if (State & INSERT) {
edit_unputchar();
@@ -2383,8 +2425,8 @@ static int vgetorpeek(bool advance)
/*
* The "INSERT" message is taken care of here:
- * if we return an ESC to exit insert mode, the message is deleted
- * if we don't return an ESC but deleted the message before, redisplay it
+ * if we return an ESC to exit insert mode, the message is deleted
+ * if we don't return an ESC but deleted the message before, redisplay it
*/
if (advance && p_smd && msg_silent == 0 && (State & INSERT)) {
if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) {
@@ -2418,34 +2460,30 @@ static int vgetorpeek(bool advance)
return c;
}
-/*
- * inchar() - get one character from
- * 1. a scriptfile
- * 2. the keyboard
- *
- * As much characters as we can get (up to 'maxlen') are put in "buf" and
- * NUL terminated (buffer length must be 'maxlen' + 1).
- * Minimum for "maxlen" is 3!!!!
- *
- * "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into
- * it. When typebuf.tb_change_cnt changes (e.g., when a message is received
- * from a remote client) "buf" can no longer be used. "tb_change_cnt" is 0
- * otherwise.
- *
- * If we got an interrupt all input is read until none is available.
- *
- * If wait_time == 0 there is no waiting for the char.
- * If wait_time == n we wait for n msec for a character to arrive.
- * If wait_time == -1 we wait forever for a character to arrive.
- *
- * Return the number of obtained characters.
- * Return -1 when end of input script reached.
- */
-int inchar(
- char_u *buf,
- int maxlen,
- long wait_time // milli seconds
-)
+/// inchar() - get one character from
+/// 1. a scriptfile
+/// 2. the keyboard
+///
+/// As much characters as we can get (up to 'maxlen') are put in "buf" and
+/// NUL terminated (buffer length must be 'maxlen' + 1).
+/// Minimum for "maxlen" is 3!!!!
+///
+/// "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into
+/// it. When typebuf.tb_change_cnt changes (e.g., when a message is received
+/// from a remote client) "buf" can no longer be used. "tb_change_cnt" is 0
+/// otherwise.
+///
+/// If we got an interrupt all input is read until none is available.
+///
+/// If wait_time == 0 there is no waiting for the char.
+/// If wait_time == n we wait for n msec for a character to arrive.
+/// If wait_time == -1 we wait forever for a character to arrive.
+///
+/// Return the number of obtained characters.
+/// Return -1 when end of input script reached.
+///
+/// @param wait_time milli seconds
+int inchar(char_u *buf, int maxlen, long wait_time)
{
int len = 0; // Init for GCC.
int retesc = false; // Return ESC with gotint.
@@ -2551,10 +2589,10 @@ int fix_input_buffer(char_u *buf, int len)
// Reading from script, need to process special bytes
int i;
- char_u *p = buf;
+ char_u *p = buf;
// Two characters are special: NUL and K_SPECIAL.
- // Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
+ // Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
// Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER
// Replace CSI by K_SPECIAL KS_EXTRA KE_CSI
for (i = len; --i >= 0; ++p) {
@@ -2595,9 +2633,8 @@ int fix_input_buffer(char_u *buf, int len)
/// @param[in] orig_rhs_len `strlen` of orig_rhs.
/// @param[in] cpo_flags See param docs for @ref replace_termcodes.
/// @param[out] mapargs MapArguments struct holding the replaced strings.
-void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len,
- const char_u *orig_rhs, const size_t orig_rhs_len,
- int cpo_flags, MapArguments *mapargs)
+void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const char_u *orig_rhs,
+ const size_t orig_rhs_len, int cpo_flags, MapArguments *mapargs)
{
char_u *lhs_buf = NULL;
char_u *rhs_buf = NULL;
@@ -2764,11 +2801,10 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs)
/// @param mode @see do_map
/// @param is_abbrev @see do_map
/// @param buf Target Buffer
-int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
- buf_T *buf)
+int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T *buf)
{
- mapblock_T *mp, **mpp;
- char_u *p;
+ mapblock_T *mp, **mpp;
+ char_u *p;
int n;
int len = 0; // init for GCC
int did_it = false;
@@ -2777,8 +2813,8 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
int retval = 0;
int hash;
int new_hash;
- mapblock_T **abbr_table;
- mapblock_T **map_table;
+ mapblock_T **abbr_table;
+ mapblock_T **map_table;
int noremap;
map_table = maphash;
@@ -3148,15 +3184,15 @@ int do_map(int maptype, char_u *arg, int mode, bool is_abbrev)
MapArguments parsed_args;
int result = str_to_mapargs(arg, maptype == 1, &parsed_args);
switch (result) {
- case 0:
- break;
- case 1:
- // invalid arguments
- goto free_and_return;
- default:
- assert(false && "Unknown return code from str_to_mapargs!");
- result = -1;
- goto free_and_return;
+ case 0:
+ break;
+ case 1:
+ // invalid arguments
+ goto free_and_return;
+ default:
+ assert(false && "Unknown return code from str_to_mapargs!");
+ result = -1;
+ goto free_and_return;
} // switch
result = buf_do_map(maptype, &parsed_args, mode, is_abbrev, curbuf);
@@ -3173,7 +3209,7 @@ free_and_return:
*/
static void mapblock_free(mapblock_T **mpp)
{
- mapblock_T *mp;
+ mapblock_T *mp;
mp = *mpp;
xfree(mp->m_keys);
@@ -3199,7 +3235,7 @@ static void validate_maphash(void)
*/
int get_map_mode(char_u **cmdp, bool forceit)
{
- char_u *p;
+ char_u *p;
int modec;
int mode;
@@ -3253,21 +3289,19 @@ void map_clear_mode(char_u *cmdp, char_u *arg, int forceit, int abbr)
mode = get_map_mode(&cmdp, forceit);
map_clear_int(curbuf, mode,
- local,
- abbr);
+ local,
+ abbr);
}
-/*
- * Clear all mappings in "mode".
- */
-void map_clear_int(
- buf_T *buf, // buffer for local mappings
- int mode, // mode in which to delete
- bool local, // true for buffer-local mappings
- bool abbr // true for abbreviations
-)
+/// Clear all mappings in "mode".
+///
+/// @param buf, buffer for local mappings
+/// @param mode mode in which to delete
+/// @param local true for buffer-local mappings
+/// @param abbr true for abbreviations
+void map_clear_int(buf_T *buf, int mode, bool local, bool abbr)
{
- mapblock_T *mp, **mpp;
+ mapblock_T *mp, **mpp;
int hash;
int new_hash;
@@ -3284,10 +3318,11 @@ void map_clear_int(
mpp = &first_abbr;
}
} else {
- if (local)
+ if (local) {
mpp = &buf->b_maphash[hash];
- else
+ } else {
mpp = &maphash[hash];
+ }
}
while (*mpp != NULL) {
mp = *mpp;
@@ -3365,10 +3400,8 @@ char *map_mode_to_chars(int mode)
return (char *)mapmode.ga_data;
}
-static void showmap(
- mapblock_T *mp,
- bool local // true for buffer-local map
-)
+/// @param local true for buffer-local map
+static void showmap(mapblock_T *mp, bool local)
{
size_t len = 1;
@@ -3390,8 +3423,9 @@ static void showmap(
xfree(mapchars);
}
- while (++len <= 3)
+ while (++len <= 3) {
msg_putchar(' ');
+ }
// Display the LHS. Get length of what we write.
len = (size_t)msg_outtrans_special(mp->m_keys, true, 0);
@@ -3408,10 +3442,11 @@ static void showmap(
msg_putchar(' ');
}
- if (local)
+ if (local) {
msg_putchar('@');
- else
+ } else {
msg_putchar(' ');
+ }
/* Use FALSE below if we only want things like <Up> to show up as such on
* the rhs, and not M-x etc, TRUE gets both -- webb */
@@ -3441,8 +3476,7 @@ static void showmap(
/// @param[in] abbr true if checking abbreviations in place of mappings.
///
/// @return true if there is at least one mapping with given parameters.
-bool map_to_exists(const char *const str, const char *const modechars,
- const bool abbr)
+bool map_to_exists(const char *const str, const char *const modechars, const bool abbr)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
{
int mode = 0;
@@ -3487,7 +3521,7 @@ bool map_to_exists(const char *const str, const char *const modechars,
/// @return true if there is at least one mapping with given parameters.
int map_to_exists_mode(const char *const rhs, const int mode, const bool abbr)
{
- mapblock_T *mp;
+ mapblock_T *mp;
int hash;
bool exp_buffer = false;
@@ -3533,29 +3567,25 @@ static int expand_mapmodes = 0;
static bool expand_isabbrev = false;
static bool expand_buffer = false;
-/*
- * Work out what to complete when doing command line completion of mapping
- * or abbreviation names.
- */
-char_u *set_context_in_map_cmd(
- expand_T *xp,
- char_u *cmd,
- char_u *arg,
- bool forceit, // true if '!' given
- bool isabbrev, // true if abbreviation
- bool isunmap, // true if unmap/unabbrev command
- cmdidx_T cmdidx
-)
+/// Work out what to complete when doing command line completion of mapping
+/// or abbreviation names.
+///
+/// @param forceit true if '!' given
+/// @param isabbrev true if abbreviation
+/// @param isunmap true if unmap/unabbrev command
+char_u *set_context_in_map_cmd(expand_T *xp, char_u *cmd, char_u *arg, bool forceit, bool isabbrev,
+ bool isunmap, cmdidx_T cmdidx)
{
- if (forceit && cmdidx != CMD_map && cmdidx != CMD_unmap)
+ if (forceit && cmdidx != CMD_map && cmdidx != CMD_unmap) {
xp->xp_context = EXPAND_NOTHING;
- else {
- if (isunmap)
+ } else {
+ if (isunmap) {
expand_mapmodes = get_map_mode(&cmd, forceit || isabbrev);
- else {
+ } else {
expand_mapmodes = INSERT + CMDLINE;
- if (!isabbrev)
+ if (!isabbrev) {
expand_mapmodes += VISUAL + SELECTMODE + NORMAL + OP_PENDING;
+ }
}
expand_isabbrev = isabbrev;
xp->xp_context = EXPAND_MAPPINGS;
@@ -3603,11 +3633,11 @@ char_u *set_context_in_map_cmd(
// Return OK if matches found, FAIL otherwise.
int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
{
- mapblock_T *mp;
+ mapblock_T *mp;
int hash;
int count;
int round;
- char_u *p;
+ char_u *p;
int i;
validate_maphash();
@@ -3642,10 +3672,11 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
}
if (vim_regexec(regmatch, p, (colnr_T)0)) {
- if (round == 1)
+ if (round == 1) {
++count;
- else
+ } else {
(*file)[count++] = vim_strsave(p);
+ }
}
}
@@ -3655,17 +3686,18 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
break; // for (hash)
}
mp = first_abbr;
- } else if (expand_buffer)
+ } else if (expand_buffer) {
mp = curbuf->b_maphash[hash];
- else
+ } else {
mp = maphash[hash];
+ }
for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) {
p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
- if (round == 1)
+ if (round == 1) {
++count;
- else {
+ } else {
(*file)[count++] = p;
p = NULL;
}
@@ -3685,9 +3717,9 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
} // for (round)
if (count > 1) {
- char_u **ptr1;
- char_u **ptr2;
- char_u **ptr3;
+ char_u **ptr1;
+ char_u **ptr2;
+ char_u **ptr3;
// Sort the matches
sort_strings(*file, count);
@@ -3698,9 +3730,9 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
ptr3 = ptr1 + count;
while (ptr2 < ptr3) {
- if (STRCMP(*ptr1, *ptr2))
+ if (STRCMP(*ptr1, *ptr2)) {
*++ptr1 = *ptr2++;
- else {
+ } else {
xfree(*ptr2++);
count--;
}
@@ -3732,10 +3764,10 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
int len;
int scol; // starting column of the abbr.
int j;
- char_u *s;
+ char_u *s;
char_u tb[MB_MAXBYTES + 4];
- mapblock_T *mp;
- mapblock_T *mp2;
+ mapblock_T *mp;
+ mapblock_T *mp2;
int clen = 0; // length in characters
bool is_id = true;
@@ -3779,8 +3811,9 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
scol = (int)(p - ptr);
}
- if (scol < mincol)
+ if (scol < mincol) {
scol = mincol;
+ }
if (scol < col) { // there is a word in front of the cursor
ptr += scol;
len = col - scol;
@@ -3858,17 +3891,19 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
// insert the last typed char
(void)ins_typebuf(tb, 1, 0, true, mp->m_silent);
}
- if (mp->m_expr)
+ if (mp->m_expr) {
s = eval_map_expr(mp->m_str, c);
- else
+ } else {
s = mp->m_str;
+ }
if (s != NULL) {
// insert the to string
(void)ins_typebuf(s, mp->m_noremap, 0, true, mp->m_silent);
// no abbrev. for these chars
typebuf.tb_no_abbr_cnt += (int)STRLEN(s) + j + 1;
- if (mp->m_expr)
+ if (mp->m_expr) {
xfree(s);
+ }
}
tb[0] = Ctrl_H;
@@ -3883,20 +3918,16 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
return false;
}
-/*
- * Evaluate the RHS of a mapping or abbreviations and take care of escaping
- * special characters.
- */
-static char_u *
-eval_map_expr (
- char_u *str,
- int c // NUL or typed character for abbreviation
-)
+/// Evaluate the RHS of a mapping or abbreviations and take care of escaping
+/// special characters.
+///
+/// @param c NUL or typed character for abbreviation
+static char_u *eval_map_expr(char_u *str, int c)
{
- char_u *res;
- char_u *p;
- char_u *expr;
- char_u *save_cmd;
+ char_u *res;
+ char_u *p;
+ char_u *expr;
+ char_u *save_cmd;
pos_T save_cursor;
int save_msg_col;
int save_msg_row;
@@ -3926,8 +3957,9 @@ eval_map_expr (
restore_cmdline_alloc(save_cmd);
xfree(expr);
- if (p == NULL)
+ if (p == NULL) {
return NULL;
+ }
// Escape CSI in the result to be able to use the string as typeahead.
res = vim_strsave_escape_csi(p);
xfree(p);
@@ -3970,7 +4002,7 @@ char_u *vim_strsave_escape_csi(char_u *p)
*/
void vim_unescape_csi(char_u *p)
{
- char_u *s = p, *d = p;
+ char_u *s = p, *d = p;
while (*s != NUL) {
if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) {
@@ -3980,26 +4012,23 @@ void vim_unescape_csi(char_u *p)
&& s[1] == KS_EXTRA && s[2] == (int)KE_CSI) {
*d++ = CSI;
s += 3;
- } else
+ } else {
*d++ = *s++;
+ }
}
*d = NUL;
}
-/*
- * Write map commands for the current mappings to an .exrc file.
- * Return FAIL on error, OK otherwise.
- */
-int
-makemap(
- FILE *fd,
- buf_T *buf // buffer for local mappings or NULL
-)
+/// Write map commands for the current mappings to an .exrc file.
+/// Return FAIL on error, OK otherwise.
+///
+/// @param buf buffer for local mappings or NULL
+int makemap(FILE *fd, buf_T *buf)
{
- mapblock_T *mp;
+ mapblock_T *mp;
char_u c1, c2, c3;
- char_u *p;
- char *cmd;
+ char_u *p;
+ char *cmd;
int abbr;
int hash;
bool did_cpo = false;
@@ -4209,13 +4238,14 @@ makemap(
// return FAIL for failure, OK otherwise
int put_escstr(FILE *fd, char_u *strstart, int what)
{
- char_u *str = strstart;
+ char_u *str = strstart;
int c;
// :map xx <Nop>
if (*str == NUL && what == 1) {
- if (fprintf(fd, "<Nop>") < 0)
+ if (fprintf(fd, "<Nop>") < 0) {
return FAIL;
+ }
return OK;
}
@@ -4224,9 +4254,11 @@ int put_escstr(FILE *fd, char_u *strstart, int what)
// K_SPECIAL and CSI bytes.
const char *p = mb_unescape((const char **)&str);
if (p != NULL) {
- while (*p != NUL)
- if (fputc(*p++, fd) < 0)
+ while (*p != NUL) {
+ if (fputc(*p++, fd) < 0) {
return FAIL;
+ }
+ }
--str;
continue;
}
@@ -4261,11 +4293,13 @@ int put_escstr(FILE *fd, char_u *strstart, int what)
*/
if (c == NL) {
if (what == 2) {
- if (fprintf(fd, "\\\026\n") < 0)
+ if (fprintf(fd, "\\\026\n") < 0) {
return FAIL;
+ }
} else {
- if (fprintf(fd, "<NL>") < 0)
+ if (fprintf(fd, "<NL>") < 0) {
return FAIL;
+ }
}
continue;
}
@@ -4282,39 +4316,38 @@ int put_escstr(FILE *fd, char_u *strstart, int what)
* A space in the lhs of a :map needs a CTRL-V.
*/
if (what == 2 && (ascii_iswhite(c) || c == '"' || c == '\\')) {
- if (putc('\\', fd) < 0)
+ if (putc('\\', fd) < 0) {
return FAIL;
+ }
} else if (c < ' ' || c > '~' || c == '|'
|| (what == 0 && c == ' ')
|| (what == 1 && str == strstart && c == ' ')
|| (what != 2 && c == '<')) {
- if (putc(Ctrl_V, fd) < 0)
+ if (putc(Ctrl_V, fd) < 0) {
return FAIL;
+ }
}
- if (putc(c, fd) < 0)
+ if (putc(c, fd) < 0) {
return FAIL;
+ }
}
return OK;
}
-/*
- * Check the string "keys" against the lhs of all mappings.
- * Return pointer to rhs of mapping (mapblock->m_str).
- * NULL when no mapping found.
- */
-char_u *
-check_map (
- char_u *keys,
- int mode,
- int exact, // require exact match
- int ign_mod, // ignore preceding modifier
- int abbr, // do abbreviations
- mapblock_T **mp_ptr, // return: pointer to mapblock or NULL
- int *local_ptr // return: buffer-local mapping or NULL
-)
+/// Check the string "keys" against the lhs of all mappings.
+/// Return pointer to rhs of mapping (mapblock->m_str).
+/// NULL when no mapping found.
+///
+/// @param exact require exact match
+/// @param ign_mod ignore preceding modifier
+/// @param abbr do abbreviations
+/// @param mp_ptr return: pointer to mapblock or NULL
+/// @param local_ptr return: buffer-local mapping or NULL
+char_u *check_map(char_u *keys, int mode, int exact, int ign_mod, int abbr, mapblock_T **mp_ptr,
+ int *local_ptr)
{
int len, minlen;
- mapblock_T *mp;
+ mapblock_T *mp;
validate_maphash();
@@ -4349,10 +4382,12 @@ check_map (
}
minlen = keylen < len ? keylen : len;
if (STRNCMP(s, keys, minlen) == 0) {
- if (mp_ptr != NULL)
+ if (mp_ptr != NULL) {
*mp_ptr = mp;
- if (local_ptr != NULL)
+ }
+ if (local_ptr != NULL) {
*local_ptr = local;
+ }
return mp->m_str;
}
}
@@ -4374,8 +4409,8 @@ check_map (
/// @param nore If true, make a non-recursive mapping.
void add_map(char_u *map, int mode, bool nore)
{
- char_u *s;
- char_u *cpo_save = p_cpo;
+ char_u *s;
+ char_u *cpo_save = p_cpo;
p_cpo = (char_u *)""; // Allow <> notation
// Need to put string in allocated memory, because do_map() will modify it.
@@ -4385,21 +4420,20 @@ void add_map(char_u *map, int mode, bool nore)
p_cpo = cpo_save;
}
-// Translate an internal mapping/abbreviation representation into the
-// corresponding external one recognized by :map/:abbrev commands.
-//
-// This function is called when expanding mappings/abbreviations on the
-// command-line.
-//
-// It uses a growarray to build the translation string since the latter can be
-// wider than the original description. The caller has to free the string
-// afterwards.
-//
-// Returns NULL when there is a problem.
-static char_u * translate_mapping (
- char_u *str,
- int cpo_flags // Value of various flags present in &cpo
-)
+/// Translate an internal mapping/abbreviation representation into the
+/// corresponding external one recognized by :map/:abbrev commands.
+///
+/// This function is called when expanding mappings/abbreviations on the
+/// command-line.
+///
+/// It uses a growarray to build the translation string since the latter can be
+/// wider than the original description. The caller has to free the string
+/// afterwards.
+///
+/// @param cpo_flags Value of various flags present in &cpo
+///
+/// @return NULL when there is a problem.
+static char_u *translate_mapping(char_u *str, int cpo_flags)
{
garray_T ga;
ga_init(&ga, 1, 40);
@@ -4447,8 +4481,9 @@ static bool typebuf_match_len(const uint8_t *str, int *mlen)
{
int i;
for (i = 0; i < typebuf.tb_len && str[i]; i++) {
- if (str[i] != typebuf.tb_buf[typebuf.tb_off + i])
+ if (str[i] != typebuf.tb_buf[typebuf.tb_off + i]) {
break;
+ }
}
*mlen = i;
return str[i] == NUL; // matched the whole string
@@ -4469,7 +4504,7 @@ mapblock_T *get_maphash(int index, buf_T *buf)
}
/// Get command argument for <Cmd> key
-char_u * getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
+char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
{
garray_T line_ga;
int c1 = -1, c2;
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 1b1735c991..125108ee78 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -6,35 +6,35 @@
*/
#include <assert.h>
-#include <string.h>
#include <inttypes.h>
+#include <string.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
+#include "nvim/vim.h"
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
-#include "nvim/hardcopy.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/fileio.h"
+#include "nvim/garray.h"
+#include "nvim/hardcopy.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/garray.h"
#include "nvim/option.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/version.h"
-#include "nvim/os/os.h"
-#include "nvim/os/input.h"
/*
* To implement printing on a platform, the following functions must be
@@ -98,20 +98,20 @@
static option_table_T printer_opts[OPT_PRINT_NUM_OPTIONS]
=
{
- {"top", TRUE, 0, NULL, 0, FALSE},
- {"bottom", TRUE, 0, NULL, 0, FALSE},
- {"left", TRUE, 0, NULL, 0, FALSE},
- {"right", TRUE, 0, NULL, 0, FALSE},
- {"header", TRUE, 0, NULL, 0, FALSE},
- {"syntax", FALSE, 0, NULL, 0, FALSE},
- {"number", FALSE, 0, NULL, 0, FALSE},
- {"wrap", FALSE, 0, NULL, 0, FALSE},
- {"duplex", FALSE, 0, NULL, 0, FALSE},
- {"portrait", FALSE, 0, NULL, 0, FALSE},
- {"paper", FALSE, 0, NULL, 0, FALSE},
- {"collate", FALSE, 0, NULL, 0, FALSE},
- {"jobsplit", FALSE, 0, NULL, 0, FALSE},
- {"formfeed", FALSE, 0, NULL, 0, FALSE},
+ { "top", TRUE, 0, NULL, 0, FALSE },
+ { "bottom", TRUE, 0, NULL, 0, FALSE },
+ { "left", TRUE, 0, NULL, 0, FALSE },
+ { "right", TRUE, 0, NULL, 0, FALSE },
+ { "header", TRUE, 0, NULL, 0, FALSE },
+ { "syntax", FALSE, 0, NULL, 0, FALSE },
+ { "number", FALSE, 0, NULL, 0, FALSE },
+ { "wrap", FALSE, 0, NULL, 0, FALSE },
+ { "duplex", FALSE, 0, NULL, 0, FALSE },
+ { "portrait", FALSE, 0, NULL, 0, FALSE },
+ { "paper", FALSE, 0, NULL, 0, FALSE },
+ { "collate", FALSE, 0, NULL, 0, FALSE },
+ { "jobsplit", FALSE, 0, NULL, 0, FALSE },
+ { "formfeed", FALSE, 0, NULL, 0, FALSE },
}
;
@@ -150,12 +150,12 @@ static int page_count;
static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] =
{
- {"c", FALSE, 0, NULL, 0, FALSE},
- {"a", FALSE, 0, NULL, 0, FALSE},
- {"r", FALSE, 0, NULL, 0, FALSE},
- {"b", FALSE, 0, NULL, 0, FALSE},
- {"i", FALSE, 0, NULL, 0, FALSE},
- {"o", FALSE, 0, NULL, 0, FALSE},
+ { "c", FALSE, 0, NULL, 0, FALSE },
+ { "a", FALSE, 0, NULL, 0, FALSE },
+ { "r", FALSE, 0, NULL, 0, FALSE },
+ { "b", FALSE, 0, NULL, 0, FALSE },
+ { "i", FALSE, 0, NULL, 0, FALSE },
+ { "o", FALSE, 0, NULL, 0, FALSE },
};
/*
@@ -183,31 +183,31 @@ struct prt_ps_font_S {
int uline_width;
int bbox_min_y;
int bbox_max_y;
- char *(ps_fontname[4]);
+ char *(ps_fontname[4]);
};
/* Structures to map user named encoding and mapping to PS equivalents for
* building CID font name */
struct prt_ps_encoding_S {
- char *encoding;
- char *cmap_encoding;
+ char *encoding;
+ char *cmap_encoding;
int needs_charset;
};
struct prt_ps_charset_S {
- char *charset;
- char *cmap_charset;
+ char *charset;
+ char *cmap_charset;
int has_charset;
};
// Collections of encodings and charsets for multi-byte printing
struct prt_ps_mbfont_S {
int num_encodings;
- struct prt_ps_encoding_S *encodings;
+ struct prt_ps_encoding_S *encodings;
int num_charsets;
- struct prt_ps_charset_S *charsets;
- char *ascii_enc;
- char *defcs;
+ struct prt_ps_charset_S *charsets;
+ char *ascii_enc;
+ char *defcs;
};
// Types of PS resource file currently used
@@ -234,14 +234,14 @@ struct prt_ps_resource_S {
};
struct prt_dsc_comment_S {
- char *string;
+ char *string;
int len;
int type;
};
struct prt_dsc_line_S {
int type;
- char_u *string;
+ char_u *string;
int len;
};
@@ -286,15 +286,14 @@ char_u *parse_printmbfont(void)
* Returns an error message for an illegal option, NULL otherwise.
* Only used for the printer at the moment...
*/
-static char_u *parse_list_options(char_u *option_str, option_table_T *table,
- size_t table_size)
+static char_u *parse_list_options(char_u *option_str, option_table_T *table, size_t table_size)
{
option_table_T *old_opts;
- char_u *ret = NULL;
- char_u *stringp;
- char_u *colonp;
- char_u *commap;
- char_u *p;
+ char_u *ret = NULL;
+ char_u *stringp;
+ char_u *colonp;
+ char_u *commap;
+ char_u *p;
size_t idx = 0; // init for GCC
int len;
@@ -317,14 +316,17 @@ static char_u *parse_list_options(char_u *option_str, option_table_T *table,
break;
}
commap = vim_strchr(stringp, ',');
- if (commap == NULL)
+ if (commap == NULL) {
commap = option_str + STRLEN(option_str);
+ }
len = (int)(colonp - stringp);
- for (idx = 0; idx < table_size; ++idx)
- if (STRNICMP(stringp, table[idx].name, len) == 0)
+ for (idx = 0; idx < table_size; ++idx) {
+ if (STRNICMP(stringp, table[idx].name, len) == 0) {
break;
+ }
+ }
if (idx == table_size) {
ret = (char_u *)N_("E551: Illegal component");
@@ -347,8 +349,9 @@ static char_u *parse_list_options(char_u *option_str, option_table_T *table,
table[idx].strlen = (int)(commap - p);
stringp = commap;
- if (*stringp == ',')
+ if (*stringp == ',') {
++stringp;
+ }
}
if (ret != NULL) {
@@ -401,16 +404,18 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
colorindex = atoi(color);
}
- if (colorindex >= 0 && colorindex < t_colors)
+ if (colorindex >= 0 && colorindex < t_colors) {
fg_color = prt_get_term_color(colorindex);
- else
+ } else {
fg_color = PRCOLOR_BLACK;
+ }
}
- if (fg_color == PRCOLOR_WHITE)
+ if (fg_color == PRCOLOR_WHITE) {
fg_color = PRCOLOR_BLACK;
- else if (*p_bg == 'd')
+ } else if (*p_bg == 'd') {
fg_color = darken_rgb(fg_color);
+ }
pattr->fg_color = fg_color;
pattr->bg_color = PRCOLOR_WHITE;
@@ -432,8 +437,7 @@ static void prt_set_bg(uint32_t bg)
}
}
-static void prt_set_font(const TriState bold, const TriState italic,
- const TriState underline)
+static void prt_set_font(const TriState bold, const TriState italic, const TriState underline)
{
if (curr_bold != bold
|| curr_italic != italic
@@ -446,8 +450,8 @@ static void prt_set_font(const TriState bold, const TriState italic,
}
// Print the line number in the left margin.
-static void prt_line_number(prt_settings_T *const psettings,
- const int page_line, const linenr_T lnum)
+static void prt_line_number(prt_settings_T *const psettings, const int page_line,
+ const linenr_T lnum)
{
prt_set_fg(psettings->number.fg_color);
prt_set_bg(psettings->number.bg_color);
@@ -504,18 +508,19 @@ int prt_get_unit(int idx)
int i;
static char *(units[4]) = PRT_UNIT_NAMES;
- if (printer_opts[idx].present)
- for (i = 0; i < 4; ++i)
+ if (printer_opts[idx].present) {
+ for (i = 0; i < 4; ++i) {
if (STRNICMP(printer_opts[idx].string, units[i], 2) == 0) {
u = i;
break;
}
+ }
+ }
return u;
}
// Print the page header.
-static void prt_header(prt_settings_T *const psettings, const int pagenum,
- const linenr_T lnum)
+static void prt_header(prt_settings_T *const psettings, const int pagenum, const linenr_T lnum)
{
int width = psettings->chars_per_line;
@@ -548,8 +553,8 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum,
use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0);
build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
- p_header, use_sandbox,
- ' ', width, NULL, NULL);
+ p_header, use_sandbox,
+ ' ', width, NULL, NULL);
// Reset line numbers
curwin->w_cursor.lnum = tmp_lnum;
@@ -616,17 +621,19 @@ void ex_hardcopy(exarg_T *eap)
settings.has_color = TRUE;
if (*eap->arg == '>') {
- char_u *errormsg = NULL;
+ char_u *errormsg = NULL;
// Expand things like "%.ps".
if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL) {
- if (errormsg != NULL)
+ if (errormsg != NULL) {
EMSG(errormsg);
+ }
return;
}
settings.outfile = skipwhite(eap->arg + 1);
- } else if (*eap->arg != NUL)
+ } else if (*eap->arg != NUL) {
settings.arguments = eap->arg;
+ }
/*
* Initialise for printing. Ask the user for settings, unless forceit is
@@ -636,24 +643,26 @@ void ex_hardcopy(exarg_T *eap)
* PS.)
*/
if (mch_print_init(&settings,
- curbuf->b_fname == NULL
+ curbuf->b_fname == NULL
? (char_u *)buf_spname(curbuf)
: curbuf->b_sfname == NULL
? curbuf->b_fname
: curbuf->b_sfname,
- eap->forceit) == FAIL)
+ eap->forceit) == FAIL) {
return;
+ }
settings.modec = 'c';
- if (!syntax_present(curwin))
+ if (!syntax_present(curwin)) {
settings.do_syntax = FALSE;
- else if (printer_opts[OPT_PRINT_SYNTAX].present
- && TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) != 'a')
+ } else if (printer_opts[OPT_PRINT_SYNTAX].present
+ && TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) != 'a') {
settings.do_syntax =
(TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) == 'y');
- else
+ } else {
settings.do_syntax = settings.has_color;
+ }
// Set up printing attributes for line numbers
settings.number.fg_color = PRCOLOR_BLACK;
@@ -675,8 +684,9 @@ void ex_hardcopy(exarg_T *eap)
/*
* Estimate the total lines to be printed
*/
- for (lnum = eap->line1; lnum <= eap->line2; lnum++)
+ for (lnum = eap->line1; lnum <= eap->line2; lnum++) {
bytes_to_print += STRLEN(skipwhite(ml_get(lnum)));
+ }
if (bytes_to_print == 0) {
MSG(_("No text to be printed"));
goto print_fail_no_begin;
@@ -697,8 +707,9 @@ void ex_hardcopy(exarg_T *eap)
jobsplit = (printer_opts[OPT_PRINT_JOBSPLIT].present
&& TOLOWER_ASC(printer_opts[OPT_PRINT_JOBSPLIT].string[0]) == 'y');
- if (!mch_print_begin(&settings))
+ if (!mch_print_begin(&settings)) {
goto print_fail_no_begin;
+ }
/*
* Loop over collated copies: 1 2 3, 1 2 3, ...
@@ -718,8 +729,9 @@ void ex_hardcopy(exarg_T *eap)
if (jobsplit && collated_copies > 0) {
// Splitting jobs: Stop a previous job and start a new one.
mch_print_end(&settings);
- if (!mch_print_begin(&settings))
+ if (!mch_print_begin(&settings)) {
goto print_fail_no_begin;
+ }
}
/*
@@ -746,34 +758,38 @@ void ex_hardcopy(exarg_T *eap)
// Check for interrupt character every page.
os_breakcheck();
- if (got_int || settings.user_abort)
+ if (got_int || settings.user_abort) {
goto print_fail;
+ }
assert(prtpos.bytes_printed <= SIZE_MAX / 100);
sprintf((char *)IObuff, _("Printing page %d (%zu%%)"),
page_count + 1 + side,
prtpos.bytes_printed * 100 / bytes_to_print);
- if (!mch_print_begin_page(IObuff))
+ if (!mch_print_begin_page(IObuff)) {
goto print_fail;
+ }
- if (settings.n_collated_copies > 1)
+ if (settings.n_collated_copies > 1) {
sprintf((char *)IObuff + STRLEN(IObuff),
- _(" Copy %d of %d"),
- collated_copies + 1,
- settings.n_collated_copies);
+ _(" Copy %d of %d"),
+ collated_copies + 1,
+ settings.n_collated_copies);
+ }
prt_message(IObuff);
/*
* Output header if required
*/
- if (prt_header_height() > 0)
+ if (prt_header_height() > 0) {
prt_header(&settings, page_count + 1 + side,
- prtpos.file_line);
+ prtpos.file_line);
+ }
for (page_line = 0; page_line < settings.lines_per_page;
++page_line) {
prtpos.column = hardcopy_line(&settings,
- page_line, &prtpos);
+ page_line, &prtpos);
if (prtpos.column == 0) {
// finished a file line
prtpos.bytes_printed +=
@@ -803,19 +819,21 @@ void ex_hardcopy(exarg_T *eap)
if (prtpos.file_line > eap->line2 && settings.duplex
&& side == 0
&& uncollated_copies + 1 < settings.n_uncollated_copies) {
- if (!mch_print_blank_page())
+ if (!mch_print_blank_page()) {
goto print_fail;
+ }
}
}
- if (settings.duplex && prtpos.file_line <= eap->line2)
+ if (settings.duplex && prtpos.file_line <= eap->line2) {
++page_count;
+ }
// Remember the position where the next page starts.
page_prtpos = prtpos;
}
vim_snprintf((char *)IObuff, IOSIZE, _("Printed: %s"),
- settings.jobname);
+ settings.jobname);
prt_message(IObuff);
}
@@ -837,7 +855,7 @@ print_fail_no_begin:
static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T *ppos)
{
colnr_T col;
- char_u *line;
+ char_u *line;
int need_break = FALSE;
int outputlen;
int tab_spaces;
@@ -848,8 +866,9 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
if (ppos->column == 0 || ppos->ff) {
print_pos = 0;
tab_spaces = 0;
- if (!ppos->ff && prt_use_number())
+ if (!ppos->ff && prt_use_number()) {
prt_line_number(psettings, page_line, ppos->file_line);
+ }
ppos->ff = FALSE;
} else {
// left over from wrap halfway through a tab
@@ -870,10 +889,11 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
// syntax highlighting stuff.
if (psettings->do_syntax) {
id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE);
- if (id > 0)
+ if (id > 0) {
id = syn_get_final_id(id);
- else
+ } else {
id = 0;
+ }
// Get the line again, a multi-line regexp may invalidate it.
line = ml_get(ppos->file_line);
@@ -900,8 +920,9 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
need_break = mch_print_text_out((char_u *)" ", 1);
print_pos++;
tab_spaces--;
- if (need_break)
+ if (need_break) {
break;
+ }
}
// Keep the TAB if we didn't finish it.
if (need_break && tab_spaces > 0) {
@@ -930,8 +951,9 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
&& (line[col] == NUL
|| (printer_opts[OPT_PRINT_WRAP].present
&& TOLOWER_ASC(printer_opts[OPT_PRINT_WRAP].string[0])
- == 'n')))
+ == 'n'))) {
return 0;
+ }
return col;
}
@@ -1000,7 +1022,7 @@ static struct prt_ps_font_S prt_ps_courier_font =
600,
-100, 50,
-250, 805,
- {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}
+ { "Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique" }
};
// Generic font metrics for multi-byte fonts
@@ -1009,7 +1031,7 @@ static struct prt_ps_font_S prt_ps_mb_font =
1000,
-100, 50,
-250, 805,
- {NULL, NULL, NULL, NULL}
+ { NULL, NULL, NULL, NULL }
};
// Pointer to current font set being used
@@ -1027,25 +1049,25 @@ static struct prt_ps_font_S *prt_ps_font;
// Japanese encodings and charsets
static struct prt_ps_encoding_S j_encodings[] =
{
- {"iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990|
- CS_NEC)},
- {"euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990)},
- {"sjis", "RKSJ", (CS_JIS_C_1978|CS_JIS_X_1983|CS_MSWINDOWS|
- CS_KANJITALK6|CS_KANJITALK7)},
- {"cp932", "RKSJ", CS_JIS_X_1983},
- {"ucs-2", "UCS2", CS_JIS_X_1990},
- {"utf-8", "UTF8", CS_JIS_X_1990}
+ { "iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990|
+ CS_NEC) },
+ { "euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990) },
+ { "sjis", "RKSJ", (CS_JIS_C_1978|CS_JIS_X_1983|CS_MSWINDOWS|
+ CS_KANJITALK6|CS_KANJITALK7) },
+ { "cp932", "RKSJ", CS_JIS_X_1983 },
+ { "ucs-2", "UCS2", CS_JIS_X_1990 },
+ { "utf-8", "UTF8", CS_JIS_X_1990 }
};
static struct prt_ps_charset_S j_charsets[] =
{
- {"JIS_C_1978", "78", CS_JIS_C_1978},
- {"JIS_X_1983", NULL, CS_JIS_X_1983},
- {"JIS_X_1990", "Hojo", CS_JIS_X_1990},
- {"NEC", "Ext", CS_NEC},
- {"MSWINDOWS", "90ms", CS_MSWINDOWS},
- {"CP932", "90ms", CS_JIS_X_1983},
- {"KANJITALK6", "83pv", CS_KANJITALK6},
- {"KANJITALK7", "90pv", CS_KANJITALK7}
+ { "JIS_C_1978", "78", CS_JIS_C_1978 },
+ { "JIS_X_1983", NULL, CS_JIS_X_1983 },
+ { "JIS_X_1990", "Hojo", CS_JIS_X_1990 },
+ { "NEC", "Ext", CS_NEC },
+ { "MSWINDOWS", "90ms", CS_MSWINDOWS },
+ { "CP932", "90ms", CS_JIS_X_1983 },
+ { "KANJITALK6", "83pv", CS_KANJITALK6 },
+ { "KANJITALK7", "90pv", CS_KANJITALK7 }
};
#define CS_GB_2312_80 (0x01)
@@ -1059,23 +1081,23 @@ static struct prt_ps_charset_S j_charsets[] =
// Simplified Chinese encodings and charsets
static struct prt_ps_encoding_S sc_encodings[] =
{
- {"iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90)},
- {"gb18030", NULL, CS_GBK2K},
- {"euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC|
- CS_GBT_90_MAC)},
- {"gbk", "EUC", CS_GBK},
- {"ucs-2", "UCS2", CS_SC_ISO10646},
- {"utf-8", "UTF8", CS_SC_ISO10646}
+ { "iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90) },
+ { "gb18030", NULL, CS_GBK2K },
+ { "euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC|
+ CS_GBT_90_MAC) },
+ { "gbk", "EUC", CS_GBK },
+ { "ucs-2", "UCS2", CS_SC_ISO10646 },
+ { "utf-8", "UTF8", CS_SC_ISO10646 }
};
static struct prt_ps_charset_S sc_charsets[] =
{
- {"GB_2312-80", "GB", CS_GB_2312_80},
- {"GBT_12345-90","GBT", CS_GBT_12345_90},
- {"MAC", "GBpc", CS_SC_MAC},
- {"GBT-90_MAC", "GBTpc", CS_GBT_90_MAC},
- {"GBK", "GBK", CS_GBK},
- {"GB18030", "GBK2K", CS_GBK2K},
- {"ISO10646", "UniGB", CS_SC_ISO10646}
+ { "GB_2312-80", "GB", CS_GB_2312_80 },
+ { "GBT_12345-90", "GBT", CS_GBT_12345_90 },
+ { "MAC", "GBpc", CS_SC_MAC },
+ { "GBT-90_MAC", "GBTpc", CS_GBT_90_MAC },
+ { "GBK", "GBK", CS_GBK },
+ { "GB18030", "GBK2K", CS_GBK2K },
+ { "ISO10646", "UniGB", CS_SC_ISO10646 }
};
#define CS_CNS_PLANE_1 (0x01)
@@ -1095,33 +1117,33 @@ static struct prt_ps_charset_S sc_charsets[] =
// Traditional Chinese encodings and charsets
static struct prt_ps_encoding_S tc_encodings[] =
{
- {"iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2)},
- {"euc-tw", "EUC", CS_CNS_PLANE_1_2},
- {"big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS|
- CS_HK_SCS_ETEN|CS_MTHKL|CS_MTHKS|CS_DLHKL|
- CS_DLHKS)},
- {"cp950", "B5", CS_B5},
- {"ucs-2", "UCS2", CS_TC_ISO10646},
- {"utf-8", "UTF8", CS_TC_ISO10646},
- {"utf-16", "UTF16", CS_TC_ISO10646},
- {"utf-32", "UTF32", CS_TC_ISO10646}
+ { "iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2) },
+ { "euc-tw", "EUC", CS_CNS_PLANE_1_2 },
+ { "big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS|
+ CS_HK_SCS_ETEN|CS_MTHKL|CS_MTHKS|CS_DLHKL|
+ CS_DLHKS) },
+ { "cp950", "B5", CS_B5 },
+ { "ucs-2", "UCS2", CS_TC_ISO10646 },
+ { "utf-8", "UTF8", CS_TC_ISO10646 },
+ { "utf-16", "UTF16", CS_TC_ISO10646 },
+ { "utf-32", "UTF32", CS_TC_ISO10646 }
};
static struct prt_ps_charset_S tc_charsets[] =
{
- {"CNS_1992_1", "CNS1", CS_CNS_PLANE_1},
- {"CNS_1992_2", "CNS2", CS_CNS_PLANE_2},
- {"CNS_1993", "CNS", CS_CNS_PLANE_1_2},
- {"BIG5", NULL, CS_B5},
- {"CP950", NULL, CS_B5},
- {"ETEN", "ETen", CS_ETEN},
- {"HK_GCCS", "HKgccs", CS_HK_GCCS},
- {"SCS", "HKscs", CS_HK_SCS},
- {"SCS_ETEN", "ETHK", CS_HK_SCS_ETEN},
- {"MTHKL", "HKm471", CS_MTHKL},
- {"MTHKS", "HKm314", CS_MTHKS},
- {"DLHKL", "HKdla", CS_DLHKL},
- {"DLHKS", "HKdlb", CS_DLHKS},
- {"ISO10646", "UniCNS", CS_TC_ISO10646}
+ { "CNS_1992_1", "CNS1", CS_CNS_PLANE_1 },
+ { "CNS_1992_2", "CNS2", CS_CNS_PLANE_2 },
+ { "CNS_1993", "CNS", CS_CNS_PLANE_1_2 },
+ { "BIG5", NULL, CS_B5 },
+ { "CP950", NULL, CS_B5 },
+ { "ETEN", "ETen", CS_ETEN },
+ { "HK_GCCS", "HKgccs", CS_HK_GCCS },
+ { "SCS", "HKscs", CS_HK_SCS },
+ { "SCS_ETEN", "ETHK", CS_HK_SCS_ETEN },
+ { "MTHKL", "HKm471", CS_MTHKL },
+ { "MTHKS", "HKm314", CS_MTHKS },
+ { "DLHKL", "HKdla", CS_DLHKL },
+ { "DLHKS", "HKdlb", CS_DLHKS },
+ { "ISO10646", "UniCNS", CS_TC_ISO10646 }
};
#define CS_KR_X_1992 (0x01)
@@ -1132,24 +1154,24 @@ static struct prt_ps_charset_S tc_charsets[] =
// Korean encodings and charsets
static struct prt_ps_encoding_S k_encodings[] =
{
- {"iso-2022-kr", NULL, CS_KR_X_1992},
- {"euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC)},
- {"johab", "Johab", CS_KR_X_1992},
- {"cp1361", "Johab", CS_KR_X_1992},
- {"uhc", "UHC", CS_KR_X_1992_MS},
- {"cp949", "UHC", CS_KR_X_1992_MS},
- {"ucs-2", "UCS2", CS_KR_ISO10646},
- {"utf-8", "UTF8", CS_KR_ISO10646}
+ { "iso-2022-kr", NULL, CS_KR_X_1992 },
+ { "euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC) },
+ { "johab", "Johab", CS_KR_X_1992 },
+ { "cp1361", "Johab", CS_KR_X_1992 },
+ { "uhc", "UHC", CS_KR_X_1992_MS },
+ { "cp949", "UHC", CS_KR_X_1992_MS },
+ { "ucs-2", "UCS2", CS_KR_ISO10646 },
+ { "utf-8", "UTF8", CS_KR_ISO10646 }
};
static struct prt_ps_charset_S k_charsets[] =
{
- {"KS_X_1992", "KSC", CS_KR_X_1992},
- {"CP1361", "KSC", CS_KR_X_1992},
- {"MAC", "KSCpc", CS_KR_MAC},
- {"MSWINDOWS", "KSCms", CS_KR_X_1992_MS},
- {"CP949", "KSCms", CS_KR_X_1992_MS},
- {"WANSUNG", "KSCms", CS_KR_X_1992_MS},
- {"ISO10646", "UniKS", CS_KR_ISO10646}
+ { "KS_X_1992", "KSC", CS_KR_X_1992 },
+ { "CP1361", "KSC", CS_KR_X_1992 },
+ { "MAC", "KSCpc", CS_KR_MAC },
+ { "MSWINDOWS", "KSCms", CS_KR_X_1992_MS },
+ { "CP949", "KSCms", CS_KR_X_1992_MS },
+ { "WANSUNG", "KSCms", CS_KR_X_1992_MS },
+ { "ISO10646", "UniKS", CS_KR_ISO10646 }
};
static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
@@ -1196,7 +1218,7 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
*
* VIM Prolog CIDProlog
* 6.2 1.3
- * 7.0 1.4 1.0
+ * 7.0 1.4 1.0
*/
#define PRT_PROLOG_VERSION ((char_u *)"1.4")
#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
@@ -1224,11 +1246,11 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
#define SIZEOF_CSTR(s) (sizeof(s) - 1)
static struct prt_dsc_comment_S prt_dsc_table[] =
{
- {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE},
- {PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION),
- PRT_DSC_VERSION_TYPE},
- {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS),
- PRT_DSC_ENDCOMMENTS_TYPE}
+ { PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE },
+ { PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION),
+ PRT_DSC_VERSION_TYPE },
+ { PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS),
+ PRT_DSC_ENDCOMMENTS_TYPE }
};
@@ -1359,14 +1381,15 @@ static void prt_write_boolean(int b)
static void prt_def_font(char *new_name, char *encoding, int height, char *font)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
+ "/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
prt_write_file(prt_line_buffer);
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n",
- new_name, height, 500./prt_ps_courier_font.wx, new_name);
- else
+ new_name, height, 500./prt_ps_courier_font.wx, new_name);
+ } else {
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/%s %d /_%s ffs\n", new_name, height, new_name);
+ "/%s %d /_%s ffs\n", new_name, height, new_name);
+ }
prt_write_file(prt_line_buffer);
}
@@ -1376,10 +1399,10 @@ static void prt_def_font(char *new_name, char *encoding, int height, char *font)
static void prt_def_cidfont(char *new_name, int height, char *cidfont)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
+ "/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
prt_write_file(prt_line_buffer);
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/%s %d /_%s ffs\n", new_name, height, new_name);
+ "/%s %d /_%s ffs\n", new_name, height, new_name);
prt_write_file(prt_line_buffer);
}
@@ -1389,7 +1412,7 @@ static void prt_def_cidfont(char *new_name, int height, char *cidfont)
static void prt_dup_cidfont(char *original_name, char *new_name)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/%s %s d\n", new_name, original_name);
+ "/%s %s d\n", new_name, original_name);
prt_write_file(prt_line_buffer);
}
@@ -1402,10 +1425,12 @@ static void prt_real_bits(double real, int precision, int *pinteger, int *pfract
{
int integer = (int)real;
double fraction = real - integer;
- if (real < integer)
+ if (real < integer) {
fraction = -fraction;
- for (int i = 0; i < precision; i++)
+ }
+ for (int i = 0; i < precision; i++) {
fraction *= 10.0;
+ }
*pinteger = integer;
*pfraction = (int)(fraction + 0.5);
@@ -1447,7 +1472,7 @@ static void prt_write_real(double val, int prec)
static void prt_def_var(char *name, double value, int prec)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "/%s ", name);
+ "/%s ", name);
prt_write_file(prt_line_buffer);
prt_write_real(value, prec);
sprintf((char *)prt_line_buffer, "d\n");
@@ -1500,16 +1525,18 @@ static void prt_flush_buffer(void)
prt_write_string("ul\n");
}
// Draw the text
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
prt_write_string("<");
- else
+ } else {
prt_write_string("(");
+ }
assert(prt_ps_buffer.ga_len >= 0);
prt_write_file_raw_len(prt_ps_buffer.ga_data, (size_t)prt_ps_buffer.ga_len);
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
prt_write_string(">");
- else
+ } else {
prt_write_string(")");
+ }
// Add a moveto if need be and use the appropriate show procedure
if (prt_do_moveto) {
prt_write_real(prt_pos_x_moveto, 2);
@@ -1529,15 +1556,16 @@ static void prt_resource_name(char_u *filename, void *cookie)
{
char_u *resource_filename = cookie;
- if (STRLEN(filename) >= MAXPATHL)
+ if (STRLEN(filename) >= MAXPATHL) {
*resource_filename = NUL;
- else
+ } else {
STRCPY(resource_filename, filename);
+ }
}
static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
{
- char_u *buffer;
+ char_u *buffer;
int retval;
buffer = xmallocz(MAXPATHL);
@@ -1568,15 +1596,17 @@ static int prt_resfile_next_line(void)
// Move to start of next line and then find end of line
idx = prt_resfile.line_end + 1;
while (idx < prt_resfile.len) {
- if (prt_resfile.buffer[idx] != PSLF && prt_resfile.buffer[idx] != PSCR)
+ if (prt_resfile.buffer[idx] != PSLF && prt_resfile.buffer[idx] != PSCR) {
break;
+ }
idx++;
}
prt_resfile.line_start = idx;
while (idx < prt_resfile.len) {
- if (prt_resfile.buffer[idx] == PSLF || prt_resfile.buffer[idx] == PSCR)
+ if (prt_resfile.buffer[idx] == PSLF || prt_resfile.buffer[idx] == PSCR) {
break;
+ }
idx++;
}
prt_resfile.line_end = idx;
@@ -1592,7 +1622,7 @@ static int prt_resfile_strncmp(int offset, const char *string, int len)
return 1;
}
return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset],
- string, len);
+ string, len);
}
static int prt_resfile_skip_nonws(int offset)
@@ -1601,8 +1631,9 @@ static int prt_resfile_skip_nonws(int offset)
idx = prt_resfile.line_start + offset;
while (idx < prt_resfile.line_end) {
- if (isspace(prt_resfile.buffer[idx]))
+ if (isspace(prt_resfile.buffer[idx])) {
return idx - prt_resfile.line_start;
+ }
idx++;
}
return -1;
@@ -1614,8 +1645,9 @@ static int prt_resfile_skip_ws(int offset)
idx = prt_resfile.line_start + offset;
while (idx < prt_resfile.line_end) {
- if (!isspace(prt_resfile.buffer[idx]))
+ if (!isspace(prt_resfile.buffer[idx])) {
return idx - prt_resfile.line_start;
+ }
idx++;
}
return -1;
@@ -1685,10 +1717,10 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource)
// Parse first line to ensure valid resource file
prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u),
- PRT_FILE_BUFFER_LEN, fd_resource);
+ PRT_FILE_BUFFER_LEN, fd_resource);
if (ferror(fd_resource)) {
EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
- resource->filename);
+ resource->filename);
fclose(fd_resource);
return false;
}
@@ -1702,7 +1734,7 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource)
int offset = 0;
if (prt_resfile_strncmp(offset, PRT_RESOURCE_HEADER,
- (int)STRLEN(PRT_RESOURCE_HEADER)) != 0) {
+ (int)STRLEN(PRT_RESOURCE_HEADER)) != 0) {
EMSG2(_("E618: file \"%s\" is not a PostScript resource file"),
resource->filename);
return false;
@@ -1719,7 +1751,7 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource)
return false;
}
if (prt_resfile_strncmp(offset, PRT_RESOURCE_RESOURCE,
- (int)STRLEN(PRT_RESOURCE_RESOURCE)) != 0) {
+ (int)STRLEN(PRT_RESOURCE_RESOURCE)) != 0) {
EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
resource->filename);
return false;
@@ -1786,8 +1818,7 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource)
return true;
}
-static bool prt_check_resource(const struct prt_ps_resource_S *resource,
- const char_u *version)
+static bool prt_check_resource(const struct prt_ps_resource_S *resource, const char_u *version)
FUNC_ATTR_NONNULL_ALL
{
// Version number m.n should match, the revision number does not matter
@@ -1809,14 +1840,14 @@ static void prt_dsc_start(void)
static void prt_dsc_noarg(char *comment)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%%s\n", comment);
+ "%%%%%s\n", comment);
prt_write_file(prt_line_buffer);
}
static void prt_dsc_textline(char *comment, char *text)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%%s: %s\n", comment, text);
+ "%%%%%s: %s\n", comment, text);
prt_write_file(prt_line_buffer);
}
@@ -1824,7 +1855,7 @@ static void prt_dsc_text(char *comment, char *text)
{
// TODO(vim): - should scan 'text' for any chars needing escaping!
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%%s: (%s)\n", comment, text);
+ "%%%%%s: (%s)\n", comment, text);
prt_write_file(prt_line_buffer);
}
@@ -1835,7 +1866,7 @@ static void prt_dsc_ints(char *comment, int count, int *ints)
int i;
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%%s:", comment);
+ "%%%%%s:", comment);
prt_write_file(prt_line_buffer);
for (i = 0; i < count; i++) {
@@ -1846,23 +1877,21 @@ static void prt_dsc_ints(char *comment, int count, int *ints)
prt_write_string("\n");
}
-static void prt_dsc_resources(
- const char *comment, // if NULL add to previous
- const char *type,
- const char *string
-)
+/// @param comment if NULL add to previous
+static void prt_dsc_resources(const char *comment, const char *type, const char *string)
FUNC_ATTR_NONNULL_ARG(2, 3)
{
- if (comment != NULL)
+ if (comment != NULL) {
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%%s: %s", comment, type);
- else
+ "%%%%%s: %s", comment, type);
+ } else {
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%+ %s", type);
+ "%%%%+ %s", type);
+ }
prt_write_file(prt_line_buffer);
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- " %s\n", string);
+ " %s\n", string);
prt_write_file(prt_line_buffer);
}
@@ -1871,10 +1900,12 @@ static void prt_dsc_font_resource(char *resource, struct prt_ps_font_S *ps_font)
int i;
prt_dsc_resources(resource, "font",
- ps_font->ps_fontname[PRT_PS_FONT_ROMAN]);
- for (i = PRT_PS_FONT_BOLD; i <= PRT_PS_FONT_BOLDOBLIQUE; i++)
- if (ps_font->ps_fontname[i] != NULL)
+ ps_font->ps_fontname[PRT_PS_FONT_ROMAN]);
+ for (i = PRT_PS_FONT_BOLD; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) {
+ if (ps_font->ps_fontname[i] != NULL) {
prt_dsc_resources(NULL, "font", ps_font->ps_fontname[i]);
+ }
+ }
}
static void prt_dsc_requirements(int duplex, int tumble, int collate, int color, int num_copies)
@@ -1882,21 +1913,25 @@ static void prt_dsc_requirements(int duplex, int tumble, int collate, int color,
/* Only output the comment if we need to.
* Note: tumble is ignored if we are not duplexing
*/
- if (!(duplex || collate || color || (num_copies > 1)))
+ if (!(duplex || collate || color || (num_copies > 1))) {
return;
+ }
sprintf((char *)prt_line_buffer, "%%%%Requirements:");
prt_write_file(prt_line_buffer);
if (duplex) {
prt_write_string(" duplex");
- if (tumble)
+ if (tumble) {
prt_write_string("(tumble)");
+ }
}
- if (collate)
+ if (collate) {
prt_write_string(" collate");
- if (color)
+ }
+ if (color) {
prt_write_string(" color");
+ }
if (num_copies > 1) {
prt_write_string(" numcopies(");
// Note: no space wanted so don't use prt_write_int()
@@ -1908,23 +1943,26 @@ static void prt_dsc_requirements(int duplex, int tumble, int collate, int color,
prt_write_string("\n");
}
-static void prt_dsc_docmedia(char *paper_name, double width, double height, double weight, char *colour, char *type)
+static void prt_dsc_docmedia(char *paper_name, double width, double height, double weight,
+ char *colour, char *type)
{
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
- "%%%%DocumentMedia: %s ", paper_name);
+ "%%%%DocumentMedia: %s ", paper_name);
prt_write_file(prt_line_buffer);
prt_write_real(width, 2);
prt_write_real(height, 2);
prt_write_real(weight, 2);
- if (colour == NULL)
+ if (colour == NULL) {
prt_write_string("()");
- else
+ } else {
prt_write_string(colour);
+ }
prt_write_string(" ");
- if (type == NULL)
+ if (type == NULL) {
prt_write_string("()");
- else
+ } else {
prt_write_string(type);
+ }
prt_write_string("\n");
}
@@ -1938,8 +1976,9 @@ void mch_print_cleanup(void)
* one style).
*/
for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) {
- if (prt_ps_mb_font.ps_fontname[i] != NULL)
+ if (prt_ps_mb_font.ps_fontname[i] != NULL) {
xfree(prt_ps_mb_font.ps_fontname[i]);
+ }
prt_ps_mb_font.ps_fontname[i] = NULL;
}
}
@@ -1993,7 +2032,8 @@ static double to_device_units(int idx, double physsize, int def_number)
/*
* Calculate margins for given width and height from printoptions settings.
*/
-static void prt_page_margins(double width, double height, double *left, double *right, double *top, double *bottom)
+static void prt_page_margins(double width, double height, double *left, double *right, double *top,
+ double *bottom)
{
*left = to_device_units(OPT_PRINT_LEFT, width, 10);
*right = width - to_device_units(OPT_PRINT_RIGHT, width, 5);
@@ -2015,11 +2055,13 @@ static int prt_get_cpl(void)
/* If we are outputting multi-byte characters then line numbers will be
* printed with half width characters
*/
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
prt_number_width /= 2;
+ }
prt_left_margin += prt_number_width;
- } else
+ } else {
prt_number_width = 0.0;
+ }
return (int)((prt_right_margin - prt_left_margin) / prt_char_width);
}
@@ -2044,11 +2086,11 @@ static int prt_get_lpp(void)
* case where the font height can exceed the line height.
*/
prt_bgcol_offset = PRT_PS_FONT_TO_USER(prt_line_height,
- prt_ps_font->bbox_min_y);
+ prt_ps_font->bbox_min_y);
if ((prt_ps_font->bbox_max_y - prt_ps_font->bbox_min_y) < 1000.0) {
prt_bgcol_offset -= PRT_PS_FONT_TO_USER(prt_line_height,
- (1000.0 - (prt_ps_font->bbox_max_y -
- prt_ps_font->bbox_min_y)) / 2);
+ (1000.0 - (prt_ps_font->bbox_max_y -
+ prt_ps_font->bbox_min_y)) / 2);
}
// Get height for topmost line based on background rect offset.
@@ -2063,11 +2105,12 @@ static int prt_get_lpp(void)
return lpp - prt_header_height();
}
-static int prt_match_encoding(char *p_encoding, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_encoding_S **pp_mbenc)
+static int prt_match_encoding(char *p_encoding, struct prt_ps_mbfont_S *p_cmap,
+ struct prt_ps_encoding_S **pp_mbenc)
{
int mbenc;
int enc_len;
- struct prt_ps_encoding_S *p_mbenc;
+ struct prt_ps_encoding_S *p_mbenc;
*pp_mbenc = NULL;
// Look for recognised encoding
@@ -2083,7 +2126,8 @@ static int prt_match_encoding(char *p_encoding, struct prt_ps_mbfont_S *p_cmap,
return FALSE;
}
-static int prt_match_charset(char *p_charset, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_charset_S **pp_mbchar)
+static int prt_match_charset(char *p_charset, struct prt_ps_mbfont_S *p_cmap,
+ struct prt_ps_charset_S **pp_mbchar)
{
int mbchar;
int char_len;
@@ -2108,24 +2152,25 @@ static int prt_match_charset(char *p_charset, struct prt_ps_mbfont_S *p_cmap, st
int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
{
int i;
- char *paper_name;
+ char *paper_name;
int paper_strlen;
int fontsize;
- char_u *p;
+ char_u *p;
int props;
int cmap = 0;
- char_u *p_encoding;
+ char_u *p_encoding;
struct prt_ps_encoding_S *p_mbenc;
struct prt_ps_encoding_S *p_mbenc_first;
- struct prt_ps_charset_S *p_mbchar = NULL;
+ struct prt_ps_charset_S *p_mbchar = NULL;
/*
* Set up font and encoding.
*/
p_encoding = enc_skip(p_penc);
- if (*p_encoding == NUL)
+ if (*p_encoding == NUL) {
p_encoding = enc_skip(p_enc);
+ }
/* Look for a multi-byte font that matches the encoding and character set.
* Only look if multi-byte character set is defined, or using multi-byte
@@ -2136,16 +2181,18 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) {
p_mbenc_first = NULL;
int effective_cmap = 0;
- for (cmap = 0; cmap < (int)ARRAY_SIZE(prt_ps_mbfonts); cmap++)
+ for (cmap = 0; cmap < (int)ARRAY_SIZE(prt_ps_mbfonts); cmap++) {
if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
&p_mbenc)) {
if (p_mbenc_first == NULL) {
p_mbenc_first = p_mbenc;
effective_cmap = cmap;
}
- if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap], &p_mbchar))
+ if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap], &p_mbchar)) {
break;
+ }
}
+ }
// Use first encoding matched if no charset matched
if (p_mbenc_first != NULL && p_mbchar == NULL) {
@@ -2205,7 +2252,6 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
prt_build_cid_fontname(PRT_PS_FONT_BOLD,
mbfont_opts[OPT_MBFONT_BOLD].string,
mbfont_opts[OPT_MBFONT_BOLD].strlen);
-
}
if (mbfont_opts[OPT_MBFONT_OBLIQUE].present) {
prt_build_cid_fontname(PRT_PS_FONT_OBLIQUE,
@@ -2221,8 +2267,8 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
// Check if need to use Courier for ASCII code range, and if so pick up
// the encoding to use
prt_use_courier = (
- mbfont_opts[OPT_MBFONT_USECOURIER].present
- && (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y'));
+ mbfont_opts[OPT_MBFONT_USECOURIER].present
+ && (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y'));
if (prt_use_courier) {
// Use national ASCII variant unless ASCII wanted
if (mbfont_opts[OPT_MBFONT_ASCII].present
@@ -2252,13 +2298,16 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
paper_name = "A4";
paper_strlen = 2;
}
- for (i = 0; i < (int)PRT_MEDIASIZE_LEN; ++i)
+ for (i = 0; i < (int)PRT_MEDIASIZE_LEN; ++i) {
if (STRLEN(prt_mediasize[i].name) == (unsigned)paper_strlen
&& STRNICMP(prt_mediasize[i].name, paper_name,
- paper_strlen) == 0)
+ paper_strlen) == 0) {
break;
- if (i == PRT_MEDIASIZE_LEN)
+ }
+ }
+ if (i == PRT_MEDIASIZE_LEN) {
i = 0;
+ }
prt_media = i;
/*
@@ -2280,7 +2329,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
// needs to be done before the cpl and lpp are calculated.
double left, right, top, bottom;
prt_page_margins(prt_page_width, prt_page_height, &left, &right, &top,
- &bottom);
+ &bottom);
prt_left_margin = left;
prt_right_margin = right;
prt_top_margin = top;
@@ -2290,9 +2339,11 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
* Set up the font size.
*/
fontsize = PRT_PS_DEFAULT_FONTSIZE;
- for (p = p_pfn; (p = vim_strchr(p, ':')) != NULL; ++p)
- if (p[1] == 'h' && ascii_isdigit(p[2]))
+ for (p = p_pfn; (p = vim_strchr(p, ':')) != NULL; ++p) {
+ if (p[1] == 'h' && ascii_isdigit(p[2])) {
fontsize = atoi((char *)p + 2);
+ }
+ }
prt_font_metrics(fontsize);
/*
@@ -2340,8 +2391,9 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
prt_duplex = FALSE;
psettings->duplex = 0;
} else if (STRNICMP(printer_opts[OPT_PRINT_DUPLEX].string, "short", 5)
- == 0)
+ == 0) {
prt_tumble = TRUE;
+ }
}
// For now user abort not supported
@@ -2369,8 +2421,9 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
}
prt_bufsiz = psettings->chars_per_line;
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
prt_bufsiz *= 2;
+ }
ga_init(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz);
prt_page_num = 0;
@@ -2389,7 +2442,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
static int prt_add_resource(struct prt_ps_resource_S *resource)
{
- FILE* fd_resource;
+ FILE * fd_resource;
char_u resource_buffer[512];
size_t bytes_read;
@@ -2403,7 +2456,7 @@ static int prt_add_resource(struct prt_ps_resource_S *resource)
case PRT_RESOURCE_TYPE_ENCODING:
case PRT_RESOURCE_TYPE_CMAP:
prt_dsc_resources("BeginResource", prt_resource_types[resource->type],
- (char *)resource->title);
+ (char *)resource->title);
break;
default:
return FALSE;
@@ -2413,15 +2466,16 @@ static int prt_add_resource(struct prt_ps_resource_S *resource)
for (;; ) {
bytes_read = fread((char *)resource_buffer, sizeof(char_u),
- sizeof(resource_buffer), fd_resource);
+ sizeof(resource_buffer), fd_resource);
if (ferror(fd_resource)) {
EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
- resource->filename);
+ resource->filename);
fclose(fd_resource);
return FALSE;
}
- if (bytes_read == 0)
+ if (bytes_read == 0) {
break;
+ }
prt_write_file_raw_len(resource_buffer, bytes_read);
if (prt_file_error) {
fclose(fd_resource);
@@ -2447,8 +2501,8 @@ int mch_print_begin(prt_settings_T *psettings)
struct prt_ps_resource_S res_prolog;
struct prt_ps_resource_S res_encoding;
char buffer[256];
- char_u *p_encoding;
- char_u *p;
+ char_u *p_encoding;
+ char_u *p;
struct prt_ps_resource_S res_cidfont;
struct prt_ps_resource_S res_cmap;
int retval = FALSE;
@@ -2468,8 +2522,9 @@ int mch_print_begin(prt_settings_T *psettings)
char *p_time = os_ctime(ctime_buf, sizeof(ctime_buf));
// Note: os_ctime() adds a \n so we have to remove it :-(
p = vim_strchr((char_u *)p_time, '\n');
- if (p != NULL)
+ if (p != NULL) {
*p = NUL;
+ }
prt_dsc_textline("CreationDate", p_time);
prt_dsc_textline("DocumentData", "Clean8Bit");
prt_dsc_textline("Orientation", "Portrait");
@@ -2479,8 +2534,8 @@ int mch_print_begin(prt_settings_T *psettings)
* user coordinate system! We have to recalculate right and bottom
* coordinates based on the font metrics for the bbox to be accurate. */
prt_page_margins(prt_mediasize[prt_media].width,
- prt_mediasize[prt_media].height,
- &left, &right, &top, &bottom);
+ prt_mediasize[prt_media].height,
+ &left, &right, &top, &bottom);
bbox[0] = (int)left;
if (prt_portrait) {
/* In portrait printing the fixed point is the top left corner so we
@@ -2515,9 +2570,10 @@ int mch_print_begin(prt_settings_T *psettings)
}
if (prt_out_mbyte) {
prt_dsc_font_resource((prt_use_courier ? NULL
- : "DocumentNeededResources"), &prt_ps_mb_font);
- if (!prt_custom_cmap)
+ : "DocumentNeededResources"), &prt_ps_mb_font);
+ if (!prt_custom_cmap) {
prt_dsc_resources(NULL, "cmap", prt_cmap);
+ }
}
// Search for external resources VIM supplies
@@ -2525,20 +2581,24 @@ int mch_print_begin(prt_settings_T *psettings)
EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\""));
return FALSE;
}
- if (!prt_open_resource(&res_prolog))
+ if (!prt_open_resource(&res_prolog)) {
return FALSE;
- if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION))
+ }
+ if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION)) {
return FALSE;
+ }
if (prt_out_mbyte) {
// Look for required version of multi-byte printing procset
if (!prt_find_resource("cidfont", &res_cidfont)) {
EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\""));
return FALSE;
}
- if (!prt_open_resource(&res_cidfont))
+ if (!prt_open_resource(&res_cidfont)) {
return FALSE;
- if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION))
+ }
+ if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION)) {
return FALSE;
+ }
}
/* Find an encoding to use for printing.
@@ -2562,28 +2622,31 @@ int mch_print_begin(prt_settings_T *psettings)
p_encoding = (char_u *)"latin1";
if (!prt_find_resource((char *)p_encoding, &res_encoding)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
- p_encoding);
+ p_encoding);
return FALSE;
}
}
}
- if (!prt_open_resource(&res_encoding))
+ if (!prt_open_resource(&res_encoding)) {
return FALSE;
+ }
/* For the moment there are no checks on encoding resource files to
* perform */
} else {
p_encoding = enc_skip(p_penc);
- if (*p_encoding == NUL)
+ if (*p_encoding == NUL) {
p_encoding = enc_skip(p_enc);
+ }
if (prt_use_courier) {
// Include ASCII range encoding vector
if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
- prt_ascii_encoding);
+ prt_ascii_encoding);
return FALSE;
}
- if (!prt_open_resource(&res_encoding))
+ if (!prt_open_resource(&res_encoding)) {
return FALSE;
+ }
/* For the moment there are no checks on encoding resource files to
* perform */
}
@@ -2604,11 +2667,12 @@ int mch_print_begin(prt_settings_T *psettings)
// Find user supplied CMap
if (!prt_find_resource(prt_cmap, &res_cmap)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
- prt_cmap);
+ prt_cmap);
return FALSE;
}
- if (!prt_open_resource(&res_cmap))
+ if (!prt_open_resource(&res_cmap)) {
return FALSE;
+ }
}
// List resources supplied
@@ -2636,8 +2700,8 @@ int mch_print_begin(prt_settings_T *psettings)
prt_dsc_resources(NULL, "encoding", buffer);
}
prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate,
- psettings->do_syntax
- , prt_num_copies);
+ psettings->do_syntax
+ , prt_num_copies);
prt_dsc_noarg("EndComments");
/*
@@ -2651,9 +2715,10 @@ int mch_print_begin(prt_settings_T *psettings)
}
if (prt_out_mbyte) {
prt_dsc_font_resource((prt_use_courier ? NULL : "PageResources"),
- &prt_ps_mb_font);
- if (!prt_custom_cmap)
+ &prt_ps_mb_font);
+ if (!prt_custom_cmap) {
prt_dsc_resources(NULL, "cmap", prt_cmap);
+ }
}
// Paper will be used for all pages
@@ -2680,11 +2745,13 @@ int mch_print_begin(prt_settings_T *psettings)
}
}
- if (!prt_out_mbyte || prt_use_courier)
+ if (!prt_out_mbyte || prt_use_courier) {
/* There will be only one Roman font encoding to be included in the PS
* file. */
- if (!prt_add_resource(&res_encoding))
+ if (!prt_add_resource(&res_encoding)) {
return FALSE;
+ }
+ }
prt_dsc_noarg("EndProlog");
@@ -2710,44 +2777,47 @@ int mch_print_begin(prt_settings_T *psettings)
if (!prt_out_mbyte || prt_use_courier) {
/* When using Courier for ASCII range when printing multi-byte, need to
* pick up ASCII encoding to use with it. */
- if (prt_use_courier)
+ if (prt_use_courier) {
p_encoding = (char_u *)prt_ascii_encoding;
+ }
prt_dsc_resources("IncludeResource", "font",
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
prt_def_font("F0", (char *)p_encoding, (int)prt_line_height,
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
prt_dsc_resources("IncludeResource", "font",
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
prt_def_font("F1", (char *)p_encoding, (int)prt_line_height,
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
prt_dsc_resources("IncludeResource", "font",
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
prt_def_font("F2", (char *)p_encoding, (int)prt_line_height,
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
prt_dsc_resources("IncludeResource", "font",
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
prt_def_font("F3", (char *)p_encoding, (int)prt_line_height,
- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
+ prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
}
if (prt_out_mbyte) {
- /* Define the CID fonts to be used in the job. Typically CJKV fonts do
+ /* Define the CID fonts to be used in the job. Typically CJKV fonts do
* not have an italic form being a western style, so where no font is
* defined for these faces VIM falls back to an existing face.
* Note: if using Courier for the ASCII range then the printout will
* have bold/italic/bolditalic regardless of the setting of printmbfont.
*/
prt_dsc_resources("IncludeResource", "font",
- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
- if (!prt_custom_cmap)
+ prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
+ if (!prt_custom_cmap) {
prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
+ }
prt_def_cidfont("CF0", (int)prt_line_height,
- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
+ prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD] != NULL) {
prt_dsc_resources("IncludeResource", "font",
- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
- if (!prt_custom_cmap)
+ prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
+ if (!prt_custom_cmap) {
prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
+ }
prt_def_cidfont("CF1", (int)prt_line_height,
prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
} else {
@@ -2756,9 +2826,10 @@ int mch_print_begin(prt_settings_T *psettings)
}
if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE] != NULL) {
prt_dsc_resources("IncludeResource", "font",
- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
- if (!prt_custom_cmap)
+ prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
+ if (!prt_custom_cmap) {
prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
+ }
prt_def_cidfont("CF2", (int)prt_line_height,
prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
} else {
@@ -2767,9 +2838,10 @@ int mch_print_begin(prt_settings_T *psettings)
}
if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE] != NULL) {
prt_dsc_resources("IncludeResource", "font",
- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
- if (!prt_custom_cmap)
+ prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
+ if (!prt_custom_cmap) {
prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
+ }
prt_def_cidfont("CF3", (int)prt_line_height,
prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
} else {
@@ -2780,9 +2852,9 @@ int mch_print_begin(prt_settings_T *psettings)
// Misc constant vars used for underlining and background rects
prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height,
- prt_ps_font->uline_offset), 2);
+ prt_ps_font->uline_offset), 2);
prt_def_var("UW", PRT_PS_FONT_TO_USER(prt_line_height,
- prt_ps_font->uline_width), 2);
+ prt_ps_font->uline_width), 2);
prt_def_var("BO", prt_bgcol_offset, 2);
prt_dsc_noarg("EndSetup");
@@ -2818,7 +2890,7 @@ void mch_print_end(prt_settings_T *psettings)
prt_message((char_u *)_("Sending to printer..."));
// Not printing to a file: use 'printexpr' to print the file.
- if (eval_printexpr((char *) prt_ps_file_name, (char *) psettings->arguments)
+ if (eval_printexpr((char *)prt_ps_file_name, (char *)psettings->arguments)
== FAIL) {
EMSG(_("E365: Failed to print PostScript file"));
} else {
@@ -2853,10 +2925,11 @@ int mch_print_begin_page(char_u *str)
prt_write_string("sv\n0 g\n");
prt_in_ascii = !prt_out_mbyte;
- if (prt_out_mbyte)
+ if (prt_out_mbyte) {
prt_write_string("CF0 sf\n");
- else
+ } else {
prt_write_string("F0 sf\n");
+ }
prt_fgcol = PRCOLOR_BLACK;
prt_bgcol = PRCOLOR_WHITE;
prt_font = PRT_PS_FONT_ROMAN;
@@ -2983,9 +3056,9 @@ int mch_print_text_out(char_u *const textp, size_t len)
b = prt_fgcol & 0xff;
prt_write_real(r / 255.0, 3);
- if (r == g && g == b)
+ if (r == g && g == b) {
prt_write_string("g\n");
- else {
+ } else {
prt_write_real(g / 255.0, 3);
prt_write_real(b / 255.0, 3);
prt_write_string("r\n");
@@ -3003,8 +3076,9 @@ int mch_print_text_out(char_u *const textp, size_t len)
}
prt_need_bgcol = false;
- if (prt_need_underline)
+ if (prt_need_underline) {
prt_do_underline = prt_underline;
+ }
prt_need_underline = false;
prt_attribute_change = false;
@@ -3042,14 +3116,22 @@ int mch_print_text_out(char_u *const textp, size_t len)
*/
ga_append(&prt_ps_buffer, '\\');
switch (ch) {
- case BS: ga_append(&prt_ps_buffer, 'b'); break;
- case TAB: ga_append(&prt_ps_buffer, 't'); break;
- case NL: ga_append(&prt_ps_buffer, 'n'); break;
- case FF: ga_append(&prt_ps_buffer, 'f'); break;
- case CAR: ga_append(&prt_ps_buffer, 'r'); break;
- case '(': ga_append(&prt_ps_buffer, '('); break;
- case ')': ga_append(&prt_ps_buffer, ')'); break;
- case '\\': ga_append(&prt_ps_buffer, '\\'); break;
+ case BS:
+ ga_append(&prt_ps_buffer, 'b'); break;
+ case TAB:
+ ga_append(&prt_ps_buffer, 't'); break;
+ case NL:
+ ga_append(&prt_ps_buffer, 'n'); break;
+ case FF:
+ ga_append(&prt_ps_buffer, 'f'); break;
+ case CAR:
+ ga_append(&prt_ps_buffer, 'r'); break;
+ case '(':
+ ga_append(&prt_ps_buffer, '('); break;
+ case ')':
+ ga_append(&prt_ps_buffer, ')'); break;
+ case '\\':
+ ga_append(&prt_ps_buffer, '\\'); break;
default:
sprintf((char *)ch_buff, "%03o", (unsigned int)ch);
@@ -3058,8 +3140,9 @@ int mch_print_text_out(char_u *const textp, size_t len)
ga_append(&prt_ps_buffer, (char)ch_buff[2]);
break;
}
- } else
+ } else {
ga_append(&prt_ps_buffer, (char)ch);
+ }
}
// Need to free any translated characters
@@ -3071,7 +3154,7 @@ int mch_print_text_out(char_u *const textp, size_t len)
// The downside of fp - use relative error on right margin check
const double next_pos = prt_pos_x + prt_char_width;
const bool need_break = (next_pos > prt_right_margin)
- && ((next_pos - prt_right_margin) > (prt_right_margin * 1e-5));
+ && ((next_pos - prt_right_margin) > (prt_right_margin * 1e-5));
if (need_break) {
prt_flush_buffer();
@@ -3080,15 +3163,16 @@ int mch_print_text_out(char_u *const textp, size_t len)
return need_break;
}
-void mch_print_set_font(const TriState iBold, const TriState iItalic,
- const TriState iUnderline)
+void mch_print_set_font(const TriState iBold, const TriState iItalic, const TriState iUnderline)
{
int font = 0;
- if (iBold)
+ if (iBold) {
font |= 0x01;
- if (iItalic)
+ }
+ if (iItalic) {
font |= 0x02;
+ }
if (font != prt_font) {
prt_font = font;
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 526bc284a4..a8e5de839a 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -22,15 +22,15 @@
/// memory).
#include <assert.h>
+#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
-#include <inttypes.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/hashtab.h"
-#include "nvim/message.h"
#include "nvim/memory.h"
+#include "nvim/message.h"
+#include "nvim/vim.h"
// Magic value for algorithm that walks through the array.
#define PERTURB_SHIFT 5
@@ -102,8 +102,7 @@ hashitem_T *hash_find(const hashtab_T *const ht, const char_u *const key)
///
/// @warning Returned pointer becomes invalid as soon as the hash table
/// is changed in any way.
-hashitem_T *hash_find_len(const hashtab_T *const ht, const char *const key,
- const size_t len)
+hashitem_T *hash_find_len(const hashtab_T *const ht, const char *const key, const size_t len)
{
return hash_lookup(ht, key, len, hash_hash_len(key, len));
}
@@ -119,8 +118,7 @@ hashitem_T *hash_find_len(const hashtab_T *const ht, const char *const key,
/// used for that key.
/// WARNING: Returned pointer becomes invalid as soon as the hash table
/// is changed in any way.
-hashitem_T *hash_lookup(const hashtab_T *const ht,
- const char *const key, const size_t key_len,
+hashitem_T *hash_lookup(const hashtab_T *const ht, const char *const key, const size_t key_len,
const hash_T hash)
{
#ifdef HT_DEBUG
@@ -336,7 +334,7 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
bool newarray_is_small = newsize == HT_INIT_SIZE;
bool keep_smallarray = newarray_is_small
- && ht->ht_array == ht->ht_smallarray;
+ && ht->ht_array == ht->ht_smallarray;
// Make sure that oldarray and newarray do not overlap,
// so that copying is possible.
@@ -387,7 +385,7 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
}
#define HASH_CYCLE_BODY(hash, p) \
- hash = hash * 101 + *p++
+ hash = hash * 101 + *p++
/// Get the hash number for a key.
///
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 7341ac9393..bb325b3f25 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -3,9 +3,11 @@
// highlight.c: low level code for UI and syntax highlighting
-#include "nvim/vim.h"
+#include "nvim/api/private/defs.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/highlight.h"
#include "nvim/highlight_defs.h"
+#include "nvim/lua/executor.h"
#include "nvim/map.h"
#include "nvim/message.h"
#include "nvim/option.h"
@@ -13,9 +15,7 @@
#include "nvim/screen.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
-#include "nvim/api/private/defs.h"
-#include "nvim/api/private/helpers.h"
-#include "nvim/lua/executor.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "highlight.c.generated.h"
@@ -361,19 +361,19 @@ void update_window_hl(win_T *wp, bool invalid)
int hl_get_underline(void)
{
return get_attr_entry((HlEntry){
- .attr = (HlAttrs){
- .cterm_ae_attr = (int16_t)HL_UNDERLINE,
- .cterm_fg_color = 0,
- .cterm_bg_color = 0,
- .rgb_ae_attr = (int16_t)HL_UNDERLINE,
- .rgb_fg_color = -1,
- .rgb_bg_color = -1,
- .rgb_sp_color = -1,
- .hl_blend = -1,
- },
- .kind = kHlUI,
- .id1 = 0,
- .id2 = 0,
+ .attr = (HlAttrs){
+ .cterm_ae_attr = (int16_t)HL_UNDERLINE,
+ .cterm_fg_color = 0,
+ .cterm_bg_color = 0,
+ .rgb_ae_attr = (int16_t)HL_UNDERLINE,
+ .rgb_fg_color = -1,
+ .rgb_bg_color = -1,
+ .rgb_sp_color = -1,
+ .hl_blend = -1,
+ },
+ .kind = kHlUI,
+ .id1 = 0,
+ .id2 = 0,
});
}
@@ -648,23 +648,23 @@ static int hl_cterm2rgb_color(int nr)
};
static char_u ansi_table[16][4] = {
// R G B idx
- { 0, 0, 0, 1 } , // black
- { 224, 0, 0, 2 } , // dark red
- { 0, 224, 0, 3 } , // dark green
- { 224, 224, 0, 4 } , // dark yellow / brown
- { 0, 0, 224, 5 } , // dark blue
- { 224, 0, 224, 6 } , // dark magenta
- { 0, 224, 224, 7 } , // dark cyan
- { 224, 224, 224, 8 } , // light grey
-
- { 128, 128, 128, 9 } , // dark grey
- { 255, 64, 64, 10 } , // light red
- { 64, 255, 64, 11 } , // light green
- { 255, 255, 64, 12 } , // yellow
- { 64, 64, 255, 13 } , // light blue
- { 255, 64, 255, 14 } , // light magenta
- { 64, 255, 255, 15 } , // light cyan
- { 255, 255, 255, 16 } , // white
+ { 0, 0, 0, 1 }, // black
+ { 224, 0, 0, 2 }, // dark red
+ { 0, 224, 0, 3 }, // dark green
+ { 224, 224, 0, 4 }, // dark yellow / brown
+ { 0, 0, 224, 5 }, // dark blue
+ { 224, 0, 224, 6 }, // dark magenta
+ { 0, 224, 224, 7 }, // dark cyan
+ { 224, 224, 224, 8 }, // light grey
+
+ { 128, 128, 128, 9 }, // dark grey
+ { 255, 64, 64, 10 }, // light red
+ { 64, 255, 64, 11 }, // light green
+ { 255, 255, 64, 12 }, // yellow
+ { 64, 64, 255, 13 }, // light blue
+ { 255, 64, 255, 14 }, // light magenta
+ { 64, 255, 255, 15 }, // light cyan
+ { 255, 255, 255, 16 }, // white
};
int r = 0;
@@ -790,7 +790,7 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb)
}
if (ae.hl_blend > -1) {
- PUT(hl, "blend", INTEGER_OBJ(ae.hl_blend));
+ PUT(hl, "blend", INTEGER_OBJ(ae.hl_blend));
}
return hl;
@@ -847,7 +847,7 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
err)) {
cterm_mask |= flags[m].flag;
}
- break;
+ break;
}
}
}
@@ -915,9 +915,9 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
hlattrs.rgb_fg_color = fg;
hlattrs.rgb_sp_color = sp;
hlattrs.cterm_bg_color =
- ctermbg == -1 ? cterm_normal_bg_color : ctermbg + 1;
+ ctermbg == -1 ? cterm_normal_bg_color : ctermbg + 1;
hlattrs.cterm_fg_color =
- ctermfg == -1 ? cterm_normal_fg_color : ctermfg + 1;
+ ctermfg == -1 ? cterm_normal_fg_color : ctermfg + 1;
hlattrs.cterm_ae_attr = cterm_mask;
} else {
hlattrs.cterm_ae_attr = cterm_mask;
@@ -945,34 +945,34 @@ static void hl_inspect_impl(Array *arr, int attr)
HlEntry e = kv_A(attr_entries, attr);
switch (e.kind) {
- case kHlSyntax:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax")));
- PUT(item, "hi_name",
- STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id1))));
- break;
-
- case kHlUI:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("ui")));
- const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
- PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name)));
- PUT(item, "hi_name",
- STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id2))));
- break;
-
- case kHlTerminal:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("term")));
- break;
-
- case kHlCombine:
- case kHlBlend:
- case kHlBlendThrough:
- // attribute combination is associative, so flatten to an array
- hl_inspect_impl(arr, e.id1);
- hl_inspect_impl(arr, e.id2);
- return;
-
- case kHlUnknown:
- return;
+ case kHlSyntax:
+ PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax")));
+ PUT(item, "hi_name",
+ STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id1))));
+ break;
+
+ case kHlUI:
+ PUT(item, "kind", STRING_OBJ(cstr_to_string("ui")));
+ const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
+ PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name)));
+ PUT(item, "hi_name",
+ STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id2))));
+ break;
+
+ case kHlTerminal:
+ PUT(item, "kind", STRING_OBJ(cstr_to_string("term")));
+ break;
+
+ case kHlCombine:
+ case kHlBlend:
+ case kHlBlendThrough:
+ // attribute combination is associative, so flatten to an array
+ hl_inspect_impl(arr, e.id1);
+ hl_inspect_impl(arr, e.id2);
+ return;
+
+ case kHlUnknown:
+ return;
}
PUT(item, "id", INTEGER_OBJ(attr));
ADD(*arr, DICTIONARY_OBJ(item));
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 609598b678..a3ee3983e5 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -7,13 +7,14 @@
#include "nvim/ascii.h"
#include "nvim/assert.h"
+#include "nvim/buffer.h"
#include "nvim/change.h"
-#include "nvim/indent.h"
-#include "nvim/eval.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
-#include "nvim/mark.h"
+#include "nvim/eval.h"
#include "nvim/extmark.h"
+#include "nvim/indent.h"
+#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/misc1.h"
@@ -25,7 +26,6 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/undo.h"
-#include "nvim/buffer.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -444,8 +444,8 @@ int get_breakindent_win(win_T *wp, char_u *line)
int bri = 0;
// window width minus window margin space, i.e. what rests for text
const int eff_wwidth = wp->w_width_inner
- - ((wp->w_p_nu || wp->w_p_rnu)
- && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
+ - ((wp->w_p_nu || wp->w_p_rnu)
+ && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
// used cached indent, unless pointer or 'tabstop' changed
@@ -510,7 +510,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
// the line.
int inindent(int extra)
{
- char_u *ptr;
+ char_u *ptr;
colnr_T col;
for (col = 0, ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr); ++col) {
@@ -533,15 +533,14 @@ int get_expr_indent(void)
colnr_T save_curswant;
int save_set_curswant;
int save_State;
- int use_sandbox = was_set_insecurely(
- curwin, (char_u *)"indentexpr", OPT_LOCAL);
+ int use_sandbox = was_set_insecurely(curwin, (char_u *)"indentexpr", OPT_LOCAL);
// Save and restore cursor position and curswant, in case it was changed
// * via :normal commands.
save_pos = curwin->w_cursor;
save_curswant = curwin->w_curswant;
save_set_curswant = curwin->w_set_curswant;
- set_vim_var_nr(VV_LNUM, (varnumber_T) curwin->w_cursor.lnum);
+ set_vim_var_nr(VV_LNUM, (varnumber_T)curwin->w_cursor.lnum);
if (use_sandbox) {
sandbox++;
@@ -722,11 +721,11 @@ int get_lisp_indent(void)
quotecount = 0;
if (vi_lisp || ((*that != '"') && (*that != '\'')
- && (*that != '#') && ((*that < '0') || (*that > '9')))) {
+ && (*that != '#') && ((*that < '0') || (*that > '9')))) {
while (*that
&& (!ascii_iswhite(*that) || quotecount || parencount)
&& (!((*that == '(' || *that == '[')
- && !quotecount && !parencount && vi_lisp))) {
+ && !quotecount && !parencount && vi_lisp))) {
if (*that == '"') {
quotecount = !quotecount;
}
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index c6966ff9fa..b724d82f7c 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -5,16 +5,16 @@
#include <inttypes.h>
#include <limits.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/keymap.h"
#include "nvim/charset.h"
-#include "nvim/memory.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
+#include "nvim/keymap.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/strings.h"
#include "nvim/mouse.h"
+#include "nvim/strings.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "keymap.c.generated.h"
@@ -51,48 +51,48 @@ static const struct modmasktable {
static char_u modifier_keys_table[] =
{
- /* mod mask with modifier without modifier */
- MOD_MASK_SHIFT, '&', '9', '@', '1', /* begin */
- MOD_MASK_SHIFT, '&', '0', '@', '2', /* cancel */
- MOD_MASK_SHIFT, '*', '1', '@', '4', /* command */
- MOD_MASK_SHIFT, '*', '2', '@', '5', /* copy */
- MOD_MASK_SHIFT, '*', '3', '@', '6', /* create */
- MOD_MASK_SHIFT, '*', '4', 'k', 'D', /* delete char */
- MOD_MASK_SHIFT, '*', '5', 'k', 'L', /* delete line */
- MOD_MASK_SHIFT, '*', '7', '@', '7', /* end */
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_END, '@', '7', /* end */
- MOD_MASK_SHIFT, '*', '9', '@', '9', /* exit */
- MOD_MASK_SHIFT, '*', '0', '@', '0', /* find */
- MOD_MASK_SHIFT, '#', '1', '%', '1', /* help */
- MOD_MASK_SHIFT, '#', '2', 'k', 'h', /* home */
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_HOME, 'k', 'h', /* home */
- MOD_MASK_SHIFT, '#', '3', 'k', 'I', /* insert */
- MOD_MASK_SHIFT, '#', '4', 'k', 'l', /* left arrow */
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_LEFT, 'k', 'l', /* left arrow */
- MOD_MASK_SHIFT, '%', 'a', '%', '3', /* message */
- MOD_MASK_SHIFT, '%', 'b', '%', '4', /* move */
- MOD_MASK_SHIFT, '%', 'c', '%', '5', /* next */
- MOD_MASK_SHIFT, '%', 'd', '%', '7', /* options */
- MOD_MASK_SHIFT, '%', 'e', '%', '8', /* previous */
- MOD_MASK_SHIFT, '%', 'f', '%', '9', /* print */
- MOD_MASK_SHIFT, '%', 'g', '%', '0', /* redo */
- MOD_MASK_SHIFT, '%', 'h', '&', '3', /* replace */
- MOD_MASK_SHIFT, '%', 'i', 'k', 'r', /* right arr. */
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_RIGHT, 'k', 'r', /* right arr. */
- MOD_MASK_SHIFT, '%', 'j', '&', '5', /* resume */
- MOD_MASK_SHIFT, '!', '1', '&', '6', /* save */
- MOD_MASK_SHIFT, '!', '2', '&', '7', /* suspend */
- MOD_MASK_SHIFT, '!', '3', '&', '8', /* undo */
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_UP, 'k', 'u', /* up arrow */
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_DOWN, 'k', 'd', /* down arrow */
-
- /* vt100 F1 */
+ // mod mask with modifier without modifier
+ MOD_MASK_SHIFT, '&', '9', '@', '1', // begin
+ MOD_MASK_SHIFT, '&', '0', '@', '2', // cancel
+ MOD_MASK_SHIFT, '*', '1', '@', '4', // command
+ MOD_MASK_SHIFT, '*', '2', '@', '5', // copy
+ MOD_MASK_SHIFT, '*', '3', '@', '6', // create
+ MOD_MASK_SHIFT, '*', '4', 'k', 'D', // delete char
+ MOD_MASK_SHIFT, '*', '5', 'k', 'L', // delete line
+ MOD_MASK_SHIFT, '*', '7', '@', '7', // end
+ MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_END, '@', '7', // end
+ MOD_MASK_SHIFT, '*', '9', '@', '9', // exit
+ MOD_MASK_SHIFT, '*', '0', '@', '0', // find
+ MOD_MASK_SHIFT, '#', '1', '%', '1', // help
+ MOD_MASK_SHIFT, '#', '2', 'k', 'h', // home
+ MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_HOME, 'k', 'h', // home
+ MOD_MASK_SHIFT, '#', '3', 'k', 'I', // insert
+ MOD_MASK_SHIFT, '#', '4', 'k', 'l', // left arrow
+ MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_LEFT, 'k', 'l', // left arrow
+ MOD_MASK_SHIFT, '%', 'a', '%', '3', // message
+ MOD_MASK_SHIFT, '%', 'b', '%', '4', // move
+ MOD_MASK_SHIFT, '%', 'c', '%', '5', // next
+ MOD_MASK_SHIFT, '%', 'd', '%', '7', // options
+ MOD_MASK_SHIFT, '%', 'e', '%', '8', // previous
+ MOD_MASK_SHIFT, '%', 'f', '%', '9', // print
+ MOD_MASK_SHIFT, '%', 'g', '%', '0', // redo
+ MOD_MASK_SHIFT, '%', 'h', '&', '3', // replace
+ MOD_MASK_SHIFT, '%', 'i', 'k', 'r', // right arr.
+ MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_RIGHT, 'k', 'r', // right arr.
+ MOD_MASK_SHIFT, '%', 'j', '&', '5', // resume
+ MOD_MASK_SHIFT, '!', '1', '&', '6', // save
+ MOD_MASK_SHIFT, '!', '2', '&', '7', // suspend
+ MOD_MASK_SHIFT, '!', '3', '&', '8', // undo
+ MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_UP, 'k', 'u', // up arrow
+ MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_DOWN, 'k', 'd', // down arrow
+
+ // vt100 F1
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF1, KS_EXTRA, (int)KE_XF1,
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF2, KS_EXTRA, (int)KE_XF2,
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF3, KS_EXTRA, (int)KE_XF3,
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF4, KS_EXTRA, (int)KE_XF4,
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F1, 'k', '1', /* F1 */
+ MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F1, 'k', '1', // F1
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F2, 'k', '2',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F3, 'k', '3',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F4, 'k', '4',
@@ -101,7 +101,7 @@ static char_u modifier_keys_table[] =
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F7, 'k', '7',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F8, 'k', '8',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F9, 'k', '9',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F10, 'k', ';', /* F10 */
+ MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F10, 'k', ';', // F10
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F11, 'F', '1',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F12, 'F', '2',
@@ -133,7 +133,7 @@ static char_u modifier_keys_table[] =
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F36, 'F', 'Q',
MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F37, 'F', 'R',
- /* TAB pseudo code*/
+ // TAB pseudo code
MOD_MASK_SHIFT, 'k', 'B', KS_EXTRA, (int)KE_TAB,
NUL
@@ -397,22 +397,38 @@ int handle_x_keys(const int key)
FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT
{
switch (key) {
- case K_XUP: return K_UP;
- case K_XDOWN: return K_DOWN;
- case K_XLEFT: return K_LEFT;
- case K_XRIGHT: return K_RIGHT;
- case K_XHOME: return K_HOME;
- case K_ZHOME: return K_HOME;
- case K_XEND: return K_END;
- case K_ZEND: return K_END;
- case K_XF1: return K_F1;
- case K_XF2: return K_F2;
- case K_XF3: return K_F3;
- case K_XF4: return K_F4;
- case K_S_XF1: return K_S_F1;
- case K_S_XF2: return K_S_F2;
- case K_S_XF3: return K_S_F3;
- case K_S_XF4: return K_S_F4;
+ case K_XUP:
+ return K_UP;
+ case K_XDOWN:
+ return K_DOWN;
+ case K_XLEFT:
+ return K_LEFT;
+ case K_XRIGHT:
+ return K_RIGHT;
+ case K_XHOME:
+ return K_HOME;
+ case K_ZHOME:
+ return K_HOME;
+ case K_XEND:
+ return K_END;
+ case K_ZEND:
+ return K_END;
+ case K_XF1:
+ return K_F1;
+ case K_XF2:
+ return K_F2;
+ case K_XF3:
+ return K_F3;
+ case K_XF4:
+ return K_F4;
+ case K_S_XF1:
+ return K_S_F1;
+ case K_S_XF2:
+ return K_S_F2;
+ case K_S_XF3:
+ return K_S_F3;
+ case K_S_XF4:
+ return K_S_F4;
}
return key;
}
@@ -427,31 +443,33 @@ char_u *get_special_key_name(int c, int modifiers)
int i, idx;
int table_idx;
- char_u *s;
+ char_u *s;
string[0] = '<';
idx = 1;
- /* Key that stands for a normal character. */
- if (IS_SPECIAL(c) && KEY2TERMCAP0(c) == KS_KEY)
+ // Key that stands for a normal character.
+ if (IS_SPECIAL(c) && KEY2TERMCAP0(c) == KS_KEY) {
c = KEY2TERMCAP1(c);
+ }
/*
* Translate shifted special keys into unshifted keys and set modifier.
* Same for CTRL and ALT modifiers.
*/
if (IS_SPECIAL(c)) {
- for (i = 0; modifier_keys_table[i] != 0; i += MOD_KEYS_ENTRY_SIZE)
- if ( KEY2TERMCAP0(c) == (int)modifier_keys_table[i + 1]
- && (int)KEY2TERMCAP1(c) == (int)modifier_keys_table[i + 2]) {
+ for (i = 0; modifier_keys_table[i] != 0; i += MOD_KEYS_ENTRY_SIZE) {
+ if (KEY2TERMCAP0(c) == (int)modifier_keys_table[i + 1]
+ && (int)KEY2TERMCAP1(c) == (int)modifier_keys_table[i + 2]) {
modifiers |= modifier_keys_table[i];
c = TERMCAP2KEY(modifier_keys_table[i + 3],
- modifier_keys_table[i + 4]);
+ modifier_keys_table[i + 4]);
break;
}
+ }
}
- /* try to find the key in the special key table */
+ // try to find the key in the special key table
table_idx = find_special_key_in_table(c);
/*
@@ -459,14 +477,13 @@ char_u *get_special_key_name(int c, int modifiers)
* extract modifiers.
*/
if (c > 0
- && (*mb_char2len)(c) == 1
- ) {
+ && (*mb_char2len)(c) == 1) {
if (table_idx < 0
&& (!vim_isprintc(c) || (c & 0x7f) == ' ')
&& (c & 0x80)) {
c &= 0x7f;
modifiers |= MOD_MASK_ALT;
- /* try again, to find the un-alted key in the special key table */
+ // try again, to find the un-alted key in the special key table
table_idx = find_special_key_in_table(c);
}
if (table_idx < 0 && !vim_isprintc(c) && c < ' ') {
@@ -475,15 +492,16 @@ char_u *get_special_key_name(int c, int modifiers)
}
}
- /* translate the modifier into a string */
- for (i = 0; mod_mask_table[i].name != 'A'; i++)
+ // translate the modifier into a string
+ for (i = 0; mod_mask_table[i].name != 'A'; i++) {
if ((modifiers & mod_mask_table[i].mod_mask)
== mod_mask_table[i].mod_flag) {
string[idx++] = mod_mask_table[i].name;
string[idx++] = (char_u)'-';
}
+ }
- if (table_idx < 0) { /* unknown special key, may output t_xx */
+ if (table_idx < 0) { // unknown special key, may output t_xx
if (IS_SPECIAL(c)) {
string[idx++] = 't';
string[idx++] = '_';
@@ -497,16 +515,17 @@ char_u *get_special_key_name(int c, int modifiers)
string[idx++] = (char_u)c;
} else {
s = transchar(c);
- while (*s)
+ while (*s) {
string[idx++] = *s++;
+ }
}
}
} else { // use name of special key
size_t len = STRLEN(key_names_table[table_idx].name);
if ((int)len + idx + 2 <= MAX_KEY_NAME_LEN) {
- STRCPY(string + idx, key_names_table[table_idx].name);
- idx += (int)len;
+ STRCPY(string + idx, key_names_table[table_idx].name);
+ idx += (int)len;
}
}
string[idx++] = '>';
@@ -525,9 +544,8 @@ char_u *get_special_key_name(int c, int modifiers)
/// @param[in] in_string Inside a double quoted string
///
/// @return Number of characters added to dst, zero for no match.
-unsigned int trans_special(const char_u **srcp, const size_t src_len,
- char_u *const dst, const bool keycode,
- const bool in_string)
+unsigned int trans_special(const char_u **srcp, const size_t src_len, char_u *const dst,
+ const bool keycode, const bool in_string)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
int modifiers = 0;
@@ -582,9 +600,8 @@ unsigned int special_to_buf(int key, int modifiers, bool keycode, char_u *dst)
/// @param[in] in_string In string, double quote is escaped
///
/// @return Key and modifiers or 0 if there is no match.
-int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
- const bool keycode, const bool keep_x_key,
- const bool in_string)
+int find_special_key(const char_u **srcp, const size_t src_len, int *const modp, const bool keycode,
+ const bool keep_x_key, const bool in_string)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
const char_u *last_dash;
@@ -641,7 +658,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
if (bp <= end && *bp == '>') { // found matching '>'
end_of_name = bp + 1;
- /* Which modifiers are given? */
+ // Which modifiers are given?
modifiers = 0x0;
for (bp = src + 1; bp < last_dash; bp++) {
if (*bp != '-') {
@@ -795,13 +812,14 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag)
{
int i;
- for (i = 0; mouse_table[i].pseudo_code; i++)
+ for (i = 0; mouse_table[i].pseudo_code; i++) {
if (code == mouse_table[i].pseudo_code) {
*is_click = mouse_table[i].is_click;
*is_drag = mouse_table[i].is_drag;
return mouse_table[i].button;
}
- return 0; /* Shouldn't get here */
+ }
+ return 0; // Shouldn't get here
}
/// Replace any terminal code strings with the equivalent internal
@@ -829,9 +847,8 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag)
/// @return Pointer to an allocated memory in case of success, "from" in case of
/// failure. In case of success returned pointer is also saved to
/// "bufp".
-char_u *replace_termcodes(const char_u *from, const size_t from_len,
- char_u **bufp, const bool from_part, const bool do_lt,
- const bool special, int cpo_flags)
+char_u *replace_termcodes(const char_u *from, const size_t from_len, char_u **bufp,
+ const bool from_part, const bool do_lt, const bool special, int cpo_flags)
FUNC_ATTR_NONNULL_ALL
{
ssize_t i;
@@ -841,7 +858,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len,
const char_u *src;
const char_u *const end = from + from_len - 1;
int do_backslash; // backslash is a special character
- char_u *result; // buffer for resulting string
+ char_u *result; // buffer for resulting string
do_backslash = !(cpo_flags&FLAG_CPO_BSLASH);
@@ -897,7 +914,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len,
}
if (special) {
- char_u *p, *s, len;
+ char_u *p, *s, len;
// Replace <Leader> by the value of "mapleader".
// Replace <LocalLeader> by the value of "maplocalleader".
diff --git a/src/nvim/log.c b/src/nvim/log.c
index 324382a0f7..5539e3d6c5 100644
--- a/src/nvim/log.c
+++ b/src/nvim/log.c
@@ -17,9 +17,9 @@
#include "auto/config.h"
#include "nvim/log.h"
-#include "nvim/types.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
+#include "nvim/types.h"
#define LOG_FILE_ENV "NVIM_LOG_FILE"
@@ -124,8 +124,8 @@ void log_unlock(void)
/// @param line_num Source line number, or -1
/// @param eol Append linefeed "\n"
/// @param fmt printf-style format string
-bool logmsg(int log_level, const char *context, const char *func_name,
- int line_num, bool eol, const char *fmt, ...)
+bool logmsg(int log_level, const char *context, const char *func_name, int line_num, bool eol,
+ const char *fmt, ...)
FUNC_ATTR_UNUSED FUNC_ATTR_PRINTF(6, 7)
{
if (log_level < MIN_LOG_LEVEL) {
@@ -215,8 +215,7 @@ FILE *open_log_file(void)
}
#ifdef HAVE_EXECINFO_BACKTRACE
-void log_callstack_to_file(FILE *log_file, const char *const func_name,
- const int line_num)
+void log_callstack_to_file(FILE *log_file, const char *const func_name, const int line_num)
{
void *trace[100];
int trace_size = backtrace(trace, ARRAY_SIZE(trace));
@@ -268,8 +267,7 @@ end:
#endif
static bool 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, ...)
+ const char *func_name, int line_num, bool eol, const char *fmt, ...)
FUNC_ATTR_PRINTF(7, 8)
{
va_list args;
@@ -281,9 +279,8 @@ static bool do_log_to_file(FILE *log_file, int log_level, const char *context,
return ret;
}
-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,
+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)
{
static const char *log_levels[] = {
@@ -317,10 +314,10 @@ static bool v_do_log_to_file(FILE *log_file, int log_level,
? fprintf(log_file, "%s %s.%03d %-5" PRId64 " %s",
log_levels[log_level], date_time, millis, pid,
(context == NULL ? "?:" : context))
- : fprintf(log_file, "%s %s.%03d %-5" PRId64 " %s%s:%d: ",
- log_levels[log_level], date_time, millis, pid,
- (context == NULL ? "" : context),
- func_name, line_num);
+ : fprintf(log_file, "%s %s.%03d %-5" PRId64 " %s%s:%d: ",
+ log_levels[log_level], date_time, millis, pid,
+ (context == NULL ? "" : context),
+ func_name, line_num);
if (rv < 0) {
return false;
}
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index e19274ced9..37929093e3 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -260,7 +260,7 @@ int tslua_push_parser(lua_State *L)
return 1;
}
-static TSParser ** parser_check(lua_State *L, uint16_t index)
+static TSParser **parser_check(lua_State *L, uint16_t index)
{
return luaL_checkudata(L, index, TS_META_PARSER);
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index fea1ab77a2..fe4ec9f96c 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1999,7 +1999,7 @@ void mb_check_adjust_col(void *win_)
/// @param line start of the string
///
/// @return a pointer to the character before "*p", if there is one.
-char_u * mb_prevptr(char_u *line, char_u *p)
+char_u *mb_prevptr(char_u *line, char_u *p)
{
if (p > line) {
MB_PTR_BACK(line, p);
@@ -2099,7 +2099,7 @@ const char *mb_unescape(const char **const pp)
/*
* Skip the Vim specific head of a 'encoding' name.
*/
-char_u * enc_skip(char_u *p)
+char_u *enc_skip(char_u *p)
{
if (STRNCMP(p, "2byte-", 6) == 0) {
return p + 6;
@@ -2202,7 +2202,7 @@ static int enc_alias_search(char_u *name)
* Get the canonicalized encoding of the current locale.
* Returns an allocated string when successful, NULL when not.
*/
-char_u * enc_locale(void)
+char_u *enc_locale(void)
{
int i;
char buf[50];
@@ -2274,7 +2274,7 @@ enc_locale_copy_enc:
* Returns (void *)-1 if failed.
* (should return iconv_t, but that causes problems with prototypes).
*/
-void * my_iconv_open(char_u *to, char_u *from)
+void *my_iconv_open(char_u *to, char_u *from)
{
iconv_t fd;
#define ICONV_TESTLEN 400
@@ -2501,8 +2501,8 @@ char_u *string_convert(const vimconv_T *const vcp, char_u *ptr, size_t *lenp)
* an incomplete sequence at the end it is not converted and "*unconvlenp" is
* set to the number of remaining bytes.
*/
-char_u * string_convert_ext(const vimconv_T *const vcp, char_u *ptr, size_t *lenp,
- size_t *unconvlenp)
+char_u *string_convert_ext(const vimconv_T *const vcp, char_u *ptr, size_t *lenp,
+ size_t *unconvlenp)
{
char_u *retval = NULL;
char_u *d;
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 0fc3f35ffc..f239c9e1ec 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -1146,7 +1146,7 @@ size_t home_replace(const buf_T *const buf, const char_u *src, char_u *const dst
/// Like home_replace, store the replaced string in allocated memory.
/// @param buf When not NULL, check for help files
/// @param src Input file name
-char_u * home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
+char_u *home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
{
size_t len = 3; // space for "~/" and trailing NUL
if (src != NULL) { // just in case
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 65b1845d01..0d125ec964 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -119,7 +119,7 @@ void signal_accept_deadly(void)
rejecting_deadly = false;
}
-static char * signal_name(int signum)
+static char *signal_name(int signum)
{
switch (signum) {
#ifdef SIGPWR
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 10cc2ea9b8..559a7380eb 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -93,7 +93,7 @@ typedef struct hl_group {
static garray_T highlight_ga = GA_EMPTY_INIT_VALUE;
Map(cstr_t, int) highlight_unames = MAP_INIT;
-static inline struct hl_group * HL_TABLE(void)
+static inline struct hl_group *HL_TABLE(void)
{
return ((struct hl_group *)((highlight_ga.ga_data)));
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 4bbdaefd1f..400962f993 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -7058,13 +7058,13 @@ void win_id2tabwin(typval_T *const argvars, typval_T *const rettv)
tv_list_append_number(list, winnr);
}
-win_T * win_id2wp(typval_T *argvars)
+win_T *win_id2wp(typval_T *argvars)
{
return win_id2wp_tp(argvars, NULL);
}
// Return the window and tab pointer of window "id".
-win_T * win_id2wp_tp(typval_T *argvars, tabpage_T **tpp)
+win_T *win_id2wp_tp(typval_T *argvars, tabpage_T **tpp)
{
int id = tv_get_number(&argvars[0]);