Skip to content

Commit

Permalink
custom format will work without pcre, but with no regexp support in c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
unxed committed Jul 25, 2023
1 parent 90933f2 commit e20d42f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions multiarc/CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions multiarc/src/formats/custom/custom.cpp
Expand Up @@ -24,8 +24,10 @@ using namespace oldfar;
#include "fmt.hpp"
#include <errno.h>

#ifndef NOPCRE
#include "pcre++.h"
using namespace PCRE;
#endif

#if defined(__BORLANDC__)
#pragma option -a1
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down

1 comment on commit e20d42f

@unxed
Copy link
Contributor Author

@unxed unxed commented on e20d42f Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom formats support without pcre library is not ideal for now, though. See #1777

Please sign in to comment.