Skip to content

Commit ef4bc8f

Browse files
committed
sync with 3dstool
1 parent 30d3f6e commit ef4bc8f

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ if(WIN32)
6666
endif()
6767
if(UNIX OR MINGW)
6868
add_definitions(-D_FILE_OFFSET_BITS=64)
69-
if(NOT APPLE)
69+
if(APPLE)
70+
add_definitions(-Wno-shift-overflow)
71+
else()
7072
add_definitions(-Wno-multichar -Wno-unused-result)
7173
endif()
7274
set(CMAKE_INSTALL_RPATH .)

cmake/AutoFiles.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function(AUTO_FILES FOLDER FILTER PATTERN)
2626
string(REPLACE "./" "" AUTO_FILES_FILTER "${AUTO_FILES_FILTER}")
2727
string(REPLACE "/" "\\" AUTO_FILES_FILTER "${AUTO_FILES_FILTER}")
2828
string(REPLACE "..\\" "../" AUTO_FILES_FILTER "${AUTO_FILES_FILTER}")
29-
if("${AUTO_FILES_FILTER}" STREQUAL "../")
30-
set(AUTO_FILES_FILTER "..")
29+
if("${AUTO_FILES_FILTER}" MATCHES "(.+)/$")
30+
set(AUTO_FILES_FILTER "${CMAKE_MATCH_1}")
3131
endif()
3232
if("${AUTO_FILES_FILTER}" STREQUAL ".")
3333
source_group("${FILTER}" FILES ${AUTO_FILES_FOLDER_FILES})

src/utility.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,45 +95,45 @@ int main(int argc, char* argv[])
9595
const UString& UGetModuleFileName()
9696
{
9797
const u32 uMaxPath = 4096;
98-
static UString sFileName;
99-
if (!sFileName.empty())
98+
static UString c_sFileName;
99+
if (!c_sFileName.empty())
100100
{
101-
return sFileName;
101+
return c_sFileName;
102102
}
103-
sFileName.resize(uMaxPath, USTR('\0'));
103+
c_sFileName.resize(uMaxPath, USTR('\0'));
104104
u32 uSize = 0;
105105
#if SDW_PLATFORM == SDW_PLATFORM_WINDOWS
106-
uSize = GetModuleFileNameW(nullptr, &*sFileName.begin(), uMaxPath);
106+
uSize = GetModuleFileNameW(nullptr, &*c_sFileName.begin(), uMaxPath);
107107
#elif SDW_PLATFORM == SDW_PLATFORM_MACOS
108108
char szPath[uMaxPath] = {};
109109
u32 uPathSize = uMaxPath;
110110
if (_NSGetExecutablePath(szPath, &uPathSize) != 0)
111111
{
112-
sFileName.clear();
112+
c_sFileName.clear();
113113
printf("ERROR: _NSGetExecutablePath error\n\n");
114114
}
115-
else if (realpath(szPath, &*sFileName.begin()) == nullptr)
115+
else if (realpath(szPath, &*c_sFileName.begin()) == nullptr)
116116
{
117-
sFileName.clear();
117+
c_sFileName.clear();
118118
printf("ERROR: realpath error\n\n");
119119
}
120-
uSize = strlen(sFileName.c_str());
120+
uSize = strlen(c_sFileName.c_str());
121121
#elif SDW_PLATFORM == SDW_PLATFORM_LINUX || SDW_PLATFORM == SDW_PLATFORM_CYGWIN
122-
ssize_t nCount = readlink("/proc/self/exe", &*sFileName.begin(), uMaxPath);
122+
ssize_t nCount = readlink("/proc/self/exe", &*c_sFileName.begin(), uMaxPath);
123123
if (nCount == -1)
124124
{
125-
sFileName.clear();
125+
c_sFileName.clear();
126126
printf("ERROR: readlink /proc/self/exe error\n\n");
127127
}
128128
else
129129
{
130-
sFileName[nCount] = '\0';
130+
c_sFileName[nCount] = '\0';
131131
}
132-
uSize = strlen(sFileName.c_str());
132+
uSize = strlen(c_sFileName.c_str());
133133
#endif
134-
sFileName.erase(uSize);
135-
sFileName = Replace(sFileName, USTR('\\'), USTR('/'));
136-
return sFileName;
134+
c_sFileName.erase(uSize);
135+
c_sFileName = Replace(c_sFileName, USTR('\\'), USTR('/'));
136+
return c_sFileName;
137137
}
138138

139139
void SetLocale()

src/utility.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ typedef string UString;
155155

156156
#define SDW_BIT64(n) (UINT64_C(1) << (n))
157157

158-
#define SDW_CONVERT_ENDIAN32(n) (((n) >> 24 & 0xFF) | ((n) >> 8 & 0xFF00) | (((n) & 0xFF00) << 8) | (((n) & 0xFF) << 24))
158+
#define SDW_CONVERT_ENDIAN32(n) (((n) >> 24 & 0xFF) | ((n) >> 8 & 0xFF00) | ((n) << 8 & 0xFF0000) | ((n) << 24 & 0xFF000000))
159159

160160
#if SDW_PLATFORM == SDW_PLATFORM_WINDOWS
161161
#define Chsize _chsize_s
@@ -216,19 +216,19 @@ TDest TSToS(const TSrc& a_sString, const string& a_sSrcType, const string& a_sDe
216216
return sConverted;
217217
}
218218
size_t uStringLeft = a_sString.size() * sizeof(typename TSrc::value_type);
219-
static const n32 c_nBufferSize = 1024;
220-
static const n32 c_nConvertBufferSize = c_nBufferSize - 4;
219+
static const int c_nBufferSize = 1024;
220+
static const int c_nConvertBufferSize = c_nBufferSize - 4;
221221
char szBuffer[c_nBufferSize];
222222
typename TSrc::value_type* pString = const_cast<typename TSrc::value_type*>(a_sString.c_str());
223223
do
224224
{
225225
char* pBuffer = szBuffer;
226226
size_t uBufferLeft = c_nConvertBufferSize;
227-
n32 nError = iconv(cd, reinterpret_cast<char**>(&pString), &uStringLeft, &pBuffer, &uBufferLeft);
227+
int nError = static_cast<int>(iconv(cd, reinterpret_cast<char**>(&pString), &uStringLeft, &pBuffer, &uBufferLeft));
228228
#if SDW_PLATFORM == SDW_PLATFORM_MACOS
229-
if (nError >= 0 || (nError == static_cast<size_t>(-1) && errno == E2BIG))
229+
if (nError >= 0 || (nError == -1 && errno == E2BIG))
230230
#else
231-
if (nError == 0 || (nError == static_cast<size_t>(-1) && errno == E2BIG))
231+
if (nError == 0 || (nError == -1 && errno == E2BIG))
232232
#endif
233233
{
234234
*reinterpret_cast<typename TDest::value_type*>(szBuffer + c_nConvertBufferSize - uBufferLeft) = 0;

0 commit comments

Comments
 (0)