summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmAddDependenciesCommand.cxx7
-rw-r--r--Source/cmAddExecutableCommand.cxx72
-rw-r--r--Source/cmAddExecutableCommand.h13
-rw-r--r--Source/cmAddLibraryCommand.cxx80
-rw-r--r--Source/cmAddLibraryCommand.h13
-rw-r--r--Source/cmCPluginAPI.cxx5
-rw-r--r--Source/cmExportCommand.cxx9
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx12
-rw-r--r--Source/cmGetPropertyCommand.cxx12
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx25
-rw-r--r--Source/cmGlobalGenerator.cxx26
-rw-r--r--Source/cmGlobalGenerator.h7
-rw-r--r--Source/cmInstallCommand.cxx9
-rw-r--r--Source/cmListFileCache.cxx222
-rw-r--r--Source/cmListFileCache.h17
-rw-r--r--Source/cmListFileLexer.c411
-rw-r--r--Source/cmListFileLexer.h1
-rw-r--r--Source/cmListFileLexer.in.l26
-rw-r--r--Source/cmMacroCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx52
-rw-r--r--Source/cmMakefile.h7
-rw-r--r--Source/cmSetPropertyCommand.cxx5
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx5
-rw-r--r--Source/cmTarget.cxx6
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx5
-rw-r--r--Source/cmTargetPropCommandBase.cxx5
-rw-r--r--Source/cmVariableWatchCommand.cxx15
-rw-r--r--Source/cmWhileCommand.cxx4
29 files changed, 812 insertions, 263 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 001ed8f..ef7c8fb 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -2,5 +2,5 @@
set(CMake_VERSION_MAJOR 2)
set(CMake_VERSION_MINOR 8)
set(CMake_VERSION_PATCH 11)
-set(CMake_VERSION_TWEAK 20130802)
+set(CMake_VERSION_TWEAK 20130806)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 04a304e..e4d7f7f 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -24,6 +24,13 @@ bool cmAddDependenciesCommand
}
std::string target_name = args[0];
+ if(this->Makefile->IsAlias(target_name.c_str()))
+ {
+ cmOStringStream e;
+ e << "Cannot add target-level dependencies to alias target \""
+ << target_name << "\".\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
{
std::vector<std::string>::const_iterator s = args.begin();
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 6dd8e5c..5785259 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -30,6 +30,7 @@ bool cmAddExecutableCommand
bool excludeFromAll = false;
bool importTarget = false;
bool importGlobal = false;
+ bool isAlias = false;
while ( s != args.end() )
{
if (*s == "WIN32")
@@ -57,6 +58,11 @@ bool cmAddExecutableCommand
++s;
importGlobal = true;
}
+ else if(*s == "ALIAS")
+ {
+ ++s;
+ isAlias = true;
+ }
else
{
break;
@@ -83,6 +89,72 @@ bool cmAddExecutableCommand
}
return false;
}
+ if (isAlias)
+ {
+ if(!cmGeneratorExpression::IsValidTargetName(exename.c_str()))
+ {
+ this->SetError(("Invalid name for ALIAS: " + exename).c_str());
+ return false;
+ }
+ if(excludeFromAll)
+ {
+ this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ return false;
+ }
+ if(importTarget || importGlobal)
+ {
+ this->SetError("IMPORTED with ALIAS is not allowed.");
+ return false;
+ }
+ if(args.size() != 3)
+ {
+ cmOStringStream e;
+ e << "ALIAS requires exactly one target argument.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ const char *aliasedName = s->c_str();
+ if(this->Makefile->IsAlias(aliasedName))
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if(!aliasedTarget)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" does not already "
+ "exist.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ cmTarget::TargetType type = aliasedTarget->GetType();
+ if(type != cmTarget::EXECUTABLE)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is not an "
+ "executable.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(aliasedTarget->IsImported())
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ this->Makefile->AddAlias(exename.c_str(), aliasedTarget);
+ return true;
+ }
// Handle imported target creation.
if(importTarget)
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 1e9f9b3..2774ce8 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -107,6 +107,19 @@ public:
"(and its per-configuration version IMPORTED_LOCATION_<CONFIG>) "
"which specifies the location of the main executable file on disk. "
"See documentation of the IMPORTED_* properties for more information."
+ "\n"
+ "The signature\n"
+ " add_executable(<name> ALIAS <target>)\n"
+ "creates an alias, such that <name> can be used to refer to <target> "
+ "in subsequent commands. The <name> does not appear in the generated "
+ "buildsystem as a make target. The <target> may not be an IMPORTED "
+ "target or an ALIAS. Alias targets can be used as linkable targets, "
+ "targets to read properties from, executables for custom commands and "
+ "custom targets. They can also be tested for existance with the "
+ "regular if(TARGET) subcommand. The <name> may not be used to modify "
+ "properties of <target>, that is, it may not be used as the operand of "
+ "set_property, set_target_properties, target_link_libraries etc. An "
+ "ALIAS target may not be installed of exported."
;
}
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index fd39eec..cbc6ed1 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -43,6 +43,7 @@ bool cmAddLibraryCommand
// the type of library. Otherwise, it is treated as a source or
// source list name. There may be two keyword arguments, check for them
bool haveSpecifiedType = false;
+ bool isAlias = false;
while ( s != args.end() )
{
std::string libType = *s;
@@ -76,6 +77,11 @@ bool cmAddLibraryCommand
type = cmTarget::UNKNOWN_LIBRARY;
haveSpecifiedType = true;
}
+ else if(libType == "ALIAS")
+ {
+ ++s;
+ isAlias = true;
+ }
else if(*s == "EXCLUDE_FROM_ALL")
{
++s;
@@ -96,6 +102,80 @@ bool cmAddLibraryCommand
break;
}
}
+ if (isAlias)
+ {
+ if(!cmGeneratorExpression::IsValidTargetName(libName.c_str()))
+ {
+ this->SetError(("Invalid name for ALIAS: " + libName).c_str());
+ return false;
+ }
+ if(excludeFromAll)
+ {
+ this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ return false;
+ }
+ if(importTarget || importGlobal)
+ {
+ this->SetError("IMPORTED with ALIAS is not allowed.");
+ return false;
+ }
+ if(args.size() != 3)
+ {
+ cmOStringStream e;
+ e << "ALIAS requires exactly one target argument.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ const char *aliasedName = s->c_str();
+ if(this->Makefile->IsAlias(aliasedName))
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if(!aliasedTarget)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" does not already "
+ "exist.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ cmTarget::TargetType aliasedType = aliasedTarget->GetType();
+ if(aliasedType != cmTarget::SHARED_LIBRARY
+ && aliasedType != cmTarget::STATIC_LIBRARY
+ && aliasedType != cmTarget::MODULE_LIBRARY
+ && aliasedType != cmTarget::OBJECT_LIBRARY)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is not a library.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(aliasedTarget->IsImported())
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ this->Makefile->AddAlias(libName.c_str(), aliasedTarget);
+ return true;
+ }
+
+ if(importTarget && excludeFromAll)
+ {
+ this->SetError("excludeFromAll with IMPORTED target makes no sense.");
+ return false;
+ }
/* ideally we should check whether for the linker language of the target
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index e5f27cb..59354b0 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -138,6 +138,19 @@ public:
"Some native build systems may not like targets that have only "
"object files, so consider adding at least one real source file "
"to any target that references $<TARGET_OBJECTS:objlib>."
+ "\n"
+ "The signature\n"
+ " add_library(<name> ALIAS <target>)\n"
+ "creates an alias, such that <name> can be used to refer to <target> "
+ "in subsequent commands. The <name> does not appear in the generated "
+ "buildsystem as a make target. The <target> may not be an IMPORTED "
+ "target or an ALIAS. Alias targets can be used as linkable targets, "
+ "targets to read properties from. They can also be tested for "
+ "existance with the "
+ "regular if(TARGET) subcommand. The <name> may not be used to modify "
+ "properties of <target>, that is, it may not be used as the operand of "
+ "set_property, set_target_properties, target_link_libraries etc. An "
+ "ALIAS target may not be installed of exported."
;
}
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 48ae50e..cb62f21 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -422,8 +422,9 @@ int CCONV cmExecuteCommand(void *arg, const char *name,
for(int i = 0; i < numArgs; ++i)
{
// Assume all arguments are quoted.
- lff.Arguments.push_back(cmListFileArgument(args[i], true,
- "[CMake-Plugin]", 0));
+ lff.Arguments.push_back(
+ cmListFileArgument(args[i], cmListFileArgument::Quoted,
+ "[CMake-Plugin]", 0));
}
cmExecutionStatus status;
return mf->ExecuteCommand(lff,status);
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 9c3f314..f059ceb 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -114,6 +114,15 @@ bool cmExportCommand
currentTarget != this->Targets.GetVector().end();
++currentTarget)
{
+ if (this->Makefile->IsAlias(currentTarget->c_str()))
+ {
+ cmOStringStream e;
+ e << "given ALIAS target \"" << *currentTarget
+ << "\" which may not be exported.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
if(cmTarget* target =
this->Makefile->GetLocalGenerator()->
GetGlobalGenerator()->FindTarget(0, currentTarget->c_str()))
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index d0b6190..e0c8c9e 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -747,6 +747,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"Target name not supported.");
return std::string();
}
+ if(propertyName == "ALIASED_TARGET")
+ {
+ if(context->Makefile->IsAlias(targetName.c_str()))
+ {
+ if(cmTarget* tgt =
+ context->Makefile->FindTargetToUse(targetName.c_str()))
+ {
+ return tgt->GetName();
+ }
+ }
+ return "";
+ }
target = context->Makefile->FindTargetToUse(
targetName.c_str());
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 985dc50..faba7cd 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -288,6 +288,18 @@ bool cmGetPropertyCommand::HandleTargetMode()
return false;
}
+ if(this->PropertyName == "ALIASED_TARGET")
+ {
+ if(this->Makefile->IsAlias(this->Name.c_str()))
+ {
+ if(cmTarget* target =
+ this->Makefile->FindTargetToUse(this->Name.c_str()))
+ {
+ return this->StoreResult(target->GetName());
+ }
+ }
+ return false;
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str()))
{
return this->StoreResult(target->GetProperty(this->PropertyName.c_str()));
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 1947139..02f00a5 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -22,17 +22,30 @@ bool cmGetTargetPropertyCommand
}
std::string var = args[0].c_str();
const char* targetName = args[1].c_str();
+ const char *prop = 0;
- if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
+ if(args[2] == "ALIASED_TARGET")
{
- cmTarget& target = *tgt;
- const char *prop = target.GetProperty(args[2].c_str());
- if (prop)
+ if(this->Makefile->IsAlias(targetName))
{
- this->Makefile->AddDefinition(var.c_str(), prop);
- return true;
+ if(cmTarget* target =
+ this->Makefile->FindTargetToUse(targetName))
+ {
+ prop = target->GetName();
+ }
}
}
+ else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
+ {
+ cmTarget& target = *tgt;
+ prop = target.GetProperty(args[2].c_str());
+ }
+
+ if (prop)
+ {
+ this->Makefile->AddDefinition(var.c_str(), prop);
+ return true;
+ }
this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
return true;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 9b6ac93..7f2b592 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1769,10 +1769,22 @@ cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir)
return 0;
}
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
+{
+ this->AliasTargets[name] = tgt;
+}
+
+//----------------------------------------------------------------------------
+bool cmGlobalGenerator::IsAlias(const char *name)
+{
+ return this->AliasTargets.find(name) != this->AliasTargets.end();
+}
//----------------------------------------------------------------------------
cmTarget*
-cmGlobalGenerator::FindTarget(const char* project, const char* name)
+cmGlobalGenerator::FindTarget(const char* project, const char* name,
+ bool excludeAliases)
{
// if project specific
if(project)
@@ -1780,7 +1792,8 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name)
std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
for(unsigned int i = 0; i < gens->size(); ++i)
{
- cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name);
+ cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name,
+ excludeAliases);
if(ret)
{
return ret;
@@ -1790,6 +1803,15 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name)
// if all projects/directories
else
{
+ if (!excludeAliases)
+ {
+ std::map<cmStdString, cmTarget*>::iterator ai
+ = this->AliasTargets.find(name);
+ if (ai != this->AliasTargets.end())
+ {
+ return ai->second;
+ }
+ }
std::map<cmStdString,cmTarget *>::iterator i =
this->TotalTargets.find ( name );
if ( i != this->TotalTargets.end() )
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 2fcdc43..18aba24 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -196,7 +196,11 @@ public:
void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
- cmTarget* FindTarget(const char* project, const char* name);
+ cmTarget* FindTarget(const char* project, const char* name,
+ bool excludeAliases = false);
+
+ void AddAlias(const char *name, cmTarget *tgt);
+ bool IsAlias(const char *name);
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
@@ -347,6 +351,7 @@ protected:
// All targets in the entire project.
std::map<cmStdString,cmTarget *> TotalTargets;
+ std::map<cmStdString,cmTarget *> AliasTargets;
std::map<cmStdString,cmTarget *> ImportedTargets;
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 0faf1d4..3c76bd6 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -362,6 +362,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
targetIt!=targetList.GetVector().end();
++targetIt)
{
+
+ if (this->Makefile->IsAlias(targetIt->c_str()))
+ {
+ cmOStringStream e;
+ e << "TARGETS given target \"" << (*targetIt)
+ << "\" which is an alias.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
// Lookup this target in the current directory.
if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str()))
{
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 36d84f3..c02866c 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -22,45 +22,58 @@
# pragma warn -8060 /* possibly incorrect assignment */
#endif
-bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
- cmListFileFunction& function,
- const char* filename);
+//----------------------------------------------------------------------------
+struct cmListFileParser
+{
+ cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
+ ~cmListFileParser();
+ bool ParseFile();
+ bool ParseFunction(const char* name, long line);
+ void AddArgument(cmListFileLexer_Token* token,
+ cmListFileArgument::Delimiter delim);
+ cmListFile* ListFile;
+ cmMakefile* Makefile;
+ const char* FileName;
+ cmListFileLexer* Lexer;
+ cmListFileFunction Function;
+ enum { SeparationOkay, SeparationWarning } Separation;
+};
-bool cmListFile::ParseFile(const char* filename,
- bool topLevel,
- cmMakefile *mf)
+//----------------------------------------------------------------------------
+cmListFileParser::cmListFileParser(cmListFile* lf, cmMakefile* mf,
+ const char* filename):
+ ListFile(lf), Makefile(mf), FileName(filename),
+ Lexer(cmListFileLexer_New())
{
- if(!cmSystemTools::FileExists(filename))
- {
- return false;
- }
+}
- // Create the scanner.
- cmListFileLexer* lexer = cmListFileLexer_New();
- if(!lexer)
- {
- cmSystemTools::Error("cmListFileCache: error allocating lexer ");
- return false;
- }
+//----------------------------------------------------------------------------
+cmListFileParser::~cmListFileParser()
+{
+ cmListFileLexer_Delete(this->Lexer);
+}
+//----------------------------------------------------------------------------
+bool cmListFileParser::ParseFile()
+{
// Open the file.
- if(!cmListFileLexer_SetFileName(lexer, filename))
+ if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName))
{
- cmListFileLexer_Delete(lexer);
cmSystemTools::Error("cmListFileCache: error can not open file ",
- filename);
+ this->FileName);
return false;
}
// Use a simple recursive-descent parser to process the token
// stream.
- this->ModifiedTime = cmSystemTools::ModifiedTime(filename);
- bool parseError = false;
bool haveNewline = true;
- cmListFileLexer_Token* token;
- while(!parseError && (token = cmListFileLexer_Scan(lexer)))
+ while(cmListFileLexer_Token* token =
+ cmListFileLexer_Scan(this->Lexer))
{
- if(token->type == cmListFileLexer_Token_Newline)
+ if(token->type == cmListFileLexer_Token_Space)
+ {
+ }
+ else if(token->type == cmListFileLexer_Token_Newline)
{
haveNewline = true;
}
@@ -69,51 +82,66 @@ bool cmListFile::ParseFile(const char* filename,
if(haveNewline)
{
haveNewline = false;
- cmListFileFunction inFunction;
- inFunction.Name = token->text;
- inFunction.FilePath = filename;
- inFunction.Line = token->line;
- if(cmListFileCacheParseFunction(lexer, inFunction, filename))
+ if(this->ParseFunction(token->text, token->line))
{
- this->Functions.push_back(inFunction);
+ this->ListFile->Functions.push_back(this->Function);
}
else
{
- parseError = true;
+ return false;
}
}
else
{
cmOStringStream error;
error << "Error in cmake code at\n"
- << filename << ":" << token->line << ":\n"
+ << this->FileName << ":" << token->line << ":\n"
<< "Parse error. Expected a newline, got "
- << cmListFileLexer_GetTypeAsString(lexer, token->type)
+ << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
cmSystemTools::Error(error.str().c_str());
- parseError = true;
+ return false;
}
}
else
{
cmOStringStream error;
error << "Error in cmake code at\n"
- << filename << ":" << token->line << ":\n"
+ << this->FileName << ":" << token->line << ":\n"
<< "Parse error. Expected a command name, got "
- << cmListFileLexer_GetTypeAsString(lexer, token->type)
+ << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \""
<< token->text << "\".";
cmSystemTools::Error(error.str().c_str());
- parseError = true;
+ return false;
}
}
- if (parseError)
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmListFile::ParseFile(const char* filename,
+ bool topLevel,
+ cmMakefile *mf)
+{
+ if(!cmSystemTools::FileExists(filename))
+ {
+ return false;
+ }
+
+ bool parseError = false;
+ this->ModifiedTime = cmSystemTools::ModifiedTime(filename);
+
+ {
+ cmListFileParser parser(this, mf, filename);
+ parseError = !parser.ParseFile();
+ }
+
+ if(parseError)
{
this->ModifiedTime = 0;
}
- cmListFileLexer_Delete(lexer);
-
// do we need a cmake_policy(VERSION call?
if(topLevel)
{
@@ -196,7 +224,8 @@ bool cmListFile::ParseFile(const char* filename,
{
cmListFileFunction project;
project.Name = "PROJECT";
- cmListFileArgument prj("Project", false, filename, 0);
+ cmListFileArgument prj("Project", cmListFileArgument::Unquoted,
+ filename, 0);
project.Arguments.push_back(prj);
this->Functions.insert(this->Functions.begin(),project);
}
@@ -208,17 +237,24 @@ bool cmListFile::ParseFile(const char* filename,
return true;
}
-bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
- cmListFileFunction& function,
- const char* filename)
+//----------------------------------------------------------------------------
+bool cmListFileParser::ParseFunction(const char* name, long line)
{
+ // Inintialize a new function call.
+ this->Function = cmListFileFunction();
+ this->Function.FilePath = this->FileName;
+ this->Function.Name = name;
+ this->Function.Line = line;
+
// Command name has already been parsed. Read the left paren.
cmListFileLexer_Token* token;
- if(!(token = cmListFileLexer_Scan(lexer)))
+ while((token = cmListFileLexer_Scan(this->Lexer)) &&
+ token->type == cmListFileLexer_Token_Space) {}
+ if(!token)
{
cmOStringStream error;
- error << "Error in cmake code at\n"
- << filename << ":" << cmListFileLexer_GetCurrentLine(lexer) << ":\n"
+ error << "Error in cmake code at\n" << this->FileName << ":"
+ << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Function missing opening \"(\".";
cmSystemTools::Error(error.str().c_str());
return false;
@@ -226,26 +262,33 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
if(token->type != cmListFileLexer_Token_ParenLeft)
{
cmOStringStream error;
- error << "Error in cmake code at\n"
- << filename << ":" << cmListFileLexer_GetCurrentLine(lexer) << ":\n"
+ error << "Error in cmake code at\n" << this->FileName << ":"
+ << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Expected \"(\", got "
- << cmListFileLexer_GetTypeAsString(lexer, token->type)
+ << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
cmSystemTools::Error(error.str().c_str());
return false;
}
// Arguments.
- unsigned long lastLine = cmListFileLexer_GetCurrentLine(lexer);
+ unsigned long lastLine;
unsigned long parenDepth = 0;
- while((token = cmListFileLexer_Scan(lexer)))
+ this->Separation = SeparationOkay;
+ while((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
+ token = cmListFileLexer_Scan(this->Lexer)))
{
+ if(token->type == cmListFileLexer_Token_Space ||
+ token->type == cmListFileLexer_Token_Newline)
+ {
+ this->Separation = SeparationOkay;
+ continue;
+ }
if(token->type == cmListFileLexer_Token_ParenLeft)
{
parenDepth++;
- cmListFileArgument a("(",
- false, filename, token->line);
- function.Arguments.push_back(a);
+ this->AddArgument(token, cmListFileArgument::Unquoted);
+ this->Separation = SeparationOkay;
}
else if(token->type == cmListFileLexer_Token_ParenRight)
{
@@ -254,43 +297,39 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
return true;
}
parenDepth--;
- cmListFileArgument a(")",
- false, filename, token->line);
- function.Arguments.push_back(a);
+ this->Separation = SeparationOkay;
+ this->AddArgument(token, cmListFileArgument::Unquoted);
+ this->Separation = SeparationWarning;
}
else if(token->type == cmListFileLexer_Token_Identifier ||
token->type == cmListFileLexer_Token_ArgumentUnquoted)
{
- cmListFileArgument a(token->text,
- false, filename, token->line);
- function.Arguments.push_back(a);
+ this->AddArgument(token, cmListFileArgument::Unquoted);
+ this->Separation = SeparationWarning;
}
else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
{
- cmListFileArgument a(token->text,
- true, filename, token->line);
- function.Arguments.push_back(a);
+ this->AddArgument(token, cmListFileArgument::Quoted);
+ this->Separation = SeparationWarning;
}
- else if(token->type != cmListFileLexer_Token_Newline)
+ else
{
// Error.
cmOStringStream error;
- error << "Error in cmake code at\n"
- << filename << ":" << cmListFileLexer_GetCurrentLine(lexer)
- << ":\n"
+ error << "Error in cmake code at\n" << this->FileName << ":"
+ << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Function missing ending \")\". "
<< "Instead found "
- << cmListFileLexer_GetTypeAsString(lexer, token->type)
+ << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
cmSystemTools::Error(error.str().c_str());
return false;
}
- lastLine = cmListFileLexer_GetCurrentLine(lexer);
}
cmOStringStream error;
error << "Error in cmake code at\n"
- << filename << ":" << lastLine << ":\n"
+ << this->FileName << ":" << lastLine << ":\n"
<< "Parse error. Function missing ending \")\". "
<< "End of file reached.";
cmSystemTools::Error(error.str().c_str());
@@ -299,6 +338,45 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
}
//----------------------------------------------------------------------------
+void cmListFileParser::AddArgument(cmListFileLexer_Token* token,
+ cmListFileArgument::Delimiter delim)
+{
+ cmListFileArgument a(token->text, delim, this->FileName, token->line);
+ this->Function.Arguments.push_back(a);
+ if(delim == cmListFileArgument::Unquoted)
+ {
+ // Warn about a future behavior change.
+ const char* c = a.Value.c_str();
+ if(*c++ == '[')
+ {
+ while(*c == '=')
+ { ++c; }
+ if(*c == '[')
+ {
+ cmOStringStream m;
+ m << "Syntax Warning in cmake code at\n"
+ << " " << this->FileName << ":" << token->line << ":"
+ << token->column << "\n"
+ << "A future version of CMake may treat unquoted argument:\n"
+ << " " << a.Value << "\n"
+ << "as an opening long bracket. Double-quote the argument.";
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+ }
+ }
+ }
+ if(this->Separation == SeparationOkay)
+ {
+ return;
+ }
+ cmOStringStream m;
+ m << "Syntax Warning in cmake code at\n"
+ << " " << this->FileName << ":" << token->line << ":"
+ << token->column << "\n"
+ << "Argument not separated from preceding token by whitespace.";
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+}
+
+//----------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
{
os << lfc.FilePath;
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index fec3d07..7bb3b34 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -25,22 +25,27 @@ class cmMakefile;
struct cmListFileArgument
{
- cmListFileArgument(): Value(), Quoted(false), FilePath(0), Line(0) {}
+ enum Delimiter
+ {
+ Unquoted,
+ Quoted
+ };
+ cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
cmListFileArgument(const cmListFileArgument& r):
- Value(r.Value), Quoted(r.Quoted), FilePath(r.FilePath), Line(r.Line) {}
- cmListFileArgument(const std::string& v, bool q, const char* file,
- long line): Value(v), Quoted(q),
+ Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
+ cmListFileArgument(const std::string& v, Delimiter d, const char* file,
+ long line): Value(v), Delim(d),
FilePath(file), Line(line) {}
bool operator == (const cmListFileArgument& r) const
{
- return (this->Value == r.Value) && (this->Quoted == r.Quoted);
+ return (this->Value == r.Value) && (this->Delim == r.Delim);
}
bool operator != (const cmListFileArgument& r) const
{
return !(*this == r);
}
std::string Value;
- bool Quoted;
+ Delimiter Delim;
const char* FilePath;
long Line;
};
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c
index e7965b5..2841fe5 100644
--- a/Source/cmListFileLexer.c
+++ b/Source/cmListFileLexer.c
@@ -9,7 +9,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 31
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -31,7 +31,15 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
@@ -46,7 +54,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@@ -77,6 +84,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@@ -86,11 +95,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -126,8 +136,6 @@ typedef void* yyscan_t;
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-int cmListFileLexer_yylex_init (yyscan_t* scanner);
-
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
@@ -151,9 +159,21 @@ int cmListFileLexer_yylex_init (yyscan_t* scanner);
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
@@ -192,14 +212,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
} \
while ( 0 )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -354,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 14
-#define YY_END_OF_BUFFER 15
+#define YY_NUM_RULES 16
+#define YY_END_OF_BUFFER 17
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -363,12 +378,13 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[39] =
+static yyconst flex_int16_t yy_accept[45] =
{ 0,
- 0, 0, 0, 0, 15, 6, 12, 1, 7, 2,
- 6, 3, 4, 6, 13, 8, 9, 10, 11, 6,
- 0, 6, 0, 2, 0, 5, 6, 8, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 17, 6, 14, 1, 8, 2,
+ 6, 3, 4, 6, 15, 9, 11, 12, 13, 6,
+ 0, 6, 0, 14, 2, 0, 5, 6, 9, 0,
+ 10, 0, 7, 0, 0, 0, 7, 0, 7, 0,
+ 0, 0, 0, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -405,64 +421,70 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[13] =
{ 0,
- 1, 1, 2, 1, 3, 1, 1, 1, 4, 4,
- 4, 1
+ 1, 2, 3, 2, 4, 1, 1, 1, 5, 5,
+ 5, 1
} ;
-static yyconst flex_int16_t yy_base[48] =
+static yyconst flex_int16_t yy_base[56] =
{ 0,
- 0, 0, 10, 20, 34, 32, 89, 89, 89, 0,
- 23, 89, 89, 35, 0, 18, 89, 89, 44, 0,
- 49, 21, 0, 0, 19, 0, 0, 15, 59, 0,
- 18, 0, 15, 12, 11, 10, 9, 89, 64, 68,
- 72, 76, 80, 13, 84, 12, 10
+ 0, 0, 10, 20, 38, 32, 0, 109, 109, 0,
+ 28, 109, 109, 35, 0, 23, 109, 109, 44, 0,
+ 49, 26, 0, 0, 0, 22, 0, 0, 18, 24,
+ 109, 0, 61, 20, 0, 18, 0, 17, 16, 0,
+ 12, 11, 10, 109, 73, 16, 78, 83, 88, 93,
+ 12, 98, 11, 103, 9
} ;
-static yyconst flex_int16_t yy_def[48] =
+static yyconst flex_int16_t yy_def[56] =
{ 0,
- 38, 1, 39, 39, 38, 38, 38, 38, 38, 40,
- 6, 38, 38, 6, 41, 42, 38, 38, 42, 6,
- 38, 6, 43, 40, 44, 14, 6, 42, 42, 21,
- 21, 45, 46, 44, 47, 46, 47, 0, 38, 38,
- 38, 38, 38, 38, 38, 38, 38
+ 44, 1, 45, 45, 44, 44, 46, 44, 44, 47,
+ 6, 44, 44, 6, 48, 49, 44, 44, 49, 6,
+ 44, 6, 50, 46, 47, 51, 14, 6, 49, 49,
+ 44, 21, 44, 21, 52, 53, 33, 51, 33, 54,
+ 55, 53, 55, 0, 44, 44, 44, 44, 44, 44,
+ 44, 44, 44, 44, 44
} ;
-static yyconst flex_int16_t yy_nxt[102] =
+static yyconst flex_int16_t yy_nxt[122] =
{ 0,
6, 7, 8, 7, 9, 10, 11, 12, 13, 6,
- 14, 15, 17, 37, 18, 36, 34, 30, 20, 30,
- 27, 19, 17, 20, 18, 35, 29, 27, 33, 29,
- 25, 19, 20, 38, 38, 38, 21, 38, 22, 38,
- 38, 20, 20, 23, 26, 26, 28, 38, 28, 30,
- 30, 38, 38, 20, 38, 31, 38, 38, 30, 30,
- 32, 28, 38, 28, 16, 16, 16, 16, 24, 38,
- 24, 24, 27, 38, 27, 27, 28, 38, 38, 28,
- 20, 38, 20, 20, 30, 38, 30, 30, 5, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
-
- 38
+ 14, 15, 17, 43, 18, 42, 38, 24, 32, 33,
+ 32, 19, 17, 36, 18, 37, 33, 41, 29, 30,
+ 37, 19, 20, 36, 30, 26, 21, 44, 22, 44,
+ 44, 20, 20, 23, 27, 27, 31, 44, 29, 32,
+ 32, 44, 44, 33, 44, 34, 44, 44, 32, 32,
+ 35, 33, 44, 44, 44, 21, 44, 39, 44, 44,
+ 33, 33, 40, 16, 16, 16, 16, 16, 25, 25,
+ 44, 25, 25, 28, 28, 44, 28, 28, 29, 29,
+ 44, 44, 29, 20, 20, 44, 20, 20, 32, 32,
+
+ 44, 32, 32, 33, 33, 44, 33, 33, 5, 44,
+ 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
+ 44
} ;
-static yyconst flex_int16_t yy_chk[102] =
+static yyconst flex_int16_t yy_chk[122] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 47, 3, 46, 44, 37, 36, 35,
- 34, 3, 4, 33, 4, 31, 28, 25, 22, 16,
- 11, 4, 6, 5, 0, 0, 6, 0, 6, 0,
+ 1, 1, 3, 55, 3, 53, 51, 46, 43, 42,
+ 41, 3, 4, 39, 4, 38, 36, 34, 30, 29,
+ 26, 4, 6, 22, 16, 11, 6, 5, 6, 0,
0, 6, 6, 6, 14, 14, 19, 0, 19, 21,
21, 0, 0, 21, 0, 21, 0, 0, 21, 21,
- 21, 29, 0, 29, 39, 39, 39, 39, 40, 0,
- 40, 40, 41, 0, 41, 41, 42, 0, 0, 42,
- 43, 0, 43, 43, 45, 0, 45, 45, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
-
- 38
+ 21, 33, 0, 0, 0, 33, 0, 33, 0, 0,
+ 33, 33, 33, 45, 45, 45, 45, 45, 47, 47,
+ 0, 47, 47, 48, 48, 0, 48, 48, 49, 49,
+ 0, 0, 49, 50, 50, 0, 50, 50, 52, 52,
+
+ 0, 52, 52, 54, 54, 0, 54, 54, 44, 44,
+ 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
+ 44
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[15] =
+static yyconst flex_int32_t yy_rule_can_match_eol[17] =
{ 0,
-1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, };
+1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@@ -494,9 +516,11 @@ Run flex like this:
Modify cmListFileLexer.c:
- remove TABs
+ - remove use of the 'register' storage class specifier
- remove the yyunput function
- add a statement "(void)yyscanner;" to the top of these methods:
yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree
+ - remove statement "yyscanner = NULL;" from cmListFileLexer_yylex_destroy
- remove all YY_BREAK lines occurring right after return statements
- remove the isatty forward declaration
@@ -540,7 +564,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/*--------------------------------------------------------------------------*/
-#line 568 "cmListFileLexer.c"
+#line 570 "cmListFileLexer.c"
#define INITIAL 0
#define STRING 1
@@ -591,6 +615,12 @@ struct yyguts_t
}; /* end struct yyguts_t */
+static int yy_init_globals (yyscan_t yyscanner );
+
+int cmListFileLexer_yylex_init (yyscan_t* scanner);
+
+int cmListFileLexer_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
@@ -620,6 +650,10 @@ int cmListFileLexer_yyget_lineno (yyscan_t yyscanner );
void cmListFileLexer_yyset_lineno (int line_number ,yyscan_t yyscanner );
+int cmListFileLexer_yyget_column (yyscan_t yyscanner );
+
+void cmListFileLexer_yyset_column (int column_no ,yyscan_t yyscanner );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -652,7 +686,12 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -660,7 +699,7 @@ static int input (yyscan_t yyscanner );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -754,14 +793,14 @@ YY_DECL
int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 100 "cmListFileLexer.in.l"
+#line 82 "cmListFileLexer.in.l"
-#line 787 "cmListFileLexer.c"
+#line 804 "cmListFileLexer.c"
- if ( yyg->yy_init )
+ if ( !yyg->yy_init )
{
- yyg->yy_init = 0;
+ yyg->yy_init = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
@@ -810,13 +849,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 39 )
+ if ( yy_current_state >= 45 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 89 );
+ while ( yy_base[yy_current_state] != 109 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -855,7 +894,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
-#line 102 "cmListFileLexer.in.l"
+#line 84 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_Newline;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -865,14 +904,14 @@ YY_RULE_SETUP
}
case 2:
YY_RULE_SETUP
-#line 110 "cmListFileLexer.in.l"
+#line 92 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
}
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 114 "cmListFileLexer.in.l"
+#line 96 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ParenLeft;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -881,7 +920,7 @@ YY_RULE_SETUP
}
case 4:
YY_RULE_SETUP
-#line 121 "cmListFileLexer.in.l"
+#line 103 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ParenRight;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -890,7 +929,7 @@ YY_RULE_SETUP
}
case 5:
YY_RULE_SETUP
-#line 128 "cmListFileLexer.in.l"
+#line 110 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_Identifier;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -899,7 +938,7 @@ YY_RULE_SETUP
}
case 6:
YY_RULE_SETUP
-#line 135 "cmListFileLexer.in.l"
+#line 117 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -908,7 +947,16 @@ YY_RULE_SETUP
}
case 7:
YY_RULE_SETUP
-#line 142 "cmListFileLexer.in.l"
+#line 124 "cmListFileLexer.in.l"
+{
+ lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
+ cmListFileLexerSetToken(lexer, yytext, yyleng);
+ lexer->column += yyleng;
+ return 1;
+}
+case 8:
+YY_RULE_SETUP
+#line 131 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
cmListFileLexerSetToken(lexer, "", 0);
@@ -916,58 +964,69 @@ YY_RULE_SETUP
BEGIN(STRING);
}
YY_BREAK
-case 8:
-/* rule 8 can match eol */
+case 9:
YY_RULE_SETUP
-#line 149 "cmListFileLexer.in.l"
+#line 138 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
YY_BREAK
-case 9:
-/* rule 9 can match eol */
+case 10:
+/* rule 10 can match eol */
YY_RULE_SETUP
-#line 154 "cmListFileLexer.in.l"
+#line 143 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
lexer->column = 1;
}
YY_BREAK
-case 10:
+case 11:
+/* rule 11 can match eol */
+YY_RULE_SETUP
+#line 149 "cmListFileLexer.in.l"
+{
+ cmListFileLexerAppend(lexer, yytext, yyleng);
+ ++lexer->line;
+ lexer->column = 1;
+}
+ YY_BREAK
+case 12:
YY_RULE_SETUP
-#line 160 "cmListFileLexer.in.l"
+#line 155 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
BEGIN(INITIAL);
return 1;
}
-case 11:
+case 13:
YY_RULE_SETUP
-#line 166 "cmListFileLexer.in.l"
+#line 161 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
YY_BREAK
case YY_STATE_EOF(STRING):
-#line 171 "cmListFileLexer.in.l"
+#line 166 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_BadString;
BEGIN(INITIAL);
return 1;
}
-case 12:
+case 14:
YY_RULE_SETUP
-#line 177 "cmListFileLexer.in.l"
+#line 172 "cmListFileLexer.in.l"
{
+ lexer->token.type = cmListFileLexer_Token_Space;
+ cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
+ return 1;
}
- YY_BREAK
-case 13:
+case 15:
YY_RULE_SETUP
-#line 181 "cmListFileLexer.in.l"
+#line 179 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_BadCharacter;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -975,18 +1034,18 @@ YY_RULE_SETUP
return 1;
}
case YY_STATE_EOF(INITIAL):
-#line 188 "cmListFileLexer.in.l"
+#line 186 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_None;
cmListFileLexerSetToken(lexer, 0, 0);
return 0;
}
-case 14:
+case 16:
YY_RULE_SETUP
-#line 194 "cmListFileLexer.in.l"
+#line 192 "cmListFileLexer.in.l"
ECHO;
YY_BREAK
-#line 1025 "cmListFileLexer.c"
+#line 1064 "cmListFileLexer.c"
case YY_END_OF_BUFFER:
{
@@ -1171,7 +1230,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{
- size_t num_to_read =
+ int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
@@ -1216,7 +1275,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- yyg->yy_n_chars, num_to_read );
+ yyg->yy_n_chars, (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
@@ -1240,6 +1299,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmListFileLexer_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
@@ -1270,7 +1337,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 39 )
+ if ( yy_current_state >= 45 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1287,7 +1354,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
int yy_is_jam;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
char *yy_cp = yyg->yy_c_buf_p;
YY_CHAR yy_c = 1;
@@ -1299,11 +1366,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 39 )
+ if ( yy_current_state >= 45 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 38);
+ yy_is_jam = (yy_current_state == 44);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1633,6 +1700,8 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -1651,6 +1720,8 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1695,26 +1766,26 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size ,
/** Setup the input buffer state to scan a string. The next call to cmListFileLexer_yylex() will
* scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
+ * @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* cmListFileLexer_yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner)
+YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
{
- return cmListFileLexer_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner);
+ return cmListFileLexer_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
}
/** Setup the input buffer state to scan the given bytes. The next call to cmListFileLexer_yylex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * bytes, int len , yyscan_t yyscanner)
+YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
@@ -1722,15 +1793,15 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * bytes, int len ,
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
+ n = _yybytes_len + 2;
buf = (char *) cmListFileLexer_yyalloc(n ,yyscanner );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_bytes()" );
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = cmListFileLexer_yy_scan_buffer(buf,n ,yyscanner);
if ( ! b )
@@ -1918,21 +1989,87 @@ void cmListFileLexer_yyset_debug (int bdebug , yyscan_t yyscanner)
/* Accessor methods for yylval and yylloc */
+/* User-visible API */
+
+/* cmListFileLexer_yylex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+
+int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals)
+
+{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+/* cmListFileLexer_yylex_init_extra has the same functionality as cmListFileLexer_yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to cmListFileLexer_yyalloc in
+ * the yyextra field.
+ */
+
+int cmListFileLexer_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+ struct yyguts_t dummy_yyguts;
+
+ cmListFileLexer_yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ cmListFileLexer_yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- This function is called once per scanner lifetime. */
+ * This function is called from cmListFileLexer_yylex_destroy(), so don't allocate here.
+ */
yyg->yy_buffer_stack = 0;
yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = (char *) 0;
- yyg->yy_init = 1;
+ yyg->yy_init = 0;
yyg->yy_start = 0;
+
yyg->yy_start_stack_ptr = 0;
yyg->yy_start_stack_depth = 0;
- yyg->yy_start_stack = (int *) 0;
+ yyg->yy_start_stack = NULL;
/* Defined in main.c */
#ifdef YY_STDINIT
@@ -1949,33 +2086,6 @@ static int yy_init_globals (yyscan_t yyscanner)
return 0;
}
-/* User-visible API */
-
-/* cmListFileLexer_yylex_init is special because it creates the scanner itself, so it is
- * the ONLY reentrant function that doesn't take the scanner as the last argument.
- * That's why we explicitly handle the declaration, instead of using our macros.
- */
-
-int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals)
-
-{
- if (ptr_yy_globals == NULL){
- errno = EINVAL;
- return 1;
- }
-
- *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), NULL );
-
- if (*ptr_yy_globals == NULL){
- errno = ENOMEM;
- return 1;
- }
-
- memset(*ptr_yy_globals,0,sizeof(struct yyguts_t));
-
- return yy_init_globals ( *ptr_yy_globals );
-}
-
/* cmListFileLexer_yylex_destroy is for both reentrant and non-reentrant scanners. */
int cmListFileLexer_yylex_destroy (yyscan_t yyscanner)
{
@@ -1996,6 +2106,10 @@ int cmListFileLexer_yylex_destroy (yyscan_t yyscanner)
cmListFileLexer_yyfree(yyg->yy_start_stack ,yyscanner );
yyg->yy_start_stack = NULL;
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * cmListFileLexer_yylex() is called, initialization will occur. */
+ yy_init_globals( yyscanner);
+
/* Destroy the main struct (reentrant only). */
cmListFileLexer_yyfree ( yyscanner , yyscanner );
return 0;
@@ -2009,7 +2123,6 @@ int cmListFileLexer_yylex_destroy (yyscan_t yyscanner)
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
int i;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@@ -2019,7 +2132,6 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
int n;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
for ( n = 0; s[n]; ++n )
;
@@ -2054,19 +2166,7 @@ void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#undef YY_NEW_FILE
-#undef YY_FLUSH_BUFFER
-#undef yy_set_bol
-#undef yy_new_buffer
-#undef yy_set_interactive
-#undef yytext_ptr
-#undef YY_DO_BEFORE_ACTION
-
-#ifdef YY_DECL_IS_OURS
-#undef YY_DECL_IS_OURS
-#undef YY_DECL
-#endif
-#line 194 "cmListFileLexer.in.l"
+#line 192 "cmListFileLexer.in.l"
@@ -2122,7 +2222,7 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
}
/* We need to extend the buffer. */
- temp = (char*)malloc(newSize);
+ temp = malloc(newSize);
if(lexer->token.text)
{
memcpy(temp, lexer->token.text, lexer->token.length);
@@ -2303,6 +2403,7 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
switch(type)
{
case cmListFileLexer_Token_None: return "nothing";
+ case cmListFileLexer_Token_Space: return "space";
case cmListFileLexer_Token_Newline: return "newline";
case cmListFileLexer_Token_Identifier: return "identifier";
case cmListFileLexer_Token_ParenLeft: return "left paren";
diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h
index 5f4db33..cc78b5c 100644
--- a/Source/cmListFileLexer.h
+++ b/Source/cmListFileLexer.h
@@ -15,6 +15,7 @@
typedef enum cmListFileLexer_Type_e
{
cmListFileLexer_Token_None,
+ cmListFileLexer_Token_Space,
cmListFileLexer_Token_Newline,
cmListFileLexer_Token_Identifier,
cmListFileLexer_Token_ParenLeft,
diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l
index eedf494..12b53ee 100644
--- a/Source/cmListFileLexer.in.l
+++ b/Source/cmListFileLexer.in.l
@@ -24,6 +24,7 @@ Modify cmListFileLexer.c:
- remove the yyunput function
- add a statement "(void)yyscanner;" to the top of these methods:
yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree
+ - remove statement "yyscanner = NULL;" from cmListFileLexer_yylex_destroy
- remove all YY_BREAK lines occurring right after return statements
- remove the isatty forward declaration
@@ -75,6 +76,8 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
%x STRING
MAKEVAR \$\([A-Za-z0-9_]*\)
+UNQUOTED ([^ \t\r\n\(\)#\\\"]|\\.)
+LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\"
%%
@@ -111,7 +114,14 @@ MAKEVAR \$\([A-Za-z0-9_]*\)
return 1;
}
-({MAKEVAR}|[^ \t\r\n\(\)#\\\"]|\\.)({MAKEVAR}|[^ \t\r\n\(\)#\\\"]|\\.|\"({MAKEVAR}|[^\r\n\(\)#\\\"]|\\.)*\")* {
+({UNQUOTED})({UNQUOTED})* {
+ lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
+ cmListFileLexerSetToken(lexer, yytext, yyleng);
+ lexer->column += yyleng;
+ return 1;
+}
+
+({MAKEVAR}|{UNQUOTED})({LEGACY})* {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
@@ -125,11 +135,17 @@ MAKEVAR \$\([A-Za-z0-9_]*\)
BEGIN(STRING);
}
-<STRING>([^\\\n\"]|\\(.|\n))+ {
+<STRING>([^\\\n\"]|\\.)+ {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
+<STRING>\\\n {
+ cmListFileLexerAppend(lexer, yytext, yyleng);
+ ++lexer->line;
+ lexer->column = 1;
+}
+
<STRING>\n {
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
@@ -153,8 +169,11 @@ MAKEVAR \$\([A-Za-z0-9_]*\)
return 1;
}
-[ \t\r] {
+[ \t\r]+ {
+ lexer->token.type = cmListFileLexer_Token_Space;
+ cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
+ return 1;
}
. {
@@ -405,6 +424,7 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
switch(type)
{
case cmListFileLexer_Token_None: return "nothing";
+ case cmListFileLexer_Token_Space: return "space";
case cmListFileLexer_Token_Newline: return "newline";
case cmListFileLexer_Token_Identifier: return "identifier";
case cmListFileLexer_Token_ParenLeft: return "left paren";
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index bd7ec00..8ba612c 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -227,7 +227,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
}
arg.Value = tmps;
- arg.Quoted = k->Quoted;
+ arg.Delim = k->Delim;
arg.FilePath = k->FilePath;
arg.Line = k->Line;
newLFF.Arguments.push_back(arg);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1920cc0..c4859b6 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -41,6 +41,7 @@
#include <stack>
#include <ctype.h> // for isspace
+#include <assert.h>
class cmMakefile::Internals
{
@@ -1437,6 +1438,14 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end())
{
+ if(this->IsAlias(target))
+ {
+ cmOStringStream e;
+ e << "ALIAS target \"" << target << "\" "
+ << "may not be linked into another target.";
+ this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ return;
+ }
i->second.AddLinkDirectory( d );
}
else
@@ -1923,6 +1932,12 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
}
+void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
+{
+ this->AliasTargets[lname] = tgt;
+ this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
+}
+
cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll)
@@ -2784,7 +2799,7 @@ bool cmMakefile::ExpandArguments(
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
- if(i->Quoted)
+ if(i->Delim == cmListFileArgument::Quoted)
{
outArgs.push_back(value);
}
@@ -3758,8 +3773,17 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config)
return 0;
}
-cmTarget* cmMakefile::FindTarget(const char* name)
+cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases)
{
+ if (!excludeAliases)
+ {
+ std::map<std::string, cmTarget*>::iterator i
+ = this->AliasTargets.find(name);
+ if (i != this->AliasTargets.end())
+ {
+ return i->second;
+ }
+ }
cmTargets& tgts = this->GetTargets();
cmTargets::iterator i = tgts.find ( name );
@@ -4184,7 +4208,7 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
}
//----------------------------------------------------------------------------
-cmTarget* cmMakefile::FindTargetToUse(const char* name)
+cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases)
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
@@ -4196,15 +4220,25 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name)
}
// Look for a target built in this directory.
- if(cmTarget* t = this->FindTarget(name))
+ if(cmTarget* t = this->FindTarget(name, excludeAliases))
{
return t;
}
// Look for a target built in this project.
- return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name);
+ return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name,
+ excludeAliases);
}
+//----------------------------------------------------------------------------
+bool cmMakefile::IsAlias(const char *name)
+{
+ if (this->AliasTargets.find(name) != this->AliasTargets.end())
+ return true;
+ return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(name);
+}
+
+//----------------------------------------------------------------------------
cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
{
cmTarget *t = this->FindTargetToUse(name);
@@ -4215,6 +4249,14 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom)
{
+ if(this->IsAlias(name.c_str()))
+ {
+ cmOStringStream e;
+ e << "cannot create target \"" << name
+ << "\" because an alias with the same name already exists.";
+ msg = e.str();
+ return false;
+ }
if(cmTarget* existing = this->FindTargetToUse(name.c_str()))
{
// The name given conflicts with an existing target. Produce an
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 871fa1b..711a208 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -337,6 +337,7 @@ public:
cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll = false);
+ void AddAlias(const char *libname, cmTarget *tgt);
#if defined(CMAKE_BUILD_WITH_CMAKE)
/**
@@ -536,11 +537,12 @@ public:
this->GeneratorTargets = targets;
}
- cmTarget* FindTarget(const char* name);
+ cmTarget* FindTarget(const char* name, bool excludeAliases = false);
/** Find a target to use in place of the given name. The target
returned may be imported or built within the project. */
- cmTarget* FindTargetToUse(const char* name);
+ cmTarget* FindTargetToUse(const char* name, bool excludeAliases = false);
+ bool IsAlias(const char *name);
cmGeneratorTarget* FindGeneratorTargetToUse(const char* name);
/**
@@ -902,6 +904,7 @@ protected:
// libraries, classes, and executables
cmTargets Targets;
+ std::map<std::string, cmTarget*> AliasTargets;
cmGeneratorTargetsType GeneratorTargets;
std::vector<cmSourceFile*> SourceFiles;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index b5e5225..4207860 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -244,6 +244,11 @@ bool cmSetPropertyCommand::HandleTargetMode()
for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
+ if (this->Makefile->IsAlias(ni->c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(ni->c_str()))
{
// Handle the current target.
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index a2b50a8..78ef393 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -72,6 +72,11 @@ bool cmSetTargetPropertiesCommand
int i;
for(i = 0; i < numFiles; ++i)
{
+ if (this->Makefile->IsAlias(args[i].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
bool ret = cmSetTargetPropertiesCommand::SetOneTarget
(args[i].c_str(),propertyPairs,this->Makefile);
if (!ret)
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 667c685..13cd006 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -969,6 +969,12 @@ void cmTarget::DefineProperties(cmake *cm)
"This is the configuration-specific version of OUTPUT_NAME.");
cm->DefineProperty
+ ("ALIASED_TARGET", cmProperty::TARGET,
+ "Name of target aliased by this target.",
+ "If this is an ALIAS target, this property contains the name of the "
+ "target aliased.");
+
+ cm->DefineProperty
("<CONFIG>_OUTPUT_NAME", cmProperty::TARGET,
"Old per-configuration target file base name.",
"This is a configuration-specific version of OUTPUT_NAME. "
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 0ee9420..863b391 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -31,6 +31,11 @@ bool cmTargetLinkLibrariesCommand
return false;
}
+ if (this->Makefile->IsAlias(args[0].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
// Lookup the target for which libraries are specified.
this->Target =
this->Makefile->GetCMakeInstance()
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 37aa604..1862cb6 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -26,6 +26,11 @@ bool cmTargetPropCommandBase
}
// Lookup the target for which libraries are specified.
+ if (this->Makefile->IsAlias(args[0].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
this->Target =
this->Makefile->GetCMakeInstance()
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 4eff19e..33e159b 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -48,15 +48,20 @@ static void cmVariableWatchCommandVariableAccessed(
{
newLFF.Arguments.clear();
newLFF.Arguments.push_back(
- cmListFileArgument(variable, true, "unknown", 9999));
+ cmListFileArgument(variable, cmListFileArgument::Quoted,
+ "unknown", 9999));
newLFF.Arguments.push_back(
- cmListFileArgument(accessString, true, "unknown", 9999));
+ cmListFileArgument(accessString, cmListFileArgument::Quoted,
+ "unknown", 9999));
newLFF.Arguments.push_back(
- cmListFileArgument(newValue?newValue:"", true, "unknown", 9999));
+ cmListFileArgument(newValue?newValue:"", cmListFileArgument::Quoted,
+ "unknown", 9999));
newLFF.Arguments.push_back(
- cmListFileArgument(currentListFile, true, "unknown", 9999));
+ cmListFileArgument(currentListFile, cmListFileArgument::Quoted,
+ "unknown", 9999));
newLFF.Arguments.push_back(
- cmListFileArgument(stack, true, "unknown", 9999));
+ cmListFileArgument(stack, cmListFileArgument::Quoted,
+ "unknown", 9999));
newLFF.Name = data->Command;
newLFF.FilePath = "Some weird path";
newLFF.Line = 9999;
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 4000345..7d2eead 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -49,9 +49,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
unsigned int i;
for(i =0; i < this->Args.size(); ++i)
{
- err += (this->Args[i].Quoted?"\"":"");
+ err += (this->Args[i].Delim?"\"":"");
err += this->Args[i].Value;
- err += (this->Args[i].Quoted?"\"":"");
+ err += (this->Args[i].Delim?"\"":"");
err += " ";
}
err += "(";