Use libpcre2 instead of libpcre

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 38bd16e351)
r14.1.x
Michele Calgaro 3 months ago
parent 2e1cbea341
commit 10acf64502
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -52,9 +52,9 @@ if( WITH_JAVASCRIPT )
set( USE_JAVASCRIPT false )
endif( WITH_JAVASCRIPT )
#### check for pcre
#### check for pcre2
pkg_search_module( PCRE libpcre )
if( NOT PCRE_FOUND )
tde_message_fatal( "pcre (2.8.x) is required but was not found on your system." )
endif( NOT PCRE_FOUND )
pkg_check_modules( PCRE2 libpcre2-8 libpcre2-posix )
if( NOT PCRE2_FOUND )
tde_message_fatal( "pcre2 is required but was not found on your system." )
endif( )

@ -6,7 +6,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
${PCRE_INCLUDE_DIRS}
${PCRE2_INCLUDE_DIRS}
)
link_directories(
@ -57,7 +57,7 @@ tde_add_executable( ${PROJECT_NAME} AUTOMOC
tdeprint-shared
tdeabc-shared
kjs-shared
${PCRE_LIBRARIES}
${PCRE2_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
)

@ -20,7 +20,8 @@
#include "barkode.h"
#include "tokendialog.h"
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
// TQt includes
#include <tqcheckbox.h>
@ -46,11 +47,9 @@ BarcodeValidator::BarcodeValidator( TQObject* parent, const char* name )
bool BarcodeValidator::pcreValidate( TQString* pattern, const TQString & input ) const
{
const char* error;
const int ovector_size = 12;
int erroffset;
pcre* compiled;
int ovector[ovector_size];
int errcode;
PCRE2_SIZE erroffset;
pcre2_code* compiled;
int result;
if( !pattern || input.isEmpty() )
@ -59,13 +58,17 @@ bool BarcodeValidator::pcreValidate( TQString* pattern, const TQString & input )
if( pattern->isEmpty() )
return true;
compiled = pcre_compile( pattern->latin1(), 0, &error, &erroffset, NULL );
compiled = pcre2_compile( (PCRE2_SPTR)pattern->latin1(), PCRE2_ZERO_TERMINATED, 0,
&errcode, &erroffset, NULL );
if( !compiled ) // ignore all errors
return true;
result = pcre_exec( compiled, NULL, input.latin1(), input.length(), 0, 0, ovector, ovector_size );
pcre2_match_data *match_data;
result = pcre2_match( compiled, (PCRE2_SPTR)input.latin1(), input.length(), 0, 0, match_data, NULL);
pcre2_match_data_free(match_data);
pcre2_code_free(compiled);
return (result >= 1);
return (result >= 1);
}
TQValidator::State BarcodeValidator::validate( TQString & input, int & pos ) const

Loading…
Cancel
Save