13
13
| [email protected] so we can mail you a copy immediately. |
14
14
+----------------------------------------------------------------------+
15
15
| Author: Pierre-Alain Joye <[email protected] > |
16
+ | Ilia Alshanetsky <[email protected] > |
16
17
+----------------------------------------------------------------------+
17
18
18
19
$Id$
@@ -81,6 +82,7 @@ function_entry enchant_functions[] = {
81
82
PHP_FE (enchant_dict_store_replacement , NULL )
82
83
PHP_FE (enchant_dict_get_error , NULL )
83
84
PHP_FE (enchant_dict_describe , NULL )
85
+ PHP_FE (enchant_dict_quick_check , third_arg_force_ref )
84
86
85
87
{NULL , NULL , NULL } /* Must be the last line in enchant_functions[] */
86
88
};
@@ -496,8 +498,47 @@ PHP_FUNCTION(enchant_broker_describe)
496
498
}
497
499
/* }}} */
498
500
501
+ PHP_FUNCTION (enchant_dict_quick_check )
502
+ {
503
+ zval * dict , * sugg = NULL ;
504
+ char * word ;
505
+ int wordlen ;
506
+ enchant_dict * pdict ;
507
+
508
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rs|z/" , & dict , & word , & wordlen , & sugg ) == FAILURE ) {
509
+ RETURN_FALSE ;
510
+ }
511
+
512
+ if (sugg ) {
513
+ zval_dtor (sugg );
514
+ }
515
+
516
+ PHP_ENCHANT_GET_DICT ;
517
+
518
+ if (enchant_dict_check (pdict -> pdict , word , wordlen ) > 0 ) {
519
+ if (!sugg && ZEND_NUM_ARGS () == 2 ) {
520
+ RETURN_FALSE ;
521
+ }
522
+
523
+ int n_sugg ;
524
+ char * * suggs ;
525
+
526
+ array_init (sugg );
527
+
528
+ suggs = enchant_dict_suggest (pdict -> pdict , word , wordlen , & n_sugg );
529
+ if (suggs && n_sugg ) {
530
+ int i ;
531
+ for (i = 0 ; i < n_sugg ; i ++ ) {
532
+ add_next_index_string (sugg , suggs [i ], 1 );
533
+ }
534
+ }
535
+ RETURN_FALSE ;
536
+ }
537
+ RETURN_TRUE ;
538
+ }
539
+
499
540
/* {{{ proto long enchant_dict_check(resource broker)
500
- 0 if the word is correctly spelled, positive if not, negative if error */
541
+ If the word is correctly spelled return true, otherwise return false */
501
542
PHP_FUNCTION (enchant_dict_check )
502
543
{
503
544
zval * dict ;
@@ -511,7 +552,7 @@ PHP_FUNCTION(enchant_dict_check)
511
552
512
553
PHP_ENCHANT_GET_DICT ;
513
554
514
- RETURN_LONG (( long ) enchant_dict_check (pdict -> pdict , word , wordlen ));
555
+ RETURN_BOOL (! enchant_dict_check (pdict -> pdict , word , wordlen ));
515
556
}
516
557
/* }}} */
517
558
0 commit comments