aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2020-11-25 09:19:24 -0800
committerGitHub <noreply@github.com>2020-11-25 09:19:24 -0800
commit28aebf2b22f252af8d44955fe45094e5274d71cc (patch)
tree42cbcc589382d20187df42f404cd97ce8f7af8ba
parent30761e48dfbd810912cf94f3eff2c410f371e0ab (diff)
parentdf42668e183b368ad2a7128427bfa3681e45db93 (diff)
downloadpugixml-28aebf2b22f252af8d44955fe45094e5274d71cc.zip
pugixml-28aebf2b22f252af8d44955fe45094e5274d71cc.tar.gz
pugixml-28aebf2b22f252af8d44955fe45094e5274d71cc.tar.bz2
Merge pull request #382 from zeux/TheNicker-master
Fix MSVC deprecation warnings when using clang-cl
-rw-r--r--src/pugixml.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 5a665a3..a74b118 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4981,7 +4981,12 @@ PUGI__NS_BEGIN
#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)))
PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode)
{
+#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
+ FILE* file = 0;
+ return _wfopen_s(&file, path, mode) == 0 ? file : 0;
+#else
return _wfopen(path, mode);
+#endif
}
#else
PUGI__FN char* convert_path_heap(const wchar_t* str)
@@ -5025,6 +5030,16 @@ PUGI__NS_BEGIN
}
#endif
+ PUGI__FN FILE* open_file(const char* path, const char* mode)
+ {
+#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
+ FILE* file = 0;
+ return fopen_s(&file, path, mode) == 0 ? file : 0;
+#else
+ return fopen(path, mode);
+#endif
+ }
+
PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding)
{
if (!file) return false;
@@ -7187,7 +7202,7 @@ namespace pugi
reset();
using impl::auto_deleter; // MSVC7 workaround
- auto_deleter<FILE> file(fopen(path_, "rb"), impl::close_file);
+ auto_deleter<FILE> file(impl::open_file(path_, "rb"), impl::close_file);
return impl::load_file_impl(static_cast<impl::xml_document_struct*>(_root), file.data, options, encoding, &_buffer);
}
@@ -7270,7 +7285,7 @@ namespace pugi
PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
{
using impl::auto_deleter; // MSVC7 workaround
- auto_deleter<FILE> file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);
+ auto_deleter<FILE> file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);
return impl::save_file_impl(*this, file.data, indent, flags, encoding);
}