summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-20 14:37:15 +0100
committerandrew <xdotftw@gmail.com>2014-02-20 14:37:15 +0100
commit83d3a2eedf88a3a180b9dfc4c706838d7f99382a (patch)
treed96970727615c681efe3bf76793015cead438394 /lib
parentcMapDecorator: Implemented random rotations (diff)
parentAPIDump: Fixed cBlockArea:GetRelBlockType() return types. (diff)
downloadcuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.gz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.bz2
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.lz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.xz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.zst
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.zip
Diffstat (limited to 'lib')
-rw-r--r--lib/inifile/iniFile.cpp38
-rw-r--r--lib/inifile/iniFile.h2
m---------lib/polarssl0
-rw-r--r--lib/polarssl.cmake5
-rw-r--r--lib/tolua++/CMakeLists.txt2
-rw-r--r--lib/zlib/CMakeLists.txt14
6 files changed, 53 insertions, 8 deletions
diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp
index afa1c110d..cf8b63987 100644
--- a/lib/inifile/iniFile.cpp
+++ b/lib/inifile/iniFile.cpp
@@ -83,6 +83,8 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect)
}
}
+ bool IsFirstLine = true;
+
while (getline(f, line))
{
// To be compatible with Win32, check for existence of '\r'.
@@ -90,6 +92,14 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect)
// Note that the '\r' will be written to INI files from
// Unix so that the created INI file can be read under Win32
// without change.
+
+ // Removes UTF-8 Byte Order Markers (BOM) if, present.
+ if (IsFirstLine)
+ {
+ RemoveBom(line);
+ IsFirstLine = false;
+ }
+
size_t lineLength = line.length();
if (lineLength == 0)
{
@@ -162,11 +172,12 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect)
{
return false;
}
-
+
if (IsFromExampleRedirect)
{
WriteFile(FILE_IO_PREFIX + a_FileName);
}
+
return true;
}
@@ -824,3 +835,28 @@ AString cIniFile::CheckCase(const AString & s) const
+
+void cIniFile::RemoveBom(AString & a_line) const
+{
+ // The BOM sequence for UTF-8 is 0xEF,0xBB,0xBF
+ static unsigned const char BOM[] = { 0xEF, 0xBB, 0xBF };
+
+ // The BOM sequence, if present, is always th e first three characters of the input.
+ const AString ref = a_line.substr(0, 3);
+
+ // If any of the first three chars do not match, return and do nothing.
+ for (int i = 0; i < 3; ++i)
+ {
+ if (static_cast<unsigned char>(ref[i]) != BOM[i])
+ {
+ return;
+ }
+ }
+
+ // First three characters match; erase them.
+ a_line.erase(0, 3);
+}
+
+
+
+
diff --git a/lib/inifile/iniFile.h b/lib/inifile/iniFile.h
index 40af618dc..0bf1d917e 100644
--- a/lib/inifile/iniFile.h
+++ b/lib/inifile/iniFile.h
@@ -51,6 +51,8 @@ private:
/// If the object is case-insensitive, returns s as lowercase; otherwise returns s as-is
AString CheckCase(const AString & s) const;
+ /// Removes the UTF-8 BOMs (Byte order makers), if present.
+ void RemoveBom(AString & a_line) const;
public:
enum errors
{
diff --git a/lib/polarssl b/lib/polarssl
-Subproject 2cb1a0c4009ecf368ecc74eb428394e10f9e6d0
+Subproject 2ceda579893ceb23c5eb0d56df47dc235644e0f
diff --git a/lib/polarssl.cmake b/lib/polarssl.cmake
new file mode 100644
index 000000000..d57cc9220
--- /dev/null
+++ b/lib/polarssl.cmake
@@ -0,0 +1,5 @@
+
+if(NOT TARGET polarssl)
+ message("including polarssl")
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl EXCLUDE_FROM_ALL )
+endif()
diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt
index 239232c38..5ec8ee822 100644
--- a/lib/tolua++/CMakeLists.txt
+++ b/lib/tolua++/CMakeLists.txt
@@ -19,7 +19,7 @@ add_library(tolualib ${LIB_SOURCE})
#m is the standard math librarys
if(UNIX)
-target_link_libraries(tolua m)
+target_link_libraries(tolua m ${DYNAMIC_LOADER})
endif()
target_link_libraries(tolua lua tolualib)
diff --git a/lib/zlib/CMakeLists.txt b/lib/zlib/CMakeLists.txt
index b1b74031d..6c52578ee 100644
--- a/lib/zlib/CMakeLists.txt
+++ b/lib/zlib/CMakeLists.txt
@@ -8,12 +8,14 @@ file(GLOB SOURCE
"*.c"
)
-add_library(zlib ${SOURCE})
+if(NOT TARGET zlib)
+ add_library(zlib ${SOURCE})
-if (MSVC)
- # Remove SCL warnings, we expect this library to have been tested safe
- SET_TARGET_PROPERTIES(
- zlib PROPERTIES COMPILE_FLAGS "-D_CRT_SECURE_NO_WARNINGS"
- )
+ if (MSVC)
+ # Remove SCL warnings, we expect this library to have been tested safe
+ SET_TARGET_PROPERTIES(
+ zlib PROPERTIES COMPILE_FLAGS "-D_CRT_SECURE_NO_WARNINGS"
+ )
+ endif()
endif()