summaryrefslogtreecommitdiff
path: root/riscos/save_complete.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-11 17:22:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-03-11 17:22:46 +0000
commitb577562953e0afff4cd37185396565dc58d36fcf (patch)
tree1f1bb060658b7940f11c130a5551f6c053b7e521 /riscos/save_complete.c
parent5ca66d22e42acf8a813fbb889bfa51a40f67012f (diff)
downloadnetsurf-b577562953e0afff4cd37185396565dc58d36fcf.tar.gz
netsurf-b577562953e0afff4cd37185396565dc58d36fcf.tar.bz2
We don't need to reparse the document when saving complete -- the document persists for the lifetime of its content.
Better still would be to perform the serialisation manually, so that we don't need to copy the document at all. svn path=/trunk/netsurf/; revision=6774
Diffstat (limited to 'riscos/save_complete.c')
-rw-r--r--riscos/save_complete.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/riscos/save_complete.c b/riscos/save_complete.c
index e0f4cc6ae..98cddbb44 100644
--- a/riscos/save_complete.c
+++ b/riscos/save_complete.c
@@ -111,7 +111,7 @@ bool save_complete_html(struct content *c, const char *path, bool index)
{
char spath[256];
unsigned int i;
- htmlParserCtxtPtr parser;
+ xmlDocPtr doc;
os_error *error;
if (c->type != CONTENT_HTML)
@@ -201,35 +201,16 @@ bool save_complete_html(struct content *c, const char *path, bool index)
/*save_complete_list_dump();*/
- /* make a copy of the document tree */
- parser = htmlCreateMemoryParserCtxt(c->source_data, c->source_size);
- if (!parser) {
+ /* copy document */
+ doc = xmlCopyDoc(c->data.html.document, 1);
+ if (doc == NULL) {
warn_user("NoMemory", 0);
return false;
}
- /* set parser charset */
- if (c->data.html.encoding) {
- xmlCharEncodingHandler *enc_handler;
- enc_handler =
- xmlFindCharEncodingHandler(c->data.html.encoding);
- if (enc_handler) {
- xmlCtxtResetLastError(parser);
- if (xmlSwitchToEncoding(parser, enc_handler)) {
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
- warn_user("MiscError",
- "Encoding switch failed");
- return false;
- }
- }
- }
-
- htmlParseDocument(parser);
/* rewrite all urls we know about */
- if (!rewrite_document_urls(parser->myDoc, c->data.html.base_url)) {
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
+ if (!rewrite_document_urls(doc, c->data.html.base_url)) {
+ xmlFreeDoc(doc);
warn_user("NoMemory", 0);
return false;
}
@@ -241,14 +222,18 @@ bool save_complete_html(struct content *c, const char *path, bool index)
snprintf(spath, sizeof spath, "%s.%x", path, (unsigned int)c);
errno = 0;
- if (htmlSaveFileFormat(spath, parser->myDoc, 0, 0) == -1) {
+ if (htmlSaveFileFormat(spath, doc, 0, 0) == -1) {
if (errno)
warn_user("SaveError", strerror(errno));
else
warn_user("SaveError", "htmlSaveFileFormat failed");
+
+ xmlFreeDoc(doc);
return false;
}
+ xmlFreeDoc(doc);
+
error = xosfile_set_type(spath, 0xfaf);
if (error) {
LOG(("xosfile_set_type: 0x%x: %s",
@@ -257,9 +242,6 @@ bool save_complete_html(struct content *c, const char *path, bool index)
return false;
}
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
-
return true;
}