From 4f2be9d332594f1fdd494437e6f7d5468c1c6022 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Dec 2011 19:55:45 +0000 Subject: Fix string length calculation. git-svn-id: http://svn.drobilla.net/serd/trunk@241 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/reader.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/reader.c b/src/reader.c index 7c083dd6..d718d255 100644 --- a/src/reader.c +++ b/src/reader.c @@ -236,8 +236,7 @@ push_byte(SerdReader* reader, Ref ref, const uint8_t c) serd_stack_push(&reader->stack, 1); SerdNode* const node = deref(reader, ref); ++node->n_bytes; - if ((c & 0xC0) != 0x80) { - // Does not start with `10', start of a new character + if (!(c & 0x80)) { // Starts with 0 bit, start of new character ++node->n_chars; } assert(node->n_bytes >= node->n_chars); @@ -464,7 +463,7 @@ read_character(SerdReader* reader, Ref dest) assert(c != '\\'); // Only called from methods that handle escapes first switch (c) { case '\0': - error(reader, "unexpected end of file\n", peek_byte(reader)); + error(reader, "unexpected end of file\n", c); return SERD_ERR_BAD_SYNTAX; default: if (c < 0x20) { // ASCII control character -- cgit v1.2.1