summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/hubbub/functypes.h3
-rw-r--r--src/tokeniser/tokeniser.c6
-rw-r--r--src/treebuilder/internal.h3
-rw-r--r--src/treebuilder/treebuilder.c6
-rw-r--r--test/parser.c6
-rw-r--r--test/tokeniser.c6
-rw-r--r--test/tokeniser2.c8
-rw-r--r--test/tokeniser3.c8
8 files changed, 30 insertions, 16 deletions
diff --git a/include/hubbub/functypes.h b/include/hubbub/functypes.h
index c6dbee2..d41f6bd 100644
--- a/include/hubbub/functypes.h
+++ b/include/hubbub/functypes.h
@@ -20,7 +20,8 @@ typedef void *(*hubbub_alloc)(void *ptr, size_t size, void *pw);
/**
* Type of token handling function
*/
-typedef void (*hubbub_token_handler)(const hubbub_token *token, void *pw);
+typedef hubbub_error (*hubbub_token_handler)(
+ const hubbub_token *token, void *pw);
/**
* Type of parse error handling function
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c
index 73f7bf6..a4d7046 100644
--- a/src/tokeniser/tokeniser.c
+++ b/src/tokeniser/tokeniser.c
@@ -3023,12 +3023,14 @@ hubbub_error emit_current_doctype(hubbub_tokeniser *tokeniser,
hubbub_error hubbub_tokeniser_emit_token(hubbub_tokeniser *tokeniser,
hubbub_token *token)
{
+ hubbub_error err = HUBBUB_OK;
+
assert(tokeniser != NULL);
assert(token != NULL);
/* Emit the token */
if (tokeniser->token_handler) {
- tokeniser->token_handler(token, tokeniser->token_pw);
+ err = tokeniser->token_handler(token, tokeniser->token_pw);
}
/* Discard current buffer */
@@ -3044,5 +3046,5 @@ hubbub_error hubbub_tokeniser_emit_token(hubbub_tokeniser *tokeniser,
tokeniser->context.pending = 0;
}
- return HUBBUB_OK;
+ return err;
}
diff --git a/src/treebuilder/internal.h b/src/treebuilder/internal.h
index 059e177..c63ee99 100644
--- a/src/treebuilder/internal.h
+++ b/src/treebuilder/internal.h
@@ -115,7 +115,8 @@ struct hubbub_treebuilder
void *alloc_pw; /**< Client private data */
};
-void hubbub_treebuilder_token_handler(const hubbub_token *token, void *pw);
+hubbub_error hubbub_treebuilder_token_handler(
+ const hubbub_token *token, void *pw);
bool process_characters_expect_whitespace(
hubbub_treebuilder *treebuilder, const hubbub_token *token,
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index 95a05b5..8bc9d52 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -251,7 +251,7 @@ hubbub_error hubbub_treebuilder_setopt(hubbub_treebuilder *treebuilder,
* \param token The emitted token
* \param pw Pointer to treebuilder instance
*/
-void hubbub_treebuilder_token_handler(const hubbub_token *token,
+hubbub_error hubbub_treebuilder_token_handler(const hubbub_token *token,
void *pw)
{
hubbub_treebuilder *treebuilder = (hubbub_treebuilder *) pw;
@@ -260,7 +260,7 @@ void hubbub_treebuilder_token_handler(const hubbub_token *token,
/* Do nothing if we have no document node or there's no tree handler */
if (treebuilder->context.document == NULL ||
treebuilder->tree_handler == NULL)
- return;
+ return HUBBUB_OK;
assert((signed) treebuilder->context.current_node >= 0);
@@ -348,6 +348,8 @@ void hubbub_treebuilder_token_handler(const hubbub_token *token,
break;
}
}
+
+ return HUBBUB_OK;
}
diff --git a/test/parser.c b/test/parser.c
index 63e39ff..1ab77d7 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -10,7 +10,7 @@
#include "testutils.h"
-static void token_handler(const hubbub_token *token, void *pw);
+static hubbub_error token_handler(const hubbub_token *token, void *pw);
static void *myrealloc(void *ptr, size_t len, void *pw)
{
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
return 0;
}
-void token_handler(const hubbub_token *token, void *pw)
+hubbub_error token_handler(const hubbub_token *token, void *pw)
{
static const char *token_names[] = {
"DOCTYPE", "START TAG", "END TAG",
@@ -170,4 +170,6 @@ void token_handler(const hubbub_token *token, void *pw)
printf("\n");
break;
}
+
+ return HUBBUB_OK;
}
diff --git a/test/tokeniser.c b/test/tokeniser.c
index 0ccf264..77635bc 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -11,7 +11,7 @@
#include "testutils.h"
-static void token_handler(const hubbub_token *token, void *pw);
+static hubbub_error token_handler(const hubbub_token *token, void *pw);
static void *myrealloc(void *ptr, size_t len, void *pw)
{
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
return 0;
}
-void token_handler(const hubbub_token *token, void *pw)
+hubbub_error token_handler(const hubbub_token *token, void *pw)
{
static const char *token_names[] = {
"DOCTYPE", "START TAG", "END TAG",
@@ -177,4 +177,6 @@ void token_handler(const hubbub_token *token, void *pw)
printf("\n");
break;
}
+
+ return HUBBUB_OK;
}
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index 2b9e739..3dee590 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -30,7 +30,7 @@ typedef struct context {
} context;
static void run_test(context *ctx);
-static void token_handler(const hubbub_token *token, void *pw);
+static hubbub_error token_handler(const hubbub_token *token, void *pw);
static void *myrealloc(void *ptr, size_t len, void *pw)
{
@@ -219,7 +219,7 @@ void run_test(context *ctx)
}
}
-void token_handler(const hubbub_token *token, void *pw)
+hubbub_error token_handler(const hubbub_token *token, void *pw)
{
static const char *token_names[] = {
"DOCTYPE", "StartTag", "EndTag",
@@ -255,7 +255,7 @@ void token_handler(const hubbub_token *token, void *pw)
/* Got a terminating EOF -- no error */
if (ctx->output_index >= array_list_length(ctx->output))
- return;
+ return HUBBUB_OK;
/* Now increment the output index so we don't re-expect this token */
ctx->output_index++;
@@ -477,4 +477,6 @@ void token_handler(const hubbub_token *token, void *pw)
printf("\n");
break;
}
+
+ return HUBBUB_OK;
}
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index e67b047..8febda9 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -28,7 +28,7 @@ typedef struct context {
} context;
static void run_test(context *ctx);
-static void token_handler(const hubbub_token *token, void *pw);
+static hubbub_error token_handler(const hubbub_token *token, void *pw);
static void *myrealloc(void *ptr, size_t len, void *pw)
{
@@ -221,7 +221,7 @@ void run_test(context *ctx)
}
}
-void token_handler(const hubbub_token *token, void *pw)
+hubbub_error token_handler(const hubbub_token *token, void *pw)
{
static const char *token_names[] = {
"DOCTYPE", "StartTag", "EndTag",
@@ -257,7 +257,7 @@ void token_handler(const hubbub_token *token, void *pw)
/* Got a terminating EOF -- no error */
if (ctx->output_index >= array_list_length(ctx->output))
- return;
+ return HUBBUB_OK;
/* Now increment the output index so we don't re-expect this token */
ctx->output_index++;
@@ -483,4 +483,6 @@ void token_handler(const hubbub_token *token, void *pw)
printf("\n");
break;
}
+
+ return HUBBUB_OK;
}