diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-09 19:04:30 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-09 19:04:30 +0000 |
commit | 8a16d5942b9afbdf56451b60fb11b3461fa3fbb4 (patch) | |
tree | 0054012dbc10cd44b30c92981c9264feea32ceb2 /render/html.c | |
parent | 3b6476130da62806c1bce7f3b30da299779f8bd9 (diff) | |
download | netsurf-8a16d5942b9afbdf56451b60fb11b3461fa3fbb4.tar.gz netsurf-8a16d5942b9afbdf56451b60fb11b3461fa3fbb4.tar.bz2 |
Port to new hubbub parser API
svn path=/trunk/netsurf/; revision=5669
Diffstat (limited to 'render/html.c')
-rw-r--r-- | render/html.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/render/html.c b/render/html.c index 00f2d7615..e45d77e4d 100644 --- a/render/html.c +++ b/render/html.c @@ -104,6 +104,7 @@ bool html_create(struct content *c, const char *params[]) unsigned int i; struct content_html_data *html = &c->data.html; union content_msg_data msg_data; + binding_error error; html->parser_binding = NULL; html->document = 0; @@ -131,22 +132,28 @@ bool html_create(struct content *c, const char *params[]) for (i = 0; params[i]; i += 2) { if (strcasecmp(params[i], "charset") == 0) { html->encoding = talloc_strdup(c, params[i + 1]); - if (!html->encoding) - goto no_memory; + if (!html->encoding) { + error = BINDING_NOMEM; + goto error; + } html->encoding_source = ENCODING_SOURCE_HEADER; break; } } /* Create the parser binding */ - html->parser_binding = binding_create_tree(c, html->encoding); - if (!html->parser_binding) - goto no_memory; + error = binding_create_tree(c, html->encoding, &html->parser_binding); + if (error != BINDING_OK) + goto error; return true; -no_memory: - msg_data.error = messages_get("NoMemory"); +error: + if (error == BINDING_BADENCODING) + msg_data.error = messages_get("BadEncoding"); + else + msg_data.error = messages_get("NoMemory"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); return false; } @@ -206,12 +213,15 @@ encoding_change: binding_destroy_tree(c->data.html.parser_binding); /* Create new binding, using the new encoding */ - c->data.html.parser_binding = binding_create_tree(c, - c->data.html.encoding); - if (!c->data.html.parser_binding) { + err = binding_create_tree(c, c->data.html.encoding, + &c->data.html.parser_binding); + if (err != BINDING_OK) { union content_msg_data msg_data; - msg_data.error = messages_get("NoMemory"); + if (err == BINDING_BADENCODING) + msg_data.error = messages_get("BadEncoding"); + else + msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); return false; } |