Skip to content

Commit 42a0a4d

Browse files
committed
Addressing more review comments
1 parent e8f6976 commit 42a0a4d

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

Core/Libraries/Source/WWVegas/WWLib/WWCommon.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626

2727
// This macro serves as a general way to determine the number of elements within an array.
2828
#ifndef ARRAY_SIZE
29-
#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0]))
29+
#if defined(_MSC_VER) && _MSC_VER < 1300
30+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
31+
#else
32+
template <typename Type, size_t Size> char (*ArraySizeHelper(Type(&)[Size]))[Size];
33+
#define ARRAY_SIZE(arr) sizeof(*ArraySizeHelper(arr))
3034
#endif
35+
#endif // ARRAY_SIZE
3136

3237
enum
3338
{

Core/Libraries/Source/debug/debug_io_flat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void DebugIOFlat::ExpandMagic(const char *src, const char *splitName, char *buf)
275275
unsigned len=strlen(help);
276276
if (dst-buf+len>250)
277277
break;
278-
strlcpy(dst, help, ARRAY_SIZE(dst));
278+
strcpy(dst, help);
279279
dst+=len;
280280
}
281281
strcpy(dst,".log");

Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,16 +2098,13 @@ void CWorldBuilderDoc::OnDumpDocToText(void)
20982098
static FILE *theLogFile = NULL;
20992099
Bool open = false;
21002100
try {
2101-
char dirbuf[ _MAX_PATH ];
2102-
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
2103-
if (char *pEnd = strrchr(dirbuf, '\\'))
2101+
char curbuf[_MAX_PATH];
2102+
GetModuleFileName(NULL, curbuf, sizeof(curbuf));
2103+
if (char *pEnd = strrchr(curbuf, '\\'))
21042104
{
21052105
*(pEnd + 1) = 0;
21062106
}
21072107

2108-
char curbuf[ _MAX_PATH ];
2109-
2110-
strlcpy(curbuf, dirbuf, ARRAY_SIZE(curbuf));
21112108
strlcat(curbuf, m_strTitle, ARRAY_SIZE(curbuf));
21122109
strlcat(curbuf, ".txt", ARRAY_SIZE(curbuf));
21132110

GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,16 +2155,13 @@ void CWorldBuilderDoc::OnDumpDocToText(void)
21552155
static FILE *theLogFile = NULL;
21562156
Bool open = false;
21572157
try {
2158-
char dirbuf[ _MAX_PATH ];
2159-
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
2160-
if (char *pEnd = strrchr(dirbuf, '\\'))
2158+
char curbuf[_MAX_PATH];
2159+
GetModuleFileName(NULL, curbuf, sizeof(curbuf));
2160+
if (char *pEnd = strrchr(curbuf, '\\'))
21612161
{
21622162
*(pEnd + 1) = 0;
21632163
}
21642164

2165-
char curbuf[ _MAX_PATH ];
2166-
2167-
strlcpy(curbuf, dirbuf, ARRAY_SIZE(curbuf));
21682165
strlcat(curbuf, m_strTitle, ARRAY_SIZE(curbuf));
21692166
strlcat(curbuf, ".txt", ARRAY_SIZE(curbuf));
21702167

0 commit comments

Comments
 (0)