[evolution-rss] coding style and whitespace cleanup



commit a269555bc5a0cdc888bfcb8924aff8b2a2ea4fd3
Author: Lucian Langa <lucilanga gnome org>
Date:   Thu Mar 18 13:54:52 2010 +0200

    coding style and whitespace cleanup

 TODO         |    1 +
 src/misc.c   |  215 ++++++++++++++++++++++++++++++----------------------------
 src/misc.h   |    1 +
 src/parser.c |   33 +++++----
 4 files changed, 131 insertions(+), 119 deletions(-)
---
diff --git a/TODO b/TODO
index 87ee384..04f6262 100644
--- a/TODO
+++ b/TODO
@@ -41,3 +41,4 @@
 	* when delete folder remove any pending filter process
 	* when import opml print opml title
 	* import without fetching (add without validate ?)
+	* do not mark folders as feeds (icon)
diff --git a/src/misc.c b/src/misc.c
index 0dc5589..eb73098 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -49,6 +49,12 @@ on_next_unread_item_activate(gpointer a)
 }
 
 void
+print_list(gpointer data, gpointer user_data)
+{
+	g_print("list element:%s\n", (gchar *)data);
+}
+
+void
 print_hash(gpointer key, gpointer value, gpointer user_data)
 {
 	g_print("key:%s, value:%s\n", (gchar *)key, (gchar *)value);
@@ -258,46 +264,46 @@ strplchr(gchar *source)
 gchar *
 markup_decode (gchar *str)
 {
-        char *iterator, *temp;
-        int cnt = 0;
-        GString *result = g_string_new (NULL);
-
-        g_return_val_if_fail (str != NULL, NULL);
-
-        iterator = str;
-
-        for (cnt = 0, iterator = str;
-             cnt <= (int)(strlen (str));
-             cnt++, iterator++) {
-                if (*iterator == '&') {
-                        int jump = 0;
-                        int i;
-
-                        if (g_ascii_strncasecmp (iterator, "&amp;", 5) == 0) {
-                                g_string_append_c (result, '&');
-                                jump = 5;
-                        } else if (g_ascii_strncasecmp (iterator, "&lt;", 4) == 0) {
-                                g_string_append_c (result, '<');
-                                jump = 4;
-                        } else if (g_ascii_strncasecmp (iterator, "&gt;", 4) == 0) {
-                                g_string_append_c (result, '>');
-                                jump = 4;
-                        } else if (g_ascii_strncasecmp (iterator, "&quot;", 6) == 0) {
-                                g_string_append_c (result, '\"');
-                                jump = 6;
-                        }
-                        for (i = jump - 1; i > 0; i--) {
-                                iterator++;
-                                if (*iterator == '\0')
-                                        break;
-                        }
-                } else {
-                        g_string_append_c (result, *iterator);
-                }
-        }
-        temp = result->str;
-        g_string_free (result, FALSE);
-        return temp;
+	char *iterator, *temp;
+	int cnt = 0;
+	GString *result = g_string_new (NULL);
+
+	g_return_val_if_fail (str != NULL, NULL);
+
+	iterator = str;
+
+	for (cnt = 0, iterator = str;
+	cnt <= (int)(strlen (str));
+	cnt++, iterator++) {
+		if (*iterator == '&') {
+			int jump = 0;
+			int i;
+
+			if (g_ascii_strncasecmp (iterator, "&amp;", 5) == 0) {
+				g_string_append_c (result, '&');
+				jump = 5;
+			} else if (g_ascii_strncasecmp (iterator, "&lt;", 4) == 0) {
+				g_string_append_c (result, '<');
+				jump = 4;
+			} else if (g_ascii_strncasecmp (iterator, "&gt;", 4) == 0) {
+				g_string_append_c (result, '>');
+				jump = 4;
+			} else if (g_ascii_strncasecmp (iterator, "&quot;", 6) == 0) {
+				g_string_append_c (result, '\"');
+				jump = 6;
+			}
+			for (i = jump - 1; i > 0; i--) {
+				iterator++;
+				if (*iterator == '\0')
+					break;
+			}
+		} else {
+			g_string_append_c (result, *iterator);
+		}
+	}
+	temp = result->str;
+	g_string_free (result, FALSE);
+	return temp;
 }
 
 gchar *
@@ -348,53 +354,53 @@ header_decode_lwsp(const char **in)
 	char c;
 
 
-        while ((camel_mime_is_lwsp(*inptr) || *inptr =='(') && *inptr != '\0') {
-                while (camel_mime_is_lwsp(*inptr) && *inptr != '\0') {
-                        inptr++;
-                }
-
-                /* check for comments */
-                if (*inptr == '(') {
-                        int depth = 1;
-                        inptr++;
-                        while (depth && (c=*inptr) && *inptr != '\0') {
-                                if (c=='\\' && inptr[1]) {
-                                        inptr++;
-                                } else if (c=='(') {
-                                        depth++;
-                                } else if (c==')') {
-                                        depth--;
-                                }
-                                inptr++;
-                        }
-                }
-        }
-        *in = inptr;
+	while ((camel_mime_is_lwsp(*inptr) || *inptr =='(') && *inptr != '\0') {
+		while (camel_mime_is_lwsp(*inptr) && *inptr != '\0') {
+			inptr++;
+		}
+
+		/* check for comments */
+		if (*inptr == '(') {
+			int depth = 1;
+			inptr++;
+			while (depth && (c=*inptr) && *inptr != '\0') {
+				if (c=='\\' && inptr[1]) {
+					inptr++;
+				} else if (c=='(') {
+					depth++;
+				} else if (c==')') {
+					depth--;
+				}
+				inptr++;
+			}
+		}
+	}
+	*in = inptr;
 }
 
 char *
 decode_token (const char **in)
 {
-        const char *inptr = *in;
-        const char *start;
-
-        header_decode_lwsp (&inptr);
-        start = inptr;
-        while (camel_mime_is_ttoken (*inptr))
-                inptr++;
-        if (inptr > start) {
-                *in = inptr;
-                return g_strndup (start, inptr - start);
-        } else {
-                return NULL;
-        }
+	const char *inptr = *in;
+	const char *start;
+
+	header_decode_lwsp (&inptr);
+	start = inptr;
+	while (camel_mime_is_ttoken (*inptr))
+		inptr++;
+	if (inptr > start) {
+		*in = inptr;
+		return g_strndup (start, inptr - start);
+	} else {
+		return NULL;
+	}
 }
 
 gchar *extract_main_folder(gchar *folder)
 {
 	gchar *main_folder = lookup_main_folder();
-        gchar *base = g_strdup_printf("%s/", main_folder);
-        gchar **nnew;
+	gchar *base = g_strdup_printf("%s/", main_folder);
+	gchar **nnew;
 	gchar *tmp;
 	if ((nnew = g_strsplit(folder, base, 0))) {
 		g_free(base);
@@ -408,24 +414,24 @@ gchar *extract_main_folder(gchar *folder)
 
 /* hrm, is there a library for this shit? */
 struct {
-        const char *name;
-        int offset;
+	const char *name;
+	int offset;
 } tz_offsets [] = {
-        { "UT", 0 },
-        { "GMT", 0 },
-        { "EST", -500 },        /* these are all US timezones.  bloody yanks */
-        { "EDT", -400 },
-        { "CST", -600 },
-        { "CDT", -500 },
-        { "MST", -700 },
-        { "MDT", -600 },
-        { "PST", -800 },
-        { "PDT", -700 },
-        { "Z", 0 },
-        { "A", -100 },
-        { "M", -1200 },
-        { "N", 100 },
-        { "Y", 1200 },
+	{ "UT", 0 },
+	{ "GMT", 0 },
+	{ "EST", -500 },        /* these are all US timezones.  bloody yanks */
+	{ "EDT", -400 },
+	{ "CST", -600 },
+	{ "CDT", -500 },
+	{ "MST", -700 },
+	{ "MDT", -600 },
+	{ "PST", -800 },
+	{ "PDT", -700 },
+	{ "Z", 0 },
+	{ "A", -100 },
+	{ "M", -1200 },
+	{ "N", 100 },
+	{ "Y", 1200 },
 };
 
 static const char tz_months [][4] = {
@@ -446,20 +452,19 @@ is_rfc822(char *in)
 	gchar *day, *monthname;
 	gboolean foundmonth;
 
-        header_decode_lwsp (&inptr);
+	header_decode_lwsp (&inptr);
 	day =  decode_token(&inptr);
-        if (day)
-        {
+	if (day) {
 		g_free (day);
-                header_decode_lwsp (&inptr);
-                if (*inptr == ',')
-                        inptr++;
-                else
-                        goto notrfc;
+		header_decode_lwsp (&inptr);
+		if (*inptr == ',')
+			inptr++;
+		else
+			goto notrfc;
 	}
-        tm.tm_mday = camel_header_decode_int(&inptr);
-        if (tm.tm_mday == 0)
-                goto notrfc;
+	tm.tm_mday = camel_header_decode_int(&inptr);
+	if (tm.tm_mday == 0)
+		goto notrfc;
 
 	monthname = decode_token(&inptr);
 	foundmonth = FALSE;
diff --git a/src/misc.h b/src/misc.h
index 188ac53..67ba195 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -38,6 +38,7 @@ gchar *sanitize_folder(gchar *text);
 void header_decode_lwsp(const char **in);
 char *decode_token (const char **in);
 gchar *encode_rfc2047(gchar *str);
+void print_list(gpointer data, gpointer user_data);
 void print_hash(gpointer key, gpointer value, gpointer user_data);
 void print_hash_int(gpointer key, gpointer value, gpointer user_data);
 gboolean feed_is_new(gchar *file_name, gchar *needle);
diff --git a/src/parser.c b/src/parser.c
index 45048b7..c8c54b8 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -73,8 +73,12 @@ rss_html_url_decode(const char *html, int len)
 				g_free(feed_dir);
 				return NULL;
 			}
-			tmpurl = camel_url_decode_path(strstr(url, "http:"));
-			xmlSetProp((xmlNodePtr)doc, (xmlChar *)"src", (xmlChar *)tmpurl);
+			tmpurl = camel_url_decode_path(
+					strstr(url, "http:"));
+			xmlSetProp(
+				(xmlNodePtr)doc,
+				(xmlChar *)"src",
+				(xmlChar *)tmpurl);
 			g_free(tmpurl);
 		}
 	}
@@ -83,7 +87,9 @@ rss_html_url_decode(const char *html, int len)
 }
 
 void
-html_set_base(xmlNode *doc, char *base, const char *tag, const char *prop, char *basehref)
+html_set_base(
+	xmlNode *doc, char *base, const char *tag,
+	const char *prop, char *basehref)
 {
 	gchar *url;
 #if LIBSOUP_VERSION < 2003000
@@ -581,15 +587,11 @@ layer_find_tag_prop (xmlNodePtr node,
 		xmlDebugDumpNode (stdout, node, 32);
 		printf("%s.\n", node->name);
 #endif
-		if (node->ns && node->ns->prefix)
-		{
-			for (i=0; i < 1; i++)
-			{
-				if (!strcasecmp ((char *)node->ns->prefix, property_rss_modules[i][1]))
-				{
+		if (node->ns && node->ns->prefix) {
+			for (i=0; i < 1; i++) {
+				if (!strcasecmp ((char *)node->ns->prefix, property_rss_modules[i][1])) {
 					func = (gpointer)property_rss_modules[i][2];
-					if (strcasecmp ((char *)node->ns->prefix, match)==0)
-					{
+					if (strcasecmp ((char *)node->ns->prefix, match)==0) {
 						g_print("URL:%s\n", func(node, search, fail));
 					}
 				}
@@ -868,9 +870,12 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
 	char *p = g_strdup(layer_find (top, "title", "Untitled article"));
 	//firstly try to parse as an ATOM author
 	//process person construct
-	char *q1 = g_strdup(layer_find_innerhtml (top, "author", "name", NULL));
-	char *q2 = g_strdup(layer_find_innerhtml (top, "author", "uri", NULL));
-	char *q3 = g_strdup(layer_find_innerhtml (top, "author", "email", NULL));
+	char *q1 = g_strdup(
+			layer_find_innerhtml (top, "author", "name", NULL));
+	char *q2 = g_strdup(
+			layer_find_innerhtml (top, "author", "uri", NULL));
+	char *q3 = g_strdup(
+			layer_find_innerhtml (top, "author", "email", NULL));
 	if (q1) {
 		q1 = g_strdelimit(q1, "><", ' ');
 		qsafe = encode_rfc2047(q1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]