[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.196 1.197 cmXCodeObject.cxx 1.25 1.26 cmXCodeObject.h 1.18 1.19
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Sep 2 10:27:17 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv28102/Source
Modified Files:
cmGlobalXCodeGenerator.cxx cmXCodeObject.cxx cmXCodeObject.h
Log Message:
ENH: Simplify string attributes in Xcode generator
This change cleans up the implementation of cmXCodeObject to avoid
un-escaping and re-escaping string values. There is no need to store
the string in escaped form. It can be escaped once when it is printed
out to the generated project file.
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.196
retrieving revision 1.197
diff -C 2 -d -r1.196 -r1.197
*** cmGlobalXCodeGenerator.cxx 14 Jul 2008 22:51:54 -0000 1.196
--- cmGlobalXCodeGenerator.cxx 2 Sep 2008 14:27:15 -0000 1.197
***************
*** 690,694 ****
cmtarget.GetTargetSourceFileFlags(*i);
! if(strcmp(filetype->GetString(), "\"compiled.mach-o.objfile\"") == 0)
{
externalObjFiles.push_back(xsf);
--- 690,694 ----
cmtarget.GetTargetSourceFileFlags(*i);
! if(strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
{
externalObjFiles.push_back(xsf);
***************
*** 1958,1977 ****
{
std::string oldValue = attr->GetString();
-
- // unescape escaped quotes internal to the string:
- cmSystemTools::ReplaceString(oldValue, "\\\"", "\"");
-
- // remove surrounding quotes, if any:
- std::string::size_type len = oldValue.length();
- if(oldValue[0] == '\"' && oldValue[len-1] == '\"')
- {
- oldValue = oldValue.substr(1, len-2);
- }
-
oldValue += " ";
oldValue += value;
-
- // SetString automatically escapes internal quotes and then surrounds
- // the result with quotes if necessary...
attr->SetString(oldValue.c_str());
}
--- 1958,1963 ----
Index: cmXCodeObject.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmXCodeObject.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -C 2 -d -r1.25 -r1.26
*** cmXCodeObject.cxx 9 May 2008 01:14:16 -0000 1.25
--- cmXCodeObject.cxx 2 Sep 2008 14:27:15 -0000 1.26
***************
*** 152,156 ****
if(j->second->TypeValue == STRING)
{
! out << j->first << " = " << j->second->String << ";";
}
else if(j->second->TypeValue == OBJECT_LIST)
--- 152,158 ----
if(j->second->TypeValue == STRING)
{
! out << j->first << " = ";
! j->second->PrintString(out);
! out << ";";
}
else if(j->second->TypeValue == OBJECT_LIST)
***************
*** 161,165 ****
if(j->second->List[k]->TypeValue == STRING)
{
! out << j->second->List[k]->String << ", ";
}
else
--- 163,168 ----
if(j->second->List[k]->TypeValue == STRING)
{
! j->second->List[k]->PrintString(out);
! out << ", ";
}
else
***************
*** 193,197 ****
else if(object->TypeValue == STRING)
{
! out << i->first << " = " << object->String << ";" << separator;
}
else
--- 196,202 ----
else if(object->TypeValue == STRING)
{
! out << i->first << " = ";
! object->PrintString(out);
! out << ";" << separator;
}
else
***************
*** 231,258 ****
//----------------------------------------------------------------------------
! void cmXCodeObject::SetString(const char* s)
{
! std::string ss = s;
! if(ss.size() == 0)
! {
! this->String = "\"\"";
! return;
! }
! // escape quotes
! cmSystemTools::ReplaceString(ss, "\"", "\\\"");
! bool needQuote = false;
! this->String = "";
! if(ss.find_first_of(" <>.+-=@") != ss.npos)
! {
! needQuote = true;
! }
! if(needQuote)
! {
! this->String = "\"";
! }
! this->String += ss;
! if(needQuote)
{
! this->String += "\"";
}
}
--- 236,266 ----
//----------------------------------------------------------------------------
! void cmXCodeObject::PrintString(std::ostream& os) const
{
! // The string needs to be quoted if it contains any characters
! // considered special by the Xcode project file parser.
! bool needQuote =
! (this->String.empty() ||
! this->String.find_first_of(" <>.+-=@") != this->String.npos);
! const char* quote = needQuote? "\"" : "";
!
! // Print the string, quoted and escaped as necessary.
! os << quote;
! for(std::string::const_iterator i = this->String.begin();
! i != this->String.end(); ++i)
{
! if(*i == '"')
! {
! // Escape double-quotes.
! os << '\\';
! }
! os << *i;
}
+ os << quote;
+ }
+
+ //----------------------------------------------------------------------------
+ void cmXCodeObject::SetString(const char* s)
+ {
+ this->String = s;
}
Index: cmXCodeObject.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmXCodeObject.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** cmXCodeObject.h 27 Jul 2007 14:55:24 -0000 1.18
--- cmXCodeObject.h 2 Sep 2008 14:27:15 -0000 1.19
***************
*** 148,151 ****
--- 148,153 ----
void SetComment(const char* c) { this->Comment = c;}
protected:
+ void PrintString(std::ostream& os) const;
+
cmTarget* Target;
Type TypeValue;
More information about the Cmake-commits
mailing list