From 0a2844c40a3907fe1207aed5ce89416dd06c5637 Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 24 Oct 2023 13:55:58 -0400 Subject: Added debug configuration option --- .cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx | Bin 520 -> 0 bytes .cache/clangd/index/holder.h.A6A9759559698491.idx | Bin 454 -> 0 bytes .cache/clangd/index/main.c.B35546292B5EA1F4.idx | Bin 3652 -> 0 bytes .cache/clangd/index/ring.h.D0AA315870801682.idx | Bin 872 -> 0 bytes .gitignore | 1 + config.h.in | 3 ++ config.h.in~ | 61 ---------------------- configure | 24 +++++++++ configure.ac | 11 ++++ src/main.c | 39 +++++++------- 10 files changed, 60 insertions(+), 79 deletions(-) delete mode 100644 .cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx delete mode 100644 .cache/clangd/index/holder.h.A6A9759559698491.idx delete mode 100644 .cache/clangd/index/main.c.B35546292B5EA1F4.idx delete mode 100644 .cache/clangd/index/ring.h.D0AA315870801682.idx delete mode 100644 config.h.in~ diff --git a/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx b/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx deleted file mode 100644 index aa95afc..0000000 Binary files a/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx and /dev/null differ diff --git a/.cache/clangd/index/holder.h.A6A9759559698491.idx b/.cache/clangd/index/holder.h.A6A9759559698491.idx deleted file mode 100644 index 9f59667..0000000 Binary files a/.cache/clangd/index/holder.h.A6A9759559698491.idx and /dev/null differ diff --git a/.cache/clangd/index/main.c.B35546292B5EA1F4.idx b/.cache/clangd/index/main.c.B35546292B5EA1F4.idx deleted file mode 100644 index 02a1be3..0000000 Binary files a/.cache/clangd/index/main.c.B35546292B5EA1F4.idx and /dev/null differ diff --git a/.cache/clangd/index/ring.h.D0AA315870801682.idx b/.cache/clangd/index/ring.h.D0AA315870801682.idx deleted file mode 100644 index 304b0bb..0000000 Binary files a/.cache/clangd/index/ring.h.D0AA315870801682.idx and /dev/null differ diff --git a/.gitignore b/.gitignore index 490cac5..0e87bc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .cache .cache/* +*~ diff --git a/config.h.in b/config.h.in index 031bab0..61ea3f8 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Enable debug printing */ +#undef DEBUG + /* Define to 1 if a SysV or X/Open compatible Curses library is present */ #undef HAVE_CURSES diff --git a/config.h.in~ b/config.h.in~ deleted file mode 100644 index 031bab0..0000000 --- a/config.h.in~ +++ /dev/null @@ -1,61 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if a SysV or X/Open compatible Curses library is present */ -#undef HAVE_CURSES - -/* Define to 1 if library supports color (enhanced functions) */ -#undef HAVE_CURSES_COLOR - -/* Define to 1 if library supports X/Open Enhanced functions */ -#undef HAVE_CURSES_ENHANCED - -/* Define to 1 if is present */ -#undef HAVE_CURSES_H - -/* Define to 1 if library supports certain obsolete features */ -#undef HAVE_CURSES_OBSOLETE - -/* Define to 1 if the Ncurses library is present */ -#undef HAVE_NCURSES - -/* Define to 1 if the NcursesW library is present */ -#undef HAVE_NCURSESW - -/* Define to 1 if is present */ -#undef HAVE_NCURSESW_CURSES_H - -/* Define to 1 if is present */ -#undef HAVE_NCURSESW_H - -/* Define to 1 if is present */ -#undef HAVE_NCURSES_CURSES_H - -/* Define to 1 if is present */ -#undef HAVE_NCURSES_H - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Title to print at the top */ -#undef TITLE - -/* Version number of package */ -#undef VERSION diff --git a/configure b/configure index 55bbf15..9e18f98 100755 --- a/configure +++ b/configure @@ -678,6 +678,7 @@ ac_user_opts=' enable_option_checking with_ncurses with_ncursesw +enable_debug enable_dependency_tracking enable_silent_rules ' @@ -1309,6 +1310,7 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-debug enable debug output (disabled by default) --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking @@ -3918,6 +3920,28 @@ if test "x$ax_cv_curses" != xyes; then as_fn_error $? "requires an X/Open-compatible Curses library" "$LINENO" 5 fi +# enables/disables +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; enable_debug=${enableval} +else + enable_debug=no +fi + +if test "x$enable_debug" = xyes; then + +cat >>confdefs.h <<_ACEOF +#define DEBUG 1 +_ACEOF + +else + +cat >>confdefs.h <<_ACEOF +#define DEBUG 0 +_ACEOF + +fi + # Setup Automake am__api_version='1.16' diff --git a/configure.ac b/configure.ac index 356ff6e..694f712 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,17 @@ if test "x$ax_cv_curses" != xyes; then AC_MSG_ERROR([requires an X/Open-compatible Curses library]) fi +# enables/disables +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], [enable debug output (disabled by default)])], + [enable_debug=${enableval}], + [enable_debug=no]) +if test "x$enable_debug" = xyes; then + AC_DEFINE_UNQUOTED([DEBUG], [1], [Enable debug printing]) +else + AC_DEFINE_UNQUOTED([DEBUG], [0], [Enable debug printing]) +fi + # Setup Automake AM_INIT_AUTOMAKE AC_CONFIG_FILES([ diff --git a/src/main.c b/src/main.c index 4039aa3..4e74d19 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,5 @@ #include +#include #include #include "config.h" @@ -86,24 +87,26 @@ void draw_body() { */ // DEBUG - mvprintw(0, 0, "tower 1: %c %c %c", (towers[0].rings[0] ? 'X' : '_'), (towers[0].rings[1] ? 'X' : '_'), (towers[0].rings[2] ? 'X' : '_')); - mvprintw(1, 0, "tower 2: %c %c %c", (towers[1].rings[0] ? 'X' : '_'), (towers[1].rings[1] ? 'X' : '_'), (towers[1].rings[2] ? 'X' : '_')); - mvprintw(2, 0, "tower 3: %c %c %c", (towers[2].rings[0] ? 'X' : '_'), (towers[2].rings[1] ? 'X' : '_'), (towers[2].rings[2] ? 'X' : '_')); - mvprintw(3, 0, "ring 1:"); - mvprintw(4, 2, "location: %d", rings[0].location); - mvprintw(5, 2, "held: %d", rings[0].held); - mvprintw(6, 2, "size: %d", rings[0].size); - mvprintw(7, 2, "ascii: %s", rings[0].ascii); - mvprintw(8, 0, "ring 2:"); - mvprintw(9, 2, "location: %d", rings[1].location); - mvprintw(10, 2, "held: %d", rings[1].held); - mvprintw(11, 2, "size: %d", rings[1].size); - mvprintw(12, 2, "ascii: %s", rings[1].ascii); - mvprintw(13, 0, "ring 3:"); - mvprintw(14, 2, "location: %d", rings[2].location); - mvprintw(15, 2, "held: %d", rings[2].held); - mvprintw(16, 2, "size: %d", rings[2].size); - mvprintw(17, 2, "ascii: %s", rings[2].ascii); + if(DEBUG) { + mvprintw(0, 0, "tower 1: %c %c %c", (towers[0].rings[0] ? 'X' : '_'), (towers[0].rings[1] ? 'X' : '_'), (towers[0].rings[2] ? 'X' : '_')); + mvprintw(1, 0, "tower 2: %c %c %c", (towers[1].rings[0] ? 'X' : '_'), (towers[1].rings[1] ? 'X' : '_'), (towers[1].rings[2] ? 'X' : '_')); + mvprintw(2, 0, "tower 3: %c %c %c", (towers[2].rings[0] ? 'X' : '_'), (towers[2].rings[1] ? 'X' : '_'), (towers[2].rings[2] ? 'X' : '_')); + mvprintw(3, 0, "ring 1:"); + mvprintw(4, 2, "location: %d", rings[0].location); + mvprintw(5, 2, "held: %d", rings[0].held); + mvprintw(6, 2, "size: %d", rings[0].size); + mvprintw(7, 2, "ascii: %s", rings[0].ascii); + mvprintw(8, 0, "ring 2:"); + mvprintw(9, 2, "location: %d", rings[1].location); + mvprintw(10, 2, "held: %d", rings[1].held); + mvprintw(11, 2, "size: %d", rings[1].size); + mvprintw(12, 2, "ascii: %s", rings[1].ascii); + mvprintw(13, 0, "ring 3:"); + mvprintw(14, 2, "location: %d", rings[2].location); + mvprintw(15, 2, "held: %d", rings[2].held); + mvprintw(16, 2, "size: %d", rings[2].size); + mvprintw(17, 2, "ascii: %s", rings[2].ascii); + } } void draw_tower(int ring_index, int startx, int starty) { -- cgit