summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-04-03 13:27:12 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-04-03 13:27:12 -0700
commit54f87d3b59215348a33483cf12e855af0a362e0e (patch)
tree8eb70258db25abe34cc669296c632ff76415614e /src
parentdba79320000f9934287d6cb5023f59e86696e8ac (diff)
parent0564d55e1911ee51fc407ae3794dceae55cc596d (diff)
Merge pull request #92 from QUSpilPrgm/master
Do not assume that fclose can be converted to int(*)(FILE*)
Diffstat (limited to 'src')
-rw-r--r--src/pugixml.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index c8d72ce..fac9ceb 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -255,6 +255,13 @@ PUGI__NS_BEGIN
return result;
}
};
+
+ // Do not assume that fclose can be converted to int(*)(FILE*) because some
+ // compilers use a special calling convention for stdlib functions like fclose
+ PUGI__FN void auto_deleter_fclose(FILE* File)
+ {
+ fclose(File);
+ }
PUGI__NS_END
#ifdef PUGIXML_COMPACT
@@ -6865,8 +6872,7 @@ namespace pugi
reset();
using impl::auto_deleter; // MSVC7 workaround
- typedef int (*fclose_t)(FILE*); // BCC5 workaround
- auto_deleter<FILE, fclose_t> file(fopen(path_, "rb"), fclose);
+ auto_deleter<FILE> file(fopen(path_, "rb"), impl::auto_deleter_fclose);
return impl::load_file_impl(static_cast<impl::xml_document_struct*>(_root), file.data, options, encoding, &_buffer);
}
@@ -6876,8 +6882,7 @@ namespace pugi
reset();
using impl::auto_deleter; // MSVC7 workaround
- typedef int (*fclose_t)(FILE*); // BCC5 workaround
- auto_deleter<FILE, fclose_t> file(impl::open_file_wide(path_, L"rb"), fclose);
+ auto_deleter<FILE> file(impl::open_file_wide(path_, L"rb"), impl::auto_deleter_fclose);
return impl::load_file_impl(static_cast<impl::xml_document_struct*>(_root), file.data, options, encoding, &_buffer);
}
@@ -6950,8 +6955,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
- typedef int (*fclose_t)(FILE*); // BCC5 workaround
- auto_deleter<FILE, fclose_t> file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), fclose);
+ auto_deleter<FILE> file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::auto_deleter_fclose);
return impl::save_file_impl(*this, file.data, indent, flags, encoding);
}
@@ -6959,8 +6963,7 @@ namespace pugi
PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
{
using impl::auto_deleter; // MSVC7 workaround
- typedef int (*fclose_t)(FILE*); // BCC5 workaround
- auto_deleter<FILE, fclose_t> file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), fclose);
+ auto_deleter<FILE> file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), impl::auto_deleter_fclose);
return impl::save_file_impl(*this, file.data, indent, flags, encoding);
}