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;
}
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
msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
{
int i;
if (!msgbuf_has_matching_tags(msgbuf, capmask))
return;
*buf = '@';
for (i = 0; i < msgbuf->n_tags; i++)