Skip to content

Commit

Permalink
new fmt and tinyxml2 versions, don't preload lua51 if there are no pl…
Browse files Browse the repository at this point in the history
…ugins at all
  • Loading branch information
alabuzhev committed Aug 30, 2017
1 parent d88c64f commit dfc283f
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 30 deletions.
6 changes: 6 additions & 0 deletions far/changelog
@@ -1,3 +1,9 @@
drkns 30.08.2017 20:44:52 +0100 - build 5019

1. Новые версии tinyxml2 и fmt.

2. Не прелоадим lua51.dll, если плагины отсутствуют в принципе.

svs 30.08.2017 14:14:51 +0300 - build 5018

1. SQLite 3.20.1
Expand Down
1 change: 1 addition & 0 deletions far/disabled_warnings.hpp
Expand Up @@ -39,6 +39,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma warning(disable: 4091) // https://msdn.microsoft.com/en-us/library/eehkcz60.aspx 'typedef ': ignored on left of 'type' when no variable is declared
#pragma warning(disable: 4265) // https://msdn.microsoft.com/en-us/library/wzxffy8c.aspx 'class' : class has virtual functions, but destructor is not virtual
#pragma warning(disable: 4668) // https://msdn.microsoft.com/en-us/library/4dt9kyhy.aspx 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
#pragma warning(disable: 4768) // no page __declspec attributes before linkage specification are ignored
#pragma warning(disable: 4774) // no page 'function' : format string expected in argument 'number' is not a string literal
#pragma warning(disable: 4917) // https://msdn.microsoft.com/en-us/library/3w98z1xh.aspx 'declarator' : a GUID can only be associated with a class, interface or namespace
#pragma warning(disable: 4987) // no page nonstandard extension used: 'throw (...)'
Expand Down
3 changes: 2 additions & 1 deletion far/format.hpp
Expand Up @@ -37,6 +37,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
WARNING_PUSH(3)

#include "thirdparty/fmt/format.h"
#include "thirdparty/fmt/string.h"

WARNING_POP()

Expand All @@ -49,7 +50,7 @@ auto format(F&& Format, args&&... Args)
template<typename T>
auto str(T&& Value)
{
return format(L"{0}", FWD(Value));
return fmt::to_wstring(FWD(Value));
}

template<typename T>
Expand Down
34 changes: 33 additions & 1 deletion far/legacy_cpu_check.cpp
@@ -1,3 +1,35 @@
/*
legacy_cpu_check.cpp
Проверка поддержки SSE2 для x86
*/
/*
Copyright © 2017 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "headers.hpp"
#pragma hdrstop

Expand All @@ -20,7 +52,7 @@ bool IsLegacyCPU()
int info[4] = { 0, 0, 0, 0 };
cpuid(info, 0);
if (info[0] >= 1)
{
{
cpuid(info, 1);
have_sse2 = (info[3] & ((int)1 << 26)) != 0;
}
Expand Down
7 changes: 3 additions & 4 deletions far/legacy_cpu_check.hpp
@@ -1,15 +1,14 @@
#ifndef LEGACY_CPU_CHECK_HPP_38B388C1_AF11_4F09_9643_074418E35699
#ifndef LEGACY_CPU_CHECK_HPP_38B388C1_AF11_4F09_9643_074418E35699
#define LEGACY_CPU_CHECK_HPP_38B388C1_AF11_4F09_9643_074418E35699
#pragma once

/*
legacy_cpu_check.hpp
Ïðîâåðêà ïîääåðæêè SSE2 äëÿ x86
Проверка поддержки SSE2 для x86
*/
/*
Copyright © 1996 Eugene Roshal
Copyright © 2000 Far Group
Copyright © 2017 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 0 additions & 7 deletions far/main.cpp
Expand Up @@ -70,7 +70,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cvtname.hpp"
#include "drivemix.hpp"
#include "new_handler.hpp"
#include "legacy_cpu_check.hpp"

global *Global = nullptr;

Expand Down Expand Up @@ -150,12 +149,6 @@ static int MainProcess(
ppanel = Global->Opt->LocalProfilePath;
}

if (IsLegacyCPU())
{
auto legacy_path = Global->g_strFarPath + L"\\legacy\\lua51.dll"; // %FARHOME%\legacy\lua51.dll
LoadLibraryW(legacy_path.data());
}

if (!ename.empty() || !vname.empty())
{
Global->OnlyEditorViewerUsed = true;
Expand Down
27 changes: 25 additions & 2 deletions far/plugins.cpp
Expand Up @@ -69,6 +69,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "string_utils.hpp"
#include "cvtname.hpp"
#include "delete.hpp"
#include "legacy_cpu_check.hpp"

static const wchar_t PluginsFolderName[] = L"Plugins";

Expand Down Expand Up @@ -127,6 +128,16 @@ static void CallPluginSynchroEvent(const any& Payload)
}
}

static void EnsureLuaCpuCompatibility()
{
if (!IsLegacyCPU())
return;

static os::rtdl::module LuaModule(Global->g_strFarPath + L"\\legacy\\lua51.dll");
// modules are lazy loaded
LuaModule.operator bool();
}

PluginManager::PluginManager():
m_PluginSynchro(plugin_synchro, &CallPluginSynchroEvent),
#ifndef NO_WRAPPER
Expand Down Expand Up @@ -382,7 +393,19 @@ void PluginManager::LoadFactories()

void PluginManager::LoadPlugins()
{
const auto AnyPluginsPossible =
Global->Opt->LoadPlug.PluginsCacheOnly ||
Global->Opt->LoadPlug.MainPluginDir ||
Global->Opt->LoadPlug.PluginsPersonal ||
!Global->Opt->LoadPlug.strCustomPluginsPath.empty();

if (!AnyPluginsPossible)
return;

SCOPED_ACTION(IndeterminateTaskBar)(false);

EnsureLuaCpuCompatibility();

m_PluginsLoaded = false;

LoadFactories();
Expand All @@ -391,7 +414,7 @@ void PluginManager::LoadPlugins()
{
LoadPluginsFromCache();
}
else if (Global->Opt->LoadPlug.MainPluginDir || !Global->Opt->LoadPlug.strCustomPluginsPath.empty() || (Global->Opt->LoadPlug.PluginsPersonal && !Global->Opt->LoadPlug.strPersonalPluginsPath.empty()))
else
{
ScanTree ScTree(false, true, Global->Opt->LoadPlug.ScanSymlinks);
string strPluginsDir;
Expand All @@ -402,7 +425,7 @@ void PluginManager::LoadPlugins()
{
strPluginsDir=Global->g_strFarPath+PluginsFolderName;
// ...а персональные есть?
if (Global->Opt->LoadPlug.PluginsPersonal && !Global->Opt->LoadPlug.strPersonalPluginsPath.empty())
if (Global->Opt->LoadPlug.PluginsPersonal)
append(strPluginsDir, L';', Global->Opt->LoadPlug.strPersonalPluginsPath);
}
else if (!Global->Opt->LoadPlug.strCustomPluginsPath.empty()) // только "заказные" пути?
Expand Down
34 changes: 25 additions & 9 deletions far/thirdparty/fmt/format.h
Expand Up @@ -28,6 +28,7 @@
#ifndef FMT_FORMAT_H_
#define FMT_FORMAT_H_

#define FMT_INCLUDE
#include <cassert>
#include <clocale>
#include <cmath>
Expand All @@ -39,11 +40,12 @@
#include <string>
#include <vector>
#include <utility> // for std::pair
#undef FMT_INCLUDE

// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 40000
#define FMT_VERSION 40001

#ifdef _SECURE_SCL
#if defined _SECURE_SCL && _SECURE_SCL
# define FMT_SECURE_SCL _SECURE_SCL
#else
# define FMT_SECURE_SCL 0
Expand Down Expand Up @@ -97,7 +99,9 @@ typedef __int64 intmax_t;
# define FMT_HAS_GXX_CXX11 1
# endif
#else
# define FMT_GCC_VERSION 0
# define FMT_GCC_EXTENSION
# define FMT_HAS_GXX_CXX11 0
#endif

#if defined(__INTEL_COMPILER)
Expand Down Expand Up @@ -135,6 +139,15 @@ typedef __int64 intmax_t;
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
#endif

// Use the compiler's attribute noreturn
#if defined(__MINGW32__) || defined(__MINGW64__)
# define FMT_NORETURN __attribute__((noreturn))
#elif FMT_HAS_CPP_ATTRIBUTE(noreturn) && __cplusplus >= 201103L
# define FMT_NORETURN [[noreturn]]
#else
# define FMT_NORETURN
#endif

#ifndef FMT_USE_VARIADIC_TEMPLATES
// Variadic templates are available in GCC since version 4.4
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
Expand Down Expand Up @@ -262,11 +275,14 @@ typedef __int64 intmax_t;
// makes the fmt::literals implementation easier. However, an explicit check
// for variadic templates is added here just in case.
// For Intel's compiler both it and the system gcc/msc must support UDLs.
# define FMT_USE_USER_DEFINED_LITERALS \
FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \
# if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \
(FMT_HAS_FEATURE(cxx_user_literals) || \
(FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900) && \
(!defined(FMT_ICC_VERSION) || FMT_ICC_VERSION >= 1500)
# define FMT_USE_USER_DEFINED_LITERALS 1
# else
# define FMT_USE_USER_DEFINED_LITERALS 0
# endif
#endif

#ifndef FMT_USE_EXTERN_TEMPLATES
Expand Down Expand Up @@ -726,7 +742,7 @@ template <typename T>
template <typename U>
void Buffer<T>::append(const U *begin, const U *end) {
FMT_ASSERT(end >= begin, "negative value");
std::size_t new_size = size_ + (end - begin);
std::size_t new_size = size_ + static_cast<std::size_t>(end - begin);
if (new_size > capacity_)
grow(new_size);
std::uninitialized_copy(begin, end,
Expand Down Expand Up @@ -916,7 +932,7 @@ struct IntTraits {
TypeSelector<std::numeric_limits<T>::digits <= 32>::Type MainType;
};

FMT_API void report_unknown_type(char code, const char *type);
FMT_API FMT_NORETURN void report_unknown_type(char code, const char *type);

// Static data is placed in this class template to allow header-only
// configuration.
Expand Down Expand Up @@ -1248,9 +1264,9 @@ inline fmt::StringRef thousands_sep(...) { return ""; }
typedef int FMT_CONCAT_(Assert, __LINE__)[(cond) ? 1 : -1] FMT_UNUSED
#endif

template <typename Formatter, typename Char, typename T>
void format_arg(Formatter &, const Char *, const T &) {
FMT_STATIC_ASSERT(FalseType<T>::value,
template <typename Formatter>
void format_arg(Formatter&, ...) {
FMT_STATIC_ASSERT(FalseType<Formatter>::value,
"Cannot format argument. To enable the use of ostream "
"operator<< include fmt/ostream.h. Otherwise provide "
"an overload of format_arg.");
Expand Down
8 changes: 6 additions & 2 deletions far/thirdparty/tinyxml2/tinyxml2.cpp
Expand Up @@ -424,20 +424,24 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length

output += *length;

// Scary scary fall throughs.
// Scary scary fall throughs are annotated with carefully designed comments
// to suppress compiler warnings such as -Wimplicit-fallthrough in gcc
switch (*length) {
case 4:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 3:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 2:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 1:
--output;
*output = (char)(input | FIRST_BYTE_MARK[*length]);
Expand Down Expand Up @@ -2050,7 +2054,7 @@ void XMLDocument::Clear()
}


void XMLDocument::DeepCopy(XMLDocument* target)
void XMLDocument::DeepCopy(XMLDocument* target) const
{
TIXMLASSERT(target);
if (target == this) {
Expand Down
6 changes: 3 additions & 3 deletions far/thirdparty/tinyxml2/tinyxml2.h
Expand Up @@ -341,8 +341,8 @@ class MemPoolT : public MemPool
void Clear() {
// Delete the blocks.
while( !_blockPtrs.Empty()) {
Block* b = _blockPtrs.Pop();
delete b;
Block* lastBlock = _blockPtrs.Pop();
delete lastBlock;
}
_root = 0;
_currentAllocs = 0;
Expand Down Expand Up @@ -1826,7 +1826,7 @@ class TINYXML2_LIB XMLDocument : public XMLNode
NOTE: that the 'target' must be non-null.
*/
void DeepCopy(XMLDocument* target);
void DeepCopy(XMLDocument* target) const;

// internal
char* Identify( char* p, XMLNode** node );
Expand Down
1 change: 0 additions & 1 deletion far/tinyxml.cpp
Expand Up @@ -45,7 +45,6 @@ WARNING_PUSH()
WARNING_DISABLE_MSC(4296) // https://msdn.microsoft.com/en-us/library/wz2y40yt.aspx 'operator' : expression is always true

WARNING_DISABLE_GCC("-Wpragmas")
WARNING_DISABLE_GCC("-Wimplicit-fallthrough")
WARNING_DISABLE_GCC("-Wsuggest-override")
WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant")

Expand Down

0 comments on commit dfc283f

Please sign in to comment.