From a5ad4a7d4c9e8caa3cc6d457d5f21082348cb3ad Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Thu, 7 Mar 2024 20:51:58 +0100 Subject: [PATCH 1/7] COLS/LINES as local vars when assigning to --- cmatrix.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cmatrix.c b/cmatrix.c index 7d8ca39..2f7956e 100644 --- a/cmatrix.c +++ b/cmatrix.c @@ -56,7 +56,6 @@ #include #endif #endif - #ifdef HAVE_SYS_IOCTL_H #include #endif @@ -261,8 +260,11 @@ void resize_screen(void) { char *tty; int fd = 0; int result = 0; + int cols = 0; + int lines = 0; struct winsize win; + tty = ttyname(0); if (!tty) { return; @@ -271,8 +273,8 @@ void resize_screen(void) { result = GetConsoleScreenBufferInfo(hStdHandle, &csbiInfo); if (!result) return; - LINES = csbiInfo.dwSize.Y; - COLS = csbiInfo.dwSize.X; + lines = csbiInfo.dwSize.Y; + cols = csbiInfo.dwSize.X; #else } fd = open(tty, O_RDWR); @@ -284,21 +286,21 @@ void resize_screen(void) { return; } - COLS = win.ws_col; - LINES = win.ws_row; + cols = win.ws_col; + lines = win.ws_row; #endif - if (LINES < 10) { - LINES = 10; + if (lines < 10) { + lines = 10; } - if (COLS < 10) { - COLS = 10; + if (cols < 10) { + cols = 10; } #ifdef HAVE_RESIZETERM - resizeterm(LINES, COLS); + resizeterm(lines, cols); #ifdef HAVE_WRESIZE - if (wresize(stdscr, LINES, COLS) == ERR) { + if (wresize(stdscr, lines, cols) == ERR) { c_die("Cannot resize window!"); } #endif /* HAVE_WRESIZE */ From 86e0c8cae6e4a28123204113b68194e98b208a5d Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Thu, 7 Mar 2024 20:59:08 +0100 Subject: [PATCH 2/7] Fix spacing --- cmatrix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmatrix.c b/cmatrix.c index 2f7956e..0aae03e 100644 --- a/cmatrix.c +++ b/cmatrix.c @@ -56,6 +56,7 @@ #include #endif #endif + #ifdef HAVE_SYS_IOCTL_H #include #endif From c56098fadb6184f424cc142142c9dfde63511036 Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Sun, 23 Jun 2024 16:58:21 +0200 Subject: [PATCH 3/7] Changes to support ncursesw --- CMakeLists.txt | 2 +- Makefile.am | 5 +++++ cmatrix.c | 5 ++++- configure.ac | 23 ++++++++++++++++------- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fba6fed..0397d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ include(GNUInstallDirs) # These are relative to CMAKE_INSTALL_PREFIX # which by default is "/usr/local" -set(CONSOLE_FONTS_DIRS "share/consolefonts" "lib/kbd/consolefonts") +set(CONSOLE_FONTS_DIRS "share/consolefonts" "lib/kbd/consolefonts" "share/kbd/consolefonts") set(X_FONTS_DIRS "lib/X11/fonts/misc" "X11R6/lib/X11/fonts/misc" "share/fonts/X11/misc") set(MKFONTDIR "/usr/bin/mkfontdir") diff --git a/Makefile.am b/Makefile.am index be482b4..0716c26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,11 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/matrix.fnt $(DESTDIR)/usr/lib/kbd/consolefonts; \ $(INSTALL_DATA) $(srcdir)/matrix.psf.gz $(DESTDIR)/usr/lib/kbd/consolefonts; \ fi; \ + if test -d /usr/share/kbd/consolefonts; then \ + echo " Installing matrix fonts in /usr/share/kbd/consolefonts..."; \ + $(INSTALL_DATA) $(srcdir)/matrix.fnt $(DESTDIR)/usr/share/kbd/consolefonts; \ + $(INSTALL_DATA) $(srcdir)/matrix.psf.gz $(DESTDIR)/usr/share/kbd/consolefonts; \ + fi; \ if test -d /usr/share/fonts/misc; then \ echo " Installing X window matrix fonts in /usr/share/fonts/misc..."; \ echo " Running mkfontdir /usr/share/fonts/misc..."; \ diff --git a/cmatrix.c b/cmatrix.c index 0aae03e..03f5b91 100644 --- a/cmatrix.c +++ b/cmatrix.c @@ -47,6 +47,9 @@ #include #endif +#ifdef HAVE_NCURSESW +#include +#else #ifdef HAVE_NCURSES_H #include #else @@ -56,7 +59,7 @@ #include #endif #endif - +#endif #ifdef HAVE_SYS_IOCTL_H #include #endif diff --git a/configure.ac b/configure.ac index 0565a52..d78b8de 100644 --- a/configure.ac +++ b/configure.ac @@ -19,9 +19,6 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_MAKE_SET -dnl Checks for libraries. -dnl Replace `main' with a function in -lncurses: -AC_CHECK_LIB(ncurses, main) dnl Checks for header files. AC_HEADER_STDC @@ -34,8 +31,14 @@ AC_CHECK_FUNCS(putenv) dnl Checks for libraries. AC_CHECK_HEADERS(curses.h ncurses.h) + CURSES_LIB_NAME="" -AC_CHECK_LIB(ncurses, tgetent, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) +AC_CHECK_LIB(ncursesw, tgetent, CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw) + +if eval "test x$CURSES_LIB_NAME = x" +then + AC_CHECK_LIB(ncurses, tgetent, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) +fi if eval "test x$CURSES_LIB_NAME = x" then @@ -49,7 +52,7 @@ fi if eval "test x$CURSES_LIB_NAME = x" then - AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap) + AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap)q fi if eval "test x$CURSES_LIB_NAME = x" @@ -65,6 +68,10 @@ then *** errors compiling cmatrix.]) else AC_MSG_RESULT("Using $CURSES_LIB_NAME as the termcap library") + if eval "test $CURSES_LIB_NAME = ncursesw" + then + AC_CHECK_LIB([$CURSES_LIB_NAME], addwstr, [AC_DEFINE(HAVE_NCURSESW)]) + fi fi AC_CHECK_LIB($CURSES_LIB_NAME, use_default_colors, @@ -72,7 +79,6 @@ AC_CHECK_LIB($CURSES_LIB_NAME, use_default_colors, AC_CHECK_LIB($CURSES_LIB_NAME, resizeterm, [AC_DEFINE(HAVE_RESIZETERM)]) AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, [AC_DEFINE(HAVE_WRESIZE)]) - dnl Only change gcc options if we are using gcc. if test "$ac_cv_prog_CC" = gcc -o "$ac_cv_prog_CC" = g++; then CFLAGS="$CFLAGS -Wall -Wno-comment" @@ -115,10 +121,11 @@ if test "x$enable_fonts" != xfalse; then if test x$SETFONT != x -o x$SETFONT != x'"$SETFONT"'; then dnl Now look for the console fonts directory - AC_CHECK_FILES([/usr/lib/kbd/consolefonts /usr/share/consolefonts]) + AC_CHECK_FILES([/usr/lib/kbd/consolefonts /usr/share/consolefonts /usr/share/kbd/consolefonts]) if test "x$ac_cv_file__usr_lib_kbd_consolefonts" = "xno"; then if test "x$ac_cv_file__usr_share_consolefonts" = "xno"; then + if test "x$ac_cv_file__usr_share_kbd_consolefonts" = "xno"; then AC_MSG_WARN([ *** You do not appear to have a consolefonts directory in a standard location @@ -128,6 +135,7 @@ if test "x$enable_fonts" != xfalse; then *** matrix console font (and the -l command line switch) unless the font *** is located in your current directory when you run CMatrix. ]) + fi fi fi fi @@ -168,5 +176,6 @@ AH_TEMPLATE([HAVE_SETFONT], [Define this if you have the linux setfont program]) AH_TEMPLATE([HAVE_WRESIZE], [Define this if you have the wresize function in your ncurses-type library]) AH_TEMPLATE([HAVE_RESIZETERM], [Define this if you have the resizeterm function in your ncurses-type library]) AH_TEMPLATE([USE_TIOCSTI], [Define this if you want a character you pressed in the screensaver mode to retain in the terminal]) +AH_TEMPLATE([HAVE_NCURSESW], [Define this if you have the ncursesw library]) AC_OUTPUT(Makefile cmatrix.spec) From 0ec4cd7ba4bea5581462706987160d3e91baff66 Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Sat, 29 Jun 2024 09:39:16 +0200 Subject: [PATCH 4/7] Remove stray q at the end of tgetent check --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d78b8de..f1adf39 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,7 @@ fi if eval "test x$CURSES_LIB_NAME = x" then - AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap)q + AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap) fi if eval "test x$CURSES_LIB_NAME = x" From 6e8309be48d508722c7edcd8f959ca02b471eb07 Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Sat, 29 Jun 2024 13:14:19 +0200 Subject: [PATCH 5/7] termcap and ncurses check was mushed together - now separated --- configure.ac | 64 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index f1adf39..84bd8ee 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([cmatrix], [2.0], [abishekvashok@gmail.com]) +AC_INIT([cmatrix],[2.0],[abishekvashok@gmail.com]) AC_CONFIG_SRCDIR([cmatrix.c]) -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE AC_CANONICAL_HOST @@ -25,49 +25,78 @@ AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h termios.h termio.h getopt.h) dnl Checks for library functions. -AC_TYPE_SIGNAL +AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. +Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl +AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( +[AC_LANG_PROGRAM([#include +#include +], + [return *(signal (0, 0)) (0) == 1;])], + [ac_cv_type_signal=int], + [ac_cv_type_signal=void])]) +AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers + (`int' or `void').]) + AC_CHECK_FUNCS(putenv) dnl Checks for libraries. AC_CHECK_HEADERS(curses.h ncurses.h) -CURSES_LIB_NAME="" -AC_CHECK_LIB(ncursesw, tgetent, CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw) +TERMCAP_LIB_NAME="" +AC_CHECK_LIB(ncursesw, tgetent, TERMCAP_LIB="-lncursesw" TERMCAP_LIB_NAME=ncursesw) -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(ncurses, tgetent, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) + AC_CHECK_LIB(ncurses, tgetent, TERMCAP_LIB="-lncurses" TERMCAP_LIB_NAME=ncurses) fi -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(curses, tgetent, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses) + AC_CHECK_LIB(curses, tgetent, TERMCAP_LIB="-lcurses" TERMCAP_LIB_NAME=curses) fi -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(pdcurses, initscr, CURSES_LIB="-lpdcurses" CURSES_LIB_NAME=pdcurses) + AC_CHECK_LIB(pdcurses, initscr, TERMCAP_LIB="-lpdcurses" TERMCAP_LIB_NAME=pdcurses) fi -if eval "test x$CURSES_LIB_NAME = x" +if eval "test x$TERMCAP_LIB_NAME = x" +then + AC_CHECK_LIB(termcap, tgetent, TERMCAP_LIB="-ltermcap" TERMCAP_LIB_NAME=termcap) +fi + +if eval "test x$TERMCAP_LIB_NAME = x" +then + AC_CHECK_LIB(tinfo, tgetent, TERMCAP_LIB="-ltinfo" TERMCAP_LIB_NAME=tinfo) +fi + +if eval "test x$TERMCAP_LIB_NAME = x" then - AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap) + AC_MSG_WARN([ +*** No termcap lib available, consider getting the official ncurses +*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get +*** errors compiling cmatrix.]) +else + AC_MSG_RESULT(Using $TERMCAP_LIB_NAME as the termcap library) fi +CURSES_LIB_NAME="" +AC_CHECK_LIB(ncursesw, addwstr, CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw) + if eval "test x$CURSES_LIB_NAME = x" then - AC_CHECK_LIB(tinfo, tgetent, CURSES_LIB="-ltinfo" CURSES_LIB_NAME=tinfo) + AC_CHECK_LIB(ncurses, addwstr, CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses) fi if eval "test x$CURSES_LIB_NAME = x" then AC_MSG_WARN([ -*** No termcap lib available, consider getting the official ncurses +*** No curses lib available, consider getting the official ncurses *** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get *** errors compiling cmatrix.]) else - AC_MSG_RESULT("Using $CURSES_LIB_NAME as the termcap library") + AC_MSG_RESULT(Using $CURSES_LIB_NAME as the ncurses library) if eval "test $CURSES_LIB_NAME = ncursesw" then AC_CHECK_LIB([$CURSES_LIB_NAME], addwstr, [AC_DEFINE(HAVE_NCURSESW)]) @@ -178,4 +207,5 @@ AH_TEMPLATE([HAVE_RESIZETERM], [Define this if you have the resizeterm function AH_TEMPLATE([USE_TIOCSTI], [Define this if you want a character you pressed in the screensaver mode to retain in the terminal]) AH_TEMPLATE([HAVE_NCURSESW], [Define this if you have the ncursesw library]) -AC_OUTPUT(Makefile cmatrix.spec) +AC_CONFIG_FILES([Makefile cmatrix.spec]) +AC_OUTPUT From 701f6d4b7005d29fdf7bbcab14eca3f16be48744 Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Sat, 29 Jun 2024 14:26:14 +0200 Subject: [PATCH 6/7] Actually add termcap lib to link command --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 84bd8ee..62ca077 100644 --- a/configure.ac +++ b/configure.ac @@ -189,7 +189,7 @@ fi dnl Parse any configure options -LIBS="$LIBS $CURSES_LIB" +LIBS="$LIBS $CURSES_LIB $TERMCAP_LIB" AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging (def disabled)],) AM_CONDITIONAL([MATRIX_FONTS], [test x$enable_fonts = xtrue]) From 21989d6731b5099436a77084a654fd6015a3ef28 Mon Sep 17 00:00:00 2001 From: Martin Zinser Date: Sat, 29 Jun 2024 18:54:33 +0200 Subject: [PATCH 7/7] Tweak for recent auto tools version --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 62ca077..27b5550 100644 --- a/configure.ac +++ b/configure.ac @@ -21,11 +21,11 @@ AC_PROG_MAKE_SET dnl Checks for header files. -AC_HEADER_STDC +AC_PROG_EGREP AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h termios.h termio.h getopt.h) dnl Checks for library functions. -AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. +m4_warn([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([#include