[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Weechat-cvs] weechat/src/plugins/aspell weechat-aspell.c
From: |
kolter |
Subject: |
[Weechat-cvs] weechat/src/plugins/aspell weechat-aspell.c |
Date: |
Tue, 20 Jun 2006 18:00:47 +0000 |
CVSROOT: /sources/weechat
Module name: weechat
Changes by: kolter <kolter> 06/06/20 18:00:47
Modified files:
src/plugins/aspell: weechat-aspell.c
Log message:
do not check words made of punctuation and digits and fix a bug while
saving aspell plugin configuration
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/weechat/src/plugins/aspell/weechat-aspell.c?cvsroot=weechat&r1=1.5&r2=1.6
Patches:
Index: weechat-aspell.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/aspell/weechat-aspell.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- weechat-aspell.c 16 Jun 2006 16:06:25 -0000 1.5
+++ weechat-aspell.c 20 Jun 2006 18:00:47 -0000 1.6
@@ -766,7 +766,8 @@
{
aspell_config_t *p, *q;
char *servers, *channels, *option;
- int n;
+ char **servers_list;
+ int n, i, s, found;
servers = NULL;
@@ -785,7 +786,19 @@
}
else
{
- if (!strstr (servers, p->server))
+ servers_list = weechat_aspell_plugin->explode_string
(weechat_aspell_plugin, servers, " ", 0, &s);
+ if (servers_list)
+ {
+ found = 0;
+ for (i=0; i<s; i++)
+ {
+ if (strcmp (servers_list[i], p->server) == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+ if (found == 0)
{
n = strlen (servers) + strlen (p->server) + 2;
servers = (char *) realloc (servers, n * sizeof (char));
@@ -793,6 +806,8 @@
strcat (servers, p->server);
weechat_aspell_plugin->set_plugin_config
(weechat_aspell_plugin, "servers", servers);
}
+ free (servers_list);
+ }
free (servers);
}
@@ -805,14 +820,11 @@
channels = strdup (q->channel);
else
{
- if (!strstr (channels, q->channel))
- {
n = strlen (channels) + strlen (q->channel) + 2;
channels = (char *) realloc (channels, n * sizeof
(char));
strcat (channels, " ");
strcat (channels, q->channel);
}
- }
n = 7 + strlen (p->server) + strlen (q->channel);
option = (char *) malloc ( n * sizeof (char));
@@ -1041,7 +1053,8 @@
{
if (c >= 2)
{
- weechat_aspell_config_addword (args[1]); r = 1;
+ weechat_aspell_config_addword (args[1]);
+ r = 1;
}
}
@@ -1141,6 +1154,33 @@
}
/*
+ * weechat_aspell_is_simili_number :
+ * detect if a word is made of chars and punctation
+ */
+int
+weechat_aspell_is_simili_number (char *word)
+{
+ int len, ret, i;
+
+ ret = 1;
+ len = strlen (word);
+
+ if (!word)
+ return 0;
+
+ for (i=0; i<len; i++)
+ {
+ if (!ispunct(word[i]) && !isdigit(word[i]))
+ {
+ ret = 0;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/*
* weechat_aspell_keyb_check : handler to check spelling on input line
*/
int
@@ -1203,6 +1243,8 @@
{
if ( (int) strlen (clword) >= aspell_plugin_options.word_size)
{
+ if (!weechat_aspell_is_simili_number (clword))
+ {
if (!weechat_aspell_nick_in_channel (clword, server, channel))
{
if (aspell_speller_check (c->speller->speller, clword, -1)
!= 1)
@@ -1215,6 +1257,7 @@
}
}
}
+ }
free (clword);
}