Replace vim_strncpy calls: tag.c

This commit is contained in:
Douglas Schneider
2014-05-29 08:20:11 -06:00
committed by Justin M. Keyes
parent 1a1725765c
commit 43f5a5ef65

View File

@@ -698,12 +698,11 @@ do_tag (
len = (int)(tagp.tagname_end - tagp.tagname); len = (int)(tagp.tagname_end - tagp.tagname);
if (len > 128) if (len > 128)
len = 128; len = 128;
vim_strncpy(tag_name, tagp.tagname, len); STRLCPY(tag_name, tagp.tagname, len + 1);
tag_name[len] = NUL;
/* Save the tag file name */ /* Save the tag file name */
p = tag_full_fname(&tagp); p = tag_full_fname(&tagp);
vim_strncpy(fname, p, MAXPATHL); STRLCPY(fname, p, MAXPATHL + 1);
free(p); free(p);
/* /*
@@ -1827,7 +1826,7 @@ parse_line:
mfp = xmalloc(sizeof(struct match_found) + len); mfp = xmalloc(sizeof(struct match_found) + len);
mfp->len = len + 1; /* include the NUL */ mfp->len = len + 1; /* include the NUL */
p = mfp->match; p = mfp->match;
vim_strncpy(p, tagp.command + 2, len); STRLCPY(p, tagp.command + 2, len + 1);
} else } else
mfp = NULL; mfp = NULL;
get_it_again = FALSE; get_it_again = FALSE;
@@ -1836,7 +1835,7 @@ parse_line:
mfp = xmalloc(sizeof(struct match_found) + len); mfp = xmalloc(sizeof(struct match_found) + len);
mfp->len = len + 1; /* include the NUL */ mfp->len = len + 1; /* include the NUL */
p = mfp->match; 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 wanted, re-read line to get long form too */
if (State & INSERT) if (State & INSERT)
@@ -2058,8 +2057,8 @@ get_tagfname (
STRCPY(buf, p_hf); STRCPY(buf, p_hf);
STRCPY(path_tail(buf), "tags"); STRCPY(path_tail(buf), "tags");
} else } else
vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[ STRLCPY(buf, ((char_u **)(tag_fnames.ga_data))[
tnp->tn_hf_idx++], MAXPATHL - 1); tnp->tn_hf_idx++], MAXPATHL);
return OK; 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) { && (p = path_tail(tag_fname)) != tag_fname) {
retval = xmalloc(MAXPATHL); retval = xmalloc(MAXPATHL);
STRCPY(retval, tag_fname); STRCPY(retval, tag_fname);
vim_strncpy(retval + (p - tag_fname), fname, STRLCPY(retval + (p - tag_fname), fname,
MAXPATHL - (p - tag_fname) - 1); MAXPATHL - (p - tag_fname));
/* /*
* Translate names like "src/a/../b/file.c" into "src/b/file.c". * Translate names like "src/a/../b/file.c" into "src/b/file.c".
*/ */
@@ -2791,7 +2790,7 @@ add_tag_field (
len = (int)(end - start); len = (int)(end - start);
if (len > MAXPATHL - 1) if (len > MAXPATHL - 1)
len = MAXPATHL - 1; len = MAXPATHL - 1;
vim_strncpy(buf, start, len); STRLCPY(buf, start, len + 1);
} }
buf[len] = NUL; buf[len] = NUL;
retval = dict_add_nr_str(dict, field_name, 0L, buf); retval = dict_add_nr_str(dict, field_name, 0L, buf);