Control: tags -1 + patch Please find attached a patch (build-tested only).
>From e7127e5a2fa57f84dc12cc6d63671c872c48d28b Mon Sep 17 00:00:00 2001 From: Yavor Doganov <ya...@gnu.org> Date: Thu, 14 Dec 2023 18:31:41 +0200 Subject: [PATCH] Port to PCRE2 (#1050187)
--- debian/changelog | 7 + debian/control | 2 +- debian/patches/pcre2.patch | 316 +++++++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 4 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 debian/patches/pcre2.patch diff --git a/debian/changelog b/debian/changelog index 0f44607..9874ff2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mvdsv (0.35-7) UNRELEASED; urgency=medium + + * debian/patches/pcre2.patch: New; port to PCRE2 (Closes: #1050187). + * debian/control (Build-Depends): Replace libpcre3-dev with libpcre2-dev. + + -- Yavor Doganov <ya...@gnu.org> Thu, 14 Dec 2023 18:30:40 +0200 + mvdsv (0.35-6) unstable; urgency=high * Fix build failure on big endian systems diff --git a/debian/control b/debian/control index d53102d..f69173d 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Priority: optional Build-Depends: debhelper-compat (= 13), cmake, libcurl4-openssl-dev, - libpcre3-dev, + libpcre2-dev, Rules-Requires-Root: no Standards-Version: 4.6.2 Vcs-Browser: https://salsa.debian.org/games-team/mvdsv diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch new file mode 100644 index 0000000..efad8d1 --- /dev/null +++ b/debian/patches/pcre2.patch @@ -0,0 +1,316 @@ +Description: Port to PCRE2. +Bug-Debian: https://bugs.debian.org/1050187 +Author: Yavor Doganov <ya...@gnu.org> +Forwarded: no +Last-Update: 2023-12-14 +--- + +--- mvdsv.orig/CMakeLists.txt ++++ mvdsv/CMakeLists.txt +@@ -90,18 +90,14 @@ + ###################################################################################################### + + # Check for PCRE. if found, include it; if not found, use bundled PCRE. +-find_library(PCRE_LIBRARIES pcre) ++find_library(PCRE_LIBRARIES pcre2-8) + if(PCRE_LIBRARIES) + set(PCRE_FOUND 1) +- find_path(PCRE_INCLUDE_DIR pcre.h) ++ find_path(PCRE_INCLUDE_DIR pcre2.h) + endif(PCRE_LIBRARIES) + + if(NOT PCRE_FOUND) +- message(STATUS "PCRE library not found. Using bundled PCRE instead.") +- list(APPEND SRC_COMMON +- "${DIR_SRC}/pcre/get.c" +- "${DIR_SRC}/pcre/pcre.c" +- ) ++ message(FATAL_ERROR "PCRE library not found.") + else() + message(STATUS "Found PCRE: ${PCRE_LIBRARIES}") + endif() +--- mvdsv.orig/src/sv_demo_misc.c ++++ mvdsv/src/sv_demo_misc.c +@@ -22,7 +22,8 @@ + #ifndef CLIENTONLY + #include "qwsvdef.h" + #ifndef SERVERONLY +-#include "pcre.h" ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include <pcre2.h> + #endif + + #define MAX_DEMOINFO_SIZE (1024 * 200) +@@ -342,8 +343,10 @@ + int files[MAX_DIRFILES + 1]; + + int r; +- pcre *preg; +- const char *errbuf; ++ size_t erroffset; ++ pcre2_code *preg; ++ pcre2_match_data *md; ++ PCRE2_UCHAR errbuf[120]; + + memset(files, 0, sizeof(files)); + +@@ -361,26 +364,29 @@ + { + if (use_regex) + { +- if (!(preg = pcre_compile(Q_normalizetext(Cmd_Argv(j)), PCRE_CASELESS, &errbuf, &r, NULL))) ++ if (!(preg = pcre2_compile((PCRE2_SPTR)Q_normalizetext(Cmd_Argv(j)), PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &r, &erroffset, NULL))) + { +- Con_Printf("Sys_listdir: pcre_compile(%s) error: %s at offset %d\n", +- Cmd_Argv(j), errbuf, r); +- pcre_free(preg); ++ pcre2_get_error_message(r, errbuf, sizeof(errbuf)); ++ Con_Printf("Sys_listdir: pcre2_compile(%s) error: %s at offset %lu\n", ++ Cmd_Argv(j), errbuf, erroffset); + break; + } +- switch (r = pcre_exec(preg, NULL, list->name, +- strlen(list->name), 0, 0, NULL, 0)) ++ md = pcre2_match_data_create_from_pattern(preg, NULL); ++ switch (r = pcre2_match(preg, (PCRE2_SPTR)list->name, ++ strlen(list->name), 0, 0, md, NULL)) + { + case 0: +- pcre_free(preg); ++ pcre2_match_data_free(md); ++ pcre2_code_free(preg); + continue; +- case PCRE_ERROR_NOMATCH: ++ case PCRE2_ERROR_NOMATCH: + break; + default: +- Con_Printf("Sys_listdir: pcre_exec(%s, %s) error code: %d\n", ++ Con_Printf("Sys_listdir: pcre2_match(%s, %s) error code: %d\n", + Cmd_Argv(j), list->name, r); + } +- pcre_free(preg); ++ pcre2_match_data_free(md); ++ pcre2_code_free(preg); + break; + } + else +@@ -502,9 +508,11 @@ + char s[MAX_OSPATH]; + int len; + +- int r, ovector[OVECCOUNT]; +- pcre *preg; +- const char *errbuf; ++ int r; ++ size_t erroffset, *ovector; ++ pcre2_code *preg; ++ pcre2_match_data *md; ++ PCRE2_UCHAR errbuf[120]; + + if (!name) + return NULL; +@@ -515,29 +523,33 @@ + strlcpy(s, name, MAX_OSPATH); + len = strlen(s); + +- if (!(preg = pcre_compile(sv_demoRegexp.string, PCRE_CASELESS, &errbuf, &r, NULL))) ++ if (!(preg = pcre2_compile((PCRE2_SPTR)sv_demoRegexp.string, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &r, &erroffset, NULL))) + { +- Con_Printf("SV_MVDName2Txt: pcre_compile(%s) error: %s at offset %d\n", +- sv_demoRegexp.string, errbuf, r); +- pcre_free(preg); ++ pcre2_get_error_message(r, errbuf, sizeof(errbuf)); ++ Con_Printf("SV_MVDName2Txt: pcre2_compile(%s) error: %s at offset %lu\n", ++ sv_demoRegexp.string, errbuf, erroffset); + return NULL; + } +- r = pcre_exec(preg, NULL, s, len, 0, 0, ovector, OVECCOUNT); +- pcre_free(preg); ++ md = pcre2_match_data_create(OVECCOUNT, NULL); ++ r = pcre2_match(preg, (PCRE2_SPTR)s, len, 0, 0, md, NULL); ++ pcre2_code_free(preg); + if (r < 0) + { + switch (r) + { +- case PCRE_ERROR_NOMATCH: ++ case PCRE2_ERROR_NOMATCH: ++ pcre2_match_data_free(md); + return NULL; + default: +- Con_Printf("SV_MVDName2Txt: pcre_exec(%s, %s) error code: %d\n", ++ Con_Printf("SV_MVDName2Txt: pcre2_match(%s, %s) error code: %d\n", + sv_demoRegexp.string, s, r); ++ pcre2_match_data_free(md); + return NULL; + } + } + else + { ++ ovector = pcre2_get_ovector_pointer(md); + if (ovector[0] + 5 > MAX_OSPATH) + len = MAX_OSPATH - 5; + else +@@ -549,6 +561,7 @@ + s[len++] = 't'; + s[len] = '\0'; + ++ pcre2_match_data_free(md); + //Con_Printf("%d) %s, %s\n", r, name, s); + return va("%s", s); + } +--- mvdsv.orig/src/sv_mod_frags.c ++++ mvdsv/src/sv_mod_frags.c +@@ -30,7 +30,8 @@ + #ifndef CLIENTONLY + #include "qwsvdef.h" + #ifndef SERVERONLY +-#include "pcre.h" ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include <pcre2.h> + #endif + #include "sv_mod_frags.h" + +@@ -113,26 +114,31 @@ + + const char **qwmsg_pcre_check(const char *str, const char *qwm_str, int str_len) + { +- pcre *reg; +- int *ovector[32]; +- const char *errbuf; +- int erroffset = 0; ++ pcre2_code *reg; ++ pcre2_match_data *md; ++ int errcode; ++ PCRE2_UCHAR errbuf[120]; ++ size_t erroffset; + const char **buf = NULL; + int stringcount; + +- if (!(reg = pcre_compile(qwm_str, 0, &errbuf, &erroffset, 0))) ++ if (!(reg = pcre2_compile((PCRE2_SPTR)qwm_str, PCRE2_ZERO_TERMINATED, 0, &errcode, &erroffset, NULL))) + { +- Sys_Printf("WARNING: qwmsg_pcre_check: pcre_compile(%s) error %s\n", qwm_str, errbuf); ++ pcre2_get_error_message(errcode, errbuf, sizeof(errbuf)); ++ Sys_Printf("WARNING: qwmsg_pcre_check: pcre2_compile(%s) error %s\n", qwm_str, errbuf); + return NULL; + } + +- stringcount = pcre_exec(reg, NULL, str, str_len, 0, 0, (int *)&ovector[0], 32); +- pcre_free(reg); ++ md = pcre2_match_data_create(32, NULL); ++ stringcount = pcre2_match(reg, (PCRE2_SPTR)str, str_len, 0, 0, md, NULL); ++ pcre2_code_free(reg); + if (stringcount <= 0) { ++ pcre2_match_data_free(md); + return NULL; + } + +- pcre_get_substring_list(str, (int *)&ovector[0], stringcount, &buf); ++ pcre2_substring_list_get(md, (PCRE2_UCHAR ***)&buf, NULL); ++ pcre2_match_data_free(md); + return buf; + } + +@@ -171,7 +177,7 @@ + break; + default: ret = NULL; + } +- pcre_free_substring_list(buf); ++ pcre2_substring_list_free((PCRE2_SPTR *)buf); + break; + } + } +--- mvdsv.orig/src/qwsvdef.h ++++ mvdsv/src/qwsvdef.h +@@ -88,7 +88,8 @@ + #define PCRE_STATIC + #endif + +-#include "pcre/pcre.h" ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include <pcre2.h> + + //============================================================================= + +--- mvdsv.orig/src/sv_sys_unix.c ++++ mvdsv/src/sv_sys_unix.c +@@ -121,8 +121,10 @@ + qbool all; + + int r; +- pcre *preg = NULL; +- const char *errbuf; ++ size_t erroffset; ++ pcre2_code *preg = NULL; ++ pcre2_match_data *md; ++ PCRE2_UCHAR errbuf[120]; + + memset(list, 0, sizeof(list)); + memset(&dir, 0, sizeof(dir)); +@@ -130,35 +132,37 @@ + dir.files = list; + all = !strncmp(ext, ".*", 3); + if (!all) +- if (!(preg = pcre_compile(ext, PCRE_CASELESS, &errbuf, &r, NULL))) ++ if (!(preg = pcre2_compile((PCRE2_SPTR)ext, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &r, &erroffset, NULL))) + { +- Con_Printf("Sys_listdir: pcre_compile(%s) error: %s at offset %d\n", +- ext, errbuf, r); +- Q_free(preg); ++ pcre2_get_error_message(r, errbuf, sizeof(errbuf)); ++ Con_Printf("Sys_listdir: pcre2_compile(%s) error: %s at offset %lu\n", ++ ext, errbuf, erroffset); + return dir; + } + + if (!(d = opendir(path))) + { + if (!all) +- Q_free(preg); ++ pcre2_code_free(preg); + return dir; + } ++ md = pcre2_match_data_create_from_pattern(preg, NULL); + while ((oneentry = readdir(d))) + { + if (!strncmp(oneentry->d_name, ".", 2) || !strncmp(oneentry->d_name, "..", 3)) + continue; + if (!all) + { +- switch (r = pcre_exec(preg, NULL, oneentry->d_name, +- strlen(oneentry->d_name), 0, 0, NULL, 0)) ++ switch (r = pcre2_match(preg, (PCRE2_SPTR)oneentry->d_name, ++ strlen(oneentry->d_name), 0, 0, md, NULL)) + { + case 0: break; +- case PCRE_ERROR_NOMATCH: continue; ++ case PCRE2_ERROR_NOMATCH: continue; + default: +- Con_Printf("Sys_listdir: pcre_exec(%s, %s) error code: %d\n", ++ Con_Printf("Sys_listdir: pcre2_match(%s, %s) error code: %d\n", + ext, oneentry->d_name, r); +- Q_free(preg); ++ pcre2_match_data_free(md); ++ pcre2_code_free(preg); + return dir; + } + } +@@ -184,7 +188,7 @@ + } + closedir(d); + if (!all) +- Q_free(preg); ++ pcre2_code_free(preg); + + switch (sort_type) + { +@@ -197,6 +201,8 @@ + break; + } + ++ pcre2_match_data_free(md); ++ + return dir; + } + diff --git a/debian/patches/series b/debian/patches/series index 43b88b6..95e74c2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ 0001-use-system-pcre3.patch 0002-fix-big-endian.patch +pcre2.patch -- 2.43.0