[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.221 1.222 cmGlobalXCodeGenerator.h 1.60 1.61
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Jul 29 16:40:09 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv3136/Source
Modified Files:
cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.h
Log Message:
Separate Xcode flag escaping code from defines
Generalize the core Xcode generator preprocessor flag escaping code to
be useful for escaping all flags.
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.221
retrieving revision 1.222
diff -C 2 -d -r1.221 -r1.222
*** cmGlobalXCodeGenerator.cxx 29 Jul 2009 20:39:45 -0000 1.221
--- cmGlobalXCodeGenerator.cxx 29 Jul 2009 20:40:07 -0000 1.222
***************
*** 3127,3172 ****
cmSystemTools::ExpandListArgument(defines_list, defines);
// GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
! // We escape everything as follows:
! // - Place each definition in single quotes ''
// - Escape a single quote as \\'
// - Escape a backslash as \\\\ since it itself is an escape
// Note that in the code below we need one more level of escapes for
// C string syntax in this source file.
! for(std::vector<std::string>::const_iterator di = defines.begin();
! di != defines.end(); ++di)
! {
! std::string def;
// Open single quote.
! def += "'";
! // Add -D flag if requested.
! if(dflag)
{
! def += "-D";
}
!
! // Escaped definition string.
! for(const char* c = di->c_str(); *c; ++c)
{
! if(*c == '\'')
! {
! def += "\\\\'";
! }
! else if(*c == '\\')
! {
! def += "\\\\\\\\";
! }
! else
! {
! def += *c;
! }
}
// Close single quote.
! def += "'";
!
! defs.Add(def.c_str());
}
}
--- 3127,3213 ----
cmSystemTools::ExpandListArgument(defines_list, defines);
+ // Store the definitions in the string.
+ this->AppendDefines(defs, defines, dflag);
+ }
+
+ //----------------------------------------------------------------------------
+ void
+ cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
+ std::vector<std::string> const& defines,
+ bool dflag)
+ {
// GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
! std::string def;
! for(std::vector<std::string>::const_iterator di = defines.begin();
! di != defines.end(); ++di)
! {
! // Start with -D if requested.
! def = dflag? "-D": "";
! def += *di;
!
! // Append the flag with needed escapes.
! std::string tmp;
! this->AppendFlag(tmp, def);
! defs.Add(tmp.c_str());
! }
! }
!
! //----------------------------------------------------------------------------
! void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
! std::string const& flag)
! {
! // Short-circuit for an empty flag.
! if(flag.empty())
! {
! return;
! }
!
! // Separate from previous flags.
! if(!flags.empty())
! {
! flags += " ";
! }
!
! // Check if the flag needs quoting.
! bool quoteFlag =
! flag.find_first_of("`~!@#$%^&*()+={}[]|:;\"'<>,.? ") != flag.npos;
!
! // We escape a flag as follows:
! // - Place each flag in single quotes ''
// - Escape a single quote as \\'
// - Escape a backslash as \\\\ since it itself is an escape
// Note that in the code below we need one more level of escapes for
// C string syntax in this source file.
! //
! // The final level of escaping is done when the string is stored
! // into the project file by cmXCodeObject::PrintString.
+ if(quoteFlag)
+ {
// Open single quote.
! flags += "'";
! }
! // Flag value with escaped quotes and backslashes.
! for(const char* c = flag.c_str(); *c; ++c)
! {
! if(*c == '\'')
{
! flags += "\\\\'";
}
! else if(*c == '\\')
{
! flags += "\\\\\\\\";
! }
! else
! {
! flags += *c;
}
+ }
+ if(quoteFlag)
+ {
// Close single quote.
! flags += "'";
}
}
Index: cmGlobalXCodeGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -C 2 -d -r1.60 -r1.61
*** cmGlobalXCodeGenerator.h 10 Jul 2009 20:51:44 -0000 1.60
--- cmGlobalXCodeGenerator.h 29 Jul 2009 20:40:07 -0000 1.61
***************
*** 184,187 ****
--- 184,191 ----
void AppendDefines(BuildObjectListOrString& defs, const char* defines_list,
bool dflag = false);
+ void AppendDefines(BuildObjectListOrString& defs,
+ std::vector<std::string> const& defines,
+ bool dflag = false);
+ void AppendFlag(std::string& flags, std::string const& flag);
protected:
More information about the Cmake-commits
mailing list