Commit e197332f authored by Alexandre Julliard's avatar Alexandre Julliard

Removed a few more strncpy calls.

parent d70a253f
...@@ -153,14 +153,14 @@ void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDec ...@@ -153,14 +153,14 @@ void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDec
#if 0 #if 0
void TGraphCtrl::SetXUnits(const char* string) void TGraphCtrl::SetXUnits(const char* string)
{ {
strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1); lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
/* clear out the existing garbage, re-start with a clean plot */ /* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl(); InvalidateCtrl();
} }
void TGraphCtrl::SetYUnits(const char* string) void TGraphCtrl::SetYUnits(const char* string)
{ {
strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1); lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
/* clear out the existing garbage, re-start with a clean plot */ /* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl(); InvalidateCtrl();
} }
......
...@@ -336,7 +336,7 @@ void LoadBoard( BOARD *p_board ) ...@@ -336,7 +336,7 @@ void LoadBoard( BOARD *p_board )
if( RegQueryValueEx( hkey, key_name, NULL, (LPDWORD) &type, if( RegQueryValueEx( hkey, key_name, NULL, (LPDWORD) &type,
(LPBYTE) data, (LPBYTE) data,
(LPDWORD) &size ) == ERROR_SUCCESS ) (LPDWORD) &size ) == ERROR_SUCCESS )
strncpy( p_board->best_name[i], data, sizeof( data ) ); lstrcpynA( p_board->best_name[i], data, sizeof(p_board->best_name[i]) );
else else
LoadString( p_board->hInst, IDS_NOBODY, p_board->best_name[i], 16 ); LoadString( p_board->hInst, IDS_NOBODY, p_board->best_name[i], 16 );
} }
......
...@@ -392,3 +392,18 @@ LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src ) ...@@ -392,3 +392,18 @@ LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
strcpy( dst, src ); strcpy( dst, src );
return dst; return dst;
} }
LPSTR WINAPI lstrcpynA( LPSTR dst, LPCSTR src, INT n )
{
LPSTR d = dst;
LPCSTR s = src;
UINT count = n;
while ((count > 1) && *s)
{
count--;
*d++ = *s++;
}
if (count) *d = 0;
return dst;
}
...@@ -1207,8 +1207,8 @@ static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile) ...@@ -1207,8 +1207,8 @@ static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile)
if (idx < face_num) if (idx < face_num)
{ {
strncpy(hlpfile->fonts[i].LogFont.lfFaceName, ref + face_offset + idx * len, min(len, LF_FACESIZE - 1)); memcpy(hlpfile->fonts[i].LogFont.lfFaceName, ref + face_offset + idx * len, min(len, LF_FACESIZE - 1));
hlpfile->fonts[i].LogFont.lfFaceName[min(len, LF_FACESIZE - 1) + 1] = '\0'; hlpfile->fonts[i].LogFont.lfFaceName[min(len, LF_FACESIZE - 1)] = '\0';
} }
else else
{ {
...@@ -1415,9 +1415,12 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) ...@@ -1415,9 +1415,12 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile)
unsigned flags = GET_USHORT(ptr, 4); unsigned flags = GET_USHORT(ptr, 4);
HLPFILE_WINDOWINFO* wi = &hlpfile->windows[hlpfile->numWindows - 1]; HLPFILE_WINDOWINFO* wi = &hlpfile->windows[hlpfile->numWindows - 1];
if (flags & 0x0001) strcpy(wi->type, ptr + 6); else wi->type[0] = '\0'; if (flags & 0x0001) strcpy(wi->type, ptr + 6);
if (flags & 0x0002) strcpy(wi->name, ptr + 16); else wi->name[0] = '\0'; else wi->type[0] = '\0';
if (flags & 0x0004) strcpy(wi->caption, ptr + 25); else strncpy(wi->caption, hlpfile->lpszTitle, sizeof(wi->caption)); if (flags & 0x0002) strcpy(wi->name, ptr + 16);
else wi->name[0] = '\0';
if (flags & 0x0004) strcpy(wi->caption, ptr + 25);
else lstrcpynA(wi->caption, hlpfile->lpszTitle, sizeof(wi->caption));
wi->origin.x = (flags & 0x0008) ? GET_USHORT(ptr, 76) : CW_USEDEFAULT; wi->origin.x = (flags & 0x0008) ? GET_USHORT(ptr, 76) : CW_USEDEFAULT;
wi->origin.y = (flags & 0x0010) ? GET_USHORT(ptr, 78) : CW_USEDEFAULT; wi->origin.y = (flags & 0x0010) ? GET_USHORT(ptr, 78) : CW_USEDEFAULT;
wi->size.cx = (flags & 0x0020) ? GET_USHORT(ptr, 80) : CW_USEDEFAULT; wi->size.cx = (flags & 0x0020) ? GET_USHORT(ptr, 80) : CW_USEDEFAULT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment