From 809f992f83d46abbb876ac0bcc82effa210ae508 Mon Sep 17 00:00:00 2001
From: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Date: Sat, 17 Oct 2015 10:51:20 -0700
Subject: Fix MSVC6 header-only build

name_sentry dtor results in multiple symbol definition errors in MSVC6.
---
 src/pugixml.cpp | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

(limited to 'src')

diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 9bb054e..9cbce7c 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4891,6 +4891,22 @@ PUGI__NS_BEGIN
 
 		return ferror(file) == 0;
 	}
+
+	struct name_null_sentry
+	{
+		xml_node_struct* node;
+		char_t* name;
+
+		name_null_sentry(xml_node_struct* node): node(node), name(node->name)
+		{
+			node->name = 0;
+		}
+
+		~name_null_sentry()
+		{
+			node->name = name;
+		}
+	};
 PUGI__NS_END
 
 namespace pugi
@@ -5920,17 +5936,7 @@ namespace pugi
 		doc->extra_buffers = extra;
 
 		// name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level
-		struct name_sentry
-		{
-			xml_node_struct* node;
-			char_t* name;
-
-			~name_sentry() { node->name = name; }
-		};
-
-		name_sentry sentry = { _root, _root->name };
-
-		sentry.node->name = 0;
+		impl::name_null_sentry sentry(_root);
 
 		return impl::load_buffer_impl(doc, _root, const_cast<void*>(contents), size, options, encoding, false, false, &extra->buffer);
 	}
-- 
cgit v1.2.3