]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0002: str2specialbuf() can be improved v9.2.0002
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sun, 15 Feb 2026 14:48:54 +0000 (14:48 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 15 Feb 2026 14:50:35 +0000 (14:50 +0000)
Problem:  str2specialbuf() can be improved
Solution: Optimize str2specialbuf function in message.c
          (Yasuhiro Matsumoto)

closes: #19415

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/message.c
src/version.c

index e2058f8d4d65d5eac6d8a50356e6e5120cfe8227..192442ab4eac782f8ae9d43606e50a8564058e9b 100644 (file)
@@ -2012,14 +2012,22 @@ str2special(
     void
 str2specialbuf(char_u *sp, char_u *buf, int len)
 {
-    char_u     *s;
+    char_u     *s;
+    size_t     buf_len = 0;
+    size_t     s_len;
 
     *buf = NUL;
     while (*sp)
     {
-       s = str2special(&sp, FALSE, FALSE);
-       if ((int)(STRLEN(s) + STRLEN(buf)) < len)
-           STRCAT(buf, s);
+        s = str2special(&sp, FALSE, FALSE);
+        s_len = STRLEN(s);
+        if (buf_len + s_len < (size_t)len)
+        {
+            STRCPY(buf + buf_len, s);
+            buf_len += s_len;
+        }
+        else
+            break;
     }
 }
 
index 8dd6db06c72b7a9de908511d8a745f8cebb307ec..0b6275096c245ece48047f495481fecf68871b5d 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2,
 /**/
     1,
 /**/