Skip to content

Commit

Permalink
use a for..break because we can't depend on count
Browse files Browse the repository at this point in the history
as commented in http://aspell.net/sf-issue-files/11b76e92/632d/test.c
` aspell_dict_info_list_size(dlist)` will allways return `0` for some
reason. execute `aspell_dict_info_enumeration_next(dels)` until it
returns nil.
  • Loading branch information
Stijn Van Campenhout committed Jul 1, 2020
1 parent ebca0f9 commit f14a7da
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions aspell.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,24 @@ type Dict struct {

// Dicts returns the list of available aspell dictionaries.
func Dicts() []Dict {
var result []Dict
config := C.new_aspell_config()
dlist := C.get_aspell_dict_info_list(config)
C.delete_aspell_config(config)

count := int(C.aspell_dict_info_list_size(dlist))
result := make([]Dict, count)

dels := C.aspell_dict_info_list_elements(dlist)
for i := 0; i < count; i++ {
for {
entry := C.aspell_dict_info_enumeration_next(dels)
if entry == nil {
break
}
result[i] = Dict{
result = append(result, Dict{
name: C.GoString(entry.name),
code: C.GoString(entry.code),
jargon: C.GoString(entry.jargon),
size: C.GoString(entry.size_str),
module: C.GoString(entry.module.name),
}
})
}
C.delete_aspell_dict_info_enumeration(dels)

Expand Down

0 comments on commit f14a7da

Please sign in to comment.