comparison src/util.c @ 14039:5e6d4c36630a

[gaim-migrate @ 16643] Return g_string_free(str, FALSE) directly instead of assigning str->str to a temporary directory and returning that. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Aug 2006 09:17:09 +0000
parents 8bda65b88e49
children 426a98fa4527
comparison
equal deleted inserted replaced
14038:443aaa05a7c3 14039:5e6d4c36630a
2024 return g_string_free(ret, FALSE); 2024 return g_string_free(ret, FALSE);
2025 } 2025 }
2026 2026
2027 char * 2027 char *
2028 gaim_unescape_html(const char *html) { 2028 gaim_unescape_html(const char *html) {
2029 char *unescaped = NULL; 2029 const char *c;
2030 2030 GString *ret;
2031 if (html != NULL) { 2031
2032 const char *c = html; 2032 if (html == NULL)
2033 GString *ret = g_string_new(""); 2033 return NULL;
2034 while (*c) { 2034
2035 if (!strncmp(c, "&amp;", 5)) { 2035 c = html;
2036 ret = g_string_append_c(ret, '&'); 2036 ret = g_string_new("");
2037 c += 5; 2037 while (*c) {
2038 } else if (!strncmp(c, "&lt;", 4)) { 2038 if (!strncmp(c, "&amp;", 5)) {
2039 ret = g_string_append_c(ret, '<'); 2039 ret = g_string_append_c(ret, '&');
2040 c += 4; 2040 c += 5;
2041 } else if (!strncmp(c, "&gt;", 4)) { 2041 } else if (!strncmp(c, "&lt;", 4)) {
2042 ret = g_string_append_c(ret, '>'); 2042 ret = g_string_append_c(ret, '<');
2043 c += 4; 2043 c += 4;
2044 } else if (!strncmp(c, "&quot;", 6)) { 2044 } else if (!strncmp(c, "&gt;", 4)) {
2045 ret = g_string_append_c(ret, '"'); 2045 ret = g_string_append_c(ret, '>');
2046 c += 6; 2046 c += 4;
2047 } else if (!strncmp(c, "&apos;", 6)) { 2047 } else if (!strncmp(c, "&quot;", 6)) {
2048 ret = g_string_append_c(ret, '\''); 2048 ret = g_string_append_c(ret, '"');
2049 c += 6; 2049 c += 6;
2050 } else if (!strncmp(c, "<br>", 4)) { 2050 } else if (!strncmp(c, "&apos;", 6)) {
2051 ret = g_string_append_c(ret, '\n'); 2051 ret = g_string_append_c(ret, '\'');
2052 c += 4; 2052 c += 6;
2053 } else { 2053 } else if (!strncmp(c, "<br>", 4)) {
2054 ret = g_string_append_c(ret, *c); 2054 ret = g_string_append_c(ret, '\n');
2055 c++; 2055 c += 4;
2056 } 2056 } else {
2057 } 2057 ret = g_string_append_c(ret, *c);
2058 2058 c++;
2059 unescaped = ret->str; 2059 }
2060 g_string_free(ret, FALSE); 2060 }
2061 } 2061
2062 return unescaped; 2062 return g_string_free(ret, FALSE);
2063 2063
2064 } 2064 }
2065 2065
2066 char * 2066 char *
2067 gaim_markup_slice(const char *str, guint x, guint y) 2067 gaim_markup_slice(const char *str, guint x, guint y)