STYLE: Minor style
This commit is contained in:
parent
428bc24823
commit
1defe94e31
|
@ -38,7 +38,7 @@ class DirectoryInternals
|
||||||
public:
|
public:
|
||||||
// Array of Files
|
// Array of Files
|
||||||
kwsys_stl::vector<kwsys_stl::string> Files;
|
kwsys_stl::vector<kwsys_stl::string> Files;
|
||||||
|
|
||||||
// Path to Open'ed directory
|
// Path to Open'ed directory
|
||||||
kwsys_stl::string Path;
|
kwsys_stl::string Path;
|
||||||
};
|
};
|
||||||
|
@ -113,32 +113,32 @@ bool Directory::Load(const char* name)
|
||||||
#endif
|
#endif
|
||||||
char* buf;
|
char* buf;
|
||||||
size_t n = strlen(name);
|
size_t n = strlen(name);
|
||||||
if ( name[n - 1] == '/' )
|
if ( name[n - 1] == '/' )
|
||||||
{
|
{
|
||||||
buf = new char[n + 1 + 1];
|
buf = new char[n + 1 + 1];
|
||||||
sprintf(buf, "%s*", name);
|
sprintf(buf, "%s*", name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf = new char[n + 2 + 1];
|
buf = new char[n + 2 + 1];
|
||||||
sprintf(buf, "%s/*", name);
|
sprintf(buf, "%s/*", name);
|
||||||
}
|
}
|
||||||
struct _finddata_t data; // data of current file
|
struct _finddata_t data; // data of current file
|
||||||
|
|
||||||
// Now put them into the file array
|
// Now put them into the file array
|
||||||
srchHandle = _findfirst(buf, &data);
|
srchHandle = _findfirst(buf, &data);
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
|
|
||||||
if ( srchHandle == -1 )
|
if ( srchHandle == -1 )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through names
|
// Loop through names
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
this->Internal->Files.push_back(data.name);
|
this->Internal->Files.push_back(data.name);
|
||||||
}
|
}
|
||||||
while ( _findnext(srchHandle, &data) != -1 );
|
while ( _findnext(srchHandle, &data) != -1 );
|
||||||
this->Internal->Path = name;
|
this->Internal->Path = name;
|
||||||
return _findclose(srchHandle) != -1;
|
return _findclose(srchHandle) != -1;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
// 3. Windows which uses LoadLibrary
|
// 3. Windows which uses LoadLibrary
|
||||||
// 4. Most unix systems (including Mac OS X 10.3 and later) which use dlopen (default)
|
// 4. Most unix systems (including Mac OS X 10.3 and later) which use dlopen (default)
|
||||||
// Each part of the ifdef contains a complete implementation for
|
// Each part of the ifdef contains a complete implementation for
|
||||||
// the static methods of DynamicLoader.
|
// the static methods of DynamicLoader.
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE
|
namespace KWSYS_NAMESPACE
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle /* lib */, const
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LibPrefix()
|
const char* DynamicLoader::LibPrefix()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ const char* DynamicLoader::LastError()
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE
|
namespace KWSYS_NAMESPACE
|
||||||
{
|
{
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
LibHandle DynamicLoader::OpenLibrary(const char* libname)
|
LibHandle DynamicLoader::OpenLibrary(const char* libname)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ int DynamicLoader::CloseLibrary(LibHandle lib)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle lib, const char* sym)
|
DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle lib, const char* sym)
|
||||||
{
|
{
|
||||||
void *result;
|
void *result;
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
wchar_t wsym[MB_CUR_MAX];
|
wchar_t wsym[MB_CUR_MAX];
|
||||||
|
@ -233,7 +233,7 @@ DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle lib, const char*
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LibPrefix()
|
const char* DynamicLoader::LibPrefix()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,16 +248,16 @@ const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
|
|
||||||
FormatMessage(
|
FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL,
|
NULL,
|
||||||
GetLastError(),
|
GetLastError(),
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||||
(LPTSTR) &lpMsgBuf,
|
(LPTSTR) &lpMsgBuf,
|
||||||
0,
|
0,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
static char* str = 0;
|
static char* str = 0;
|
||||||
delete [] str;
|
delete [] str;
|
||||||
str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf);
|
str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf);
|
||||||
|
@ -280,7 +280,7 @@ const char* DynamicLoader::LastError()
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE
|
namespace KWSYS_NAMESPACE
|
||||||
{
|
{
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
LibHandle DynamicLoader::OpenLibrary(const char* libname )
|
LibHandle DynamicLoader::OpenLibrary(const char* libname )
|
||||||
{
|
{
|
||||||
|
@ -301,16 +301,16 @@ int DynamicLoader::CloseLibrary(LibHandle lib)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle lib, const char* sym)
|
DynamicLoaderFunction DynamicLoader::GetSymbolAddress(LibHandle lib, const char* sym)
|
||||||
{
|
{
|
||||||
void* result = dlsym(lib, sym);
|
void* result = dlsym(lib, sym);
|
||||||
|
|
||||||
// Hack to cast pointer-to-data to pointer-to-function.
|
// Hack to cast pointer-to-data to pointer-to-function.
|
||||||
return *reinterpret_cast<DynamicLoaderFunction*>(&result);
|
return *reinterpret_cast<DynamicLoaderFunction*>(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LibPrefix()
|
const char* DynamicLoader::LibPrefix()
|
||||||
{
|
{
|
||||||
return "lib";
|
return "lib";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ const char* DynamicLoader::LibExtension()
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
return dlerror();
|
return dlerror();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "testSystemTools.h"
|
#include "testSystemTools.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* toUnixPaths[][2] =
|
const char* toUnixPaths[][2] =
|
||||||
{
|
{
|
||||||
{ "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
|
{ "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
|
||||||
{ "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
|
{ "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
|
||||||
|
@ -50,16 +50,16 @@ const char* toUnixPaths[][2] =
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CheckConvertToUnixSlashes(kwsys_stl::string input,
|
bool CheckConvertToUnixSlashes(kwsys_stl::string input,
|
||||||
kwsys_stl::string output)
|
kwsys_stl::string output)
|
||||||
{
|
{
|
||||||
kwsys_stl::string result = input;
|
kwsys_stl::string result = input;
|
||||||
kwsys::SystemTools::ConvertToUnixSlashes(result);
|
kwsys::SystemTools::ConvertToUnixSlashes(result);
|
||||||
if ( result != output )
|
if ( result != output )
|
||||||
{
|
{
|
||||||
kwsys_ios::cerr
|
kwsys_ios::cerr
|
||||||
<< "Problem with ConvertToUnixSlashes - input: " << input.c_str()
|
<< "Problem with ConvertToUnixSlashes - input: " << input.c_str()
|
||||||
<< " output: " << result.c_str() << " expected: " << output.c_str()
|
<< " output: " << result.c_str() << " expected: " << output.c_str()
|
||||||
<< kwsys_ios::endl;
|
<< kwsys_ios::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -67,25 +67,25 @@ bool CheckConvertToUnixSlashes(kwsys_stl::string input,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* checkEscapeChars[][4] =
|
const char* checkEscapeChars[][4] =
|
||||||
{
|
{
|
||||||
{ "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2"},
|
{ "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2"},
|
||||||
{ " {} ", "{}", "#", " #{#} "},
|
{ " {} ", "{}", "#", " #{#} "},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CheckEscapeChars(kwsys_stl::string input,
|
bool CheckEscapeChars(kwsys_stl::string input,
|
||||||
const char *chars_to_escape,
|
const char *chars_to_escape,
|
||||||
char escape_char,
|
char escape_char,
|
||||||
kwsys_stl::string output)
|
kwsys_stl::string output)
|
||||||
{
|
{
|
||||||
kwsys_stl::string result = kwsys::SystemTools::EscapeChars(
|
kwsys_stl::string result = kwsys::SystemTools::EscapeChars(
|
||||||
input.c_str(), chars_to_escape, escape_char);
|
input.c_str(), chars_to_escape, escape_char);
|
||||||
if (result != output)
|
if (result != output)
|
||||||
{
|
{
|
||||||
kwsys_ios::cerr
|
kwsys_ios::cerr
|
||||||
<< "Problem with CheckEscapeChars - input: " << input.c_str()
|
<< "Problem with CheckEscapeChars - input: " << input.c_str()
|
||||||
<< " output: " << result.c_str() << " expected: " << output.c_str()
|
<< " output: " << result.c_str() << " expected: " << output.c_str()
|
||||||
<< kwsys_ios::endl;
|
<< kwsys_ios::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -97,20 +97,20 @@ bool CheckDetectFileType()
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_BIN_FILE) !=
|
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_BIN_FILE) !=
|
||||||
kwsys::SystemTools::FileTypeBinary)
|
kwsys::SystemTools::FileTypeBinary)
|
||||||
{
|
{
|
||||||
kwsys_ios::cerr
|
kwsys_ios::cerr
|
||||||
<< "Problem with DetectFileType - failed to detect type of: "
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
<< TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
|
<< TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_SRC_FILE) !=
|
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_SRC_FILE) !=
|
||||||
kwsys::SystemTools::FileTypeText)
|
kwsys::SystemTools::FileTypeText)
|
||||||
{
|
{
|
||||||
kwsys_ios::cerr
|
kwsys_ios::cerr
|
||||||
<< "Problem with DetectFileType - failed to detect type of: "
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
|
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue