xC: deal with so far unexpected multiline messages

And get rid of an outdated unmarked TODO comment.
This commit is contained in:
Přemysl Eric Janouch 2022-09-10 18:48:15 +02:00
parent e7d0f2380e
commit 7d5e63be1f
Signed by: p
GPG Key ID: A0420B94F92B9493

26
xC.c
View File

@ -9075,12 +9075,21 @@ irc_autosplit_message (struct server *s, const char *message,
- 1 - (int) strlen (s->irc_user_host) - 1 - (int) strlen (s->irc_user_host)
- 1 - fixed_part; - 1 - fixed_part;
// However we don't always have the full info for message splitting // Multiline messages can be triggered through hooks and plugins.
if (!space_in_one_message) struct strv lines = strv_make ();
strv_append (output, message); cstr_split (message, "\r\n", false, &lines);
else if (!wrap_message (message, space_in_one_message, output, e)) bool success = true;
return false; for (size_t i = 0; i < lines.len; i++)
return true; {
// We don't always have the full info for message splitting.
if (!space_in_one_message)
strv_append (output, lines.vector[i]);
else if (!(success =
wrap_message (lines.vector[i], space_in_one_message, output, e)))
break;
}
strv_free (&lines);
return success;
} }
static void static void
@ -9089,12 +9098,11 @@ send_autosplit_message (struct server *s,
const char *prefix, const char *suffix) const char *prefix, const char *suffix)
{ {
struct buffer *buffer = str_map_find (&s->irc_buffer_map, target); struct buffer *buffer = str_map_find (&s->irc_buffer_map, target);
// "COMMAND target * :prefix*suffix"
int fixed_part = strlen (command) + 1 + strlen (target) + 1 + 1 int fixed_part = strlen (command) + 1 + strlen (target) + 1 + 1
+ strlen (prefix) + strlen (suffix); + strlen (prefix) + strlen (suffix);
// We might also want to preserve attributes across splits but
// that would make this code a lot more complicated
struct strv lines = strv_make (); struct strv lines = strv_make ();
struct error *e = NULL; struct error *e = NULL;
if (!irc_autosplit_message (s, message, fixed_part, &lines, &e)) if (!irc_autosplit_message (s, message, fixed_part, &lines, &e))