Fixed POSIX !searchparse bug (patch #251) and hopefully better compatibility with 2.46

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6485 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-05-19 19:23:06 +00:00
parent 881fa61896
commit 0bcb8f40ed
7 changed files with 31 additions and 49 deletions

View file

@ -67,21 +67,13 @@ double my_wtof(const wchar_t *str)
return atof(buf);
}
unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax)
size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax)
{
// Dest and Src must be valid, Dest is always \0 terminated.
// Returns number of TCHARs copied to Dest; min(strlen(Src),cchMax-1).
unsigned int cch = 0;
if (cchMax)
{
for(;--cchMax;)
{
TCHAR ch = Src[cch];
if (!ch) break;
Dest[cch++] = ch;
}
Dest[cch] = _T('\0');
}
// Returns number of TCHARs copied to Dest (not counting \0); min(strlen(Src),cchMax-1).
size_t cch = 0;
if (cchMax) for (TCHAR c; --cchMax;) if (!(c = Src[cch])) break; else Dest[cch++] = c;
Dest[cch] = _T('\0');
return cch;
}