netsurf: branch master updated. ce640e59fdcb178a906cf644f7d45be905e6356d

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Sun Nov 11 11:31:50 GMT 2012


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/ce640e59fdcb178a906cf644f7d45be905e6356d
...commit http://git.netsurf-browser.org/netsurf.git/commit/ce640e59fdcb178a906cf644f7d45be905e6356d
...tree http://git.netsurf-browser.org/netsurf.git/tree/ce640e59fdcb178a906cf644f7d45be905e6356d

The branch, master has been updated
       via  ce640e59fdcb178a906cf644f7d45be905e6356d (commit)
       via  bb3a6bbb3b905287f94575fc3c65e44887b0ff58 (commit)
      from  f2ab822a83537427cbc914dcc5fc575e5ddbaee7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ce640e59fdcb178a906cf644f7d45be905e6356d
commit ce640e59fdcb178a906cf644f7d45be905e6356d
Author: John-Mark Bell <jmb at netsurf-browser.org>
Commit: John-Mark Bell <jmb at netsurf-browser.org>

    Report (and ignore) failure to load non-existent document. (Credit: Chris Young)

diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 6097651..d2701e5 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -728,15 +728,18 @@ bool tree_urlfile_load(const char *filename, struct tree *tree,
 	dom_document *document;
 	dom_node *html, *body, *ul;
 	struct node *root;
+	nserror error;
 	tree_url_load_ctx ctx;
 
 	if (filename == NULL) {
 		return false;
 	}
 
-	document = libdom_parse_file(filename, "iso-8859-1");
-	if (document == NULL) {
-		warn_user("TreeLoadError", messages_get("ParsingFail"));
+	error = libdom_parse_file(filename, "iso-8859-1", &document);
+	if (error != NSERROR_OK) {
+		if (error != NSERROR_NOT_FOUND) {
+			warn_user("TreeLoadError", messages_get("ParsingFail"));
+		}
 		return false;
 	}
 
diff --git a/utils/libdom.c b/utils/libdom.c
index 756465a..ee911c3 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -259,7 +259,7 @@ static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
 }
 
 /* exported interface documented in libdom.h */
-dom_document *libdom_parse_file(const char *filename, const char *encoding)
+nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc)
 {
 	dom_hubbub_error error;
 	dom_hubbub_parser *parser;
@@ -270,14 +270,14 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 
 	fp = fopen(filename, "r");
 	if (fp == NULL) {
-		return NULL;
+		return NSERROR_NOT_FOUND;
 	}
 
 	parser = dom_hubbub_parser_create(encoding, false, false,
 			ignore_dom_msg, NULL, NULL, &document);
 	if (parser == NULL) {
 		fclose(fp);
-		return NULL;
+		return NSERROR_DOM;
 	}
 
 	while (feof(fp) == 0) {
@@ -288,7 +288,7 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 			dom_node_unref(document);
 			dom_hubbub_parser_destroy(parser);
 			fclose(fp);
-			return NULL;
+			return NSERROR_DOM;
 		}
 	}
 
@@ -297,10 +297,11 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 		dom_node_unref(document);
 		dom_hubbub_parser_destroy(parser);
 		fclose(fp);
-		return NULL;
+		return NSERROR_DOM;
 	}
 
 	dom_hubbub_parser_destroy(parser);
 
-	return document;
+	*doc = document;
+	return NSERROR_OK;
 }
diff --git a/utils/libdom.h b/utils/libdom.h
index f2da405..d79c92d 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -62,6 +62,7 @@ typedef bool (*libdom_iterate_cb)(dom_node *node, void *ctx);
 void libdom_iterate_child_elements(dom_node *parent,
 		libdom_iterate_cb cb, void *ctx);
 
-dom_document *libdom_parse_file(const char *filename, const char *encoding);
+nserror libdom_parse_file(const char *filename, const char *encoding,
+		dom_document **doc);
 
 #endif


commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/bb3a6bbb3b905287f94575fc3c65e44887b0ff58
commit bb3a6bbb3b905287f94575fc3c65e44887b0ff58
Author: John-Mark Bell <jmb at netsurf-browser.org>
Commit: John-Mark Bell <jmb at netsurf-browser.org>

    Permit hotlist entries to have no title.

diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 8cc3e05..6097651 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -502,7 +502,7 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
 	}
 
 	derror = dom_node_get_text_content(a, &title1);
-	if (derror != DOM_NO_ERR || title1 == NULL) {
+	if (derror != DOM_NO_ERR) {
 		warn_user("TreeLoadError", "(No title)");
 		dom_node_unref(a);
 		return;
@@ -516,18 +516,20 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
 		return;
 	}
 
-	title = strndup(dom_string_data(title1),
-			dom_string_byte_length(title1));
+	if (title1 != NULL) {
+		title = strndup(dom_string_data(title1),
+				dom_string_byte_length(title1));
+		dom_string_unref(title1);
+	} else {
+		title = strdup("");
+	}
 	if (title == NULL) {
 		warn_user("NoMemory", NULL);
 		dom_string_unref(url1);
-		dom_string_unref(title1);
 		dom_node_unref(a);
 		return;
 	}
 
-	dom_string_unref(title1);
-
 	/* We're loading external input.
 	 * This may be garbage, so attempt to normalise via nsurl
 	 */


-----------------------------------------------------------------------

Summary of changes:
 desktop/tree_url_node.c |   23 ++++++++++++++---------
 utils/libdom.c          |   13 +++++++------
 utils/libdom.h          |    3 ++-
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 8cc3e05..d2701e5 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -502,7 +502,7 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
 	}
 
 	derror = dom_node_get_text_content(a, &title1);
-	if (derror != DOM_NO_ERR || title1 == NULL) {
+	if (derror != DOM_NO_ERR) {
 		warn_user("TreeLoadError", "(No title)");
 		dom_node_unref(a);
 		return;
@@ -516,18 +516,20 @@ static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
 		return;
 	}
 
-	title = strndup(dom_string_data(title1),
-			dom_string_byte_length(title1));
+	if (title1 != NULL) {
+		title = strndup(dom_string_data(title1),
+				dom_string_byte_length(title1));
+		dom_string_unref(title1);
+	} else {
+		title = strdup("");
+	}
 	if (title == NULL) {
 		warn_user("NoMemory", NULL);
 		dom_string_unref(url1);
-		dom_string_unref(title1);
 		dom_node_unref(a);
 		return;
 	}
 
-	dom_string_unref(title1);
-
 	/* We're loading external input.
 	 * This may be garbage, so attempt to normalise via nsurl
 	 */
@@ -726,15 +728,18 @@ bool tree_urlfile_load(const char *filename, struct tree *tree,
 	dom_document *document;
 	dom_node *html, *body, *ul;
 	struct node *root;
+	nserror error;
 	tree_url_load_ctx ctx;
 
 	if (filename == NULL) {
 		return false;
 	}
 
-	document = libdom_parse_file(filename, "iso-8859-1");
-	if (document == NULL) {
-		warn_user("TreeLoadError", messages_get("ParsingFail"));
+	error = libdom_parse_file(filename, "iso-8859-1", &document);
+	if (error != NSERROR_OK) {
+		if (error != NSERROR_NOT_FOUND) {
+			warn_user("TreeLoadError", messages_get("ParsingFail"));
+		}
 		return false;
 	}
 
diff --git a/utils/libdom.c b/utils/libdom.c
index 756465a..ee911c3 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -259,7 +259,7 @@ static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
 }
 
 /* exported interface documented in libdom.h */
-dom_document *libdom_parse_file(const char *filename, const char *encoding)
+nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc)
 {
 	dom_hubbub_error error;
 	dom_hubbub_parser *parser;
@@ -270,14 +270,14 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 
 	fp = fopen(filename, "r");
 	if (fp == NULL) {
-		return NULL;
+		return NSERROR_NOT_FOUND;
 	}
 
 	parser = dom_hubbub_parser_create(encoding, false, false,
 			ignore_dom_msg, NULL, NULL, &document);
 	if (parser == NULL) {
 		fclose(fp);
-		return NULL;
+		return NSERROR_DOM;
 	}
 
 	while (feof(fp) == 0) {
@@ -288,7 +288,7 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 			dom_node_unref(document);
 			dom_hubbub_parser_destroy(parser);
 			fclose(fp);
-			return NULL;
+			return NSERROR_DOM;
 		}
 	}
 
@@ -297,10 +297,11 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding)
 		dom_node_unref(document);
 		dom_hubbub_parser_destroy(parser);
 		fclose(fp);
-		return NULL;
+		return NSERROR_DOM;
 	}
 
 	dom_hubbub_parser_destroy(parser);
 
-	return document;
+	*doc = document;
+	return NSERROR_OK;
 }
diff --git a/utils/libdom.h b/utils/libdom.h
index f2da405..d79c92d 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -62,6 +62,7 @@ typedef bool (*libdom_iterate_cb)(dom_node *node, void *ctx);
 void libdom_iterate_child_elements(dom_node *parent,
 		libdom_iterate_cb cb, void *ctx);
 
-dom_document *libdom_parse_file(const char *filename, const char *encoding);
+nserror libdom_parse_file(const char *filename, const char *encoding,
+		dom_document **doc);
 
 #endif


-- 
NetSurf Browser



More information about the netsurf-commits mailing list