refactor: format with uncrustify #15755

This commit is contained in:
dundargoc
2021-09-24 14:03:15 +02:00
committed by GitHub
parent 433bda405e
commit 7a26eb8a56
10 changed files with 1475 additions and 1428 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,14 +7,13 @@
#include <stdbool.h>
#include <string.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/os_unix.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -23,19 +22,20 @@
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/mouse.h"
#include "nvim/garray.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os/signal.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/types.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os/input.h"
#include "nvim/os/shell.h"
#include "nvim/os/signal.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os_unix.c.generated.h"
@@ -61,13 +61,15 @@ vim_acl_T mch_get_acl(const char_u *fname)
// Set the ACL of file "fname" to "acl" (unless it's NULL).
void mch_set_acl(const char_u *fname, vim_acl_T aclent)
{
if (aclent == NULL)
if (aclent == NULL) {
return;
}
}
void mch_free_acl(vim_acl_T aclent)
{
if (aclent == NULL)
if (aclent == NULL) {
return;
}
}
#endif

View File

@@ -6,15 +6,13 @@
#include <stdbool.h>
#include <stdlib.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/path.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/memfile.h"
#include "nvim/memline.h"
@@ -22,20 +20,22 @@
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types.h"
#include "nvim/os/input.h"
#include "nvim/vim.h"
#include "nvim/window.h"
#define URL_SLASH 1 /* path_is_url() has found "://" */
#define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */
#define URL_SLASH 1 // path_is_url() has found "://"
#define URL_BACKSLASH 2 // path_is_url() has found ":\\"
#ifdef gen_expand_wildcards
# undef gen_expand_wildcards
@@ -53,8 +53,8 @@
/// @param checkname When both files don't exist, only compare their names.
/// @param expandenv Whether to expand environment variables in file names.
/// @return Enum of type FileComparison. @see FileComparison.
FileComparison path_full_compare(char_u *const s1, char_u *const s2,
const bool checkname, const bool expandenv)
FileComparison path_full_compare(char_u *const s1, char_u *const s2, const bool checkname,
const bool expandenv)
{
assert(s1 && s2);
char_u exp1[MAXPATHL];
@@ -266,7 +266,7 @@ int vim_ispathlistsep(int c)
#ifdef UNIX
return c == ':';
#else
return c == ';'; /* might not be right for every system... */
return c == ';'; // might not be right for every system...
#endif
}
@@ -280,11 +280,12 @@ char_u *shorten_dir(char_u *str)
char_u *d = str;
bool skip = false;
for (char_u *s = str;; ++s) {
if (s >= tail) { /* copy the whole tail */
if (s >= tail) { // copy the whole tail
*d++ = *s;
if (*s == NUL)
if (*s == NUL) {
break;
} else if (vim_ispathsep(*s)) { /* copy '/' and next char */
}
} else if (vim_ispathsep(*s)) { // copy '/' and next char
*d++ = *s;
skip = false;
} else if (!skip) {
@@ -348,8 +349,7 @@ int path_fnamecmp(const char *fname1, const char *fname2)
/// @param[in] len Compare at most len bytes.
///
/// @return 0 if they are equal, non-zero otherwise.
int path_fnamencmp(const char *const fname1, const char *const fname2,
size_t len)
int path_fnamencmp(const char *const fname1, const char *const fname2, size_t len)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
#ifdef BACKSLASH_IN_FILENAME
@@ -389,9 +389,8 @@ int path_fnamencmp(const char *const fname1, const char *const fname2,
/// add a path separator before fname2.
///
/// @return fname1
static inline char *do_concat_fnames(char *fname1, const size_t len1,
const char *fname2, const size_t len2,
const bool sep)
static inline char *do_concat_fnames(char *fname1, const size_t len1, const char *fname2,
const size_t len2, const bool sep)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
{
if (sep && *fname1 && !after_pathsep(fname1, fname1 + len1)) {
@@ -590,8 +589,8 @@ static const char *scandir_next_with_dots(Directory *dir)
/// Implementation of path_expand().
///
/// Chars before `path + wildoff` do not get expanded.
static size_t do_path_expand(garray_T *gap, const char_u *path,
size_t wildoff, int flags, bool didstar)
static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff, int flags,
bool didstar)
FUNC_ATTR_NONNULL_ALL
{
int start_len = gap->ga_len;
@@ -599,12 +598,13 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
bool starstar = false;
static int stardepth = 0; // depth for "**" expansion
/* Expanding "**" may take a long time, check for CTRL-C. */
// Expanding "**" may take a long time, check for CTRL-C.
if (stardepth > 0) {
os_breakcheck();
if (got_int)
if (got_int) {
return 0;
}
}
// Make room for file name. When doing encoding conversion the actual
// length may be quite a bit longer, thus use the maximum possible length.
@@ -644,20 +644,23 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
e = p;
*e = NUL;
/* Now we have one wildcard component between "s" and "e". */
// Now we have one wildcard component between "s" and "e".
/* Remove backslashes between "wildoff" and the start of the wildcard
* component. */
for (p = buf + wildoff; p < s; ++p)
for (p = buf + wildoff; p < s; ++p) {
if (rem_backslash(p)) {
STRMOVE(p, p + 1);
--e;
--s;
}
}
/* Check for "**" between "s" and "e". */
for (p = s; p < e; ++p)
if (p[0] == '*' && p[1] == '*')
// Check for "**" between "s" and "e".
for (p = s; p < e; ++p) {
if (p[0] == '*' && p[1] == '*') {
starstar = true;
}
}
// convert the file pattern to a regexp pattern
int starts_with_dot = *s == '.';
@@ -675,11 +678,13 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
#else
regmatch.rm_ic = true; // Always ignore case on Windows.
#endif
if (flags & (EW_NOERROR | EW_NOTWILD))
if (flags & (EW_NOERROR | EW_NOTWILD)) {
++emsg_silent;
}
regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
if (flags & (EW_NOERROR | EW_NOTWILD))
if (flags & (EW_NOERROR | EW_NOTWILD)) {
--emsg_silent;
}
xfree(pat);
if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0) {
@@ -727,9 +732,9 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
}
STRCPY(buf + len, path_end);
if (path_has_exp_wildcard(path_end)) { /* handle more wildcards */
/* need to expand another component of the path */
/* remove backslashes for the remaining components only */
if (path_has_exp_wildcard(path_end)) { // handle more wildcards
// need to expand another component of the path
// remove backslashes for the remaining components only
(void)do_path_expand(gap, buf, len + 1, flags, false);
} else {
FileInfo file_info;
@@ -767,14 +772,16 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
*/
static int find_previous_pathsep(char_u *path, char_u **psep)
{
/* skip the current separator */
if (*psep > path && vim_ispathsep(**psep))
// skip the current separator
if (*psep > path && vim_ispathsep(**psep)) {
--*psep;
}
/* find the previous separator */
// find the previous separator
while (*psep > path) {
if (vim_ispathsep(**psep))
if (vim_ispathsep(**psep)) {
return OK;
}
MB_PTR_BACK(path, *psep);
}
@@ -828,8 +835,9 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
/* Relative to current buffer:
* "/path/file" + "." -> "/path/"
* "/path/file" + "./subdir" -> "/path/subdir" */
if (curbuf->b_ffname == NULL)
if (curbuf->b_ffname == NULL) {
continue;
}
char_u *p = path_tail(curbuf->b_ffname);
size_t len = (size_t)(p - curbuf->b_ffname);
if (len + STRLEN(buf) >= MAXPATHL) {
@@ -932,14 +940,16 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
STRCAT(file_pattern, pattern);
char_u *pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, true);
xfree(file_pattern);
if (pat == NULL)
if (pat == NULL) {
return;
}
regmatch.rm_ic = TRUE; /* always ignore case */
regmatch.rm_ic = TRUE; // always ignore case
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
xfree(pat);
if (regmatch.regprog == NULL)
if (regmatch.regprog == NULL) {
return;
}
char_u *curdir = xmalloc(MAXPATHL);
os_dirname(curdir, MAXPATHL);
@@ -957,10 +967,11 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
len = STRLEN(path);
is_in_curdir = fnamencmp(curdir, path, dir_end - path) == 0
&& curdir[dir_end - path] == NUL;
if (is_in_curdir)
if (is_in_curdir) {
in_curdir[i] = vim_strsave(path);
}
/* Shorten the filename while maintaining its uniqueness */
// Shorten the filename while maintaining its uniqueness
path_cutoff = get_path_cutoff(path, &path_ga);
// Don't assume all files can be reached without path when search
@@ -1010,19 +1021,21 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
os_breakcheck();
}
/* Shorten filenames in /in/current/directory/{filename} */
// Shorten filenames in /in/current/directory/{filename}
for (int i = 0; i < gap->ga_len && !got_int; i++) {
char_u *rel_path;
char_u *path = in_curdir[i];
if (path == NULL)
if (path == NULL) {
continue;
}
/* If the {filename} is not unique, change it to ./{filename}.
* Else reduce it to {filename} */
short_name = path_shorten_fname(path, curdir);
if (short_name == NULL)
if (short_name == NULL) {
short_name = path;
}
if (is_unique(short_name, gap, i)) {
STRCPY(fnames[i], short_name);
continue;
@@ -1040,15 +1053,17 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
}
xfree(curdir);
for (int i = 0; i < gap->ga_len; i++)
for (int i = 0; i < gap->ga_len; i++) {
xfree(in_curdir[i]);
}
xfree(in_curdir);
ga_clear_strings(&path_ga);
vim_regfree(regmatch.regprog);
if (sort_again)
if (sort_again) {
ga_remove_duplicate_strings(gap);
}
}
/// Find end of the directory name
///
@@ -1072,8 +1087,9 @@ const char *gettail_dir(const char *const fname)
look_for_sep = false;
}
} else {
if (!look_for_sep)
if (!look_for_sep) {
dir_end = next_dir_end;
}
look_for_sep = true;
}
MB_PTR_ADV(p);
@@ -1082,16 +1098,12 @@ const char *gettail_dir(const char *const fname)
}
/*
* Calls globpath() with 'path' values for the given pattern and stores the
* result in "gap".
* Returns the total number of matches.
*/
static int expand_in_path(
garray_T *const gap,
char_u *const pattern,
const int flags // EW_* flags
)
/// Calls globpath() with 'path' values for the given pattern and stores the
/// result in "gap".
/// Returns the total number of matches.
///
/// @param flags EW_* flags
static int expand_in_path(garray_T *const gap, char_u *const pattern, const int flags)
{
garray_T path_ga;
@@ -1186,8 +1198,7 @@ static bool has_special_wildchar(char_u *p)
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set
/// to NULL or points to "".
int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
char_u ***file, int flags)
int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)
{
garray_T ga;
char_u *p;
@@ -1203,9 +1214,9 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
*/
if (recursive)
#ifdef SPECIAL_WILDCHAR
return os_expand_wildcards(num_pat, pat, num_file, file, flags);
{ return os_expand_wildcards(num_pat, pat, num_file, file, flags); }
#else
return FAIL;
{ return FAIL; }
#endif
#ifdef SPECIAL_WILDCHAR
@@ -1247,8 +1258,9 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
// First expand environment variables, "~/" and "~user/".
if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~') {
p = expand_env_save_opt(p, true);
if (p == NULL)
if (p == NULL) {
p = pat[i];
}
#ifdef UNIX
/*
* On Unix, if expand_env() can't expand an environment
@@ -1278,8 +1290,8 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
&& !path_is_absolute(p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
|| (p[1] == '.' && vim_ispathsep(p[2]))))
) {
|| (p[1] == '.' &&
vim_ispathsep(p[2]))))) {
/* :find completion where 'path' is used.
* Recursiveness is OK here. */
recursive = false;
@@ -1310,11 +1322,13 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
}
}
if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH))
if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH)) {
uniquefy_paths(&ga, p);
if (p != pat[i])
}
if (p != pat[i]) {
xfree(p);
}
}
*num_file = ga.ga_len;
*file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data : NULL;
@@ -1333,14 +1347,12 @@ static int vim_backtick(char_u *p)
return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`';
}
// Expand an item in `backticks` by executing it as a command.
// Currently only works when pat[] starts and ends with a `.
// Returns number of file names found, -1 if an error is encountered.
static int expand_backtick(
garray_T *gap,
char_u *pat,
int flags /* EW_* flags */
)
/// Expand an item in `backticks` by executing it as a command.
/// Currently only works when pat[] starts and ends with a `.
/// Returns number of file names found, -1 if an error is encountered.
///
/// @param flags EW_* flags
static int expand_backtick(garray_T *gap, char_u *pat, int flags)
{
char_u *p;
char_u *buffer;
@@ -1361,11 +1373,12 @@ static int expand_backtick(
cmd = buffer;
while (*cmd != NUL) {
cmd = skipwhite(cmd); /* skip over white space */
cmd = skipwhite(cmd); // skip over white space
p = cmd;
while (*p != NUL && *p != '\r' && *p != '\n') /* skip over entry */
while (*p != NUL && *p != '\r' && *p != '\n') { // skip over entry
++p;
/* add an entry if it is not empty */
}
// add an entry if it is not empty
if (p > cmd) {
char_u i = *p;
*p = NUL;
@@ -1374,9 +1387,10 @@ static int expand_backtick(
++cnt;
}
cmd = p;
while (*cmd != NUL && (*cmd == '\r' || *cmd == '\n'))
while (*cmd != NUL && (*cmd == '\r' || *cmd == '\n')) {
++cmd;
}
}
xfree(buffer);
return cnt;
@@ -1414,18 +1428,16 @@ void slash_adjust(char_u *p)
}
#endif
// Add a file to a file list. Accepted flags:
// EW_DIR add directories
// EW_FILE add files
// EW_EXEC add executable files
// EW_NOTFOUND add even when it doesn't exist
// EW_ADDSLASH add slash after directory name
// EW_ALLLINKS add symlink also when the referred file does not exist
void addfile(
garray_T *gap,
char_u *f, /* filename */
int flags
)
/// Add a file to a file list. Accepted flags:
/// EW_DIR add directories
/// EW_FILE add files
/// EW_EXEC add executable files
/// EW_NOTFOUND add even when it doesn't exist
/// EW_ADDSLASH add slash after directory name
/// EW_ALLLINKS add symlink also when the referred file does not exist
///
/// @param f filename
void addfile(garray_T *gap, char_u *f, int flags)
{
bool isdir;
FileInfo file_info;
@@ -1439,14 +1451,16 @@ void addfile(
}
#ifdef FNAME_ILLEGAL
/* if the file/dir contains illegal characters, don't add it */
if (vim_strpbrk(f, (char_u *)FNAME_ILLEGAL) != NULL)
// if the file/dir contains illegal characters, don't add it
if (vim_strpbrk(f, (char_u *)FNAME_ILLEGAL) != NULL) {
return;
}
#endif
isdir = os_isdir(f);
if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE)))
if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) {
return;
}
// If the file isn't executable, may not add it. Do accept directories.
// When invoked from expand_shellcmd() do not use $PATH.
@@ -1464,8 +1478,9 @@ void addfile(
/*
* Append a slash or backslash after directory names if none is present.
*/
if (isdir && (flags & EW_ADDSLASH))
if (isdir && (flags & EW_ADDSLASH)) {
add_pathsep((char *)p);
}
GA_APPEND(char_u *, gap, p);
}
@@ -1484,8 +1499,9 @@ void simplify_filename(char_u *filename)
p = filename;
#ifdef BACKSLASH_IN_FILENAME
if (p[1] == ':') /* skip "x:" */
if (p[1] == ':') { // skip "x:"
p += 2;
}
#endif
if (vim_ispathsep(*p)) {
@@ -1494,17 +1510,18 @@ void simplify_filename(char_u *filename)
++p;
while (vim_ispathsep(*p));
}
start = p; /* remember start after "c:/" or "/" or "///" */
start = p; // remember start after "c:/" or "/" or "///"
do {
/* At this point "p" is pointing to the char following a single "/"
* or "p" is at the "start" of the (absolute or relative) path name. */
if (vim_ispathsep(*p))
STRMOVE(p, p + 1); /* remove duplicate "/" */
else if (p[0] == '.' && (vim_ispathsep(p[1]) || p[1] == NUL)) {
if (p == start && relative)
p += 1 + (p[1] != NUL); /* keep single "." or leading "./" */
else {
if (vim_ispathsep(*p)) {
STRMOVE(p, p + 1); // remove duplicate "/"
} else if (p[0] == '.' &&
(vim_ispathsep(p[1]) || p[1] == NUL)) {
if (p == start && relative) {
p += 1 + (p[1] != NUL); // keep single "." or leading "./"
} else {
/* Strip "./" or ".///". If we are at the end of the file name
* and there is no trailing path separator, either strip "/." if
* we are after "start", or strip "." if we are at the beginning
@@ -1527,11 +1544,11 @@ void simplify_filename(char_u *filename)
MB_PTR_ADV(tail);
}
if (components > 0) { /* strip one preceding component */
if (components > 0) { // strip one preceding component
bool do_strip = false;
char_u saved_char;
/* Don't strip for an erroneous file name. */
// Don't strip for an erroneous file name.
if (!stripping_disabled) {
/* If the preceding component does not exist in the file
* system, we strip it. On Unix, we don't accept a symbolic
@@ -1613,21 +1630,22 @@ void simplify_filename(char_u *filename)
*p++ = '.';
*p = NUL;
} else {
if (p > start && tail[-1] == '.')
if (p > start && tail[-1] == '.') {
--p;
STRMOVE(p, tail); /* strip previous component */
}
STRMOVE(p, tail); // strip previous component
}
--components;
}
} else if (p == start && !relative) /* leading "/.." or "/../" */
STRMOVE(p, tail); /* strip ".." or "../" */
else {
if (p == start + 2 && p[-2] == '.') { /* leading "./../" */
STRMOVE(p - 2, p); /* strip leading "./" */
} else if (p == start && !relative) { // leading "/.." or "/../"
STRMOVE(p, tail); // strip ".." or "../"
} else {
if (p == start + 2 && p[-2] == '.') { // leading "./../"
STRMOVE(p - 2, p); // strip leading "./"
tail -= 2;
}
p = tail; /* skip to char after ".." or "../" */
p = tail; // skip to char after ".." or "../"
}
} else {
components++; // Simple path component.
@@ -1639,25 +1657,18 @@ void simplify_filename(char_u *filename)
static char *eval_includeexpr(const char *const ptr, const size_t len)
{
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
char *res = (char *)eval_to_string_safe(
curbuf->b_p_inex, NULL,
was_set_insecurely(curwin, (char_u *)"includeexpr", OPT_LOCAL));
char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL,
was_set_insecurely(curwin, (char_u *)"includeexpr",
OPT_LOCAL));
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}
/*
* Return the name of the file ptr[len] in 'path'.
* Otherwise like file_name_at_cursor().
*/
char_u *
find_file_name_in_path (
char_u *ptr,
size_t len,
int options,
long count,
char_u *rel_fname /* file we are searching relative to */
)
/// Return the name of the file ptr[len] in 'path'.
/// Otherwise like file_name_at_cursor().
///
/// @param rel_fname file we are searching relative to
char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count, char_u *rel_fname)
{
char_u *file_name;
char_u *tofree = NULL;
@@ -1701,8 +1712,9 @@ find_file_name_in_path (
xfree(file_name);
file_name = find_file_in_path(ptr, len, options, FALSE, rel_fname);
}
} else
} else {
file_name = vim_strnsave(ptr, len);
}
xfree(tofree);
@@ -1714,10 +1726,11 @@ find_file_name_in_path (
// URL_BACKSLASH.
int path_is_url(const char *p)
{
if (strncmp(p, "://", 3) == 0)
if (strncmp(p, "://", 3) == 0) {
return URL_SLASH;
else if (strncmp(p, ":\\\\", 3) == 0)
} else if (strncmp(p, ":\\\\", 3) == 0) {
return URL_BACKSLASH;
}
return 0;
}
@@ -1735,7 +1748,9 @@ int path_with_url(const char *fname)
bool path_with_extension(const char *path, const char *extension)
{
const char *last_dot = strrchr(path, '.');
if (!last_dot) { return false; }
if (!last_dot) {
return false;
}
return strcmp(last_dot + 1, extension) == 0;
}
@@ -1809,8 +1824,9 @@ char *fix_fname(const char *fname)
# ifdef BACKSLASH_IN_FILENAME
|| strstr(fname, "\\\\") != NULL
# endif
)
) {
return FullName_save(fname, false);
}
fname = xstrdup(fname);
@@ -1898,9 +1914,10 @@ bool same_directory(char_u *f1, char_u *f2)
char_u *t1;
char_u *t2;
/* safety check */
if (f1 == NULL || f2 == NULL)
// safety check
if (f1 == NULL || f2 == NULL) {
return false;
}
(void)vim_FullName((char *)f1, (char *)ffname, MAXPATHL, FALSE);
t1 = path_tail_with_sep(ffname);
@@ -1924,16 +1941,17 @@ int pathcmp(const char *p, const char *q, int maxlen)
c1 = PTR2CHAR((char_u *)p + i);
c2 = PTR2CHAR((char_u *)q + j);
/* End of "p": check if "q" also ends or just has a slash. */
// End of "p": check if "q" also ends or just has a slash.
if (c1 == NUL) {
if (c2 == NUL) /* full match */
if (c2 == NUL) { // full match
return 0;
}
s = q;
i = j;
break;
}
/* End of "q": check if "p" just has a slash. */
// End of "q": check if "p" just has a slash.
if (c2 == NUL) {
s = p;
break;
@@ -1941,15 +1959,17 @@ int pathcmp(const char *p, const char *q, int maxlen)
if ((p_fic ? mb_toupper(c1) != mb_toupper(c2) : c1 != c2)
#ifdef BACKSLASH_IN_FILENAME
/* consider '/' and '\\' to be equal */
// consider '/' and '\\' to be equal
&& !((c1 == '/' && c2 == '\\')
|| (c1 == '\\' && c2 == '/'))
#endif
) {
if (vim_ispathsep(c1))
if (vim_ispathsep(c1)) {
return -1;
if (vim_ispathsep(c2))
}
if (vim_ispathsep(c2)) {
return 1;
}
return p_fic ? mb_toupper(c1) - mb_toupper(c2)
: c1 - c2; // no match
}
@@ -2057,8 +2077,7 @@ char_u *path_shorten_fname(char_u *full_path, char_u *dir_name)
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set
/// to NULL or points to "".
int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
int flags)
int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file, int flags)
{
int ret = FAIL;
char_u *eval_pat = NULL;
@@ -2071,12 +2090,14 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
NULL, &ignored_msg, NULL);
--emsg_off;
if (eval_pat != NULL)
if (eval_pat != NULL) {
exp_pat = concat_str(eval_pat, exp_pat + usedlen);
}
}
if (exp_pat != NULL)
if (exp_pat != NULL) {
ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
}
if (eval_pat != NULL) {
xfree(exp_pat);
@@ -2100,19 +2121,19 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set to
/// NULL or points to "".
int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files,
int flags)
int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files, int flags)
{
int retval;
int i, j;
char_u *p;
int non_suf_match; /* number without matching suffix */
int non_suf_match; // number without matching suffix
retval = gen_expand_wildcards(num_pat, pat, num_files, files, flags);
/* When keeping all matches, return here */
if ((flags & EW_KEEPALL) || retval == FAIL)
// When keeping all matches, return here
if ((flags & EW_KEEPALL) || retval == FAIL) {
return retval;
}
/*
* Remove names that match 'wildignore'.
@@ -2183,7 +2204,7 @@ int match_suffix(char_u *fname)
if (setsuflen == 0) {
char_u *tail = path_tail(fname);
/* empty entry: match name without a '.' */
// empty entry: match name without a '.'
if (vim_strchr(tail, '.') == NULL) {
setsuflen = 1;
break;
@@ -2283,8 +2304,7 @@ int append_path(char *path, const char *to_append, size_t max_len)
/// @param force also expand when "fname" is already absolute.
///
/// @return FAIL for failure, OK for success.
static int path_to_absolute(const char_u *fname, char_u *buf, size_t len,
int force)
static int path_to_absolute(const char_u *fname, char_u *buf, size_t len, int force)
{
char_u *p;
*buf = NUL;

View File

@@ -5,18 +5,17 @@
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/plines.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/func_attr.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/indent.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -24,10 +23,11 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/vim.h"
#include "nvim/window.h"
#include "nvim/buffer.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "plines.c.generated.h"
@@ -159,8 +159,8 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
/// @param[in] cache whether to use the window's cache for folds
///
/// @return the total number of screen lines
int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp,
bool *const foldedp, const bool cache)
int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, bool *const foldedp,
const bool cache)
{
bool folded = hasFoldingWin(wp, lnum, NULL, nextp, cache, NULL);
if (foldedp) {
@@ -302,8 +302,7 @@ int lbr_chartabsize_adv(char_u *line, char_u **s, colnr_T col)
/// @param headp
///
/// @return The number of characters taken up on the screen.
int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
colnr_T col, int *headp)
int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp)
{
colnr_T col2;
colnr_T col_adj = 0; // col + screen size of tab

View File

@@ -9,25 +9,25 @@
#include <inttypes.h>
#include <stdbool.h>
#include "nvim/buffer.h"
#include "nvim/vim.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/eval/typval.h"
#include "nvim/popupmnu.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/edit.h"
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/popupmnu.h"
#include "nvim/screen.h"
#include "nvim/ui_compositor.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/memory.h"
#include "nvim/window.h"
#include "nvim/edit.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/vim.h"
#include "nvim/window.h"
static pumitem_T *pum_array = NULL; // items of displayed pum
static int pum_size; // nr of items in "pum_array"
@@ -98,8 +98,7 @@ static void pum_compute_size(void)
/// if false, a new item is selected, but the array
/// is the same
/// @param cmd_startcol only for cmdline mode: column of completed match
void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
int cmd_startcol)
void pum_display(pumitem_T *array, int size, int selected, bool array_changed, int cmd_startcol)
{
int context_lines;
int above_row;

View File

@@ -1,17 +1,16 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include "nvim/assert.h"
#include "nvim/profile.h"
#include "nvim/os/time.h"
#include "nvim/func_attr.h"
#include "nvim/os/os_defs.h"
#include "nvim/globals.h" // for the global `time_fd` (startuptime)
#include "nvim/os/os_defs.h"
#include "nvim/os/time.h"
#include "nvim/profile.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "profile.c.generated.h"

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,8 @@
#include <string.h>
#include "nvim/memory.h"
#include "nvim/vim.h"
#include "nvim/rbuffer.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "rbuffer.c.generated.h"

View File

@@ -5,16 +5,16 @@
///
/// Management of runtime files (including packages)
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/option.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
#include "nvim/os/os.h"
#include "nvim/runtime.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "runtime.c.generated.h"
@@ -60,8 +60,7 @@ static void source_callback(char_u *fname, void *cookie)
/// When "flags" has DIP_ERR: give an error message if there is no match.
///
/// return FAIL when no file could be sourced, OK otherwise.
int do_in_path(char_u *path, char_u *name, int flags,
DoInRuntimepathCB callback, void *cookie)
int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
{
char_u *tail;
int num_files;
@@ -164,8 +163,8 @@ int do_in_path(char_u *path, char_u *name, int flags,
/// If "name" is NULL calls callback for each entry in "path". Cookie is
/// passed by reference in this case, setting it to NULL indicates that callback
/// has done its job.
int do_in_path_and_pp(char_u *path, char_u *name, int flags,
DoInRuntimepathCB callback, void *cookie)
int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback,
void *cookie)
{
int done = FAIL;
if (!(flags & (DIP_NOAFTER | DIP_AFTER))) {
@@ -564,8 +563,7 @@ static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
/// (common_suf is present after each new item, single_suf is present
/// after half of the new items) and with commas after each item, commas
/// inside the values are escaped.
static inline size_t compute_double_env_sep_len(const char *const val,
const size_t common_suf_len,
static inline size_t compute_double_env_sep_len(const char *const val, const size_t common_suf_len,
const size_t single_suf_len)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
{
@@ -608,9 +606,8 @@ static inline size_t compute_double_env_sep_len(const char *const val,
/// Otherwise in reverse.
///
/// @return (dest + appended_characters_length)
static inline char *add_env_sep_dirs(char *dest, const char *const val,
const char *const suf1, const size_t len1,
const char *const suf2, const size_t len2,
static inline char *add_env_sep_dirs(char *dest, const char *const val, const char *const suf1,
const size_t len1, const char *const suf2, const size_t len2,
const bool forward)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
{
@@ -669,9 +666,8 @@ static inline char *add_env_sep_dirs(char *dest, const char *const val,
/// Otherwise in reverse.
///
/// @return (dest + appended_characters_length)
static inline char *add_dir(char *dest, const char *const dir,
const size_t dir_len, const XDGVarType type,
const char *const suf1, const size_t len1,
static inline char *add_dir(char *dest, const char *const dir, const size_t dir_len,
const XDGVarType type, const char *const suf1, const size_t len1,
const char *const suf2, const size_t len2)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
{

View File

@@ -1,4 +1,4 @@
# Uncrustify-0.73.0-164-c9a58467
# Uncrustify-0.73.0-168-f20a083e
#
# General options