diff options
author | Reuben Thomas <rrt@sc3d.org> | 2017-02-21 12:09:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 12:09:35 +0000 |
commit | b90435e9f241dde68f2e615135d6a7f3e1587d44 (patch) | |
tree | 906bd12f6f8919e6da5dbad3c7fbaf62371f3523 /src | |
parent | 3f89992378adc4c5ce4365a75d415c8e9abd116c (diff) | |
parent | 936827fd7152fe4d01449eeb214d828d545102f8 (diff) | |
download | enchant-b90435e9f241dde68f2e615135d6a7f3e1587d44.tar.gz |
Merge pull request #91 from rrthomas/master
Overhaul compiler warning flags
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/aspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/aspell/aspell_provider.c | 15 | ||||
-rw-r--r-- | src/enchant-lsmod.c | 11 | ||||
-rw-r--r-- | src/enchant.c | 23 | ||||
-rw-r--r-- | src/hspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/hspell/hspell_provider.c | 13 | ||||
-rw-r--r-- | src/ispell/Makefile.am | 2 | ||||
-rw-r--r-- | src/ispell/ispell_checker.cpp | 94 | ||||
-rw-r--r-- | src/ispell/ispell_checker.h | 2 | ||||
-rw-r--r-- | src/myspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/myspell/myspell_checker.cpp | 67 | ||||
-rw-r--r-- | src/pwl.c | 10 | ||||
-rw-r--r-- | src/uspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/voikko/Makefile.am | 2 | ||||
-rw-r--r-- | src/voikko/voikko_provider.c | 20 | ||||
-rw-r--r-- | src/zemberek/Makefile.am | 2 |
17 files changed, 163 insertions, 108 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index fb8f0c5..0d2f32b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS=. aspell ispell uspell myspell hspell applespell voikko zemberek -AM_CPPFLAGS=-I$(top_srcdir) $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib $(ENCHANT_CFLAGS) $(WARN_CFLAGS) lib_LTLIBRARIES = libenchant.la diff --git a/src/aspell/Makefile.am b/src/aspell/Makefile.am index 18bfcf1..5e54d1d 100644 --- a/src/aspell/Makefile.am +++ b/src/aspell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) @ASPELL_INC@ -D_ENCHANT_BUILD=1 @ASPELL_CFLAGS@ +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(WARN_CFLAGS) @ASPELL_INC@ -D_ENCHANT_BUILD=1 @ASPELL_CFLAGS@ aspell_LTLIBRARIES = $(target_lib) aspelldir= $(libdir)/enchant diff --git a/src/aspell/aspell_provider.c b/src/aspell/aspell_provider.c index 9a448b9..03bd1b9 100644 --- a/src/aspell/aspell_provider.c +++ b/src/aspell/aspell_provider.c @@ -28,6 +28,8 @@ * do so, delete this exception statement from your version. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,6 +39,7 @@ #include "enchant.h" #include "enchant-provider.h" +#include "unused-parameter.h" ENCHANT_PLUGIN_DECLARE("Aspell") @@ -150,7 +153,7 @@ aspell_dict_store_replacement (EnchantDict * me, } static EnchantDict * -aspell_provider_request_dict (EnchantProvider * me, const char *const tag) +aspell_provider_request_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, const char *const tag) { EnchantDict *dict; AspellSpeller *manager; @@ -183,7 +186,7 @@ aspell_provider_request_dict (EnchantProvider * me, const char *const tag) } static void -aspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) +aspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) { AspellSpeller *manager; @@ -194,7 +197,7 @@ aspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) } static char ** -aspell_provider_list_dicts (EnchantProvider * me, +aspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, size_t * out_n_dicts) { AspellConfig * spell_config; @@ -235,7 +238,7 @@ aspell_provider_list_dicts (EnchantProvider * me, } static void -aspell_provider_free_string_list (EnchantProvider * me, char **str_list) +aspell_provider_free_string_list (EnchantProvider * me _GL_UNUSED_PARAMETER, char **str_list) { g_strfreev (str_list); } @@ -247,13 +250,13 @@ aspell_provider_dispose (EnchantProvider * me) } static const char * -aspell_provider_identify (EnchantProvider * me) +aspell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "aspell"; } static const char * -aspell_provider_describe (EnchantProvider * me) +aspell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "Aspell Provider"; } diff --git a/src/enchant-lsmod.c b/src/enchant-lsmod.c index 6ed3f4f..05d56bc 100644 --- a/src/enchant-lsmod.c +++ b/src/enchant-lsmod.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "unused-parameter.h" #include "enchant.h" #include "enchant-provider.h" @@ -41,8 +42,8 @@ static void describe_dict (const char * const lang_tag, const char * const provider_name, - const char * const provider_desc, - const char * const provider_file, + const char * const provider_desc _GL_UNUSED_PARAMETER, + const char * const provider_file _GL_UNUSED_PARAMETER, void * user_data) { FILE * out = (FILE *)user_data; @@ -52,7 +53,7 @@ describe_dict (const char * const lang_tag, static void enumerate_providers (const char * name, const char * desc, - const char * file, + const char * file _GL_UNUSED_PARAMETER, void * user_data) { FILE * out = (FILE *)user_data; @@ -62,8 +63,8 @@ enumerate_providers (const char * name, static void enumerate_dicts (const char * const lang_tag, const char * const provider_name, - const char * const provider_desc, - const char * const provider_file, + const char * const provider_desc _GL_UNUSED_PARAMETER, + const char * const provider_file _GL_UNUSED_PARAMETER, void * user_data) { FILE * out = (FILE *)user_data; diff --git a/src/enchant.c b/src/enchant.c index 9c59ba2..98756bc 100644 --- a/src/enchant.c +++ b/src/enchant.c @@ -28,6 +28,8 @@ * do so, delete this exception statement from your version. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -41,6 +43,7 @@ #include "enchant.h" #include "enchant-provider.h" #include "pwl.h" +#include "unused-parameter.h" #if defined(__APPLE__) && defined(__MACH__) #define ENCHANT_USER_PATH_EXTENSION "Library", "Application Support", "Enchant" @@ -314,7 +317,7 @@ enchant_ascii_strdown (gchar *str, /* returns TRUE if tag is valid * for requires alphanumeric ASCII or underscore */ -static int +static _GL_ATTRIBUTE_PURE int enchant_is_valid_dictionary_tag(const char * const tag) { const char * it; @@ -670,11 +673,7 @@ enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len) * returns the number of items in @suggs after merge is complete */ static int -enchant_dict_merge_suggestions(EnchantDict * dict, - char ** suggs, - size_t n_suggs, - char ** new_suggs, - size_t n_new_suggs) +enchant_dict_merge_suggestions(char ** suggs, size_t n_suggs, char ** new_suggs, size_t n_new_suggs) { size_t i, j; @@ -809,13 +808,11 @@ enchant_dict_suggest (EnchantDict * dict, const char *const word, suggs = g_new0 (char *, n_suggs + 1); /* Copy over suggestions from dict, if no dupes */ - n_suggs = enchant_dict_merge_suggestions(dict, - suggs, 0, + n_suggs = enchant_dict_merge_suggestions(suggs, 0, dict_suggs, n_dict_suggs); /* Copy over suggestions from pwl, if no dupes */ - n_suggs = enchant_dict_merge_suggestions(dict, - suggs, n_suggs, + n_suggs = enchant_dict_merge_suggestions(suggs, n_suggs, pwl_suggs, n_pwl_suggs); if(n_suggs == 0) { @@ -1179,7 +1176,7 @@ enchant_load_providers_in_dir (EnchantBroker * broker, const char *dir_name) { GModule *module = NULL; GDir *dir; - G_CONST_RETURN char *dir_entry; + const char *dir_entry; size_t entry_len, g_module_suffix_len; char * filename; @@ -1423,7 +1420,7 @@ enchant_dict_destroyed (gpointer data) } static void -enchant_provider_free (gpointer data, gpointer user_data) +enchant_provider_free (gpointer data, gpointer user_data _GL_UNUSED_PARAMETER) { EnchantProvider *provider; GModule *module; @@ -2088,7 +2085,7 @@ enchant_get_dirs_from_param (EnchantBroker * broker, const char * const param_na return _enchant_get_dirs_from_string (param_value); } -ENCHANT_MODULE_EXPORT(const char *) +ENCHANT_MODULE_EXPORT(const char *) _GL_ATTRIBUTE_CONST enchant_get_version (void) { return ENCHANT_VERSION_STRING; } diff --git a/src/hspell/Makefile.am b/src/hspell/Makefile.am index 28560c3..1d11782 100644 --- a/src/hspell/Makefile.am +++ b/src/hspell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) $(HSPELL_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(WARN_CFLAGS) $(HSPELL_CFLAGS) -D_ENCHANT_BUILD=1 hspell_LTLIBRARIES = $(target_lib) hspelldir= $(libdir)/enchant diff --git a/src/hspell/hspell_provider.c b/src/hspell/hspell_provider.c index 99e7287..bd52aff 100644 --- a/src/hspell/hspell_provider.c +++ b/src/hspell/hspell_provider.c @@ -29,6 +29,8 @@ * do so, delete this exception statement from your version. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,6 +40,7 @@ #include "enchant.h" #include "enchant-provider.h" +#include "unused-parameter.h" ENCHANT_PLUGIN_DECLARE ("Hspell") @@ -205,7 +208,7 @@ hspell_provider_request_dict (EnchantProvider * me, const char *const tag) } static void -hspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) +hspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) { struct dict_radix *hspell_dict; @@ -217,7 +220,7 @@ hspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) /* test for the existence of, then return $prefix/share/hspell/hebrew.wgz */ static char ** -hspell_provider_list_dicts (EnchantProvider * me, +hspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, size_t * out_n_dicts) { const char * dictionary_path; @@ -246,7 +249,7 @@ hspell_provider_dictionary_exists (struct str_enchant_provider * me, } static void -hspell_provider_free_string_list (EnchantProvider * me, char **str_list) +hspell_provider_free_string_list (EnchantProvider * me _GL_UNUSED_PARAMETER, char **str_list) { g_strfreev (str_list); } @@ -258,13 +261,13 @@ hspell_provider_dispose (EnchantProvider * me) } static const char * -hspell_provider_identify (EnchantProvider * me) +hspell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "hspell"; } static const char * -hspell_provider_describe (EnchantProvider * me) +hspell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "Hspell Provider"; } diff --git a/src/ispell/Makefile.am b/src/ispell/Makefile.am index da20b6d..b62649c 100644 --- a/src/ispell/Makefile.am +++ b/src/ispell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CXX_WARN_CFLAGS) $(ISPELL_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(WARN_CXXFLAGS) $(ISPELL_CFLAGS) -D_ENCHANT_BUILD=1 ispell_LTLIBRARIES = $(target_lib) ispelldir= $(libdir)/enchant diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp index fcc9dd4..41b9eb2 100644 --- a/src/ispell/ispell_checker.cpp +++ b/src/ispell/ispell_checker.cpp @@ -1,4 +1,6 @@ /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -10,6 +12,7 @@ #include "sp_spell.h" #include "ispell_checker.h" #include "enchant.h" +#include "unused-parameter.h" #ifndef ENCHANT_ISPELL_HOME_DIR #define ENCHANT_ISPELL_HOME_DIR "ispell" @@ -67,6 +70,12 @@ static const IspellMap ispell_map [] = { static const size_t size_ispell_map = G_N_ELEMENTS(ispell_map); +static void +ispell_checker_free_helper (gpointer p, gpointer user _GL_UNUSED_PARAMETER) +{ + g_free (p); +} + static bool g_iconv_is_valid(GIConv i) { @@ -99,16 +108,39 @@ ISpellChecker::ISpellChecker(EnchantBroker * broker) m_nd(NULL), m_so(NULL), m_se(NULL), + m_sg(0), m_ti(NULL), m_te(NULL), + m_li(0), + m_co(0), + m_numhits(0), m_hashstrings(NULL), + m_hashheader({}), m_hashtbl(NULL), + m_hashsize(0), + m_aflag(0), + m_cflag(0), + m_lflag(0), + m_incfileflag(0), + m_nodictflag(0), + m_uerasechar(0), + m_ukillchar(0), + m_laststringch(0U), + m_defdupchar(0), + m_numpflags(0), + m_numsflags(0), m_pflaglist(NULL), m_sflaglist(NULL), m_chartypes(NULL), m_infile(NULL), m_outfile(NULL), m_askfilename(NULL), + m_changes(0), + m_readonly(0), + m_quit(0), + m_pcount(0), + m_maxposslen(0), + m_easypossibilities(0), m_Trynum(0), m_translate_in(G_ICONV_INVALID), m_translate_out(G_ICONV_INVALID) @@ -168,7 +200,7 @@ ISpellChecker::checkWord(const char * const utf8Word, size_t length) len_out = sizeof( szWord ) - 1; result = g_iconv(m_translate_in, &In, &len_in, &Out, &len_out); g_free(normalizedWord); - if ((size_t)-1 == result) + if (static_cast<size_t>(-1) == result) return false; *Out = '\0'; } @@ -215,7 +247,7 @@ ISpellChecker::suggestWord(const char * const utf8Word, size_t length, len_out = sizeof( word8 ) - 1; result = g_iconv(m_translate_in, &In, &len_in, &Out, &len_out); g_free(normalizedWord); - if ((size_t)-1 == result) + if (static_cast<size_t>(-1) == result) return NULL; *Out = '\0'; } @@ -250,11 +282,11 @@ ISpellChecker::suggestWord(const char * const utf8Word, size_t length, size_t len_in, len_out; char *In = m_possibilities[c]; - char *Out = reinterpret_cast<char *>(utf8Sugg); + char *Out = utf8Sugg; len_in = l; len_out = INPUTWORDLEN + MAXAFFIXLEN; - if ((size_t)-1 == g_iconv(m_translate_out, &In, &len_in, &Out, &len_out)) { + if (static_cast<size_t>(-1) == g_iconv(m_translate_out, &In, &len_in, &Out, &len_out)) { *out_n_suggestions = c; return sugg_arr; } @@ -280,11 +312,11 @@ ispell_checker_get_dictionary_dirs (EnchantBroker * broker) for (iter = config_dirs; iter; iter = iter->next) { - dirs = g_slist_append (dirs, g_build_filename ((const gchar *)iter->data, - ENCHANT_ISPELL_HOME_DIR, NULL)); + dirs = g_slist_append (dirs, g_build_filename (static_cast<const gchar *>(iter->data), + ENCHANT_ISPELL_HOME_DIR, nullptr)); } - g_slist_foreach (config_dirs, (GFunc)g_free, NULL); + g_slist_foreach (config_dirs, ispell_checker_free_helper, nullptr); g_slist_free (config_dirs); } @@ -292,7 +324,7 @@ ispell_checker_get_dictionary_dirs (EnchantBroker * broker) char * enchant_prefix = enchant_get_prefix_dir(); if(enchant_prefix) { - char * ispell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "ispell", NULL); + char * ispell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "ispell", nullptr); g_free(enchant_prefix); dirs = g_slist_append (dirs, ispell_prefix); } @@ -308,10 +340,10 @@ ispell_checker_get_dictionary_dirs (EnchantBroker * broker) for (iter = config_dirs; iter; iter = iter->next) { - dirs = g_slist_append (dirs, g_strdup ((const gchar *)iter->data)); + dirs = g_slist_append (dirs, g_strdup (static_cast<const gchar *>(iter->data))); } - g_slist_foreach (config_dirs, (GFunc)g_free, NULL); + g_slist_foreach (config_dirs, ispell_checker_free_helper, nullptr); g_slist_free (config_dirs); } @@ -330,12 +362,12 @@ s_buildHashNames (std::vector<std::string> & names, EnchantBroker * broker, cons { char *tmp; - tmp = g_build_filename ((const gchar *)iter->data, dict, NULL); + tmp = g_build_filename (static_cast<const gchar *>(iter->data), dict, nullptr); names.push_back (tmp); g_free (tmp); } - g_slist_foreach (dirs, (GFunc)g_free, NULL); + g_slist_foreach (dirs, ispell_checker_free_helper, nullptr); g_slist_free (dirs); } @@ -371,7 +403,7 @@ ISpellChecker::loadDictionaryForLanguage ( const char * szLang ) for (size_t i = 0; i < size_ispell_map; i++) { - const IspellMap * mapping = (const IspellMap *)(&(ispell_map[i])); + const IspellMap * mapping = &(ispell_map[i]); if (!strcmp (szLang, mapping->lang)) { szFile = mapping->dict; @@ -389,14 +421,14 @@ ISpellChecker::loadDictionaryForLanguage ( const char * szLang ) return false; // one of the two above calls succeeded - setDictionaryEncoding (hashname, encoding); + setDictionaryEncoding (encoding); g_free (hashname); return true; } void -ISpellChecker::setDictionaryEncoding( const char * hashname, const char * encoding ) +ISpellChecker::setDictionaryEncoding( const char * encoding ) { /* Get Hash encoding from XML file. This should always work! */ try_autodetect_charset(encoding); @@ -405,7 +437,7 @@ ISpellChecker::setDictionaryEncoding( const char * hashname, const char * encodi { /* We still have to setup prefstringchar*/ prefstringchar = findfiletype("utf8", 1, deftflag < 0 ? &deftflag - : static_cast<int *>(NULL)); + : nullptr); if (prefstringchar < 0) { @@ -414,7 +446,7 @@ ISpellChecker::setDictionaryEncoding( const char * hashname, const char * encodi { sprintf(teststring, "latin%d", n1); prefstringchar = findfiletype(teststring, 1, - deftflag < 0 ? &deftflag : static_cast<int *>(NULL)); + deftflag < 0 ? &deftflag : nullptr); if (prefstringchar >= 0) break; } @@ -424,7 +456,7 @@ ISpellChecker::setDictionaryEncoding( const char * hashname, const char * encodi } /* Test for UTF-8 first */ - prefstringchar = findfiletype("utf8", 1, deftflag < 0 ? &deftflag : static_cast<int *>(NULL)); + prefstringchar = findfiletype("utf8", 1, deftflag < 0 ? &deftflag : nullptr); if (prefstringchar >= 0) { m_translate_in = g_iconv_open("UTF-8", "UTF-8"); @@ -438,11 +470,11 @@ ISpellChecker::setDictionaryEncoding( const char * hashname, const char * encodi if (!g_iconv_is_valid(m_translate_in)) { /* Look for "altstringtype" names from latin1 to latin15 */ - for(int n1 = 1; n1 <= 15; n1++) + for(unsigned n1 = 1; n1 <= 15; n1++) { char * teststring = g_strdup_printf("latin%u", n1); prefstringchar = findfiletype(teststring, 1, - deftflag < 0 ? &deftflag : static_cast<int *>(NULL)); + deftflag < 0 ? &deftflag : nullptr); if (prefstringchar >= 0) { m_translate_in = g_iconv_open(teststring, "UTF-8"); @@ -474,7 +506,7 @@ ISpellChecker::requestDictionary(const char *szLang) std::string shortened_dict (szLang); size_t uscore_pos; - if ((uscore_pos = shortened_dict.rfind ('_')) != ((size_t)-1)) { + if ((uscore_pos = shortened_dict.rfind ('_')) != (static_cast<size_t>(-1))) { shortened_dict = shortened_dict.substr(0, uscore_pos); if (!loadDictionaryForLanguage (shortened_dict.c_str())) return false; @@ -498,7 +530,7 @@ ispell_dict_suggest (EnchantDict * me, const char *const word, { ISpellChecker * checker; - checker = (ISpellChecker *) me->user_data; + checker = static_cast<ISpellChecker *>(me->user_data); return checker->suggestWord (word, len, out_n_suggs); } @@ -507,7 +539,7 @@ ispell_dict_check (EnchantDict * me, const char *const word, size_t len) { ISpellChecker * checker; - checker = (ISpellChecker *) me->user_data; + checker = static_cast<ISpellChecker *>(me->user_data); if (checker->checkWord(word, len)) return 0; @@ -534,7 +566,7 @@ ispell_provider_request_dict (EnchantProvider * me, const char *const tag) } dict = g_new0 (EnchantDict, 1); - dict->user_data = (void *) checker; + dict->user_data = checker; dict->check = ispell_dict_check; dict->suggest = ispell_dict_suggest; // don't implement session or personal @@ -543,11 +575,11 @@ ispell_provider_request_dict (EnchantProvider * me, const char *const tag) } static void -ispell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) +ispell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) { ISpellChecker * checker; - checker = (ISpellChecker *) dict->user_data; + checker = static_cast<ISpellChecker *>(dict->user_data); delete checker; g_free (dict); @@ -589,7 +621,7 @@ ispell_provider_list_dictionaries (EnchantProvider * me, *out_n_dicts = nb; if (nb == 0) { g_free (out_dicts); - out_dicts = NULL; + out_dicts = nullptr; } return out_dicts; @@ -606,7 +638,7 @@ ispell_provider_dictionary_exists (struct str_enchant_provider * me, for (size_t i = 0; i < size_ispell_map; i++) { - const IspellMap * mapping = (const IspellMap *)(&(ispell_map[i])); + const IspellMap * mapping = &(ispell_map[i]); if (!strcmp (tag, mapping->lang) || !strcmp (shortened_dict.c_str(), mapping->lang)) return _ispell_provider_dictionary_exists(me->owner, mapping->dict); } @@ -615,7 +647,7 @@ ispell_provider_dictionary_exists (struct str_enchant_provider * me, } static void -ispell_provider_free_string_list (EnchantProvider * me, char **str_list) +ispell_provider_free_string_list (EnchantProvider * me _GL_UNUSED_PARAMETER, char **str_list) { g_strfreev (str_list); } @@ -627,13 +659,13 @@ ispell_provider_dispose (EnchantProvider * me) } static const char * -ispell_provider_identify (EnchantProvider * me) +ispell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "ispell"; } static const char * -ispell_provider_describe (EnchantProvider * me) +ispell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "Ispell Provider"; } diff --git a/src/ispell/ispell_checker.h b/src/ispell/ispell_checker.h index 8ffcc31..af4acda 100644 --- a/src/ispell/ispell_checker.h +++ b/src/ispell/ispell_checker.h @@ -26,7 +26,7 @@ private: char * loadDictionary (const char * szLang ); bool loadDictionaryForLanguage ( const char * szLang ); - void setDictionaryEncoding ( const char * hashname, const char * enc ); + void setDictionaryEncoding ( const char * enc ); // // The member functions after this point were formerly global functions diff --git a/src/myspell/Makefile.am b/src/myspell/Makefile.am index f278a37..cfea67b 100644 --- a/src/myspell/Makefile.am +++ b/src/myspell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(MYSPELL_CFLAGS) $(CXX_WARN_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(MYSPELL_CFLAGS) $(WARN_CXXFLAGS) -D_ENCHANT_BUILD=1 myspell_LTLIBRARIES = $(target_lib) myspelldir= $(libdir)/enchant diff --git a/src/myspell/myspell_checker.cpp b/src/myspell/myspell_checker.cpp index d04a726..8f4f128 100644 --- a/src/myspell/myspell_checker.cpp +++ b/src/myspell/myspell_checker.cpp @@ -28,6 +28,8 @@ * do so, delete this exception statement from your version. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,6 +39,7 @@ #include "enchant.h" #include "enchant-provider.h" +#include "unused-parameter.h" #include <hunspell/hunspell.hxx> @@ -72,6 +75,12 @@ private: EnchantBroker *m_broker; }; +static void +myspell_checker_free_helper (gpointer p, gpointer user _GL_UNUSED_PARAMETER) +{ + g_free (p); +} + /***************************************************************************/ static bool @@ -109,7 +118,7 @@ MySpellChecker::checkWord(const char *utf8Word, size_t len) size_t len_out = sizeof( word8 ) - 1; size_t result = g_iconv(m_translate_in, &in, &len_in, &out, &len_out); g_free(normalizedWord); - if ((size_t)-1 == result) + if (static_cast<size_t>(-1) == result) return false; *out = '\0'; if (myspell->spell(word8)) @@ -124,7 +133,7 @@ MySpellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug if (len > MAXWORDLEN || !g_iconv_is_valid(m_translate_in) || !g_iconv_is_valid(m_translate_out)) - return 0; + return nullptr; // the 8bit encodings use precomposed forms char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC); @@ -135,8 +144,8 @@ MySpellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug size_t len_out = sizeof(word8) - 1; size_t result = g_iconv(m_translate_in, &in, &len_in, &out, &len_out); g_free(normalizedWord); - if ((size_t)-1 == result) - return NULL; + if (static_cast<size_t>(-1) == result) + return nullptr; *out = '\0'; char **sugMS; @@ -148,8 +157,8 @@ MySpellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug len_in = strlen(in); len_out = MAXWORDLEN; char *word = g_new0(char, len_out + 1); - out = reinterpret_cast<char *>(word); - if ((size_t)-1 == g_iconv(m_translate_out, &in, &len_in, &out, &len_out)) { + out = word; + if (static_cast<size_t>(-1) == g_iconv(m_translate_out, &in, &len_in, &out, &len_out)) { for (size_t j = i; j < *nsug; j++) free(sugMS[j]); free(sugMS); @@ -165,7 +174,7 @@ MySpellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug return sug; } else - return 0; + return nullptr; } static GSList * @@ -180,11 +189,11 @@ myspell_checker_get_dictionary_dirs (EnchantBroker * broker) for (iter = config_dirs; iter; iter = iter->next) { - dirs = g_slist_append (dirs, g_build_filename ((const gchar *)iter->data, - "myspell", NULL)); + dirs = g_slist_append (dirs, g_build_filename (static_cast<const gchar *>(iter->data), + "myspell", nullptr)); } - g_slist_foreach (config_dirs, (GFunc)g_free, NULL); + g_slist_foreach (config_dirs, myspell_checker_free_helper, nullptr); g_slist_free (config_dirs); } @@ -194,7 +203,7 @@ myspell_checker_get_dictionary_dirs (EnchantBroker * broker) for (iter = system_data_dirs; *iter; iter++) { - dirs = g_slist_append (dirs, g_build_filename (*iter, "myspell", "dicts", NULL)); + dirs = g_slist_append (dirs, g_build_filename (*iter, "myspell", "dicts", nullptr)); } } @@ -202,7 +211,7 @@ myspell_checker_get_dictionary_dirs (EnchantBroker * broker) char * enchant_prefix = enchant_get_prefix_dir(); if(enchant_prefix) { - char * myspell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "myspell", NULL); + char * myspell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "myspell", nullptr); g_free(enchant_prefix); dirs = g_slist_append (dirs, myspell_prefix); } @@ -218,10 +227,10 @@ myspell_checker_get_dictionary_dirs (EnchantBroker * broker) for (iter = config_dirs; iter; iter = iter->next) { - dirs = g_slist_append (dirs, g_strdup ((const gchar *)iter->data)); + dirs = g_slist_append (dirs, g_strdup (static_cast<const gchar *>(iter->data))); } - g_slist_foreach (config_dirs, (GFunc)g_free, NULL); + g_slist_foreach (config_dirs, myspell_checker_free_helper, nullptr); g_slist_free (config_dirs); } @@ -246,10 +255,10 @@ s_buildDictionaryDirs (std::vector<std::string> & dirs, EnchantBroker * broker) myspell_dirs = myspell_checker_get_dictionary_dirs (broker); for (iter = myspell_dirs; iter; iter = iter->next) { - dirs.push_back ((const char *)iter->data); + dirs.push_back (static_cast<const char *>(iter->data)); } - g_slist_foreach (myspell_dirs, (GFunc)g_free, NULL); + g_slist_foreach (myspell_dirs, myspell_checker_free_helper, nullptr); g_slist_free (myspell_dirs); } @@ -261,10 +270,10 @@ s_buildHashNames (std::vector<std::string> & names, EnchantBroker * broker, cons std::vector<std::string> dirs; s_buildDictionaryDirs (dirs, broker); - char *dict_dic = g_strconcat(dict, ".dic", NULL); + char *dict_dic = g_strconcat(dict, ".dic", nullptr); for (size_t i = 0; i < dirs.size(); i++) { - char *tmp = g_build_filename (dirs[i].c_str(), dict_dic, NULL); + char *tmp = g_build_filename (dirs[i].c_str(), dict_dic, nullptr); names.push_back (tmp); g_free (tmp); } @@ -320,13 +329,13 @@ myspell_request_dictionary (EnchantBroker * broker, const char * tag) s_buildDictionaryDirs (dirs, broker); for (size_t i = 0; i < dirs.size(); i++) { - GDir *dir = g_dir_open (dirs[i].c_str(), 0, NULL); + GDir *dir = g_dir_open (dirs[i].c_str(), 0, nullptr); if (dir) { const char *dir_entry; while ((dir_entry = g_dir_read_name (dir)) != NULL) { if (is_plausible_dict_for_tag(dir_entry, tag)) { char *dict = g_build_filename (dirs[i].c_str(), - dir_entry, NULL); + dir_entry, nullptr); if(s_hasCorrespondingAffFile(dict)){ g_dir_close (dir); return dict; @@ -380,7 +389,7 @@ myspell_dict_suggest (EnchantDict * me, const char *const word, { MySpellChecker * checker; - checker = (MySpellChecker *) me->user_data; + checker = static_cast<MySpellChecker *>(me->user_data); return checker->suggestWord (word, len, out_n_suggs); } @@ -389,7 +398,7 @@ myspell_dict_check (EnchantDict * me, const char *const word, size_t len) { MySpellChecker * checker; - checker = (MySpellChecker *) me->user_data; + checker = static_cast<MySpellChecker *>(me->user_data); if (checker->checkWord(word, len)) return 0; @@ -401,12 +410,12 @@ static void myspell_provider_enum_dicts (const char * const directory, std::vector<std::string> & out_dicts) { - GDir * dir = g_dir_open (directory, 0, NULL); + GDir * dir = g_dir_open (directory, 0, nullptr); if (dir) { const char * entry; while ((entry = g_dir_read_name (dir)) != NULL) { - char * utf8_entry = g_filename_to_utf8 (entry, -1, NULL, NULL, NULL); + char * utf8_entry = g_filename_to_utf8 (entry, -1, nullptr, nullptr, nullptr); if (utf8_entry) { std::string dir_entry (utf8_entry); g_free (utf8_entry); @@ -419,7 +428,7 @@ myspell_provider_enum_dicts (const char * const directory, { std::string name(dir_entry.substr (0, hit)); std::string affFileName(name + ".aff"); - char * aff = g_build_filename(directory, affFileName.c_str(), NULL); + char * aff = g_build_filename(directory, affFileName.c_str(), nullptr); if (g_file_test(aff, G_FILE_TEST_EXISTS)) { out_dicts.push_back (dir_entry.substr (0, hit)); @@ -465,7 +474,7 @@ myspell_provider_list_dicts (EnchantProvider * me, } static void -myspell_provider_free_string_list (EnchantProvider * me, char **str_list) +myspell_provider_free_string_list (EnchantProvider * me _GL_UNUSED_PARAMETER, char **str_list) { g_strfreev (str_list); } @@ -496,7 +505,7 @@ myspell_provider_request_dict(EnchantProvider * me, const char *const tag) } static void -myspell_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) +myspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) { MySpellChecker *checker; @@ -533,13 +542,13 @@ myspell_provider_dispose (EnchantProvider * me) } static const char * -myspell_provider_identify (EnchantProvider * me) +myspell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "myspell"; } static const char * -myspell_provider_describe (EnchantProvider * me) +myspell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "Myspell Provider"; } @@ -52,6 +52,8 @@ * */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -63,6 +65,7 @@ #include <glib.h> #include <glib/gstdio.h> #include "enchant-provider.h" +#include "unused-parameter.h" #include "pwl.h" @@ -758,7 +761,8 @@ static void enchant_pwl_suggest_cb(char* match,EnchantTrieMatcher* matcher) } -void enchant_pwl_free_string_list(EnchantPWL *pwl, char** string_list) +void enchant_pwl_free_string_list(EnchantPWL *pwl _GL_UNUSED_PARAMETER, + char** string_list) { g_strfreev(string_list); } @@ -794,7 +798,9 @@ static void enchant_trie_free(EnchantTrie* trie) g_free(trie); } -static void enchant_trie_free_cb(void* key, void* value, void* data) +static void enchant_trie_free_cb(void* key _GL_UNUSED_PARAMETER, + void* value, + void* data _GL_UNUSED_PARAMETER) { enchant_trie_free((EnchantTrie*) value); } diff --git a/src/uspell/Makefile.am b/src/uspell/Makefile.am index 8a42796..efe7d80 100644 --- a/src/uspell/Makefile.am +++ b/src/uspell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(USPELL_CFLAGS) $(CXX_WARN_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(USPELL_CFLAGS) $(WARN_CXXFLAGS) -D_ENCHANT_BUILD=1 uspell_LTLIBRARIES = $(target_lib) uspelldir= $(libdir)/enchant diff --git a/src/voikko/Makefile.am b/src/voikko/Makefile.am index 739c36a..3e724ce 100644 --- a/src/voikko/Makefile.am +++ b/src/voikko/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) $(VOIKKO_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(WARN_CFLAGS) $(VOIKKO_CFLAGS) -D_ENCHANT_BUILD=1 voikko_LTLIBRARIES = $(target_lib) voikkodir= $(libdir)/enchant diff --git a/src/voikko/voikko_provider.c b/src/voikko/voikko_provider.c index 6cf4c6d..d4a6327 100644 --- a/src/voikko/voikko_provider.c +++ b/src/voikko/voikko_provider.c @@ -30,12 +30,15 @@ * do so, delete this exception statement from your version. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> #include <glib.h> #include <libvoikko/voikko.h> +#include "unused-parameter.h" #include "enchant.h" #include "enchant-provider.h" @@ -48,7 +51,7 @@ ENCHANT_PLUGIN_DECLARE("Voikko") static int -voikko_dict_check (EnchantDict * me, const char *const word, size_t len) +voikko_dict_check (EnchantDict * me, const char *const word, size_t len _GL_UNUSED_PARAMETER) { int result; int voikko_handle; @@ -65,7 +68,7 @@ voikko_dict_check (EnchantDict * me, const char *const word, size_t len) static char ** voikko_dict_suggest (EnchantDict * me, const char *const word, - size_t len, size_t * out_n_suggs) + size_t len _GL_UNUSED_PARAMETER, size_t * out_n_suggs) { char **sugg_arr; int voikko_handle; @@ -104,14 +107,14 @@ voikko_provider_request_dict (EnchantProvider * me, const char *const tag) } static void -voikko_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict) +voikko_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) { voikko_terminate((long) dict->user_data); g_free (dict); } static int -voikko_provider_dictionary_exists (struct str_enchant_provider * me, +voikko_provider_dictionary_exists (struct str_enchant_provider * me _GL_UNUSED_PARAMETER, const char *const tag) { int voikko_handle; @@ -130,7 +133,7 @@ voikko_provider_dictionary_exists (struct str_enchant_provider * me, static char ** -voikko_provider_list_dicts (EnchantProvider * me, +voikko_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, size_t * out_n_dicts) { char ** out_list = NULL; @@ -148,7 +151,8 @@ voikko_provider_list_dicts (EnchantProvider * me, } static void -voikko_provider_free_string_list (EnchantProvider * me, char **str_list) +voikko_provider_free_string_list (EnchantProvider * me _GL_UNUSED_PARAMETER, + char **str_list) { g_strfreev (str_list); } @@ -160,13 +164,13 @@ voikko_provider_dispose (EnchantProvider * me) } static const char * -voikko_provider_identify (EnchantProvider * me) +voikko_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "voikko"; } static const char * -voikko_provider_describe (EnchantProvider * me) +voikko_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) { return "Voikko Provider"; } diff --git a/src/zemberek/Makefile.am b/src/zemberek/Makefile.am index 6e30006..c347a53 100644 --- a/src/zemberek/Makefile.am +++ b/src/zemberek/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(ZEMBEREK_CFLAGS) $(CXX_WARN_CFLAGS) -D_ENCHANT_BUILD=1 +AM_CPPFLAGS=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(ZEMBEREK_CFLAGS) $(WARN_CXXFLAGS) -D_ENCHANT_BUILD=1 zemberek_LTLIBRARIES = $(target_lib) zemberekdir= $(libdir)/enchant |