# HG changeset patch # User Mark Doliner # Date 1249031060 0 # Node ID 516993d86e722a24c8f75530226402ba632e1402 # Parent 70219821df98e48395c8ffb1b1fa0a83cf93e1ce Stop using a GString when a gchar* will do fine diff -r 70219821df98 -r 516993d86e72 libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Fri Jul 31 08:55:10 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Fri Jul 31 09:04:20 2009 +0000 @@ -309,12 +309,12 @@ } /* The Yahoo size tag is actually an absz tag; convert it to an HTML size, and include both tags */ -static void _font_tags_fix_size(GString *tag, GString *dest) +static void _font_tags_fix_size(const char *tag, GString *dest) { char *x, *end; int size; - if (((x = strstr(tag->str, "size"))) && ((x = strchr(x, '=')))) { + if (((x = strstr(tag, "size"))) && ((x = strchr(x, '=')))) { while (*x && !g_ascii_isdigit(*x)) x++; if (*x) { @@ -322,16 +322,16 @@ size = strtol(x, &end, 10); htmlsize = point_to_html(size); - g_string_append_len(dest, tag->str, x - tag->str); + g_string_append_len(dest, tag, x - tag); g_string_append_printf(dest, "%d", htmlsize); g_string_append_printf(dest, "\" absz=\"%d", size); g_string_append(dest, end); } else { - g_string_append(dest, tag->str); + g_string_append(dest, tag); return; } } else { - g_string_append(dest, tag->str); + g_string_append(dest, tag); return; } } @@ -339,8 +339,9 @@ char *yahoo_codes_to_html(const char *x) { size_t x_len; - GString *s, *tmp; + GString *s; int i, j; + gchar *tmp; gboolean no_more_end_tags = FALSE; /* s/endtags/closinganglebrackets */ const char *match; @@ -357,20 +358,21 @@ if (x[j] != 'm') continue; else { - tmp = g_string_new_len(x + i + 2, j - i - 2); - if (tmp->str[0] == '#') - g_string_append_printf(s, "", tmp->str); - else if ((match = g_hash_table_lookup(ht, tmp->str))) + /* We've reached the end of the formatting code, yay */ + tmp = g_strndup(x + i + 2, j - i - 2); + if (tmp[0] == '#') + g_string_append_printf(s, "", tmp); + else if ((match = g_hash_table_lookup(ht, tmp))) g_string_append(s, match); else { purple_debug_error("yahoo", - "Unknown ansi code 'ESC[%sm'.\n", tmp->str); - g_string_free(tmp, TRUE); + "Unknown ansi code 'ESC[%sm'.\n", tmp); + g_free(tmp); break; } i = j; - g_string_free(tmp, TRUE); + g_free(tmp); break; } } @@ -387,30 +389,30 @@ else continue; else { - tmp = g_string_new_len(x + i, j - i + 1); - g_string_ascii_down(tmp); + tmp = g_strndup(x + i, j - i + 1); + g_ascii_strdown(tmp, -1); - if ((match = g_hash_table_lookup(ht, tmp->str))) + if ((match = g_hash_table_lookup(ht, tmp))) g_string_append(s, match); - else if (!strncmp(tmp->str, "str, "str, "str, "