From 6cbe4010227c6a51e9b36462ce01913bde4f6033 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Thu, 18 Dec 2025 10:03:02 +0000 Subject: [PATCH] more C90 strictness; move dos stuff into a dosbox folder --- .clang-tidy | 25 +++++++++++++++++++ .gitignore | 1 + CMakeLists.txt | 3 ++- build.sh | 6 ++++- .../CordleDosBoxLauncher.bat | 0 .../CordleDosMakefile.mk | 0 .../DosBoxCordleSetupGuide.md | 0 .../DosboxCordleLauncher.sh | 0 .../cordle_dos_REAMDE.txt | 0 .../dosbox_config_cordle.ini | 0 .../dosbox_cordle_configuration.ini | 0 src/game.c | 2 +- 12 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .clang-tidy rename CordleDosBoxLauncher.bat => dosbox/CordleDosBoxLauncher.bat (100%) rename CordleDosMakefile.mk => dosbox/CordleDosMakefile.mk (100%) rename DosBoxCordleSetupGuide.md => dosbox/DosBoxCordleSetupGuide.md (100%) rename DosboxCordleLauncher.sh => dosbox/DosboxCordleLauncher.sh (100%) rename cordle_dos_REAMDE.txt => dosbox/cordle_dos_REAMDE.txt (100%) rename dosbox_config_cordle.ini => dosbox/dosbox_config_cordle.ini (100%) rename dosbox_cordle_configuration.ini => dosbox/dosbox_cordle_configuration.ini (100%) diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..ed0a13a --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,25 @@ +Checks: > + -*, + clang-diagnostic-*, + clang-analyzer-*, + readability-*, + -readability-identifier-length, + -readability-magic-numbers, + -readability-function-cognitive-complexity, + bugprone-*, + -bugprone-easily-swappable-parameters, + misc-*, + -misc-unused-parameters, + portability-* + +WarningsAsErrors: '' + +HeaderFilterRegex: '.*' + +CheckOptions: + - key: readability-function-size.LineThreshold + value: '100' + - key: readability-function-size.StatementThreshold + value: '50' + +FormatStyle: none \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8a579ce..7e1aae6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ build/ cmake-build-debug/ +cmake-build-release/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a1b61c7..218ddd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(cordle C) set(CMAKE_C_STANDARD 90) set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c90 -pedantic") # Find ncurses library find_package(Curses REQUIRED) @@ -27,5 +28,5 @@ target_link_libraries(cordle ${CURSES_LIBRARIES}) # Set compiler flags for C90 compliance if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - target_compile_options(cordle PRIVATE -Wall -Wextra -pedantic) + target_compile_options(cordle PRIVATE -Wpedantic -Wextra -pedantic) endif() diff --git a/build.sh b/build.sh index f08d31a..ea01efb 100755 --- a/build.sh +++ b/build.sh @@ -3,11 +3,15 @@ mkdir -p build/cordle echo "Building application." -gcc -std=c90 -pedantic -Wall -o build/cordle/cordle src/*.c -Iinclude -lncurses +gcc -v -std=c90 -pedantic -Wpedantic -o build/cordle/cordle src/*.c -Iinclude -lncurses > build/cordle-build.log 2>&1 export RESULT=$? if (( RESULT == 0 )); then echo "Compile successful. Copying wordlists..." cp -R wordlists build/cordle echo "Build completed." + rm build/cordle-build.log +else + echo "Something went wrong..." + cat build/cordle-build.log fi diff --git a/CordleDosBoxLauncher.bat b/dosbox/CordleDosBoxLauncher.bat similarity index 100% rename from CordleDosBoxLauncher.bat rename to dosbox/CordleDosBoxLauncher.bat diff --git a/CordleDosMakefile.mk b/dosbox/CordleDosMakefile.mk similarity index 100% rename from CordleDosMakefile.mk rename to dosbox/CordleDosMakefile.mk diff --git a/DosBoxCordleSetupGuide.md b/dosbox/DosBoxCordleSetupGuide.md similarity index 100% rename from DosBoxCordleSetupGuide.md rename to dosbox/DosBoxCordleSetupGuide.md diff --git a/DosboxCordleLauncher.sh b/dosbox/DosboxCordleLauncher.sh similarity index 100% rename from DosboxCordleLauncher.sh rename to dosbox/DosboxCordleLauncher.sh diff --git a/cordle_dos_REAMDE.txt b/dosbox/cordle_dos_REAMDE.txt similarity index 100% rename from cordle_dos_REAMDE.txt rename to dosbox/cordle_dos_REAMDE.txt diff --git a/dosbox_config_cordle.ini b/dosbox/dosbox_config_cordle.ini similarity index 100% rename from dosbox_config_cordle.ini rename to dosbox/dosbox_config_cordle.ini diff --git a/dosbox_cordle_configuration.ini b/dosbox/dosbox_cordle_configuration.ini similarity index 100% rename from dosbox_cordle_configuration.ini rename to dosbox/dosbox_cordle_configuration.ini diff --git a/src/game.c b/src/game.c index 6e7d27e..3afe2a7 100644 --- a/src/game.c +++ b/src/game.c @@ -76,7 +76,7 @@ void check_guess(GameState *game, const char *guess, int *colors) { break; } } - /* If still absent, mark letter as not in word */ + /* If still absent, mark a letter as not in word */ if (colors[i] == COLOR_ABSENT) { if (game->letter_status[guess_copy[i] - 'A'] == STATUS_UNUSED) { game->letter_status[guess_copy[i] - 'A'] = STATUS_ABSENT;