Skip to content

Commit e9274de

Browse files
committed
Add support for pspell
1 parent 08c4b47 commit e9274de

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

ext/pspell/pspell.c

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -213,33 +213,37 @@ zend_module_entry pspell_module_entry = {
213213
ZEND_GET_MODULE(pspell)
214214
#endif
215215

216-
static void php_pspell_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
216+
static void php_pspell_close(zend_resource *rsrc TSRMLS_DC)
217217
{
218218
PspellManager *manager = (PspellManager *)rsrc->ptr;
219219

220220
delete_pspell_manager(manager);
221221
}
222222

223-
static void php_pspell_close_config(zend_rsrc_list_entry *rsrc TSRMLS_DC)
223+
static void php_pspell_close_config(zend_resource *rsrc TSRMLS_DC)
224224
{
225225
PspellConfig *config = (PspellConfig *)rsrc->ptr;
226226

227227
delete_pspell_config(config);
228228
}
229229

230-
#define PSPELL_FETCH_CONFIG \
231-
config = (PspellConfig *) zend_list_find(conf, &type); \
232-
if (config == NULL || type != le_pspell_config) { \
233-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a PSPELL config index", conf); \
234-
RETURN_FALSE; \
235-
} \
236-
237-
#define PSPELL_FETCH_MANAGER \
238-
manager = (PspellManager *) zend_list_find(scin, &type); \
239-
if (!manager || type != le_pspell) { \
240-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a PSPELL result index", scin); \
241-
RETURN_FALSE; \
242-
} \
230+
#define PSPELL_FETCH_CONFIG do { \
231+
zval *res = zend_hash_index_find(&EG(regular_list), conf); \
232+
if (res == NULL || Z_RES_P(res)->type != le_pspell_config) { \
233+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a PSPELL config index", conf); \
234+
RETURN_FALSE; \
235+
} \
236+
config = (PspellConfig *)Z_RES_P(res)->ptr; \
237+
} while (0)
238+
239+
#define PSPELL_FETCH_MANAGER do { \
240+
zval *res = zend_hash_index_find(&EG(regular_list), scin); \
241+
if (res == NULL || Z_RES_P(res)->type != le_pspell) { \
242+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a PSPELL result index", scin); \
243+
RETURN_FALSE; \
244+
} \
245+
manager = (PspellManager *)Z_RES_P(res)->ptr; \
246+
} while (0);
243247

244248
/* {{{ PHP_MINIT_FUNCTION
245249
*/
@@ -263,7 +267,7 @@ static PHP_FUNCTION(pspell_new)
263267
int language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
264268
long mode = 0L, speed = 0L;
265269
int argc = ZEND_NUM_ARGS();
266-
int ind;
270+
zval *ind;
267271

268272
#ifdef PHP_WIN32
269273
TCHAR aspell_dir[200];
@@ -348,7 +352,7 @@ static PHP_FUNCTION(pspell_new)
348352

349353
manager = to_pspell_manager(ret);
350354
ind = zend_list_insert(manager, le_pspell TSRMLS_CC);
351-
RETURN_LONG(ind);
355+
RETURN_LONG(Z_RES_HANDLE_P(ind));
352356
}
353357
/* }}} */
354358

@@ -360,7 +364,7 @@ static PHP_FUNCTION(pspell_new_personal)
360364
int personal_len, language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
361365
long mode = 0L, speed = 0L;
362366
int argc = ZEND_NUM_ARGS();
363-
int ind;
367+
zval *ind;
364368

365369
#ifdef PHP_WIN32
366370
TCHAR aspell_dir[200];
@@ -453,16 +457,17 @@ static PHP_FUNCTION(pspell_new_personal)
453457

454458
manager = to_pspell_manager(ret);
455459
ind = zend_list_insert(manager, le_pspell TSRMLS_CC);
456-
RETURN_LONG(ind);
460+
RETURN_LONG(Z_RES_HANDLE_P(ind));
457461
}
458462
/* }}} */
459463

460464
/* {{{ proto int pspell_new_config(int config)
461465
Load a dictionary based on the given config */
462466
static PHP_FUNCTION(pspell_new_config)
463467
{
464-
int type, ind;
468+
int type;
465469
long conf;
470+
zval *ind;
466471
PspellCanHaveError *ret;
467472
PspellManager *manager;
468473
PspellConfig *config;
@@ -483,7 +488,7 @@ static PHP_FUNCTION(pspell_new_config)
483488

484489
manager = to_pspell_manager(ret);
485490
ind = zend_list_insert(manager, le_pspell TSRMLS_CC);
486-
RETURN_LONG(ind);
491+
RETURN_LONG(Z_RES_HANDLE_P(ind));
487492
}
488493
/* }}} */
489494

@@ -685,7 +690,7 @@ static PHP_FUNCTION(pspell_config_create)
685690
{
686691
char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
687692
int language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
688-
int ind;
693+
zval *ind;
689694
PspellConfig *config;
690695

691696
#ifdef PHP_WIN32
@@ -743,7 +748,7 @@ static PHP_FUNCTION(pspell_config_create)
743748
pspell_config_replace(config, "save-repl", "false");
744749

745750
ind = zend_list_insert(config, le_pspell_config TSRMLS_CC);
746-
RETURN_LONG(ind);
751+
RETURN_LONG(Z_RES_HANDLE_P(ind));
747752
}
748753
/* }}} */
749754

0 commit comments

Comments
 (0)