On Mon, May 27, 2024 at 09:21:34PM -0500, Don Wilburn wrote: > Dear OpenBSD, > > I recently upgraded from version 7.4 to 7.5. This broke the old cribbage > game. This is included with OpenBSD, if you choose to install the games. > > I'm not a programmer, but I promise you this happened because ncurses was > updated from version 5.7 to 6.4 > > The problem: > > Normally the game gives prompts for play options and cards. It's supposed > to leave the prompt after the response, then advance to a new line. This > gives a brief history of selections > > Now, starting with the third prompt (cut the cards), the prompts disappear > when a response key is pressed. This ruins the game. The effect is obvious, > even if you don't know how to play cribbage. > > It would be even more obvious if you have an older system to compare with a > current v7.5 system. > > This happened to linux bsd-games many years ago. A search will indicate > that I filed this same bug with Gentoo linux over 9 years ago. Linux > classic bsd-games has been unmaintained since before that time. This is > where I observed that the bug happened with a ncurses update. Nobody > pursued the solution. > > I don't have the skills to butcher the game code to work with with the > update of ncurses. Likewise, I don't know how to use a debugger or write a > sample program to replicate the effect. I can't demonstrate WHY ncurses is > the problem. Maybe it's the C compiler's fault? > > I still play this obsolete command line game. It's nostalgia, I guess. I > know OpenBSD developers have really important things to maintain. If > someone could spare some time for this little bug, I'd be happy. Maybe it > could be delegated to a student? > > Thanks for reading, DW >
One remains a student forever. Try this, it does not try to cut corners with switching windows. -Otto Index: io.c =================================================================== RCS file: /home/cvs/src/games/cribbage/io.c,v diff -u -p -r1.22 io.c --- io.c 10 Jan 2016 13:35:09 -0000 1.22 +++ io.c 29 May 2024 06:00:03 -0000 @@ -505,14 +505,11 @@ get_line(void) { size_t pos; int c, oy, ox; - WINDOW *oscr; - oscr = stdscr; - stdscr = Msgwin; - getyx(stdscr, oy, ox); - refresh(); + getyx(Msgwin, oy, ox); + wrefresh(Msgwin); /* loop reading in the string, and put it in a temporary buffer */ - for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) { + for (pos = 0; (c = readchar()) != '\n'; wclrtoeol(Msgwin), wrefresh(Msgwin)) { if (c == -1) continue; if (c == ' ' && (pos == 0 || linebuf[pos - 1] == ' ')) @@ -522,13 +519,13 @@ get_line(void) int i; pos--; for (i = strlen(unctrl(linebuf[pos])); i; i--) - addch('\b'); + waddch(Msgwin, '\b'); } continue; } if (c == killchar()) { pos = 0; - move(oy, ox); + wmove(Msgwin, oy, ox); continue; } if (pos >= LINESIZE - 1 || !(isalnum(c) || c == ' ')) { @@ -538,12 +535,11 @@ get_line(void) if (islower(c)) c = toupper(c); linebuf[pos++] = c; - addstr(unctrl(c)); + waddstr(Msgwin, unctrl(c)); Mpos++; } while (pos < sizeof(linebuf)) linebuf[pos++] = '\0'; - stdscr = oscr; return (linebuf); }