diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-09-20 18:35:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-20 09:35:41 -0700 |
| commit | f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45 (patch) | |
| tree | 054d1d35a890843504412b859249f0b0b0b4b810 | |
| parent | 1f8c91bf729707fdb005292aecca8dd79538f4a5 (diff) | |
| download | rneovim-f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45.tar.gz rneovim-f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45.tar.bz2 rneovim-f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45.zip | |
refactor: reformat with uncrustify #15736
* fix function parameter comments
* remove space after star in function names
| -rw-r--r-- | contrib/uncrustify.cfg | 4 | ||||
| -rw-r--r-- | src/nvim/buffer.c | 4 | ||||
| -rw-r--r-- | src/nvim/charset.c | 14 | ||||
| -rw-r--r-- | src/nvim/diff.c | 2 | ||||
| -rw-r--r-- | src/nvim/digraph.c | 2 | ||||
| -rw-r--r-- | src/nvim/edit.c | 2 | ||||
| -rw-r--r-- | src/nvim/eval.c | 2 | ||||
| -rw-r--r-- | src/nvim/eval/funcs.c | 4 | ||||
| -rw-r--r-- | src/nvim/eval/userfunc.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_docmd.c | 8 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 6 | ||||
| -rw-r--r-- | src/nvim/file_search.c | 735 | ||||
| -rw-r--r-- | src/nvim/fileio.c | 4 | ||||
| -rw-r--r-- | src/nvim/garray.c | 23 | ||||
| -rw-r--r-- | src/nvim/getchar.c | 729 | ||||
| -rw-r--r-- | src/nvim/hardcopy.c | 730 | ||||
| -rw-r--r-- | src/nvim/hashtab.c | 16 | ||||
| -rw-r--r-- | src/nvim/highlight.c | 132 | ||||
| -rw-r--r-- | src/nvim/indent.c | 23 | ||||
| -rw-r--r-- | src/nvim/keymap.c | 197 | ||||
| -rw-r--r-- | src/nvim/log.c | 25 | ||||
| -rw-r--r-- | src/nvim/lua/treesitter.c | 2 | ||||
| -rw-r--r-- | src/nvim/mbyte.c | 12 | ||||
| -rw-r--r-- | src/nvim/os/env.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/signal.c | 2 | ||||
| -rw-r--r-- | src/nvim/syntax.c | 2 | ||||
| -rw-r--r-- | src/nvim/window.c | 4 |
27 files changed, 1419 insertions, 1269 deletions
diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg index d82bb47ec3..1bc6bb02c5 100644 --- a/contrib/uncrustify.cfg +++ b/contrib/uncrustify.cfg @@ -208,7 +208,7 @@ sp_after_ptr_star_qualifier = ignore # ignore/add/remove/force/not_defined # prototype or function definition. # # Overrides sp_after_ptr_star and sp_type_func. -sp_after_ptr_star_func = ignore # ignore/add/remove/force/not_defined +sp_after_ptr_star_func = remove # ignore/add/remove/force/not_defined # Add or remove space after a pointer star '*' in the trailing return of a # function prototype or function definition. @@ -3279,5 +3279,5 @@ set PREPROC REAL_FATTR_CONST set PREPROC REAL_FATTR_NONNULL_ALL set PREPROC REAL_FATTR_PURE set PREPROC REAL_FATTR_WARN_UNUSED_RESULT -# option(s) with 'not default' value: 61 +# option(s) with 'not default' value: 62 # 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; } |