summaryrefslogtreecommitdiffstats
path: root/22.patch
blob: 60d5f62396494dbd20cd97df7a8c60518f829554 (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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
+};