[PATCH] handle c dependicies for files with utf-8 BOM
Evgeniy A. Dushistov
dushistov at mail.ru
Mon Oct 14 03:56:50 EDT 2013
---
Source/cmDependsC.cxx | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index a252a1a..1d05797 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -249,6 +249,14 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
std::ifstream fin(fullName.c_str());
if(fin)
{
+ static const unsigned char UTF8_BOM[3] = {0xEF, 0xBB, 0xBF};
+ unsigned char bom[3];
+ fin.read(reinterpret_cast<char *>(bom), sizeof(bom));
+ if ((fin && !(bom[0] == UTF8_BOM[0] && bom[1] == UTF8_BOM[1] && bom[2] == UTF8_BOM[2])) || !fin)
+ {
+ fin.clear();
+ fin.seekg(0, std::ios::beg);
+ }
// Add this file as a dependency.
dependencies.insert(fullName);
--
1.8.1.5
--vtzGhvizbBRQ85DL--
More information about the cmake-developers
mailing list