diff --git a/far/changelog b/far/changelog index edda2534d2..361e65a1b4 100644 --- a/far/changelog +++ b/far/changelog @@ -1,4 +1,10 @@ -drkns 17.01.2015 09:38:11 +0200 - build 4241 +drkns 17.01.2015 16:00:16 +0200 - build 4242 + +1. Продолжение 4241. + +1. Поддержка компиляции в Intel C++ 14. + +drkns 17.01.2015 09:38:11 +0200 - build 4241 1. Race condition при far /? diff --git a/far/codepage.cpp b/far/codepage.cpp index 633c4058ec..670e819272 100644 --- a/far/codepage.cpp +++ b/far/codepage.cpp @@ -57,7 +57,7 @@ const wchar_t *NamesOfCodePagesKey = L"CodePages.Names"; const wchar_t *FavoriteCodePagesKey = L"CodePages.Favorites"; // -ENUM(codepages::CodePagesCallbackCallSource) +ENUM(CodePagesCallbackCallSource) { CodePageSelect, CodePagesFill, @@ -84,7 +84,7 @@ enum StandardCodePagesMenuItems class system_codepages_enumerator { public: - const static codepages::codepages_data* context; + static const codepages::codepages_data* context; static BOOL CALLBACK enum_cp(wchar_t *cpNum) { diff --git a/far/codepage.hpp b/far/codepage.hpp index 07b566ae93..b8d951e8d8 100644 --- a/far/codepage.hpp +++ b/far/codepage.hpp @@ -52,6 +52,7 @@ inline bool IsUnicodeOrUtfCodePage(uintptr_t cp) { return IsUnicodeCodePage(cp) class Dialog; struct DialogBuilderListItem2; class VMenu2; +ENUM(CodePagesCallbackCallSource); class codepages: noncopyable { @@ -101,7 +102,6 @@ class codepages: noncopyable uintptr_t currentCodePage; int favoriteCodePages, normalCodePages; bool selectedCodePages; - ENUM(CodePagesCallbackCallSource); CodePagesCallbackCallSource CallbackCallSource; class codepages_data diff --git a/far/common/enum.hpp b/far/common/enum.hpp index 48949d36d5..1c19d6c3ac 100644 --- a/far/common/enum.hpp +++ b/far/common/enum.hpp @@ -27,14 +27,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __GNUC__ -# define ENUM(ENUM_NAME) enum ENUM_NAME:int -#endif - -#ifdef _MSC_VER -# if _MSC_VER>1600 -# define ENUM(ENUM_NAME) enum ENUM_NAME:int -# else -# define ENUM(ENUM_NAME) enum ENUM_NAME -# endif +#if defined _MSC_VER && _MSC_VER < 1700 +#define ENUM(ENUM_NAME) enum ENUM_NAME +#else +#define ENUM(ENUM_NAME) enum ENUM_NAME:int #endif diff --git a/far/configdb.cpp b/far/configdb.cpp index fa41071773..dc6e129135 100644 --- a/far/configdb.cpp +++ b/far/configdb.cpp @@ -2294,7 +2294,7 @@ HierarchicalConfigUniquePtr Database::CreateHierarchicalConfig(dbcheck DbId, con return HierarchicalConfigUniquePtr(cfg.release()); } -ENUM(Database::dbcheck) +ENUM(dbcheck) { CHECK_NONE = 0, CHECK_FILTERS = BIT(0), diff --git a/far/configdb.hpp b/far/configdb.hpp index 2b651cd468..7372073a96 100644 --- a/far/configdb.hpp +++ b/far/configdb.hpp @@ -58,6 +58,7 @@ class GeneralConfig: public XmlConfig, virtual public transactional { public: virtual ~GeneralConfig() {} + virtual bool SetValue(const string& Key, const string& Name, const string& Value) = 0; virtual bool SetValue(const string& Key, const string& Name, const wchar_t* Value) = 0; virtual bool SetValue(const string& Key, const string& Name, unsigned __int64 Value) = 0; @@ -66,12 +67,20 @@ class GeneralConfig: public XmlConfig, virtual public transactional typename std::enable_if::value && !std::is_integral::value, bool>::type SetValue(const string& Key, const string& Name, const T& Value) { + static_assert(std::is_pod::value, "This template requires a POD type"); return SetValue(Key, Name, &Value, sizeof(Value)); } virtual bool GetValue(const string& Key, const string& Name, long long *Value, long long Default) = 0; virtual bool GetValue(const string& Key, const string& Name, string &strValue, const wchar_t *Default) = 0; virtual int GetValue(const string& Key, const string& Name, void *Value, size_t Size, const void *Default) = 0; + template + typename std::enable_if::value && !std::is_integral::value, bool>::type + GetValue(const string& Key, const string& Name, T& Value) + { + static_assert(std::is_pod::value, "This template requires a POD type"); + return GetValue(Key, Name, &Value, sizeof(Value)) != 0; + } virtual bool DeleteValue(const string& Key, const string& Name) = 0; virtual bool EnumValues(const string& Key, DWORD Index, string &strName, string &strValue) = 0; @@ -106,6 +115,7 @@ class HierarchicalConfig: public XmlConfig, virtual public transactional virtual unsigned __int64 CreateKey(unsigned __int64 Root, const string& Name, const string* Description=nullptr) = 0; virtual unsigned __int64 GetKeyID(unsigned __int64 Root, const string& Name) = 0; virtual bool SetKeyDescription(unsigned __int64 Root, const string& Description) = 0; + virtual bool SetValue(unsigned __int64 Root, const string& Name, const string& Value) = 0; virtual bool SetValue(unsigned __int64 Root, const string& Name, const wchar_t* Value) = 0; virtual bool SetValue(unsigned __int64 Root, const string& Name, unsigned __int64 Value) = 0; @@ -114,11 +124,21 @@ class HierarchicalConfig: public XmlConfig, virtual public transactional typename std::enable_if::value && !std::is_integral::value, bool>::type SetValue(unsigned __int64 Root, const string& Name, const T& Value) { + static_assert(std::is_pod::value, "This template requires a POD type"); return SetValue(Root, Name, &Value, sizeof(Value)); } + virtual bool GetValue(unsigned __int64 Root, const string& Name, unsigned __int64 *Value) = 0; virtual bool GetValue(unsigned __int64 Root, const string& Name, string &strValue) = 0; virtual int GetValue(unsigned __int64 Root, const string& Name, void *Value, size_t Size) = 0; + template + typename std::enable_if::value && !std::is_integral::value, bool>::type + GetValue(unsigned __int64 Root, const string& Name, T& Value) + { + static_assert(std::is_pod::value, "This template requires a POD type"); + return GetValue(Root, Name, &Value, sizeof(Value)) != 0; + } + virtual bool DeleteKeyTree(unsigned __int64 KeyID) = 0; virtual bool DeleteValue(unsigned __int64 Root, const string& Name) = 0; virtual bool EnumKeys(unsigned __int64 Root, DWORD Index, string &strName) = 0; @@ -270,6 +290,8 @@ class HistoryConfig: public XmlConfig, virtual public transactional HistoryConfig() {} }; +ENUM(dbcheck); + class Database: noncopyable { public: @@ -300,7 +322,6 @@ class Database: noncopyable HierarchicalConfigUniquePtr CreatePanelModeConfig(); private: - ENUM(dbcheck); template HierarchicalConfigUniquePtr CreateHierarchicalConfig(dbcheck DbId, const string& dbn, const char *xmln, bool Local = false, bool plugin = false); template std::unique_ptr CreateDatabase(const char *son = nullptr); void TryImportDatabase(XmlConfig *p, const char *son = nullptr, bool plugin=false); diff --git a/far/cpp.hpp b/far/cpp.hpp index 80bc1d4eb5..90991a4699 100644 --- a/far/cpp.hpp +++ b/far/cpp.hpp @@ -145,7 +145,7 @@ namespace std // already included in VC2014 #if defined _MSC_VER && _MSC_VER < 1900 -#ifndef __clang__ +#if !defined __clang__ && !defined __INTEL_COMPILER #define noexcept throw() #endif #endif @@ -159,7 +159,7 @@ namespace std #endif // already fixed in VC2013 -#if defined _MSC_VER && _MSC_VER < 1800 +#if defined _MSC_VER && _MSC_VER < 1800 || defined __INTEL_COMPILER // operator :: doesn't work with decltype(T) in VC prior to 2013, this trick fixes it: #define decltype(T) std::enable_if::type #endif diff --git a/far/far.vcxproj b/far/far.vcxproj index 0643774b61..825c8d033c 100644 --- a/far/far.vcxproj +++ b/far/far.vcxproj @@ -476,6 +476,8 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c NotUsing NotUsing NotUsing + false + false diff --git a/far/filefilter.cpp b/far/filefilter.cpp index f7ddbd616e..542aac9758 100644 --- a/far/filefilter.cpp +++ b/far/filefilter.cpp @@ -759,7 +759,7 @@ void FileFilter::InitFilter() } DWORD Flags[FFFT_COUNT] = {}; - cfg->GetValue(root,L"FoldersFilterFFlags", Flags, sizeof(Flags)); + cfg->GetValue(root,L"FoldersFilterFFlags", Flags); for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++) FoldersFilter->SetFlags((enumFileFilterFlagsType)i, Flags[i]); @@ -785,8 +785,8 @@ void FileFilter::InitFilter() NewItem.SetMask(UseMask != 0, strMask); FILETIME DateAfter = {}, DateBefore = {}; - cfg->GetValue(key,L"DateAfter", &DateAfter, sizeof(DateAfter)); - cfg->GetValue(key,L"DateBefore", &DateBefore, sizeof(DateBefore)); + cfg->GetValue(key,L"DateAfter", DateAfter); + cfg->GetValue(key,L"DateBefore", DateBefore); unsigned __int64 UseDate = 0; cfg->GetValue(key,L"UseDate",&UseDate); @@ -821,7 +821,7 @@ void FileFilter::InitFilter() NewItem.SetAttr(UseAttr != 0, (DWORD)AttrSet, (DWORD)AttrClear); DWORD Flags[FFFT_COUNT] = {}; - cfg->GetValue(key,L"FFlags", Flags, sizeof(Flags)); + cfg->GetValue(key,L"FFlags", Flags); for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++) NewItem.SetFlags((enumFileFilterFlagsType)i, Flags[i]); @@ -842,7 +842,7 @@ void FileFilter::InitFilter() // , NewItem.SetAttr(1, 0, FILE_ATTRIBUTE_DIRECTORY); DWORD Flags[FFFT_COUNT] = {}; - cfg->GetValue(key,L"FFlags", Flags, sizeof(Flags)); + cfg->GetValue(key,L"FFlags", Flags); for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++) NewItem.SetFlags((enumFileFilterFlagsType)i, Flags[i]); diff --git a/far/hilight.cpp b/far/hilight.cpp index b21da3177b..55ebb7d351 100644 --- a/far/hilight.cpp +++ b/far/hilight.cpp @@ -219,9 +219,9 @@ static void LoadFilter(HierarchicalConfig *cfg, unsigned __int64 key, FileFilter } FILETIME DateAfter = {}; - cfg->GetValue(key,HLS.DateAfter, &DateAfter, sizeof(DateAfter)); + cfg->GetValue(key,HLS.DateAfter, DateAfter); FILETIME DateBefore = {}; - cfg->GetValue(key,HLS.DateBefore, &DateBefore, sizeof(DateBefore)); + cfg->GetValue(key,HLS.DateBefore, DateBefore); unsigned __int64 UseDate = 0; cfg->GetValue(key,HLS.UseDate,&UseDate); unsigned __int64 DateType = 0; @@ -270,14 +270,14 @@ static void LoadFilter(HierarchicalConfig *cfg, unsigned __int64 key, FileFilter HData.SetSortGroup(SortGroup); HighlightFiles::highlight_item Colors = {}; - cfg->GetValue(key,HLS.NormalColor, &Colors.Color[HighlightFiles::NORMAL_COLOR].FileColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.SelectedColor, &Colors.Color[HighlightFiles::SELECTED_COLOR].FileColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.CursorColor, &Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].FileColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.SelectedCursorColor, &Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].FileColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.MarkCharNormalColor, &Colors.Color[HighlightFiles::NORMAL_COLOR].MarkColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.MarkCharSelectedColor, &Colors.Color[HighlightFiles::SELECTED_COLOR].MarkColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.MarkCharCursorColor, &Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].MarkColor, sizeof(FarColor)); - cfg->GetValue(key,HLS.MarkCharSelectedCursorColor, &Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].MarkColor, sizeof(FarColor)); + cfg->GetValue(key,HLS.NormalColor, Colors.Color[HighlightFiles::NORMAL_COLOR].FileColor); + cfg->GetValue(key,HLS.SelectedColor, Colors.Color[HighlightFiles::SELECTED_COLOR].FileColor); + cfg->GetValue(key,HLS.CursorColor, Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].FileColor); + cfg->GetValue(key,HLS.SelectedCursorColor, Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].FileColor); + cfg->GetValue(key,HLS.MarkCharNormalColor, Colors.Color[HighlightFiles::NORMAL_COLOR].MarkColor); + cfg->GetValue(key,HLS.MarkCharSelectedColor, Colors.Color[HighlightFiles::SELECTED_COLOR].MarkColor); + cfg->GetValue(key,HLS.MarkCharCursorColor, Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].MarkColor); + cfg->GetValue(key,HLS.MarkCharSelectedCursorColor, Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].MarkColor); unsigned __int64 MarkChar; if (cfg->GetValue(key,HLS.MarkChar,&MarkChar)) diff --git a/far/sqlite.c b/far/sqlite.c index 21dcfdcac1..750e409364 100644 --- a/far/sqlite.c +++ b/far/sqlite.c @@ -34,7 +34,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma warning(push, 1) #pragma warning(disable:4701) -#pragma runtime_checks("c", off) #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wstrict-overflow" diff --git a/far/syslog.cpp b/far/syslog.cpp index 42e8e1538d..5b197c5d66 100644 --- a/far/syslog.cpp +++ b/far/syslog.cpp @@ -651,7 +651,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp) if (i) { i->GetTypeAndName(Type,Name); - fwprintf(fp,L"\twindow: %p Type='%s' Name='%s'\n", i, Type.data(), Name.data()); + fwprintf(fp,L"\twindow: %p Type='%s' Name='%s'\n", i.get(), Type.data(), Name.data()); } else fwprintf(fp,L"\twindow nullptr\n"); @@ -664,7 +664,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp) if (i) { i->GetTypeAndName(Type,Name); - fwprintf(fp,L"\tModalStack Item %p Type='%s' Name='%s'\n", i, Type.data(), Name.data()); + fwprintf(fp,L"\tModalStack Item %p Type='%s' Name='%s'\n", i.get(), Type.data(), Name.data()); } else fwprintf(fp,L"\tModalStack Item nullptr\n"); @@ -677,7 +677,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp) else Man->m_currentWindow->GetTypeAndName(Type,Name); - fwprintf(fp,L"\tCurrentWindow=%p (Type='%s' Name='%s')\n", Man->m_currentWindow,Type.data(), Name.data()); + fwprintf(fp,L"\tCurrentWindow=%p (Type='%s' Name='%s')\n", Man->m_currentWindow.get(), Type.data(), Name.data()); fwprintf(fp,L"\n"); fflush(fp); } diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 5213157f88..5fbb9006dd 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4241)m4_dnl +m4_define(BUILD,4242)m4_dnl diff --git a/far/viewer.cpp b/far/viewer.cpp index ec78c4be55..a716b03f4a 100644 --- a/far/viewer.cpp +++ b/far/viewer.cpp @@ -2628,7 +2628,7 @@ struct Viewer::search_data } }; -ENUM(Viewer::SEARCHER_RESULT) +ENUM(SEARCHER_RESULT) { Search_NotFound = 0, Search_Continue = 1, @@ -2645,7 +2645,7 @@ ENUM(SEARCH_WRAP_MODE) SearchWrap_CYCLE = 2, }; -Viewer::SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd) +SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd) { char *buff = (char *)Search_buffer.data(); const char *search_str = sd->search_bytes; @@ -2713,7 +2713,7 @@ Viewer::SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd) return Search_Continue; } -Viewer::SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd) +SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd) { char *buff = (char *)Search_buffer.data(); const char *search_str = sd->search_bytes; @@ -2779,7 +2779,7 @@ Viewer::SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd) return Search_Continue; } -Viewer::SEARCHER_RESULT Viewer::search_text_forward(search_data* sd) +SEARCHER_RESULT Viewer::search_text_forward(search_data* sd) { int bsize = 8192, slen = sd->search_len, ww = (LastSearchWholeWords ? 1 : 0); wchar_t prev_char = L'\0', *buff = Search_buffer.data(), *t_buff = (sd->ch_size < 0 ? buff + bsize : nullptr); @@ -2862,7 +2862,7 @@ Viewer::SEARCHER_RESULT Viewer::search_text_forward(search_data* sd) return Search_Continue; } -Viewer::SEARCHER_RESULT Viewer::search_text_backward(search_data* sd) +SEARCHER_RESULT Viewer::search_text_backward(search_data* sd) { int bsize = 8192, slen = sd->search_len, ww = (LastSearchWholeWords ? 1 : 0); wchar_t *buff = Search_buffer.data(), *t_buff = (sd->ch_size < 0 ? buff + bsize : nullptr); @@ -2973,7 +2973,7 @@ int Viewer::read_line(wchar_t *buf, wchar_t *tbuf, INT64 cpos, int adjust, INT64 return llen; } -Viewer::SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd) +SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd) { assert(sd->pRex); assert(Search_buffer.size() >= static_cast(2*MAX_VIEWLINEB)); @@ -3040,7 +3040,7 @@ Viewer::SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd) } } -Viewer::SEARCHER_RESULT Viewer::search_regex_backward(search_data* sd) +SEARCHER_RESULT Viewer::search_regex_backward(search_data* sd) { assert(sd->pRex); assert(Search_buffer.size() >= static_cast(2*MAX_VIEWLINEB)); diff --git a/far/viewer.hpp b/far/viewer.hpp index 6358b26b3f..d9fda87da1 100644 --- a/far/viewer.hpp +++ b/far/viewer.hpp @@ -44,6 +44,7 @@ class FileViewer; class KeyBar; class Dialog; class time_check; +ENUM(SEARCHER_RESULT); class Viewer:public SimpleScreenObject { @@ -96,7 +97,6 @@ class Viewer:public SimpleScreenObject private: struct ViewerString; - ENUM(SEARCHER_RESULT); virtual void DisplayObject() override; void ShowPage(int nMode);