Skip to content

Commit fda58f8

Browse files
committed
Add wide versions of suggestions_words.
1 parent 4e3ad79 commit fda58f8

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

auto/MkSrc/CcHelper.pm

+2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ sub make_wide_version ( $ \@ $ ; \% ) {
108108
109109
#ifdef __cplusplus
110110
# define aspell_cast_(type, expr) (static_cast<type>(expr))
111+
# define aspell_rcast_(type, expr) (reinterpret_cast<type>(expr))
111112
# define aspell_cast_from_wide_(str) (static_cast<const void *>(str))
112113
#else
113114
# define aspell_cast_(type, expr) ((type)(expr))
115+
# define aspell_rcast_(type, expr) ((type)(expr))
114116
# define aspell_cast_from_wide_(str) ((const char *)(str))
115117
#endif
116118
---

auto/mk-src.in

+10-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ class: speller
730730
/
731731
suggestions
732732
encoded string: word
733-
void pointer: unusued
733+
void pointer: unused
734734

735735
method: store replacement
736736

@@ -982,10 +982,19 @@ group: suggestions
982982
class: suggestions
983983
/
984984
method: words
985+
cc extra =>
986+
\#define aspell_suggestions_words_w(type, ths, len) \\
987+
aspell_rcast_(const type * *, aspell_suggestions_words(ths, len))
985988
/
986989
string array
987990
array size pointer: len
988991

992+
# method: words wide
993+
# c impl =>
994+
# return reinterpret_cast<const void * *>(ths->words(len));
995+
# const void pointer array
996+
# array size pointer: len
997+
989998
method: normalized scores
990999
desc => Returns the normalized scores. The values are between 0 and 1 inclusive
9911000
where higher numbers indicate a better match. The exact values may not

test/wide_test_valid.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,18 @@ int main() {
3737
AspellStringEnumeration * elements = aspell_word_list_elements(suggestions);
3838
const uint16_t * word = aspell_string_enumeration_next_w(uint16_t, elements);
3939
if (memcmp(word, test_word, sizeof(test_incorrect)) != 0) {
40-
fprintf(stderr, "%s", "fail: first suggesion is not what is expected\n");
40+
fprintf(stderr, "%s", "fail: first suggesion is not what is expected (suggest)\n");
4141
fail = 1;
4242
}
4343
delete_aspell_string_enumeration(elements);
44+
45+
AspellSuggestions * sugs = aspell_speller_suggestions_w(spell_checker, test_incorrect, -1, NULL);
46+
unsigned len;
47+
const uint16_t * * words = aspell_suggestions_words_w(uint16_t, sugs, &len);
48+
if (len < 1 || memcmp(words[0], test_word, sizeof(test_incorrect)) != 0) {
49+
fprintf(stderr, "%s", "fail: first suggesion is not what is expected (suggestions)\n");
50+
fail = 1;
51+
}
4452

4553
possible_err = new_aspell_document_checker(spell_checker);
4654
if (aspell_error(possible_err) != 0) {

0 commit comments

Comments
 (0)