Mercurial > pidgin.yaz
diff src/protocols/msn/msg.c @ 6181:29fef9695c4d
[gaim-migrate @ 6667]
MSN messages with newlines being sent to an MSN client had \n and not \r\n,
but the official MSN client requires \r\n (wonderful, huh?) Now we send
\r\n for MSN messages. Problem solved.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 17 Jul 2003 20:49:40 +0000 |
parents | f7ddc1f6227e |
children | b7e113a59b51 |
line wrap: on
line diff
--- a/src/protocols/msn/msg.c Thu Jul 17 15:24:21 2003 +0000 +++ b/src/protocols/msn/msg.c Thu Jul 17 20:49:40 2003 +0000 @@ -407,6 +407,11 @@ void msn_message_set_body(MsnMessage *msg, const char *body) { + const char *c; + char *buf, *d; + int newline_count = 0; + size_t new_len; + g_return_if_fail(msg != NULL); g_return_if_fail(body != NULL); @@ -415,9 +420,27 @@ g_free(msg->body); } - msg->body = g_strdup(body); + for (c = body; *c != '\0'; c++) { + if (*c == '\n' && (c == body || *(c - 1) != '\r')) + newline_count++; + } + + new_len = strlen(body) + newline_count; + + buf = g_new0(char, new_len + 1); - msg->size += strlen(body); + for (c = body, d = buf; *c != '\0'; c++) { + if (*c == '\n' && (c == body || *(c - 1) != '\r')) { + *d++ = '\r'; + *d++ = '\n'; + } + else + *d++ = *c; + } + + msg->body = buf; + + msg->size += new_len; } const char *