Commit 6c973b46 authored by Kitware Robot's avatar Kitware Robot Committed by Brad King

Revise C++ coding style using clang-format

Run the `clang-format.bash` script to update all our C and C++ code to a new
style defined by `.clang-format`.  Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Change-Id: Ie3aedc03bfe5c3999d4a077fafb8c6f3bbffc5c5
parent 6604c4b6
This diff is collapsed.
......@@ -12,41 +12,40 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsysBase64 kwsys_ns(Base64)
# define kwsysBase64_Decode kwsys_ns(Base64_Decode)
# define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
# define kwsysBase64_Encode kwsys_ns(Base64_Encode)
# define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
# define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
# define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
#define kwsysBase64 kwsys_ns(Base64)
#define kwsysBase64_Decode kwsys_ns(Base64_Decode)
#define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
#define kwsysBase64_Encode kwsys_ns(Base64_Encode)
#define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
#define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
#define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
#endif
#if defined(__cplusplus)
extern "C"
{
extern "C" {
#endif
/**
* Encode 3 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode3(const unsigned char* src,
unsigned char* dest);
/**
* Encode 2 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode2(const unsigned char* src,
unsigned char* dest);
/**
* Encode 1 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode1(const unsigned char* src,
unsigned char* dest);
/**
* Encode 'length' bytes from the input buffer and store the encoded
......@@ -61,17 +60,16 @@ kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
* the extra padding needed to complete the encode 4 bytes will stop
* the decoding anyway).
*/
kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char *input,
size_t length,
unsigned char *output,
kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char* input,
size_t length, unsigned char* output,
int mark_end);
/**
* Decode 4 bytes into a 3 byte string. Returns the number of bytes
* actually decoded.
*/
kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT int kwsysBase64_Decode3(const unsigned char* src,
unsigned char* dest);
/**
* Decode bytes from the input buffer and store the decoded stream
......@@ -85,9 +83,8 @@ kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
* much decoded data to expect (of course, the buffer must be large
* enough).
*/
kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input,
size_t length,
unsigned char *output,
kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char* input,
size_t length, unsigned char* output,
size_t max_input_length);
#if defined(__cplusplus)
......@@ -97,17 +94,17 @@ kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input,
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
# undef kwsys_ns
# undef kwsysEXPORT
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsysBase64
# undef kwsysBase64_Decode
# undef kwsysBase64_Decode3
# undef kwsysBase64_Encode
# undef kwsysBase64_Encode1
# undef kwsysBase64_Encode2
# undef kwsysBase64_Encode3
# endif
#undef kwsys_ns
#undef kwsysEXPORT
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
#undef kwsysBase64
#undef kwsysBase64_Decode
#undef kwsysBase64_Decode3
#undef kwsysBase64_Encode
#undef kwsysBase64_Encode1
#undef kwsysBase64_Encode2
#undef kwsysBase64_Encode3
#endif
#endif
#endif
This diff is collapsed.
......@@ -9,8 +9,7 @@
#include <string>
#include <vector>
namespace @KWSYS_NAMESPACE@
{
namespace @KWSYS_NAMESPACE@ {
class CommandLineArgumentsInternal;
struct CommandLineArgumentsCallbackStructure;
......@@ -32,28 +31,29 @@ struct CommandLineArgumentsCallbackStructure;
* the argument is specified, the variable is set to the specified value casted
* to the appropriate type. For boolean (NO_ARGUMENT), the value is "1".
*
* Both interfaces can be used at the same time.
* Both interfaces can be used at the same time.
*
* Possible argument types are:
* NO_ARGUMENT - The argument takes no value : --A
* CONCAT_ARGUMENT - The argument takes value after no space : --Aval
* SPACE_ARGUMENT - The argument takes value after space : --A val
* SPACE_ARGUMENT - The argument takes value after space : --A val
* EQUAL_ARGUMENT - The argument takes value after equal : --A=val
* MULTI_ARGUMENT - The argument takes values after space : --A val1 val2 val3 ...
* MULTI_ARGUMENT - The argument takes values after space : --A val1 val2
* val3 ...
*
* Example use:
*
* kwsys::CommandLineArguments arg;
* arg.Initialize(argc, argv);
* typedef kwsys::CommandLineArguments argT;
* arg.AddArgument("--something", argT::EQUAL_ARGUMENT, &some_variable,
* arg.AddArgument("--something", argT::EQUAL_ARGUMENT, &some_variable,
* "This is help string for --something");
* if ( !arg.Parse() )
* {
* std::cerr << "Problem parsing arguments" << std::endl;
* res = 1;
* }
*
*
*/
class @KWSYS_NAMESPACE@_EXPORT CommandLineArguments
......@@ -65,7 +65,8 @@ public:
/**
* Various argument types.
*/
enum ArgumentTypeEnum {
enum ArgumentTypeEnum
{
NO_ARGUMENT,
CONCAT_ARGUMENT,
SPACE_ARGUMENT,
......@@ -77,27 +78,28 @@ public:
* Various variable types. When using the variable interface, this specifies
* what type the variable is.
*/
enum VariableTypeEnum {
NO_VARIABLE_TYPE = 0, // The variable is not specified
INT_TYPE, // The variable is integer (int)
BOOL_TYPE, // The variable is boolean (bool)
DOUBLE_TYPE, // The variable is float (double)
STRING_TYPE, // The variable is string (char*)
STL_STRING_TYPE, // The variable is string (char*)
VECTOR_INT_TYPE, // The variable is integer (int)
VECTOR_BOOL_TYPE, // The variable is boolean (bool)
VECTOR_DOUBLE_TYPE, // The variable is float (double)
VECTOR_STRING_TYPE, // The variable is string (char*)
VECTOR_STL_STRING_TYPE, // The variable is string (char*)
enum VariableTypeEnum
{
NO_VARIABLE_TYPE = 0, // The variable is not specified
INT_TYPE, // The variable is integer (int)
BOOL_TYPE, // The variable is boolean (bool)
DOUBLE_TYPE, // The variable is float (double)
STRING_TYPE, // The variable is string (char*)
STL_STRING_TYPE, // The variable is string (char*)
VECTOR_INT_TYPE, // The variable is integer (int)
VECTOR_BOOL_TYPE, // The variable is boolean (bool)
VECTOR_DOUBLE_TYPE, // The variable is float (double)
VECTOR_STRING_TYPE, // The variable is string (char*)
VECTOR_STL_STRING_TYPE, // The variable is string (char*)
LAST_VARIABLE_TYPE
};
/**
* Prototypes for callbacks for callback interface.
*/
typedef int(*CallbackType)(const char* argument, const char* value,
void* call_data);
typedef int(*ErrorCallbackType)(const char* argument, void* client_data);
typedef int (*CallbackType)(const char* argument, const char* value,
void* call_data);
typedef int (*ErrorCallbackType)(const char* argument, void* client_data);
/**
* Initialize internal data structures. This should be called before parsing.
......@@ -124,24 +126,24 @@ public:
* argument help specifies the help string used with this option. The
* callback and call_data can be skipped.
*/
void AddCallback(const char* argument, ArgumentTypeEnum type,
CallbackType callback, void* call_data, const char* help);
void AddCallback(const char* argument, ArgumentTypeEnum type,
CallbackType callback, void* call_data, const char* help);
/**
* Add handler for argument which is going to set the variable to the
* specified value. If the argument is specified, the option is casted to the
* appropriate type.
*/
void AddArgument(const char* argument, ArgumentTypeEnum type, bool* variable,
const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type, int* variable,
const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
bool* variable, const char* help);
double* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
int* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
double* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
char** variable, const char* help);
char** variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::string* variable, const char* help);
std::string* variable, const char* help);
/**
* Add handler for argument which is going to set the variable to the
......@@ -149,31 +151,31 @@ public:
* appropriate type. This will handle the multi argument values.
*/
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<bool>* variable, const char* help);
std::vector<bool>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<int>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<int>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<double>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<char*>* variable, const char* help);
std::vector<double>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<std::string>* variable, const char* help);
std::vector<char*>* variable, const char* help);
void AddArgument(const char* argument, ArgumentTypeEnum type,
std::vector<std::string>* variable, const char* help);
/**
* Add handler for boolean argument. The argument does not take any option
* and if it is specified, the value of the variable is true/1, otherwise it
* is false/0.
*/
void AddBooleanArgument(const char* argument,
bool* variable, const char* help);
void AddBooleanArgument(const char* argument,
int* variable, const char* help);
void AddBooleanArgument(const char* argument,
double* variable, const char* help);
void AddBooleanArgument(const char* argument,
char** variable, const char* help);
void AddBooleanArgument(const char* argument,
std::string* variable, const char* help);
void AddBooleanArgument(const char* argument, bool* variable,
const char* help);
void AddBooleanArgument(const char* argument, int* variable,
const char* help);
void AddBooleanArgument(const char* argument, double* variable,
const char* help);
void AddBooleanArgument(const char* argument, char** variable,
const char* help);
void AddBooleanArgument(const char* argument, std::string* variable,
const char* help);
/**
* Set the callbacks for error handling.
......@@ -227,14 +229,14 @@ protected:
//! This is internal method that registers variable with argument
void AddArgument(const char* argument, ArgumentTypeEnum type,
VariableTypeEnum vtype, void* variable, const char* help);
VariableTypeEnum vtype, void* variable, const char* help);
bool GetMatchedArguments(std::vector<std::string>* matches,
const std::string& arg);
const std::string& arg);
//! Populate individual variables
bool PopulateVariable(CommandLineArgumentsCallbackStructure* cs,
const char* value);
const char* value);
//! Populate individual variables of type ...
void PopulateVariable(bool* variable, const std::string& value);
......@@ -244,9 +246,12 @@ protected:
void PopulateVariable(std::string* variable, const std::string& value);
void PopulateVariable(std::vector<bool>* variable, const std::string& value);
void PopulateVariable(std::vector<int>* variable, const std::string& value);
void PopulateVariable(std::vector<double>* variable, const std::string& value);
void PopulateVariable(std::vector<char*>* variable, const std::string& value);
void PopulateVariable(std::vector<std::string>* variable, const std::string& value);
void PopulateVariable(std::vector<double>* variable,
const std::string& value);
void PopulateVariable(std::vector<char*>* variable,
const std::string& value);
void PopulateVariable(std::vector<std::string>* variable,
const std::string& value);
typedef CommandLineArgumentsInternal Internal;
Internal* Internals;
......@@ -260,8 +265,3 @@ protected:
} // namespace @KWSYS_NAMESPACE@
#endif
......@@ -7,22 +7,22 @@
namespace. When not building a kwsys source file these macros are
temporarily defined inside the headers that use them. */
#if defined(KWSYS_NAMESPACE)
# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
/* Disable some warnings inside kwsys source files. */
#if defined(KWSYS_NAMESPACE)
# if defined(__BORLANDC__)
# pragma warn -8027 /* function not inlined. */
# endif
# if defined(__INTEL_COMPILER)
# pragma warning (disable: 1572) /* floating-point equality test */
# endif
# if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 3970 /* pointer to int conversion */
# pragma set woff 3968 /* 64 bit conversion */
# endif
#if defined(__BORLANDC__)
#pragma warn - 8027 /* function not inlined. */
#endif
#if defined(__INTEL_COMPILER)
#pragma warning(disable : 1572) /* floating-point equality test */
#endif
#if defined(__sgi) && !defined(__GNUC__)
#pragma set woff 3970 /* pointer to int conversion */
#pragma set woff 3968 /* 64 bit conversion */
#endif
#endif
/* Whether kwsys namespace is "kwsys". */
......@@ -33,84 +33,84 @@
/* Whether Large File Support is available. */
#if @KWSYS_NAMESPACE@_LFS_REQUESTED
# define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
#define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
#endif
/* Setup Large File Support if requested. */
#if @KWSYS_NAMESPACE@_LFS_REQUESTED
/* Since LFS is requested this header must be included before system
headers whether or not LFS is available. */
# if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
# error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
# endif
/* Enable the large file API if it is available. */
# if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
# if !defined(_LARGEFILE_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
# define _LARGEFILE_SOURCE
# endif
# if !defined(_LARGEFILE64_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
# define _LARGEFILE64_SOURCE
# endif
# if !defined(_LARGE_FILES) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
# define _LARGE_FILES
# endif
# if !defined(_FILE_OFFSET_BITS) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
# define _FILE_OFFSET_BITS 64
# endif
# if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
# error "_FILE_OFFSET_BITS must be defined to at least 64"
# endif
# endif
/* Since LFS is requested this header must be included before system
headers whether or not LFS is available. */
#if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
#error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
#endif
/* Enable the large file API if it is available. */
#if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
#if !defined(_LARGEFILE_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
#define _LARGEFILE_SOURCE
#endif
#if !defined(_LARGEFILE64_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
#define _LARGEFILE64_SOURCE
#endif
#if !defined(_LARGE_FILES) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
#define _LARGE_FILES
#endif
#if !defined(_FILE_OFFSET_BITS) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
#define _FILE_OFFSET_BITS 64
#endif
#if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
#error "_FILE_OFFSET_BITS must be defined to at least 64"
#endif
#endif
#endif
/* Setup the export macro. */
#if @KWSYS_BUILD_SHARED@
# if defined(_WIN32) || defined(__CYGWIN__)
# if defined(@KWSYS_NAMESPACE@_EXPORTS)
# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
# else
# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
# endif
# elif __GNUC__ >= 4
# define @KWSYS_NAMESPACE@_EXPORT __attribute__ ((visibility("default")))
# else
# define @KWSYS_NAMESPACE@_EXPORT
# endif
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(@KWSYS_NAMESPACE@_EXPORTS)
#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
#else
#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define @KWSYS_NAMESPACE@_EXPORT __attribute__((visibility("default")))
#else
#define @KWSYS_NAMESPACE@_EXPORT
#endif
#else
# define @KWSYS_NAMESPACE@_EXPORT
#define @KWSYS_NAMESPACE@_EXPORT
#endif
/* Enable warnings that are off by default but are useful. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_ENABLE)
# if defined(_MSC_VER)
# pragma warning ( default : 4263 ) /* no override, call convention differs */
# endif
#if defined(_MSC_VER)
#pragma warning(default : 4263) /* no override, call convention differs */
#endif
#endif
/* Disable warnings that are on by default but occur in valid code. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE)
# if defined(_MSC_VER)
# pragma warning (disable: 4097) /* typedef is synonym for class */
# pragma warning (disable: 4127) /* conditional expression is constant */
# pragma warning (disable: 4244) /* possible loss in conversion */
# pragma warning (disable: 4251) /* missing DLL-interface */
# pragma warning (disable: 4305) /* truncation from type1 to type2 */
# pragma warning (disable: 4309) /* truncation of constant value */
# pragma warning (disable: 4514) /* unreferenced inline function */
# pragma warning (disable: 4706) /* assignment in conditional expression */
# pragma warning (disable: 4710) /* function not inlined */
# pragma warning (disable: 4786) /* identifier truncated in debug info */
# endif
# if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
# pragma warn -8019
# endif
#if defined(_MSC_VER)
#pragma warning(disable : 4097) /* typedef is synonym for class */
#pragma warning(disable : 4127) /* conditional expression is constant */
#pragma warning(disable : 4244) /* possible loss in conversion */
#pragma warning(disable : 4251) /* missing DLL-interface */
#pragma warning(disable : 4305) /* truncation from type1 to type2 */
#pragma warning(disable : 4309) /* truncation of constant value */
#pragma warning(disable : 4514) /* unreferenced inline function */
#pragma warning(disable : 4706) /* assignment in conditional expression */
#pragma warning(disable : 4710) /* function not inlined */
#pragma warning(disable : 4786) /* identifier truncated in debug info */
#endif
#if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
#pragma warn - 8019
#endif
#endif
/* MSVC 6.0 in release mode will warn about code it produces with its
......@@ -118,10 +118,10 @@
configuration. Real warnings will be revealed by a debug build or
by other compilers. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE_BOGUS)
# if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
# pragma warning ( disable : 4701 ) /* Variable may be used uninitialized. */
# pragma warning ( disable : 4702 ) /* Unreachable code. */
# endif
#if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
#pragma warning(disable : 4701) /* Variable may be used uninitialized. */
#pragma warning(disable : 4702) /* Unreachable code. */
#endif
#endif
#endif
......@@ -9,17 +9,19 @@
/* Whether wstring is available. */
#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@
/* Whether <ext/stdio_filebuf.h> is available. */
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H @KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys @KWSYS_NAMESPACE@
# endif
# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
#define kwsys @KWSYS_NAMESPACE@
#endif
#define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
#define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
#define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
#endif
#endif
This diff is collapsed.
......@@ -18,8 +18,7 @@
#include <string>
#include <vector>
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
//----------------------------------------------------------------------------
class DirectoryInternals
......@@ -53,10 +52,9 @@ unsigned long Directory::GetNumberOfFiles() const
//----------------------------------------------------------------------------
const char* Directory::GetFile(unsigned long dindex) const
{
if ( dindex >= this->Internal->Files.size() )
{
if (dindex >= this->Internal->Files.size()) {
return 0;
}
}
return this->Internal->Files[dindex].c_str();
}
......@@ -91,15 +89,14 @@ void Directory::Clear()
// Wide function names can vary depending on compiler:
#ifdef __BORLANDC__
# define _wfindfirst_func __wfindfirst
# define _wfindnext_func __wfindnext
#define _wfindfirst_func __wfindfirst
#define _wfindnext_func __wfindnext
#else
# define _wfindfirst_func _wfindfirst
# define _wfindnext_func _wfindnext
#define _wfindfirst_func _wfindfirst
#define _wfindnext_func _wfindnext
#endif
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
bool Directory::Load(const std::string& name)
{
......@@ -112,42 +109,34 @@ bool Directory::Load(const std::string& name)
#endif
char* buf;
size_t n = name.size();
if ( *name.rbegin() == '/' || *name.rbegin() == '\\' )
{
if (*name.rbegin() == '/' || *name.rbegin() == '\\') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
}
else
{
} else {
// Make sure the slashes in the wildcard suffix are consistent with the
// rest of the path
buf = new char[n + 2 + 1];
if ( name.find('\\') != name.npos )
{
if (name.find('\\') != name.npos) {
sprintf(buf, "%s\\*", name.c_str());
}
else
{
} else {
sprintf(buf, "%s/*", name.c_str());
}
}
struct _wfinddata_t data; // data of current file
}
struct _wfinddata_t data; // data of current file
// Now put them into the file array
srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete [] buf;
srchHandle =
_wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete[] buf;
if ( srchHandle == -1 )
{
if (srchHandle == -1) {
return 0;
}
}
// Loop through names
do
{
do {
this->Internal->Files.push_back(Encoding::ToNarrow(data.name));
}
while ( _wfindnext_func(srchHandle, &data) != -1 );
} while (_wfindnext_func(srchHandle, &data) != -1);
this->Internal->Path = name;
return _findclose(srchHandle) != -1;
}
......@@ -162,34 +151,29 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
#endif
char* buf;
size_t n = name.size();
if ( *name.rbegin() == '/' )
{
if (*name.rbegin() == '/') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
}
else
{
} else {
buf = new char[n + 2 + 1];
sprintf(buf, "%s/*", name.c_str());
}
struct _wfinddata_t data; // data of current file
}
struct _wfinddata_t data; // data of current file
// Now put them into the file array
srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete [] buf;
srchHandle =
_wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete[] buf;
if ( srchHandle == -1 )
{
if (srchHandle == -1) {
return 0;
}
}
// Loop through names
unsigned long count = 0;
do
{
do {
count++;
}
while ( _wfindnext_func(srchHandle, &data) != -1 );
} while (_wfindnext_func(srchHandle, &data) != -1);
_findclose(srchHandle);
return count;
}
......@@ -209,33 +193,30 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
// Work around the problem by mapping dirent the same way as readdir.
#if defined(__PGI) && defined(__GLIBC__)
# define kwsys_dirent_readdir dirent
# define kwsys_dirent_readdir64 dirent64
# define kwsys_dirent kwsys_dirent_lookup(readdir)
# define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
# define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
#define kwsys_dirent_readdir dirent
#define kwsys_dirent_readdir64 dirent64
#define kwsys_dirent kwsys_dirent_lookup(readdir)
#define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
#define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
#else
# define kwsys_dirent dirent
#define kwsys_dirent dirent
#endif
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
bool Directory::Load(const std::string& name)
{
this->Clear();
DIR* dir = opendir(name.c_str());
if (!dir)
{
if (!dir) {
return 0;
}
}
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
{
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
this->Internal->Files.push_back(d->d_name);
<