0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-19 08:21:09 +01:00

msgbuf: msgbuf_unparse_tags(): don't send a tags sigil unless tags will actually be emitted

This commit is contained in:
William Pitcock 2016-02-20 18:41:16 -06:00
parent 474f6342e8
commit 4d2f203026

View file

@ -114,11 +114,28 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
return 0; return 0;
} }
static int
msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask)
{
int i;
for (i = 0; i < msgbuf->n_tags; i++)
{
if ((msgbuf->tags[i].capmask & capmask) != 0)
return 1;
}
return 0;
}
static void static void
msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
{ {
int i; int i;
if (!msgbuf_has_matching_tags(msgbuf, capmask))
return;
*buf = '@'; *buf = '@';
for (i = 0; i < msgbuf->n_tags; i++) for (i = 0; i < msgbuf->n_tags; i++)