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-20 21:32:03 +0900
commit38bd16e351b79c74556195529d72bb7423f3912c (patch)
tree531d3e69285366120847e1051286591887158a0e
parent5215d91dcd98d02932f4146aa5ee70fd2ca412bb (diff)
downloadkbarcode-38bd16e351b79c74556195529d72bb7423f3912c.tar.gz
kbarcode-38bd16e351b79c74556195529d72bb7423f3912c.zip
Use libpcre2 instead of libpcre
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-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