From b0e28889d79df18161d5a6dd93ff0593f3d87ff1 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 24 Aug 2020 16:34:17 +0200 Subject: [PATCH 01/12] Update source code and compilation files in order to get them compiling under FreeBSD --- .../DocDocxConverter/StringTable.h | 4 ++-- ASCOfficeRtfFile/RtfFormatLib/source/Utils.h | 2 +- .../source/XlsFormat/Auxiliary/HelpFunc.cpp | 4 ++-- .../source/XlsFormat/Crypt/rtl/cipher.h | 2 +- .../source/XlsFormat/Crypt/rtl/digest.h | 2 +- .../Logic/Biff_structures/BitMarkedStructs.h | 2 +- Common/3dParty/boost/boost.pri | 10 +++++++-- Common/3dParty/icu/icu.pri | 13 ++++++++--- Common/3dParty/v8/v8.pri | 19 +++++++++++----- Common/DocxFormat/Source/Base/Types_32.h | 2 +- Common/DocxFormat/Source/DocxFormat/Docx.cpp | 2 +- .../DocxFormat/Source/XlsxFormat/Common.cpp | 5 +++++ Common/base.pri | 7 ++++++ DesktopEditor/agg-2.4/include/agg_math.h | 2 +- .../agg-2.4/include/agg_span_gradient.h | 2 +- DesktopEditor/common/Directory.cpp | 10 ++++----- DesktopEditor/common/File.cpp | 22 ++++++++++++++++++- DesktopEditor/common/Path.cpp | 6 ++--- DesktopEditor/common/Types.h | 2 +- DesktopEditor/cximage/CxImage/ximage.h | 2 +- DesktopEditor/cximage/CxImage/ximainfo.cpp | 2 +- DesktopEditor/cximage/CxImage/ximajas.h | 2 +- DesktopEditor/cximage/CxImage/ximajpg.cpp | 2 +- DesktopEditor/cximage/CxImage/ximajpg.h | 2 +- DesktopEditor/cximage/CxImage/ximapng.h | 2 +- DesktopEditor/cximage/CxImage/ximaraw.cpp | 2 +- DesktopEditor/cximage/raw/libdcr.h | 2 +- DesktopEditor/cximage/tiff/tif_config.h | 8 +++---- DesktopEditor/cximage/tiff/tiffconf.h | 2 +- DesktopEditor/cximage/tiff/tiffiop.h | 4 ++++ .../doctrenderer/app_builder/main.cpp | 2 +- DesktopEditor/doctrenderer/docbuilder_p.h | 6 ++--- DesktopEditor/fontengine/ApplicationFonts.cpp | 2 +- DesktopEditor/fontengine/MemoryStream.h | 2 +- .../fontengine/fontconverter/MemoryUtils.h | 2 +- DesktopEditor/graphics/Graphics.cpp | 6 ++--- .../JBig2/source/LeptonLib/readfile.cpp | 4 ++-- .../raster/Metafile/Wmf/WmfObjects.h | 2 +- DesktopEditor/xml/libxml2/trionan.c | 4 ++-- .../xmlsec/src/src/XmlCertificate.cpp | 2 +- HtmlFile/HtmlFile.cpp | 4 ++-- Makefile | 16 ++++++++++++++ .../src/zlib-1.2.11/contrib/minizip/miniunz.c | 2 +- .../src/zlib-1.2.11/contrib/minizip/minizip.c | 2 +- PdfWriter/Src/Types.h | 2 +- Test/Applications/StandardTester/main.cpp | 4 ++-- .../icubuilds-mac/icu/unicode/platform.h | 2 +- X2tConverter/src/ASCConverters.cpp | 4 ++-- .../batch_convert/x2t_test/mainwindow.cpp | 4 ++-- 49 files changed, 146 insertions(+), 74 deletions(-) diff --git a/ASCOfficeDocFile/DocDocxConverter/StringTable.h b/ASCOfficeDocFile/DocDocxConverter/StringTable.h index 9ee5fb69fea..a4e384f2d43 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StringTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/StringTable.h @@ -77,13 +77,13 @@ namespace DocFileFormat } StringTable( VirtualStreamReader *reader, int code_page_ ): - code_page(code_page_), fExtend(false), cbData(0), cbExtra(0), DataExtra(NULL) + code_page(code_page_), fExtend(false), cbData(0), cbExtra(0) { parse( reader, (unsigned int)reader->GetPosition(), 0, false ); } StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, int nWordVersion, bool bReadExta = false) : - code_page(1250), fExtend(false), cbData(0), cbExtra(0), DataExtra(NULL) + code_page(1250), fExtend(false), cbData(0), cbExtra(0) { if ( lcb > 0 ) { diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h b/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h index 57d7f88b0b3..f068940ec20 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h @@ -565,7 +565,7 @@ class RtfUtility sResult.erase(outsize_with_0 - 1); ansi = false; } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) std::string sCodepage = "CP" + std::to_string(nCodepage); iconv_t ic= iconv_open("WCHAR_T", sCodepage.c_str()); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/HelpFunc.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/HelpFunc.cpp index 900bbe775e4..6c6d1ddc178 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/HelpFunc.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/HelpFunc.cpp @@ -352,7 +352,7 @@ const std::wstring unescape_ST_Xstring(const std::wstring& wstr) while(true) { -#if defined(__linux__) || defined(_MAC) || defined(_IOS) +#if defined(__linux__) || defined(__FreeBSD__) || defined(_MAC) || defined(_IOS) const auto it_range = boost::make_iterator_range(x_pos_noncopied, wstr_end); x_pos_next = boost::algorithm::find_first(it_range, L"_x").begin(); #else @@ -469,7 +469,7 @@ std::wstring toStdWStringSystem(std::string ansi_string, const unsigned int code sResult.erase(outsize_with_0 - 1); ansi = false; } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) std::string sCodepage = "CP" + std::to_string(code_page); iconv_t ic= iconv_open("WCHAR_T", sCodepage.c_str()); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h b/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h index 61193823b35..62b81eececa 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/cipher.h @@ -33,7 +33,7 @@ #include -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #endif diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/digest.h b/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/digest.h index 66b2e31ee27..88c751310fd 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/digest.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Crypt/rtl/digest.h @@ -31,7 +31,7 @@ */ #pragma once -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #endif diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BitMarkedStructs.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BitMarkedStructs.h index a0d67957815..44a452b1d2f 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BitMarkedStructs.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/BitMarkedStructs.h @@ -31,7 +31,7 @@ */ #pragma once -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #endif diff --git a/Common/3dParty/boost/boost.pri b/Common/3dParty/boost/boost.pri index 5c0141ff596..0b18561ed1a 100644 --- a/Common/3dParty/boost/boost.pri +++ b/Common/3dParty/boost/boost.pri @@ -1,5 +1,11 @@ -INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include -CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib +!core_freebsd { + INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include + CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib +} +core_freebsd { + INCLUDEPATH += /usr/local/include + CORE_BOOST_LIBS = /usr/local/lib +} core_windows { core_win_64:BOOST_POSTFIX = -vc140-mt-x64-1_72 diff --git a/Common/3dParty/icu/icu.pri b/Common/3dParty/icu/icu.pri index 424edb38150..c632e4c5069 100644 --- a/Common/3dParty/icu/icu.pri +++ b/Common/3dParty/icu/icu.pri @@ -11,10 +11,17 @@ core_windows { } core_linux { - INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include + !core_freebsd { + INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include + + LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.$$ICU_MAJOR_VER + LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.$$ICU_MAJOR_VER + } + core_freebsd { + INCLUDEPATH += /usr/local/include + LIBS += -licuuc -l icudata + } - LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.$$ICU_MAJOR_VER - LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.$$ICU_MAJOR_VER } core_mac { diff --git a/Common/3dParty/v8/v8.pri b/Common/3dParty/v8/v8.pri index a59f0b5693f..5d0ce50b17a 100644 --- a/Common/3dParty/v8/v8.pri +++ b/Common/3dParty/v8/v8.pri @@ -20,15 +20,22 @@ core_windows { } core_linux { - SNAPSHOT_LIB=v8_snapshot - !exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) { - SNAPSHOT_LIB=v8_nosnapshot + !core_freebsd { + SNAPSHOT_LIB=v8_snapshot + !exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) { + SNAPSHOT_LIB=v8_nosnapshot + } + + LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -l$$SNAPSHOT_LIB -lv8_libsampler + LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc + } + core_freebsd { + INCLUDEPATH += /usr/local/include/node + LIBS += -lnode } - - LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -l$$SNAPSHOT_LIB -lv8_libsampler - LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc } + core_mac { LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_snapshot -lv8_libsampler diff --git a/Common/DocxFormat/Source/Base/Types_32.h b/Common/DocxFormat/Source/Base/Types_32.h index 394a8eb9a79..9baf26bf2c6 100644 --- a/Common/DocxFormat/Source/Base/Types_32.h +++ b/Common/DocxFormat/Source/Base/Types_32.h @@ -38,7 +38,7 @@ typedef unsigned __int16 _UINT16; typedef unsigned __int32 _UINT32; typedef unsigned __int64 _UINT64; -#elif __linux__ +#elif defined(__linux__) || defined(__FreeBSD__) typedef int16_t _INT16; typedef int32_t _INT32; typedef int64_t _INT64; diff --git a/Common/DocxFormat/Source/DocxFormat/Docx.cpp b/Common/DocxFormat/Source/DocxFormat/Docx.cpp index 3609fe3c1c8..7d3f9aa830a 100644 --- a/Common/DocxFormat/Source/DocxFormat/Docx.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Docx.cpp @@ -67,7 +67,7 @@ namespace OOX { void CDocx::FixAfterRead() { //solve id conflict between comments and documentComments - if(NULL != m_pComments && m_pComments->m_arrComments.size() > 0 && NULL != m_pDocumentComments && NULL != m_pDocumentComments->m_arrComments.size() > 0) + if(NULL != m_pComments && m_pComments->m_arrComments.size() > 0 && NULL != m_pDocumentComments && m_pDocumentComments->m_arrComments.size() > 0) { int maxId = INT_MIN; for (size_t i = 0; i < m_pComments->m_arrComments.size(); ++i) diff --git a/Common/DocxFormat/Source/XlsxFormat/Common.cpp b/Common/DocxFormat/Source/XlsxFormat/Common.cpp index d3b3341ea1e..f09d5e24516 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Common.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/Common.cpp @@ -43,6 +43,11 @@ #define _gcvt gcvt #endif +#ifdef __FreeBSD__ +#define _gcvt(x,n,b) sprintf(b, "%.17g", x) +#endif + + #define DBL_MAX 15 #define DBL_MAXDIG10 17 diff --git a/Common/base.pri b/Common/base.pri index 86e43d427a0..4bed36722b5 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -102,6 +102,13 @@ linux-g++:contains(DST_ARCH, arm): { } } +freebsd-clang { + message("freebsd-clang") + CONFIG += core_linux + CONFIG += core_linux_64 + CONFIG += core_freebsd +} + linux-g++-64 { message("linux-64") CONFIG += core_linux diff --git a/DesktopEditor/agg-2.4/include/agg_math.h b/DesktopEditor/agg-2.4/include/agg_math.h index 58d99bfa9ef..f8f883affb1 100644 --- a/DesktopEditor/agg-2.4/include/agg_math.h +++ b/DesktopEditor/agg-2.4/include/agg_math.h @@ -431,7 +431,7 @@ namespace agg } } -#if defined(_LINUX) || defined(__APPLE__) +#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) inline double _hypot(const double& x, const double& y) { return sqrt(x * x + y * y); diff --git a/DesktopEditor/agg-2.4/include/agg_span_gradient.h b/DesktopEditor/agg-2.4/include/agg_span_gradient.h index 8543a4dcc2d..e77ff2b7d78 100644 --- a/DesktopEditor/agg-2.4/include/agg_span_gradient.h +++ b/DesktopEditor/agg-2.4/include/agg_span_gradient.h @@ -24,7 +24,7 @@ namespace agg { -#if !defined(_LINUX) && !(defined(_WIN32) || defined (_WIN64)) && !defined(__APPLE__) +#if !defined(_LINUX) && !defined(__FreeBSD__) && !(defined(_WIN32) || defined (_WIN64)) && !defined(__APPLE__) double _hypot(double x, double y) { return sqrt(x*x + y*y); diff --git a/DesktopEditor/common/Directory.cpp b/DesktopEditor/common/Directory.cpp index 0f9d33fd700..4ce14ff4892 100644 --- a/DesktopEditor/common/Directory.cpp +++ b/DesktopEditor/common/Directory.cpp @@ -35,7 +35,7 @@ #include "windef.h" #include #include -#elif __linux__ +#elif defined(__linux__) || defined(__FreeBSD__) #include #include #include @@ -120,7 +120,7 @@ namespace NSDirectory FindClose( hRes ); #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); @@ -233,7 +233,7 @@ namespace NSDirectory } } while( FindNextFileW( hRes, &oFD ) ); FindClose( hRes ); -#elif __linux__ +#elif defined(__linux__) || defined(__FreeBSD__) BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); @@ -297,7 +297,7 @@ namespace NSDirectory #if defined(_WIN32) || defined (_WIN64) DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str()); return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); -#elif __linux__ +#elif defined(__linux__) || defined(__FreeBSD__) BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); @@ -491,7 +491,7 @@ namespace NSDirectory } #if defined(_WIN32) || defined (_WIN64) if (deleteRoot) RemoveDirectoryW(strDirectory.c_str()); -#elif __linux__ +#elif defined(__linux__) || defined(__FreeBSD__) BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index 71d173408b2..93a65d07b5b 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -39,9 +39,13 @@ #include #endif -#if defined(__linux__) || defined(_MAC) && !defined(_IOS) +#if defined(__linux__) || defined(__FreeBSD__) || defined(_MAC) && !defined(_IOS) #include #include +#if defined(__FreeBSD__) +#include +#include +#endif #endif #ifdef _IOS @@ -1481,6 +1485,22 @@ namespace NSFile return sRet; #endif +#if defined(__FreeBSD__) + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + char buf[NS_FILE_MAX_PATH]; + size_t size = NS_FILE_MAX_PATH; + + memset(buf, 0, NS_FILE_MAX_PATH); + if (sysctl(mib, 4, &buf, &size, NULL, 0) != 0) { + size = readlink("/proc/curproc/file", buf, size - 1); + if (size < 0) + return L""; + } + std::string sUTF8(buf); + std::wstring sRet = CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sUTF8.c_str(), sUTF8.length()); + return sRet; +#endif + return L""; } diff --git a/DesktopEditor/common/Path.cpp b/DesktopEditor/common/Path.cpp index 4508dc2a0b3..0718fffa259 100644 --- a/DesktopEditor/common/Path.cpp +++ b/DesktopEditor/common/Path.cpp @@ -34,7 +34,7 @@ #if defined(_WIN32) || defined (_WIN64) #include -#elif __linux__ || MAC +#elif __linux__ || __FreeBSD__ || MAC #include #endif @@ -53,7 +53,7 @@ namespace NSSystemPath sRes.append(tFolder); if(sRes.length() > 0) sRes.erase(sRes.length()-1); -#elif __linux__ || MAC +#elif __linux__ || __FreeBSD__ || MAC BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false); @@ -73,7 +73,7 @@ namespace NSSystemPath sRes.append(tFilename); sRes.append(tExt); return sRes; -#elif __linux__ || MAC +#elif __linux__ || __FreeBSD__ || MAC BYTE* pUtf8 = NULL; LONG lLen = 0; NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false); diff --git a/DesktopEditor/common/Types.h b/DesktopEditor/common/Types.h index d63f2ff253a..9b71c829726 100644 --- a/DesktopEditor/common/Types.h +++ b/DesktopEditor/common/Types.h @@ -75,7 +75,7 @@ typedef int INT; typedef unsigned int UINT, *PUINT; typedef wchar_t WCHAR; -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include typedef int64_t T_LONG64; typedef uint64_t T_ULONG64; diff --git a/DesktopEditor/cximage/CxImage/ximage.h b/DesktopEditor/cximage/CxImage/ximage.h index 61f8f4aa533..3600e7aa520 100644 --- a/DesktopEditor/cximage/CxImage/ximage.h +++ b/DesktopEditor/cximage/CxImage/ximage.h @@ -52,7 +52,7 @@ #pragma once #endif -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #define _XOPEN_SOURCE #include #include diff --git a/DesktopEditor/cximage/CxImage/ximainfo.cpp b/DesktopEditor/cximage/CxImage/ximainfo.cpp index e3a278c0c0f..1ed13adafdd 100644 --- a/DesktopEditor/cximage/CxImage/ximainfo.cpp +++ b/DesktopEditor/cximage/CxImage/ximainfo.cpp @@ -5,7 +5,7 @@ #include "ximage.h" -#if defined(_LINUX) || defined(__APPLE__) +#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef UNICODE #define _tcsnicmp(a,b,c) wcscasecmp(a,b) #else diff --git a/DesktopEditor/cximage/CxImage/ximajas.h b/DesktopEditor/cximage/CxImage/ximajas.h index 24781ee4d88..76f639ae612 100644 --- a/DesktopEditor/cximage/CxImage/ximajas.h +++ b/DesktopEditor/cximage/CxImage/ximajas.h @@ -16,7 +16,7 @@ #if CXIMAGE_SUPPORT_JASPER -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include #else #include "../jasper/include/jasper/jasper.h" diff --git a/DesktopEditor/cximage/CxImage/ximajpg.cpp b/DesktopEditor/cximage/CxImage/ximajpg.cpp index 686dc180715..8f410b21191 100644 --- a/DesktopEditor/cximage/CxImage/ximajpg.cpp +++ b/DesktopEditor/cximage/CxImage/ximajpg.cpp @@ -9,7 +9,7 @@ #if CXIMAGE_SUPPORT_JPG -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include #else #include "../jpeg/jmorecfg.h" diff --git a/DesktopEditor/cximage/CxImage/ximajpg.h b/DesktopEditor/cximage/CxImage/ximajpg.h index 4cb2484a8b7..74160700c6a 100644 --- a/DesktopEditor/cximage/CxImage/ximajpg.h +++ b/DesktopEditor/cximage/CxImage/ximajpg.h @@ -29,7 +29,7 @@ #define CXIMAGEJPG_SUPPORT_EXIF CXIMAGE_SUPPORT_EXIF extern "C" { -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include #include #else diff --git a/DesktopEditor/cximage/CxImage/ximapng.h b/DesktopEditor/cximage/CxImage/ximapng.h index cf9c4a5d577..0056f0d3e53 100644 --- a/DesktopEditor/cximage/CxImage/ximapng.h +++ b/DesktopEditor/cximage/CxImage/ximapng.h @@ -22,7 +22,7 @@ #if CXIMAGE_SUPPORT_PNG extern "C" { -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #undef _DLL #include #include diff --git a/DesktopEditor/cximage/CxImage/ximaraw.cpp b/DesktopEditor/cximage/CxImage/ximaraw.cpp index af6dd0def0c..1f16858fcfb 100644 --- a/DesktopEditor/cximage/CxImage/ximaraw.cpp +++ b/DesktopEditor/cximage/CxImage/ximaraw.cpp @@ -204,7 +204,7 @@ bool CxImageRAW::Decode(CxFile *hFile) for (c=0; c < dcr.colors; c++) ppm2[col*dcr.colors+c] = dcr.image[soff][c]; } if (dcr.opt.output_bps == 16 && !dcr.opt.output_tiff && htons(0x55aa) != 0x55aa) -#if defined(_LINUX) || defined(__APPLE__) +#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2); #else _swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2); diff --git a/DesktopEditor/cximage/raw/libdcr.h b/DesktopEditor/cximage/raw/libdcr.h index 212c15a2e44..a83bbe22bcc 100644 --- a/DesktopEditor/cximage/raw/libdcr.h +++ b/DesktopEditor/cximage/raw/libdcr.h @@ -42,7 +42,7 @@ #include #endif -#if defined(_LINUX) || defined(__APPLE__) +#if defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) #include #include #define _swab swab diff --git a/DesktopEditor/cximage/tiff/tif_config.h b/DesktopEditor/cximage/tiff/tif_config.h index 76e55df816f..544a2be4de0 100644 --- a/DesktopEditor/cximage/tiff/tif_config.h +++ b/DesktopEditor/cximage/tiff/tif_config.h @@ -19,7 +19,7 @@ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ -#ifndef _LINUX +#if !defined(_LINUX) && !defined(__FreeBSD__) #define HAVE_IO_H 1 #endif @@ -35,7 +35,7 @@ /* The size of a `long', as computed by sizeof. */ #define SIZEOF_LONG 4 -#ifndef _LINUX +#if !defined(_LINUX) && !defined(__FreeBSD__) /* Signed 64-bit type */ #define TIFF_INT64_T signed __int64 @@ -43,7 +43,7 @@ #define TIFF_UINT64_T unsigned __int64 #endif -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include /* Signed 64-bit type */ @@ -69,7 +69,7 @@ //# endif //#endif -#ifndef _LINUX +#if !defined(_LINUX) && !defined(__FreeBSD__) #define lfind _lfind #endif /* diff --git a/DesktopEditor/cximage/tiff/tiffconf.h b/DesktopEditor/cximage/tiff/tiffconf.h index be746e6ea8a..9b0ed761422 100644 --- a/DesktopEditor/cximage/tiff/tiffconf.h +++ b/DesktopEditor/cximage/tiff/tiffconf.h @@ -33,7 +33,7 @@ #define TIFF_UINT64_T unsigned __int64 #endif -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include /* Signed 64-bit type */ diff --git a/DesktopEditor/cximage/tiff/tiffiop.h b/DesktopEditor/cximage/tiff/tiffiop.h index f85b923482d..30855611243 100644 --- a/DesktopEditor/cximage/tiff/tiffiop.h +++ b/DesktopEditor/cximage/tiff/tiffiop.h @@ -62,8 +62,12 @@ extern void *lfind(const void *, const void *, size_t *, size_t, Libtiff itself does not require a 64-bit type, but bundled TIFF utilities may use it. */ +#ifndef TIFF_INT64_T typedef TIFF_INT64_T int64; +#endif +#ifndef TIFF_UINT64_T typedef TIFF_UINT64_T uint64; +#endif #endif diff --git a/DesktopEditor/doctrenderer/app_builder/main.cpp b/DesktopEditor/doctrenderer/app_builder/main.cpp index d9ced92b29b..fd68ed3a3b7 100644 --- a/DesktopEditor/doctrenderer/app_builder/main.cpp +++ b/DesktopEditor/doctrenderer/app_builder/main.cpp @@ -34,7 +34,7 @@ #include "../docbuilder.h" #include "../../common/File.h" -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include "../../../DesktopEditor/common/File.h" #endif diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index ddb66c280c7..f61887703df 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -50,7 +50,7 @@ #include "nativebuilder.h" #include -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include #include #include @@ -645,7 +645,7 @@ namespace NSDoctRenderer #endif - #ifdef LINUX + #if defined(LINUX) || defined(__FreeBSD__) pid_t pid = fork(); // create child process int status; @@ -935,7 +935,7 @@ namespace NSDoctRenderer #endif - #ifdef LINUX + #if defined(LINUX) || defined(__FreeBSD__) pid_t pid = fork(); // create child process int status; diff --git a/DesktopEditor/fontengine/ApplicationFonts.cpp b/DesktopEditor/fontengine/ApplicationFonts.cpp index 32daceeb69c..67fe5412b37 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.cpp +++ b/DesktopEditor/fontengine/ApplicationFonts.cpp @@ -1638,7 +1638,7 @@ void CApplicationFonts::Initialize(bool bIsCheckSelection) InitFromReg(); #endif -#if defined(_LINUX) && !defined(_MAC) && !defined(__ANDROID__) +#if ( defined(_LINUX) || defined(__FreeBSD__) ) && !defined(_MAC) && !defined(__ANDROID__) m_oList.LoadFromFolder(L"/usr/share/fonts"); #endif diff --git a/DesktopEditor/fontengine/MemoryStream.h b/DesktopEditor/fontengine/MemoryStream.h index 50568d4a0bc..a99f3090149 100644 --- a/DesktopEditor/fontengine/MemoryStream.h +++ b/DesktopEditor/fontengine/MemoryStream.h @@ -41,7 +41,7 @@ //#define _LOGGING_NATIVE_ #endif -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include #endif diff --git a/DesktopEditor/fontengine/fontconverter/MemoryUtils.h b/DesktopEditor/fontengine/fontconverter/MemoryUtils.h index ebb15196c35..2644a2bc1bf 100644 --- a/DesktopEditor/fontengine/fontconverter/MemoryUtils.h +++ b/DesktopEditor/fontengine/fontconverter/MemoryUtils.h @@ -37,7 +37,7 @@ #include #include -#ifdef __linux__ +#ifdef __linux__ || __FreeBSD__ #include #endif diff --git a/DesktopEditor/graphics/Graphics.cpp b/DesktopEditor/graphics/Graphics.cpp index 149d8bf8358..012b6dd778b 100644 --- a/DesktopEditor/graphics/Graphics.cpp +++ b/DesktopEditor/graphics/Graphics.cpp @@ -60,7 +60,7 @@ namespace Aggplus m_dGlobalAlpha = 1.0; m_bSwapRGB = false; -#if defined (_LINUX) || defined (_QT) +#if defined (_LINUX) || defined (_QT) || defined(__FreeBSD__) m_bSwapRGB = true; #endif @@ -93,7 +93,7 @@ namespace Aggplus m_bSwapRGB = false; -#if defined (_LINUX) || defined (_QT) +#if defined (_LINUX) || defined (_QT) || defined(__FreeBSD__) m_bSwapRGB = true; #endif @@ -131,7 +131,7 @@ namespace Aggplus m_bSwapRGB = false; -#if defined (_LINUX) || defined (_QT) +#if defined (_LINUX) || defined (_QT) || defined(_FreeBSD__) m_bSwapRGB = true; #endif diff --git a/DesktopEditor/raster/JBig2/source/LeptonLib/readfile.cpp b/DesktopEditor/raster/JBig2/source/LeptonLib/readfile.cpp index 2c398d5c6fb..e47a61b26c0 100644 --- a/DesktopEditor/raster/JBig2/source/LeptonLib/readfile.cpp +++ b/DesktopEditor/raster/JBig2/source/LeptonLib/readfile.cpp @@ -81,10 +81,10 @@ static const char JP2K_IMAGE_DATA[12] = { }; #else -static const char JP2K_CODESTREAM[4] = { 0xff, 0x4f, 0xff, 0x51 }; +static const char JP2K_CODESTREAM[4] = { (char)0xff, 0x4f, (char)0xff, 0x51 }; static const char JP2K_IMAGE_DATA[12] = { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, - 0x0D, 0x0A, 0x87, 0x0A }; + 0x0D, 0x0A, (char)0x87, 0x0A }; #endif /*---------------------------------------------------------------------* diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfObjects.h b/DesktopEditor/raster/Metafile/Wmf/WmfObjects.h index 8f27b011141..874e4f98ffc 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfObjects.h +++ b/DesktopEditor/raster/Metafile/Wmf/WmfObjects.h @@ -37,7 +37,7 @@ #include "WmfTypes.h" -#ifdef __linux__ +#ifdef __linux__ || __FreeBSD__ #include //memset oO #endif namespace MetaFile diff --git a/DesktopEditor/xml/libxml2/trionan.c b/DesktopEditor/xml/libxml2/trionan.c index 74313efd71d..a1493d13e1f 100644 --- a/DesktopEditor/xml/libxml2/trionan.c +++ b/DesktopEditor/xml/libxml2/trionan.c @@ -51,7 +51,7 @@ # include #endif #if defined(TRIO_COMPILER_DECC) -# if defined(__linux__) +# if defined(__linux__) || defined(__FreeBSD__) # include # else # include @@ -85,7 +85,7 @@ # error "Must be compiled with option -ieee" # endif # endif -# elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__)) +# elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__)) || defined(__FreeBSD__) # error "Must be compiled with option -mieee" # endif #endif /* __alpha && ! _IEEE_FP */ diff --git a/DesktopEditor/xmlsec/src/src/XmlCertificate.cpp b/DesktopEditor/xmlsec/src/src/XmlCertificate.cpp index 11664c2d7a0..78cf0e6dc7f 100644 --- a/DesktopEditor/xmlsec/src/src/XmlCertificate.cpp +++ b/DesktopEditor/xmlsec/src/src/XmlCertificate.cpp @@ -19,7 +19,7 @@ namespace NSOpenSSL #include "../../../common/File.h" -#if defined(_LINUX) && !defined(_MAC) +#if (defined(_LINUX) || defined(__FreeBSD__)) && !defined(_MAC) #include "./XmlSigner_openssl.h" #define XML_CERTIFICATE_USE_OPENSSL #define CCertificate CCertificate_openssl diff --git a/HtmlFile/HtmlFile.cpp b/HtmlFile/HtmlFile.cpp index 0ab4fa30766..f5761d209c8 100644 --- a/HtmlFile/HtmlFile.cpp +++ b/HtmlFile/HtmlFile.cpp @@ -45,7 +45,7 @@ #include #include -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include #include #include @@ -475,7 +475,7 @@ int CHtmlFile::Convert(const std::vector& arFiles, const std::wstr NSFile::CFileBinary::Remove(sTempFileForParams); #endif -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) std::wstring sTempFileForParams = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"XML"); NSFile::CFileBinary oFile; oFile.CreateFileW(sTempFileForParams); diff --git a/Makefile b/Makefile index cbcf30b568a..4250d091769 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,10 @@ ifeq ($(UNAME_M),x86_64) ARCHITECTURE := 64 ARCH_SUFFIX := x64 endif +ifeq ($(UNAME_M),amd64) + ARCHITECTURE := 64 + ARCH_SUFFIX := x64 +endif ifneq ($(filter %86,$(UNAME_M)),) ARCHITECTURE := 32 ARCH_SUFFIX := x86 @@ -40,6 +44,18 @@ else PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER) ARCH_REPO_DIR := linux endif + ifeq ($(UNAME_S),FreeBSD) + PLATFORM := linux + SHARED_EXT := .so* + SHELL_EXT := .sh + LIB_EXT := .a + LIB_PREFIX := lib + ARCH_EXT := .tar.gz + MAKE := gmake + AR := tar -zcvf + PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER) + ARCH_REPO_DIR := linux + endif ifeq ($(UNAME_S),Darwin) PLATFORM := mac SHARED_EXT := .dylib diff --git a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/miniunz.c b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/miniunz.c index 715b27f58ce..908e5148e2c 100644 --- a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/miniunz.c +++ b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/miniunz.c @@ -97,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date) SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); #else -#if defined(unix) || defined(_LINUX) || defined(__APPLE__) +#if defined(unix) || defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) struct utimbuf ut; struct tm newdate; newdate.tm_sec = tmu_date.tm_sec; diff --git a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/minizip.c b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/minizip.c index 36afed644cb..b7e82c54fdd 100644 --- a/OfficeUtils/src/zlib-1.2.11/contrib/minizip/minizip.c +++ b/OfficeUtils/src/zlib-1.2.11/contrib/minizip/minizip.c @@ -94,7 +94,7 @@ uLong filetime(f, tmzip, dt) return ret; } #else -#if defined(unix) || defined(_LINUX) || defined(__APPLE__) +#if defined(unix) || defined(_LINUX) || defined(__APPLE__) || defined(__FreeBSD__) uLong filetime(f, tmzip, dt) char *f; /* name of file to get info on */ tm_zip *tmzip; /* return value: access, modific. and creation times */ diff --git a/PdfWriter/Src/Types.h b/PdfWriter/Src/Types.h index bf126327a3d..00f3c2d1ed3 100644 --- a/PdfWriter/Src/Types.h +++ b/PdfWriter/Src/Types.h @@ -46,7 +46,7 @@ #include #include -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #endif diff --git a/Test/Applications/StandardTester/main.cpp b/Test/Applications/StandardTester/main.cpp index dda9eb82fa0..bd65cef32a2 100644 --- a/Test/Applications/StandardTester/main.cpp +++ b/Test/Applications/StandardTester/main.cpp @@ -13,7 +13,7 @@ #include "../../../DesktopEditor/fontengine/application_generate_fonts.h" -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include #include #include @@ -176,7 +176,7 @@ namespace NSX2T #endif -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) pid_t pid = fork(); // create child process int status; diff --git a/UnicodeConverter/icubuilds-mac/icu/unicode/platform.h b/UnicodeConverter/icubuilds-mac/icu/unicode/platform.h index 471caa233f7..0bd7aaf3159 100644 --- a/UnicodeConverter/icubuilds-mac/icu/unicode/platform.h +++ b/UnicodeConverter/icubuilds-mac/icu/unicode/platform.h @@ -150,7 +150,7 @@ # include #elif defined(__native_client__) # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT -#elif defined(linux) || defined(__linux__) || defined(__linux) +#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__FreeBSD__) # define U_PLATFORM U_PF_LINUX #elif defined(__APPLE__) && defined(__MACH__) # include diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 6823da87fde..2bacd15a916 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -3948,7 +3948,7 @@ namespace NExtractTools { bool bMacros = true; - _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros); + _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, 0, bMacros); nRes = processEncryptionError(nRes, sFrom, params); return nRes; @@ -3981,7 +3981,7 @@ namespace NExtractTools NSDirectory::CreateDirectory(sResultXlsxDir); bool bMacros = true; - _UINT32 nRes = ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros); + _UINT32 nRes = ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, 0, bMacros); nRes = processEncryptionError(nRes, sFrom, params); if (SUCCEEDED_X2T(nRes)) diff --git a/X2tConverter/test/batch_convert/x2t_test/mainwindow.cpp b/X2tConverter/test/batch_convert/x2t_test/mainwindow.cpp index b8d4cc1cc98..d00510b4ac5 100644 --- a/X2tConverter/test/batch_convert/x2t_test/mainwindow.cpp +++ b/X2tConverter/test/batch_convert/x2t_test/mainwindow.cpp @@ -85,7 +85,7 @@ class CDirectoryParse : public NSThreads::CBaseThread CApplicationFonts oApplication; std::vector strFontsW_Cur = oApplication.GetSetupFontFiles(); -#if defined(_LINUX) +#if defined(_LINUX) || defined(__FreeBSD__) std::wstring sHome = GetHomeDirectory(); if (!sHome.empty()) { @@ -767,7 +767,7 @@ class CConverter : public NSThreads::CBaseThread #endif -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) pid_t pid = fork(); // create child process int status; From 3cbba5e001aea4074a76a11446d723c45d0ad51f Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:30:28 +0200 Subject: [PATCH 02/12] Add iconv library needed under FreeBSD --- DesktopEditor/AllFontsGen/AllFontsGen.pro | 4 ++++ DesktopEditor/allthemesgen/allthemesgen.pro | 5 +++++ X2tConverter/build/Qt/X2tConverter.pri | 3 +++ 3 files changed, 12 insertions(+) diff --git a/DesktopEditor/AllFontsGen/AllFontsGen.pro b/DesktopEditor/AllFontsGen/AllFontsGen.pro index 245103df8ca..5073af85dec 100644 --- a/DesktopEditor/AllFontsGen/AllFontsGen.pro +++ b/DesktopEditor/AllFontsGen/AllFontsGen.pro @@ -39,4 +39,8 @@ core_linux { QMAKE_LFLAGS += -Wl,--rpath=./ } +core_freebsd { + LIBS += -liconv +} + SOURCES += main.cpp diff --git a/DesktopEditor/allthemesgen/allthemesgen.pro b/DesktopEditor/allthemesgen/allthemesgen.pro index 664144457b2..9e6b4364ed0 100644 --- a/DesktopEditor/allthemesgen/allthemesgen.pro +++ b/DesktopEditor/allthemesgen/allthemesgen.pro @@ -33,4 +33,9 @@ core_linux { QMAKE_LFLAGS += -Wl,--rpath=./ } +core_freebsd { + LIBS += -liconv +} + + SOURCES += main.cpp diff --git a/X2tConverter/build/Qt/X2tConverter.pri b/X2tConverter/build/Qt/X2tConverter.pri index 1f38285f30a..3dae37cd2b6 100755 --- a/X2tConverter/build/Qt/X2tConverter.pri +++ b/X2tConverter/build/Qt/X2tConverter.pri @@ -103,5 +103,8 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri) core_windows { LIBS += -lAdvapi32 } +core_freebsd { + LIBS += -liconv +} ######################################################## From 8852725836f6af4b91c1096ca85427dba0ad844e Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:30:57 +0200 Subject: [PATCH 03/12] Since V8 build tools are unavaible under FreeBSD it is not possible to use the officially V8 sources build with the DocumentServer scrit. A workaround is to use FreeBSD ports to get V8 --- Common/3dParty/v8/v8.pri | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Common/3dParty/v8/v8.pri b/Common/3dParty/v8/v8.pri index 4df1a4c18b9..e622a54f183 100644 --- a/Common/3dParty/v8/v8.pri +++ b/Common/3dParty/v8/v8.pri @@ -35,13 +35,19 @@ core_linux { use_v8_monolith { LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith } else { - SNAPSHOT_LIB=v8_snapshot - !exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) { - SNAPSHOT_LIB=v8_nosnapshot - } + !core_freebsd { + SNAPSHOT_LIB=v8_snapshot + !exists($$CORE_V8_PATH_LIBS/libv8_snapshot.a) { + SNAPSHOT_LIB=v8_nosnapshot + } LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -l$$SNAPSHOT_LIB -lv8_libsampler LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc + } + core_freebsd { + INCLUDEPATH += /usr/local/include/node + LIBS += -lnode + } } } From c145076e31c27f92bca9df2a2d2df42fdd3fd80a Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:32:33 +0200 Subject: [PATCH 04/12] Iconv library is needed by docbuilder --- DesktopEditor/doctrenderer/app_builder/docbuilder.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DesktopEditor/doctrenderer/app_builder/docbuilder.pro b/DesktopEditor/doctrenderer/app_builder/docbuilder.pro index 90e45135a05..f0f3e0dbcaa 100644 --- a/DesktopEditor/doctrenderer/app_builder/docbuilder.pro +++ b/DesktopEditor/doctrenderer/app_builder/docbuilder.pro @@ -44,5 +44,8 @@ ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, doctrenderer) core_linux { LIBS += -ldl } +core_freebsd { + LIBS += -liconv +} SOURCES += main.cpp From 3f7f5b72f9c7c1b2f18481bd7d8a507d4ced2598 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:33:05 +0200 Subject: [PATCH 05/12] 1. Add FreeBSD preproc command in order to load the correct header files 2. Add a specific FreeBSD routine in order to get the correct path of binary which corresponds to the current running process --- DesktopEditor/common/File.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index 9810df209cd..4479a4de2c2 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -39,10 +39,14 @@ #include #endif -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #include #include #include +#if defined(__FreeBSD__) +#include +#include +#endif #endif #ifdef _IOS @@ -1618,6 +1622,22 @@ namespace NSFile return sRet; #endif +#if defined(__FreeBSD__) + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + char buf[NS_FILE_MAX_PATH]; + size_t size = NS_FILE_MAX_PATH; + + memset(buf, 0, NS_FILE_MAX_PATH); + if (sysctl(mib, 4, &buf, &size, NULL, 0) != 0) { + size = readlink("/proc/curproc/file", buf, size - 1); + if (size < 0) + return L""; + } + std::string sUTF8(buf); + std::wstring sRet = CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sUTF8.c_str(), sUTF8.length()); + return sRet; +#endif + #if defined(__FreeBSD__) int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; char buf[NS_FILE_MAX_PATH]; From 221e1fd2c8547b157783bbbdc9f52fbbdc636aa3 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:35:28 +0200 Subject: [PATCH 06/12] Bug correction: a bool function cannot returns NULL. --- DesktopEditor/cximage/CxImage/ximagif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/cximage/CxImage/ximagif.cpp b/DesktopEditor/cximage/CxImage/ximagif.cpp index 4fbcf1eb706..36b3fb631f3 100644 --- a/DesktopEditor/cximage/CxImage/ximagif.cpp +++ b/DesktopEditor/cximage/CxImage/ximagif.cpp @@ -86,7 +86,7 @@ namespace NSGeneratePalette if ( ( X + Width ) > SrcWidth || ( Y + Height ) > SrcHeigth || NULL == pSrc ) { - return NULL; + return false; } (*pImage) = new CImage8bit (); From 013647a1385fa96abfdee5c4c176cfa2a1c45569 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:35:58 +0200 Subject: [PATCH 07/12] Add FreeBSD preproc in order to load the correct header files --- DesktopEditor/cximage/CxImage/ximapng.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/cximage/CxImage/ximapng.h b/DesktopEditor/cximage/CxImage/ximapng.h index d143d29ea97..6e1d7a5695a 100644 --- a/DesktopEditor/cximage/CxImage/ximapng.h +++ b/DesktopEditor/cximage/CxImage/ximapng.h @@ -22,7 +22,7 @@ #if CXIMAGE_SUPPORT_PNG extern "C" { -#ifdef _LINUX +#if defined(_LINUX) || defined(__FreeBSD__) #undef _DLL #include #include From ad83d6c8241df4ca13c40382bb4b87d9b4b564f1 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:36:23 +0200 Subject: [PATCH 08/12] Add FreeBSD preproc conditions in order to load the correct FreeBSD heaer files --- DesktopEditor/doctrenderer/docbuilder_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index ce06ac33c86..37c5aeedb68 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -50,7 +50,7 @@ #include "embed/NativeControlEmbed.h" #include "embed/MemoryStreamEmbed.h" #include "embed/GraphicsEmbed.h" -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include #include #include From ceff9387e02f18d6c41ab253dd9105d5ffd610d6 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:37:05 +0200 Subject: [PATCH 09/12] Bug correction: v8::ObjectTemplate::New() is a protected function which cannot be executed in this scope. "isolate" argument might correct the bug --- DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp index 0c75d227ea3..ab321777ce4 100644 --- a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp +++ b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp @@ -124,7 +124,7 @@ namespace NSGraphics { v8::EscapableHandleScope handle_scope(isolate); - v8::Local result = v8::ObjectTemplate::New(); + v8::Local result = v8::ObjectTemplate::New(isolate); result->SetInternalFieldCount(1); v8::Isolate* current = v8::Isolate::GetCurrent(); From 39763535807117b0c044fb41ecf11ed8e7e04559 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:38:07 +0200 Subject: [PATCH 10/12] Bug correction: pData is a char*& argument so this line is a bug. I guess that you wanted to reset the pointer so using "*" is wrong. If you want to reset the data buffer content you might first check that pData is not equal to NULL and then do: "*pData = (char)0;". NULL is equivalent to a pointer (its cast is void*) not a byte nor a char. --- DesktopEditor/doctrenderer/nativecontrol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/doctrenderer/nativecontrol.h b/DesktopEditor/doctrenderer/nativecontrol.h index 1f8e9238eab..ddec5637782 100644 --- a/DesktopEditor/doctrenderer/nativecontrol.h +++ b/DesktopEditor/doctrenderer/nativecontrol.h @@ -327,7 +327,7 @@ class CNativeControl if (m_map_access_directories.end() == m_map_access_directories.find(NSFile::GetDirectoryName(strFile))) { - *pData = NULL; + pData = NULL; dwLen = 0; return; } From 7d77b3acbc28e62c91c10ea675c37b93ea4c1a37 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:43:21 +0200 Subject: [PATCH 11/12] Add preproc condition in order to load the FreeBSD header files --- Test/Applications/StandardTester/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/Applications/StandardTester/main.cpp b/Test/Applications/StandardTester/main.cpp index 4e58d4ca2ef..4e558e8dd76 100644 --- a/Test/Applications/StandardTester/main.cpp +++ b/Test/Applications/StandardTester/main.cpp @@ -13,7 +13,7 @@ #include "../../../OfficeUtils/src/OfficeUtils.h" -#ifdef LINUX +#if defined(LINUX) || defined(__FreeBSD__) #include #include #include From 8cd53bc8a6d23519cb2a13c035b1b6414bd98c18 Mon Sep 17 00:00:00 2001 From: Teetoow Date: Mon, 19 Jul 2021 11:46:22 +0200 Subject: [PATCH 12/12] This is a commit error: this code has been set twice --- DesktopEditor/common/File.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index 4479a4de2c2..467f36ed5f1 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -1622,22 +1622,6 @@ namespace NSFile return sRet; #endif -#if defined(__FreeBSD__) - int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - char buf[NS_FILE_MAX_PATH]; - size_t size = NS_FILE_MAX_PATH; - - memset(buf, 0, NS_FILE_MAX_PATH); - if (sysctl(mib, 4, &buf, &size, NULL, 0) != 0) { - size = readlink("/proc/curproc/file", buf, size - 1); - if (size < 0) - return L""; - } - std::string sUTF8(buf); - std::wstring sRet = CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sUTF8.c_str(), sUTF8.length()); - return sRet; -#endif - #if defined(__FreeBSD__) int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; char buf[NS_FILE_MAX_PATH];