Skip to content

Commit 43f9611

Browse files
committed
Merge branch 'develop'
# Conflicts: # test/Catch2 conflict resolution: manually update Catch2 submodule to tag v3.5.0 (same as in develop branch).
2 parents fa74ff6 + 7ccfaad commit 43f9611

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+347
-225
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
# - We use the *-latest runners because we strive to build with relatively
1515
# new versions of each environment that have modern compilers (we need at
1616
# least C++17, see CMakeLists.txt) and tools.
17-
# - As of writing this all of the *-latest runners use CMake 3.19.1.
1817
# - The library should not only be cross-platform, it should also not rely
1918
# on any particular compiler. On macOS the clang compiler is used
2019
# (AppleClang), on Ubuntu the default is GNU GCC, and on Windows it's
@@ -26,7 +25,10 @@ jobs:
2625

2726
steps:
2827
- name: Checking out the sources
29-
uses: actions/checkout@v2
28+
# @v4 refers to the Git tag "v4" in https://github.com/actions/checkout.
29+
# The repo maintainers update the "v4" tag to always point to the latest
30+
# v4 release of the checkout action.
31+
uses: actions/checkout@v4
3032
with:
3133
submodules: recursive
3234

@@ -40,19 +42,11 @@ jobs:
4042
cmake -DCMAKE_BUILD_TYPE=Release ..
4143
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
4244

43-
- name: Generat build system (Windows)
45+
- name: Generate build system (Windows)
4446
run: |
4547
mkdir build
4648
cd build
47-
# Setting CMAKE_SYSTEM_VERSION defines the Windows SDK that CMake should
48-
# use for the build. We have to do this in order to override the
49-
# Windows SDK that CMake would select on its own. The default Windows SDK
50-
# on the windows-latest runner is currently 10.0.17763.0, and for unknown
51-
# reasons that SDK version breaks the build. The symptoms are many C5105
52-
# warnings, and eventually also some compiler errors. Windows SDK
53-
# 10.0.18362.0 is a version that is known to work and that is also known
54-
# to be installed on the windows-latest runner.
55-
cmake -DCMAKE_SYSTEM_VERSION="10.0.18362.0" ..
49+
cmake ..
5650
if: matrix.os == 'windows-latest'
5751

5852
- name: Build the project

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ project (
2121
# The project version.
2222
# Sets PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR,
2323
# PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK.
24-
VERSION 1.0
24+
VERSION 2.0.0
2525

2626
# Some informational package metadata. Not necessary for the build.
2727
# Sets PROJECT_HOMEPAGE_URL and PROJECT_DESCRIPTION

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libsgfc++
2-
Copyright 2020-2021 Patrick Näf ([email protected])
2+
Copyright 2020-2024 Patrick Näf ([email protected])
33

44
This product uses the source code provided by the SGFC command line utility to
55
read, parse and write SGF data. SGFC was developed by Arno Hollosi

doc/Build.md

Lines changed: 102 additions & 15 deletions
Large diffs are not rendered by default.

doc/ChangeLog.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# ChangeLog
22

3+
## Version 2.0.0 (January 3 2024)
4+
5+
### Features
6+
7+
- None
8+
9+
### Bugfixes
10+
11+
- Fixed numeric value of `SgfcMessageID::IllegalVariationStartCorrected` (#39). The enum value had the same numeric value as `SgfcMessageID::IllegalVariationStartIgnored`.
12+
- Changed the value type for referencing line and column numbers in messages to `unsigned long`, to match the error reporting interface of SGFC (#40). The old type `int` was insufficient to hold all possible `unsigned long` values, also the there was a signed/unsigned mismatch. The change affects the `ISgfcMessage` getters `GetLineNumber()` and `GetColumnNumber()`, as well as the constants `SgfcConstants::InvalidLineNumber` and `SgfcConstants::InvalidColumnNumber`. The constants also changed their value (previously -1, now 0).
13+
14+
### Regressions
15+
16+
- None
17+
18+
### Technical changes
19+
20+
- Replaced internal custom code to determine the path to a temporary folder with `std::filesystem::temp_directory_path()` (#18).
21+
- Updated unit test library Catch2 from v2.13.4 to v3.5.0.
22+
- Updated the [Cross-compiling for iOS](Build.md#cross-compiling-for-ios) documentation for modern CMake/Xcode versions.
23+
- Updated the GitHub build pipelines.
24+
25+
### GitHub issue list
26+
27+
A list of all issues closed for this release is available [on GitHub](https://github.com/herzbube/libsgfcplusplus/milestone/4?closed=1)
28+
29+
30+
## Version 1.0 (February 23 2021)
31+
32+
Initial 1.0 release that includes SGFC v2.0.
33+
34+
## Version 0.2 (beta) (January 12 2021)
35+
36+
Release of version 0.2 (beta).
37+
338
## Version 0.1 (alpha) (October 11 2020)
439

540
Release of version 0.1 (alpha).

include/ISgfcMessage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -----------------------------------------------------------------------------
2-
// Copyright 2020 Patrick Näf ([email protected])
2+
// Copyright 2024 Patrick Näf ([email protected])
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -76,13 +76,13 @@ namespace LibSgfcPlusPlus
7676
/// that caused the message. Returns SgfcConstants::InvalidLineNumber if
7777
/// the message does not refer to a specific line in the SGF data (most
7878
/// fatal errors, but also some errors and warnings).
79-
virtual int GetLineNumber() const = 0;
79+
virtual unsigned long GetLineNumber() const = 0;
8080

8181
/// @brief Returns the number of the column (1-based) in the parsed SGF data
8282
/// that caused the message. Returns SgfcConstants::InvalidColumnNumber if
8383
/// the message does not refer to a specific column in the SGF data (most
8484
/// fatal errors, but also some errors and warnings).
85-
virtual int GetColumnNumber() const = 0;
85+
virtual unsigned long GetColumnNumber() const = 0;
8686

8787
/// @brief Returns true if the message describes a critical problem. Only
8888
/// warning and error messages can be critical. Always returns false for

include/SgfcConstants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -----------------------------------------------------------------------------
2-
// Copyright 2020 Patrick Näf ([email protected])
2+
// Copyright 2024 Patrick Näf ([email protected])
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -58,10 +58,10 @@ namespace LibSgfcPlusPlus
5858
//@{
5959
/// @brief Indicates an invalid line number. This is used for messages
6060
/// that do not refer to a specific line number in a piece of SGF content.
61-
static const int InvalidLineNumber;
61+
static const unsigned long InvalidLineNumber;
6262
/// @brief Indicates an invalid column number. This is used for messages
6363
/// that do not refer to a specific column number in a piece of SGF content.
64-
static const int InvalidColumnNumber;
64+
static const unsigned long InvalidColumnNumber;
6565
/// @brief A library error number (= errno value) indicating "no error".
6666
/// This is defined to be the value 0 (zero).
6767
static const int LibraryErrorNumberNoError;

include/SgfcMessageID.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -----------------------------------------------------------------------------
2-
// Copyright 2020 Patrick Näf ([email protected])
2+
// Copyright 2024 Patrick Näf ([email protected])
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -276,7 +276,7 @@ namespace LibSgfcPlusPlus
276276
/// @brief SGFC found (and fixed) a node that was not in any variation.
277277
NodeNotInVariation = 66,
278278
/// @brief SGFC found (and corrected) an illegal variation start.
279-
IllegalVariationStartCorrected = 21,
279+
IllegalVariationStartCorrected = 67,
280280
/// @brief SGFC was invoked with an argument that is not a supported long
281281
/// command line option.
282282
///

src/SgfcConstants.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -----------------------------------------------------------------------------
2-
// Copyright 2020 Patrick Näf ([email protected])
2+
// Copyright 2024 Patrick Näf ([email protected])
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -24,11 +24,13 @@
2424
namespace LibSgfcPlusPlus
2525
{
2626
const std::string SgfcConstants::LibraryName = "libsgfc++";
27-
const std::string SgfcConstants::LibraryVersion = "1.0";
27+
const std::string SgfcConstants::LibraryVersion = "2.0.0";
2828
const std::string SgfcConstants::SgfcVersion = "2.0";
2929

30-
const int SgfcConstants::InvalidLineNumber = -1;
31-
const int SgfcConstants::InvalidColumnNumber = -1;
30+
// SgfcMessage line and column numbers are 1-based, so value 0 (zero) can be
31+
// used as indicator for an invalid line or column number.
32+
const unsigned long SgfcConstants::InvalidLineNumber = 0;
33+
const unsigned long SgfcConstants::InvalidColumnNumber = 0;
3234

3335
const int SgfcConstants::LibraryErrorNumberNoError = 0;
3436

src/SgfcUtility.cpp

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -----------------------------------------------------------------------------
2-
// Copyright 2020 Patrick Näf ([email protected])
2+
// Copyright 2024 Patrick Näf ([email protected])
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -21,18 +21,17 @@
2121

2222
// C++ Standard Library includes
2323
#include <cstdio> // for remove()
24+
#include <filesystem> // for std::filesystem::temp_directory_path()
2425
#include <fstream> // for std::ofstream and std::ifstream
2526
#include <random>
2627
#include <sstream>
2728
#include <stdexcept>
2829

2930
// System includes
3031
#ifdef _MSC_VER
31-
#include <Windows.h> // for GetTempPath()
3232
#include <io.h> // for _access_s()
3333
#include <process.h> // for _getpid()
3434
#else
35-
#include <cstdlib> // for std::getenv()
3635
#include <unistd.h> // for access() and getpid()
3736
#endif
3837

@@ -190,53 +189,8 @@ namespace LibSgfcPlusPlus
190189

191190
std::string SgfcUtility::GetTempFolderPath()
192191
{
193-
std::string tempFolderPath;
194-
195-
#ifdef _MSC_VER
196-
197-
DWORD bufferLength = MAX_PATH + 1;
198-
char* buffer = new char[bufferLength];
199-
200-
// The Win32 API works with TCHAR, but since everything else in libsgfc++
201-
// does not work with wchar or wstring we don't bother here and just use
202-
// char and string.
203-
204-
DWORD getTempPathResult = GetTempPath(bufferLength, buffer);
205-
if (getTempPathResult == 0 || getTempPathResult > bufferLength)
206-
{
207-
delete[] buffer;
208-
throw std::runtime_error("Win32 API function GetTempPath() failed");
209-
}
210-
211-
tempFolderPath = buffer;
212-
delete[] buffer;
213-
214-
#else
215-
216-
// Environment variable names taken from
217-
// https://en.cppreference.com/w/cpp/filesystem/temp_directory_path
218-
static std::vector<std::string> environmentVariableNames = { "TMPDIR", "TMP", "TEMP", "TEMPDIR" };
219-
220-
tempFolderPath = "/tmp";
221-
222-
for ( const auto& environmentVariableName : environmentVariableNames )
223-
{
224-
const char* environmentVariableValue = std::getenv(environmentVariableName.c_str());
225-
if (environmentVariableValue != nullptr)
226-
{
227-
tempFolderPath = environmentVariableValue;
228-
break;
229-
}
230-
}
231-
232-
#endif
233-
234-
// On all platforms we have no guarantee that the folder actually exists.
235-
// This works purely by convention. Because we intend to replace all this
236-
// cruft with std::filesystem::temp_directory_path() anyway sooner or later,
237-
// this implementation is good enough.
238-
239-
return tempFolderPath;
192+
std::filesystem::path tempFolderPath = std::filesystem::temp_directory_path();
193+
return tempFolderPath.u8string();
240194
}
241195

242196
std::string SgfcUtility::GetUniqueTempFileName()

0 commit comments

Comments
 (0)