diff src/os_win32.c @ 19405:08f4dc2ba716 v8.2.0260

patch 8.2.0260: several lines of code are duplicated Commit: https://github.com/vim/vim/commit/f4140488c72cad4dbf5449dba099cfa7de7bbb22 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 15 23:06:45 2020 +0100 patch 8.2.0260: several lines of code are duplicated Problem: Several lines of code are duplicated. Solution: Move duplicated code to a function. (Yegappan Lakshmanan, closes #5330)
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Feb 2020 23:15:04 +0100
parents 7894f20668b1
children 5eb0ead1415f
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4173,7 +4173,6 @@ mch_system_piped(char *cmd, int options)
     int		ta_len = 0;		// valid bytes in ta_buf[]
 
     DWORD	i;
-    int		c;
     int		noread_cnt = 0;
     garray_T	ga;
     int		delay = 1;
@@ -4312,29 +4311,7 @@ mch_system_piped(char *cmd, int options)
 			}
 		    }
 
-		    // replace K_BS by <BS> and K_DEL by <DEL>
-		    for (i = ta_len; i < ta_len + len; ++i)
-		    {
-			if (ta_buf[i] == CSI && len - i > 2)
-			{
-			    c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);
-			    if (c == K_DEL || c == K_KDEL || c == K_BS)
-			    {
-				mch_memmove(ta_buf + i + 1, ta_buf + i + 3,
-					    (size_t)(len - i - 2));
-				if (c == K_DEL || c == K_KDEL)
-				    ta_buf[i] = DEL;
-				else
-				    ta_buf[i] = Ctrl_H;
-				len -= 2;
-			    }
-			}
-			else if (ta_buf[i] == '\r')
-			    ta_buf[i] = '\n';
-			if (has_mbyte)
-			    i += (*mb_ptr2len_len)(ta_buf + i,
-						    ta_len + len - i) - 1;
-		    }
+		    term_replace_bs_del_keycode(ta_buf, ta_len, len);
 
 		    /*
 		     * For pipes: echo the typed characters.  For a pty this