summaryrefslogtreecommitdiff
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2006-02-23 11:36:36 -0500
committerBill Hoffman <bill.hoffman@kitware.com>2006-02-23 11:36:36 -0500
commit3d617b48aafbef2cbfa078a52fa8ffbceae14286 (patch)
treea87011cf394d7a3ffb9858d5d0fd8078bf0584cc /Source/cmSourceGroupCommand.cxx
parent32c403f6654c26d9a5c81badbe817327229e6e71 (diff)
downloadcmake-3d617b48aafbef2cbfa078a52fa8ffbceae14286.tar.gz
ENH: fix for bug 2908 crash for empty source group name
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r--Source/cmSourceGroupCommand.cxx36
1 files changed, 14 insertions, 22 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 01b969fd4e..32b652f9b5 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -21,27 +21,17 @@ inline std::vector<std::string> tokenize(const std::string& str,
bool skipEmptyTokens)
{
std::vector<std::string> tokens;
- std::string::size_type tokstart,tokend;
-
- if (skipEmptyTokens)
+ if(str.size() == 0)
{
- tokend=0;
+ tokens.push_back("");
+ return tokens;
}
- else
- {
- tokend=std::string::npos;
- }
-
+ std::string::size_type tokstart,tokend;
+
+ tokend=0;
do
{
- if (skipEmptyTokens)
- {
- tokstart=str.find_first_not_of(sep,tokend);
- }
- else
- {
- tokstart=tokend+1;
- }
+ tokstart=str.find_first_not_of(sep,tokend);
if (tokstart==std::string::npos)
{
break; // no more tokens
@@ -56,7 +46,6 @@ inline std::vector<std::string> tokenize(const std::string& str,
tokens.push_back(str.substr(tokstart,tokend-tokstart));
}
} while (tokend!=std::string::npos);
-
return tokens;
}
@@ -70,16 +59,15 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args)
}
std::string delimiter = "\\";
-
if(m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"))
+ {
delimiter = m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
+ }
std::vector<std::string> folders = tokenize(args[0], delimiter, true);
const char *parent = NULL;
-
cmSourceGroup* sg = NULL;
-
for(unsigned int i=0;i<folders.size();++i)
{
sg = m_Makefile->GetSourceGroup(folders[i].c_str());
@@ -90,7 +78,11 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args)
sg = m_Makefile->GetSourceGroup(folders[i].c_str());
parent = folders[i].c_str();
}
-
+ if(!sg)
+ {
+ this->SetError("Could not create or find source group");
+ return false;
+ }
// If only two arguments are given, the pre-1.8 version of the
// command is being invoked.
if(args.size() == 2 && args[1] != "FILES")