Author: hpoussin
Date: Wed Sep 12 11:04:32 2007
New Revision: 29012
URL:
http://svn.reactos.org/svn/reactos?rev=29012&view=rev
Log:
Cleanup GetDirectory(), GetFilename() and GetExtension() usage
Modified:
trunk/reactos/tools/rbuild/automaticdependency.cpp
trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp
trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
trunk/reactos/tools/rbuild/compilationunit.cpp
trunk/reactos/tools/rbuild/module.cpp
trunk/reactos/tools/rbuild/rbuild.h
trunk/reactos/tools/rbuild/testsupportcode.cpp
trunk/reactos/tools/rbuild/wineresource.cpp
Modified: trunk/reactos/tools/rbuild/automaticdependency.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/automaticdepe…
==============================================================================
--- trunk/reactos/tools/rbuild/automaticdependency.cpp (original)
+++ trunk/reactos/tools/rbuild/automaticdependency.cpp Wed Sep 12 11:04:32 2007
@@ -26,6 +26,18 @@
using std::string;
using std::vector;
using std::map;
+
+static std::string
+GetExtension ( const std::string& filename )
+{
+ size_t index = filename.find_last_of ( '/' );
+ if (index == string::npos) index = 0;
+ string tmp = filename.substr( index, filename.size() - index );
+ size_t ext_index = tmp.find_last_of( '.' );
+ if (ext_index != string::npos)
+ return filename.substr ( index + ext_index, filename.size() );
+ return "";
+}
SourceFile::SourceFile ( AutomaticDependency* automaticDependency,
const Module& module,
@@ -409,17 +421,6 @@
return false;
}
-string
-AutomaticDependency::GetFilename ( const string& filename )
-{
- size_t index = filename.find_last_of ( cSep );
- if (index == string::npos)
- return filename;
- else
- return filename.substr ( index + 1,
- filename.length () - index - 1);
-}
-
void
AutomaticDependency::GetIncludeDirectories ( vector<Include*>& includes,
const Module& module,
Modified: trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/codeb…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp Wed Sep 12 11:04:32 2007
@@ -101,6 +101,18 @@
}
}
+static std::string
+GetExtension ( const std::string& filename )
+{
+ size_t index = filename.find_last_of ( '/' );
+ if (index == string::npos) index = 0;
+ string tmp = filename.substr( index, filename.size() - index );
+ size_t ext_index = tmp.find_last_of( '.' );
+ if (ext_index != string::npos)
+ return filename.substr ( index + ext_index, filename.size() );
+ return "";
+}
+
static bool FileExists(string &filename)
{
ifstream file(filename.c_str());
@@ -342,7 +354,7 @@
string path_basedir = module.GetPathToBaseDir ();
string intenv = Environment::GetIntermediatePath ();
string outenv = Environment::GetOutputPath ();
- string module_type = GetExtension(module.output->name);
+ string module_type = GetExtension(*module.output);
string cbproj_path = module.output->relative_path;
string CompilerVar;
string baseaddr;
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Wed Sep 12 11:04:32 2007
@@ -266,7 +266,7 @@
{
string filename = file->name;
- string extension = GetExtension ( filename );
+ string extension = GetExtension ( *file );
if ( extension == ".spec" || extension == ".SPEC" )
{
string basename = GetBasename ( filename );
@@ -305,7 +305,7 @@
MingwModuleHandler::GetExtraDependencies (
const FileLocation *file ) const
{
- string extension = GetExtension ( file->name );
+ string extension = GetExtension ( *file );
if ( extension == ".idl" || extension == ".IDL" )
{
if ( (module.type == RpcServer) || (module.type == RpcClient) )
@@ -349,7 +349,7 @@
bool
MingwModuleHandler::IsGeneratedFile ( const File& file ) const
{
- string extension = GetExtension ( file.file.name );
+ string extension = GetExtension ( file.file );
return ( extension == ".spec" || extension == ".SPEC" );
}
@@ -486,10 +486,9 @@
const FileLocation* sourceFile,
string_list* pclean_files ) const
{
- string sourceFilename = sourceFile->name;
DirectoryLocation destination_directory;
string newExtension;
- string extension = GetExtension ( sourceFilename );
+ string extension = GetExtension ( *sourceFile );
if ( extension == ".rc" || extension == ".RC" )
newExtension = ".coff";
else if ( extension == ".spec" || extension == ".SPEC" )
@@ -1353,8 +1352,7 @@
const string& widlflagsMacro )
{
const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string filename = backend->GetFullName ( *sourceFile );
- string extension = GetExtension ( filename );
+ string extension = GetExtension ( *sourceFile );
if ( extension == ".c" || extension == ".C" )
{
GenerateGccCommand ( sourceFile,
@@ -1419,7 +1417,7 @@
__LINE__,
"Unsupported filename extension '%s' in
file '%s'",
extension.c_str (),
- filename.c_str () );
+ backend->GetFullName ( *sourceFile ).c_str () );
}
void
@@ -1465,10 +1463,9 @@
fprintf ( fMakefile,
"ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
- string filename = module.output->name;
FileLocation nostripFilename ( OutputDirectory,
module.output->relative_path,
- GetBasename ( filename ) + ".nostrip" +
GetExtension ( filename ) );
+ GetBasename ( module.output->name ) +
".nostrip" + GetExtension ( *module.output ) );
CLEAN_FILE ( nostripFilename );
OutputCopyCommand ( *module.output, nostripFilename );
@@ -1881,7 +1878,7 @@
{
CompilationUnit& compilationUnit =
*library.importedModule->non_if_data.compilationUnits[j];
const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( sourceFile->name );
+ string extension = GetExtension ( *sourceFile );
if ( extension == ".idl" || extension == ".IDL" )
{
string basename = GetBasename ( sourceFile->name );
@@ -1921,7 +1918,7 @@
{
CompilationUnit& compilationUnit = *compilationUnits[i];
const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( sourceFile->name );
+ string extension = GetExtension ( *sourceFile );
if ( extension == ".spec" || extension == ".SPEC" )
GetSpecObjectDependencies ( s, sourceFile );
}
@@ -2300,7 +2297,7 @@
{
CompilationUnit& compilationUnit = *compilationUnits[i];
const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( sourceFile->name );
+ string extension = GetExtension ( *sourceFile );
if ( extension == ".spec" || extension == ".SPEC" )
GetSpecObjectDependencies ( dependencies, sourceFile );
if ( extension == ".idl" || extension == ".IDL" )
Modified: trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msbui…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp Wed Sep 12 11:04:32 2007
@@ -83,7 +83,7 @@
{
size_t i;
- string module_type = GetExtension(module.output->name);
+ string module_type = GetExtension(*module.output);
vector<string> source_files, resource_files, includes, libraries;
vector<string> header_files, common_defines, compiler_flags;
vector<string> vars, values;
Modified: trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp Wed Sep 12 11:04:32 2007
@@ -56,7 +56,7 @@
imports.push_back ( module.non_if_data.libraries[i]->name );
}
- string module_type = GetExtension(module.output->name);
+ string module_type = GetExtension(*module.output);
bool lib = (module_type == ".lib") || (module_type == ".a");
bool dll = (module_type == ".dll") || (module_type == ".cpl");
bool exe = (module_type == ".exe") || (module_type == ".scr");
Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Wed Sep 12 11:04:32 2007
@@ -98,7 +98,7 @@
FILE* OUT = fopen ( vcproj_file.c_str(), "wb" );
vector<string> imports;
- string module_type = GetExtension(module.output->name);
+ string module_type = GetExtension(*module.output);
bool lib = (module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type
== RpcServer) || (module_type == ".lib") || (module_type == ".a");
bool dll = (module_type == ".dll") || (module_type == ".cpl");
bool exe = (module_type == ".exe") || (module_type == ".scr");
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationun…
==============================================================================
--- trunk/reactos/tools/rbuild/compilationunit.cpp (original)
+++ trunk/reactos/tools/rbuild/compilationunit.cpp Wed Sep 12 11:04:32 2007
@@ -67,7 +67,7 @@
if ( files.size () != 1 )
return false;
File* file = files[0];
- string extension = GetExtension ( file->file.name );
+ string extension = GetExtension ( file->file );
return ( extension == ".spec" || extension == ".SPEC" );
}
@@ -78,7 +78,7 @@
for ( i = 0; i < files.size (); i++ )
{
File& file = *files[i];
- string fileExtension = GetExtension ( file.file.name );
+ string fileExtension = GetExtension ( file.file );
if ( !stricmp ( fileExtension.c_str (), extension.c_str () ) )
return true;
}
Modified: trunk/reactos/tools/rbuild/module.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?re…
==============================================================================
--- trunk/reactos/tools/rbuild/module.cpp (original)
+++ trunk/reactos/tools/rbuild/module.cpp Wed Sep 12 11:04:32 2007
@@ -137,7 +137,7 @@
return FixSeparator(path + cSep + att_value);
}
-string
+static string
GetExtension ( const string& filename )
{
size_t index = filename.find_last_of ( '/' );
@@ -150,23 +150,9 @@
}
string
-GetDirectory ( const string& filename )
-{
- size_t index = filename.find_last_of ( cSep );
- if ( index == string::npos )
- return "";
- else
- return filename.substr ( 0, index );
-}
-
-string
-GetFilename ( const string& filename )
-{
- size_t index = filename.find_last_of ( cSep );
- if ( index == string::npos )
- return filename;
- else
- return filename.substr ( index + 1, filename.length () - index );
+GetExtension ( const FileLocation& file )
+{
+ return GetExtension ( file.name );
}
string
Modified: trunk/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=…
==============================================================================
--- trunk/reactos/tools/rbuild/rbuild.h (original)
+++ trunk/reactos/tools/rbuild/rbuild.h Wed Sep 12 11:04:32 2007
@@ -775,7 +775,6 @@
AutomaticDependency ( const Project& project );
~AutomaticDependency ();
- std::string GetFilename ( const std::string& filename );
bool LocateIncludedFile ( const FileLocation& directory,
const std::string& includedFilename,
std::string& resolvedFilename );
@@ -1030,13 +1029,7 @@
const std::string& att_value );
extern std::string
-GetExtension ( const std::string& filename );
-
-extern std::string
-GetDirectory ( const std::string& filename );
-
-extern std::string
-GetFilename ( const std::string& filename );
+GetExtension ( const FileLocation& file );
extern std::string
NormalizeFilename ( const std::string& filename );
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/testsupportco…
==============================================================================
--- trunk/reactos/tools/rbuild/testsupportcode.cpp (original)
+++ trunk/reactos/tools/rbuild/testsupportcode.cpp Wed Sep 12 11:04:32 2007
@@ -23,6 +23,16 @@
using std::string;
using std::vector;
+static std::string
+GetFilename ( const std::string& filename )
+{
+ size_t index = filename.find_last_of ( cSep );
+ if ( index == string::npos )
+ return filename;
+ else
+ return filename.substr ( index + 1, filename.length () - index );
+}
+
TestSupportCode::TestSupportCode ( const Project& project )
: project ( project )
{
Modified: trunk/reactos/tools/rbuild/wineresource.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/wineresource.…
==============================================================================
--- trunk/reactos/tools/rbuild/wineresource.cpp (original)
+++ trunk/reactos/tools/rbuild/wineresource.cpp Wed Sep 12 11:04:32 2007
@@ -37,7 +37,7 @@
bool
WineResource::IsSpecFile ( const File& file )
{
- string extension = GetExtension ( file.file.name );
+ string extension = GetExtension ( file.file );
if ( extension == ".spec" || extension == ".SPEC" )
return true;
return false;
@@ -58,7 +58,7 @@
bool
WineResource::IsResourceFile ( const File& file )
{
- string extension = GetExtension ( file.file.name );
+ string extension = GetExtension ( file.file );
if ( extension == ".rc" || extension == ".RC" )
return true;
return false;