mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
Merge #743 'Replace vim_strncpy with strlcpy'
This commit is contained in:
commit
8bbeb4b480
@ -2126,7 +2126,7 @@ void buflist_list(exarg_T *eap)
|
||||
continue;
|
||||
msg_putchar('\n');
|
||||
if (buf_spname(buf) != NULL)
|
||||
vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
|
||||
else
|
||||
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
|
||||
|
||||
@ -2473,7 +2473,7 @@ fileinfo (
|
||||
|
||||
*p++ = '"';
|
||||
if (buf_spname(curbuf) != NULL)
|
||||
vim_strncpy(p, buf_spname(curbuf), IOSIZE - (p - buffer) - 1);
|
||||
STRLCPY(p, buf_spname(curbuf), IOSIZE - (p - buffer));
|
||||
else {
|
||||
if (!fullname && curbuf->b_fname != NULL)
|
||||
name = curbuf->b_fname;
|
||||
@ -2619,10 +2619,10 @@ void maketitle(void)
|
||||
#define SPACE_FOR_DIR (IOSIZE - 20)
|
||||
#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
|
||||
if (curbuf->b_fname == NULL)
|
||||
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
|
||||
STRLCPY(buf, _("[No Name]"), SPACE_FOR_FNAME + 1);
|
||||
else {
|
||||
p = transstr(path_tail(curbuf->b_fname));
|
||||
vim_strncpy(buf, p, SPACE_FOR_FNAME);
|
||||
STRLCPY(buf, p, SPACE_FOR_FNAME + 1);
|
||||
free(p);
|
||||
}
|
||||
|
||||
@ -2654,8 +2654,7 @@ void maketitle(void)
|
||||
p = path_tail_with_sep(buf + off);
|
||||
if (p == buf + off)
|
||||
/* must be a help buffer */
|
||||
vim_strncpy(buf + off, (char_u *)_("help"),
|
||||
(size_t)(SPACE_FOR_DIR - off - 1));
|
||||
STRLCPY(buf + off, _("help"), SPACE_FOR_DIR - off);
|
||||
else
|
||||
*p = NUL;
|
||||
|
||||
@ -2664,11 +2663,10 @@ void maketitle(void)
|
||||
* file name) use (...). */
|
||||
if (off < SPACE_FOR_DIR) {
|
||||
p = transstr(buf + off);
|
||||
vim_strncpy(buf + off, p, (size_t)(SPACE_FOR_DIR - off));
|
||||
STRLCPY(buf + off, p, SPACE_FOR_DIR - off + 1);
|
||||
free(p);
|
||||
} else {
|
||||
vim_strncpy(buf + off, (char_u *)"...",
|
||||
(size_t)(SPACE_FOR_ARGNR - off));
|
||||
STRLCPY(buf + off, "...", SPACE_FOR_ARGNR - off + 1);
|
||||
}
|
||||
STRCAT(buf, ")");
|
||||
}
|
||||
@ -3071,7 +3069,7 @@ build_stl_str_hl (
|
||||
case STL_FILENAME:
|
||||
fillable = FALSE; /* don't change ' ' to fillchar */
|
||||
if (buf_spname(wp->w_buffer) != NULL)
|
||||
vim_strncpy(NameBuff, buf_spname(wp->w_buffer), MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL);
|
||||
else {
|
||||
t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
|
||||
: wp->w_buffer->b_fname;
|
||||
@ -3513,10 +3511,9 @@ void get_rel_pos(win_T *wp, char_u *buf, int buflen)
|
||||
above += diff_check_fill(wp, wp->w_topline) - wp->w_topfill;
|
||||
below = wp->w_buffer->b_ml.ml_line_count - wp->w_botline + 1;
|
||||
if (below <= 0)
|
||||
vim_strncpy(buf, (char_u *)(above == 0 ? _("All") : _("Bot")),
|
||||
(size_t)(buflen - 1));
|
||||
STRLCPY(buf, (above == 0 ? _("All") : _("Bot")), buflen);
|
||||
else if (above <= 0)
|
||||
vim_strncpy(buf, (char_u *)_("Top"), (size_t)(buflen - 1));
|
||||
STRLCPY(buf, _("Top"), buflen);
|
||||
else
|
||||
vim_snprintf((char *)buf, (size_t)buflen, "%2d%%", above > 1000000L
|
||||
? (int)(above / ((above + below) / 100L))
|
||||
|
@ -5875,7 +5875,7 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len)
|
||||
tofree = akey = vim_strnsave(key, len);
|
||||
} else {
|
||||
/* Avoid a malloc/free by using buf[]. */
|
||||
vim_strncpy(buf, key, len);
|
||||
STRLCPY(buf, key, len + 1);
|
||||
akey = buf;
|
||||
}
|
||||
|
||||
|
@ -4095,9 +4095,8 @@ check_more (
|
||||
char_u buff[DIALOG_MSG_SIZE];
|
||||
|
||||
if (n == 1)
|
||||
vim_strncpy(buff,
|
||||
(char_u *)_("1 more file to edit. Quit anyway?"),
|
||||
DIALOG_MSG_SIZE - 1);
|
||||
STRLCPY(buff, _("1 more file to edit. Quit anyway?"),
|
||||
DIALOG_MSG_SIZE);
|
||||
else
|
||||
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
|
||||
_("%d more files to edit. Quit anyway?"), n);
|
||||
@ -5865,7 +5864,7 @@ static void ex_tabs(exarg_T *eap)
|
||||
msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
|
||||
msg_putchar(' ');
|
||||
if (buf_spname(wp->w_buffer) != NULL)
|
||||
vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);
|
||||
STRLCPY(IObuff, buf_spname(wp->w_buffer), IOSIZE);
|
||||
else
|
||||
home_replace(wp->w_buffer, wp->w_buffer->b_fname,
|
||||
IObuff, IOSIZE, TRUE);
|
||||
|
@ -3372,7 +3372,7 @@ addstar (
|
||||
} else {
|
||||
retval = xmalloc(len + 4);
|
||||
if (retval != NULL) {
|
||||
vim_strncpy(retval, fname, len);
|
||||
STRLCPY(retval, fname, len + 1);
|
||||
|
||||
/*
|
||||
* Don't add a star to *, ~, ~user, $var or `cmd`.
|
||||
@ -3896,10 +3896,10 @@ expand_shellcmd (
|
||||
l = e - s;
|
||||
if (l > MAXPATHL - 5)
|
||||
break;
|
||||
vim_strncpy(buf, s, l);
|
||||
STRLCPY(buf, s, l + 1);
|
||||
add_pathsep(buf);
|
||||
l = STRLEN(buf);
|
||||
vim_strncpy(buf + l, pat, MAXPATHL - 1 - l);
|
||||
STRLCPY(buf + l, pat, MAXPATHL - l);
|
||||
|
||||
/* Expand matches in one directory of $PATH. */
|
||||
ret = expand_wildcards(1, &buf, num_file, file, flags);
|
||||
|
@ -307,7 +307,7 @@ vim_findfile_init (
|
||||
|
||||
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
|
||||
/* Make the start dir an absolute path name. */
|
||||
vim_strncpy(ff_expand_buffer, rel_fname, len);
|
||||
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
|
||||
search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE);
|
||||
} else
|
||||
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
|
||||
@ -1092,7 +1092,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
||||
// For a URL we only compare the name, otherwise we compare the
|
||||
// device/inode.
|
||||
if (path_with_url(fname)) {
|
||||
vim_strncpy(ff_expand_buffer, fname, MAXPATHL - 1);
|
||||
STRLCPY(ff_expand_buffer, fname, MAXPATHL);
|
||||
url = true;
|
||||
} else {
|
||||
ff_expand_buffer[0] = NUL;
|
||||
|
@ -1599,7 +1599,7 @@ static void foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
|
||||
newline = xmalloc(line_len + markerlen + STRLEN(cms) + 1);
|
||||
STRCPY(newline, line);
|
||||
if (p == NULL)
|
||||
vim_strncpy(newline + line_len, marker, markerlen);
|
||||
STRLCPY(newline + line_len, marker, markerlen + 1);
|
||||
else {
|
||||
STRCPY(newline + line_len, cms);
|
||||
STRNCPY(newline + line_len + (p - cms), marker, markerlen);
|
||||
|
@ -266,7 +266,7 @@ add_buff (
|
||||
ssize_t len;
|
||||
if (buf->bh_space >= (int)slen) {
|
||||
len = STRLEN(buf->bh_curr->b_str);
|
||||
vim_strncpy(buf->bh_curr->b_str + len, s, (size_t)slen);
|
||||
STRLCPY(buf->bh_curr->b_str + len, s, slen + 1);
|
||||
buf->bh_space -= slen;
|
||||
} else {
|
||||
if (slen < MINIMAL_SIZE)
|
||||
@ -275,7 +275,7 @@ add_buff (
|
||||
len = slen;
|
||||
buffblock_T *p = xmalloc(sizeof(buffblock_T) + len);
|
||||
buf->bh_space = (int)(len - slen);
|
||||
vim_strncpy(p->b_str, s, (size_t)slen);
|
||||
STRLCPY(p->b_str, s, slen + 1);
|
||||
|
||||
p->b_next = buf->bh_curr->b_next;
|
||||
buf->bh_curr->b_next = p;
|
||||
|
@ -1539,7 +1539,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
|
||||
|
||||
buffer = xmallocz(MAXPATHL);
|
||||
|
||||
vim_strncpy(resource->name, (char_u *)name, 63);
|
||||
STRLCPY(resource->name, name, 64);
|
||||
/* Look for named resource file in runtimepath */
|
||||
STRCPY(buffer, "print");
|
||||
add_pathsep(buffer);
|
||||
@ -1748,14 +1748,14 @@ static int prt_open_resource(struct prt_ps_resource_S *resource)
|
||||
while (!seen_all && prt_next_dsc(&dsc_line)) {
|
||||
switch (dsc_line.type) {
|
||||
case PRT_DSC_TITLE_TYPE:
|
||||
vim_strncpy(resource->title, dsc_line.string, dsc_line.len);
|
||||
STRLCPY(resource->title, dsc_line.string, dsc_line.len + 1);
|
||||
seen_title = TRUE;
|
||||
if (seen_version)
|
||||
seen_all = TRUE;
|
||||
break;
|
||||
|
||||
case PRT_DSC_VERSION_TYPE:
|
||||
vim_strncpy(resource->version, dsc_line.string, dsc_line.len);
|
||||
STRLCPY(resource->version, dsc_line.string, dsc_line.len + 1);
|
||||
seen_version = TRUE;
|
||||
if (seen_title)
|
||||
seen_all = TRUE;
|
||||
@ -2160,8 +2160,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
||||
|
||||
/* Add charset name if not empty */
|
||||
if (p_mbchar->cmap_charset != NULL) {
|
||||
vim_strncpy((char_u *)prt_cmap,
|
||||
(char_u *)p_mbchar->cmap_charset, sizeof(prt_cmap) - 3);
|
||||
STRLCPY(prt_cmap, p_mbchar->cmap_charset, sizeof(prt_cmap) - 2);
|
||||
STRCAT(prt_cmap, "-");
|
||||
}
|
||||
} else {
|
||||
@ -2170,7 +2169,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
||||
EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding."));
|
||||
return FALSE;
|
||||
}
|
||||
vim_strncpy((char_u *)prt_cmap, p_pmcs, sizeof(prt_cmap) - 3);
|
||||
STRLCPY(prt_cmap, p_pmcs, sizeof(prt_cmap) - 2);
|
||||
STRCAT(prt_cmap, "-");
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ int cs_fgets(char_u *buf, int size)
|
||||
|
||||
if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL)
|
||||
return TRUE;
|
||||
vim_strncpy(buf, (char_u *)p, size - 1);
|
||||
STRLCPY(buf, p, size);
|
||||
|
||||
return FALSE;
|
||||
} /* cs_fgets */
|
||||
@ -2043,9 +2043,9 @@ static char *cs_resolve_file(int i, char *name)
|
||||
/* If 'cscoperelative' is set and ppath is not set, use cscope.out
|
||||
* path in path resolution. */
|
||||
csdir = xmalloc(MAXPATHL);
|
||||
vim_strncpy(csdir, (char_u *)csinfo[i].fname,
|
||||
STRLCPY(csdir, csinfo[i].fname,
|
||||
path_tail((char_u *)csinfo[i].fname)
|
||||
- (char_u *)csinfo[i].fname);
|
||||
- (char_u *)csinfo[i].fname + 1);
|
||||
len += STRLEN(csdir);
|
||||
}
|
||||
|
||||
|
@ -474,9 +474,9 @@ static void fname2fnum(xfmark_T *fm)
|
||||
|
||||
expand_env((char_u *)"~/", NameBuff, MAXPATHL);
|
||||
len = (int)STRLEN(NameBuff);
|
||||
vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1);
|
||||
STRLCPY(NameBuff + len, fm->fname + 2, MAXPATHL - len);
|
||||
} else
|
||||
vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, fm->fname, MAXPATHL);
|
||||
|
||||
/* Try to shorten the file name. */
|
||||
os_dirname(IObuff, IOSIZE);
|
||||
|
@ -677,8 +677,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
||||
size_t ulen = STRLEN(uname);
|
||||
size_t flen = STRLEN(b0p->b0_fname);
|
||||
if (retval == FAIL || ulen + flen > B0_FNAME_SIZE_CRYPT - 1) {
|
||||
vim_strncpy(b0p->b0_fname, buf->b_ffname,
|
||||
B0_FNAME_SIZE_CRYPT - 1);
|
||||
STRLCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE_CRYPT);
|
||||
} else {
|
||||
memmove(b0p->b0_fname + ulen + 1, b0p->b0_fname + 1, flen);
|
||||
memmove(b0p->b0_fname + 1, uname, ulen);
|
||||
@ -951,7 +950,7 @@ void ml_recover(void)
|
||||
smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
|
||||
|
||||
if (buf_spname(curbuf) != NULL)
|
||||
vim_strncpy(NameBuff, buf_spname(curbuf), MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, buf_spname(curbuf), MAXPATHL);
|
||||
else
|
||||
home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
|
||||
smsg((char_u *)_("Original file \"%s\""), NameBuff);
|
||||
@ -3021,7 +3020,7 @@ int resolve_symlink(char_u *fname, char_u *buf)
|
||||
return FAIL;
|
||||
|
||||
/* Put the result so far in tmp[], starting with the original name. */
|
||||
vim_strncpy(tmp, fname, MAXPATHL - 1);
|
||||
STRLCPY(tmp, fname, MAXPATHL);
|
||||
|
||||
for (;; ) {
|
||||
/* Limit symlink depth to 100, catch recursive loops. */
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Various routines dealing with allocation and deallocation of memory.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
|
@ -888,7 +888,7 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
|
||||
menu = root_menu;
|
||||
if (after_dot != arg) {
|
||||
path_name = xmalloc(after_dot - arg);
|
||||
vim_strncpy(path_name, arg, after_dot - arg - 1);
|
||||
STRLCPY(path_name, arg, after_dot - arg);
|
||||
}
|
||||
name = path_name;
|
||||
while (name != NULL && *name) {
|
||||
@ -1004,9 +1004,9 @@ char_u *get_menu_names(expand_T *xp, int idx)
|
||||
if (menu->modes & expand_modes) {
|
||||
if (menu->children != NULL) {
|
||||
if (should_advance)
|
||||
vim_strncpy(tbuffer, menu->en_dname, TBUFFER_LEN - 2);
|
||||
STRLCPY(tbuffer, menu->en_dname, TBUFFER_LEN - 1);
|
||||
else {
|
||||
vim_strncpy(tbuffer, menu->dname, TBUFFER_LEN - 2);
|
||||
STRLCPY(tbuffer, menu->dname, TBUFFER_LEN - 1);
|
||||
if (menu->en_dname == NULL)
|
||||
should_advance = TRUE;
|
||||
}
|
||||
|
@ -1838,7 +1838,8 @@ store_sb_text (
|
||||
mp->sb_eol = finish;
|
||||
mp->sb_msg_col = *sb_col;
|
||||
mp->sb_attr = attr;
|
||||
vim_strncpy(mp->sb_text, *sb_str, s - *sb_str);
|
||||
memcpy(mp->sb_text, *sb_str, s - *sb_str);
|
||||
mp->sb_text[s - *sb_str] = NUL;
|
||||
|
||||
if (last_msgchunk == NULL) {
|
||||
last_msgchunk = mp;
|
||||
|
@ -503,7 +503,7 @@ open_line (
|
||||
+ (second_line_indent > 0 ? second_line_indent : 0) + 1);
|
||||
allocated = leader; /* remember to free it later */
|
||||
|
||||
vim_strncpy(leader, saved_line, lead_len);
|
||||
STRLCPY(leader, saved_line, lead_len + 1);
|
||||
|
||||
/*
|
||||
* Replace leader with lead_repl, right or left adjusted
|
||||
@ -2560,11 +2560,9 @@ void msgmore(long n)
|
||||
if (pn > p_report) {
|
||||
if (pn == 1) {
|
||||
if (n > 0)
|
||||
vim_strncpy(msg_buf, (char_u *)_("1 more line"),
|
||||
MSG_BUF_LEN - 1);
|
||||
STRLCPY(msg_buf, _("1 more line"), MSG_BUF_LEN);
|
||||
else
|
||||
vim_strncpy(msg_buf, (char_u *)_("1 line less"),
|
||||
MSG_BUF_LEN - 1);
|
||||
STRLCPY(msg_buf, _("1 line less"), MSG_BUF_LEN);
|
||||
} else {
|
||||
if (n > 0)
|
||||
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
|
||||
@ -3109,7 +3107,7 @@ char_u *get_env_name(expand_T *xp, int idx)
|
||||
static char_u name[ENVNAMELEN];
|
||||
char *envname = os_getenvname_at_index(idx);
|
||||
if (envname) {
|
||||
vim_strncpy(name, (char_u *)envname, ENVNAMELEN - 1);
|
||||
STRLCPY(name, envname, ENVNAMELEN);
|
||||
free(envname);
|
||||
return name;
|
||||
} else {
|
||||
|
@ -375,7 +375,7 @@ int vim_chdirfile(char_u *fname)
|
||||
{
|
||||
char_u dir[MAXPATHL];
|
||||
|
||||
vim_strncpy(dir, fname, MAXPATHL - 1);
|
||||
STRLCPY(dir, fname, MAXPATHL);
|
||||
*path_tail_with_sep(dir) = NUL;
|
||||
return os_chdir((char *)dir) == 0 ? OK : FAIL;
|
||||
}
|
||||
|
@ -2222,7 +2222,7 @@ int op_change(oparg_T *oap)
|
||||
/* Subsequent calls to ml_get() flush the firstline data - take a
|
||||
* copy of the inserted text. */
|
||||
ins_text = (char_u *) xmalloc((size_t)(ins_len + 1));
|
||||
vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
|
||||
STRLCPY(ins_text, firstline + bd.textcol, ins_len + 1);
|
||||
for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum;
|
||||
linenr++) {
|
||||
block_prep(oap, &bd, linenr, TRUE);
|
||||
|
@ -3209,7 +3209,7 @@ skip:
|
||||
}
|
||||
|
||||
if (errmsg != NULL) {
|
||||
vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
|
||||
STRLCPY(IObuff, _(errmsg), IOSIZE);
|
||||
i = (int)STRLEN(IObuff) + 2;
|
||||
if (i + (arg - startarg) < IOSIZE) {
|
||||
/* append the argument with the error */
|
||||
@ -7480,7 +7480,7 @@ option_value2string (
|
||||
else if ((char_u **)opp->var == &p_pt)
|
||||
str2specialbuf(p_pt, NameBuff, MAXPATHL);
|
||||
else
|
||||
vim_strncpy(NameBuff, varp, MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, varp, MAXPATHL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ int os_dirname(char_u *buf, size_t len)
|
||||
|
||||
int errno;
|
||||
if ((errno = uv_cwd((char *)buf, &len)) != kLibuvSuccess) {
|
||||
vim_strncpy(buf, (char_u *)uv_strerror(errno), len - 1);
|
||||
STRLCPY(buf, uv_strerror(errno), len);
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
@ -123,7 +123,7 @@ static bool is_executable_in_path(const char_u *name)
|
||||
|
||||
// Glue together the given directory from $PATH with name and save into
|
||||
// buf.
|
||||
vim_strncpy(buf, (char_u *) path, e - path);
|
||||
STRLCPY(buf, path, e - path + 1);
|
||||
append_path((char *) buf, (const char *) name, (int)buf_len);
|
||||
|
||||
if (is_executable(buf)) {
|
||||
|
@ -56,7 +56,7 @@ int os_get_uname(uid_t uid, char *s, size_t len)
|
||||
|
||||
if ((pw = getpwuid(uid)) != NULL
|
||||
&& pw->pw_name != NULL && *(pw->pw_name) != NUL) {
|
||||
vim_strncpy((char_u *)s, (char_u *)pw->pw_name, len - 1);
|
||||
STRLCPY(s, pw->pw_name, len);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -409,9 +409,9 @@ int len /* buffer size, only used when name gets longer */
|
||||
struct stat st2;
|
||||
|
||||
/* Verify the inode is equal. */
|
||||
vim_strncpy(newname, name, MAXPATHL);
|
||||
vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
|
||||
MAXPATHL - (tail - name));
|
||||
STRLCPY(newname, name, MAXPATHL + 1);
|
||||
STRLCPY(newname + (tail - name), dp->d_name,
|
||||
MAXPATHL - (tail - name) + 1);
|
||||
if (lstat((char *)newname, &st2) >= 0
|
||||
&& st.st_ino == st2.st_ino
|
||||
&& st.st_dev == st2.st_dev) {
|
||||
|
@ -1534,7 +1534,7 @@ vim_FullName (
|
||||
retval = path_get_absolute_path(fname, buf, len, force);
|
||||
if (url || retval == FAIL) {
|
||||
/* something failed; use the file name (truncate when too long) */
|
||||
vim_strncpy(buf, fname, len - 1);
|
||||
STRLCPY(buf, fname, len);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -484,9 +484,9 @@ qf_init_ext (
|
||||
len = (int)STRLEN(p_str);
|
||||
|
||||
if (len > CMDBUFFSIZE - 2)
|
||||
vim_strncpy(IObuff, p_str, CMDBUFFSIZE - 2);
|
||||
STRLCPY(IObuff, p_str, CMDBUFFSIZE - 1);
|
||||
else
|
||||
vim_strncpy(IObuff, p_str, len);
|
||||
STRLCPY(IObuff, p_str, len + 1);
|
||||
|
||||
p_str += len;
|
||||
} else if (tv->v_type == VAR_LIST) {
|
||||
@ -501,7 +501,7 @@ qf_init_ext (
|
||||
if (len > CMDBUFFSIZE - 2)
|
||||
len = CMDBUFFSIZE - 2;
|
||||
|
||||
vim_strncpy(IObuff, p_li->li_tv.vval.v_string, len);
|
||||
STRLCPY(IObuff, p_li->li_tv.vval.v_string, len + 1);
|
||||
|
||||
p_li = p_li->li_next; /* next item */
|
||||
}
|
||||
@ -509,8 +509,8 @@ qf_init_ext (
|
||||
/* Get the next line from the supplied buffer */
|
||||
if (buflnum > lnumlast)
|
||||
break;
|
||||
vim_strncpy(IObuff, ml_get_buf(buf, buflnum++, FALSE),
|
||||
CMDBUFFSIZE - 2);
|
||||
STRLCPY(IObuff, ml_get_buf(buf, buflnum++, FALSE),
|
||||
CMDBUFFSIZE - 1);
|
||||
}
|
||||
} else if (fgets((char *)IObuff, CMDBUFFSIZE - 2, fd) == NULL)
|
||||
break;
|
||||
@ -609,7 +609,7 @@ restofline:
|
||||
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
|
||||
continue;
|
||||
len = (int)(regmatch.endp[i] - regmatch.startp[i]);
|
||||
vim_strncpy(errmsg, regmatch.startp[i], len);
|
||||
STRLCPY(errmsg, regmatch.startp[i], len + 1);
|
||||
}
|
||||
if ((i = (int)fmt_ptr->addr[6]) > 0) { /* %r */
|
||||
if (regmatch.startp[i] == NULL)
|
||||
|
@ -6772,7 +6772,7 @@ char_u *reg_submatch(int no)
|
||||
len = submatch_mmatch->endpos[no].col
|
||||
- submatch_mmatch->startpos[no].col;
|
||||
if (round == 2)
|
||||
vim_strncpy(retval, s, len);
|
||||
STRLCPY(retval, s, len + 1);
|
||||
++len;
|
||||
} else {
|
||||
/* Multiple lines: take start line from start col, middle
|
||||
|
@ -5082,11 +5082,11 @@ win_redr_custom (
|
||||
|
||||
/* Make all characters printable. */
|
||||
p = transstr(buf);
|
||||
vim_strncpy(buf, p, sizeof(buf) - 1);
|
||||
len = STRLCPY(buf, p, sizeof(buf));
|
||||
len = (size_t)len < sizeof(buf) ? len : (int)sizeof(buf) - 1;
|
||||
free(p);
|
||||
|
||||
/* fill up with "fillchar" */
|
||||
len = (int)STRLEN(buf);
|
||||
while (width < maxwidth && len < (int)sizeof(buf) - 1) {
|
||||
len += (*mb_char2bytes)(fillchar, buf + len);
|
||||
++width;
|
||||
@ -7626,7 +7626,7 @@ static void draw_tabline(void)
|
||||
void get_trans_bufname(buf_T *buf)
|
||||
{
|
||||
if (buf_spname(buf) != NULL)
|
||||
vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
|
||||
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
|
||||
else
|
||||
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
|
||||
trans_characters(NameBuff, MAXPATHL);
|
||||
|
@ -1553,7 +1553,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
if (ptr == mip->mi_word)
|
||||
(void)spell_casefold(ptr, wlen, fword, MAXWLEN);
|
||||
else
|
||||
vim_strncpy(fword, ptr, endlen[endidxcnt]);
|
||||
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
|
||||
}
|
||||
if (!can_compound(slang, fword, mip->mi_compflags))
|
||||
continue;
|
||||
@ -2274,7 +2274,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen)
|
||||
n = (int)(p - line) + 1;
|
||||
if (n < maxlen - 1) {
|
||||
memset(buf, ' ', n);
|
||||
vim_strncpy(buf + n, p, maxlen - 1 - n);
|
||||
STRLCPY(buf + n, p, maxlen - n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3064,7 +3064,7 @@ count_common_word (
|
||||
if (len == -1)
|
||||
p = word;
|
||||
else {
|
||||
vim_strncpy(buf, word, len);
|
||||
STRLCPY(buf, word, len + 1);
|
||||
p = buf;
|
||||
}
|
||||
|
||||
@ -3354,7 +3354,7 @@ static int init_syl_tab(slang_T *slang)
|
||||
ga_grow(&slang->sl_syl_items, 1);
|
||||
syl = ((syl_item_T *)slang->sl_syl_items.ga_data)
|
||||
+ slang->sl_syl_items.ga_len++;
|
||||
vim_strncpy(syl->sy_chars, s, l);
|
||||
STRLCPY(syl->sy_chars, s, l + 1);
|
||||
syl->sy_len = l;
|
||||
}
|
||||
return OK;
|
||||
@ -3761,7 +3761,7 @@ char_u *did_set_spelllang(win_T *wp)
|
||||
p = vim_strchr(path_tail(lang), '_');
|
||||
if (p != NULL && ASCII_ISALPHA(p[1]) && ASCII_ISALPHA(p[2])
|
||||
&& !ASCII_ISALPHA(p[3])) {
|
||||
vim_strncpy(region_cp, p + 1, 2);
|
||||
STRLCPY(region_cp, p + 1, 3);
|
||||
memmove(p, p + 3, len - (p - lang) - 2);
|
||||
len -= 3;
|
||||
region = region_cp;
|
||||
@ -3883,7 +3883,7 @@ char_u *did_set_spelllang(win_T *wp)
|
||||
if (round == 0)
|
||||
STRCPY(lang, "internal wordlist");
|
||||
else {
|
||||
vim_strncpy(lang, path_tail(spf_name), MAXWLEN);
|
||||
STRLCPY(lang, path_tail(spf_name), MAXWLEN + 1);
|
||||
p = vim_strchr(lang, '.');
|
||||
if (p != NULL)
|
||||
*p = NUL; // truncate at ".encoding.add"
|
||||
@ -4004,7 +4004,7 @@ static void use_midword(slang_T *lp, win_T *wp)
|
||||
bp = vim_strnsave(wp->w_s->b_spell_ismw_mb, n + l);
|
||||
free(wp->w_s->b_spell_ismw_mb);
|
||||
wp->w_s->b_spell_ismw_mb = bp;
|
||||
vim_strncpy(bp + n, p, l);
|
||||
STRLCPY(bp + n, p, l + 1);
|
||||
}
|
||||
p += l;
|
||||
} else
|
||||
@ -4652,7 +4652,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
// times. The affix files that do this have an undocumented
|
||||
// "S" flag on all but the last block, thus we check for that
|
||||
// and store it in ah_follows.
|
||||
vim_strncpy(key, items[1], AH_KEY_LEN - 1);
|
||||
STRLCPY(key, items[1], AH_KEY_LEN);
|
||||
hi = hash_find(tp, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
cur_aff = HI2AH(hi);
|
||||
@ -5223,7 +5223,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
|
||||
if (flag != 0) {
|
||||
// Find the flag in the hashtable. If it was used before, use
|
||||
// the existing ID. Otherwise add a new entry.
|
||||
vim_strncpy(key, prevp, p - prevp);
|
||||
STRLCPY(key, prevp, p - prevp + 1);
|
||||
hi = hash_find(&aff->af_comp, key);
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
id = HI2CI(hi)->ci_newID;
|
||||
@ -5612,7 +5612,7 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist
|
||||
if (get_affitem(affile->af_flagtype, &p) != 0) {
|
||||
// A flag is a postponed prefix flag if it appears in "af_pref"
|
||||
// and it's ID is not zero.
|
||||
vim_strncpy(key, prevp, p - prevp);
|
||||
STRLCPY(key, prevp, p - prevp + 1);
|
||||
hi = hash_find(&affile->af_pref, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
id = HI2AH(hi)->ah_newID;
|
||||
@ -5643,7 +5643,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl
|
||||
prevp = p;
|
||||
if (get_affitem(affile->af_flagtype, &p) != 0) {
|
||||
// A flag is a compound flag if it appears in "af_comp".
|
||||
vim_strncpy(key, prevp, p - prevp);
|
||||
STRLCPY(key, prevp, p - prevp + 1);
|
||||
hi = hash_find(&affile->af_comp, key);
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
store_afflist[cnt++] = HI2CI(hi)->ci_newID;
|
||||
@ -5738,7 +5738,7 @@ store_aff_word (
|
||||
if (ae->ae_add == NULL)
|
||||
*newword = NUL;
|
||||
else
|
||||
vim_strncpy(newword, ae->ae_add, MAXWLEN - 1);
|
||||
STRLCPY(newword, ae->ae_add, MAXWLEN);
|
||||
p = word;
|
||||
if (ae->ae_chop != NULL) {
|
||||
// Skip chop string.
|
||||
@ -5752,7 +5752,7 @@ store_aff_word (
|
||||
STRCAT(newword, p);
|
||||
} else {
|
||||
// suffix: chop/add at the end of the word
|
||||
vim_strncpy(newword, word, MAXWLEN - 1);
|
||||
STRLCPY(newword, word, MAXWLEN);
|
||||
if (ae->ae_chop != NULL) {
|
||||
// Remove chop string.
|
||||
p = newword + STRLEN(newword);
|
||||
@ -5834,7 +5834,7 @@ store_aff_word (
|
||||
// Obey a "COMPOUNDFORBIDFLAG" of the affix: don't
|
||||
// use the compound flags.
|
||||
if (use_pfxlist != NULL && ae->ae_compforbid) {
|
||||
vim_strncpy(pfx_pfxlist, use_pfxlist, use_pfxlen);
|
||||
STRLCPY(pfx_pfxlist, use_pfxlist, use_pfxlen + 1);
|
||||
use_pfxlist = pfx_pfxlist;
|
||||
}
|
||||
|
||||
@ -7188,7 +7188,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname)
|
||||
// Write the .sug file.
|
||||
// Make the file name by changing ".spl" to ".sug".
|
||||
fname = xmalloc(MAXPATHL);
|
||||
vim_strncpy(fname, wfname, MAXPATHL - 1);
|
||||
STRLCPY(fname, wfname, MAXPATHL);
|
||||
len = (int)STRLEN(fname);
|
||||
fname[len - 2] = 'u';
|
||||
fname[len - 1] = 'g';
|
||||
@ -7612,7 +7612,7 @@ mkspell (
|
||||
fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc());
|
||||
} else if (len > 4 && STRCMP(fnames[0] + len - 4, ".spl") == 0) {
|
||||
// Name ends in ".spl", use as the file name.
|
||||
vim_strncpy(wfname, fnames[0], MAXPATHL - 1);
|
||||
STRLCPY(wfname, fnames[0], MAXPATHL);
|
||||
} else
|
||||
// Name should be language, make the file name from it.
|
||||
vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL,
|
||||
@ -7974,8 +7974,8 @@ static void init_spellfile(void)
|
||||
if (aspath)
|
||||
// Use directory of an entry with path, e.g., for
|
||||
// "/dir/lg.utf-8.spl" use "/dir".
|
||||
vim_strncpy(buf, curbuf->b_s.b_p_spl,
|
||||
lstart - curbuf->b_s.b_p_spl - 1);
|
||||
STRLCPY(buf, curbuf->b_s.b_p_spl,
|
||||
lstart - curbuf->b_s.b_p_spl);
|
||||
else
|
||||
// Copy the path from 'runtimepath' to buf[].
|
||||
copy_option_part(&rtp, buf, MAXPATHL, ",");
|
||||
@ -7983,8 +7983,8 @@ static void init_spellfile(void)
|
||||
// Use the first language name from 'spelllang' and the
|
||||
// encoding used in the first loaded .spl file.
|
||||
if (aspath)
|
||||
vim_strncpy(buf, curbuf->b_s.b_p_spl,
|
||||
lend - curbuf->b_s.b_p_spl);
|
||||
STRLCPY(buf, curbuf->b_s.b_p_spl,
|
||||
lend - curbuf->b_s.b_p_spl + 1);
|
||||
else {
|
||||
// Create the "spell" directory if it doesn't exist yet.
|
||||
l = (int)STRLEN(buf);
|
||||
@ -8530,11 +8530,11 @@ void spell_suggest(int count)
|
||||
|
||||
// The suggested word may replace only part of the bad word, add
|
||||
// the not replaced part.
|
||||
vim_strncpy(wcopy, stp->st_word, MAXWLEN);
|
||||
STRLCPY(wcopy, stp->st_word, MAXWLEN + 1);
|
||||
if (sug.su_badlen > stp->st_orglen)
|
||||
vim_strncpy(wcopy + stp->st_wordlen,
|
||||
STRLCPY(wcopy + stp->st_wordlen,
|
||||
sug.su_badptr + stp->st_orglen,
|
||||
sug.su_badlen - stp->st_orglen);
|
||||
sug.su_badlen - stp->st_orglen + 1);
|
||||
vim_snprintf((char *)IObuff, IOSIZE, "%2d", i + 1);
|
||||
if (cmdmsg_rl)
|
||||
rl_mirror(IObuff);
|
||||
@ -8816,7 +8816,7 @@ spell_find_suggest (
|
||||
|
||||
if (su->su_badlen >= MAXWLEN)
|
||||
su->su_badlen = MAXWLEN - 1; // just in case
|
||||
vim_strncpy(su->su_badword, su->su_badptr, su->su_badlen);
|
||||
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
|
||||
(void)spell_casefold(su->su_badptr, su->su_badlen,
|
||||
su->su_fbadword, MAXWLEN);
|
||||
// get caps flags for bad word
|
||||
@ -9259,7 +9259,7 @@ onecap_copy (
|
||||
l = 1;
|
||||
wcopy[0] = c;
|
||||
}
|
||||
vim_strncpy(wcopy + l, p, MAXWLEN - l - 1);
|
||||
STRLCPY(wcopy + l, p, MAXWLEN - l);
|
||||
}
|
||||
|
||||
// Make a copy of "word" with all the letters upper cased into
|
||||
@ -9625,9 +9625,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou
|
||||
|
||||
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
|
||||
compflags[sp->ts_complen + 1] = NUL;
|
||||
vim_strncpy(preword + sp->ts_prewordlen,
|
||||
STRLCPY(preword + sp->ts_prewordlen,
|
||||
tword + sp->ts_splitoff,
|
||||
sp->ts_twordlen - sp->ts_splitoff);
|
||||
sp->ts_twordlen - sp->ts_splitoff + 1);
|
||||
|
||||
// Verify CHECKCOMPOUNDPATTERN rules.
|
||||
if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
|
||||
@ -10968,8 +10968,8 @@ stp_sal_score (
|
||||
// Add part of the bad word to the good word, so that we soundfold
|
||||
// what replaces the bad word.
|
||||
STRCPY(goodword, stp->st_word);
|
||||
vim_strncpy(goodword + stp->st_wordlen,
|
||||
su->su_badptr + su->su_badlen - lendiff, lendiff);
|
||||
STRLCPY(goodword + stp->st_wordlen,
|
||||
su->su_badptr + su->su_badlen - lendiff, lendiff + 1);
|
||||
pgood = goodword;
|
||||
} else
|
||||
pgood = stp->st_word;
|
||||
@ -11545,10 +11545,10 @@ check_suggestions (
|
||||
stp = &SUG(*gap, 0);
|
||||
for (int i = gap->ga_len - 1; i >= 0; --i) {
|
||||
// Need to append what follows to check for "the the".
|
||||
vim_strncpy(longword, stp[i].st_word, MAXWLEN);
|
||||
STRLCPY(longword, stp[i].st_word, MAXWLEN + 1);
|
||||
len = stp[i].st_wordlen;
|
||||
vim_strncpy(longword + len, su->su_badptr + stp[i].st_orglen,
|
||||
MAXWLEN - len);
|
||||
STRLCPY(longword + len, su->su_badptr + stp[i].st_orglen,
|
||||
MAXWLEN - len + 1);
|
||||
attr = HLF_COUNT;
|
||||
(void)spell_check(curwin, longword, &attr, NULL, FALSE);
|
||||
if (attr != HLF_COUNT) {
|
||||
@ -11815,7 +11815,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res)
|
||||
}
|
||||
*t = NUL;
|
||||
} else
|
||||
vim_strncpy(word, s, MAXWLEN - 1);
|
||||
STRLCPY(word, s, MAXWLEN);
|
||||
|
||||
smp = (salitem_T *)slang->sl_sal.ga_data;
|
||||
|
||||
@ -13269,7 +13269,7 @@ dump_prefixes (
|
||||
|
||||
c = valid_word_prefix(i, n, flags, word, slang, FALSE);
|
||||
if (c != 0) {
|
||||
vim_strncpy(prefix + depth, word, MAXWLEN - depth - 1);
|
||||
STRLCPY(prefix + depth, word, MAXWLEN - depth);
|
||||
dump_word(slang, prefix, pat, dir, dumpflags,
|
||||
(c & WF_RAREPFX) ? (flags | WF_RARE)
|
||||
: flags, lnum);
|
||||
@ -13284,8 +13284,7 @@ dump_prefixes (
|
||||
c = valid_word_prefix(i, n, flags, word_up, slang,
|
||||
TRUE);
|
||||
if (c != 0) {
|
||||
vim_strncpy(prefix + depth, word_up,
|
||||
MAXWLEN - depth - 1);
|
||||
STRLCPY(prefix + depth, word_up, MAXWLEN - depth);
|
||||
dump_word(slang, prefix, pat, dir, dumpflags,
|
||||
(c & WF_RAREPFX) ? (flags | WF_RARE)
|
||||
: flags, lnum);
|
||||
|
@ -2915,7 +2915,7 @@ check_keyword_id (
|
||||
* Must make a copy of the keyword, so we can add a NUL and make it
|
||||
* lowercase.
|
||||
*/
|
||||
vim_strncpy(keyword, kwp, kwlen);
|
||||
STRLCPY(keyword, kwp, kwlen + 1);
|
||||
|
||||
keyentry_T *kp = NULL;
|
||||
|
||||
@ -5122,7 +5122,7 @@ get_id_list (
|
||||
for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end)
|
||||
;
|
||||
name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */
|
||||
vim_strncpy(name + 1, p, end - p);
|
||||
STRLCPY(name + 1, p, end - p + 1);
|
||||
if ( STRCMP(name + 1, "ALLBUT") == 0
|
||||
|| STRCMP(name + 1, "ALL") == 0
|
||||
|| STRCMP(name + 1, "TOP") == 0
|
||||
@ -7229,7 +7229,7 @@ int syn_name2id(char_u *name)
|
||||
/* Avoid using stricmp() too much, it's slow on some systems */
|
||||
/* Avoid alloc()/free(), these are slow too. ID names over 200 chars
|
||||
* don't deserve to be found! */
|
||||
vim_strncpy(name_u, name, 199);
|
||||
STRLCPY(name_u, name, 200);
|
||||
vim_strup(name_u);
|
||||
for (i = highlight_ga.ga_len; --i >= 0; )
|
||||
if (HL_TABLE()[i].sg_name_u != NULL
|
||||
|
@ -698,12 +698,11 @@ do_tag (
|
||||
len = (int)(tagp.tagname_end - tagp.tagname);
|
||||
if (len > 128)
|
||||
len = 128;
|
||||
vim_strncpy(tag_name, tagp.tagname, len);
|
||||
tag_name[len] = NUL;
|
||||
STRLCPY(tag_name, tagp.tagname, len + 1);
|
||||
|
||||
/* Save the tag file name */
|
||||
p = tag_full_fname(&tagp);
|
||||
vim_strncpy(fname, p, MAXPATHL);
|
||||
STRLCPY(fname, p, MAXPATHL + 1);
|
||||
free(p);
|
||||
|
||||
/*
|
||||
@ -1827,7 +1826,7 @@ parse_line:
|
||||
mfp = xmalloc(sizeof(struct match_found) + len);
|
||||
mfp->len = len + 1; /* include the NUL */
|
||||
p = mfp->match;
|
||||
vim_strncpy(p, tagp.command + 2, len);
|
||||
STRLCPY(p, tagp.command + 2, len + 1);
|
||||
} else
|
||||
mfp = NULL;
|
||||
get_it_again = FALSE;
|
||||
@ -1836,7 +1835,7 @@ parse_line:
|
||||
mfp = xmalloc(sizeof(struct match_found) + len);
|
||||
mfp->len = len + 1; /* include the NUL */
|
||||
p = mfp->match;
|
||||
vim_strncpy(p, tagp.tagname, len);
|
||||
STRLCPY(p, tagp.tagname, len + 1);
|
||||
|
||||
/* if wanted, re-read line to get long form too */
|
||||
if (State & INSERT)
|
||||
@ -2058,8 +2057,8 @@ get_tagfname (
|
||||
STRCPY(buf, p_hf);
|
||||
STRCPY(path_tail(buf), "tags");
|
||||
} else
|
||||
vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[
|
||||
tnp->tn_hf_idx++], MAXPATHL - 1);
|
||||
STRLCPY(buf, ((char_u **)(tag_fnames.ga_data))[
|
||||
tnp->tn_hf_idx++], MAXPATHL);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -2636,8 +2635,8 @@ static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
|
||||
&& (p = path_tail(tag_fname)) != tag_fname) {
|
||||
retval = xmalloc(MAXPATHL);
|
||||
STRCPY(retval, tag_fname);
|
||||
vim_strncpy(retval + (p - tag_fname), fname,
|
||||
MAXPATHL - (p - tag_fname) - 1);
|
||||
STRLCPY(retval + (p - tag_fname), fname,
|
||||
MAXPATHL - (p - tag_fname));
|
||||
/*
|
||||
* Translate names like "src/a/../b/file.c" into "src/b/file.c".
|
||||
*/
|
||||
@ -2791,7 +2790,7 @@ add_tag_field (
|
||||
len = (int)(end - start);
|
||||
if (len > MAXPATHL - 1)
|
||||
len = MAXPATHL - 1;
|
||||
vim_strncpy(buf, start, len);
|
||||
STRLCPY(buf, start, len + 1);
|
||||
}
|
||||
buf[len] = NUL;
|
||||
retval = dict_add_nr_str(dict, field_name, 0L, buf);
|
||||
|
@ -903,9 +903,10 @@ static void do_intro_line(int row, char_u *mesg, int add_version, int attr)
|
||||
char_u modby[MODBY_LEN];
|
||||
|
||||
if (*mesg == ' ') {
|
||||
vim_strncpy(modby, (char_u *)_("Modified by "), MODBY_LEN - 1);
|
||||
l = STRLEN(modby);
|
||||
vim_strncpy(modby + l, (char_u *)MODIFIED_BY, MODBY_LEN - l - 1);
|
||||
l = STRLCPY(modby, _("Modified by "), MODBY_LEN);
|
||||
if (l < MODBY_LEN - 1) {
|
||||
STRLCPY(modby + l, MODIFIED_BY, MODBY_LEN - l);
|
||||
}
|
||||
mesg = modby;
|
||||
}
|
||||
#endif // ifdef MODIFIED_BY
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef NVIM_VIM_H
|
||||
# define NVIM_VIM_H
|
||||
|
||||
#include "nvim/memory.h"// for xstrlcpy
|
||||
#include "nvim/types.h"
|
||||
|
||||
/* Included when ported to cmake */
|
||||
@ -834,6 +835,7 @@ typedef enum {
|
||||
#define STRLEN(s) strlen((char *)(s))
|
||||
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
|
||||
#define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))
|
||||
#define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
|
||||
#define STRCMP(d, s) strcmp((char *)(d), (char *)(s))
|
||||
#define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
|
||||
#ifdef HAVE_STRCASECMP
|
||||
|
Loading…
Reference in New Issue
Block a user