diff options
author | Dom Lachowicz <domlachowicz@gmail.com> | 2004-04-21 01:57:30 +0000 |
---|---|---|
committer | Dom Lachowicz <domlachowicz@gmail.com> | 2004-04-21 01:57:30 +0000 |
commit | 1875ea74d2f05c528ca206e8e1e9b5448202ae44 (patch) | |
tree | 8b197673a453e3b4a0813fbd39804e50b5c496a5 | |
parent | d99c550943cb2ed544ac7f97984ab384b493a321 (diff) | |
download | enchant-1875ea74d2f05c528ca206e8e1e9b5448202ae44.tar.gz |
method for listing dictionaries. not fully implemented or tested
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@20929 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | src/aspell/aspell_provider.c | 60 | ||||
-rw-r--r-- | src/hspell/hspell_provider.c | 22 | ||||
-rw-r--r-- | src/ispell/ispell_checker.cpp | 31 | ||||
-rw-r--r-- | src/uspell/uspell_provider.cpp | 29 |
5 files changed, 130 insertions, 15 deletions
diff --git a/configure.in b/configure.in index 52912d2..e4da681 100644 --- a/configure.in +++ b/configure.in @@ -138,7 +138,6 @@ if test "x$check_aspell" != "xno"; then AC_CHECK_PROG(HAVE_ASPELL, aspell, yes, no) if test "x$HAVE_ASPELL" = "xyes"; then - #perl -e 'if (<STDIN> =~ /(.*) Aspell 0\.(.*)\.(.*)/) { print "$2\n"; } else { print "0\n"; }'`; AC_MSG_CHECKING([For Aspell >= 0.50.0]) aspell_major=`aspell -v | awk -F. '{print $4;}'` if test "$aspell_major" -ge "50"; then @@ -153,7 +152,7 @@ if test "x$check_aspell" != "xno"; then fi fi - if test "x$ASPELL_DICT_DIR" = "x"; then + if test "x$ASPELL_CFLAGS" = "x"; then AC_MSG_WARN([Didn't find aspell >= 0.50.0 and no explicit path aspell specified. Guessing at $aspell_prefix]) ASPELL_LIBS="-L$aspell_prefix/lib -laspell" ASPELL_CFLAGS="-DASPELL_DICT_DIR='\"$aspell_prefix/lib/aspell\"'" diff --git a/src/aspell/aspell_provider.c b/src/aspell/aspell_provider.c index 171d13d..a03efab 100644 --- a/src/aspell/aspell_provider.c +++ b/src/aspell/aspell_provider.c @@ -204,7 +204,7 @@ aspell_provider_dictionary_exists (struct str_enchant_provider * me, /* hack for a quick existence test */ - ext = g_strdup_printf ("%s.multi", tag); + ext = g_strdup_printf ("%s.dat", tag); file = g_build_filename (ASPELL_DICT_DIR, ext, NULL); if (g_file_test (file, G_FILE_TEST_EXISTS)) exists = 1; @@ -212,7 +212,7 @@ aspell_provider_dictionary_exists (struct str_enchant_provider * me, g_free (ext); if (strlen (tag) > 2 && tag[2] == '_') { - ext = g_strdup_printf ("%c%c.multi", tag[0], tag[1]); + ext = g_strdup_printf ("%c%c.dat", tag[0], tag[1]); file = g_build_filename (ASPELL_DICT_DIR, ext, NULL); if (g_file_test (file, G_FILE_TEST_EXISTS)) exists = 1; @@ -232,21 +232,57 @@ aspell_provider_dictionary_exists (struct str_enchant_provider * me, return exists; } -#if 0 - AspellDictInfoEnumeration * dels; - AspellDictInfoList * dlist; - const AspellDictInfo * entry; +static char ** +aspell_provider_list_dicts (EnchantProvider * me, + size_t * out_n_dicts) +{ +#if ASPELL_0_50_0 + PspellConfig * spell_config; + AspellDictInfoList * dlist; + char ** out_list = NULL; + + spell_config = new_pspell_config (); - dlist = get_aspell_dict_info_list(m_spellConfig); - dels = aspell_dict_info_list_elements(dlist); + dlist = get_aspell_dict_info_list (spell_config); + *out_n_dicts = aspell_dict_info_list_size (dlist); - while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) { - dict_choice->Append(entry->name); - } + if (*out_n_dicts) { + AspellDictInfoEnumeration * dels; + size_t i; + + out_list = g_new0 (char *, *out_n_dicts + 1); + dels = aspell_dict_info_list_elements (dlist); + + for (i = 0; i < *out_n_dicts; i++) { + const AspellDictInfo * entry; + + entry = aspell_dict_info_enumeration_next (dels); + out_list[i] = g_strdup (entry->code); + } + + delete_aspell_dict_info_enumeration (dels); + } + + delete_pspell_config (spell_config); + + return out_list; +#else - delete_aspell_dict_info_enumeration(dels); +#ifdef __GNUC__ +#warning "You're using an ancient aspell. aspell_provider_list_dicts() is not implemented." #endif + *out_n_dicts = 0; + return NULL; +#endif +} + +static void +aspell_provider_free_string_list (EnchantProvider * me, char **str_list) +{ + g_strfreev (str_list); +} + static void aspell_provider_dispose (EnchantProvider * me) { diff --git a/src/hspell/hspell_provider.c b/src/hspell/hspell_provider.c index a4f9dc9..ec282b0 100644 --- a/src/hspell/hspell_provider.c +++ b/src/hspell/hspell_provider.c @@ -246,6 +246,28 @@ hspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) g_free (dict); } +static char ** +hspell_provider_list_dicts (EnchantProvider * me, + size_t * out_n_dicts) +{ + char ** out_list; + + *out_n_dicts = 2; + + out_list = g_new0 (char *, 3); + + out_list[0] = g_strdup ("he_IL"); + out_list[1] = g_strdup ("he"); + + return out_list; +} + +static void +hspell_provider_free_string_list (EnchantProvider * me, char **str_list) +{ + g_strfreev (str_list); +} + static void hspell_provider_dispose (EnchantProvider * me) { diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp index 44c49ac..9121723 100644 --- a/src/ispell/ispell_checker.cpp +++ b/src/ispell/ispell_checker.cpp @@ -619,7 +619,7 @@ ispell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) } static int -ispell_provider_dictionary_exists (struct str_enchant_provider * me, +ispell_provider_dictionary_exists (EnchantProvider * me, const char *const tag) { std::vector <std::string> names; @@ -646,6 +646,35 @@ ispell_provider_dictionary_exists (struct str_enchant_provider * me, return 0; } +static char ** +ispell_provider_list_dictionaries (EnchantProvider * me, + size_t * out_n_dicts) +{ + size_t i, nb; + + nb = 0; + for (i = 0; i < size_ispell_map; i++) + if (ispell_provider_dictionary_exists (me, ispell_map[i].lang)) + nb++; + + *out_n_dicts = nb; + if(nb == 0) + return NULL; + + char ** out_dicts = g_new (char *, nb + 1); + for (i = 0; i < size_ispell_map; i++) + if (ispell_provider_dictionary_exists (me, ispell_map[i].lang)) + out_dicts[i] = g_strdup (ispell_map[i].lang); + + return out_dicts; +} + +static void +ispell_provider_free_string_list (EnchantProvider * me, char **str_list) +{ + g_strfreev (str_list); +} + static void ispell_provider_dispose (EnchantProvider * me) { diff --git a/src/uspell/uspell_provider.cpp b/src/uspell/uspell_provider.cpp index 53caccd..4cffeb8 100644 --- a/src/uspell/uspell_provider.cpp +++ b/src/uspell/uspell_provider.cpp @@ -414,6 +414,35 @@ uspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) g_free (dict); } +static char ** +uspell_provider_list_dictionaries (EnchantProvider * me, + size_t * out_n_dicts) +{ + size_t i, nb; + + nb = 0; + for (i = 0; i < n_mappings; i++) + if (uspell_provider_dictionary_exists (me, mapping[i].language_tag)) + nb++; + + *out_n_dicts = nb; + if(nb == 0) + return NULL; + + char ** out_dicts = g_new (char *, nb + 1); + for (i = 0; i < n_mappings; i++) + if (uspell_provider_dictionary_exists (me, mapping[i].language_tag)) + out_dicts[i] = g_strdup (mapping[i].language_tag); + + return out_dicts; +} + +static void +uspell_provider_free_string_list (EnchantProvider * me, char **str_list) +{ + g_strfreev (str_list); +} + static void uspell_provider_dispose (EnchantProvider * me) { |