summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2024-08-20 21:32:03 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-08-21 10:03:24 +0900
commit10acf645022fc899bbaba8753ec52993f64616e5 (patch)
tree3fcca8fd7e11823865c931177e6a59866ce858c4
parent2e1cbea341ab2ff740bf82e59ceaabb228b00ff7 (diff)
downloadkbarcode-10acf645022fc899bbaba8753ec52993f64616e5.tar.gz
kbarcode-10acf645022fc899bbaba8753ec52993f64616e5.zip
Use libpcre2 instead of libpcre
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 38bd16e351b79c74556195529d72bb7423f3912c)
-rw-r--r--ConfigureChecks.cmake10
-rw-r--r--kbarcode/CMakeLists.txt4
-rw-r--r--kbarcode/barcodecombo.cpp21
3 files changed, 19 insertions, 16 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 6805bd8..cc77191 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -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( )
diff --git a/kbarcode/CMakeLists.txt b/kbarcode/CMakeLists.txt
index 08984ee..4ba06a1 100644
--- a/kbarcode/CMakeLists.txt
+++ b/kbarcode/CMakeLists.txt
@@ -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}
)
diff --git a/kbarcode/barcodecombo.cpp b/kbarcode/barcodecombo.cpp
index e1e9dd8..78cebcc 100644
--- a/kbarcode/barcodecombo.cpp
+++ b/kbarcode/barcodecombo.cpp
@@ -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