mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Trim lines when reading from .cquery file.
Otherwise there may be newlines and the like.
This commit is contained in:
parent
95203bffd4
commit
9e6d33689f
@ -52,10 +52,15 @@ static std::vector<std::string> kBlacklistMulti = {
|
||||
|
||||
// Blacklisted flags which are always removed from the command line.
|
||||
static std::vector<std::string> kBlacklist = {
|
||||
"-c", "-MP", "-MD", "-MMD", "--fcolor-diagnostics",
|
||||
"-c",
|
||||
"-MP",
|
||||
"-MD",
|
||||
"-MMD",
|
||||
"--fcolor-diagnostics",
|
||||
|
||||
// This strips path-like args but is a bit hacky.
|
||||
"/", "..",
|
||||
"/",
|
||||
"..",
|
||||
};
|
||||
|
||||
// Arguments which are followed by a potentially relative path. We need to make
|
||||
@ -207,7 +212,9 @@ std::vector<Project::Entry> LoadFromDirectoryListing(ProjectConfig* config) {
|
||||
|
||||
std::vector<std::string> args;
|
||||
std::cerr << "Using arguments: ";
|
||||
for (const std::string& line : ReadLines(config->project_dir + "/.cquery")) {
|
||||
for (std::string line :
|
||||
ReadLinesWithEnding(config->project_dir + "/.cquery")) {
|
||||
Trim(line);
|
||||
if (line.empty() || StartsWith(line, "#"))
|
||||
continue;
|
||||
if (!args.empty())
|
||||
|
@ -245,7 +245,7 @@ optional<std::string> ReadContent(const std::string& filename) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ReadLines(std::string filename) {
|
||||
std::vector<std::string> ReadLinesWithEnding(std::string filename) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
std::ifstream input(filename);
|
||||
@ -296,7 +296,7 @@ std::unordered_map<std::string, std::string> ParseTestExpectation(
|
||||
std::string active_output_filename;
|
||||
std::string active_output_contents;
|
||||
|
||||
for (std::string line_with_ending : ReadLines(filename)) {
|
||||
for (std::string line_with_ending : ReadLinesWithEnding(filename)) {
|
||||
if (StartsWith(line_with_ending, "*/"))
|
||||
break;
|
||||
|
||||
|
@ -74,7 +74,7 @@ void EnsureEndsInSlash(std::string& path);
|
||||
std::string EscapeFileName(std::string path);
|
||||
|
||||
optional<std::string> ReadContent(const std::string& filename);
|
||||
std::vector<std::string> ReadLines(std::string filename);
|
||||
std::vector<std::string> ReadLinesWithEnding(std::string filename);
|
||||
std::vector<std::string> ToLines(const std::string& content,
|
||||
bool trim_whitespace);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user