Control: tags -1 + patch
Attached is a patch which I tested with the demo program at the end of
sipXportLib/src/utl/UtlRegex.cpp.
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/60
Author: Yavor Doganov
Forwarded: no
Last-Update: 2023-12-18
---
--- sipxtapi-3.3.0~test18+dfsg.1.orig/configure.ac
+++ sipxtapi-3.3.0~test18+dfsg.1/configure.ac
@@ -59,7 +59,7 @@
CHECK_OPUS
# PCRE is mandatory
-PKG_CHECK_MODULES([DEPS_PCRE], [libpcre >= 4.5])
+PKG_CHECK_MODULES([DEPS_PCRE], [libpcre2-8])
# OpenSSL is mandatory, find it or configure fails:
CHECK_SSL
--- sipxtapi-3.3.0~test18+dfsg.1.orig/sipXportLib/include/utl/UtlRegex.h
+++ sipxtapi-3.3.0~test18+dfsg.1/sipXportLib/include/utl/UtlRegex.h
@@ -12,7 +12,8 @@
#define _REGEX_H
#include
-#include
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include
#include "utl/UtlString.h"
/**
@@ -61,8 +62,8 @@
/// Compile a regular expression to create the matching object.
RegEx( const char * regex, //< the regular expression
- int options = 0, //< any sum of PCRE options bits
- unsigned long int maxDepth = MAX_RECURSION // see MAX_RECURSION
+ uint32_t options = 0, //< any sum of PCRE options bits
+ uint32_t maxDepth = MAX_RECURSION // see MAX_RECURSION
);
/**<
* If compiling the regular expression fails, an error message string is
@@ -71,7 +72,7 @@
*/
/// Default maximum for the recursion depth in searches.
- static const unsigned long int MAX_RECURSION;
+ static const uint32_t MAX_RECURSION;
/**<
* The PCRE internal match() function implements some searches by recursion.
* This value is the default maximumm allowed depth for that recursion. It
can
@@ -115,7 +116,7 @@
~RegEx();
/// Count the number of possible substrings returned by this expression
- int SubStrings(void) const;
+ uint32_t SubStrings(void) const;
/**<
* SubStrings() @returns the number of substrings defined by
* the regular expression.
@@ -142,8 +143,8 @@
/// Search a string for matches to this regular expression
bool Search( const char * subject, ///< the string to be searched for a
match
- int len = -1, ///< the length of the subject string
- int options = 0///< sum of any PCRE options flags
+ PCRE2_SIZE len = -1, ///< the length of the subject string
+ uint32_t options = 0 ///< sum of any PCRE options flags
);
/**<
*Apply the regular expression to the subject string.
@@ -156,9 +157,9 @@
/// Search a string starting at some offset for matches to this regular
expression
bool SearchAt(const char* subject, ///< the string to be searched for a
match
-int offset, ///< offset to begin search in subject
string
-int len = -1, ///< the length of the subject string
-int options = 0 ///< sum of any PCRE options flags
+PCRE2_SIZE offset,///< offset to begin search in subject
string
+PCRE2_SIZE len = 0, ///< the length of the subject string
+uint32_t options = 0 ///< sum of any PCRE options flags
);
/**<
*Apply the regular expression to the subject string, starting at the
given offset.
@@ -175,7 +176,7 @@
/// Repeat the last search operation, starting immediately after the
previous match
- bool SearchAgain( int options = 0///< sum of any PCRE options flags
+ bool SearchAgain( uint32_t options = 0 ///< sum of any PCRE options flags
);
/**<
*SearchAgain() applies the regular expression to the same
@@ -432,17 +433,17 @@
void ClearMatchList(void);
- pcre * re;
+ pcre2_code * re;
+ pcre2_general_context * gen_ctxt;
+ pcre2_match_context * match_ctxt;
size_t re_size;
- pcre_extra * pe;
- bool allocated_study;
- size_t study_size;
- int substrcount; // maximum substrings in pattern
+ uint32_t substrcount;// maximum substrings in pattern
const char * subjectStr; // original subject
- int subjectLen; // original length
- int lastStart; // offset of start for most recent Search or
SearchAgain
- int lastMatches; // pcre_exec return for most recent Search or
SearchAgain
- int * ovector; // results from (and workspace for) pcre_exec
+ PCRE2_SIZE subjectLen; // original length
+ PCRE2_SIZE lastStart;// offset of start for most recent Search or
SearchAgain
+ int lastMatches; // pcre2_match return for most recent Search or
SearchAgain
+ PCRE2_SIZE * ovector;// results from (and workspace for) pcre2_match
+ pcre2_match_data * md; // PCRE match data block
const char * * matchlist;// string cache for Match
};
--- sipxtapi-3.3.0~test18+dfsg.1.orig/sipXportLib/src/utl/UtlRegex.cpp
+++ sipxtapi-3.3.0~test18+dfsg.1/sipXportLib/src/utl/UtlRegex.cpp
@@