Module Name: src Committed By: rillig Date: Sat May 28 20:54:31 UTC 2022
Modified Files: src/games/gomoku: bdisp.c main.c Log Message: gomoku: remove redundant parentheses, braces, newlines, clean up get_key No functional change. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/games/gomoku/bdisp.c cvs rdiff -u -r1.62 -r1.63 src/games/gomoku/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/games/gomoku/bdisp.c diff -u src/games/gomoku/bdisp.c:1.49 src/games/gomoku/bdisp.c:1.50 --- src/games/gomoku/bdisp.c:1.49 Sat May 28 08:32:55 2022 +++ src/games/gomoku/bdisp.c Sat May 28 20:54:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bdisp.c,v 1.49 2022/05/28 08:32:55 rillig Exp $ */ +/* $NetBSD: bdisp.c,v 1.50 2022/05/28 20:54:31 rillig Exp $ */ /* * Copyright (c) 1994 @@ -34,7 +34,7 @@ #include <sys/cdefs.h> /* @(#)bdisp.c 8.2 (Berkeley) 5/3/95 */ -__RCSID("$NetBSD: bdisp.c,v 1.49 2022/05/28 08:32:55 rillig Exp $"); +__RCSID("$NetBSD: bdisp.c,v 1.50 2022/05/28 20:54:31 rillig Exp $"); #include <curses.h> #include <string.h> @@ -60,13 +60,13 @@ void cursinit(void) { - if (initscr() == NULL) { + if (initscr() == NULL) errx(EXIT_FAILURE, "Couldn't initialize screen"); - } - if ((LINES < SCRNH) || (COLS < SCRNW)) { + + if (LINES < SCRNH || COLS < SCRNW) errx(EXIT_FAILURE, "Screen too small (need %dx%d)", SCRNW, SCRNH); - } + keypad(stdscr, true); nonl(); noecho(); @@ -254,7 +254,6 @@ dislog(const char *str) /* * Display a question. */ - void ask(const char *str) { @@ -269,19 +268,15 @@ ask(const char *str) int get_key(const char *allowed) { - int ch; for (;;) { - ch = getch(); - if (allowed != NULL && - ch != '\0' && strchr(allowed, ch) == NULL) { - beep(); - refresh(); - continue; - } - break; + int ch = getch(); + if (allowed == NULL || ch == '\0' || + strchr(allowed, ch) != NULL) + return ch; + beep(); + refresh(); } - return ch; } bool Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.62 src/games/gomoku/main.c:1.63 --- src/games/gomoku/main.c:1.62 Sat May 28 17:51:27 2022 +++ src/games/gomoku/main.c Sat May 28 20:54:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.62 2022/05/28 17:51:27 rillig Exp $ */ +/* $NetBSD: main.c,v 1.63 2022/05/28 20:54:31 rillig Exp $ */ /* * Copyright (c) 1994 @@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\ The Regents of the University of California. All rights reserved."); /* @(#)main.c 8.4 (Berkeley) 5/4/95 */ -__RCSID("$NetBSD: main.c,v 1.62 2022/05/28 17:51:27 rillig Exp $"); +__RCSID("$NetBSD: main.c,v 1.63 2022/05/28 20:54:31 rillig Exp $"); #include <sys/stat.h> #include <curses.h> @@ -389,7 +389,7 @@ again: int ch = get_key("YyNnQqSs"); if (ch == 'Y' || ch == 'y') goto again; - if (ch == 'S') { + if (ch == 'S') { /* TODO: add 's' */ save_game(); goto replay; }