diff --git a/CMakeLists.txt b/CMakeLists.txt index dac6739a2..0d376e25b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -383,7 +383,7 @@ if (NOT DEFINED MULTIARC OR MULTIARC) pkg_search_module(PCRE QUIET libpcre) if(NOT PCRE_FOUND) - message(WARNING "${ColorRed}libpcre not found, multiarc will have no custom archives support. Install libpcre and reconfigure far2l if you need that functionality.${ColorNormal}") + message(WARNING "${ColorRed}libpcre not found, multiarc will have no regexp support in custom archive format descriptions. Install libpcre and reconfigure far2l if you need that functionality.${ColorNormal}") endif() add_subdirectory (multiarc) diff --git a/multiarc/CMakeLists.txt b/multiarc/CMakeLists.txt index dbba0981a..24a75672a 100644 --- a/multiarc/CMakeLists.txt +++ b/multiarc/CMakeLists.txt @@ -148,12 +148,10 @@ elseif(UNRAR) ) endif() -if(PCRE_FOUND) - set(SOURCES - ${SOURCES} - src/formats/custom/custom.cpp - ) -endif() +set(SOURCES + ${SOURCES} + src/formats/custom/custom.cpp +) if(LibArchive_FOUND) set(SOURCES @@ -203,6 +201,8 @@ if(PCRE_FOUND) target_compile_definitions(multiarc PRIVATE -DHAVE_PCRE) target_link_libraries(multiarc ${PCRE_LDFLAGS} ${PCRE_LIBRARIES}) target_include_directories(multiarc PRIVATE ${PCRE_INCLUDE_DIRS}) +else() + add_compile_definitions(NOPCRE) endif() if(LibArchive_FOUND) diff --git a/multiarc/src/formats/custom/custom.cpp b/multiarc/src/formats/custom/custom.cpp index 87847e782..3854b09b2 100644 --- a/multiarc/src/formats/custom/custom.cpp +++ b/multiarc/src/formats/custom/custom.cpp @@ -24,8 +24,10 @@ using namespace oldfar; #include "fmt.hpp" #include +#ifndef NOPCRE #include "pcre++.h" using namespace PCRE; +#endif #if defined(__BORLANDC__) #pragma option -a1 @@ -68,8 +70,10 @@ static void FillFormat(const KeyFileValues *Values); static void MakeFiletime(SYSTEMTIME st, SYSTEMTIME syst, LPFILETIME pft); static int StringToInt(const char *str); static int64_t StringToInt64(const char *str); +#ifndef NOPCRE static void ParseListingItemRegExp(Match match, struct ArcItemInfo *Info, SYSTEMTIME &stModification, SYSTEMTIME &stCreation, SYSTEMTIME &stAccess); +#endif static void ParseListingItemPlain(const char *CurFormat, const char *CurStr, struct ArcItemInfo *Info, SYSTEMTIME &stModification, SYSTEMTIME &stCreation, SYSTEMTIME &stAccess); @@ -525,6 +529,7 @@ int WINAPI _export CUSTOM_GetArcItem(struct ArcItemInfo *Info) WINPORT(GetSystemTime)(&syst); while (GetString(Str, sizeof(Str))) { +#ifndef NOPCRE RegExp re; if (!StartText.empty()) { @@ -571,6 +576,7 @@ int WINAPI _export CUSTOM_GetArcItem(struct ArcItemInfo *Info) if (Match match = re.match(Str)) ParseListingItemRegExp(match, Info, stModification, stCreation, stAccess); } else +#endif ParseListingItemPlain(CurFormatNode->Str(), Str, Info, stModification, stCreation, stAccess); CurFormatNode = CurFormatNode->Next(); @@ -808,6 +814,7 @@ static int StringToIntHex(const char *str) return i; } +#ifndef NOPCRE static void ParseListingItemRegExp(Match match, struct ArcItemInfo *Info, SYSTEMTIME &stModification, SYSTEMTIME &stCreation, SYSTEMTIME &stAccess) { @@ -903,6 +910,7 @@ static void ParseListingItemRegExp(Match match, struct ArcItemInfo *Info, SYSTEM Info->CRC32 = StringToIntHex(match["CRC"]); } +#endif static void ParseListingItemPlain(const char *CurFormat, const char *CurStr, struct ArcItemInfo *Info, SYSTEMTIME &stModification, SYSTEMTIME &stCreation, SYSTEMTIME &stAccess)