-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathenchant-php7.4.patch
301 lines (272 loc) · 11.4 KB
/
enchant-php7.4.patch
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
diff -ur php-7.4.26.orig/ext/enchant/config.m4 php-7.4.26/ext/enchant/config.m4
--- php-7.4.26.orig/ext/enchant/config.m4 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/config.m4 2021-12-14 10:38:53.318024515 +0200
@@ -4,26 +4,38 @@
[Include Enchant support])])
if test "$PHP_ENCHANT" != "no"; then
- PKG_CHECK_MODULES([ENCHANT], [enchant])
+ PKG_CHECK_MODULES([ENCHANT2], [enchant-2], [found_enchant_2=yes], [found_enchant_2=no])
- PHP_EVAL_INCLINE($ENCHANT_CFLAGS)
- PHP_EVAL_LIBLINE($ENCHANT_LIBS, ENCHANT_SHARED_LIBADD)
+ if test "$found_enchant_2" = "yes"; then
- AC_DEFINE(HAVE_ENCHANT, 1, [ ])
+ PHP_EVAL_INCLINE($ENCHANT2_CFLAGS)
+ PHP_EVAL_LIBLINE($ENCHANT2_LIBS, ENCHANT_SHARED_LIBADD)
+
+ AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ enchant_get_version since 1.6.0 ])
- PHP_CHECK_LIBRARY(enchant, enchant_get_version,
- [
- AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ ])
- ], [ ], [
- $ENCHANT_LIBS
- ])
-
- PHP_CHECK_LIBRARY(enchant, enchant_broker_set_param,
- [
- AC_DEFINE(HAVE_ENCHANT_BROKER_SET_PARAM, 1, [ ])
- ], [ ], [
- $ENCHANT_LIBS
- ])
+ else
+ AC_MSG_WARN([libenchant-2 not found trying with old libenchant])
+ PKG_CHECK_MODULES([ENCHANT], [enchant >= 1.4.2])
+
+ PHP_EVAL_INCLINE($ENCHANT_CFLAGS)
+ PHP_EVAL_LIBLINE($ENCHANT_LIBS, ENCHANT_SHARED_LIBADD)
+
+ PHP_CHECK_LIBRARY(enchant, enchant_get_version,
+ [
+ AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ enchant_get_version since 1.6.0 ])
+ ], [ ], [
+ $ENCHANT_LIBS
+ ])
+
+ PHP_CHECK_LIBRARY(enchant, enchant_broker_set_param,
+ [
+ AC_DEFINE(HAVE_ENCHANT_BROKER_SET_PARAM, 1, [ enchant_broker_set_param since 1.5.0 and removed in 2.x ])
+ ], [ ], [
+ $ENCHANT_LIBS
+ ])
+ fi
+
+ AC_DEFINE(HAVE_ENCHANT, 1, [ ])
PHP_NEW_EXTENSION(enchant, enchant.c, $ext_shared)
PHP_SUBST(ENCHANT_SHARED_LIBADD)
diff -ur php-7.4.26.orig/ext/enchant/enchant.c php-7.4.26/ext/enchant/enchant.c
--- php-7.4.26.orig/ext/enchant/enchant.c 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/enchant.c 2021-12-14 10:38:53.318024515 +0200
@@ -135,9 +135,10 @@
PHP_FE(enchant_broker_describe, arginfo_enchant_broker_free)
PHP_FE(enchant_dict_check, arginfo_enchant_dict_check)
PHP_FE(enchant_dict_suggest, arginfo_enchant_dict_check)
- PHP_FE(enchant_dict_add_to_personal, arginfo_enchant_dict_check)
+ PHP_FE(enchant_dict_add, arginfo_enchant_dict_check)
+ PHP_FALIAS(enchant_dict_add_to_personal, enchant_dict_add, arginfo_enchant_dict_check)
PHP_FE(enchant_dict_add_to_session, arginfo_enchant_dict_check)
- PHP_FE(enchant_dict_is_in_session, arginfo_enchant_dict_check)
+ PHP_FE(enchant_dict_is_added, arginfo_enchant_dict_check)
PHP_FE(enchant_dict_store_replacement, arginfo_enchant_dict_store_replacement)
PHP_FE(enchant_dict_get_error, arginfo_enchant_broker_free_dict)
PHP_FE(enchant_dict_describe, arginfo_enchant_broker_free_dict)
@@ -285,6 +286,9 @@
le_enchant_dict = zend_register_list_destructors_ex(php_enchant_dict_free, NULL, "enchant_dict", module_number);
REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_CS | CONST_PERSISTENT);
+#ifdef HAVE_ENCHANT_GET_VERSION
+ REGISTER_STRING_CONSTANT("LIBENCHANT_VERSION", enchant_get_version(), CONST_CS | CONST_PERSISTENT);
+#endif
return SUCCESS;
}
/* }}} */
@@ -392,7 +396,7 @@
{
zval *broker;
enchant_broker *pbroker;
- char *msg;
+ const char *msg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &broker) == FAILURE) {
RETURN_FALSE;
@@ -738,7 +742,7 @@
for (i = 0; i < n_sugg; i++) {
add_next_index_string(sugg, suggs[i]);
}
- enchant_dict_free_suggestions(pdict->pdict, suggs);
+ enchant_dict_free_string_list(pdict->pdict, suggs);
}
@@ -793,14 +797,14 @@
add_next_index_string(return_value, suggs[i]);
}
- enchant_dict_free_suggestions(pdict->pdict, suggs);
+ enchant_dict_free_string_list(pdict->pdict, suggs);
}
}
/* }}} */
-/* {{{ proto void enchant_dict_add_to_personal(resource dict, string word)
+/* {{{ proto void enchant_dict_add(resource dict, string word)
add 'word' to personal word list */
-PHP_FUNCTION(enchant_dict_add_to_personal)
+PHP_FUNCTION(enchant_dict_add)
{
zval *dict;
char *word;
@@ -813,7 +817,7 @@
PHP_ENCHANT_GET_DICT;
- enchant_dict_add_to_personal(pdict->pdict, word, wordlen);
+ enchant_dict_add(pdict->pdict, word, wordlen);
}
/* }}} */
@@ -836,9 +840,9 @@
}
/* }}} */
-/* {{{ proto bool enchant_dict_is_in_session(resource dict, string word)
+/* {{{ proto bool enchant_dict_is_added(resource dict, string word)
whether or not 'word' exists in this spelling-session */
-PHP_FUNCTION(enchant_dict_is_in_session)
+PHP_FUNCTION(enchant_dict_is_added)
{
zval *dict;
char *word;
@@ -851,7 +855,7 @@
PHP_ENCHANT_GET_DICT;
- RETURN_BOOL(enchant_dict_is_in_session(pdict->pdict, word, wordlen));
+ RETURN_BOOL(enchant_dict_is_added(pdict->pdict, word, wordlen));
}
/* }}} */
@@ -884,7 +888,7 @@
{
zval *dict;
enchant_dict *pdict;
- char *msg;
+ const char *msg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &dict) == FAILURE) {
RETURN_FALSE;
diff -ur php-7.4.26.orig/ext/enchant/php_enchant.h php-7.4.26/ext/enchant/php_enchant.h
--- php-7.4.26.orig/ext/enchant/php_enchant.h 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/php_enchant.h 2021-12-14 10:38:53.318024515 +0200
@@ -53,9 +53,9 @@
PHP_FUNCTION(enchant_dict_check);
PHP_FUNCTION(enchant_dict_suggest);
-PHP_FUNCTION(enchant_dict_add_to_personal);
+PHP_FUNCTION(enchant_dict_add);
PHP_FUNCTION(enchant_dict_add_to_session);
-PHP_FUNCTION(enchant_dict_is_in_session);
+PHP_FUNCTION(enchant_dict_is_added);
PHP_FUNCTION(enchant_dict_store_replacement);
PHP_FUNCTION(enchant_dict_get_error);
PHP_FUNCTION(enchant_dict_describe);
diff -ur php-7.4.26.orig/ext/enchant/tests/broker_free_02.phpt php-7.4.26/ext/enchant/tests/broker_free_02.phpt
--- php-7.4.26.orig/ext/enchant/tests/broker_free_02.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/broker_free_02.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -21,7 +21,7 @@
if ($requestDict) {
echo("OK\n");
for($x=0;$x<count($newWord);$x++) {
- $AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord[$x]);
+ $AddtoPersonalDict = enchant_dict_add($requestDict,$newWord[$x]);
}
if (NULL === $AddtoPersonalDict) {
diff -ur php-7.4.26.orig/ext/enchant/tests/broker_free_dict.phpt php-7.4.26/ext/enchant/tests/broker_free_dict.phpt
--- php-7.4.26.orig/ext/enchant/tests/broker_free_dict.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/broker_free_dict.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -19,7 +19,7 @@
if ($requestDict) {
echo("OK\n");
- $AddtoPersonalDict = enchant_dict_add_to_personal($requestDict, $newWord);
+ $AddtoPersonalDict = enchant_dict_add($requestDict, $newWord);
if (NULL === $AddtoPersonalDict) {
var_dump($AddtoPersonalDict);
diff -ur php-7.4.26.orig/ext/enchant/tests/bug53070.phpt php-7.4.26/ext/enchant/tests/bug53070.phpt
--- php-7.4.26.orig/ext/enchant/tests/bug53070.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/bug53070.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -4,6 +4,7 @@
<?php
if(!extension_loaded('enchant')) die('skip, enchant not loader');
if (!is_resource(enchant_broker_init())) {die("skip, resource dont load\n");}
+if (defined("LIBENCHANT_VERSION") && version_compare(LIBENCHANT_VERSION, "2", ">")) die('skip libenchant v1 only');
?>
--FILE--
<?php
@@ -12,8 +13,12 @@
var_dump(enchant_broker_get_dict_path($broker, ENCHANT_ISPELL));
?>
--EXPECTF--
+Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s
+
Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d
bool(false)
+Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s
+
Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d
bool(false)
diff -ur php-7.4.26.orig/ext/enchant/tests/dict_add_to_personal.phpt php-7.4.26/ext/enchant/tests/dict_add_to_personal.phpt
--- php-7.4.26.orig/ext/enchant/tests/dict_add_to_personal.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/dict_add_to_personal.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -1,5 +1,5 @@
--TEST--
-enchant_dict_add_to_personal() function
+enchant_dict_add() function
--CREDITS--
marcosptf - <[email protected]>
--SKIPIF--
@@ -20,7 +20,7 @@
if ($requestDict) {
echo("OK\n");
- $AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord);
+ $AddtoPersonalDict = enchant_dict_add($requestDict,$newWord);
if (NULL === $AddtoPersonalDict) {
var_dump($AddtoPersonalDict);
diff -ur php-7.4.26.orig/ext/enchant/tests/dict_check.phpt php-7.4.26/ext/enchant/tests/dict_check.phpt
--- php-7.4.26.orig/ext/enchant/tests/dict_check.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/dict_check.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -20,7 +20,7 @@
if ($requestDict) {
echo("OK\n");
- enchant_dict_add_to_personal($requestDict, $newWord);
+ enchant_dict_add($requestDict, $newWord);
if (enchant_dict_check($requestDict, $newWord)) {
echo("OK\n");
diff -ur php-7.4.26.orig/ext/enchant/tests/dict_is_in_session.phpt php-7.4.26/ext/enchant/tests/dict_is_in_session.phpt
--- php-7.4.26.orig/ext/enchant/tests/dict_is_in_session.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/dict_is_in_session.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -20,10 +20,10 @@
if ($requestDict) {
echo("OK\n");
- $AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord);
+ $AddtoPersonalDict = enchant_dict_add($requestDict,$newWord);
if (NULL === $AddtoPersonalDict) {
- var_dump(enchant_dict_is_in_session($requestDict,$newWord));
+ var_dump(enchant_dict_is_added($requestDict,$newWord));
} else {
echo("dict add to personal failed\n");
}
diff -ur php-7.4.26.orig/ext/enchant/tests/enchant_broker_set_dict_path.phpt php-7.4.26/ext/enchant/tests/enchant_broker_set_dict_path.phpt
--- php-7.4.26.orig/ext/enchant/tests/enchant_broker_set_dict_path.phpt 2021-11-16 17:31:31.000000000 +0200
+++ php-7.4.26/ext/enchant/tests/enchant_broker_set_dict_path.phpt 2021-12-14 10:38:53.318024515 +0200
@@ -7,7 +7,8 @@
<?php
if(!extension_loaded('enchant')) die('skip, enchant not loader');
if (!is_resource(enchant_broker_init())) {die("skip, resource dont load\n");}
-if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, dont has dictionary install in this machine! \n");}
+if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");}
+if (defined("LIBENCHANT_VERSION") && version_compare(LIBENCHANT_VERSION, "2", ">")) die('skip libenchant v1 only');
?>
--FILE--
<?php
@@ -46,8 +47,16 @@
echo("broker is not a resource; failed; \n");
}
?>
---EXPECT--
+--EXPECTF--
OK
+
+Deprecated: Function enchant_broker_set_dict_path() is deprecated in %s
OK
+
+Deprecated: Function enchant_broker_set_dict_path() is deprecated in %s
OK
+
+Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s
+
+Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s
OK