Skip to content

Commit

Permalink
Fix descriptions removal, refactoring, warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed May 29, 2020
1 parent 7bda1c2 commit c5f5238
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 28 deletions.
12 changes: 12 additions & 0 deletions _build/ci/travis/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ call :%COMPILER%
:MSVC_PROJ
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin;%PATH%

rem print version
cl

cd far
MSBuild.exe /property:Configuration=%CONFIG% /property:Platform=%PLATFORM% far.vcxproj || %throw%

Expand All @@ -20,6 +23,9 @@ MSBuild.exe /property:Configuration=%CONFIG% /property:Platform=%PLATFORM% far.v
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars%PLATFORM:~-2%.bat" || %throw%
if %CONFIG%==Debug set DEBUG=1

rem print version
cl

cd far
nmake /f makefile_vc %ADD_MAKE% || %throw%
cd ..
Expand All @@ -37,6 +43,9 @@ set PATH=C:\Program Files\LLVM\bin;%PATH%
set CLANG=1
if %CONFIG%==Debug set DEBUG=1

rem print version
clang --version

cd far
nmake /f makefile_vc %ADD_MAKE% || %throw%
cd ..
Expand All @@ -48,6 +57,9 @@ cd ..
set PATH=C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw%PLATFORM:~-2%\bin;%PATH%
if %CONFIG%==Debug set DEBUG=1

rem print version
gcc --version

cd far
mingw32-make -j4 -f makefile_gcc %ADD_MAKE% || %throw%
cd ..
Expand Down
2 changes: 2 additions & 0 deletions appveyor-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ environment:
bit: 64

build_script:
#print version
- clang --version
#build Far
- cd far
- set FARMANAGER_BUILD_TYPE=VS_RELEASE
Expand Down
2 changes: 2 additions & 0 deletions appveyor-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ environment:
ADD_MAKE: DIRBIT=64

build_script:
#print version
- gcc --version
#build Far
- cd far
- set FARMANAGER_BUILD_TYPE=VS_RELEASE
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ build_script:
- enc/tools/tool.make_lua_chm.bat
#set vs environment variables
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars%bit%.bat"
#print version
- cl
#build far
- cd far
- set FARMANAGER_BUILD_TYPE=VS_RELEASE
Expand Down
8 changes: 8 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
drkns 29.05.2020 18:57:47 +0100 - build 5612

1. В некоторых случаях не удалялись описания файлов.

2. Рефакторинг.

3. Warnings.

svs 27.05.2020 21:30:18 +0300 - build 5611

1. SQLite 3.32.1
Expand Down
12 changes: 12 additions & 0 deletions far/changelog_eng
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
drkns 29.05.2020 18:57:47 +0100 - build 5612

1. File descriptions weren't removed in some cases.

2. Refactoring.

3. Warnings.

svs 27.05.2020 21:30:18 +0300 - build 5611

1. SQLite 3.32.1

drkns 26.05.2020 08:45:08 +0100 - build 5610

1. Correction of 5608.
Expand Down
7 changes: 1 addition & 6 deletions far/common/function_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace detail
{
template<typename T>
using root_type_t = std::remove_cv_t<std::remove_reference_t<std::remove_pointer_t<T>>>;

template<typename result, typename object, typename... args>
struct function_traits_impl
{
using result_type = result;

template <size_t i>
using arg = std::tuple_element_t<i, std::tuple<args...>>;

using root_result_type = root_type_t<result>;
};
}

Expand All @@ -67,6 +62,6 @@ template<typename result, typename object, typename... args>
struct function_traits<result(object::*)(args...) const>: detail::function_traits_impl<result, object, args...> {};


#define FN_RETURN_TYPE(...) function_traits<decltype(&__VA_ARGS__)>::root_result_type
#define FN_RETURN_TYPE(...) std::decay_t<function_traits<decltype(&__VA_ARGS__)>::result_type>

#endif // FUNCTION_TRAITS_HPP_071DD1DD_F933_40DC_A662_CB85F7BE7F00
10 changes: 10 additions & 0 deletions far/common/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "function_traits.hpp"
#include "type_traits.hpp"

//----------------------------------------------------------------------------

template<typename T>
Expand Down Expand Up @@ -231,6 +234,13 @@ template<typename... args> overload(args&&...) -> overload<args...>;
template<typename callable, typename variant>
constexpr decltype(auto) visit_if(callable&& Callable, variant&& Variant)
{
{
using arg = typename function_traits<callable>::template arg<0>;
using get_arg = decltype(std::get<std::decay_t<arg>>(Variant));
// This will fail if callable's arg type is not compatible with the variant:
using try_call [[maybe_unused]] = decltype(Callable(std::declval<get_arg>()));
}

return std::visit(overload
{
FWD(Callable),
Expand Down
30 changes: 14 additions & 16 deletions far/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct total_items
class ShellDelete : noncopyable
{
public:
ShellDelete(panel_ptr SrcPanel, delete_type Type, bool UpdateDiz);
ShellDelete(panel_ptr SrcPanel, delete_type Type);

struct progress
{
Expand Down Expand Up @@ -718,11 +718,18 @@ void ShellDelete::process_item(

}

ShellDelete::ShellDelete(panel_ptr SrcPanel, delete_type const Type, bool const UpdateDiz):
ShellDelete::ShellDelete(panel_ptr SrcPanel, delete_type const Type):
m_DeleteFolders(!Global->Opt->Confirm.DeleteFolder),
m_UpdateDiz(UpdateDiz),
m_UpdateDiz(Global->Opt->Diz.UpdateMode == DIZ_UPDATE_ALWAYS || (SrcPanel->IsDizDisplayed() && Global->Opt->Diz.UpdateMode == DIZ_UPDATE_IF_DISPLAYED)),
m_DeleteType(Type)
{
if (m_UpdateDiz)
SrcPanel->ReadDiz();

const auto strDizName = SrcPanel->GetDizName();
const auto CheckDiz = [&] { return !strDizName.empty() && os::fs::exists(strDizName); };
const auto DizPresent = CheckDiz();

SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<DelPreRedrawItem>());

const auto SelCount = SrcPanel->GetSelCount();
Expand All @@ -742,6 +749,9 @@ ShellDelete::ShellDelete(panel_ptr SrcPanel, delete_type const Type, bool const

SCOPE_EXIT
{
if (m_UpdateDiz && DizPresent == CheckDiz())
SrcPanel->FlushDiz();

ShellUpdatePanels(SrcPanel, NeedSetUpADir);
};

Expand Down Expand Up @@ -1156,24 +1166,12 @@ bool delayed_deleter::any() const

void Delete(const panel_ptr& SrcPanel, delete_type const Type)
{
const auto UpdateDiz = Global->Opt->Diz.UpdateMode == DIZ_UPDATE_ALWAYS || (SrcPanel->IsDizDisplayed() && Global->Opt->Diz.UpdateMode == DIZ_UPDATE_IF_DISPLAYED);

if (UpdateDiz)
SrcPanel->ReadDiz();

const auto strDizName = SrcPanel->GetDizName();
const auto CheckDiz = [&]{ return !strDizName.empty() && os::fs::exists(strDizName); };
const auto DizPresent = CheckDiz();

try
{
ShellDelete(SrcPanel, Type, UpdateDiz);
ShellDelete(SrcPanel, Type);
}
catch (const operation_cancelled&)
{
// Nop
}

if (UpdateDiz && DizPresent == CheckDiz())
SrcPanel->FlushDiz();
}
2 changes: 1 addition & 1 deletion far/filelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5198,7 +5198,7 @@ void FileList::UpdateKeyBar()

bool FileList::PluginPanelHelp(const plugin_panel* hPlugin) const
{
auto strPath = hPlugin->plugin()->ModuleName();
string_view strPath = hPlugin->plugin()->ModuleName();
CutToSlash(strPath);
const auto [File, Name, Codepage] = OpenLangFile(strPath, Global->HelpFileMask, Global->Opt->strHelpLanguage);
if (!File)
Expand Down
2 changes: 2 additions & 0 deletions far/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

WARNING_PUSH(3)

WARNING_DISABLE_GCC("-Wctor-dtor-privacy")

WARNING_DISABLE_CLANG("-Weverything")

#include "thirdparty/fmt/fmt/format.h"
Expand Down
5 changes: 3 additions & 2 deletions far/makefile_gcc_common
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ CFLAGS += \

CCFLAGS = $(CFLAGS)\
-std=gnu++17 \
-fvisibility=hidden \
-Werror=old-style-cast \
#-Wctor-dtor-privacy \
#-Wextra-semi \
-Wctor-dtor-privacy \
-Wextra-semi \
-Wnon-virtual-dtor \
-Woverloaded-virtual \
-Wsuggest-override \
Expand Down
2 changes: 1 addition & 1 deletion far/makefile_vc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ RFLAGS=/nologo /l 0x409 /fo"$(RES_FILE)" $(ADDINCLUDE) /d $(USEDEBUG)

!ifdef CLANG
CPP = clang-cl
CPPFLAGS = $(CPPFLAGS) -Qunused-arguments -Werror=old-style-cast
CPPFLAGS = $(CPPFLAGS) /clang:-fvisibility=hidden -Qunused-arguments -Werror=old-style-cast
NOBATCH=1
NO_RELEASE_LTCG=1
!elseifdef ICL
Expand Down
3 changes: 3 additions & 0 deletions far/nsUniversalDetectorEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ WARNING_PUSH(2)

WARNING_DISABLE_GCC("-Wcast-qual")
WARNING_DISABLE_GCC("-Wdouble-promotion")
WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
WARNING_DISABLE_GCC("-Wold-style-cast")
WARNING_DISABLE_GCC("-Wsuggest-override")
WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant")

WARNING_DISABLE_CLANG("-Weverything")
WARNING_DISABLE_CLANG("-Wold-style-cast")
Expand Down
2 changes: 1 addition & 1 deletion far/platform.concurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace os::concurrency
void unlock_shared() override { imports.ReleaseSRWLockShared(&m_Lock); }

private:
SRWLOCK m_Lock = SRWLOCK_INIT;
SRWLOCK m_Lock{};
};
}

Expand Down
30 changes: 30 additions & 0 deletions far/string_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@ TEST_CASE("string.eols")
}
}

TEST_CASE("string.traits")
{
REQUIRE(is_alpha(L'A'));
REQUIRE(!is_alpha(L'1'));

REQUIRE(is_alphanumeric(L'0'));
REQUIRE(!is_alphanumeric(L'?'));

REQUIRE(is_upper(L'A'));
REQUIRE(!is_upper(L'a'));

REQUIRE(is_lower(L'a'));
REQUIRE(!is_lower(L'A'));
}

TEST_CASE("string.case")
{
REQUIRE(upper(L'a') == L'A');
REQUIRE(upper(L'A') == L'A');

REQUIRE(upper(L"foo"sv) == L"FOO"sv);
REQUIRE(upper(L"FOO"sv) == L"FOO"sv);

REQUIRE(lower(L'A') == L'a');
REQUIRE(lower(L'a') == L'a');

REQUIRE(lower(L"FOO"sv) == L"foo"sv);
REQUIRE(lower(L"foo"sv) == L"foo"sv);
}

TEST_CASE("string.utils")
{
for (const auto& i: GetSpaces())
Expand Down
1 change: 1 addition & 0 deletions far/tinyxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ WARNING_DISABLE_MSC(4668) // 'symbol' is not defined as a preprocessor macro, re
WARNING_DISABLE_GCC("-Wdouble-promotion")
WARNING_DISABLE_GCC("-Wimplicit-fallthrough")
WARNING_DISABLE_GCC("-Wold-style-cast")
WARNING_DISABLE_GCC("-Wzero-as-null-pointer-constant")

WARNING_DISABLE_CLANG("-Weverything")
WARNING_DISABLE_CLANG("-Wold-style-cast")
Expand Down
3 changes: 3 additions & 0 deletions far/tinyxml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace tinyxml_impl
{
WARNING_PUSH()

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

WARNING_DISABLE_CLANG("-Weverything")

#ifdef MEMCHECK
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5611
5612

0 comments on commit c5f5238

Please sign in to comment.