Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: apply some style fixes towards KNF
details: https://anonhg.NetBSD.org/src/rev/05fed99ed356
branches: trunk
changeset: 366142:05fed99ed356
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 15 22:00:11 2022 +0000
description:
gomoku: apply some style fixes towards KNF
There are still parts of the code that use an indentation level of 4
instead of the usual 8. Fixing that right now would introduce more
unnatural line breaks, so defer that until later.
No binary change.
diffstat:
games/gomoku/bdinit.c | 8 ++--
games/gomoku/bdisp.c | 28 ++++++++--------
games/gomoku/gomoku.h | 20 ++++++------
games/gomoku/main.c | 12 +++---
games/gomoku/makemove.c | 12 +++---
games/gomoku/pickmove.c | 77 ++++++++++++++++++++++++------------------------
games/gomoku/stoc.c | 18 +++++-----
7 files changed, 88 insertions(+), 87 deletions(-)
diffs (truncated from 509 to 300 lines):
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/bdinit.c
--- a/games/gomoku/bdinit.c Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/bdinit.c Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bdinit.c,v 1.9 2012/10/13 20:57:35 dholland Exp $ */
+/* $NetBSD: bdinit.c,v 1.10 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)bdinit.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: bdinit.c,v 1.9 2012/10/13 20:57:35 dholland Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.10 2022/05/15 22:00:11 rillig Exp $");
#endif
#endif /* not lint */
@@ -58,7 +58,7 @@
/* mark the borders as such */
sp = bp;
for (i = BSZ2; --i >= 0; sp++) {
- sp->s_occ = BORDER; /* top border */
+ sp->s_occ = BORDER; /* top border */
sp->s_flags = BFLAGALL;
}
@@ -73,7 +73,7 @@
if (j < 5) {
/* directions 1, 2, 3 are blocked */
sp->s_flags |= (BFLAG << 1) | (BFLAG << 2) |
- (BFLAG << 3);
+ (BFLAG << 3);
sp->s_fval[BLACK][1].s = MAXCOMBO;
sp->s_fval[BLACK][2].s = MAXCOMBO;
sp->s_fval[BLACK][3].s = MAXCOMBO;
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/bdisp.c
--- a/games/gomoku/bdisp.c Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/bdisp.c Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bdisp.c,v 1.19 2022/05/14 16:21:04 rillig Exp $ */
+/* $NetBSD: bdisp.c,v 1.20 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)bdisp.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: bdisp.c,v 1.19 2022/05/14 16:21:04 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.20 2022/05/15 22:00:11 rillig Exp $");
#endif
#endif /* not lint */
@@ -133,11 +133,11 @@
int i, j;
move(21, 0);
- printw(" ");
+ printw(" ");
i = strlen(plyr[BLACK]);
j = strlen(plyr[WHITE]);
if (i + j <= 20) {
- move(21, 10 - (i+j)/2);
+ move(21, 10 - (i + j) / 2);
printw("BLACK/%s (*) vs. WHITE/%s (O)",
plyr[BLACK], plyr[WHITE]);
} else {
@@ -317,7 +317,7 @@
}
}
*cp = '\0';
- return(c != EOF);
+ return (c != EOF);
}
/*
@@ -336,8 +336,8 @@
nx = curx;
ny = cury;
for (;;) {
- mvprintw(BSZ3, (BSZ -6)/2, "(%c %d) ",
- 'A'+ ((curx > 7) ? (curx+1) : curx), cury + 1);
+ mvprintw(BSZ3, (BSZ - 6) / 2, "(%c %d) ",
+ 'A' + ((curx > 7) ? (curx + 1) : curx), cury + 1);
BGOTO(cury, curx);
ch = getch();
@@ -407,7 +407,7 @@
ny = cury;
break;
case 'Y':
- nx = BSZ + curx - 5;
+ nx = BSZ + curx - 5;
ny = cury + 5;
break;
case 'B':
@@ -453,11 +453,11 @@
return SAVE;
case ' ':
case '\r':
- (void) mvaddstr(BSZ3, (BSZ -6)/2, " ");
- return PT(curx+1,cury+1);
- }
+ (void)mvaddstr(BSZ3, (BSZ - 6) / 2, " ");
+ return PT(curx + 1, cury + 1);
+ }
- curx = nx % BSZ;
- cury = ny % BSZ;
- }
+ curx = nx % BSZ;
+ cury = ny % BSZ;
+ }
}
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/gomoku.h Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gomoku.h,v 1.21 2022/05/14 16:21:04 rillig Exp $ */
+/* $NetBSD: gomoku.h,v 1.22 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -40,16 +40,16 @@
/* board dimensions */
#define BSZ 19
-#define BSZ1 (BSZ+1)
-#define BSZ2 (BSZ+2)
-#define BSZ3 (BSZ+3)
-#define BSZ4 (BSZ+4)
-#define BAREA (BSZ2*BSZ1+1)
+#define BSZ1 (BSZ + 1)
+#define BSZ2 (BSZ + 2)
+#define BSZ3 (BSZ + 3)
+#define BSZ4 (BSZ + 4)
+#define BAREA (BSZ2 * BSZ1 + 1)
-#define TRANSCRIPT_COL 46 /* necessarily == 2*BSZ4 */
+#define TRANSCRIPT_COL (2 * BSZ4)
/* interactive curses stuff */
-#define BGOTO(y,x) move(BSZ - (y), 2 * (x) + 3)
+#define BGOTO(y, x) move(BSZ - (y), 2 * (x) + 3)
/* frame dimensions (based on 5 in a row) */
#define FSZ1 BSZ
@@ -95,7 +95,7 @@
#define S 18
#define T 19
-#define PT(x,y) ((x) + BSZ1 * (y))
+#define PT(x, y) ((x) + BSZ1 * (y))
/*
* A 'frame' is a group of five or six contiguous board locations.
@@ -147,7 +147,7 @@
#define MAXB 2
#define MAXCOMBO 0x600
-union comboval {
+union comboval {
struct {
#if BYTE_ORDER == BIG_ENDIAN
u_char a; /* # moves to complete force */
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/main.c
--- a/games/gomoku/main.c Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/main.c Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.28 2021/05/02 12:50:44 rillig Exp $ */
+/* $NetBSD: main.c,v 1.29 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: main.c,v 1.28 2021/05/02 12:50:44 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.29 2022/05/15 22:00:11 rillig Exp $");
#endif
#endif /* not lint */
@@ -79,7 +79,7 @@
short intersect[FAREA * FAREA]; /* frame [a][b] intersection */
int movelog[BSZ * BSZ]; /* log of all the moves */
int movenum; /* current move number */
-const char *plyr[2]; /* who's who */
+const char *plyr[2]; /* who's who */
static int readinput(FILE *);
static void misclog(const char *, ...) __printflike(1, 2);
@@ -263,7 +263,7 @@
}
for (i = 0; i < movenum - 1; i++)
fprintf(fp, "%s\n",
- stoc(movelog[i]));
+ stoc(movelog[i]));
fclose(fp);
goto getinput;
}
@@ -336,7 +336,7 @@
}
for (i = 0; i < movenum - 1; i++)
fprintf(fp, "%s\n",
- stoc(movelog[i]));
+ stoc(movelog[i]));
fclose(fp);
goto replay;
}
@@ -344,7 +344,7 @@
}
quit();
/* NOTREACHED */
- return(0);
+ return (0);
}
static int
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/makemove.c
--- a/games/gomoku/makemove.c Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/makemove.c Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $ */
+/* $NetBSD: makemove.c,v 1.12 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)makemove.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $");
+__RCSID("$NetBSD: makemove.c,v 1.12 2022/05/15 22:00:11 rillig Exp $");
#endif
#endif /* not lint */
@@ -73,18 +73,18 @@
/* check for end of game */
if (mv == RESIGN)
- return(RESIGN);
+ return (RESIGN);
/* check for illegal move */
sp = &board[mv];
if (sp->s_occ != EMPTY)
- return(ILLEGAL);
+ return (ILLEGAL);
/* make move */
sp->s_occ = us;
movelog[movenum - 1] = mv;
if (++movenum == BSZ * BSZ)
- return(TIE);
+ return (TIE);
/* compute new frame values */
sp->s_wval = 0;
@@ -211,7 +211,7 @@
update_overlap(osp);
- return(MOVEOK);
+ return (MOVEOK);
}
/*
diff -r 32d5380b0a42 -r 05fed99ed356 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Sun May 15 21:41:56 2022 +0000
+++ b/games/gomoku/pickmove.c Sun May 15 22:00:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.23 2022/05/14 16:21:04 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.24 2022/05/15 22:00:11 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: pickmove.c,v 1.23 2022/05/14 16:21:04 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.24 2022/05/15 22:00:11 rillig Exp $");
#endif
#endif /* not lint */
@@ -88,10 +88,10 @@
/* first move is easy */
if (movenum == 1)
- return (PT(K,10));
+ return (PT(K, 10));
/* initialize all the board values */
- for (pos = PT(T,20); pos-- > PT(A,1); ) {
+ for (pos = PT(T, 20); pos-- > PT(A, 1); ) {
sp = &board[pos];
sp->s_combo[BLACK].s = MAXCOMBO + 1;
sp->s_combo[WHITE].s = MAXCOMBO + 1;
Home |
Main Index |
Thread Index |
Old Index