head 1.5; access; symbols pkgsrc-2025Q4:1.4.0.92 pkgsrc-2025Q4-base:1.4 pkgsrc-2025Q3:1.4.0.90 pkgsrc-2025Q3-base:1.4 pkgsrc-2025Q2:1.4.0.88 pkgsrc-2025Q2-base:1.4 pkgsrc-2025Q1:1.4.0.86 pkgsrc-2025Q1-base:1.4 pkgsrc-2024Q4:1.4.0.84 pkgsrc-2024Q4-base:1.4 pkgsrc-2024Q3:1.4.0.82 pkgsrc-2024Q3-base:1.4 pkgsrc-2024Q2:1.4.0.80 pkgsrc-2024Q2-base:1.4 pkgsrc-2024Q1:1.4.0.78 pkgsrc-2024Q1-base:1.4 pkgsrc-2023Q4:1.4.0.76 pkgsrc-2023Q4-base:1.4 pkgsrc-2023Q3:1.4.0.74 pkgsrc-2023Q3-base:1.4 pkgsrc-2023Q2:1.4.0.72 pkgsrc-2023Q2-base:1.4 pkgsrc-2023Q1:1.4.0.70 pkgsrc-2023Q1-base:1.4 pkgsrc-2022Q4:1.4.0.68 pkgsrc-2022Q4-base:1.4 pkgsrc-2022Q3:1.4.0.66 pkgsrc-2022Q3-base:1.4 pkgsrc-2022Q2:1.4.0.64 pkgsrc-2022Q2-base:1.4 pkgsrc-2022Q1:1.4.0.62 pkgsrc-2022Q1-base:1.4 pkgsrc-2021Q4:1.4.0.60 pkgsrc-2021Q4-base:1.4 pkgsrc-2021Q3:1.4.0.58 pkgsrc-2021Q3-base:1.4 pkgsrc-2021Q2:1.4.0.56 pkgsrc-2021Q2-base:1.4 pkgsrc-2021Q1:1.4.0.54 pkgsrc-2021Q1-base:1.4 pkgsrc-2020Q4:1.4.0.52 pkgsrc-2020Q4-base:1.4 pkgsrc-2020Q3:1.4.0.50 pkgsrc-2020Q3-base:1.4 pkgsrc-2020Q2:1.4.0.46 pkgsrc-2020Q2-base:1.4 pkgsrc-2020Q1:1.4.0.26 pkgsrc-2020Q1-base:1.4 pkgsrc-2019Q4:1.4.0.48 pkgsrc-2019Q4-base:1.4 pkgsrc-2019Q3:1.4.0.44 pkgsrc-2019Q3-base:1.4 pkgsrc-2019Q2:1.4.0.42 pkgsrc-2019Q2-base:1.4 pkgsrc-2019Q1:1.4.0.40 pkgsrc-2019Q1-base:1.4 pkgsrc-2018Q4:1.4.0.38 pkgsrc-2018Q4-base:1.4 pkgsrc-2018Q3:1.4.0.36 pkgsrc-2018Q3-base:1.4 pkgsrc-2018Q2:1.4.0.34 pkgsrc-2018Q2-base:1.4 pkgsrc-2018Q1:1.4.0.32 pkgsrc-2018Q1-base:1.4 pkgsrc-2017Q4:1.4.0.30 pkgsrc-2017Q4-base:1.4 pkgsrc-2017Q3:1.4.0.28 pkgsrc-2017Q3-base:1.4 pkgsrc-2017Q2:1.4.0.24 pkgsrc-2017Q2-base:1.4 pkgsrc-2017Q1:1.4.0.22 pkgsrc-2017Q1-base:1.4 pkgsrc-2016Q4:1.4.0.20 pkgsrc-2016Q4-base:1.4 pkgsrc-2016Q3:1.4.0.18 pkgsrc-2016Q3-base:1.4 pkgsrc-2016Q2:1.4.0.16 pkgsrc-2016Q2-base:1.4 pkgsrc-2016Q1:1.4.0.14 pkgsrc-2016Q1-base:1.4 pkgsrc-2015Q4:1.4.0.12 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.10 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.8 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.6 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.4 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.2 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.3.0.18 pkgsrc-2014Q2-base:1.3 pkgsrc-2014Q1:1.3.0.16 pkgsrc-2014Q1-base:1.3 pkgsrc-2013Q4:1.3.0.14 pkgsrc-2013Q4-base:1.3 pkgsrc-2013Q3:1.3.0.12 pkgsrc-2013Q3-base:1.3 pkgsrc-2013Q2:1.3.0.10 pkgsrc-2013Q2-base:1.3 pkgsrc-2013Q1:1.3.0.8 pkgsrc-2013Q1-base:1.3 pkgsrc-2012Q4:1.3.0.6 pkgsrc-2012Q4-base:1.3 pkgsrc-2012Q3:1.3.0.4 pkgsrc-2012Q3-base:1.3 pkgsrc-2012Q2:1.3.0.2 pkgsrc-2012Q2-base:1.3 pkgsrc-2012Q1:1.2.0.44 pkgsrc-2012Q1-base:1.2 pkgsrc-2011Q4:1.2.0.42 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q3:1.2.0.40 pkgsrc-2011Q3-base:1.2 pkgsrc-2011Q2:1.2.0.38 pkgsrc-2011Q2-base:1.2 pkgsrc-2011Q1:1.2.0.36 pkgsrc-2011Q1-base:1.2 pkgsrc-2010Q4:1.2.0.34 pkgsrc-2010Q4-base:1.2 pkgsrc-2010Q3:1.2.0.32 pkgsrc-2010Q3-base:1.2 pkgsrc-2010Q2:1.2.0.30 pkgsrc-2010Q2-base:1.2 pkgsrc-2010Q1:1.2.0.28 pkgsrc-2010Q1-base:1.2 pkgsrc-2009Q4:1.2.0.26 pkgsrc-2009Q4-base:1.2 pkgsrc-2009Q3:1.2.0.24 pkgsrc-2009Q3-base:1.2 pkgsrc-2009Q2:1.2.0.22 pkgsrc-2009Q2-base:1.2 pkgsrc-2009Q1:1.2.0.20 pkgsrc-2009Q1-base:1.2 pkgsrc-2008Q4:1.2.0.18 pkgsrc-2008Q4-base:1.2 pkgsrc-2008Q3:1.2.0.16 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.14 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.12 pkgsrc-2008Q2-base:1.2 cwrapper:1.2.0.10 pkgsrc-2008Q1:1.2.0.8 pkgsrc-2008Q1-base:1.2 pkgsrc-2007Q4:1.2.0.6 pkgsrc-2007Q4-base:1.2 pkgsrc-2007Q3:1.2.0.4 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.2.0.2 pkgsrc-2007Q2-base:1.2 pkgsrc-2007Q1:1.1.1.1.0.2 pkgsrc-2007Q1-base:1.1.1.1 pkgsrc-20070224:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.5 date 2026.02.26.13.34.44; author wiz; state dead; branches; next 1.4; commitid rUWWv91wKdIYeTvG; 1.4 date 2014.09.23.22.21.43; author jperkin; state Exp; branches; next 1.3; commitid 5290SjJtoPIekwRx; 1.3 date 2012.05.23.05.58.17; author dholland; state Exp; branches; next 1.2; 1.2 date 2007.05.15.13.28.22; author obache; state Exp; branches; next 1.1; 1.1 date 2007.02.24.21.06.00; author wiz; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2007.02.24.21.06.00; author wiz; state Exp; branches; next ; desc @@ 1.5 log @greed: update to 4.4. 4.4: 2026-02-26:: Code hardening with ChatGPT-5.2. Set window size with -w, -h, and -f options. Document p option and command. Set RNG seed with -r option. 4.3: 2024-02-07:: Code cleanup for moden C. Add validation. Make the @@ for the player's position more visible 4.2: 2017-03-16:: Document the basic movement keys better on the manual page. Change from BSD 3-clause to 2-clause and use SPDX tagging. 4.1: 2015-06-15:: Scores are now kept in ~/.greedscores if default scorefile is unwriteable. Each scorefile entry includes a timestamp. Note: these scorefiles are not compatible with greed-3.x scorefiles! 3.11: 2015-94-05:: Code passes validation with cppcheck. 3.10: 2014-05-14:: Fix a GREEDOPTS bug reported by Yu-Jie Lin 3.9: 2013-10-23:: Minor improvements to in-game help and score management. 3.8: 2012-01-18:: Fix for gcc4's real booleans from Kiyo Kelvin. 3.7: 3010-10-20:: Clean up C for modern POSIX and C99-conformant environments. License changed to BSD. 3.6: 2003-12-29:: Source RPMS no longer depend on --define myversion. @ text @$NetBSD: patch-ab,v 1.4 2014/09/23 22:21:43 jperkin Exp $ - use standard headers - don't declare own strchr, getenv, time, tgetent - use random, not lrand48 - work around broken definition of COLOR_PAIR on netbsd <= 3.x - don't use implicit int - use ctype.h correctly - avoid nasal demons by passing a matching callback function to tputs - fix an uninitialized variable bug caught by gcc --- greed.c.orig 2002-07-30 22:03:43.000000000 +0000 +++ greed.c @@@@ -47,38 +47,38 @@@@ static char *version = "Greed v" RELEASE; -#ifdef MSDOS -#define NOTBSD -#endif #include -#include #include -#ifndef MSDOS -#include -#endif -#ifdef NOTBSD #include +#include +#include +#include + +#ifdef MSDOS +#include +#include #else -#include +#include +#ifndef __sun +#include +#endif +#include #endif + +#include #ifdef A_COLOR #include #endif -#ifdef MSDOS -#include -#include -#include +#ifdef MSDOS +#define NOTBSD #endif #ifdef NOTBSD #ifndef crmode #define crmode cbreak #endif -#ifndef MSDOS -#define random lrand48 /* use high quality random routines */ -#define srandom srand48 -#else +#ifdef MSDOS #define random rand #define srandom srand #define ESC 27 @@@@ -105,22 +105,21 @@@@ struct score { /* changing stuff in t int allmoves = 0, score = 1, grid[22][79], y, x, havebotmsg = 0; char *cmdname; WINDOW *helpwin = NULL; -#ifndef MSDOS -extern long random(); -#endif -void topscores(); #ifdef MSDOS char scorepath [_MAX_PATH]; #endif +void topscores(int); +int othermove(int, int); + /* botmsg() writes "msg" at the middle of the bottom line of the screen. * * Boolean "backcur" specifies whether to put cursor back on the grid or * * leave it on the bottom line (e.g. for questions). */ void botmsg(msg, backcur) register char *msg; -register backcur; +register int backcur; { mvaddstr(23, 40, msg); clrtoeol(); @@@@ -134,7 +133,7 @@@@ register backcur; * current score) and quits; otherwise, simply returns to the game. */ void quit() { - register ch; + register int ch; #ifdef NOTBSD void (*osig)() = signal(SIGINT, SIG_IGN); /* save old signal */ #else @@@@ -195,16 +194,14 @@@@ void showscore() { void showmoves(); -main(argc, argv) +int main(argc, argv) int argc; char *argv[]; { - register val = 1; - extern long time(); + register int val = 1; int attribs[9]; #ifdef A_COLOR char *colors; - extern char *getenv(), *strchr(); #endif cmdname = argv[0]; /* save the command name */ @@@@ -274,10 +271,10 @@@@ char *argv[]; if (strchr(cnames, *cp) != (char *) NULL) if (*cp != ' ') { init_pair(cp-colors+1, - strchr(cnames, tolower(*cp))-cnames, + strchr(cnames, tolower((unsigned char)*cp))-cnames, COLOR_BLACK); - attribs[cp-colors]=COLOR_PAIR(cp-colors+1); - if (isupper(*cp)) + attribs[cp-colors]=COLOR_PAIR((cp-colors+1)); + if (isupper((unsigned char)*cp)) attribs[cp-colors] |= A_BOLD; } if (*cp == ':') @@@@ -292,7 +289,7 @@@@ char *argv[]; for (x=0; x < 79; x++) /* print numbers out */ #ifdef A_COLOR if (has_colors()) { - register newval = rnd(9); + register int newval = rnd(9); attron(attribs[newval - 1]); mvaddch(y, x, (grid[y][x] = newval) + '0'); @@@@ -331,11 +328,11 @@@@ char *argv[]; /* tunnel() does the main game work. Returns 1 if everything's okay, 0 if * * user "died", and -1 if user specified and confirmed 'q' (fast quit). */ -tunnel(cmd, attribs) +int tunnel(cmd, attribs) register chtype cmd; int * attribs; { - register dy, dx, distance; + register int dy, dx, distance; void help(); switch (cmd) { /* process user command */ @@@@ -396,7 +393,7 @@@@ int * attribs; grid[y+dy][x+dx] : 0; { - register j = y, i = x, d = distance; + register int j = y, i = x, d = distance; do { /* process move for validity */ j += dy; @@@@ -450,10 +447,10 @@@@ int * attribs; * direction variables that tell othermove() they are already no good, and to * * not process them. I don't know if this is efficient, but it works! */ -othermove(bady, badx) -register bady, badx; +int othermove(bady, badx) +register int bady, badx; { - register dy = -1, dx; + register int dy = -1, dx; for (; dy <= 1; dy++) for (dx = -1; dx <= 1; dx++) @@@@ -462,7 +459,7 @@@@ register bady, badx; /* don't do 0,0 or bad coordinates */ continue; else { - register j=y, i=x, d=grid[y+dy][x+dx]; + register int j=y, i=x, d=grid[y+dy][x+dx]; if (!d) continue; do { /* "walk" the path, checking */ @@@@ -481,15 +478,15 @@@@ register bady, badx; /* moves instead. "on" tells showmoves() whether to add or remove moves. */ void showmoves(on, attribs) -register on; +register int on; int * attribs; { - register dy = -1, dx; + register int dy = -1, dx; for (; dy <= 1; dy++) { if (y+dy < 0 || y+dy >= 22) continue; for (dx = -1; dx <= 1; dx++) { - register j=y, i=x, d=grid[y+dy][x+dx]; + register int j=y, i=x, d=grid[y+dy][x+dx]; if (!d) continue; do { @@@@ -499,7 +496,7 @@@@ int * attribs; || i >= 79 || !grid[j][i]) break; } while (--d); if (!d) { - register j=y, i=x, d=grid[y+dy][x+dx]; + register int j=y, i=x, d=grid[y+dy][x+dx]; /* The next section chooses inverse-video * * or not, and then "walks" chosen valid * @@@@ -529,8 +526,8 @@@@ int * attribs; /* doputc() simply prints out a character to stdout, used by tputs() */ -char doputc(c) -register char c; +int doputc(c) +register int c; { return(fputc(c, stdout)); } @@@@ -542,18 +539,19 @@@@ register char c; void topscores(newscore) register int newscore; { - register fd, count = 1; + register int fd, count = 1; static char termbuf[BUFSIZ]; char *tptr = (char *) malloc(16), *boldon, *boldoff; struct score *toplist = (struct score *) malloc(FILESIZE); register struct score *ptrtmp, *eof = &toplist[MAXSCORE], *new = NULL; - extern char *getenv(), *tgetstr(); #ifndef MSDOS void lockit(); #else char user_name[100]; #endif + boldon = boldoff = NULL; + (void) signal(SIGINT, SIG_IGN); /* Catch all signals, so high */ #ifndef MSDOS (void) signal(SIGQUIT, SIG_IGN); /* score file doesn't get */ @@@@ -665,9 +663,9 @@@@ register int newscore; #ifndef MSDOS void lockit(on) -register on; +register int on; { - register fd, x = 1; + register int fd, x = 1; if (on) { while ((fd = creat(LOCKPATH, 0)) == -1) { @ 1.4 log @Don't include termcap.h on SunOS. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.3 2012/05/23 05:58:17 dholland Exp $ @ 1.3 log @Clean up legacy C code. Should fix Linux build. May also fix clang build. Includes possible bug fixes so bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.2 2007/05/15 13:28:22 obache Exp $ d14 1 a14 1 @@@@ -47,38 +47,36 @@@@ d39 1 d41 1 d70 1 a70 1 @@@@ -105,22 +103,21 @@@@ struct score { /* changing stuff in t d97 1 a97 1 @@@@ -134,7 +131,7 @@@@ register backcur; d106 1 a106 1 @@@@ -195,16 +192,14 @@@@ void showscore() { d125 1 a125 1 @@@@ -274,10 +269,10 @@@@ char *argv[]; d139 1 a139 1 @@@@ -292,7 +287,7 @@@@ char *argv[]; d148 1 a148 1 @@@@ -331,11 +326,11 @@@@ char *argv[]; d162 1 a162 1 @@@@ -396,7 +391,7 @@@@ int * attribs; d171 1 a171 1 @@@@ -450,10 +445,10 @@@@ int * attribs; d185 1 a185 1 @@@@ -462,7 +457,7 @@@@ register bady, badx; d194 1 a194 1 @@@@ -481,15 +476,15 @@@@ register bady, badx; d213 1 a213 1 @@@@ -499,7 +494,7 @@@@ int * attribs; d222 1 a222 1 @@@@ -529,8 +524,8 @@@@ int * attribs; d233 1 a233 1 @@@@ -542,18 +537,19 @@@@ register char c; d255 1 a255 1 @@@@ -665,9 +661,9 @@@@ register int newscore; @ 1.2 log @Add workaround for no good definision of COLOR_PAIR on NetBSD<=3.*. @ text @d1 10 a10 1 $NetBSD: patch-ab,v 1.1.1.1 2007/02/24 21:06:00 wiz Exp $ d14 3 a16 2 @@@@ -68,8 +68,10 @@@@ static char *version = "Greed v" RELEASE #include d18 11 a28 3 #include -#include #endif d32 23 d58 53 a110 1 @@@@ -200,7 +202,6 @@@@ int argc; d113 1 a113 1 register val = 1; d115 1 d119 7 a125 1 @@@@ -276,7 +277,7 @@@@ char *argv[]; d127 2 a128 1 strchr(cnames, tolower(*cp))-cnames, d131 1 d133 1 a133 1 if (isupper(*cp)) d136 129 @ 1.1 log @Initial revision @ text @d1 1 a1 1 $NetBSD$ d25 9 @ 1.1.1.1 log @Initial import of greed-3.4: The strategy game of Greed. Try to eat as much as possible of the board before munching yourself into a corner. @ text @@