# HG changeset patch # User Richard Laager # Date 1180931668 0 # Node ID 9187a19d72a7caad2b75b0b0bbe852dfe0a18bba # Parent 2217b738a89038ac625404a35b6f73fa800df5a7# Parent 0e22098e142137b7df1e1faf2b0a8db75ad9e528 merge of '1d87bfa8d0fa4d714b78ae468166c29a21606b37' and 'd490669094dfedb728db24b519343e169ca782f9' diff -r 2217b738a890 -r 9187a19d72a7 libpurple/plugins/log_reader.c --- a/libpurple/plugins/log_reader.c Mon Jun 04 02:46:05 2007 +0000 +++ b/libpurple/plugins/log_reader.c Mon Jun 04 04:34:28 2007 +0000 @@ -1482,39 +1482,66 @@ * "> * Then, replace the next " " (or add this if the end-of-line is reached) with: * + * + * As implemented, this isn't perfect, but it should cover common cases. */ link_temp_line = NULL; - while ((link = strstr(line, "(Link: "))) { - GString *temp; + while ((link = strstr(line, "(Link: "))) + { + char *tmp = link; - *link = '\0'; - temp = g_string_new(line); - g_string_append(temp, " tag. */ + g_string_append(temp, " tag. */ g_string_append(temp, "\">"); - while (*link && *link != ' ') { - g_string_append_c(temp, *link); - link++; - } - g_string_append(temp, ""); + + /* The \r is a bit of a hack to keep there from being a \r in + * the link text, which may not matter. */ + if ((space = strstr(end_paren, " ")) || (space = strstr(end_paren, "\r"))) + { + g_string_append_len(temp, end_paren + 1, space - end_paren - 1); + + /* Close the tag. */ + g_string_append(temp, ""); - g_string_append(temp, link); + space++; + if (*space) + { + g_string_append_c(temp, ' '); + /* Keep the rest of the line. */ + g_string_append(temp, space); + } + } + else + { + /* There is no space before the end of the line. */ + g_string_append(temp, end_paren + 1); + /* Close the tag. */ + g_string_append(temp, ""); + } - /* Free the last round's line. */ - if (link_temp_line) - g_free(line); - - line = temp->str; - g_string_free(temp, FALSE); + g_free(link_temp_line); + line = g_string_free(temp, FALSE); /* Save this memory location so we can free it later. */ link_temp_line = line; @@ -1654,8 +1681,7 @@ g_string_append_c(formatted, '\n'); - if (link_temp_line) - g_free(link_temp_line); + g_free(link_temp_line); c++; line = c;