summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/copynpaste.cpp8
-rw-r--r--src/utils/dumplibs.cpp8
-rw-r--r--src/utils/env.cpp14
-rw-r--r--src/utils/gettexthelper.cpp32
-rw-r--r--src/utils/performance.cpp (renamed from src/utils/perfomance.cpp)25
-rw-r--r--src/utils/performance.h (renamed from src/utils/perfomance.h)24
-rw-r--r--src/utils/process.cpp20
-rw-r--r--src/utils/stringutils.cpp10
-rw-r--r--src/utils/xml/libxml.cpp2
-rw-r--r--src/utils/xml/pugixml.cpp2
-rw-r--r--src/utils/xml/tinyxml2.cpp2
11 files changed, 73 insertions, 74 deletions
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 73e857da2..7bbc5176c 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -63,7 +63,7 @@ PRAGMA48(GCC diagnostic pop)
#include <unistd.h>
#elif defined __native_client__
#include "utils/naclmessages.h"
-#elif defined WIN32
+#elif defined _WIN32
#include "utils/cast.h"
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
@@ -94,7 +94,7 @@ bool sendBuffer(const std::string &restrict text)
#else // USE_SDL2
-#ifdef WIN32
+#ifdef _WIN32
bool retrieveBuffer(std::string& text, size_t& pos)
{
bool ret = false;
@@ -508,7 +508,7 @@ bool sendBuffer(const std::string &restrict text)
naclPostMessage("clipboard-copy", text);
return true;
}
-#else // WIN32
+#else // _WIN32
bool retrieveBuffer(std::string &text A_UNUSED, size_t &pos A_UNUSED)
{
@@ -519,5 +519,5 @@ bool sendBuffer(const std::string &restrict text A_UNUSED)
{
return false;
}
-#endif // WIN32
+#endif // _WIN32
#endif // USE_SDL2
diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp
index 66fe62798..7efa3704a 100644
--- a/src/utils/dumplibs.cpp
+++ b/src/utils/dumplibs.cpp
@@ -140,7 +140,13 @@ void dumpLibs()
LIBXML_TEST_VERSION
#endif // LIBXML_TEST_VERSION
#ifdef ENABLE_LIBXML
- const char *const *xmlVersion = __xmlParserVersion();
+ const char *const *xmlVersion
+#if LIBXML_VERSION > 21200
+ = &xmlParserVersion;
+#else
+ = __xmlParserVersion();
+#endif
+
if (xmlVersion != nullptr)
logger->log(" libxml2: %s", *xmlVersion);
#endif // ENABLE_LIBXML
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index 10feebca7..5ecbda7b9 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -29,14 +29,14 @@
void updateEnv()
{
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || defined(__APPLE__)
if (config.getBoolValue("centerwindow"))
setEnv("SDL_VIDEO_CENTERED", "1");
else
setEnv("SDL_VIDEO_CENTERED", "0");
-#endif // defined(WIN32) || defined(__APPLE__)
+#endif // defined(_WIN32) || defined(__APPLE__)
-#ifndef WIN32
+#ifndef _WIN32
const int vsync = settings.options.test.empty()
? config.getIntValue("vsync") : 1;
// __GL_SYNC_TO_VBLANK is nvidia variable.
@@ -54,20 +54,20 @@ void updateEnv()
default:
break;
}
-#endif // WIN32
+#endif // _WIN32
}
void setEnv(const char *const name, const char *const value)
{
if ((name == nullptr) || (value == nullptr))
return;
-#ifdef WIN32
+#ifdef _WIN32
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
-#else // WIN32
+#else // _WIN32
if (setenv(name, value, 1) != 0)
-#endif // WIN32
+#endif // _WIN32
{
logger->log("setenv failed: %s=%s", name, value);
}
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
index 0069b0bfd..84a6e8602 100644
--- a/src/utils/gettexthelper.cpp
+++ b/src/utils/gettexthelper.cpp
@@ -34,10 +34,10 @@
#include <libintl.h>
#include <locale.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <string>
extern "C" char const *_nl_locale_name_default(void);
-#endif // WIN32
+#endif // _WIN32
#elif defined(ENABLE_CUSTOMNLS)
#include "utils/translation/podict.h"
#ifdef __native_client__
@@ -45,9 +45,9 @@ extern "C" char const *_nl_locale_name_default(void);
#endif // __native_client__
#endif // ENABLE_NLS
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
+#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#include "utils/env.h"
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
+#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
#include "debug.h"
@@ -55,7 +55,7 @@ extern "C" char const *_nl_locale_name_default(void);
static std::string setLangEnv()
{
std::string lang = config.getStringValue("lang");
-#if defined(ENABLE_NLS) && defined(WIN32)
+#if defined(ENABLE_NLS) && defined(_WIN32)
if (lang.empty())
lang = std::string(_nl_locale_name_default());
#elif defined(ENABLE_CUSTOMNLS) && defined(__native_client__)
@@ -66,18 +66,12 @@ static std::string setLangEnv()
naclPostMessage("get-uilanguage", "");
lang = naclWaitForMessage(handle);
}
-#endif // defined(ENABLE_NLS) && defined(WIN32)
+#endif // defined(ENABLE_NLS) && defined(_WIN32)
if (!lang.empty())
{
-#ifdef WIN32
- putenv(const_cast<char*>(("LANG=" + lang).c_str()));
- putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
-#else // WIN32
-
- setEnv("LANG", lang.c_str());
+ setEnv("LANG", lang.c_str());
setEnv("LANGUAGE", lang.c_str());
-#endif // WIN32
}
return lang;
@@ -88,11 +82,11 @@ void GettextHelper::initLang()
{
#ifdef ENABLE_NLS
const std::string lang = setLangEnv();
-#ifdef WIN32
+#ifdef _WIN32
// mingw doesn't like LOCALEDIR to be defined for some reason
if (lang != "C")
bindTextDomain("translations/");
-#else // WIN32
+#else // _WIN32
#ifdef ANDROID
#ifdef USE_SDL2
bindTextDomain((std::string(getenv("APPDIR")).append("/locale")).c_str());
@@ -115,7 +109,7 @@ void GettextHelper::initLang()
#endif // __APPLE__
#endif // ENABLE_PORTABLE
#endif // ANDROID
-#endif // WIN32
+#endif // _WIN32
char *locale = setlocale(LC_MESSAGES, lang.c_str());
if (locale)
@@ -130,8 +124,8 @@ void GettextHelper::initLang()
else
logger->log("locale empty");
}
- bind_textdomain_codeset("manaplus", "UTF-8");
- textdomain("manaplus");
+ bind_textdomain_codeset("manaverse", "UTF-8");
+ textdomain("manaverse");
#elif defined(ENABLE_CUSTOMNLS)
mainTranslator = new PoDict("en");
setLangEnv();
@@ -141,7 +135,7 @@ void GettextHelper::initLang()
#ifdef ENABLE_NLS
void GettextHelper::bindTextDomain(const char *const path)
{
- const char *const dir = bindtextdomain("manaplus", path);
+ const char *const dir = bindtextdomain("manaverse", path);
if (dir)
logger->log("bindtextdomain: %s", dir);
else
diff --git a/src/utils/perfomance.cpp b/src/utils/performance.cpp
index 3633041a3..e18e848e4 100644
--- a/src/utils/perfomance.cpp
+++ b/src/utils/performance.cpp
@@ -23,11 +23,12 @@
#ifdef USE_PROFILER
-#include "utils/perfomance.h"
+#include "utils/performance.h"
#include "configuration.h"
#include "game.h"
+#include "utils/cast.h"
#include "utils/timer.h"
#include <algorithm>
@@ -41,10 +42,10 @@
static const clockid_t clockType = CLOCK_MONOTONIC;
-#define timeData ((static_cast<long long int>(time.tv_sec) * 1000000000LL \
- + static_cast<long long int>(time.tv_nsec)) / 1)
+#define timeData \
+ (CAST_U64(time.tv_sec) * 1000000000LL + CAST_U64(time.tv_nsec))
-namespace Perfomance
+namespace Performance
{
std::ofstream file;
std::string temp;
@@ -69,24 +70,26 @@ namespace Perfomance
{
timespec time;
clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " __init__\n");
+ temp.append(toString(CAST_U64(timeData - startTime)))
+ .append(" __init__\n");
}
void blockStart(const std::string &name)
{
timespec time;
clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " start: ").append(name).append("\n");
+ temp.append(toString(CAST_U64(timeData - startTime)))
+ .append(" start: ")
+ .append(name).append("\n");
}
void blockEnd(const std::string &name)
{
timespec time;
clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " end: ").append(name).append("\n");
+ temp.append(toString(CAST_U64(timeData - startTime)))
+ .append(" end: ")
+ .append(name).append("\n");
}
void flush()
@@ -96,6 +99,6 @@ namespace Perfomance
temp.clear();
// file.flush();
}
-} // namespace Perfomance
+} // namespace Performance
#endif // USE_PROFILER
diff --git a/src/utils/perfomance.h b/src/utils/performance.h
index 5da4756ee..4c52b12fe 100644
--- a/src/utils/perfomance.h
+++ b/src/utils/performance.h
@@ -19,26 +19,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UTILS_PERFOMANCE_H
-#define UTILS_PERFOMANCE_H
+#ifndef UTILS_PERFORMANCE_H
+#define UTILS_PERFORMANCE_H
#ifdef USE_PROFILER
-#include "utils/vector.h"
#include <string>
-#include <sstream>
-#include <list>
-#include <set>
#include "localconsts.h"
-#define PROFILER_START() Perfomance::start();
-#define PROFILER_END() Perfomance::flush();
-#define BLOCK_START(name) Perfomance::blockStart(name);
-#define BLOCK_END(name) Perfomance::blockEnd(name);
-#define FUNC_BLOCK(name, id) Perfomance::Func PerfomanceFunc##id(name);
+#define PROFILER_START() Performance::start();
+#define PROFILER_END() Performance::flush();
+#define BLOCK_START(name) Performance::blockStart(name);
+#define BLOCK_END(name) Performance::blockEnd(name);
+#define FUNC_BLOCK(name, id) Performance::Func PerformanceFunc##id(name);
-namespace Perfomance
+namespace Performance
{
void start();
@@ -70,7 +66,7 @@ namespace Perfomance
std::string name;
};
-} // namespace Perfomance
+} // namespace Performance
#else // USE_PROFILER
@@ -81,4 +77,4 @@ namespace Perfomance
#define FUNC_BLOCK(name, id)
#endif // USE_PROFILER
-#endif // UTILS_PERFOMANCE_H
+#endif // UTILS_PERFORMANCE_H
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 11cdf1c53..10ee5581f 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -36,13 +36,13 @@ PRAGMA48(GCC diagnostic pop)
#include "debug.h"
-#if defined(WIN32) || defined(__linux__) || \
+#if defined(_WIN32) || defined(__linux__) || \
defined(__linux) || defined(__APPLE__)
const int timeOut = 10;
-#endif // defined(WIN32) || defined(__linux__) ||
+#endif // defined(_WIN32) || defined(__linux__) ||
// defined(__linux) || defined(__APPLE__)
-#ifdef WIN32
+#ifdef _WIN32
#include "utils/stringutils.h"
@@ -245,16 +245,16 @@ bool execFile(const std::string &pathName A_UNUSED,
return false;
}
-#endif // WIN32
+#endif // _WIN32
-#if defined WIN64
+#if defined _WIN64
bool openBrowser(std::string url)
{
return reinterpret_cast<int64_t>(ShellExecute(nullptr, "open",
replaceAll(url, " ", "").c_str(),
nullptr, nullptr, SW_SHOWNORMAL)) > 32;
}
-#elif defined WIN32
+#elif defined _WIN32
bool openBrowser(std::string url)
{
return reinterpret_cast<int32_t>(ShellExecute(nullptr, "open",
@@ -312,9 +312,9 @@ bool openBrowser(std::string url A_UNUSED)
return false;
}
-#endif // WIN32
+#endif // _WIN32
-#ifdef WIN32
+#ifdef _WIN32
void setPriority(const bool big)
{
HANDLE hCurrentProcess = GetCurrentProcess();
@@ -323,9 +323,9 @@ void setPriority(const bool big)
else
SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
}
-#else // WIN32
+#else // _WIN32
void setPriority(const bool big A_UNUSED)
{
}
-#endif // WIN32
+#endif // _WIN32
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index cc9e830b8..446d9d234 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -38,9 +38,9 @@
#include <algorithm>
#include <sstream>
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
-#endif // WIN32
+#endif // _WIN32
#include "debug.h"
@@ -1027,7 +1027,7 @@ std::string escapeString(std::string str)
void sanitizePath(std::string &path)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sepStr = '\\';
const std::string sep2Str = "\\\\";
const std::string sepWrongStr = "/";
@@ -1043,7 +1043,7 @@ void sanitizePath(std::string &path)
std::string pathJoin(std::string str1,
const std::string &str2)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sep = '\\';
std::string sepStr = "\\";
#else
@@ -1082,7 +1082,7 @@ std::string pathJoin(std::string str1,
const std::string &str2,
const std::string &str3)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sep = '\\';
std::string sepStr = "\\";
#else
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index bb414aa06..9bff3f877 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -30,8 +30,8 @@
#include "utils/cast.h"
#include "utils/checkutils.h"
#include "utils/fuzzer.h"
+#include "utils/performance.h"
#include "utils/stringutils.h"
-
#include "utils/translation/podict.h"
#include <fstream>
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
index c67f3c195..ebad1548a 100644
--- a/src/utils/xml/pugixml.cpp
+++ b/src/utils/xml/pugixml.cpp
@@ -31,8 +31,8 @@
#include "utils/checkutils.h"
#include "utils/delete2.h"
#include "utils/fuzzer.h"
+#include "utils/performance.h"
#include "utils/stringutils.h"
-
#include "utils/translation/podict.h"
#include <fstream>
diff --git a/src/utils/xml/tinyxml2.cpp b/src/utils/xml/tinyxml2.cpp
index 9f044e69b..6646f136c 100644
--- a/src/utils/xml/tinyxml2.cpp
+++ b/src/utils/xml/tinyxml2.cpp
@@ -30,8 +30,8 @@
#include "utils/cast.h"
#include "utils/checkutils.h"
#include "utils/fuzzer.h"
+#include "utils/performance.h"
#include "utils/stringutils.h"
-
#include "utils/translation/podict.h"
#include <fstream>