Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/gomoku gomoku: remove redundant parentheses, braces, n...



details:   https://anonhg.NetBSD.org/src/rev/cb5d93879c05
branches:  trunk
changeset: 366475:cb5d93879c05
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 28 20:54:31 2022 +0000

description:
gomoku: remove redundant parentheses, braces, newlines, clean up get_key

No functional change.

diffstat:

 games/gomoku/bdisp.c |  29 ++++++++++++-----------------
 games/gomoku/main.c  |   6 +++---
 2 files changed, 15 insertions(+), 20 deletions(-)

diffs (97 lines):

diff -r d59f94d9f963 -r cb5d93879c05 games/gomoku/bdisp.c
--- a/games/gomoku/bdisp.c      Sat May 28 19:47:24 2022 +0000
+++ b/games/gomoku/bdisp.c      Sat May 28 20:54:31 2022 +0000
@@ -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 @@
 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 @@
 /*
  * Display a question.
  */
-
 void
 ask(const char *str)
 {
@@ -269,19 +268,15 @@
 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
diff -r d59f94d9f963 -r cb5d93879c05 games/gomoku/main.c
--- a/games/gomoku/main.c       Sat May 28 19:47:24 2022 +0000
+++ b/games/gomoku/main.c       Sat May 28 20:54:31 2022 +0000
@@ -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 @@
                        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;
                        }



Home | Main Index | Thread Index | Old Index