summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-11-29 16:11:12 +0100
committerRemi Collet <remi@php.net>2024-11-29 16:11:12 +0100
commit7dd5d9e1fb334325c3b8f3833a364f1a87d28b49 (patch)
tree42048a80929085f8748ec6b1ccf4c3366017e935
parent28d30d7d38d2bdc964bbaae14db0e1cd6ee39b3c (diff)
use pcre2 instead of pcre using patch fromHEADmaster
https://github.com/jbboehr/handlebars.c/pull/99
-rw-r--r--libhandlebars.spec25
-rw-r--r--pcre2.patch99
2 files changed, 110 insertions, 14 deletions
diff --git a/libhandlebars.spec b/libhandlebars.spec
index 726b83d..a4387b7 100644
--- a/libhandlebars.spec
+++ b/libhandlebars.spec
@@ -7,12 +7,7 @@
# Please, preserve the changelog entries
#
-%if 0%{?rhel} == 7
-# disabe test suite as check version is too old
-%bcond_with tests
-%else
%bcond_without tests
-%endif
%global soname 9
@@ -34,7 +29,7 @@
Name: %{libname}
Version: 1.0.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Handlebars C library
# SPDX
@@ -46,6 +41,9 @@ Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_
Source1: https://github.com/%{hspec_owner}/%{hspec_project}/archive/%{hspec_commit}/%{hspec_project}-%{hspec_short}.tar.gz
Source2: https://github.com/%{mspec_owner}/%{mspec_project}/archive/%{mspec_commit}/%{mspec_project}-%{mspec_short}.tar.gz
+# Use pcre2 instead of pcre
+Patch0: pcre2.patch
+
BuildRequires: gcc
BuildRequires: autoconf
BuildRequires: automake
@@ -53,7 +51,7 @@ BuildRequires: libtool
BuildRequires: libyaml-devel
BuildRequires: json-c-devel
BuildRequires: libtalloc-devel
-BuildRequires: pcre-devel
+BuildRequires: pcre2-devel
BuildRequires: lmdb-devel
%if %{with tests}
BuildRequires: check-devel >= 0.12
@@ -97,6 +95,8 @@ This package provides handlebarsc command line tool split off %{libname}.
%prep
%setup -qn %{gh_project}-%{gh_commit} -a1 -a2
+%patch -P0 -p1 -b .pcre2
+
mkdir spec
mv %{hspec_project}-%{hspec_commit} spec/handlebars
mv %{mspec_project}-%{mspec_commit} spec/mustache
@@ -124,14 +124,7 @@ make test
%endif
-%if 0%{?fedora} < 28 && 0%{?rhel} < 8
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-%endif
-
-
%files
-%{!?_licensedir:%global license %%doc}
%license LICENSE*
%{_libdir}/%{libname}.so.%{soname}*
@@ -146,6 +139,10 @@ make test
%changelog
+* Fri Nov 29 2024 Remi Collet <remi@remirepo.net> - 1.0.0-2
+- use pcre2 instead of pcre using patch from
+ https://github.com/jbboehr/handlebars.c/pull/99
+
* Mon Nov 28 2022 Remi Collet <remi@remirepo.net> - 1.0.0-1
- update to 1.0.0
- soname bump
diff --git a/pcre2.patch b/pcre2.patch
new file mode 100644
index 0000000..bdff4d5
--- /dev/null
+++ b/pcre2.patch
@@ -0,0 +1,99 @@
+From 8dc64d7f39ad64814d6b6be2058c8d3d7a7d7ebc Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Fri, 29 Nov 2024 15:58:32 +0100
+Subject: [PATCH] switch from pcre to pcre2
+
+---
+ configure.ac | 3 ++-
+ tests/test_spec_handlebars_parser.c | 1 -
+ tests/utils.c | 32 ++++++++++++++---------------
+ 3 files changed, 18 insertions(+), 18 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 45c3b3e..88307db 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -377,7 +377,8 @@ AS_IF([test "x$with_mustache_spec" != "xno"], [
+ # pcre
+ AC_ARG_ENABLE([pcre], [AS_HELP_STRING([--disable-pcre], [disable support for pcre])], [])
+ AS_IF([test "x$enable_pcre" != "xno"], [
+- PKG_CHECK_MODULES(PCRE, [libpcre], [enable_pcre=yes], [AC_MSG_WARN([libpcre not found])])
++ PKG_CHECK_MODULES(PCRE, [libpcre2-8], [enable_pcre=yes], [AC_MSG_WARN([libpcre2-8 not found])])
++ AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
+ ])
+ AS_IF([test "x$enable_pcre" == "xyes"], [
+ AC_DEFINE([HANDLEBARS_HAVE_PCRE], [1], [Use PCRE])
+diff --git a/tests/test_spec_handlebars_parser.c b/tests/test_spec_handlebars_parser.c
+index 21dddba..5f506f3 100644
+--- a/tests/test_spec_handlebars_parser.c
++++ b/tests/test_spec_handlebars_parser.c
+@@ -22,7 +22,6 @@
+ #include <errno.h>
+ #include <check.h>
+ #include <stdio.h>
+-#include <pcre.h>
+ #include <talloc.h>
+
+ // json-c undeprecated json_object_object_get, but the version in xenial
+diff --git a/tests/utils.c b/tests/utils.c
+index 437a528..369e910 100644
+--- a/tests/utils.c
++++ b/tests/utils.c
+@@ -23,7 +23,7 @@
+ #include <stdio.h>
+ #include <string.h>
+
+-#include <pcre.h>
++#include <pcre2.h>
+ #include <talloc.h>
+
+ #include <errno.h>
+@@ -187,33 +187,33 @@ int scan_directory_callback(char * dirname, scan_directory_cb cb)
+
+ int regex_compare(const char * regex, const char * string, char ** error)
+ {
+- pcre * re;
+- const char * errmsg = NULL;
+- int erroffset;
+- int ovector[30];
++ pcre2_code *re;
++ int errorcode = 0;
++ PCRE2_UCHAR errmsg[128];
++ PCRE2_SIZE erroffset;
++ pcre2_match_data *ovector;
+ int rc, ret;
+
+- re = pcre_compile(regex, 0, &errmsg, &erroffset, NULL);
++ re = pcre2_compile((PCRE2_SPTR)regex, PCRE2_ZERO_TERMINATED, 0, &errorcode, &erroffset, NULL);
+
+- if( !re ) {
+- *error = talloc_asprintf(NULL, "Regex '%s' compilation failed at offset %d: %s\n", regex, erroffset, errmsg);
++ if (!re) {
++ pcre2_get_error_message(errorcode, errmsg, sizeof(errmsg));
++ *error = talloc_asprintf(NULL, "Regex '%s' compilation failed at offset %ld: %s\n", regex, erroffset, errmsg);
+ return 1;
+- } else if( errmsg ) {
+- *error = talloc_strdup(NULL, errmsg);
+- ret = 2;
+- goto error;
+ }
+
+- rc = pcre_exec(re, NULL, string, (int) strlen(string), 0, 0, ovector, 30);
+- if( rc <= 0 ) {
++ ovector = pcre2_match_data_create_from_pattern(re, NULL);
++ rc = pcre2_match(re, (PCRE2_SPTR)string, (PCRE2_SIZE)strlen(string), 0, 0, ovector, NULL);
++ if (rc <= 0) {
+ ret = 2;
+ *error = talloc_asprintf(NULL, "Regex '%s' didn't match string '%s'", regex, string);
+ } else {
+ ret = 0;
+ }
+
+-error:
+- pcre_free(re);
++ pcre2_match_data_free(ovector);
++ pcre2_code_free(re);
++
+ return ret;
+ }
+