Add missing braces around statements.

Apply fixits of clang-tidy's readability-braces-around-statements
checker.
This commit is contained in:
Daniel Pfeifer 2016-06-10 18:36:24 +02:00
parent bd9e551c1a
commit a16bf141bc
26 changed files with 198 additions and 105 deletions

View File

@ -345,18 +345,21 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent(
const std::string& projectName, const std::string& componentName) const std::string& projectName, const std::string& componentName)
{ {
ComponentsMap::iterator cit = Components.find(componentName); ComponentsMap::iterator cit = Components.find(componentName);
if (cit != Components.end()) if (cit != Components.end()) {
return &(cit->second); return &(cit->second);
}
cmCPackComponent* component = cmCPackComponent* component =
cmCPackGenerator::GetComponent(projectName, componentName); cmCPackGenerator::GetComponent(projectName, componentName);
if (!component) if (!component) {
return component; return component;
}
std::string name = GetComponentPackageName(component); std::string name = GetComponentPackageName(component);
PackagesMap::iterator pit = Packages.find(name); PackagesMap::iterator pit = Packages.find(name);
if (pit != Packages.end()) if (pit != Packages.end()) {
return component; return component;
}
cmCPackIFWPackage* package = &Packages[name]; cmCPackIFWPackage* package = &Packages[name];
package->Name = name; package->Name = name;
@ -387,13 +390,15 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
{ {
cmCPackComponentGroup* group = cmCPackComponentGroup* group =
cmCPackGenerator::GetComponentGroup(projectName, groupName); cmCPackGenerator::GetComponentGroup(projectName, groupName);
if (!group) if (!group) {
return group; return group;
}
std::string name = GetGroupPackageName(group); std::string name = GetGroupPackageName(group);
PackagesMap::iterator pit = Packages.find(name); PackagesMap::iterator pit = Packages.find(name);
if (pit != Packages.end()) if (pit != Packages.end()) {
return group; return group;
}
cmCPackIFWPackage* package = &Packages[name]; cmCPackIFWPackage* package = &Packages[name];
package->Name = name; package->Name = name;
@ -462,8 +467,9 @@ std::string cmCPackIFWGenerator::GetGroupPackageName(
cmCPackComponentGroup* group) const cmCPackComponentGroup* group) const
{ {
std::string name; std::string name;
if (!group) if (!group) {
return name; return name;
}
if (cmCPackIFWPackage* package = GetGroupPackage(group)) { if (cmCPackIFWPackage* package = GetGroupPackage(group)) {
return package->Name; return package->Name;
} }
@ -488,8 +494,9 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
cmCPackComponent* component) const cmCPackComponent* component) const
{ {
std::string name; std::string name;
if (!component) if (!component) {
return name; return name;
}
if (cmCPackIFWPackage* package = GetComponentPackage(component)) { if (cmCPackIFWPackage* package = GetComponentPackage(component)) {
return package->Name; return package->Name;
} }
@ -534,8 +541,9 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
const std::string& repositoryName) const std::string& repositoryName)
{ {
RepositoriesMap::iterator rit = Repositories.find(repositoryName); RepositoriesMap::iterator rit = Repositories.find(repositoryName);
if (rit != Repositories.end()) if (rit != Repositories.end()) {
return &(rit->second); return &(rit->second);
}
cmCPackIFWRepository* repository = &Repositories[repositoryName]; cmCPackIFWRepository* repository = &Repositories[repositoryName];
repository->Name = repositoryName; repository->Name = repositoryName;

View File

@ -343,6 +343,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout) void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout)
{ {
if (Generator) if (Generator) {
Generator->WriteGeneratedByToStrim(xout); Generator->WriteGeneratedByToStrim(xout);
}
} }

View File

@ -71,8 +71,9 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct(
std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
{ {
if (Compare.Type == CompareNone) if (Compare.Type == CompareNone) {
return Name; return Name;
}
std::string result = Name; std::string result = Name;
@ -128,8 +129,9 @@ bool cmCPackIFWPackage::IsVersionEqual(const char* version)
std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component) std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
{ {
if (!component) if (!component) {
return ""; return "";
}
const char* option = const char* option =
GetOption("CPACK_IFW_COMPONENT_" + GetOption("CPACK_IFW_COMPONENT_" +
cmsys::SystemTools::UpperCase(component->Name) + "_NAME"); cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
@ -189,8 +191,9 @@ int cmCPackIFWPackage::ConfigureFromOptions()
int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
{ {
if (!component) if (!component) {
return 0; return 0;
}
// Restore defaul configuration // Restore defaul configuration
DefaultConfiguration(); DefaultConfiguration();
@ -284,8 +287,9 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
{ {
if (!group) if (!group) {
return 0; return 0;
}
// Restore defaul configuration // Restore defaul configuration
DefaultConfiguration(); DefaultConfiguration();
@ -474,6 +478,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout) void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
{ {
if (Generator) if (Generator) {
Generator->WriteGeneratedByToStrim(xout); Generator->WriteGeneratedByToStrim(xout);
}
} }

View File

@ -89,8 +89,9 @@ bool cmCPackIFWRepository::IsVersionEqual(const char* version)
bool cmCPackIFWRepository::ConfigureFromOptions() bool cmCPackIFWRepository::ConfigureFromOptions()
{ {
// Name; // Name;
if (Name.empty()) if (Name.empty()) {
return false; return false;
}
std::string prefix = std::string prefix =
"CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(Name) + "_"; "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(Name) + "_";
@ -198,8 +199,9 @@ protected:
patched = true; patched = true;
} }
xout.EndElement(); xout.EndElement();
if (patched) if (patched) {
return; return;
}
if (name == "Checksum") { if (name == "Checksum") {
repository->WriteRepositoryUpdates(xout); repository->WriteRepositoryUpdates(xout);
patched = true; patched = true;
@ -209,8 +211,10 @@ protected:
virtual void CharacterDataHandler(const char* data, int length) virtual void CharacterDataHandler(const char* data, int length)
{ {
std::string content(data, data + length); std::string content(data, data + length);
if (content == "" || content == " " || content == " " || content == "\n") if (content == "" || content == " " || content == " " ||
content == "\n") {
return; return;
}
xout.Content(content); xout.Content(content);
} }
}; };
@ -332,6 +336,7 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout)
void cmCPackIFWRepository::WriteGeneratedByToStrim(cmXMLWriter& xout) void cmCPackIFWRepository::WriteGeneratedByToStrim(cmXMLWriter& xout)
{ {
if (Generator) if (Generator) {
Generator->WriteGeneratedByToStrim(xout); Generator->WriteGeneratedByToStrim(xout);
}
} }

View File

@ -826,8 +826,9 @@ static int copy_ar(CF* cfp, off_t size)
size_t nr, nw; size_t nr, nw;
char buf[8 * 1024]; char buf[8 * 1024];
if (sz == 0) if (sz == 0) {
return 0; return 0;
}
FILE* from = cfp->rFile; FILE* from = cfp->rFile;
FILE* to = cfp->wFile; FILE* to = cfp->wFile;
@ -837,16 +838,20 @@ static int copy_ar(CF* cfp, off_t size)
: sizeof(buf), : sizeof(buf),
from)) > 0) { from)) > 0) {
sz -= nr; sz -= nr;
for (size_t off = 0; off < nr; nr -= off, off += nw) for (size_t off = 0; off < nr; nr -= off, off += nw) {
if ((nw = fwrite(buf + off, 1, nr, to)) < nr) if ((nw = fwrite(buf + off, 1, nr, to)) < nr) {
return -1; return -1;
}
}
} }
if (sz) if (sz) {
return -2; return -2;
}
if (cfp->flags & WPAD && (size + ar_already_written) & 1 && if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
fwrite(&pad, 1, 1, to) != 1) fwrite(&pad, 1, 1, to) != 1) {
return -4; return -4;
}
return 0; return 0;
} }
@ -874,11 +879,11 @@ static int put_arobj(CF* cfp, struct stat* sb)
if (gid > USHRT_MAX) { if (gid > USHRT_MAX) {
gid = USHRT_MAX; gid = USHRT_MAX;
} }
if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) {
(void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
(unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode, (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
(long long)sb->st_size + lname, ARFMAG); (long long)sb->st_size + lname, ARFMAG);
else { } else {
lname = 0; lname = 0;
(void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid, (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
(unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size, (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
@ -886,12 +891,14 @@ static int put_arobj(CF* cfp, struct stat* sb)
} }
off_t size = sb->st_size; off_t size = sb->st_size;
if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) {
return -1; return -1;
}
if (lname) { if (lname) {
if (fwrite(name, 1, lname, cfp->wFile) != lname) if (fwrite(name, 1, lname, cfp->wFile) != lname) {
return -2; return -2;
}
ar_already_written = lname; ar_already_written = lname;
} }
result = copy_ar(cfp, size); result = copy_ar(cfp, size);

View File

@ -61,8 +61,9 @@ extern "C" int cmBZRXMLParserUnknownEncodingHandler(void*,
// workaround for these unknown encodings. // workaround for these unknown encodings.
if (name == std::string("ascii") || name == std::string("cp1252") || if (name == std::string("ascii") || name == std::string("cp1252") ||
name == std::string("ANSI_X3.4-1968")) { name == std::string("ANSI_X3.4-1968")) {
for (unsigned int i = 0; i < 256; ++i) for (unsigned int i = 0; i < 256; ++i) {
info->map[i] = latin1[i]; info->map[i] = latin1[i];
}
return 1; return 1;
} }
@ -336,8 +337,9 @@ private:
void DoPath(char c0, char c1, char c2, std::string path) void DoPath(char c0, char c1, char c2, std::string path)
{ {
if (path.empty()) if (path.empty()) {
return; return;
}
cmSystemTools::ConvertToUnixSlashes(path); cmSystemTools::ConvertToUnixSlashes(path);
const std::string dir = cmSystemTools::GetFilenamePath(path); const std::string dir = cmSystemTools::GetFilenamePath(path);
@ -441,8 +443,9 @@ private:
void DoPath(char c0, char c1, char c2, std::string path) void DoPath(char c0, char c1, char c2, std::string path)
{ {
if (path.empty()) if (path.empty()) {
return; return;
}
cmSystemTools::ConvertToUnixSlashes(path); cmSystemTools::ConvertToUnixSlashes(path);
if (c0 == 'C') { if (c0 == 'C') {

View File

@ -75,8 +75,9 @@ private:
void DoPath(char status, std::string const& path) void DoPath(char status, std::string const& path)
{ {
if (path.empty()) if (path.empty()) {
return; return;
}
// See "hg help status". Note that there is no 'conflict' status. // See "hg help status". Note that there is no 'conflict' status.
switch (status) { switch (status) {

View File

@ -413,12 +413,14 @@ void cmCTestMultiProcessHandler::UpdateCostData()
std::string line; std::string line;
while (std::getline(fin, line)) { while (std::getline(fin, line)) {
if (line == "---") if (line == "---") {
break; break;
}
std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' '); std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
// Format: <name> <previous_runs> <avg_cost> // Format: <name> <previous_runs> <avg_cost>
if (parts.size() < 3) if (parts.size() < 3) {
break; break;
}
std::string name = parts[0]; std::string name = parts[0];
int prev = atoi(parts[1].c_str()); int prev = atoi(parts[1].c_str());
@ -464,8 +466,9 @@ void cmCTestMultiProcessHandler::ReadCostData()
fin.open(fname.c_str()); fin.open(fname.c_str());
std::string line; std::string line;
while (std::getline(fin, line)) { while (std::getline(fin, line)) {
if (line == "---") if (line == "---") {
break; break;
}
std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' '); std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
@ -480,8 +483,9 @@ void cmCTestMultiProcessHandler::ReadCostData()
float cost = static_cast<float>(atof(parts[2].c_str())); float cost = static_cast<float>(atof(parts[2].c_str()));
int index = this->SearchByName(name); int index = this->SearchByName(name);
if (index == -1) if (index == -1) {
continue; continue;
}
this->Properties[index]->PreviousRuns = prev; this->Properties[index]->PreviousRuns = prev;
// When not running in parallel mode, don't use cost data // When not running in parallel mode, don't use cost data

View File

@ -426,8 +426,9 @@ void cmCTestP4::LoadRevisions()
ChangeLists.clear(); ChangeLists.clear();
this->RunChild(&p4_changes[0], &out, &err); this->RunChild(&p4_changes[0], &out, &err);
if (ChangeLists.empty()) if (ChangeLists.empty()) {
return; return;
}
// p4 describe -s ...@1111111,2222222 // p4 describe -s ...@1111111,2222222
std::vector<char const*> p4_describe; std::vector<char const*> p4_describe;

View File

@ -271,8 +271,9 @@ bool cmCTestSVN::UpdateImpl()
bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
OutputParser* out, OutputParser* err) OutputParser* out, OutputParser* err)
{ {
if (parameters.empty()) if (parameters.empty()) {
return false; return false;
}
std::vector<char const*> args; std::vector<char const*> args;
args.push_back(this->CommandLineTool.c_str()); args.push_back(this->CommandLineTool.c_str());

View File

@ -54,9 +54,9 @@ void cmCursesLongMessageForm::UpdateStatusBar()
size = cmCursesMainForm::MAX_WIDTH - 1; size = cmCursesMainForm::MAX_WIDTH - 1;
} }
strncpy(bar, this->Title.c_str(), size); strncpy(bar, this->Title.c_str(), size);
for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++) for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++) {
bar[i] = ' '; bar[i] = ' ';
}
int width; int width;
if (x < cmCursesMainForm::MAX_WIDTH) { if (x < cmCursesMainForm::MAX_WIDTH) {
width = x; width = x;

View File

@ -71,8 +71,9 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
while (*realbuffer != '0' && while (*realbuffer != '0' &&
(*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' || (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' ||
*realbuffer == '\n')) { *realbuffer == '\n')) {
if (*realbuffer == '\n') if (*realbuffer == '\n') {
lineno++; lineno++;
}
realbuffer++; realbuffer++;
} }
// skip blank lines and comment lines // skip blank lines and comment lines

View File

@ -158,7 +158,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
this->HeaderLocationCache.find(current.FileName); this->HeaderLocationCache.find(current.FileName);
if (headerLocationIt != this->HeaderLocationCache.end()) { if (headerLocationIt != this->HeaderLocationCache.end()) {
fullName = headerLocationIt->second; fullName = headerLocationIt->second;
} else } else {
for (std::vector<std::string>::const_iterator i = for (std::vector<std::string>::const_iterator i =
this->IncludePath.begin(); this->IncludePath.begin();
i != this->IncludePath.end(); ++i) { i != this->IncludePath.end(); ++i) {
@ -175,6 +175,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
break; break;
} }
} }
}
} }
// Complain if the file cannot be found and matches the complain // Complain if the file cannot be found and matches the complain

View File

@ -1348,8 +1348,9 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
fpath += ".app"; fpath += ".app";
if (!this->Makefile->PlatformIsAppleIos()) { if (!this->Makefile->PlatformIsAppleIos()) {
fpath += "/Contents"; fpath += "/Contents";
if (!contentOnly) if (!contentOnly) {
fpath += "/MacOS"; fpath += "/MacOS";
}
} }
return fpath; return fpath;
} }
@ -1377,8 +1378,9 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
fpath += ext; fpath += ext;
if (!this->Makefile->PlatformIsAppleIos()) { if (!this->Makefile->PlatformIsAppleIos()) {
fpath += "/Contents"; fpath += "/Contents";
if (!contentOnly) if (!contentOnly) {
fpath += "/MacOS"; fpath += "/MacOS";
}
} }
return fpath; return fpath;
} }
@ -3336,11 +3338,13 @@ static std::string intersect(const std::set<std::string>& s1,
{ {
std::string result; std::string result;
result = intersect(s1, s2); result = intersect(s1, s2);
if (!result.empty()) if (!result.empty()) {
return result; return result;
}
result = intersect(s1, s3); result = intersect(s1, s3);
if (!result.empty()) if (!result.empty()) {
return result; return result;
}
return intersect(s2, s3); return intersect(s2, s3);
} }
@ -3351,14 +3355,17 @@ static std::string intersect(const std::set<std::string>& s1,
{ {
std::string result; std::string result;
result = intersect(s1, s2); result = intersect(s1, s2);
if (!result.empty()) if (!result.empty()) {
return result; return result;
}
result = intersect(s1, s3); result = intersect(s1, s3);
if (!result.empty()) if (!result.empty()) {
return result; return result;
}
result = intersect(s1, s4); result = intersect(s1, s4);
if (!result.empty()) if (!result.empty()) {
return result; return result;
}
return intersect(s2, s3, s4); return intersect(s2, s3, s4);
} }

View File

@ -30,8 +30,9 @@ const char* cmGlobalNinjaGenerator::INDENT = " ";
void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count) void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count)
{ {
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i) {
os << cmGlobalNinjaGenerator::INDENT; os << cmGlobalNinjaGenerator::INDENT;
}
} }
void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os) void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os)
@ -43,8 +44,9 @@ void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os)
void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
const std::string& comment) const std::string& comment)
{ {
if (comment.empty()) if (comment.empty()) {
return; return;
}
std::string::size_type lpos = 0; std::string::size_type lpos = 0;
std::string::size_type rpos; std::string::size_type rpos;
@ -165,16 +167,18 @@ void cmGlobalNinjaGenerator::WriteBuild(
if (!implicitDeps.empty()) { if (!implicitDeps.empty()) {
arguments += " |"; arguments += " |";
for (cmNinjaDeps::const_iterator i = implicitDeps.begin(); for (cmNinjaDeps::const_iterator i = implicitDeps.begin();
i != implicitDeps.end(); ++i) i != implicitDeps.end(); ++i) {
arguments += " " + EncodeIdent(EncodePath(*i), os); arguments += " " + EncodeIdent(EncodePath(*i), os);
}
} }
// Write order-only dependencies. // Write order-only dependencies.
if (!orderOnlyDeps.empty()) { if (!orderOnlyDeps.empty()) {
arguments += " ||"; arguments += " ||";
for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
i != orderOnlyDeps.end(); ++i) i != orderOnlyDeps.end(); ++i) {
arguments += " " + EncodeIdent(EncodePath(*i), os); arguments += " " + EncodeIdent(EncodePath(*i), os);
}
} }
arguments += "\n"; arguments += "\n";
@ -198,9 +202,10 @@ void cmGlobalNinjaGenerator::WriteBuild(
// Write the variables bound to this build statement. // Write the variables bound to this build statement.
std::ostringstream variable_assignments; std::ostringstream variable_assignments;
for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end(); for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end();
++i) ++i) {
cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first, cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first,
i->second, "", 1); i->second, "", 1);
}
// check if a response file rule should be used // check if a response file rule should be used
std::string buildstr = build; std::string buildstr = build;
@ -430,8 +435,9 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os,
cmGlobalNinjaGenerator::WriteComment(os, comment); cmGlobalNinjaGenerator::WriteComment(os, comment);
os << "default"; os << "default";
for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end(); for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end();
++i) ++i) {
os << " " << *i; os << " " << *i;
}
os << "\n"; os << "\n";
} }
@ -907,15 +913,17 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
this->AppendTargetOutputs(target, outputs); this->AppendTargetOutputs(target, outputs);
// Mark the target's outputs as ambiguous to ensure that no other target uses // Mark the target's outputs as ambiguous to ensure that no other target uses
// the output as an alias. // the output as an alias.
for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) {
TargetAliases[*i] = 0; TargetAliases[*i] = 0;
}
// Insert the alias into the map. If the alias was already present in the // Insert the alias into the map. If the alias was already present in the
// map and referred to another target, mark it as ambiguous. // map and referred to another target, mark it as ambiguous.
std::pair<TargetAliasMap::iterator, bool> newAlias = std::pair<TargetAliasMap::iterator, bool> newAlias =
TargetAliases.insert(std::make_pair(buildAlias, target)); TargetAliases.insert(std::make_pair(buildAlias, target));
if (newAlias.second && newAlias.first->second != target) if (newAlias.second && newAlias.first->second != target) {
newAlias.first->second = 0; newAlias.first->second = 0;
}
} }
void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
@ -926,8 +934,9 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
for (TargetAliasMap::const_iterator i = TargetAliases.begin(); for (TargetAliasMap::const_iterator i = TargetAliases.begin();
i != TargetAliases.end(); ++i) { i != TargetAliases.end(); ++i) {
// Don't write ambiguous aliases. // Don't write ambiguous aliases.
if (!i->second) if (!i->second) {
continue; continue;
}
cmNinjaDeps deps; cmNinjaDeps deps;
this->AppendTargetOutputs(i->second, deps); this->AppendTargetOutputs(i->second, deps);

View File

@ -81,8 +81,9 @@ void cmLocalNinjaGenerator::Generate()
tg->Generate(); tg->Generate();
// Add the target to "all" if required. // Add the target to "all" if required.
if (!this->GetGlobalNinjaGenerator()->IsExcluded( if (!this->GetGlobalNinjaGenerator()->IsExcluded(
this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) {
this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t); this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t);
}
delete tg; delete tg;
} }
} }
@ -257,8 +258,9 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
os << "# Write statements declared in CMakeLists.txt:" << std::endl os << "# Write statements declared in CMakeLists.txt:" << std::endl
<< "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
<< std::endl; << std::endl;
if (this->IsRootMakefile()) if (this->IsRootMakefile()) {
os << "# Which is the root file." << std::endl; os << "# Which is the root file." << std::endl;
}
cmGlobalNinjaGenerator::WriteDivider(os); cmGlobalNinjaGenerator::WriteDivider(os);
os << std::endl; os << std::endl;
} }
@ -282,9 +284,10 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
for (std::vector<std::string>::const_iterator i = deps.begin(); for (std::vector<std::string>::const_iterator i = deps.begin();
i != deps.end(); ++i) { i != deps.end(); ++i) {
std::string dep; std::string dep;
if (this->GetRealDependency(*i, this->GetConfigName(), dep)) if (this->GetRealDependency(*i, this->GetConfigName(), dep)) {
ninjaDeps.push_back( ninjaDeps.push_back(
this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep)); this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep));
}
} }
} }
@ -294,12 +297,13 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
// If we have no commands but we need to build a command anyway, use ":". // If we have no commands but we need to build a command anyway, use ":".
// This happens when building a POST_BUILD value for link targets that // This happens when building a POST_BUILD value for link targets that
// don't use POST_BUILD. // don't use POST_BUILD.
if (cmdLines.empty()) if (cmdLines.empty()) {
#ifdef _WIN32 #ifdef _WIN32
return "cd ."; return "cd .";
#else #else
return ":"; return ":";
#endif #endif
}
std::ostringstream cmd; std::ostringstream cmd;
for (std::vector<std::string>::const_iterator li = cmdLines.begin(); for (std::vector<std::string>::const_iterator li = cmdLines.begin();
@ -332,8 +336,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
{ {
if (ccg.GetNumberOfCommands() > 0) { if (ccg.GetNumberOfCommands() > 0) {
std::string wd = ccg.GetWorkingDirectory(); std::string wd = ccg.GetWorkingDirectory();
if (wd.empty()) if (wd.empty()) {
wd = this->GetCurrentBinaryDirectory(); wd = this->GetCurrentBinaryDirectory();
}
std::ostringstream cdCmd; std::ostringstream cdCmd;
#ifdef _WIN32 #ifdef _WIN32
@ -361,8 +366,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps) cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps)
{ {
if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) {
return; return;
}
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this); cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this);
@ -391,8 +397,9 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
this->AppendCustomCommandDeps(ccg, ninjaDeps); this->AppendCustomCommandDeps(ccg, ninjaDeps);
for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
++i) ++i) {
this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
}
std::vector<std::string> cmdLines; std::vector<std::string> cmdLines;
this->AppendCustomCommandLines(ccg, cmdLines); this->AppendCustomCommandLines(ccg, cmdLines);

View File

@ -3620,8 +3620,9 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
bool cmMakefile::IsAlias(const std::string& name) const bool cmMakefile::IsAlias(const std::string& name) const
{ {
if (this->AliasTargets.find(name) != this->AliasTargets.end()) if (this->AliasTargets.find(name) != this->AliasTargets.end()) {
return true; return true;
}
return this->GetGlobalGenerator()->IsAlias(name); return this->GetGlobalGenerator()->IsAlias(name);
} }

View File

@ -329,8 +329,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
buildEcho += " shared library "; buildEcho += " shared library ";
break; break;
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
if (this->GeneratorTarget->IsCFBundleOnApple()) if (this->GeneratorTarget->IsCFBundleOnApple()) {
buildEcho += " CFBundle"; buildEcho += " CFBundle";
}
buildEcho += " shared module "; buildEcho += " shared module ";
break; break;
default: default:

View File

@ -41,15 +41,16 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
, TargetLinkLanguage("") , TargetLinkLanguage("")
{ {
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
if (target->GetType() == cmState::EXECUTABLE) if (target->GetType() == cmState::EXECUTABLE) {
this->GetGeneratorTarget()->GetExecutableNames( this->GetGeneratorTarget()->GetExecutableNames(
this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); this->TargetNamePDB, GetLocalGenerator()->GetConfigName());
else } else {
this->GetGeneratorTarget()->GetLibraryNames( this->GetGeneratorTarget()->GetLibraryNames(
this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
this->TargetNameImport, this->TargetNamePDB, this->TargetNameImport, this->TargetNamePDB,
GetLocalGenerator()->GetConfigName()); GetLocalGenerator()->GetConfigName());
}
if (target->GetType() != cmState::OBJECT_LIBRARY) { if (target->GetType() != cmState::OBJECT_LIBRARY) {
// on Windows the output dir is already needed at compile time // on Windows the output dir is already needed at compile time
@ -125,10 +126,11 @@ const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
case cmState::SHARED_LIBRARY: case cmState::SHARED_LIBRARY:
return "shared library"; return "shared library";
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
if (this->GetGeneratorTarget()->IsCFBundleOnApple()) if (this->GetGeneratorTarget()->IsCFBundleOnApple()) {
return "CFBundle shared module"; return "CFBundle shared module";
else } else {
return "shared module"; return "shared module";
}
case cmState::EXECUTABLE: case cmState::EXECUTABLE:
return "executable"; return "executable";
default: default:
@ -271,7 +273,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
std::string cmakeCommand = std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
if (targetType == cmState::EXECUTABLE) if (targetType == cmState::EXECUTABLE) {
this->GetGlobalGenerator()->AddRule( this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_EXECUTABLE", "CMAKE_SYMLINK_EXECUTABLE",
cmakeCommand + " -E cmake_symlink_executable" cmakeCommand + " -E cmake_symlink_executable"
@ -284,7 +286,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat*/ "", /*restat*/ "",
/*generator*/ false); /*generator*/ false);
else } else {
this->GetGlobalGenerator()->AddRule( this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_LIBRARY", "CMAKE_SYMLINK_LIBRARY",
cmakeCommand + " -E cmake_symlink_library" cmakeCommand + " -E cmake_symlink_library"
@ -297,6 +299,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat*/ "", /*restat*/ "",
/*generator*/ false); /*generator*/ false);
}
} }
} }

View File

@ -46,8 +46,9 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
// (i.e. top-level) directory. CMake creates copies of these targets // (i.e. top-level) directory. CMake creates copies of these targets
// in every directory, which we don't need. // in every directory, which we don't need.
if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(), if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
target->GetLocalGenerator()->GetSourceDirectory()) == 0) target->GetLocalGenerator()->GetSourceDirectory()) == 0) {
return new cmNinjaUtilityTargetGenerator(target); return new cmNinjaUtilityTargetGenerator(target);
}
// else fallthrough // else fallthrough
} }
@ -132,8 +133,9 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
includes, this->GeneratorTarget, language, includes, this->GeneratorTarget, language,
language == "RC", // full include paths for RC needed by cmcldeps language == "RC", // full include paths for RC needed by cmcldeps
false, this->GetConfigName()); false, this->GetConfigName());
if (this->GetGlobalGenerator()->IsGCCOnWindows()) if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/'); std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/');
}
this->LocalGenerator->AppendFlags(languageFlags, includeFlags); this->LocalGenerator->AppendFlags(languageFlags, includeFlags);
} }
@ -170,13 +172,15 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
{ {
// Static libraries never depend on other targets for linking. // Static libraries never depend on other targets for linking.
if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) {
return cmNinjaDeps(); return cmNinjaDeps();
}
cmComputeLinkInformation* cli = cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); this->GeneratorTarget->GetLinkInformation(this->GetConfigName());
if (!cli) if (!cli) {
return cmNinjaDeps(); return cmNinjaDeps();
}
const std::vector<std::string>& deps = cli->GetDepends(); const std::vector<std::string>& deps = cli->GetDepends();
cmNinjaDeps result(deps.size()); cmNinjaDeps result(deps.size());
@ -218,8 +222,9 @@ std::string cmNinjaTargetGenerator::GetObjectFilePath(
cmSourceFile const* source) const cmSourceFile const* source) const
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) if (!path.empty()) {
path += "/"; path += "/";
}
std::string const& objectName = this->GeneratorTarget->GetObjectName(source); std::string const& objectName = this->GeneratorTarget->GetObjectName(source);
path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
path += "/"; path += "/";
@ -237,8 +242,9 @@ std::string cmNinjaTargetGenerator::GetTargetFilePath(
const std::string& name) const const std::string& name) const
{ {
std::string path = this->GetTargetOutputDir(); std::string path = this->GetTargetOutputDir();
if (path.empty() || path == ".") if (path.empty() || path == ".") {
return name; return name;
}
path += "/"; path += "/";
path += name; path += name;
return path; return path;
@ -420,8 +426,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
} }
for (std::vector<std::string>::iterator i = compileCmds.begin(); for (std::vector<std::string>::iterator i = compileCmds.begin();
i != compileCmds.end(); ++i) i != compileCmds.end(); ++i) {
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
}
std::string cmdLine = std::string cmdLine =
this->GetLocalGenerator()->BuildCommandLine(compileCmds); this->GetLocalGenerator()->BuildCommandLine(compileCmds);
@ -653,8 +660,9 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
cmSystemTools::ExpandListArgument(compileCmd, compileCmds); cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
for (std::vector<std::string>::iterator i = compileCmds.begin(); for (std::vector<std::string>::iterator i = compileCmds.begin();
i != compileCmds.end(); ++i) i != compileCmds.end(); ++i) {
this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars); this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars);
}
std::string cmdLine = std::string cmdLine =
this->GetLocalGenerator()->BuildCommandLine(compileCmds); this->GetLocalGenerator()->BuildCommandLine(compileCmds);

View File

@ -57,8 +57,9 @@ void cmNinjaUtilityTargetGenerator::Generate()
std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(), std::transform(ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(util_outputs), MapToNinjaPath()); std::back_inserter(util_outputs), MapToNinjaPath());
if (ci->GetUsesTerminal()) if (ci->GetUsesTerminal()) {
uses_terminal = true; uses_terminal = true;
}
} }
} }
@ -99,10 +100,11 @@ void cmNinjaUtilityTargetGenerator::Generate()
const char* echoStr = const char* echoStr =
this->GetGeneratorTarget()->GetProperty("EchoString"); this->GetGeneratorTarget()->GetProperty("EchoString");
std::string desc; std::string desc;
if (echoStr) if (echoStr) {
desc = echoStr; desc = echoStr;
else } else {
desc = "Running utility command for " + this->GetTargetName(); desc = "Running utility command for " + this->GetTargetName();
}
// TODO: fix problematic global targets. For now, search and replace the // TODO: fix problematic global targets. For now, search and replace the
// makefile vars. // makefile vars.
@ -122,8 +124,9 @@ void cmNinjaUtilityTargetGenerator::Generate()
.c_str()); .c_str());
cmSystemTools::ReplaceString(command, "$(ARGS)", ""); cmSystemTools::ReplaceString(command, "$(ARGS)", "");
if (command.find('$') != std::string::npos) if (command.find('$') != std::string::npos) {
return; return;
}
for (cmNinjaDeps::const_iterator oi = util_outputs.begin(), for (cmNinjaDeps::const_iterator oi = util_outputs.begin(),
oe = util_outputs.end(); oe = util_outputs.end();

View File

@ -25,8 +25,9 @@ cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target,
, ConfigName(configName) , ConfigName(configName)
, MacContentFolders(0) , MacContentFolders(0)
{ {
if (this->MustSkip()) if (this->MustSkip()) {
return; return;
}
} }
bool cmOSXBundleGenerator::MustSkip() bool cmOSXBundleGenerator::MustSkip()
@ -37,8 +38,9 @@ bool cmOSXBundleGenerator::MustSkip()
void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
std::string& outpath) std::string& outpath)
{ {
if (this->MustSkip()) if (this->MustSkip()) {
return; return;
}
// Compute bundle directory names. // Compute bundle directory names.
std::string out = outpath; std::string out = outpath;
@ -64,8 +66,9 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
void cmOSXBundleGenerator::CreateFramework(const std::string& targetName, void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
const std::string& outpath) const std::string& outpath)
{ {
if (this->MustSkip()) if (this->MustSkip()) {
return; return;
}
assert(this->MacContentFolders); assert(this->MacContentFolders);
@ -92,8 +95,9 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
plist.c_str()); plist.c_str());
// Generate Versions directory only for MacOSX frameworks // Generate Versions directory only for MacOSX frameworks
if (this->Makefile->PlatformIsAppleIos()) if (this->Makefile->PlatformIsAppleIos()) {
return; return;
}
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
// drive rules to create these files at build time. // drive rules to create these files at build time.
@ -162,8 +166,9 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
const std::string& root) const std::string& root)
{ {
if (this->MustSkip()) if (this->MustSkip()) {
return; return;
}
// Compute bundle directory names. // Compute bundle directory names.
std::string out = root; std::string out = root;
@ -186,8 +191,9 @@ void cmOSXBundleGenerator::GenerateMacOSXContentStatements(
std::vector<cmSourceFile const*> const& sources, std::vector<cmSourceFile const*> const& sources,
MacOSXContentGeneratorType* generator) MacOSXContentGeneratorType* generator)
{ {
if (this->MustSkip()) if (this->MustSkip()) {
return; return;
}
for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
si != sources.end(); ++si) { si != sources.end(); ++si) {

View File

@ -228,14 +228,16 @@ std::string cmSystemTools::HelpFileName(std::string name)
std::string cmSystemTools::TrimWhitespace(const std::string& s) std::string cmSystemTools::TrimWhitespace(const std::string& s)
{ {
std::string::const_iterator start = s.begin(); std::string::const_iterator start = s.begin();
while (start != s.end() && cm_isspace(*start)) while (start != s.end() && cm_isspace(*start)) {
++start; ++start;
if (start == s.end()) }
if (start == s.end()) {
return ""; return "";
}
std::string::const_iterator stop = s.end() - 1; std::string::const_iterator stop = s.end() - 1;
while (cm_isspace(*stop)) while (cm_isspace(*stop)) {
--stop; --stop;
}
return std::string(start, stop + 1); return std::string(start, stop + 1);
} }

View File

@ -287,8 +287,9 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
{ {
std::map<std::string, cmListFileBacktrace>::const_iterator i = std::map<std::string, cmListFileBacktrace>::const_iterator i =
this->UtilityBacktraces.find(u); this->UtilityBacktraces.find(u);
if (i == this->UtilityBacktraces.end()) if (i == this->UtilityBacktraces.end()) {
return 0; return 0;
}
return &i->second; return &i->second;
} }

View File

@ -15,15 +15,15 @@ int main(int ac, char** av)
std::string logarg; std::string logarg;
bool nextarg = false; bool nextarg = false;
if (exename.find("valgrind") != exename.npos) if (exename.find("valgrind") != exename.npos) {
logarg = "--log-file="; logarg = "--log-file=";
else if (exename.find("purify") != exename.npos) } else if (exename.find("purify") != exename.npos) {
#ifdef _WIN32 #ifdef _WIN32
logarg = "/SAVETEXTDATA="; logarg = "/SAVETEXTDATA=";
#else #else
logarg = "-log-file="; logarg = "-log-file=";
#endif #endif
else if (exename.find("BC") != exename.npos) { } else if (exename.find("BC") != exename.npos) {
nextarg = true; nextarg = true;
logarg = "/X"; logarg = "/X";
} }
@ -34,8 +34,9 @@ int main(int ac, char** av)
std::string arg = argv[i]; std::string arg = argv[i];
if (arg.find(logarg) == 0) { if (arg.find(logarg) == 0) {
if (nextarg) { if (nextarg) {
if (i == argc - 1) if (i == argc - 1) {
return 1; // invalid command line return 1; // invalid command line
}
logfile = argv[i + 1]; logfile = argv[i + 1];
} else { } else {
logfile = arg.substr(logarg.length()); logfile = arg.substr(logarg.length());
@ -44,8 +45,9 @@ int main(int ac, char** av)
} }
} }
if (!logfile.empty()) if (!logfile.empty()) {
cmSystemTools::Touch(logfile, true); cmSystemTools::Touch(logfile, true);
}
} }
return RETVAL; return RETVAL;

View File

@ -46,10 +46,12 @@ private:
void ParseTranslationUnit() void ParseTranslationUnit()
{ {
this->Command = CommandType(); this->Command = CommandType();
if (!Expect('{')) if (!Expect('{')) {
return; return;
if (Expect('}')) }
if (Expect('}')) {
return; return;
}
do { do {
ParseString(); ParseString();
std::string name = this->String; std::string name = this->String;
@ -64,8 +66,9 @@ private:
void ParseString() void ParseString()
{ {
this->String = ""; this->String = "";
if (!Expect('"')) if (!Expect('"')) {
return; return;
}
while (!Expect('"')) { while (!Expect('"')) {
Expect('\\'); Expect('\\');
this->String.append(1, C); this->String.append(1, C);
@ -84,8 +87,9 @@ private:
void ExpectOrDie(char c, const std::string& message) void ExpectOrDie(char c, const std::string& message)
{ {
if (!Expect(c)) if (!Expect(c)) {
ErrorExit(std::string("'") + c + "' expected " + message + "."); ErrorExit(std::string("'") + c + "' expected " + message + ".");
}
} }
void NextNonWhitespace() void NextNonWhitespace()
@ -98,8 +102,9 @@ private:
void Next() void Next()
{ {
this->C = char(Input->get()); this->C = char(Input->get());
if (this->Input->bad()) if (this->Input->bad()) {
ErrorExit("Unexpected end of file."); ErrorExit("Unexpected end of file.");
}
} }
void ErrorExit(const std::string& message) void ErrorExit(const std::string& message)