summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-08-23 15:24:53 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-08-23 15:33:34 +0200
commit25b3f2eae7feea6e498a6a0665857fa06f7ddfc9 (patch)
tree8da32330151933b1ff905a142693b072080916ed
parent9462c87ce5aa0ead85d123f5e1fed94e8a1656ed (diff)
downloadweechat-25b3f2eae7feea6e498a6a0665857fa06f7ddfc9.zip
irc: fix string comparison when CASEMAPPING is set to "ascii"
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/irc/irc-server.c54
2 files changed, 19 insertions, 36 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index a630caa0f..252955a0c 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -40,6 +40,7 @@ Bug fixes::
* fset: remove extra spaces between min and max values when second format is used
* fset: fix mouse actions when second format is used
* fset: apply option fset.color.help_description (issue #1988)
+ * irc: fix string comparison when CASEMAPPING is set to "ascii"
* irc: fix display of country code in message 344 received as whois geo info (issue #1736)
* irc: add missing "account-tag" in list of supported capabilities
* irc: add channel in "autojoin" server option only when the channel is actually joined (issue #1990)
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 10f14c981..2cd37d1ff 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -132,6 +132,8 @@ char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
char *irc_server_casemapping_string[IRC_SERVER_NUM_CASEMAPPING] =
{ "rfc1459", "strict-rfc1459", "ascii" };
+int irc_server_casemapping_range[IRC_SERVER_NUM_CASEMAPPING] =
+{ 30, 29, 26 };
char *irc_server_utf8mapping_string[IRC_SERVER_NUM_UTF8MAPPING] =
{ "none", "rfc8265" };
@@ -295,25 +297,15 @@ int
irc_server_strcasecmp (struct t_irc_server *server,
const char *string1, const char *string2)
{
- int casemapping, rc;
+ int casemapping, range;
- casemapping = (server) ? server->casemapping : IRC_SERVER_CASEMAPPING_RFC1459;
- switch (casemapping)
- {
- case IRC_SERVER_CASEMAPPING_RFC1459:
- rc = weechat_strcasecmp_range (string1, string2, 30);
- break;
- case IRC_SERVER_CASEMAPPING_STRICT_RFC1459:
- rc = weechat_strcasecmp_range (string1, string2, 29);
- break;
- case IRC_SERVER_CASEMAPPING_ASCII:
- rc = weechat_strcasecmp (string1, string2);
- break;
- default:
- rc = weechat_strcasecmp_range (string1, string2, 30);
- break;
- }
- return rc;
+ casemapping = (server) ? server->casemapping : -1;
+ if ((casemapping < 0) || (casemapping >= IRC_SERVER_NUM_CASEMAPPING))
+ casemapping = IRC_SERVER_CASEMAPPING_RFC1459;
+
+ range = irc_server_casemapping_range[casemapping];
+
+ return weechat_strcasecmp_range (string1, string2, range);
}
/*
@@ -330,25 +322,15 @@ int
irc_server_strncasecmp (struct t_irc_server *server,
const char *string1, const char *string2, int max)
{
- int casemapping, rc;
+ int casemapping, range;
- casemapping = (server) ? server->casemapping : IRC_SERVER_CASEMAPPING_RFC1459;
- switch (casemapping)
- {
- case IRC_SERVER_CASEMAPPING_RFC1459:
- rc = weechat_strncasecmp_range (string1, string2, max, 30);
- break;
- case IRC_SERVER_CASEMAPPING_STRICT_RFC1459:
- rc = weechat_strncasecmp_range (string1, string2, max, 29);
- break;
- case IRC_SERVER_CASEMAPPING_ASCII:
- rc = weechat_strncasecmp (string1, string2, max);
- break;
- default:
- rc = weechat_strncasecmp_range (string1, string2, max, 30);
- break;
- }
- return rc;
+ casemapping = (server) ? server->casemapping : -1;
+ if ((casemapping < 0) || (casemapping >= IRC_SERVER_NUM_CASEMAPPING))
+ casemapping = IRC_SERVER_CASEMAPPING_RFC1459;
+
+ range = irc_server_casemapping_range[casemapping];
+
+ return weechat_strncasecmp_range (string1, string2, max, range);
}
/*