Skip to content

Commit

Permalink
Merge pull request #1702 from heinezen/fx/clang_format_ppindent
Browse files Browse the repository at this point in the history
Clang format rule: Indent preprocessor directives
  • Loading branch information
TheJJ authored Nov 1, 2024
2 parents 00b7f4c + 3c47b65 commit 31f74ee
Show file tree
Hide file tree
Showing 27 changed files with 254 additions and 267 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentGotoLabels: false
IndentPPDirectives: None
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
# clang-format-16 InsertNewlineAtEOF: true
Expand Down
18 changes: 9 additions & 9 deletions libopenage/console/tests.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright 2014-2019 the openage authors. See copying.md for legal info.
// Copyright 2014-2024 the openage authors. See copying.md for legal info.

#include <vector>
#include <string>
#include <vector>

#ifdef _MSC_VER
#define STDOUT_FILENO 1
#define STDOUT_FILENO 1
#else
#include <unistd.h>
#include <unistd.h>
#endif
#include "../util/fds.h"
#include "../util/pty.h"
Expand All @@ -15,8 +15,8 @@
#include <cstdlib>
#include <fcntl.h>

#include "../log/log.h"
#include "../error/error.h"
#include "../log/log.h"

#include "buf.h"
#include "console.h"
Expand Down Expand Up @@ -51,7 +51,7 @@ void render() {


void interactive() {
#ifndef _WIN32
#ifndef _WIN32

console::Buf buf{{80, 25}, 1337, 80};
struct winsize ws;
Expand All @@ -75,7 +75,7 @@ void interactive() {
throw Error(MSG(err) << "execl(\"" << shell << "\", \"" << shell << "\", nullptr) failed: " << strerror(errno));
}
default:
//we are the parent
// we are the parent
break;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ void interactive() {
ssize_t retval = read(ptyin.fd, rdbuf, rdbuf_size);
switch (retval) {
case -1:
switch(errno) {
switch (errno) {
case EIO:
loop = false;
break;
Expand Down Expand Up @@ -175,7 +175,7 @@ void interactive() {
// show cursor
termout.puts("\x1b[?25h");

#endif /* _WIN32 */
#endif /* _WIN32 */
}


Expand Down
6 changes: 3 additions & 3 deletions libopenage/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// TODO: Remove custom jthread definition when clang/libc++ finally supports it
#if __llvm__
#if !__cpp_lib_jthread
#if !__cpp_lib_jthread
namespace std {
class jthread : public thread {
public:
Expand All @@ -27,9 +27,9 @@ class jthread : public thread {
}
};
} // namespace std
#endif
#endif
#else
#include <stop_token>
#include <stop_token>
#endif


Expand Down
6 changes: 3 additions & 3 deletions libopenage/error/handlers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

/*
* This file holds handlers for std::terminate and SIGSEGV.
Expand All @@ -17,9 +17,9 @@
#include <iostream>

#ifdef _MSC_VER
#include <io.h>
#include <io.h>
#else
#include <unistd.h>
#include <unistd.h>
#endif

#include "util/init.h"
Expand Down
20 changes: 10 additions & 10 deletions libopenage/error/stackanalyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#include "stackanalyzer.h"

Expand Down Expand Up @@ -30,8 +30,8 @@ constexpr uint64_t base_skip_frames = 1;

#if WITH_BACKTRACE

// use modern <backtrace.h>
#include <backtrace.h>
// use modern <backtrace.h>
#include <backtrace.h>

namespace openage {
namespace error {
Expand Down Expand Up @@ -59,7 +59,7 @@ struct backtrace_state *bt_state;
util::OnInit init_backtrace_state([]() {
bt_state = backtrace_create_state(
nullptr, // auto-determine filename
1, // threaded
1, // threaded
backtrace_error_callback,
nullptr // passed to the callback
);
Expand Down Expand Up @@ -189,8 +189,8 @@ void StackAnalyzer::get_symbols(std::function<void(const backtrace_symbol *)> cb

#else // WITHOUT_BACKTRACE

#ifdef _WIN32
#include <windows.h>
#ifdef _WIN32
#include <windows.h>

namespace openage {
namespace error {
Expand All @@ -208,10 +208,10 @@ void StackAnalyzer::analyze() {
} // namespace error
} // namespace openage

#else // not _MSC_VER
#else // not _MSC_VER

// use GNU's <execinfo.h>
#include <execinfo.h>
// use GNU's <execinfo.h>
#include <execinfo.h>

namespace openage::error {

Expand Down Expand Up @@ -256,7 +256,7 @@ void StackAnalyzer::analyze() {

} // namespace openage::error

#endif // for _MSC_VER or GNU execinfo
#endif // for _MSC_VER or GNU execinfo

namespace openage::error {

Expand Down
32 changes: 16 additions & 16 deletions libopenage/event/demo/gui.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// Copyright 2016-2023 the openage authors. See copying.md for legal info.
// Copyright 2016-2024 the openage authors. See copying.md for legal info.

#include "gui.h"

// the gui requires ncurses.
#if WITH_NCURSES

#include <algorithm>
#include <array>
#include <cstdlib>
#include <cstring>
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__
#include <vector>

#include "curve/continuous.h"
#include "curve/discrete.h"
#include "event/demo/gamestate.h"
#include "util/fixed_point.h"
#include <algorithm>
#include <array>
#include <cstdlib>
#include <cstring>
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__
#include <vector>

#include "curve/continuous.h"
#include "curve/discrete.h"
#include "event/demo/gamestate.h"
#include "util/fixed_point.h"

namespace openage::event::demo {

Expand Down
18 changes: 9 additions & 9 deletions libopenage/event/demo/gui.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#pragma once

#include "config.h"

#if WITH_NCURSES
#include <deque>
#include <memory>
#include <string>
#include <vector>

#include "event/demo/gamestate.h"
#include "time/time.h"
#include "util/vector.h"
#include <deque>
#include <memory>
#include <string>
#include <vector>

#include "event/demo/gamestate.h"
#include "time/time.h"
#include "util/vector.h"


namespace openage::event::demo {
Expand Down
12 changes: 6 additions & 6 deletions libopenage/event/demo/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2023 the openage authors. See copying.md for legal info.
// Copyright 2016-2024 the openage authors. See copying.md for legal info.

#include "main.h"

Expand All @@ -16,11 +16,11 @@
#include "renderer/gui/integration/public/gui_application_with_logger.h"

#if WITH_NCURSES
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__
#endif


Expand Down
24 changes: 12 additions & 12 deletions libopenage/event/demo/physics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 the openage authors. See copying.md for legal info.
// Copyright 2017-2024 the openage authors. See copying.md for legal info.

#include "physics.h"

Expand All @@ -9,13 +9,13 @@
#include <string>

#if WITH_NCURSES
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__
#ifdef __MINGW32__
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif // __MINGW32__

#include "gui.h"
#include "gui.h"
#endif

#include "error/error.h"
Expand Down Expand Up @@ -377,7 +377,7 @@ void Physics::init(const std::shared_ptr<PongState> &gstate,
loop->create_event("demo.ball.reflect_panel", state->ball->position, state, now);

// FIXME once "reset": deregister
//reset(state, mgr, now);
// reset(state, mgr, now);
}

void Physics::process_input(const std::shared_ptr<PongState> &state,
Expand Down Expand Up @@ -466,11 +466,11 @@ void Physics::process_input(const std::shared_ptr<PongState> &state,
Physics::reset(state, *mgr, now);
break;

//if (player->state->get(now).state == PongEvent::LOST) {
// if (player->state->get(now).state == PongEvent::LOST) {
// state->ball.position->set_last(now, state.display_boundary * 0.5);
//}
//update_ball(state, now, init_recursion_limit);
//break;
// }
// update_ball(state, now, init_recursion_limit);
// break;

default:
break;
Expand Down
10 changes: 5 additions & 5 deletions libopenage/log/level.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#pragma once

Expand Down Expand Up @@ -50,11 +50,11 @@ struct OAAPI level : util::Enum<level_value> {
level();

#ifdef __MINGW32__
// Do not try to optimize these out even if it seems they are not used.
// Namely MIN that is not used within the library.
#define NOOPTIMIZE __attribute__((__used__))
// Do not try to optimize these out even if it seems they are not used.
// Namely MIN that is not used within the library.
#define NOOPTIMIZE __attribute__((__used__))
#else
#define NOOPTIMIZE
#define NOOPTIMIZE
#endif // _win32

static constexpr level_value MIN NOOPTIMIZE{{"min loglevel", -1000}, "5"};
Expand Down
6 changes: 3 additions & 3 deletions libopenage/log/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@


#if defined(__GNUC__)
#define OPENAGE_FUNC_NAME __PRETTY_FUNCTION__
#define OPENAGE_FUNC_NAME __PRETTY_FUNCTION__
#elif defined(_MSC_VER)
#define OPENAGE_FUNC_NAME __FUNCSIG__
#define OPENAGE_FUNC_NAME __FUNCSIG__
#else
#define OPENAGE_FUNC_NAME __FUNCTION__
#define OPENAGE_FUNC_NAME __FUNCTION__
#endif

namespace openage {
Expand Down
6 changes: 3 additions & 3 deletions libopenage/log/stdout_logsink.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#include "stdout_logsink.h"

Expand All @@ -7,8 +7,8 @@
#include <string>

#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif

#include "log/level.h"
Expand Down
Loading

0 comments on commit 31f74ee

Please sign in to comment.