From 4d2e3b5f38cbed76ede121bb0ee5ed20d2fc43c9 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 22 Sep 2024 00:39:40 +0200 Subject: [PATCH] tests: Move last remaining handlers from common.{c,h} to handlers.{c,h} --- expat/tests/common.c | 31 +------------------------------ expat/tests/common.h | 9 --------- expat/tests/handlers.c | 27 +++++++++++++++++++++++++++ expat/tests/handlers.h | 9 +++++++++ 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/expat/tests/common.c b/expat/tests/common.c index 26d0c547..799e4990 100644 --- a/expat/tests/common.c +++ b/expat/tests/common.c @@ -51,6 +51,7 @@ #include "chardata.h" #include "minicheck.h" #include "common.h" +#include "handlers.h" /* Common test data */ @@ -221,30 +222,6 @@ _expect_failure(const char *text, enum XML_Error errorCode, _xml_failure(g_parser, file, lineno); } -/* Character data support for handlers, built on top of the code in - * chardata.c - */ -void XMLCALL -accumulate_characters(void *userData, const XML_Char *s, int len) { - CharData_AppendXMLChars((CharData *)userData, s, len); -} - -void XMLCALL -accumulate_attribute(void *userData, const XML_Char *name, - const XML_Char **atts) { - CharData *storage = (CharData *)userData; - UNUSED_P(name); - /* Check there are attributes to deal with */ - if (atts == NULL) - return; - - while (storage->count < 0 && atts[0] != NULL) { - /* "accumulate" the value of the first attribute we see */ - CharData_AppendXMLChars(storage, atts[1], -1); - atts += 2; - } -} - void _run_character_check(const char *text, const XML_Char *expected, const char *file, int line) { @@ -273,12 +250,6 @@ _run_attribute_check(const char *text, const XML_Char *expected, CharData_CheckXMLChars(&storage, expected); } -void XMLCALL -ext_accumulate_characters(void *userData, const XML_Char *s, int len) { - ExtTest *test_data = (ExtTest *)userData; - accumulate_characters(test_data->storage, s, len); -} - void _run_ext_character_check(const char *text, ExtTest *test_data, const XML_Char *expected, const char *file, int line) { diff --git a/expat/tests/common.h b/expat/tests/common.h index 52f00cc0..e0276991 100644 --- a/expat/tests/common.h +++ b/expat/tests/common.h @@ -111,12 +111,6 @@ extern void _expect_failure(const char *text, enum XML_Error errorCode, /* Support functions for handlers to collect up character and attribute data. */ -extern void XMLCALL accumulate_characters(void *userData, const XML_Char *s, - int len); - -extern void XMLCALL accumulate_attribute(void *userData, const XML_Char *name, - const XML_Char **atts); - extern void _run_character_check(const char *text, const XML_Char *expected, const char *file, int line); @@ -135,9 +129,6 @@ typedef struct ExtTest { CharData *storage; } ExtTest; -extern void XMLCALL ext_accumulate_characters(void *userData, const XML_Char *s, - int len); - extern void _run_ext_character_check(const char *text, ExtTest *test_data, const XML_Char *expected, const char *file, int line); diff --git a/expat/tests/handlers.c b/expat/tests/handlers.c index 19d2590a..32ca5889 100644 --- a/expat/tests/handlers.c +++ b/expat/tests/handlers.c @@ -1906,6 +1906,33 @@ accumulate_start_element(void *userData, const XML_Char *name, CharData_AppendXMLChars(storage, XCS(")\n"), 2); } +void XMLCALL +accumulate_characters(void *userData, const XML_Char *s, int len) { + CharData_AppendXMLChars((CharData *)userData, s, len); +} + +void XMLCALL +accumulate_attribute(void *userData, const XML_Char *name, + const XML_Char **atts) { + CharData *storage = (CharData *)userData; + UNUSED_P(name); + /* Check there are attributes to deal with */ + if (atts == NULL) + return; + + while (storage->count < 0 && atts[0] != NULL) { + /* "accumulate" the value of the first attribute we see */ + CharData_AppendXMLChars(storage, atts[1], -1); + atts += 2; + } +} + +void XMLCALL +ext_accumulate_characters(void *userData, const XML_Char *s, int len) { + ExtTest *test_data = (ExtTest *)userData; + accumulate_characters(test_data->storage, s, len); +} + void XMLCALL checking_default_handler(void *userData, const XML_Char *s, int len) { DefaultCheck *data = (DefaultCheck *)userData; diff --git a/expat/tests/handlers.h b/expat/tests/handlers.h index 1865bc2d..8850bb94 100644 --- a/expat/tests/handlers.h +++ b/expat/tests/handlers.h @@ -573,6 +573,15 @@ extern void XMLCALL accumulate_start_element(void *userData, const XML_Char *name, const XML_Char **atts); +extern void XMLCALL accumulate_characters(void *userData, const XML_Char *s, + int len); + +extern void XMLCALL accumulate_attribute(void *userData, const XML_Char *name, + const XML_Char **atts); + +extern void XMLCALL ext_accumulate_characters(void *userData, const XML_Char *s, + int len); + typedef struct default_check { const XML_Char *expected; const int expectedLen;