diff libpurple/util.c @ 16084:a5a831a5f186

Patch cleanups: * Whitespace consistency * Comment cleanups * if (foo) g_free(foo); fixes * other small stuff, I'm sure This closes ticket #78.
author Richard Laager <rlaager@wiktel.com>
date Fri, 13 Apr 2007 04:15:14 +0000
parents f2a4b05407d7
children 6613fb7af427
line wrap: on
line diff
--- a/libpurple/util.c	Fri Apr 13 04:13:24 2007 +0000
+++ b/libpurple/util.c	Fri Apr 13 04:15:14 2007 +0000
@@ -861,10 +861,8 @@
  * Markup Functions
  **************************************************************************/
 
-/* Returns a NULL-terminated string after unescaping an entity
- * (eg. &amp;, &lt; &#38 etc.) starting at s. Returns NULL on failure.*/
 const char *
-purple_markup_detect_entity(const char *text, int *length)
+purple_markup_unescape_entity(const char *text, int *length)
 {
 	const char *pln;
 	int len, pound;
@@ -909,9 +907,9 @@
 	return pln;
 }
 
-gchar*
-purple_markup_get_css_property(const gchar	*style,
-				const gchar	*opt)
+char *
+purple_markup_get_css_property(const gchar *style,
+				const gchar *opt)
 {
 	const gchar *css_str = style;
 	const gchar *css_value_start;
@@ -919,48 +917,50 @@
 	gchar *tmp;
 	gchar *ret;
 
-	if(!css_str)
+	if (!css_str)
 		return NULL;
 
 	/* find the CSS property */
-	while(1){
-		/* skip widespace characters */
-		while(*css_str && g_ascii_isspace(*css_str))
+	while (1)
+	{
+		/* skip whitespace characters */
+		while (*css_str && g_ascii_isspace(*css_str))
 			css_str++;
-		if(!g_ascii_isalpha(*css_str))
+		if (!g_ascii_isalpha(*css_str))
 			return NULL;
-		if(g_ascii_strncasecmp(css_str, opt, strlen(opt)))
+		if (g_ascii_strncasecmp(css_str, opt, strlen(opt)))
 		{
 			/* go to next css property positioned after the next ';' */
-			while(*css_str && *css_str != '"' && *css_str != ';')
+			while (*css_str && *css_str != '"' && *css_str != ';')
 				css_str++;
 			if(*css_str != ';')
 				return NULL;
 			css_str++;
 		}
-		else break;
+		else
+			break;
 	}
 
 	/* find the CSS value position in the string */
 	css_str += strlen(opt);
-	while(*css_str && g_ascii_isspace(*css_str))
+	while (*css_str && g_ascii_isspace(*css_str))
 		css_str++;
-	if(*css_str != ':')
+	if (*css_str != ':')
 		return NULL;
 	css_str++;
-	while(*css_str && g_ascii_isspace(*css_str))
+	while (*css_str && g_ascii_isspace(*css_str))
 		css_str++;
-	if(*css_str == '\0' || *css_str == '"' || *css_str == ';')
+	if (*css_str == '\0' || *css_str == '"' || *css_str == ';')
 		return NULL;
 
 	/* mark the CSS value */
 	css_value_start = css_str;
-	while(*css_str && *css_str != '"' && *css_str != ';')
+	while (*css_str && *css_str != '"' && *css_str != ';')
 		css_str++;
 	css_value_end = css_str - 1;
 
 	/* Removes trailing whitespace */
-	while(css_value_end > css_value_start && g_ascii_isspace(*css_value_end))
+	while (css_value_end > css_value_start && g_ascii_isspace(*css_value_end))
 		css_value_end--;
 
 	tmp = g_strndup(css_value_start, css_value_end - css_value_start + 1);
@@ -1570,7 +1570,7 @@
 			const char *pln;
 			int len;
 
-			if ((pln = purple_markup_detect_entity(c, &len)) == NULL) {
+			if ((pln = purple_markup_unescape_entity(c, &len)) == NULL) {
 				len = 1;
 				g_snprintf(buf, sizeof(buf), "%c", *c);
 				pln = buf;
@@ -1775,7 +1775,7 @@
 			visible = TRUE;
 		}
 
-		if (str2[i] == '&' && (ent = purple_markup_detect_entity(str2 + i, &entlen)) != NULL)
+		if (str2[i] == '&' && (ent = purple_markup_unescape_entity(str2 + i, &entlen)) != NULL)
 		{
 			while (*ent)
 				str2[j++] = *ent++;
@@ -2093,7 +2093,7 @@
 			int len;
 			const char *ent;
 
-			if ((ent = purple_markup_detect_entity(c, &len)) != NULL) {
+			if ((ent = purple_markup_unescape_entity(c, &len)) != NULL) {
 				ret = g_string_append(ret, ent);
 				c += len;
 			} else if (!strncmp(c, "<br>", 4)) {