This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 8708542da2b794a08b11c3ccae91dc927504ae50 (commit) via eb86b4cec14df4a51cca9f178e8e758b97be11b7 (commit) via 178c897374718c2b7cfa76f5c016f23658d5d2b2 (commit) via 3bb4a798268669ca1364040abb3cfdf4a44c2f92 (commit) via 60b68304f25088db12112c47a4599e4fef405429 (commit) via 1731b90cd0b8c1c0da2f485a9b43006bb2174150 (commit) from 368845459f43438e239663171cb38125915d5080 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8708542da2b794a08b11c3ccae91dc927504ae50 commit 8708542da2b794a08b11c3ccae91dc927504ae50 Merge: 3688454 eb86b4c Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 16:36:47 2017 -0500 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Tue Jan 24 16:36:47 2017 -0500 Merge topic 'testdriver-cleanup' into next eb86b4ce TestDriver: fix/silence clang-tidy warnings 178c8973 TestDriver: calc NumTests at compile time 3bb4a798 TestDriver: use for loop 60b68304 TestDriver: abstract CM_CAST macro 1731b90c TestDriver: Revise C++ coding style using clang-format https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb86b4cec14df4a51cca9f178e8e758b97be11b7 commit eb86b4cec14df4a51cca9f178e8e758b97be11b7 Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 22:24:06 2017 +0100 Commit: Daniel Pfeifer <dan...@pfeifer-mail.de> CommitDate: Tue Jan 24 22:24:06 2017 +0100 TestDriver: fix/silence clang-tidy warnings diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 7340842..ecf6fa1 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -1,7 +1,7 @@ -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <ctype.h> /* NOLINT */ +#include <stdio.h> /* NOLINT */ +#include <stdlib.h> /* NOLINT */ +#include <string.h> /* NOLINT */ #if defined(_MSC_VER) #pragma warning(disable : 4996) /* deprecation */ @@ -29,7 +29,7 @@ typedef struct static functionMapEntry cmakeGeneratedFunctionMapEntries[] = { @CMAKE_FUNCTION_TABLE_ENTIRES@ - { 0, 0 } + { NULL, NULL } /* NOLINT */ }; static const int NumTests = @@ -37,7 +37,6 @@ static const int NumTests = /* Allocate and create a lowercased copy of string (note that it has to be free'd manually) */ - static char* lowercase(const char* string) { char *new_string, *p; @@ -46,8 +45,8 @@ static char* lowercase(const char* string) stringSize = CM_CAST(size_t, strlen(string) + 1); new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize)); - if (!new_string) { - return 0; + if (new_string == NULL) { /* NOLINT */ + return NULL; /* NOLINT */ } strncpy(new_string, string, stringSize); for (p = new_string; *p != 0; ++p) { @@ -87,12 +86,12 @@ int main(int ac, char* av[]) av++; } partial_match = 0; - arg = 0; + arg = NULL; /* NOLINT */ /* If partial match is requested. */ if (testToRun == -1 && ac > 1) { partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; } - if (partial_match && ac < 3) { + if (partial_match != 0 && ac < 3) { printf("-R needs an additional parameter.\n"); return -1; } @@ -101,20 +100,18 @@ int main(int ac, char* av[]) } for (i = 0; i < NumTests && testToRun == -1; ++i) { test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); - if (partial_match && strstr(test_name, arg) != NULL) { + if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */ testToRun = i; ac -= 2; av += 2; - } else if (!partial_match && strcmp(test_name, arg) == 0) { + } else if (partial_match == 0 && strcmp(test_name, arg) == 0) { testToRun = i; ac--; av++; } free(test_name); } - if (arg) { - free(arg); - } + free(arg); if (testToRun != -1) { int result; @CMAKE_TESTDRIVER_BEFORE_TESTMAIN@ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=178c897374718c2b7cfa76f5c016f23658d5d2b2 commit 178c897374718c2b7cfa76f5c016f23658d5d2b2 Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 22:24:06 2017 +0100 Commit: Daniel Pfeifer <dan...@pfeifer-mail.de> CommitDate: Tue Jan 24 22:24:06 2017 +0100 TestDriver: calc NumTests at compile time diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 8e54680..7340842 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -32,6 +32,9 @@ static functionMapEntry cmakeGeneratedFunctionMapEntries[] = { { 0, 0 } }; +static const int NumTests = + (sizeof(cmakeGeneratedFunctionMapEntries) / sizeof(functionMapEntry)) - 1; + /* Allocate and create a lowercased copy of string (note that it has to be free'd manually) */ @@ -55,16 +58,12 @@ static char* lowercase(const char* string) int main(int ac, char* av[]) { - int i, NumTests, testNum = 0, partial_match; + int i, testNum = 0, partial_match; char *arg, *test_name; - int count; int testToRun = -1; @CMAKE_TESTDRIVER_ARGVC_FUNCTION@ - for (count = 0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) { - } - NumTests = count; /* If no test name was given */ /* process command line with user function. */ if (ac < 2) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bb4a798268669ca1364040abb3cfdf4a44c2f92 commit 3bb4a798268669ca1364040abb3cfdf4a44c2f92 Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 22:24:06 2017 +0100 Commit: Daniel Pfeifer <dan...@pfeifer-mail.de> CommitDate: Tue Jan 24 22:24:06 2017 +0100 TestDriver: use for loop diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 7e17761..8e54680 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -47,10 +47,8 @@ static char* lowercase(const char* string) return 0; } strncpy(new_string, string, stringSize); - p = new_string; - while (*p != 0) { + for (p = new_string; *p != 0; ++p) { *p = CM_CAST(char, tolower(*p)); - ++p; } return new_string; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60b68304f25088db12112c47a4599e4fef405429 commit 60b68304f25088db12112c47a4599e4fef405429 Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 22:24:06 2017 +0100 Commit: Daniel Pfeifer <dan...@pfeifer-mail.de> CommitDate: Tue Jan 24 22:24:06 2017 +0100 TestDriver: abstract CM_CAST macro diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 7d03fd3..7e17761 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -12,6 +12,12 @@ /* Forward declare test functions. */ @CMAKE_FORWARD_DECLARE_TESTS@ +#ifdef __cplusplus +#define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR) +#else +#define CM_CAST(TYPE, EXPR) (TYPE)(EXPR) +#endif + /* Create map. */ typedef int (*MainFuncPointer)(int, char* []); @@ -34,13 +40,8 @@ static char* lowercase(const char* string) char *new_string, *p; size_t stringSize = 0; -#ifdef __cplusplus - stringSize = static_cast<size_t>(strlen(string) + 1); - new_string = static_cast<char*>(malloc(sizeof(char) * stringSize)); -#else - stringSize = (size_t)(strlen(string) + 1); - new_string = (char*)(malloc(sizeof(char) * stringSize)); -#endif + stringSize = CM_CAST(size_t, strlen(string) + 1); + new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize)); if (!new_string) { return 0; @@ -48,12 +49,7 @@ static char* lowercase(const char* string) strncpy(new_string, string, stringSize); p = new_string; while (*p != 0) { -#ifdef __cplusplus - *p = static_cast<char>(tolower(*p)); -#else - *p = (char)(tolower(*p)); -#endif - + *p = CM_CAST(char, tolower(*p)); ++p; } return new_string; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1731b90cd0b8c1c0da2f485a9b43006bb2174150 commit 1731b90cd0b8c1c0da2f485a9b43006bb2174150 Author: Daniel Pfeifer <dan...@pfeifer-mail.de> AuthorDate: Tue Jan 24 22:24:06 2017 +0100 Commit: Daniel Pfeifer <dan...@pfeifer-mail.de> CommitDate: Tue Jan 24 22:24:06 2017 +0100 TestDriver: Revise C++ coding style using clang-format diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 3e0afa5..7d03fd3 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -1,21 +1,20 @@ #include <ctype.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> #if defined(_MSC_VER) -# pragma warning(disable:4996) /* deprecation */ +#pragma warning(disable : 4996) /* deprecation */ #endif @CMAKE_TESTDRIVER_EXTRA_INCLUDES@ - /* Forward declare test functions. */ @CMAKE_FORWARD_DECLARE_TESTS@ /* Create map. */ -typedef int (*MainFuncPointer)(int , char*[]); +typedef int (*MainFuncPointer)(int, char* []); typedef struct { const char* name; @@ -24,33 +23,31 @@ typedef struct static functionMapEntry cmakeGeneratedFunctionMapEntries[] = { @CMAKE_FUNCTION_TABLE_ENTIRES@ - {0,0} + { 0, 0 } }; /* Allocate and create a lowercased copy of string (note that it has to be free'd manually) */ -static char* lowercase(const char *string) +static char* lowercase(const char* string) { char *new_string, *p; size_t stringSize = 0; #ifdef __cplusplus stringSize = static_cast<size_t>(strlen(string) + 1); - new_string = static_cast<char *>(malloc(sizeof(char) * stringSize)); + new_string = static_cast<char*>(malloc(sizeof(char) * stringSize)); #else stringSize = (size_t)(strlen(string) + 1); - new_string = (char *)(malloc(sizeof(char) * stringSize)); + new_string = (char*)(malloc(sizeof(char) * stringSize)); #endif - if (!new_string) - { + if (!new_string) { return 0; - } + } strncpy(new_string, string, stringSize); p = new_string; - while (*p != 0) - { + while (*p != 0) { #ifdef __cplusplus *p = static_cast<char>(tolower(*p)); #else @@ -58,11 +55,11 @@ static char* lowercase(const char *string) #endif ++p; - } + } return new_string; } -int main(int ac, char *av[]) +int main(int ac, char* av[]) { int i, NumTests, testNum = 0, partial_match; char *arg, *test_name; @@ -71,96 +68,79 @@ int main(int ac, char *av[]) @CMAKE_TESTDRIVER_ARGVC_FUNCTION@ - for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) - { - } + for (count = 0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) { + } NumTests = count; /* If no test name was given */ /* process command line with user function. */ - if (ac < 2) - { + if (ac < 2) { /* Ask for a test. */ printf("Available tests:\n"); - for (i =0; i < NumTests; ++i) - { + for (i = 0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); - } + } printf("To run a test, enter the test number: "); fflush(stdout); - if( scanf("%d", &testNum) != 1 ) - { + if (scanf("%d", &testNum) != 1) { printf("Couldn't parse that input as a number\n"); return -1; - } - if (testNum >= NumTests) - { + } + if (testNum >= NumTests) { printf("%3d is an invalid test number.\n", testNum); return -1; - } + } testToRun = testNum; ac--; av++; - } + } partial_match = 0; arg = 0; /* If partial match is requested. */ - if(testToRun == -1 && ac > 1) - { + if (testToRun == -1 && ac > 1) { partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; - } - if (partial_match && ac < 3) - { + } + if (partial_match && ac < 3) { printf("-R needs an additional parameter.\n"); return -1; - } - if(testToRun == -1) - { + } + if (testToRun == -1) { arg = lowercase(av[1 + partial_match]); - } - for (i =0; i < NumTests && testToRun == -1; ++i) - { + } + for (i = 0; i < NumTests && testToRun == -1; ++i) { test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); - if (partial_match && strstr(test_name, arg) != NULL) - { + if (partial_match && strstr(test_name, arg) != NULL) { testToRun = i; - ac -=2; + ac -= 2; av += 2; - } - else if (!partial_match && strcmp(test_name, arg) == 0) - { + } else if (!partial_match && strcmp(test_name, arg) == 0) { testToRun = i; ac--; av++; - } - free(test_name); } - if(arg) - { + free(test_name); + } + if (arg) { free(arg); - } - if(testToRun != -1) - { + } + if (testToRun != -1) { int result; @CMAKE_TESTDRIVER_BEFORE_TESTMAIN@ - if (testToRun < 0 || testToRun >= NumTests) - { - printf( - "testToRun was modified by TestDriver code to an invalid value: %3d.\n", - testNum); + if (testToRun < 0 || testToRun >= NumTests) { + printf("testToRun was modified by TestDriver code to an invalid value: " + "%3d.\n", + testNum); return -1; - } + } result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); @CMAKE_TESTDRIVER_AFTER_TESTMAIN@ return result; - } - + } /* Nothing was run, display the test names. */ printf("Available tests:\n"); - for (i =0; i < NumTests; ++i) - { + for (i = 0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); - } + } printf("Failed: %s is an invalid test name.\n", av[1]); return -1; ----------------------------------------------------------------------- Summary of changes: Templates/TestDriver.cxx.in | 146 +++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 88 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits