File: pcre2.patch

package info (click to toggle)
gpt 1.1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,132 kB
  • sloc: sh: 9,899; cpp: 6,783; makefile: 147
file content (91 lines) | stat: -rw-r--r-- 2,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/1000126
Author: Yavor Doganov <yavor@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") {