mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 05:56:03 +01:00
Dump the whole file when scaning its content
Dumping the fstream to a string just dumps a certain number of bits of it, causing some references to be missed
This commit is contained in:
parent
5d47c37cbc
commit
93739ce006
1 changed files with 12 additions and 8 deletions
|
|
@ -197,15 +197,19 @@ TraceResult followPathsToStore(GlobalOpts opts, set<fs::path> roots)
|
|||
*/
|
||||
void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res)
|
||||
{
|
||||
std::ifstream fs;
|
||||
fs.open(fileToScan);
|
||||
std::string content;
|
||||
fs >> content;
|
||||
auto fileEnd = std::sregex_iterator();
|
||||
std::ostringstream contentStream;
|
||||
{
|
||||
std::ifstream fs;
|
||||
fs.open(fileToScan);
|
||||
fs >> contentStream.rdbuf();
|
||||
}
|
||||
std::string content = contentStream.str();
|
||||
auto regex = storePathRegex(opts.storeDir);
|
||||
auto firstMatch = std::sregex_iterator(content.begin(), content.end(), regex);
|
||||
for (auto & i = firstMatch; i != fileEnd; i++)
|
||||
res[i->str()].insert(fileToScan);
|
||||
auto firstMatch
|
||||
= std::sregex_iterator { content.begin(), content.end(), regex };
|
||||
auto fileEnd = std::sregex_iterator{};
|
||||
for (auto i = firstMatch; i != fileEnd; ++i)
|
||||
res[i->str()].emplace(fileToScan);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue