summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/chatutils.cpp4
-rw-r--r--src/utils/chatutils_unittest.cc6
-rw-r--r--src/utils/copynpaste.cpp22
-rw-r--r--src/utils/cpu.cpp9
-rw-r--r--src/utils/env.cpp9
-rw-r--r--src/utils/files.cpp14
-rw-r--r--src/utils/files.h2
-rw-r--r--src/utils/fuzzer.cpp2
-rw-r--r--src/utils/gettext.h2
-rw-r--r--src/utils/gettexthelper.cpp7
-rw-r--r--src/utils/gettexthelper.h6
-rw-r--r--src/utils/mathutils.h2
-rw-r--r--src/utils/mkdir.cpp27
-rw-r--r--src/utils/paths.cpp35
-rw-r--r--src/utils/paths.h2
-rw-r--r--src/utils/perfomance.cpp2
-rw-r--r--src/utils/physfsrwops.cpp37
-rw-r--r--src/utils/physfsrwops.h6
-rw-r--r--src/utils/physfstools.cpp7
-rw-r--r--src/utils/process.cpp28
-rw-r--r--src/utils/sdlcheckutils.cpp12
-rw-r--r--src/utils/sdlhelper.cpp10
-rw-r--r--src/utils/sdlpixel.h16
-rw-r--r--src/utils/sdlsharedhelper.cpp5
-rw-r--r--src/utils/specialfolder.cpp2
-rw-r--r--src/utils/specialfolder.h2
-rw-r--r--src/utils/stringutils.cpp9
-rw-r--r--src/utils/stringutils.h6
-rw-r--r--src/utils/timer.cpp5
-rw-r--r--src/utils/translation/podict.cpp2
-rw-r--r--src/utils/translation/podict.h4
-rw-r--r--src/utils/translation/poparser_unittest.cc5
-rw-r--r--src/utils/translation/translationmanager.cpp2
-rw-r--r--src/utils/translation/translationmanager.h2
-rw-r--r--src/utils/xml/libxml.cpp9
-rw-r--r--src/utils/xml/pugixml.cpp3
-rw-r--r--src/utils/xml_unittest.cc5
37 files changed, 177 insertions, 151 deletions
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index eab50ee1c..323778372 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -36,7 +36,7 @@
#ifdef TMWA_SUPPORT
#include "net/tmwa/guildmanager.h"
-#endif
+#endif // TMWA_SUPPORT
#include "utils/stringutils.h"
@@ -78,7 +78,7 @@ void outStringNormal(ChatTab *const tab,
{
guildManager->chat(str);
}
-#endif
+#endif // TMWA_SUPPORT
}
break;
}
diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc
index d4da5e453..92698b88e 100644
--- a/src/utils/chatutils_unittest.cc
+++ b/src/utils/chatutils_unittest.cc
@@ -61,9 +61,11 @@ TEST_CASE("chatutils replaceVars")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
+
ActorSprite::load();
localPlayer = new LocalPlayer(static_cast<BeingId>(1),
BeingTypeId_zero);
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 464e7ee80..8eba45f30 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -28,10 +28,10 @@
*/
#ifdef _MSC_VER
-# include "msvc/config.h"
+#include "msvc/config.h"
#elif defined(HAVE_CONFIG_H)
-# include "config.h"
-#endif
+#include "config.h"
+#endif // _MSC_VER
#include "utils/copynpaste.h"
@@ -45,7 +45,7 @@
#if defined(__APPLE__)
#ifdef Status
#undef Status
-#endif
+#endif // Status
#include <Carbon/Carbon.h>
#elif defined USE_X11
#include "render/graphics.h"
@@ -58,7 +58,7 @@
#include "utils/naclmessages.h"
#elif defined WIN32
#include <SDL_syswm.h>
-#endif
+#endif // defined(__APPLE__)
#endif // USE_SDL2
@@ -81,7 +81,7 @@ bool sendBuffer(const std::string &restrict text)
return !SDL_SetClipboardText(text.c_str());
}
-#else
+#else // USE_SDL2
#ifdef WIN32
bool retrieveBuffer(std::string& text, size_t& pos)
@@ -450,9 +450,10 @@ static bool runxsel(const std::string &text, const char *p1, const char *p2)
const char *const xselPath =
#if defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
"/usr/local/bin/xsel";
-#else
+#else // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
"/usr/bin/xsel";
-#endif
+#endif // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
+
if (p2)
{
execl(xselPath, "xsel", p1, p2,
@@ -496,7 +497,8 @@ bool sendBuffer(const std::string &restrict text)
naclPostMessage("clipboard-copy", text);
return true;
}
-#else
+#else // WIN32
+
bool retrieveBuffer(std::string&, size_t&)
{
return false;
@@ -506,5 +508,5 @@ bool sendBuffer(const std::string &restrict text A_UNUSED)
{
return false;
}
-#endif
+#endif // WIN32
#endif // USE_SDL2
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
index 672cc115f..12cc8ceab 100644
--- a/src/utils/cpu.cpp
+++ b/src/utils/cpu.cpp
@@ -27,7 +27,8 @@
// nothing
#elif defined(__linux__) || defined(__linux)
#include "utils/stringutils.h"
-#endif
+#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
+ // && (GCC_VERSION >= 40800) && !defined(ANDROID)
#include "debug.h"
@@ -91,9 +92,11 @@ void Cpu::detect()
}
fclose(file);
logger->log("cpu features was not detected");
-#else
+#else // OTHER
+
logger->log("cpu features not supported");
-#endif
+#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
+ // && (GCC_VERSION >= 40800) && !defined(ANDROID)
}
void Cpu::printFlags()
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index ea53cb2ef..4085f8b50 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -35,7 +35,7 @@ void updateEnv()
setEnv("SDL_VIDEO_CENTERED", "1");
else
setEnv("SDL_VIDEO_CENTERED", "0");
-#endif
+#endif // defined(WIN32) || defined(__APPLE__)
if (config.getBoolValue("allowscreensaver"))
setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
@@ -60,7 +60,7 @@ void updateEnv()
default:
break;
}
-#endif
+#endif // WIN32
}
void setEnv(const char *const name, const char *const value)
@@ -70,9 +70,10 @@ void setEnv(const char *const name, const char *const value)
#ifdef WIN32
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
-#else
+#else // WIN32
+
if (setenv(name, value, 1))
-#endif
+#endif // WIN32
{
logger->log("setenv failed: %s=%s", name, value);
}
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index 6f7ae3147..1aa0e245c 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -26,7 +26,7 @@
#include "resources/resourcemanager/resourcemanager.h"
#include "utils/mkdir.h"
-#endif
+#endif // defined(ANDROID) || defined(__native_client__)
#include "utils/mkdir.h"
#include "utils/paths.h"
@@ -77,7 +77,8 @@ namespace
{
#ifdef ANDROID
int mFilesCount = 0;
-#endif
+#endif // ANDROID
+
Files::CopyFileCallbackPtr mCallbackPtr = nullptr;
} // namespace
@@ -101,7 +102,7 @@ void Files::copyPhysFsFile(const std::string &restrict inFile,
mCallbackPtr(mFilesCount);
mFilesCount ++;
}
-#endif
+#endif // ANDROID
}
void Files::copyPhysFsDir(const std::string &restrict inDir,
@@ -169,9 +170,10 @@ int Files::renameFile(const std::string &restrict srcName,
return 0;
return -1;
-#else
+#else // defined __native_client__
+
return ::rename(srcName.c_str(), dstName.c_str());
-#endif
+#endif // defined __native_client__
}
int Files::copyFile(const std::string &restrict srcName,
@@ -265,7 +267,7 @@ std::string Files::getPath(const std::string &file)
std::string dataZip = "/http/data.zip/";
if (path.substr(0, dataZip.length()) == dataZip)
path = path.replace(0, dataZip.length(), "/http/data/");
-#endif
+#endif // defined __native_client__
}
else
{
diff --git a/src/utils/files.h b/src/utils/files.h
index 8123a5949..b14030b9f 100644
--- a/src/utils/files.h
+++ b/src/utils/files.h
@@ -29,7 +29,7 @@ namespace Files
{
#ifdef ANDROID
void extractLocale();
-#endif
+#endif // ANDROID
#if defined(ANDROID) || defined(__native_client__)
typedef void (*CopyFileCallbackPtr) (int cnt);
diff --git a/src/utils/fuzzer.cpp b/src/utils/fuzzer.cpp
index c9dbad952..8efc88808 100644
--- a/src/utils/fuzzer.cpp
+++ b/src/utils/fuzzer.cpp
@@ -57,4 +57,4 @@ bool Fuzzer::conditionTerminate(const char *const name)
return false;
}
-#endif
+#endif // USE_FUZZER
diff --git a/src/utils/gettext.h b/src/utils/gettext.h
index d4b8938b5..5abdde531 100644
--- a/src/utils/gettext.h
+++ b/src/utils/gettext.h
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif // HAVE_CONFIG_H
#ifdef ENABLE_NLS
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
index 3ee1bb0b3..650258e42 100644
--- a/src/utils/gettexthelper.cpp
+++ b/src/utils/gettexthelper.cpp
@@ -22,7 +22,7 @@
#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#include "configuration.h"
-#endif
+#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#ifdef ENABLE_NLS
#include "client.h"
@@ -148,8 +148,9 @@ void GettextHelper::bindTextDomain(const char *const path)
else
logger->log("bindtextdomain failed");
}
-#else
+#else // ENABLE_NLS
+
void GettextHelper::bindTextDomain(const char *const path A_UNUSED)
{
}
-#endif
+#endif // ENABLE_NLS
diff --git a/src/utils/gettexthelper.h b/src/utils/gettexthelper.h
index 5480371ab..6f298b839 100644
--- a/src/utils/gettexthelper.h
+++ b/src/utils/gettexthelper.h
@@ -23,7 +23,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif // HAVE_CONFIG_H
#include "localconsts.h"
@@ -35,9 +35,9 @@ class GettextHelper final
private:
#ifdef ENABLE_NLS
static void bindTextDomain(const char *const path);
-#else
+#else // ENABLE_NLS
static void bindTextDomain(const char *const path A_UNUSED);
-#endif
+#endif // ENABLE_NLS
};
#endif // UTILS_GETTEXTHELPER_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index c2578e487..892d24d96 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -27,7 +27,7 @@
#ifndef USE_SDL2
#include <cmath>
-#endif
+#endif // USE_SDL2
#include "localconsts.h"
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 25a8ba521..000bfeed4 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -24,16 +24,10 @@
#if defined WIN32
#include <limits.h>
#include <windows.h>
-#endif
+#endif // defined WIN32
#include <sys/stat.h>
-#ifdef M_MKDIR_TEST_
-// compile with -D_MKDIR_TEST_ to get a standalone binary
-#include <cstdio>
-#include <cstdlib>
-#endif
-
#include "debug.h"
#if defined WIN32
@@ -101,15 +95,12 @@ int mkdir_r(const char *const pathname)
return -1;
}
-#ifdef M_MKDIR_TEST_
- printf("%s\n", tmp);
-#endif
*p = '/';
}
}
return 0;
}
-#else
+#else // WIN32
/// Create a directory, making leading components first if necessary
int mkdir_r(const char *const pathname)
@@ -164,22 +155,10 @@ int mkdir_r(const char *const pathname)
return -1;
}
-#ifdef M_MKDIR_TEST_
- printf("%s\n", tmp);
-#endif
*p = '/';
}
}
delete []tmp;
return 0;
}
-#endif
-
-#ifdef M_MKDIR_TEST_
-int main(int argc, char** argv)
-{
- if (argc < 2)
- exit(1);
- mkdir_r(argv[1]);
-}
-#endif
+#endif // WIN32
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index e5d098a42..44e132c05 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -19,10 +19,10 @@
*/
#ifdef _MSC_VER
-# include "msvc/config.h"
+#include "msvc/config.h"
#elif defined(HAVE_CONFIG_H)
-# include "config.h"
-#endif
+#include "config.h"
+#endif // _MSC_VER
#include "utils/paths.h"
@@ -33,12 +33,12 @@
#include "utils/files.h"
#include "resources/resourcemanager/resourcemanager.h"
-#endif
+#endif // USE_X11
#ifdef __native_client__
#include <limits.h>
#define realpath(N, R) strcpy(R, N)
-#endif
+#endif // __native_client__
#ifdef WIN32
#include "utils/specialfolder.h"
@@ -47,13 +47,13 @@
#include <limits>
#elif defined __native_client__
#include <limits.h>
-#endif
+#endif // WIN32
#ifdef ANDROID
#ifdef USE_SDL2
#include <SDL_system.h>
-#endif
-#endif
+#endif // USE_SDL2
+#endif // ANDROID
#include "debug.h"
@@ -69,9 +69,12 @@ std::string getRealPath(const std::string &str)
if (!realPath)
return "";
realpath(str.c_str(), realPath);
-#else
+#else // defined(__OpenBSD__) || defined(__ANDROID__) ||
+ // defined(__native_client__)
+
char *realPath = realpath(str.c_str(), nullptr);
-#endif
+#endif // defined(__OpenBSD__) || defined(__ANDROID__) ||
+ // defined(__native_client__)
if (!realPath)
return "";
@@ -148,13 +151,14 @@ std::string getSelfName()
}
}
-#else
+#else // WIN32
+
std::string getSelfName()
{
return "";
}
-#endif
+#endif // WIN32
std::string getPicturesDir()
{
@@ -195,9 +199,10 @@ std::string getPicturesDir()
}
return std::string(PhysFs::getUserDir()).append("Desktop");
-#else
+#else // WIN32
+
return std::string(PhysFs::getUserDir()).append("Desktop");
-#endif
+#endif // WIN32
}
#ifdef ANDROID
@@ -205,7 +210,7 @@ std::string getSdStoragePath()
{
return getenv("DATADIR2");
}
-#endif
+#endif // ANDROID
std::string getPackageDir()
{
diff --git a/src/utils/paths.h b/src/utils/paths.h
index 6d1cf150d..423cffffc 100644
--- a/src/utils/paths.h
+++ b/src/utils/paths.h
@@ -41,7 +41,7 @@ std::string getPicturesDir() A_WARN_UNUSED;
#ifdef ANDROID
std::string getSdStoragePath() A_WARN_UNUSED;
-#endif
+#endif // ANDROID
std::string getPackageDir() A_WARN_UNUSED;
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp
index 42ab6aaaf..df0258fee 100644
--- a/src/utils/perfomance.cpp
+++ b/src/utils/perfomance.cpp
@@ -97,4 +97,4 @@ namespace Perfomance
}
} // namespace Perfomance
-#endif
+#endif // USE_PROFILER
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index e5e7e8e98..f3ebb25b3 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -34,14 +34,14 @@
#ifdef USE_SDL2
#define PHYSFSINT int64_t
#define PHYSFSSIZE size_t
-#else
+#else // USE_SDL2
#define PHYSFSINT int32_t
#define PHYSFSSIZE int
-#endif
+#endif // USE_SDL2
#ifdef DUMP_LEAKED_RESOURCES
static int openedRWops = 0;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
static PHYSFSINT physfsrwops_seek(SDL_RWops *const rw, const PHYSFSINT offset,
const int whence)
@@ -172,10 +172,11 @@ static int physfsrwops_close(SDL_RWops *const rw)
if (openedRWops <= 0)
logger->log("closing already closed RWops");
openedRWops --;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
#ifdef DEBUG_PHYSFS
FakePhysFSClose(rw);
-#endif
+#endif // DEBUG_PHYSFS
+
return 0;
} /* physfsrwops_close */
@@ -186,7 +187,7 @@ static PHYSFSINT physfsrwops_size(SDL_RWops *const rw)
rw->hidden.unknown.data1);
return PHYSFS_fileLength(handle);
} /* physfsrwops_size */
-#endif
+#endif // USE_SDL2
static SDL_RWops *create_rwops(PHYSFS_file *const handle)
{
@@ -203,7 +204,8 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
{
#ifdef USE_SDL2
retval->size = &physfsrwops_size;
-#endif
+#endif // USE_SDL2
+
retval->seek = &physfsrwops_seek;
retval->read = &physfsrwops_read;
retval->write = &physfsrwops_write;
@@ -212,7 +214,7 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
} /* if */
#ifdef DUMP_LEAKED_RESOURCES
openedRWops ++;
-#endif
+#endif // DUMP_LEAKED_RESOURCES
} /* else */
return retval;
@@ -238,7 +240,7 @@ static bool checkFilePath(const char *const fname)
return false;
return true;
}
-#endif
+#endif // __APPLE__
SDL_RWops *PHYSFSRWOPS_openRead(const char *const fname)
{
@@ -246,18 +248,19 @@ SDL_RWops *PHYSFSRWOPS_openRead(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(fname))
return nullptr;
-#endif
+#endif // USE_FUZZER
#ifdef USE_PROFILER
SDL_RWops *const ret = create_rwops(PhysFs::openRead(fname));
BLOCK_END("PHYSFSRWOPS_openRead")
return ret;
-#else
+#else // USE_PROFILER
+
return create_rwops(PhysFs::openRead(fname));
-#endif
+#endif // USE_PROFILER
} /* PHYSFSRWOPS_openRead */
SDL_RWops *PHYSFSRWOPS_openWrite(const char *const fname)
@@ -265,7 +268,8 @@ SDL_RWops *PHYSFSRWOPS_openWrite(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
+
return create_rwops(PhysFs::openWrite(fname));
} /* PHYSFSRWOPS_openWrite */
@@ -274,7 +278,8 @@ SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname)
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
-#endif
+#endif // __APPLE__
+
return create_rwops(PhysFs::openAppend(fname));
} /* PHYSFSRWOPS_openAppend */
@@ -284,6 +289,6 @@ void reportRWops()
if (openedRWops)
logger->log("leaking RWops: %d", openedRWops);
}
-#endif
+#endif // DUMP_LEAKED_RESOURCES
/* end of physfsrwops.c ... */
diff --git a/src/utils/physfsrwops.h b/src/utils/physfsrwops.h
index 1a03b7a2f..f69a05da8 100644
--- a/src/utils/physfsrwops.h
+++ b/src/utils/physfsrwops.h
@@ -28,12 +28,12 @@
#ifdef USE_SDL2
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
-#endif
+#endif // USE_SDL2
#include <SDL_stdinc.h>
_SDL_stdinc_h
#ifdef USE_SDL2
#pragma GCC diagnostic pop
-#endif
+#endif // USE_SDL2
#include <SDL_rwops.h>
#include "utils/physfstools.h"
@@ -90,6 +90,6 @@ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *const handle) A_WARN_UNUSED;
#ifdef DUMP_LEAKED_RESOURCES
void reportRWops();
-#endif
+#endif // DUMP_LEAKED_RESOURCES
#endif // UTILS_PHYSFSRWOPS_H
diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp
index 1e2ef1e2e..78fc227eb 100644
--- a/src/utils/physfstools.cpp
+++ b/src/utils/physfstools.cpp
@@ -27,7 +27,7 @@
#ifdef ANDROID
#include "utils/paths.h"
-#endif
+#endif // ANDROID
#include "debug.h"
@@ -43,11 +43,12 @@ namespace PhysFs
void init(const char *const name A_UNUSED)
{
if (!PHYSFS_init((getRealPath(".").append("/fakebinary")).c_str()))
-#else
+#else // defined(__native_client__)
+
void init(const char *const name)
{
if (!PHYSFS_init(name))
-#endif
+#endif // defined(__native_client__)
{
std::cout << "Error while initializing PhysFS: "
<< PHYSFS_getLastError() << std::endl;
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 72deaad5b..cd3d8558c 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -27,14 +27,14 @@
#ifdef USE_SDL2
#ifdef ANDROID
#include <SDL_system.h>
-#endif
-#endif
+#endif // ANDROID
+#endif // USE_SDL2
#include "debug.h"
#ifndef __native_client__
const int timeOut = 10;
-#endif
+#endif // __native_client__
#ifdef WIN32
@@ -220,7 +220,7 @@ bool execFile(const std::string &pathName, const std::string &name,
return true;
}
-#else
+#else // OTHER
int execFileWait(const std::string &pathName A_UNUSED,
const std::string &name A_UNUSED,
@@ -239,7 +239,7 @@ bool execFile(const std::string &pathName A_UNUSED,
return false;
}
-#endif
+#endif // WIN32
#ifdef WIN32
bool openBrowser(std::string url)
@@ -252,14 +252,17 @@ bool openBrowser(std::string url)
#include "utils/stringutils.h"
#ifndef USE_SDL2
#include <SDL_screenkeyboard.h>
-#endif
+#endif // USE_SDL2
+
bool openBrowser(std::string url)
{
#ifdef USE_SDL2
SDL_OpenBrowser(replaceAll(url, " ", "").c_str());
-#else
+#else // USE_SDL2
+
SDL_ANDROID_OpenBrowser(replaceAll(url, " ", "").c_str());
-#endif
+#endif // USE_SDL2
+
return true;
}
#elif defined __APPLE__
@@ -287,13 +290,13 @@ bool openBrowser(std::string url)
naclPostMessage("open-browser", url);
return true;
}
-#else
+#else // OTHER
bool openBrowser(std::string url)
{
return false;
}
-#endif
+#endif // WIN32
#ifdef WIN32
void setPriority(const bool big)
@@ -304,8 +307,9 @@ void setPriority(const bool big)
else
SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
}
-#else
+#else // WIN32
+
void setPriority(const bool big A_UNUSED)
{
}
-#endif
+#endif // WIN32
diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp
index 8c2f77dbd..b35d151fd 100644
--- a/src/utils/sdlcheckutils.cpp
+++ b/src/utils/sdlcheckutils.cpp
@@ -46,7 +46,8 @@ static SDL_Surface *addSurface(const char *restrict const name,
#ifdef DEBUG_SURFACE_ALLOCATION
logger->log("add surface: %s %s:%u %p", name,
file, line, static_cast<void*>(surface));
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
std::map<void*, SDLMemoryObject*>::iterator
it = mSurfaces.find(surface);
if (it != mSurfaces.end())
@@ -58,7 +59,8 @@ static SDL_Surface *addSurface(const char *restrict const name,
logger->log("adding existing surface: %p, count:%d\n"
"was add %s\nwas deleted %s", surface, obj->mCnt,
obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
obj->mCnt ++;
}
}
@@ -76,7 +78,8 @@ static void deleteSurface(const char *restrict const name A_UNUSED,
{
#ifdef DEBUG_SURFACE_ALLOCATION
logger->log("delete surface: %s %s:%u %p", name, file, line, surface);
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
std::map<void*, SDLMemoryObject*>::iterator
it = mSurfaces.find(surface);
if (it == mSurfaces.end())
@@ -94,7 +97,8 @@ static void deleteSurface(const char *restrict const name A_UNUSED,
logger->log("debug deleting surface: %p, count:%d\n"
"was add %s\nwas deleted %s", surface, cnt,
obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif
+#endif // DEBUG_SURFACE_ALLOCATION
+
if (cnt < 1)
{ // surface was here but was deleted
logger->log("deleting already deleted surface: %p at %s:%d\n"
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index 2e0b51e54..501f27034 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -48,7 +48,8 @@ bool SDL::getAllVideoModes(StringVect &modeList)
logger->log("support mode: " + modeString);
modeList.push_back(modeString);
return true;
-#else
+#else // ANDROID
+
/* Check which modes are available */
if (modes == static_cast<SDL_Rect **>(nullptr))
{
@@ -72,7 +73,7 @@ bool SDL::getAllVideoModes(StringVect &modeList)
}
return true;
}
-#endif
+#endif // ANDROID
}
void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED,
@@ -162,7 +163,8 @@ void SDL::makeCurrentContext(void *const context)
info.info.x11.display,
context);
}
-#else
+#else // defined(USE_X11) && defined(USE_OPENGL)
+
void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
const int major A_UNUSED,
const int minor A_UNUSED,
@@ -174,6 +176,6 @@ void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
void SDL::makeCurrentContext(void *const context A_UNUSED)
{
}
-#endif
+#endif // defined(USE_X11) && defined(USE_OPENGL)
#endif // USE_SDL2
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 66f4c2862..231959c80 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -68,6 +68,10 @@
#include <SDL.h>
+#ifndef SDL_BYTEORDER
+#error missing SDL_endian.h
+#endif // SDL_BYTEORDER
+
/**
* Puts a pixel on an SDL_Surface.
*
@@ -107,11 +111,13 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y,
p[0] = CAST_U8((pixel >> 16) & 0xff);
p[1] = CAST_U8((pixel >> 8) & 0xff);
p[2] = CAST_U8((pixel) & 0xff);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
p[0] = CAST_U8((pixel) & 0xff);
p[1] = CAST_U8((pixel >> 8) & 0xff);
p[2] = CAST_U8((pixel >> 16) & 0xff);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
case 4:
@@ -218,14 +224,16 @@ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
+ color.g * color.a) >> 8);
p[0] = CAST_U8((p[0] * (255 - color.a)
+ color.r * color.a) >> 8);
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
p[0] = CAST_U8((p[0] * (255 - color.a)
+ color.b * color.a) >> 8);
p[1] = CAST_U8((p[1] * (255 - color.a)
+ color.g * color.a) >> 8);
p[2] = CAST_U8((p[2] * (255 - color.a)
+ color.r * color.a) >> 8);
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
break;
case 4:
diff --git a/src/utils/sdlsharedhelper.cpp b/src/utils/sdlsharedhelper.cpp
index 0f8e0a0d9..33f88dad8 100644
--- a/src/utils/sdlsharedhelper.cpp
+++ b/src/utils/sdlsharedhelper.cpp
@@ -25,7 +25,7 @@
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/mouse_cursor.h>
#include <ppapi_simple/ps.h>
-#endif
+#endif // __native_client__
#include <SDL_events.h>
@@ -43,7 +43,8 @@ void SDL::showCursor(const bool show)
pp::MouseCursor::SetCursor(
pp::InstanceHandle(PSGetInstanceId()),
cursor);
-#endif
+#endif // __native_client__
+
if (show)
SDL_ShowCursor(SDL_ENABLE);
else
diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp
index 99df90645..62695477b 100644
--- a/src/utils/specialfolder.cpp
+++ b/src/utils/specialfolder.cpp
@@ -56,4 +56,4 @@ std::string getSpecialFolderLocation(const int folderId)
return ret;
}
-#endif
+#endif // WIN32
diff --git a/src/utils/specialfolder.h b/src/utils/specialfolder.h
index 6b8f1bd43..31c69124b 100644
--- a/src/utils/specialfolder.h
+++ b/src/utils/specialfolder.h
@@ -28,6 +28,6 @@
#include "localconsts.h"
std::string getSpecialFolderLocation(const int folderId) A_WARN_UNUSED;
-#endif
+#endif // WIN32
#endif // UTILS_SPECIALFOLDER_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 3cde2f208..d1d9b7200 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -26,14 +26,14 @@
#include "resources/iteminfo.h"
#include "resources/db/itemdb.h"
-#endif
+#endif // DYECMD
#include <algorithm>
#include <sstream>
#ifdef WIN32
#include <sys/time.h>
-#endif
+#endif // WIN32
#include "utils/gettext.h"
@@ -1066,8 +1066,9 @@ void replaceItemLinks(std::string &msg)
start2 = msg.find('[', start2 + 1);
}
}
-#else
+#else // DYECMD
+
void replaceItemLinks(std::string &msg A_UNUSED)
{
}
-#endif
+#endif // DYECMD
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 5b0249cc1..1a4f6261c 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -103,10 +103,10 @@ std::string strprintf(const char *const format, ...) A_NONNULL(1) A_WARN_UNUSED
#ifdef __GNUC__
#ifdef __OpenBSD__
__attribute__((__format__(printf, 1, 2)))
-#else
+#else // __OpenBSD__
__attribute__((__format__(gnu_printf, 1, 2)))
-#endif
-#endif
+#endif // __OpenBSD__
+#endif // __GNUC__
;
/**
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
index dff2816a8..7100096c8 100644
--- a/src/utils/timer.cpp
+++ b/src/utils/timer.cpp
@@ -33,10 +33,11 @@ namespace
#ifdef USE_SDL2
SDL_TimerID mLogicCounterId(0);
SDL_TimerID mSecondsCounterId(0);
-#else
+#else // USE_SDL2
+
SDL_TimerID mLogicCounterId(nullptr);
SDL_TimerID mSecondsCounterId(nullptr);
-#endif
+#endif // USE_SDL2
} // namespace
/**
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
index ba199a6d6..400583e80 100644
--- a/src/utils/translation/podict.cpp
+++ b/src/utils/translation/podict.cpp
@@ -27,7 +27,7 @@ std::string empty;
PoDict *translator = nullptr;
#ifdef ENABLE_CUSTOMNLS
PoDict *mainTranslator = nullptr;
-#endif
+#endif // ENABLE_CUSTOMNLS
PoDict::PoDict(std::string lang) :
mPoLines(),
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
index 73948aeb4..b9a63258e 100644
--- a/src/utils/translation/podict.h
+++ b/src/utils/translation/podict.h
@@ -43,7 +43,7 @@ class PoDict final
#ifndef UNITTESTS
protected:
-#endif
+#endif // UNITTESTS
friend class PoParser;
PoMap *getMap()
@@ -63,6 +63,6 @@ class PoDict final
extern PoDict *translator;
#ifdef ENABLE_CUSTOMNLS
extern PoDict *mainTranslator;
-#endif
+#endif // ENABLE_CUSTOMNLS
#endif // UTILS_TRANSLATION_PODICT_H
diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc
index d75088ee2..a016c7a86 100644
--- a/src/utils/translation/poparser_unittest.cc
+++ b/src/utils/translation/poparser_unittest.cc
@@ -55,9 +55,10 @@ TEST_CASE("PoParser tests", "PoParser")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
ActorSprite::load();
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 4fa233990..022397401 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -50,7 +50,7 @@ void TranslationManager::loadGettextLang()
delete mainTranslator;
mainTranslator = loadLang(getLang(), "manaplus/");
}
-#endif
+#endif // ENABLE_CUSTOMNLS
void TranslationManager::close()
{
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
index e228b1e75..29cb5d2d7 100644
--- a/src/utils/translation/translationmanager.h
+++ b/src/utils/translation/translationmanager.h
@@ -43,7 +43,7 @@ class TranslationManager final
#ifdef ENABLE_CUSTOMNLS
static void loadGettextLang();
-#endif
+#endif // ENABLE_CUSTOMNLS
static bool translateFile(const std::string &fileName,
PoDict *const dict,
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 21a24fc67..1e60ab4dc 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -42,10 +42,10 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
#ifdef __GNUC__
#ifdef __OpenBSD__
__attribute__((__format__(printf, 2, 3)))
-#else
+#else // __OpenBSD__
__attribute__((__format__(gnu_printf, 2, 3)))
-#endif
-#endif
+#endif // __OpenBSD__
+#endif // __GNUC__
;
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
@@ -89,7 +89,8 @@ namespace XML
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(filename.c_str()))
return;
-#endif
+#endif // USE_FUZZER
+
BLOCK_START("XML::Document::Document")
int size = 0;
char *data = nullptr;
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
index e60012a9e..4a0c072af 100644
--- a/src/utils/xml/pugixml.cpp
+++ b/src/utils/xml/pugixml.cpp
@@ -67,7 +67,8 @@ namespace XML
#ifdef USE_FUZZER
if (Fuzzer::conditionTerminate(filename.c_str()))
return;
-#endif
+#endif // USE_FUZZER
+
BLOCK_START("XML::Document::Document")
int size = 0;
char *data = nullptr;
diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc
index 3746736ca..cd8a55de9 100644
--- a/src/utils/xml_unittest.cc
+++ b/src/utils/xml_unittest.cc
@@ -53,9 +53,10 @@ TEST_CASE("xml doc")
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
graphicsManager.createWindow(640, 480, 0,
SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else
+#else // USE_SDL2
+
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif
+#endif // USE_SDL2
theme = new Theme;
Theme::selectSkin();