summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2020-09-07 22:44:29 +0100
committerGitHub <noreply@github.com>2020-09-07 22:44:29 +0100
commita139a94e2a4f6f18f98d0c5cb8898a49617df94f (patch)
tree952f45fa5e4a68f1f9dd3e3df2c2812928361772
parent9a0f365c235e109384ef6c231cd664a02fb27054 (diff)
parent1c953ca0c1f30ad36af3002cfba90fc633948b03 (diff)
downloadenchant-a139a94e2a4f6f18f98d0c5cb8898a49617df94f.tar.gz
Merge pull request #256 from rrthomas/masterv2.2.11
Make enchant silently accept -B for Emacs compatibility
-rw-r--r--NEWS13
-rw-r--r--configure.ac4
-rw-r--r--src/enchant.c5
-rw-r--r--src/lib.c53
4 files changed, 43 insertions, 32 deletions
diff --git a/NEWS b/NEWS
index 42bf98c..9071691 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,16 @@
+2.2.11 (September 7, 2020)
+--------------------------
+
+Make enchant silently ignore -B flag, for better Emacs compatibility.
+
+Make enchant_broker_list_dicts sort the tags, so that enchant-lsmod’s output
+is sorted.
+
+Minor build system improvement: don’t use -D_FORTIFY_SOURCE, which can cause
+problems on Windows, and should be configured by the compiler vendor if
+desired.
+
+
2.2.10 (September 1, 2020)
--------------------------
diff --git a/configure.ac b/configure.ac
index 18d988a..366e85e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([enchant],[2.2.10])
+AC_INIT([enchant],[2.2.11])
AC_CONFIG_SRCDIR(src/enchant.h)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([subdir-objects])
@@ -99,8 +99,6 @@ if test "$gl_gcc_warnings" = yes; then
dnl Add an extra warning
gl_WARN_ADD([-Wstrict-overflow=1])
- dnl Add some more safety measures
- gl_WARN_ADD([-D_FORTIFY_SOURCE=2])
dnl Remove a warning being promoted to error: we trigger this and can't turn it off with pragmas.
gl_WARN_ADD([-Wno-error=format-security])
diff --git a/src/enchant.c b/src/enchant.c
index 579b6a0..953e704 100644
--- a/src/enchant.c
+++ b/src/enchant.c
@@ -422,7 +422,7 @@ int main (int argc, char ** argv)
#endif
int optchar;
- while ((optchar = getopt (argc, argv, ":d:alvLm")) != -1) {
+ while ((optchar = getopt (argc, argv, ":d:alvLmB")) != -1) {
switch (optchar) {
case 'd':
dictionary = optarg; /* Emacs calls ispell with '-d dictionary'. */
@@ -443,7 +443,8 @@ int main (int argc, char ** argv)
print_version (stderr);
exit (0);
case 'm':
- /* Ignore: Emacs calls ispell with '-m'. */
+ case 'B':
+ /* Ignore: Emacs calls ispell with '-m' and '-B'. */
break;
case 'h':
print_help (argv[0]);
diff --git a/src/lib.c b/src/lib.c
index 5a5cb5a..5831782 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -1156,13 +1156,19 @@ enchant_broker_describe (EnchantBroker * broker, EnchantBrokerDescribeFn fn, voi
}
}
+static gint
+_gfunc_strcmp(gconstpointer item1, gconstpointer item2)
+{
+ return strcmp (item1, item2);
+}
+
void
enchant_broker_list_dicts (EnchantBroker * broker, EnchantDictDescribeFn fn, void * user_data)
{
g_return_if_fail (broker);
g_return_if_fail (fn);
- GHashTable *tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ GHashTable *tag_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
enchant_broker_clear_error (broker);
@@ -1177,25 +1183,17 @@ enchant_broker_list_dicts (EnchantBroker * broker, EnchantDictDescribeFn fn, voi
for (size_t i = 0; i < n_dicts; i++)
{
- const char * tag;
-
- tag = dicts[i];
+ const char * tag = dicts[i];
if (enchant_is_valid_dictionary_tag (tag)) {
- gpointer ptr;
- GSList *providers;
- gint this_priority;
-
- providers = enchant_get_ordered_providers (broker, tag);
- this_priority = g_slist_index (providers, provider);
+ GSList *providers = enchant_get_ordered_providers (broker, tag);
+ gint this_priority = g_slist_index (providers, provider);
if (this_priority != -1) {
- gint min_priority;
-
- min_priority = this_priority + 1;
- ptr = g_hash_table_lookup (tags, tag);
+ gint min_priority = this_priority + 1;
+ gpointer ptr = g_hash_table_lookup (tag_map, tag);
if (ptr != NULL)
min_priority = g_slist_index (providers, ptr);
if (this_priority < min_priority)
- g_hash_table_insert (tags, strdup (tag), provider);
+ g_hash_table_insert (tag_map, strdup (tag), provider);
}
g_slist_free (providers);
}
@@ -1205,25 +1203,26 @@ enchant_broker_list_dicts (EnchantBroker * broker, EnchantDictDescribeFn fn, voi
}
}
+ GSList *tags = NULL;
GHashTableIter iter;
+ g_hash_table_iter_init (&iter, tag_map);
gpointer key, value;
- g_hash_table_iter_init (&iter, tags);
while (g_hash_table_iter_next (&iter, &key, &value))
- {
- const char * tag, * name, * desc, * file;
- EnchantProvider * provider;
- GModule *module;
+ tags = g_slist_insert_sorted (tags, (char *) key, _gfunc_strcmp);
- tag = (const char *) key;
- provider = (EnchantProvider *) value;
- module = (GModule *) provider->enchant_private_data;
- name = (*provider->identify) (provider);
- desc = (*provider->describe) (provider);
- file = g_module_name (module);
+ for (GSList *ptr = tags; ptr != NULL; ptr = g_slist_next (ptr))
+ {
+ const char *tag = (const char *) ptr->data;
+ EnchantProvider *provider = (EnchantProvider *) g_hash_table_lookup (tag_map, tag);
+ GModule *module = (GModule *) provider->enchant_private_data;
+ const char *name = (*provider->identify) (provider);
+ const char *desc = (*provider->describe) (provider);
+ const char *file = g_module_name (module);
(*fn) (tag, name, desc, file, user_data);
}
- g_hash_table_destroy (tags);
+ g_slist_free (tags);
+ g_hash_table_destroy (tag_map);
}
void