# HG changeset patch # User Mark Doliner # Date 1249002402 0 # Node ID 1b5b24dc03108800fc013e287f512b47d06d0a22 # Parent 37141b94d568949ee394601b980b7a110ab26299 Whoops, I forgot to add the test! Also change Yahoo to send lowercase tags to libpurple Yes, these probably should have been two separate commits. diff -r 37141b94d568 -r 1b5b24dc0310 libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Fri Jul 31 00:56:33 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Fri Jul 31 01:06:42 2009 +0000 @@ -215,23 +215,23 @@ ht = g_hash_table_new(g_str_hash, g_str_equal); /* the numbers in comments are what gyach uses, but i think they're incorrect */ - g_hash_table_insert(ht, "30", ""); /* black */ - g_hash_table_insert(ht, "31", ""); /* blue */ - g_hash_table_insert(ht, "32", ""); /* cyan */ /* 00b2b2 */ - g_hash_table_insert(ht, "33", ""); /* gray */ /* 808080 */ - g_hash_table_insert(ht, "34", ""); /* green */ /* 00c200 */ - g_hash_table_insert(ht, "35", ""); /* pink */ /* ffafaf */ - g_hash_table_insert(ht, "36", ""); /* purple */ /* b200b2 */ - g_hash_table_insert(ht, "37", ""); /* orange */ /* ffff00 */ - g_hash_table_insert(ht, "38", ""); /* red */ - g_hash_table_insert(ht, "39", ""); /* olive */ /* 546b50 */ + g_hash_table_insert(ht, "30", ""); /* black */ + g_hash_table_insert(ht, "31", ""); /* blue */ + g_hash_table_insert(ht, "32", ""); /* cyan */ /* 00b2b2 */ + g_hash_table_insert(ht, "33", ""); /* gray */ /* 808080 */ + g_hash_table_insert(ht, "34", ""); /* green */ /* 00c200 */ + g_hash_table_insert(ht, "35", ""); /* pink */ /* ffafaf */ + g_hash_table_insert(ht, "36", ""); /* purple */ /* b200b2 */ + g_hash_table_insert(ht, "37", ""); /* orange */ /* ffff00 */ + g_hash_table_insert(ht, "38", ""); /* red */ + g_hash_table_insert(ht, "39", ""); /* olive */ /* 546b50 */ - g_hash_table_insert(ht, "1", ""); - g_hash_table_insert(ht, "x1", ""); - g_hash_table_insert(ht, "2", ""); - g_hash_table_insert(ht, "x2", ""); - g_hash_table_insert(ht, "4", ""); - g_hash_table_insert(ht, "x4", ""); + g_hash_table_insert(ht, "1", ""); + g_hash_table_insert(ht, "x1", ""); + g_hash_table_insert(ht, "2", ""); + g_hash_table_insert(ht, "x2", ""); + g_hash_table_insert(ht, "4", ""); + g_hash_table_insert(ht, "x4", ""); /* these just tell us the text they surround is supposed * to be a link. purple figures that out on its own so we @@ -240,27 +240,27 @@ g_hash_table_insert(ht, "l", ""); /* link start */ g_hash_table_insert(ht, "xl", ""); /* link end */ - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); - g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); + g_hash_table_insert(ht, "", ""); /* remove these once we have proper support for and */ g_hash_table_insert(ht, "", ""); @@ -354,7 +354,7 @@ else { tmp = g_string_new_len(x + i + 2, j - i - 2); if (tmp->str[0] == '#') - g_string_append_printf(s, "", tmp->str); + g_string_append_printf(s, "", tmp->str); else if ((match = (char *) g_hash_table_lookup(ht, tmp->str))) g_string_append(s, match); else { diff -r 37141b94d568 -r 1b5b24dc0310 libpurple/tests/test_yahoo_util.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/tests/test_yahoo_util.c Fri Jul 31 01:06:42 2009 +0000 @@ -0,0 +1,37 @@ +#include + +#include "tests.h" +#include "../protocols/yahoo/libymsg.h" + +static void setup_codes_to_html(void) +{ + yahoo_init_colorht(); +} + +static void teardown_codes_to_html(void) +{ + yahoo_dest_colorht(); +} + +START_TEST(test_codes_to_html) +{ + assert_string_equal_free("plain", yahoo_codes_to_html("plain")); + assert_string_equal_free("bold", yahoo_codes_to_html("\x1B[1mbold")); + assert_string_equal_free("italic", yahoo_codes_to_html("\x1B[2mitalic")); + assert_string_equal_free("underline", yahoo_codes_to_html("\x1B[4munderline")); + assert_string_equal_free("bold italic underline", yahoo_codes_to_html("\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline")); +} +END_TEST + +Suite * +yahoo_util_suite(void) +{ + Suite *s = suite_create("Yahoo Utility Functions"); + + TCase *tc = tcase_create("Convert to Numeric"); + tcase_add_unchecked_fixture(tc, setup_codes_to_html, teardown_codes_to_html); + tcase_add_test(tc, test_codes_to_html); + suite_add_tcase(s, tc); + + return s; +}