msgbuf: improve parse logic

This commit is contained in:
William Pitcock 2016-02-10 00:46:32 -06:00
parent 4d03595da4
commit 269dd686b3
2 changed files with 8 additions and 8 deletions

View File

@ -68,9 +68,7 @@ int msgbuf_vunparse_fmt(char *buf, struct MsgBuf *head, const char *fmt, va_list
static inline void
msgbuf_init(struct MsgBuf *msgbuf)
{
msgbuf->n_tags = msgbuf->n_para = msgbuf->parselen = 0;
msgbuf->origin = NULL;
msgbuf->cmd = NULL;
memset(msgbuf, 0, sizeof(*msgbuf));
}
static inline void

View File

@ -48,7 +48,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
ch = strchr(ch, ' ');
if (ch != NULL)
{
while (t < ch)
while (1)
{
char *next = strchr(t, ';');
char *eq = strchr(t, '=');
@ -63,7 +63,11 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
*eq = '\0';
msgbuf_append_tag(msgbuf, t, eq);
t = next + 1;
if (next != NULL)
t = next + 1;
else
break;
}
}
}
@ -95,9 +99,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
return 1;
msgbuf->cmd = parv[0];
msgbuf->n_para = n_para - 1;
for (i = 1; i < n_para; i++)
for (i = 0; i < n_para; i++)
msgbuf_append_para(msgbuf, parv[i]);
return 0;