Files
CMake/Tests/FindASPELL/Test/main.c
Peter Kokot dd2edc3497 FindASPELL: Add components and imported targets
Components are added in a backward-compatible way:

* ASPELL component - adds the ASPELL::ASPELL imported target
* Executable component - adds the ASPELL::Executable imported target

If components are not specified in find_package() call, module, by
default, searches for both components and provides backward
compatibility with the find_package(ASPELL) usage via ASPELL_LIBRARIES,
ASPELL_INCLUDE_DIR, and ASPELL_EXECUTABLE variables.

The ASPELL_DEFINITIONS variable description removed from the
documentation as it was never defined by this module.

Additionally added a Pspell interface check (pspell.h header file) if
Aspell library provides it. It is checked separately because it might
be located in a subdirectory of pspell/pspell.h and code includes it as
`<pspell.h>`. Some distributions package pspell.h as part of the
libpspell development package and install also libaspell development
package as a dependency for BC.

Added also ASPELL_VERSION variable in case aspell executable can
determine it.

Issue: #26811
2025-04-01 05:25:25 +02:00

28 lines
692 B
C

#include <aspell.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
AspellConfig* config = new_aspell_config();
assert(config && "Failed creating AspellConfig");
AspellCanHaveError* result = new_aspell_speller(config);
delete_aspell_config(config);
AspellSpeller* speller = to_aspell_speller(result);
assert(aspell_error_number(result) == 0 && "Failed creating AspellSpeller");
char const* word = "conjunction";
if (aspell_speller_check(speller, word, (int)strlen(word))) {
printf("Word \"%s\" is spelled correctly\n", word);
} else {
printf("Word \"%s\" is misspelled\n", word);
}
delete_aspell_speller(speller);
return 0;
}