Commit 38482b46 authored by Brad King's avatar Brad King
Browse files

ENH: Merged use of the kwsys RegularExpression class instead of cmRegularExpression.

parent b2368399
......@@ -35,6 +35,7 @@ ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
SET(KWSYS_NAMESPACE cmsys)
SET(KWSYS_USE_SystemTools 1)
SET(KWSYS_USE_Directory 1)
SET(KWSYS_USE_RegularExpression 1)
SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
SUBDIRS(Source/kwsys)
......
......@@ -5,7 +5,6 @@ cmake.cxx
cmakewizard.cxx
cmMakeDepend.cxx
cmMakefile.cxx
cmRegularExpression.cxx
cmSourceFile.cxx
cmSystemTools.cxx
cmDocumentation.cxx
......@@ -25,7 +24,6 @@ cmake.h
cmakewizard.h
cmMakeDepend.h
cmMakefile.h
cmRegularExpression.h
cmSourceFile.h
cmSystemTools.h
cmDynamicLoader.h
......
......@@ -16,6 +16,8 @@
=========================================================================*/
#include "cmBuildNameCommand.h"
#include <cmsys/RegularExpression.hxx>
// cmBuildNameCommand
bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args)
{
......@@ -28,7 +30,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args)
if(cacheValue)
{
// do we need to correct the value?
cmRegularExpression reg("[()/]");
cmsys::RegularExpression reg("[()/]");
if (reg.find(cacheValue))
{
std::string cv = cacheValue;
......@@ -53,7 +55,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args)
if(buildname.length())
{
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
cmRegularExpression reg( RegExp.c_str() );
cmsys::RegularExpression reg( RegExp.c_str() );
if(reg.find(buildname.c_str()))
{
buildname = reg.match(1) + "-" + reg.match(2);
......
......@@ -15,10 +15,11 @@
=========================================================================*/
#include "cmCTest.h"
#include "cmRegularExpression.h"
#include "cmSystemTools.h"
#include "cmListFileCache.h"
#include <cmsys/RegularExpression.hxx>
#ifdef HAVE_CURL
# include "cmCTestSubmit.h"
# include "curl/curl.h"
......@@ -590,10 +591,10 @@ int cmCTest::UpdateDirectory()
std::vector<cmStdString> lines;
cmSystemTools::Split(goutput.c_str(), lines);
std::cout << "Updated; gathering version information" << std::endl;
cmRegularExpression date_author("^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;");
cmRegularExpression revision("^revision +([^ ]*) *$");
cmRegularExpression end_of_file("^=============================================================================$");
cmRegularExpression end_of_comment("^----------------------------$");
cmsys::RegularExpression date_author("^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;");
cmsys::RegularExpression revision("^revision +([^ ]*) *$");
cmsys::RegularExpression end_of_file("^=============================================================================$");
cmsys::RegularExpression end_of_comment("^----------------------------$");
std::string current_path = "";
bool first_file = true;
......@@ -974,7 +975,7 @@ int cmCTest::BuildDirectory()
// Errors
for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
{
cmRegularExpression re(cmCTestErrorMatches[cc]);
cmsys::RegularExpression re(cmCTestErrorMatches[cc]);
std::vector<std::string>::size_type kk;
for ( kk = 0; kk < lines.size(); kk ++ )
{
......@@ -987,7 +988,7 @@ int cmCTest::BuildDirectory()
// Warnings
for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ )
{
cmRegularExpression re(cmCTestWarningMatches[cc]);
cmsys::RegularExpression re(cmCTestWarningMatches[cc]);
std::vector<std::string>::size_type kk;
for ( kk = 0; kk < lines.size(); kk ++ )
{
......@@ -1000,7 +1001,7 @@ int cmCTest::BuildDirectory()
// Errors exceptions
for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
{
cmRegularExpression re(cmCTestErrorExceptions[cc]);
cmsys::RegularExpression re(cmCTestErrorExceptions[cc]);
std::vector<int>::size_type kk;
for ( kk =0; kk < markedLines.size(); kk ++ )
{
......@@ -1016,7 +1017,7 @@ int cmCTest::BuildDirectory()
// Warning exceptions
for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
{
cmRegularExpression re(cmCTestWarningExceptions[cc]);
cmsys::RegularExpression re(cmCTestWarningExceptions[cc]);
std::vector<int>::size_type kk;
for ( kk =0; kk < markedLines.size(); kk ++ )
{
......@@ -1614,9 +1615,9 @@ void cmCTest::ProcessDirectory(std::vector<std::string> &passed,
int firstTest = 1;
long line = 0;
cmRegularExpression ireg(this->m_IncludeRegExp.c_str());
cmRegularExpression ereg(this->m_ExcludeRegExp.c_str());
cmRegularExpression dartStuff("([\t\n ]*<DartMeasurement.*/DartMeasurement[a-zA-Z]*>[\t ]*[\n]*)");
cmsys::RegularExpression ireg(this->m_IncludeRegExp.c_str());
cmsys::RegularExpression ereg(this->m_ExcludeRegExp.c_str());
cmsys::RegularExpression dartStuff("([\t\n ]*<DartMeasurement.*/DartMeasurement[a-zA-Z]*>[\t ]*[\n]*)");
bool parseError;
while ( fin )
......
......@@ -19,9 +19,10 @@
#include "cmSystemTools.h"
#include "cmCacheManager.h"
#include "cmMakefile.h"
#include "cmRegularExpression.h"
#include "stdio.h"
#include <cmsys/RegularExpression.hxx>
#if defined(_WIN32) || defined(__CYGWIN__)
# include <windows.h>
#endif // _WIN32
......@@ -84,9 +85,9 @@ bool cmCacheManager::ParseEntry(const char* entry,
CacheEntryType& type)
{
// input line is: key:type=value
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
// input line is: "key":type=value
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
bool flag = false;
if(regQuoted.find(entry))
{
......
......@@ -16,6 +16,8 @@
=========================================================================*/
#include "cmConfigureFileCommand.h"
#include <cmsys/RegularExpression.hxx>
// cmConfigureFileCommand
bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args)
{
......@@ -106,7 +108,7 @@ void cmConfigureFileCommand::ConfigureFile()
// now copy input to output and expand variables in the
// input file at the same time
std::string inLine;
cmRegularExpression cmdefine("#cmakedefine[ \t]*([A-Za-z_0-9]*)");
cmsys::RegularExpression cmdefine("#cmakedefine[ \t]*([A-Za-z_0-9]*)");
while( cmSystemTools::GetLineFromStream(fin, inLine) )
{
m_Makefile->ExpandVariablesInString(inLine, m_EscapeQuotes, m_AtOnly);
......
......@@ -17,6 +17,8 @@
#include "cmIfCommand.h"
#include <stdlib.h> // required for atof
#include <cmsys/RegularExpression.hxx>
bool cmIfFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
{
......@@ -217,7 +219,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
if (args.size() == 3 && (args[1] == "MATCHES"))
{
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
cmRegularExpression regEntry(args[2].c_str());
cmsys::RegularExpression regEntry(args[2].c_str());
// check for black line or comment
if (!regEntry.find(def))
......
......@@ -16,7 +16,8 @@
=========================================================================*/
#include "cmListFileCache.h"
#include "cmSystemTools.h"
#include "cmRegularExpression.h"
#include <cmsys/RegularExpression.hxx>
cmListFileCache* cmListFileCache::Instance = 0;
......@@ -174,10 +175,10 @@ bool cmListFileCache::ParseFunction(std::ifstream& fin,
{
++line;
RemoveComments(inbuffer);
cmRegularExpression blankLine("^[ \t\r]*$");
cmRegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t\r]*$");
cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
cmRegularExpression lastLine("^(.*)\\)[ \t\r]*$");
cmsys::RegularExpression blankLine("^[ \t\r]*$");
cmsys::RegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t\r]*$");
cmsys::RegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
cmsys::RegularExpression lastLine("^(.*)\\)[ \t\r]*$");
// check for blank line or comment
if(blankLine.find(inbuffer.c_str()) )
......@@ -258,9 +259,9 @@ void cmListFileCache::GetArguments(std::string& line,
std::vector<cmListFileArgument>& arguments)
{
// Match a normal argument (not quoted, no spaces).
cmRegularExpression normalArgument("[ \t]*(([^ \t\r\\]|[\\].)+)[ \t\r]*");
cmsys::RegularExpression normalArgument("[ \t]*(([^ \t\r\\]|[\\].)+)[ \t\r]*");
// Match a quoted argument (surrounded by double quotes, spaces allowed).
cmRegularExpression quotedArgument("[ \t]*(\"([^\"\\]|[\\].)*\")[ \t\r]*");
cmsys::RegularExpression quotedArgument("[ \t]*(\"([^\"\\]|[\\].)*\")[ \t\r]*");
bool done = false;
while(!done)
......
......@@ -16,6 +16,7 @@
=========================================================================*/
#include "cmLoadCacheCommand.h"
#include <cmsys/RegularExpression.hxx>
// cmLoadCacheCommand
bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args)
......@@ -202,9 +203,9 @@ bool cmLoadCacheCommand::ParseEntry(const char* entry, std::string& var,
std::string& value)
{
// input line is: key:type=value
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
// input line is: "key":type=value
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
bool flag = false;
if(regQuoted.find(entry))
{
......
......@@ -22,6 +22,8 @@ PURPOSE. See the above copyright notices for more information.
#include "cmCacheManager.h"
#include "cmake.h"
#include <cmsys/RegularExpression.hxx>
cmLocalCodeWarriorGenerator::cmLocalCodeWarriorGenerator()
{
}
......@@ -168,9 +170,9 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout,
// library paths
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
cmsys::RegularExpression isAframework("[ \t]*\\-framework");
cmsys::RegularExpression isEnvironment("\\${");
cmsys::RegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
......@@ -564,9 +566,9 @@ void cmLocalCodeWarriorGenerator::WriteFileList(std::ostream& fout,
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
cmsys::RegularExpression isAframework("[ \t]*\\-framework");
cmsys::RegularExpression isEnvironment("\\${");
cmsys::RegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
......@@ -694,9 +696,9 @@ void cmLocalCodeWarriorGenerator::WriteLinkOrder(std::ostream& fout,
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
cmsys::RegularExpression isAframework("[ \t]*\\-framework");
cmsys::RegularExpression isEnvironment("\\${");
cmsys::RegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
......@@ -814,7 +816,7 @@ void cmLocalCodeWarriorGenerator::WriteLinkOrder(std::ostream& fout,
// we need at least one framework for the XML to be valid
// generate framework list
cmRegularExpression reg("[ \t]*\\-framework[ \t]+([^ \t]+)");
cmsys::RegularExpression reg("[ \t]*\\-framework[ \t]+([^ \t]+)");
std::vector<std::string> frameworks;
lib = libs.begin();
......@@ -967,9 +969,9 @@ void cmLocalCodeWarriorGenerator::WriteGroup(std::ostream& fout,
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
cmsys::RegularExpression isAframework("[ \t]*\\-framework");
cmsys::RegularExpression isEnvironment("\\${");
cmsys::RegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
......
......@@ -22,6 +22,8 @@
#include "cmMakeDepend.h"
#include "cmCacheManager.h"
#include "cmGeneratedFileStream.h"
#include <cmsys/RegularExpression.hxx>
#include <stdio.h>
cmLocalUnixMakefileGenerator::cmLocalUnixMakefileGenerator()
......@@ -565,7 +567,7 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string regexp = ".*\\";
regexp += linkSuffix;
regexp += "$";
cmRegularExpression hasSuffix(regexp.c_str());
cmsys::RegularExpression hasSuffix(regexp.c_str());
std::string librariesLinked;
const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries();
for(cmTarget::LinkLibraries::const_iterator lib = libs.begin();
......@@ -579,7 +581,7 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
// if a variable expands to nothing.
if (lib->first.size() == 0) continue;
// if it is a full path break it into -L and -l
cmRegularExpression reg("([ \t]*\\-l)|([ \t]*\\-framework)|(\\${)");
cmsys::RegularExpression reg("([ \t]*\\-l)|([ \t]*\\-framework)|(\\${)");
if(lib->first.find('/') != std::string::npos
&& !reg.find(lib->first))
{
......@@ -597,8 +599,8 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
runtimeDirs.push_back( libpath );
}
}
cmRegularExpression libname("^lib([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
cmRegularExpression libname_noprefix("([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
cmsys::RegularExpression libname("^lib([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
cmsys::RegularExpression libname_noprefix("([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
if(libname.find(file))
{
// Library had "lib" prefix.
......
......@@ -22,6 +22,8 @@
#include "cmCacheManager.h"
#include <queue>
#include <cmsys/RegularExpression.hxx>
cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator()
{
}
......@@ -607,7 +609,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
// possible
std::ifstream fin(m_DSPHeaderTemplate.c_str());
cmRegularExpression reg("# Name ");
cmsys::RegularExpression reg("# Name ");
if(!fin)
{
cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str());
......
......@@ -18,6 +18,7 @@
#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
#include <cmsys/RegularExpression.hxx>
void cmDependInformation::AddDependencies(cmDependInformation* info)
{
......@@ -189,7 +190,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
// #include directives
void cmMakeDepend::DependWalk(cmDependInformation* info)
{
cmRegularExpression includeLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
cmsys::RegularExpression includeLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
std::ifstream fin(info->m_FullPath.c_str());
if(!fin)
{
......
......@@ -19,9 +19,10 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmRegularExpression.h"
#include "cmStandardIncludes.h"
#include <cmsys/RegularExpression.hxx>
/** \class cmDependInformation
* \brief Store dependency information for a single source file.
*
......@@ -150,8 +151,8 @@ protected:
const cmMakefile* m_Makefile;
bool m_Verbose;
cmRegularExpression m_IncludeFileRegularExpression;
cmRegularExpression m_ComplainFileRegularExpression;
cmsys::RegularExpression m_IncludeFileRegularExpression;
cmsys::RegularExpression m_ComplainFileRegularExpression;
std::vector<std::string> m_IncludeDirectories;
typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
DependInformationMap m_DependInformationMap;
......
......@@ -29,6 +29,9 @@
#include "cmake.h"
#include <stdio.h> // required for sprintf
#include <stdlib.h> // required for atoi
#include <cmsys/RegularExpression.hxx>
// default is not to be building executables
cmMakefile::cmMakefile()
{
......@@ -458,7 +461,7 @@ void cmMakefile::AddCustomCommand(const char* source,
d != outputs.end(); ++d)
{
// if this looks like a real file then use is as the main depend
cmRegularExpression SourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
cmsys::RegularExpression SourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
if (SourceFiles.find(source))
{
this->AddCustomCommandToOutput(d->c_str(), command, commandArgs,
......@@ -1461,7 +1464,7 @@ void cmMakefile::RemoveVariablesInString(std::string& source,
{
if(!atOnly)
{
cmRegularExpression var("(\\${[A-Za-z_0-9]*})");
cmsys::RegularExpression var("(\\${[A-Za-z_0-9]*})");
while (var.find(source))
{
source.erase(var.start(),var.end() - var.start());
......@@ -1470,13 +1473,13 @@ void cmMakefile::RemoveVariablesInString(std::string& source,
if(!atOnly)
{
cmRegularExpression varb("(\\$ENV{[A-Za-z_0-9]*})");
cmsys::RegularExpression varb("(\\$ENV{[A-Za-z_0-9]*})");
while (varb.find(source))
{
source.erase(varb.start(),varb.end() - varb.start());
}
}
cmRegularExpression var2("(@[A-Za-z_0-9]*@)");
cmsys::RegularExpression var2("(@[A-Za-z_0-9]*@)");
while (var2.find(source))
{
source.erase(var2.start(),var2.end() - var2.start());
......
This diff is collapsed.
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Original Copyright notice:
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// Permission is granted to any individual or institution to use, copy, modify,
// and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting
// documentation.
//
// Texas Instruments Incorporated provides this software "as is" without
// express or implied warranty.
//
// Created: MNF 06/13/89 Initial Design and Implementation
// Updated: LGO 08/09/89 Inherit from Generic
// Updated: MBN 09/07/89 Added conditional exception handling
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
// Updated: DLS 03/22/91 New lite version
//
#ifndef cmRegularExpression_h
#define cmRegularExpression_h
#include "cmStandardIncludes.h"
const int NSUBEXP = 10;
/** \class cmRegularExpression
* \brief Implements pattern matching with regular expressions.
*
* This is the header file for the regular expression class. An object of
* this class contains a regular expression, in a special "compiled" format.
* This compiled format consists of several slots all kept as the objects
* private data. The cmRegularExpression class provides a convenient way to
* represent regular expressions. It makes it easy to search for the same
* regular expression in many different strings without having to compile a
* string to regular expression format more than necessary.
*
* This class implements pattern matching via regular expressions.
* A regular expression allows a programmer to specify complex
* patterns that can be searched for and matched against the
* character string of a string object. In its simplest form, a
* regular expression is a sequence of characters used to
* search for exact character matches. However, many times the
* exact sequence to be found is not known, or only a match at
* the beginning or end of a string is desired. The cmRegularExpression regu-
* lar expression class implements regular expression pattern
* matching as is found and implemented in many UNIX commands
* and utilities.
*
* Example: The perl code
*
* $filename =~ m"([a-z]+)\.cc";
* print $1;
*
* Is written as follows in C++
*
* cmRegularExpression re("([a-z]+)\\.cc");
* re.find(filename);
* cerr << re.match(1);
*
*
* The regular expression class provides a convenient mechanism
* for specifying and manipulating regular expressions. The
* regular expression object allows specification of such pat-
* terns by using the following regular expression metacharac-
* ters:
*
* ^ Matches at beginning of a line
*
* $ Matches at end of a line
*
* . Matches any single character
*
* [ ] Matches any character(s) inside the brackets
*
* [^ ] Matches any character(s) not inside the brackets
*
* - Matches any character in range on either side of a dash
*
* * Matches preceding pattern zero or more times
*
* + Matches preceding pattern one or more times
*
* ? Matches preceding pattern zero or once only
*
* () Saves a matched expression and uses it in a later match
*
* Note that more than one of these metacharacters can be used
* in a single regular expression in order to create complex
* search patterns. For example, the pattern [^ab1-9] says to
* match any character sequence that does not begin with the
* characters "ab" followed by numbers in the series one
* through nine.
*
* There are three constructors for cmRegularExpression. One just creates an
* empty cmRegularExpression object. Another creates a cmRegularExpression
* object and initializes it with a regular expression that is given in the
* form of a char*. The third takes a reference to a cmRegularExpression
* object as an argument and creates an object initialized with the
* information from the given cmRegularExpression object.
*
* The find member function finds the first occurence of the regualr
* expression of that object in the string given to find as an argument. Find
* returns a boolean, and if true, mutates the private data appropriately.
* Find sets pointers to the beginning and end of the thing last found, they
* are pointers into the actual string that was searched. The start and end
* member functions return indicies into the searched string that correspond
* to the beginning and end pointers respectively. The compile member
* function takes a char* and puts the compiled version of the char* argument
* into the object's private data fields. The == and != operators only check
* the to see if the compiled regular expression is the same, and the
* deep_equal functions also checks to see if the start and end pointers are
* the same. The is_valid function returns false if program is set to NULL,
* (i.e. there is no valid compiled exression). The set_invalid function sets
* the program to NULL (Warning: this deletes the compiled expression). The
* following examples may help clarify regular expression usage:
*
* * The regular expression "^hello" matches a "hello" only at the
* beginning of a line. It would match "hello there" but not "hi,
* hello there".
*
* * The regular expression "long$" matches a "long" only at the end
* of a line. It would match "so long\0", but not "long ago".
*
* * The regular expression "t..t..g" will match anything that has a
* "t" then any two characters, another "t", any two characters and
* then a "g". It will match "testing", or "test again" but would
* not match "toasting"
*
* * The regular expression "[1-9ab]" matches any number one through
* nine, and the characters "a" and "b". It would match "hello 1"
* or "begin", but would not match "no-match".
*
* * The regular expression "[^1-9ab]" matches any character that is
* not a number one through nine, or an "a" or "b". It would NOT
* match "hello 1" or "begin", but would match "no-match".
*
* * The regular expression "br* " matches something that begins with
* a "b", is followed by zero or more "r"s, and ends in a space. It
* would match "brrrrr ", and "b ", but would not match "brrh ".
*
* * The regular expression "br+ " matches something that begins with
* a "b", is followed by one or more "r"s, and ends in a space. It
* would match "brrrrr ", and "br ", but would not match "b " or
* "brrh ".
*