Control: tags -1 + patch

Please find a patch attached.
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/1000126
Author: Yavor Doganov <ya...@gnu.org>
Forwarded: no
Last-Update: 2024-01-02
---

--- gpt.orig/configure.ac
+++ gpt/configure.ac
@@ -109,10 +109,10 @@
 
 # AC_MSG_CHECKING(for pcre)
 
-AC_CHECK_PROG(has_pcre, pcre-config, yes)
+AC_CHECK_PROG(has_pcre, pcre2-config, yes)
 
 if test "x$has_pcre" = "xyes"; then
-  PCRE_CONFIG="pcre-config"
+  PCRE_CONFIG="pcre2-config"
 else
   AC_MSG_ERROR(
   [
@@ -123,8 +123,8 @@
 
 #pcrecpp
 
-PCRE_INC=`${PCRE_CONFIG} --cglags`
-PCRE_LIB="-L`${PCRE_CONFIG} --prefix`/lib -lpcrecpp"
+PCRE_INC=`${PCRE_CONFIG} --cflags`
+PCRE_LIB=`${PCRE_CONFIG} --libs8`
 AC_SUBST(PCRE_INC)
 AC_SUBST(PCRE_LIB)
 
--- gpt.orig/src/modules/interpreter/InterpreterDBG.cpp
+++ gpt/src/modules/interpreter/InterpreterDBG.cpp
@@ -33,7 +33,8 @@
   #include <netdb.h>
 #endif
 
-#include <pcrecpp.h>
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
 #include <unistd.h>
 
 #ifndef WIN32
@@ -403,15 +404,40 @@
 void InterpreterDBG::processBreakpointCMD(string& bpcommand) {
  //cerr << "process breakpoint " << bpcommand << endl;
 
-  string cmd;
-  string file;
-  int line;
-  pcrecpp::RE re("breakpoint 
cmd=(add|remove).*file=\"([^\"]*)\".*line=(\\d+)");
-  if(!re.FullMatch(bpcommand, &cmd, &file, &line)) {
+  pcre2_code *re;
+  pcre2_match_data *md;
+  PCRE2_UCHAR *str;
+  PCRE2_SPTR pat, subj;
+  PCRE2_SIZE offset;
+  int line, rc;
+
+  pat = reinterpret_cast<PCRE2_SPTR>("breakpoint 
cmd=(add|remove).*file=\"([^\"]*)\".*line=(\\d+)");
+  subj = reinterpret_cast<PCRE2_SPTR>(bpcommand.c_str());
+  re = pcre2_compile(pat, PCRE2_ZERO_TERMINATED, 0, &rc, &offset, nullptr);
+  if(offset != 0) {
+    return;
+  }
+
+  md = pcre2_match_data_create_from_pattern(re, nullptr);
+  rc = pcre2_match(re, subj, bpcommand.length(), 0, 0, md, nullptr);
+  pcre2_code_free(re);
+  if(rc != 4) {
     //cerr << PACKAGE << ": comando invalido (2): \"" << cmd << "\"" << endl;
+    pcre2_match_data_free(md);
     return;
   }
 
+  pcre2_substring_get_bynumber(md, 1, &str, &offset);
+  string cmd(reinterpret_cast<char *>(str));
+  pcre2_substring_free(str);
+  pcre2_substring_get_bynumber(md, 2, &str, &offset);
+  string file(reinterpret_cast<char *>(str));
+  pcre2_substring_free(str);
+  pcre2_substring_get_bynumber(md, 3, &str, &offset);
+  line = atoi((const char *)str);
+  pcre2_substring_free(str);
+  pcre2_match_data_free(md);
+
   //cerr << PACKAGE << ": capturado:" << cmd << ":" << file << ":" << line << 
endl;
 
   if(cmd == "add") {

Reply via email to