diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-25 20:58:42 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-07-25 20:58:42 +0200 |
commit | 242667ae142d9862a7bace82c58cb11c79fdab7a (patch) | |
tree | e46e81b339824a908e2b1e0530b58da37ee37ecb | |
parent | 4d68054c1e49b937a1aa9567196b97b36fe99c27 (diff) |
patch 9.1.0615: Unnecessary STRLEN() in make_percent_swname()v9.1.0615
Problem: Unnecessary STRLEN() in make_percent_swname()
Solution: Pass the end of "dir" to make_percent_swname()
(zeertzjq)
closes: #15340
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/bufwrite.c | 4 | ||||
-rw-r--r-- | src/memline.c | 8 | ||||
-rw-r--r-- | src/proto/memline.pro | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c index c9d9875d64..23cd884bfa 100644 --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -1350,7 +1350,7 @@ buf_write( p = copybuf + STRLEN(copybuf); if (after_pathsep(copybuf, p) && p[-1] == p[-2]) // Ends with '//', use full path - if ((p = make_percent_swname(copybuf, fname)) != NULL) + if ((p = make_percent_swname(copybuf, p, fname)) != NULL) { backup = modname(p, backup_ext, FALSE); vim_free(p); @@ -1564,7 +1564,7 @@ buf_write( p = IObuff + STRLEN(IObuff); if (after_pathsep(IObuff, p) && p[-1] == p[-2]) // path ends with '//', use full path - if ((p = make_percent_swname(IObuff, fname)) != NULL) + if ((p = make_percent_swname(IObuff, p, fname)) != NULL) { backup = modname(p, backup_ext, FALSE); vim_free(p); diff --git a/src/memline.c b/src/memline.c index 9e579cdfd9..b93eb0a48e 100644 --- a/src/memline.c +++ b/src/memline.c @@ -1975,7 +1975,7 @@ recover_names( if (after_pathsep(dir_name, p) && len > 1 && p[-1] == p[-2]) { // Ends with '//', Use Full path for swap name - tail = make_percent_swname(dir_name, fname_res); + tail = make_percent_swname(dir_name, p, fname_res); } else #endif @@ -2143,7 +2143,7 @@ recover_names( * removed. */ char_u * -make_percent_swname(char_u *dir, char_u *name) +make_percent_swname(char_u *dir, char_u *dir_end, char_u *name) { char_u *d = NULL, *s, *f; @@ -2159,7 +2159,7 @@ make_percent_swname(char_u *dir, char_u *name) if (vim_ispathsep(*d)) *d = '%'; - dir[STRLEN(dir) - 1] = NUL; // remove one trailing slash + dir_end[-1] = NUL; // remove one trailing slash d = concat_fnames(dir, s, TRUE); vim_free(s); } @@ -4676,7 +4676,7 @@ makeswapname( if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2]) { // Ends with '//', Use Full path r = NULL; - if ((s = make_percent_swname(dir_name, fname_res)) != NULL) + if ((s = make_percent_swname(dir_name, s, fname_res)) != NULL) { r = modname(s, (char_u *)".swp", FALSE); vim_free(s); diff --git a/src/proto/memline.pro b/src/proto/memline.pro index c5d9b5d8da..238bceafbb 100644 --- a/src/proto/memline.pro +++ b/src/proto/memline.pro @@ -11,7 +11,7 @@ void ml_close_notmod(void); void ml_timestamp(buf_T *buf); void ml_recover(int checkext); int recover_names(char_u *fname, int do_list, list_T *ret_list, int nr, char_u **fname_out); -char_u *make_percent_swname(char_u *dir, char_u *name); +char_u *make_percent_swname(char_u *dir, char_u *dir_end, char_u *name); void get_b0_dict(char_u *fname, dict_T *d); void ml_sync_all(int check_file, int check_char); void ml_preserve(buf_T *buf, int message); diff --git a/src/version.c b/src/version.c index 3d6e3a878e..f434a136b8 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 615, +/**/ 614, /**/ 613, |