From fbf68dcc14cb7a61d25fe0a744105c0d2b77f8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 17 May 2023 21:03:44 +0200 Subject: irc: get value of "msg_max_length" from isupport token "LINELEN" on upgrade from WeeChat < 4.0.0 (issue #1927) --- src/plugins/irc/irc-upgrade.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/plugins/irc') diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index b717418ca..0ca19852d 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -501,7 +501,24 @@ irc_upgrade_read_cb (const void *pointer, void *data, free (irc_upgrade_current_server->prefix_chars); irc_upgrade_current_server->prefix_chars = strdup (str); } - irc_upgrade_current_server->msg_max_length = weechat_infolist_integer (infolist, "msg_max_length"); + /* "msg_max_length" is new in WeeChat 4.0.0 */ + if (weechat_infolist_search_var (infolist, "msg_max_length")) + { + irc_upgrade_current_server->msg_max_length = weechat_infolist_integer (infolist, "msg_max_length"); + } + else + { + /* WeeChat <= 3.8 */ + str = irc_server_get_isupport_value (irc_upgrade_current_server, + "LINELEN"); + if (str) + { + error = NULL; + number = strtol (str, &error, 10); + if (error && !error[0]) + irc_upgrade_current_server->msg_max_length = (int)number; + } + } irc_upgrade_current_server->nick_max_length = weechat_infolist_integer (infolist, "nick_max_length"); /* "user_max_length" is new in WeeChat 2.6 */ if (weechat_infolist_search_var (infolist, "user_max_length")) -- cgit v1.2.3