tests CHANGE nehance xml tests - processing n-bytes UTF characters
diff --git a/src/xml.c b/src/xml.c
index 78b259f..bd26f16 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -168,7 +168,7 @@
* Includes checking for valid characters (following RFC 7950, sec 9.4)
*/
static LY_ERR
-lyxml_pututf8(char *dst, int32_t value, size_t *bytes_written)
+lyxml_pututf8(char *dst, uint32_t value, size_t *bytes_written)
{
if (value < 0x80) {
/* one byte character */
@@ -283,8 +283,8 @@
size_t len; /* write offset in output buffer */
size_t size; /* size of the output buffer */
void *p;
- int32_t n;
- size_t u;
+ uint32_t n;
+ size_t u, newlines;
bool empty_content = false;
LY_ERR rc;
@@ -302,8 +302,13 @@
if (empty_content) {
/* only when processing element's content - try to ignore whitespaces used to format XML data
* before element's child or closing tag */
- for (offset = 0; in[offset] && is_xmlws(in[offset]); ++offset);
+ for (offset = newlines = 0; in[offset] && is_xmlws(in[offset]); ++offset) {
+ if (in[offset] == '\n') {
+ ++newlines;
+ }
+ }
LY_CHECK_ERR_RET(!in[offset], LOGVAL(ctx, LY_VLOG_LINE, &context->line, LY_VCODE_EOF), LY_EVALID);
+ context->line += newlines;
if (in[offset] == '<') {
(*input) = in + offset;
return LY_EINVAL;
@@ -395,7 +400,7 @@
++offset;
rc = lyxml_pututf8(&buf[len], n, &u);
LY_CHECK_ERR_GOTO(rc, LOGVAL(ctx, LY_VLOG_LINE, &context->line, LYVE_SYNTAX,
- "Invalid character reference %.*s (0x%08x).", 12, p, n),
+ "Invalid character reference \"%.*s\" (0x%08x).", 12, p, n),
error);
len += u;
in += offset;