updated for version 7.0109
diff --git a/src/gui_w48.c b/src/gui_w48.c
index 97a0ca0..9a0247f 100644
--- a/src/gui_w48.c
+++ b/src/gui_w48.c
@@ -2194,9 +2194,8 @@
s_findrep_struct.Flags |= FR_WHOLEWORD;
if (entry_text != NULL && *entry_text != NUL)
{
- STRNCPY(s_findrep_struct.lpstrFindWhat, entry_text,
- s_findrep_struct.wFindWhatLen);
- s_findrep_struct.lpstrFindWhat[s_findrep_struct.wFindWhatLen - 1] = NUL;
+ vim_strncpy(s_findrep_struct.lpstrFindWhat, entry_text,
+ s_findrep_struct.wFindWhatLen - 1);
s_findrep_struct.lpstrReplaceWith[0] = NUL;
}
vim_free(entry_text);
@@ -3102,10 +3101,7 @@
if (dflt == NULL)
fileBuf[0] = NUL;
else
- {
- STRNCPY(fileBuf, dflt, MAXPATHL - 1);
- fileBuf[MAXPATHL - 1] = NUL;
- }
+ vim_strncpy(fileBuf, dflt, MAXPATHL - 1);
/* Convert the filter to Windows format. */
filterp = convert_filter(filter);
diff --git a/src/os_mswin.c b/src/os_mswin.c
index b0c137f..6bffdb9 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -410,8 +410,7 @@
cname = ucs2_to_enc((short_u *)wbuf, NULL);
if (cname != NULL)
{
- STRNCPY(buf, cname, len);
- buf[len - 1] = NUL;
+ vim_strncpy(buf, cname, len - 1);
nResult = OK;
}
}
@@ -423,8 +422,8 @@
{
if (_fullpath(buf, fname, len - 1) == NULL)
{
- STRNCPY(buf, fname, len); /* failed, use relative path name */
- buf[len - 1] = NUL;
+ /* failed, use relative path name */
+ vim_strncpy(buf, fname, len - 1);
}
else
nResult = OK;
@@ -493,8 +492,7 @@
char buf[_MAX_PATH + 1];
char *p;
- STRNCPY(buf, name, _MAX_PATH);
- buf[_MAX_PATH] = NUL;
+ vim_strncpy(buf, name, _MAX_PATH);
p = buf + strlen(buf);
if (p > buf)
mb_ptr_back(buf, p);
@@ -1527,8 +1525,7 @@
if (lpszMem)
{
- STRNCPY(lpszMem, str, metadata.txtlen);
- lpszMem[metadata.txtlen] = NUL;
+ vim_strncpy(lpszMem, str, metadata.txtlen);
GlobalUnlock(hMem);
}
}
diff --git a/src/os_win32.c b/src/os_win32.c
index 6ad674e..c2d5ebb 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2356,7 +2356,7 @@
if (GetUserName(szUserName, &cch))
{
- STRNCPY(s, szUserName, len);
+ vim_strncpy(s, szUserName, len - 1);
return OK;
}
s[0] = NUL;
@@ -2375,10 +2375,7 @@
DWORD cch = len;
if (!GetComputerName(s, &cch))
- {
- STRNCPY(s, "PC (Win32 Vim)", len);
- s[len - 1] = NUL; /* make sure it's terminated */
- }
+ vim_strncpy(s, "PC (Win32 Vim)", len - 1);
}
@@ -2418,8 +2415,7 @@
if (p != NULL)
{
- STRNCPY(buf, p, len - 1);
- buf[len - 1] = NUL;
+ vim_strncpy(buf, p, len - 1);
vim_free(p);
return OK;
}
@@ -2591,7 +2587,7 @@
/*
* Loop over all extensions in $PATHEXT.
*/
- STRNCPY(buf, name, _MAX_PATH);
+ vim_strncpy(buf, name, _MAX_PATH - 1);
p = mch_getenv("PATHEXT");
if (p == NULL)
p = (char_u *)".com;.exe;.bat;.cmd";
@@ -4452,7 +4448,7 @@
char *pch;
WIN32_FIND_DATA d;
- STRNCPY(TempName, n, _MAX_PATH);
+ vim_strncpy(TempName, n, _MAX_PATH);
pch = TempName + STRLEN(TempName) - 1;
if (*pch != '\\' && *pch != '/')
*++pch = '\\';