|
|
|
@ -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
|
|
|
|
|