From 1e23402eb23adf4ecd6c1c6bc83ecf21c8e0a6cd Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sun, 13 Nov 2016 16:59:14 -0800 Subject: Change status_end_element_mismatch to point to closing tag name Previously the error offset pointed to the first mismatching character, which can be confusing especially if the start tag name is a prefix of the end tag name. Instead, move the offset to the first character of the name - that way it should be more obvious that the problem is that the entire name mismatches. Fixes #112. --- src/pugixml.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index dc3e7be..f4fa792 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3346,18 +3346,20 @@ PUGI__NS_BEGIN { ++s; + mark = s; + char_t* name = cursor->name; - if (!name) PUGI__THROW_ERROR(status_end_element_mismatch, s); + if (!name) PUGI__THROW_ERROR(status_end_element_mismatch, mark); while (PUGI__IS_CHARTYPE(*s, ct_symbol)) { - if (*s++ != *name++) PUGI__THROW_ERROR(status_end_element_mismatch, s); + if (*s++ != *name++) PUGI__THROW_ERROR(status_end_element_mismatch, mark); } if (*name) { if (*s == 0 && name[0] == endch && name[1] == 0) PUGI__THROW_ERROR(status_bad_end_element, s); - else PUGI__THROW_ERROR(status_end_element_mismatch, s); + else PUGI__THROW_ERROR(status_end_element_mismatch, mark); } PUGI__POPNODE(); // Pop. -- cgit v1.2.3