patch 9.2.0002: str2specialbuf() can be improved

Commit: 
https://github.com/vim/vim/commit/76826c24dfcd89503ba92119089f96e7feeaa098
Author: Yasuhiro Matsumoto <[email protected]>
Date:   Sun Feb 15 14:48:54 2026 +0000

    patch 9.2.0002: str2specialbuf() can be improved
    
    Problem:  str2specialbuf() can be improved
    Solution: Optimize str2specialbuf function in message.c
              (Yasuhiro Matsumoto)
    
    closes: #19415
    
    Signed-off-by: Yasuhiro Matsumoto <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/message.c b/src/message.c
index e2058f8d4..192442ab4 100644
--- a/src/message.c
+++ b/src/message.c
@@ -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;
     }
 }
 
diff --git a/src/version.c b/src/version.c
index 8dd6db06c..0b6275096 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2,
 /**/
     1,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vrdbP-00Daip-J1%40256bit.org.

Raspunde prin e-mail lui