diff options
author | Remi Collet <remi@remirepo.net> | 2020-12-03 08:39:51 +0100 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2020-12-03 08:39:51 +0100 |
commit | cd7885585b32246373e124764d356924ac187e70 (patch) | |
tree | a7db3ba3347a92c6065441c15fcbecd6f4764620 | |
parent | 7bbcd6522b6cda6d9a26a1613c42a8669e8427fa (diff) |
add patch for PHP 8 from
https://github.com/ph4r05/php_aho_corasick/pull/22
-rw-r--r-- | 22.patch | 238 | ||||
-rw-r--r-- | REFLECTION | 2 | ||||
-rw-r--r-- | php-pecl-ahocorasick.spec | 35 |
3 files changed, 254 insertions, 21 deletions
diff --git a/22.patch b/22.patch new file mode 100644 index 0000000..60d5f62 --- /dev/null +++ b/22.patch @@ -0,0 +1,238 @@ +From d3512d945f0f161abe26b4dd87e6cdfbe41cd913 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Thu, 8 Oct 2020 16:43:16 +0200 +Subject: [PATCH 1/3] Fix build woth PHP 8 + +--- + src/php_ahocorasick.h | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/php_ahocorasick.h b/src/php_ahocorasick.h +index d2d58de..c00cbd5 100644 +--- a/src/php_ahocorasick.h ++++ b/src/php_ahocorasick.h +@@ -34,6 +34,11 @@ + #endif + + // Compatibility ++#ifndef TSRMLS_CC ++#define TSRMLS_CC ++#define TSRMLS_DC ++#endif ++ + #if PHP_MAJOR_VERSION < 7 + #define PHP7 0 + typedef long zend_long; + +From 94c4653df65c45574770b3530947188b96397b6b Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Thu, 8 Oct 2020 16:44:07 +0200 +Subject: [PATCH 2/3] Generate arginfo from stub + +--- + src/php_ahocorasick.c | 36 ++++------------------- + src/php_ahocorasick.stub.php | 38 ++++++++++++++++++++++++ + src/php_ahocorasick_arginfo.h | 44 ++++++++++++++++++++++++++++ + src/php_ahocorasick_legacy_arginfo.h | 44 ++++++++++++++++++++++++++++ + 4 files changed, 132 insertions(+), 30 deletions(-) + create mode 100644 src/php_ahocorasick.stub.php + create mode 100644 src/php_ahocorasick_arginfo.h + create mode 100644 src/php_ahocorasick_legacy_arginfo.h + +diff --git a/src/php_ahocorasick.c b/src/php_ahocorasick.c +index ce0da64..5ceef44 100644 +--- a/src/php_ahocorasick.c ++++ b/src/php_ahocorasick.c +@@ -66,40 +66,16 @@ static char exception_buffer[8192]; + + ZEND_DECLARE_MODULE_GLOBALS(ahocorasick) + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_match, 0, 0, 2) +- ZEND_ARG_INFO(0, needle) +- ZEND_ARG_INFO(0, id) +- ZEND_ARG_INFO(0, findAll) +-ZEND_END_ARG_INFO() +- +-ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_id, 0, 0, 1) +- ZEND_ARG_INFO(0, id) +-ZEND_END_ARG_INFO() +- +-ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_init, 0, 0, 1) +- ZEND_ARG_INFO(0, data) +-ZEND_END_ARG_INFO() +- +-ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_add_patterns, 0, 0, 2) +- ZEND_ARG_INFO(0, id) +- ZEND_ARG_INFO(0, patterns) +-ZEND_END_ARG_INFO() +- +- +-static zend_function_entry ahocorasick_functions[] = { +- PHP_FE(ahocorasick_match, arginfo_ahocorasick_match) +- PHP_FE(ahocorasick_init, arginfo_ahocorasick_init) +- PHP_FE(ahocorasick_deinit, arginfo_ahocorasick_id) +- PHP_FE(ahocorasick_isValid, arginfo_ahocorasick_id) +- PHP_FE(ahocorasick_finalize, arginfo_ahocorasick_id) +- PHP_FE(ahocorasick_add_patterns, arginfo_ahocorasick_add_patterns) +- PHP_FE_END +-}; ++#if PHP_VERSION_ID < 80000 ++#include "php_ahocorasick_legacy_arginfo.h" ++#else ++#include "php_ahocorasick_arginfo.h" ++#endif + + zend_module_entry ahocorasick_module_entry = { + STANDARD_MODULE_HEADER, + PHP_AHOCORASICK_EXTNAME, +- ahocorasick_functions, ++ ext_functions, + PHP_MINIT(ahocorasick), + PHP_MSHUTDOWN(ahocorasick), + PHP_RINIT(ahocorasick), +diff --git a/src/php_ahocorasick.stub.php b/src/php_ahocorasick.stub.php +new file mode 100644 +index 0000000..1286f4b +--- /dev/null ++++ b/src/php_ahocorasick.stub.php +@@ -0,0 +1,38 @@ ++<?php ++ ++/** ++ * @generate-function-entries ++ * @generate-legacy-arginfo ++ */ ++ ++ ++/** ++ * @param resource $id ++ */ ++function ahocorasick_match(string $needle, $id, bool $findAll=true): false|array {} ++ ++/** ++ * @return resource ++ */ ++function ahocorasick_init(array $data) {} ++ ++/** ++ * @param resource $id ++ */ ++function ahocorasick_deinit($id):bool {} ++ ++/** ++ * @param resource $id ++ */ ++function ahocorasick_isValid($id): bool {} ++ ++/** ++ * @param resource $id ++ */ ++function ahocorasick_finalize($id): bool {} ++ ++/** ++ * @param resource $id ++ */ ++function ahocorasick_add_patterns($id, array $patterns): bool {} ++ +diff --git a/src/php_ahocorasick_arginfo.h b/src/php_ahocorasick_arginfo.h +new file mode 100644 +index 0000000..ea731f4 +--- /dev/null ++++ b/src/php_ahocorasick_arginfo.h +@@ -0,0 +1,44 @@ ++/* This is a generated file, edit the .stub.php file instead. ++ * Stub hash: ba403304a9d28e8231b959ba328e0b9ef4ae92c2 */ ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ahocorasick_match, 0, 2, MAY_BE_FALSE|MAY_BE_ARRAY) ++ ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0) ++ ZEND_ARG_INFO(0, id) ++ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, findAll, _IS_BOOL, 0, "true") ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_init, 0, 0, 1) ++ ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ahocorasick_deinit, 0, 1, _IS_BOOL, 0) ++ ZEND_ARG_INFO(0, id) ++ZEND_END_ARG_INFO() ++ ++#define arginfo_ahocorasick_isValid arginfo_ahocorasick_deinit ++ ++#define arginfo_ahocorasick_finalize arginfo_ahocorasick_deinit ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ahocorasick_add_patterns, 0, 2, _IS_BOOL, 0) ++ ZEND_ARG_INFO(0, id) ++ ZEND_ARG_TYPE_INFO(0, patterns, IS_ARRAY, 0) ++ZEND_END_ARG_INFO() ++ ++ ++ZEND_FUNCTION(ahocorasick_match); ++ZEND_FUNCTION(ahocorasick_init); ++ZEND_FUNCTION(ahocorasick_deinit); ++ZEND_FUNCTION(ahocorasick_isValid); ++ZEND_FUNCTION(ahocorasick_finalize); ++ZEND_FUNCTION(ahocorasick_add_patterns); ++ ++ ++static const zend_function_entry ext_functions[] = { ++ ZEND_FE(ahocorasick_match, arginfo_ahocorasick_match) ++ ZEND_FE(ahocorasick_init, arginfo_ahocorasick_init) ++ ZEND_FE(ahocorasick_deinit, arginfo_ahocorasick_deinit) ++ ZEND_FE(ahocorasick_isValid, arginfo_ahocorasick_isValid) ++ ZEND_FE(ahocorasick_finalize, arginfo_ahocorasick_finalize) ++ ZEND_FE(ahocorasick_add_patterns, arginfo_ahocorasick_add_patterns) ++ ZEND_FE_END ++}; +diff --git a/src/php_ahocorasick_legacy_arginfo.h b/src/php_ahocorasick_legacy_arginfo.h +new file mode 100644 +index 0000000..5cd1eb1 +--- /dev/null ++++ b/src/php_ahocorasick_legacy_arginfo.h +@@ -0,0 +1,44 @@ ++/* This is a generated file, edit the .stub.php file instead. ++ * Stub hash: ba403304a9d28e8231b959ba328e0b9ef4ae92c2 */ ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_match, 0, 0, 2) ++ ZEND_ARG_INFO(0, needle) ++ ZEND_ARG_INFO(0, id) ++ ZEND_ARG_INFO(0, findAll) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_init, 0, 0, 1) ++ ZEND_ARG_INFO(0, data) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_deinit, 0, 0, 1) ++ ZEND_ARG_INFO(0, id) ++ZEND_END_ARG_INFO() ++ ++#define arginfo_ahocorasick_isValid arginfo_ahocorasick_deinit ++ ++#define arginfo_ahocorasick_finalize arginfo_ahocorasick_deinit ++ ++ZEND_BEGIN_ARG_INFO_EX(arginfo_ahocorasick_add_patterns, 0, 0, 2) ++ ZEND_ARG_INFO(0, id) ++ ZEND_ARG_INFO(0, patterns) ++ZEND_END_ARG_INFO() ++ ++ ++ZEND_FUNCTION(ahocorasick_match); ++ZEND_FUNCTION(ahocorasick_init); ++ZEND_FUNCTION(ahocorasick_deinit); ++ZEND_FUNCTION(ahocorasick_isValid); ++ZEND_FUNCTION(ahocorasick_finalize); ++ZEND_FUNCTION(ahocorasick_add_patterns); ++ ++ ++static const zend_function_entry ext_functions[] = { ++ ZEND_FE(ahocorasick_match, arginfo_ahocorasick_match) ++ ZEND_FE(ahocorasick_init, arginfo_ahocorasick_init) ++ ZEND_FE(ahocorasick_deinit, arginfo_ahocorasick_deinit) ++ ZEND_FE(ahocorasick_isValid, arginfo_ahocorasick_isValid) ++ ZEND_FE(ahocorasick_finalize, arginfo_ahocorasick_finalize) ++ ZEND_FE(ahocorasick_add_patterns, arginfo_ahocorasick_add_patterns) ++ ZEND_FE_END ++}; + + @@ -1,4 +1,4 @@ -Extension [ <persistent> extension #72 ahocorasick version 0.0.7 ] { +Extension [ <persistent> extension #117 ahocorasick version 0.0.7 ] { - Functions { Function [ <internal:ahocorasick> function ahocorasick_match ] { diff --git a/php-pecl-ahocorasick.spec b/php-pecl-ahocorasick.spec index 6c2325a..75ac1ce 100644 --- a/php-pecl-ahocorasick.spec +++ b/php-pecl-ahocorasick.spec @@ -1,6 +1,6 @@ # remirepo spec file for php-pecl-ahocorasick # -# Copyright (c) 2018-2019 Remi Collet +# Copyright (c) 2018-2020 Remi Collet # License: CC-BY-SA # http://creativecommons.org/licenses/by-sa/4.0/ # @@ -24,10 +24,12 @@ Summary: Effective Aho-Corasick string pattern matching algorithm Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: 0.0.7 -Release: 3%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +Release: 4%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} License: PHP and LGPLv3 -URL: http://pecl.php.net/package/%{pecl_name} -Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz +URL: https://pecl.php.net/package/%{pecl_name} +Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz + +Patch0: https://patch-diff.githubusercontent.com/raw/ph4r05/php_aho_corasick/pull/22.patch BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel @@ -46,30 +48,17 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{rele Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} %endif -%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -Obsoletes: php71w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.2" -Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -Obsoletes: php72w-pecl-%{pecl_name} <= %{version} -%endif %if "%{php_version}" > "7.3" Obsoletes: php73-pecl-%{pecl_name} <= %{version} -Obsoletes: php73w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.4" Obsoletes: php74-pecl-%{pecl_name} <= %{version} -Obsoletes: php74w-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "7.4" +Obsoletes: php80-pecl-%{pecl_name} <= %{version} %endif - -%if 0%{?fedora} < 20 && 0%{?rhel} < 7 -# Filter shared private -%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} -%{?filter_setup} %endif @@ -98,6 +87,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%patch0 -p1 -b .pr22 + # Sanity check, really often broken extver=$(sed -n '/#define PHP_AHOCORASICK_VERSION/{s/.* "//;s/".*$//;p}' src/php_ahocorasick.h) if test "x${extver}" != "x%{version}"; then @@ -230,6 +221,10 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Thu Dec 3 2020 Remi Collet <remi@remirepo.net> - 0.0.7-4 +- add patch for PHP 8 from + https://github.com/ph4r05/php_aho_corasick/pull/22 + * Tue Sep 03 2019 Remi Collet <remi@remirepo.net> - 0.0.7-3 - rebuild for 7.4.0RC1 |