[cfe-commits] r138671 - /cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Aug 26 15:40:55 PDT 2011
Author: akirtzidis
Date: Fri Aug 26 17:40:55 2011
New Revision: 138671
URL: http://llvm.org/viewvc/llvm-project?rev=138671&view=rev
Log:
[arcmt] Fix horrible bug where migrating files if there is a space in the paths
of the migrated files. rdar://10022801
Modified:
cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=138671&r1=138670&r2=138671&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Fri Aug 26 17:40:55 2011
@@ -59,21 +59,22 @@
return false;
std::vector<std::pair<const FileEntry *, const FileEntry *> > pairs;
-
- std::ifstream fin(infoFile.c_str());
- if (!fin.good())
+
+ llvm::OwningPtr<llvm::MemoryBuffer> fileBuf;
+ if (llvm::error_code ec = llvm::MemoryBuffer::getFile(infoFile.c_str(),
+ fileBuf))
return report(std::string("Error opening file: ") + infoFile, Diag);
-
- while (true) {
- std::string fromFilename, toFilename;
+
+ SmallVector<StringRef, 64> lines;
+ fileBuf->getBuffer().split(lines, "\n");
+
+ unsigned idx = 0;
+ while (idx+3 <= lines.size()) {
+ std::string fromFilename = lines[idx];
uint64_t timeModified;
-
- fin >> fromFilename >> timeModified >> toFilename;
- if (fin.eof())
- break;
- if (!fin.good())
- return report(std::string("Error in format of file: ") + infoFile, Diag);
-
+ lines[idx+1].getAsInteger(10, timeModified);
+ std::string toFilename = lines[idx+2];
+
const FileEntry *origFE = FileMgr->getFile(fromFilename);
if (!origFE) {
if (ignoreIfFilesChanged)
@@ -94,6 +95,8 @@
}
pairs.push_back(std::make_pair(origFE, newFE));
+
+ idx += 3;
}
for (unsigned i = 0, e = pairs.size(); i != e; ++i)
More information about the cfe-commits
mailing list