diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2000-09-27 19:01:19 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2000-09-27 19:01:19 (GMT) |
commit | 74c1345333b456eb34480c987bc186ef2af3c536 (patch) | |
tree | 0c0751e4bfef94831377d7f5e20202b27cd06de9 /Source/cmSystemTools.cxx | |
parent | 1e3ba0f1d72873233193ce69614fd4bd880e8fc5 (diff) | |
download | CMake-74c1345333b456eb34480c987bc186ef2af3c536.zip CMake-74c1345333b456eb34480c987bc186ef2af3c536.tar.gz CMake-74c1345333b456eb34480c987bc186ef2af3c536.tar.bz2 |
ENH: change ME to LIBRARY and added PROJECT, also remove ITK stuff and replaced with CMake
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b8a44c9..aa80d51 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1,6 +1,7 @@ #include "cmSystemTools.h" #include "errno.h" #include <sys/stat.h> +#include "cmRegularExpression.h" #ifdef _MSC_VER #include <windows.h> @@ -125,7 +126,7 @@ void cmSystemTools::ReadList(std::vector<std::string>& stringList, bool done = false; while ( !done ) { - fin.getline(inbuffer, 2047 ); + fin.getline(inbuffer, sizeof(inbuffer) ); std::string inname = inbuffer; if(inname.find('\\') == std::string::npos) { @@ -154,3 +155,45 @@ void cmSystemTools::ConvertToUnixSlashes(std::string& path) path = path.substr(0, path.size()-1); } } + + +int cmSystemTools::Grep(const char* dir, const char* file, const char* expression) +{ + std::string path = dir; + path += "/"; + path += file; + std::ifstream fin(path.c_str()); + char buffer[2056]; + int count = 0; + cmRegularExpression reg(expression); + while(fin) + { + fin.getline(buffer, sizeof(buffer)); + count += reg.find(buffer); + } + return count; +} + +std::string cmSystemTools::ExtractVariable(const char* variable, + const char* l) +{ + std::string line = l; + size_t varstart = line.find(variable); + size_t start = line.find("="); + if(start != std::string::npos && start > varstart ) + { + start++; + while(line[start] == ' ' && start < line.size()) + { + start++; + } + size_t end = line.size()-1; + while(line[end] == ' ' && end > start) + { + end--; + } + return line.substr(start, end).c_str(); + } + return std::string(""); +} + |