Skip to content

Commit f04d537

Browse files
committed
MSVC 2005 improvements
1 parent 0e4fabb commit f04d537

5 files changed

Lines changed: 24 additions & 38 deletions

File tree

.pre-commit-config.yaml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,58 @@ repos:
1515
hooks:
1616
- id: cppcheck
1717
name: Cppcheck
18-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" cppcheck
18+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" cppcheck
1919
language: python
2020
pass_filenames: false
2121
types_or: [c, c++]
2222
- id: build-gcc
2323
name: Build (GCC)
24-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build gcc
24+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build gcc
2525
language: python
2626
pass_filenames: false
2727
- id: test-gcc
2828
name: Test (GCC)
29-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test gcc
29+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test gcc
3030
language: python
3131
pass_filenames: false
3232
- id: build-clang
3333
name: Build (Clang)
34-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build clang
34+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build clang
3535
language: python
3636
pass_filenames: false
3737
- id: test-clang
3838
name: Test (Clang)
39-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test clang
40-
language: python
41-
pass_filenames: false
42-
- id: build-msvc-2005-wine
43-
name: Build and Test (MSVC 2005 Wine)
44-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc_2005_wine
45-
language: python
46-
pass_filenames: false
47-
- id: build-msvc-wine
48-
name: Build (MSVC Wine)
49-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc_wine
50-
language: python
51-
pass_filenames: false
52-
- id: test-msvc-wine
53-
name: Test (MSVC Wine)
54-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test msvc_wine
39+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test clang
5540
language: python
5641
pass_filenames: false
5742
- id: build-msvc
5843
name: Build (MSVC)
59-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc
44+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc
6045
language: python
6146
pass_filenames: false
6247
- id: test-msvc
6348
name: Test (MSVC)
64-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test msvc
49+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test msvc
6550
language: python
6651
pass_filenames: false
6752
- id: build-mingw
6853
name: Build (MinGW)
69-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build mingw
54+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build mingw
7055
language: python
7156
pass_filenames: false
7257
- id: test-mingw
7358
name: Test (MinGW)
74-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test mingw
59+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test mingw
7560
language: python
7661
pass_filenames: false
7762
- id: valgrind
7863
name: Valgrind (GCC)
79-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" valgrind gcc
64+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" valgrind gcc
8065
language: python
8166
pass_filenames: false
8267
- id: update-shields
8368
name: Update README Shields
84-
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" shields
69+
entry: python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" shields
8570
language: python
8671
additional_dependencies: [gcovr]
8772
pass_filenames: false

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
2626
"${PROJECT_NAME}_compiler_flags"
2727
INTERFACE
2828
"$<$<AND:${gcc_like},$<CONFIG:Debug>>:$<BUILD_INTERFACE:-Wshadow;-Wformat=2;-Wall;-Wno-missing-braces;-Wno-long-long;-pedantic;-fprofile-arcs;-ftest-coverage>>"
29-
"$<${msvc}:$<BUILD_INTERFACE:-W3;-WX;-Zi;-permissive->>"
29+
"$<${msvc}:$<BUILD_INTERFACE:-W4;-WX;-Zi;-permissive->>"
3030
)
3131
target_link_options(
3232
"${PROJECT_NAME}_compiler_flags"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ c89stringutils
22
==============
33
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
![Doc Coverage](https://img.shields.io/badge/doc__coverage-100.00%25-brightgreen)
5-
![Test Coverage](https://img.shields.io/badge/test__coverage-100.00%25-brightgreen)
5+
![Test Coverage](https://img.shields.io/badge/test__coverage-0.00%25-brightgreen)
66
[![CI for Linux, Windows, macOS](https://github.com/offscale/c89stringutils/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/c89stringutils/actions/workflows/ci.yml)
77
[![C89](https://img.shields.io/badge/C-89-blue)](https://en.wikipedia.org/wiki/C89_(C_version))
88

c89stringutils/c89stringutils_string_extras.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ extern int mock_strerror_s(char *buffer, size_t sizeInBytes, int errnum);
2727
#endif
2828
#define malloc mock_malloc
2929
#define realloc mock_realloc
30-
#define wtf_vsnprintf mock_vsnprintf
3130
#undef vsnprintf
3231
#define vsnprintf mock_vsnprintf
3332
#define strerror mock_strerror
@@ -130,8 +129,10 @@ static int wtf_vsnprintf(char *buffer, size_t count, const char *format,
130129
return rc;
131130
}
132131

132+
#ifndef C89STRINGUTILS_TEST_MOCKS
133133
#define vsnprintf(buffer, count, format, args) \
134134
wtf_vsnprintf(buffer, count, format, args)
135+
#endif
135136

136137
#endif /* !HAVE_SNPRINTF_H */
137138

c89stringutils/tests/test_string_extras.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ extern "C" {
1818
#include <errno.h>
1919
/* clang-format on */
2020

21-
static const char *buffer = "hello world";
22-
static const char *target = "hello\0\0\0";
21+
static const char *test_buffer = "hello world";
22+
static const char *test_target = "hello\0\0\0";
2323

2424
/**
2525
* @brief Test case
2626
* @return enum test result
2727
*/
2828
TEST x_strnstr_should_succeed(void) {
2929
char *out;
30-
out = c89stringutils_strnstr(buffer, target, strlen(buffer));
31-
ASSERT_EQ_FMT(buffer, out, "%s");
30+
out = c89stringutils_strnstr(test_buffer, test_target, strlen(test_buffer));
31+
ASSERT_EQ_FMT(test_buffer, out, "%s");
3232
PASS();
3333
}
3434

@@ -38,13 +38,13 @@ TEST x_strnstr_should_succeed(void) {
3838
*/
3939
TEST x_strnstr_should_fail(void) {
4040
char *out;
41-
out = c89stringutils_strnstr(buffer, "world", 5);
41+
out = c89stringutils_strnstr(test_buffer, "world", 5);
4242
ASSERT_EQ(NULL, out);
43-
out = c89stringutils_strnstr(buffer, "", 5);
44-
ASSERT_EQ(buffer, out);
45-
out = c89stringutils_strnstr(NULL, buffer, 5);
43+
out = c89stringutils_strnstr(test_buffer, "", 5);
44+
ASSERT_EQ(test_buffer, out);
45+
out = c89stringutils_strnstr(NULL, test_buffer, 5);
4646
ASSERT_EQ(NULL, out);
47-
out = c89stringutils_strnstr(buffer, NULL, 5);
47+
out = c89stringutils_strnstr(test_buffer, NULL, 5);
4848
ASSERT_EQ(NULL, out);
4949
out = c89stringutils_strnstr("abcde", "abX", 5);
5050
ASSERT_EQ(NULL, out);

0 commit comments

Comments
 (0)