Apply clang-format across the whole tree

Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs,
Allman functions) over every source file so the tree is formatter-clean.
Whitespace only -- no behavior change; full x64 + x86 suites pass.

Also set SortIncludes: false in .clang-format. Windows include order is
load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h /
dinput.h; winsock2.h must precede windows.h), and the default
alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build
break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
2026-07-12 11:52:53 +02:00
parent c684a15fb9
commit 30eccf749d
155 changed files with 3333 additions and 6171 deletions

View File

@@ -13,15 +13,13 @@
using namespace coop;
namespace
{
namespace {
int g_failures = 0;
int g_counter = 0;
void check(bool ok, const char* what)
{
std::printf("%s %s\n", ok ? " ok:" : "FAIL:", what);
if (!ok)
{
if (!ok) {
++g_failures;
}
}
@@ -30,13 +28,11 @@ std::wstring write_temp(const std::vector<std::uint8_t>& bytes)
{
wchar_t dir[MAX_PATH] = {};
GetTempPathW(MAX_PATH, dir);
std::wstring path = std::wstring(dir) + L"coop_wavtest_" + std::to_wstring(GetCurrentProcessId()) + L"_" +
std::to_wstring(g_counter++) + L".wav";
std::wstring path = std::wstring(dir) + L"coop_wavtest_" + std::to_wstring(GetCurrentProcessId()) + L"_"
+ std::to_wstring(g_counter++) + L".wav";
FILE* f = nullptr;
if (_wfopen_s(&f, path.c_str(), L"wb") == 0 && f != nullptr)
{
if (!bytes.empty())
{
if (_wfopen_s(&f, path.c_str(), L"wb") == 0 && f != nullptr) {
if (!bytes.empty()) {
std::fwrite(bytes.data(), 1, bytes.size(), f);
}
std::fclose(f);
@@ -52,10 +48,9 @@ void put4(std::vector<std::uint8_t>& b, const char* s)
// Build a WAV where the `data` chunk's declared size can differ from the bytes actually appended
// (declared_data_size < 0 means "use the real size"), and an optional junk chunk can be inserted
// before `data` with a chosen size field (to exercise the chunk walk).
std::vector<std::uint8_t> build_wav(std::uint16_t tag, std::uint16_t channels, std::uint32_t rate,
std::uint16_t bits, const std::vector<std::uint8_t>& data,
long long declared_data_size = -1, const char* junk_id = nullptr,
std::uint32_t junk_size = 0)
std::vector<std::uint8_t> build_wav(std::uint16_t tag, std::uint16_t channels, std::uint32_t rate, std::uint16_t bits,
const std::vector<std::uint8_t>& data, long long declared_data_size = -1,
const char* junk_id = nullptr, std::uint32_t junk_size = 0)
{
std::vector<std::uint8_t> b;
put4(b, "RIFF");
@@ -69,19 +64,17 @@ std::vector<std::uint8_t> build_wav(std::uint16_t tag, std::uint16_t channels, s
detail::wav_put_u32(b, rate * channels * (bits / 8));
detail::wav_put_u16(b, static_cast<std::uint16_t>(channels * (bits / 8)));
detail::wav_put_u16(b, bits);
if (junk_id != nullptr)
{
if (junk_id != nullptr) {
put4(b, junk_id);
detail::wav_put_u32(b, junk_size);
b.insert(b.end(), junk_size, 0xAB); // junk body
if (junk_size & 1)
{
if (junk_size & 1) {
b.push_back(0); // RIFF pads odd chunks to an even boundary (what the reader's & 1 skips)
}
}
put4(b, "data");
detail::wav_put_u32(b, declared_data_size < 0 ? static_cast<std::uint32_t>(data.size())
: static_cast<std::uint32_t>(declared_data_size));
: static_cast<std::uint32_t>(declared_data_size));
b.insert(b.end(), data.begin(), data.end());
return b;
}