Remove a bogus handrolled setproctitle() from ye olden days, fixes

crashes on 64-bit archs.  Add missing #includes.

Move high-score file to /var/games.

Better pkg-descr.

PR:		149406
This commit is contained in:
Christian Weisgerber 2010-08-07 19:24:37 +00:00
parent fbe2576266
commit 91aff1eab0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=258894
6 changed files with 126 additions and 115 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= connect4
PORTVERSION= 3.2
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= games
MASTER_SITES= ${MASTER_SITE_COMP_SOURCES}
MASTER_SITE_SUBDIR= games/volume6
@ -26,10 +26,14 @@ EXTRACT_AFTER_ARGS= | gunshar
NO_WRKSUBDIR= yes
MAN6= connect4.6
SCOREFILE= /var/games/connect4.scores
PLIST_SUB= SCOREFILE=${SCOREFILE}
do-install:
${INSTALL_PROGRAM} -m 2755 -o root -g games ${WRKSRC}/c4 ${PREFIX}/bin/connect4
@${MKDIR} ${PREFIX}/share/connect4
${INSTALL_DATA} -m 664 -o root -g games /dev/null ${PREFIX}/share/connect4/scores
${INSTALL_PROGRAM} -m 2755 -o root -g games ${WRKSRC}/c4 \
${PREFIX}/bin/connect4
test -f ${SCOREFILE} || \
${INSTALL_DATA} -m 664 -o root -g games /dev/null ${SCOREFILE}
${INSTALL_MAN} ${FILESDIR}/connect4.6 ${MANPREFIX}/man/man6
.include <bsd.port.mk>

View file

@ -1,30 +1,17 @@
*** Makefile.orig Fri Nov 3 02:23:51 2000
--- Makefile Fri Nov 3 02:24:41 2000
***************
*** 1,10 ****
# Makefile for c4
! CFLAGS = -g #-DSCOREFILE=\"/usr/games/lib/c4.scores\"
CURSES = -lcurses -ltermcap
c4 : c4.o screen.o c4.h tables.h types.h
! cc $(CFLAGS) -o c4 c4.o screen.o $(CURSES)
screen.o : c4.h
--- 1,15 ----
# Makefile for c4
+ # Patched for FreeBSD 2.1.5R by
+ # Joel Sutton <suttonj@interconnect.com.au>
+ # 15th April, 1997
! CFLAGS += -DSCOREFILE=\"$(PREFIX)/share/connect4/scores\"
CURSES = -lcurses -ltermcap
+ all: c4
+
c4 : c4.o screen.o c4.h tables.h types.h
! $(CC) $(CFLAGS) -o c4 c4.o screen.o $(CURSES)
screen.o : c4.h
--- Makefile.orig 2010-08-07 20:02:05.000000000 +0200
+++ Makefile 2010-08-07 20:23:05.000000000 +0200
@@ -1,10 +1,12 @@
# Makefile for c4
-CFLAGS = -g #-DSCOREFILE=\"/usr/games/lib/c4.scores\"
+CFLAGS += -DSCOREFILE=\"/var/games/connect4.scores\"
CURSES = -lcurses -ltermcap
+all: c4
+
c4 : c4.o screen.o c4.h tables.h types.h
- cc $(CFLAGS) -o c4 c4.o screen.o $(CURSES)
+ $(CC) $(CFLAGS) -o c4 c4.o screen.o $(CURSES)
screen.o : c4.h

View file

@ -1,49 +1,83 @@
*** c4.c.orig Tue Apr 15 22:06:03 1997
--- c4.c Tue Apr 15 22:16:29 1997
***************
*** 11,16 ****
--- 11,18 ----
* BITNET: tcjones@WATER.bitnet
* Canadian domain: tcjones@dragon.uwaterloo.ca
*
+ * Patched by Joel Sutton, 15th April 1997
+ * Changed gets calls to fgets. Changed inital prompt slightly.
*/
#include <stdio.h>
***************
*** 219,225 ****
register char *cp;
printf("Would you like to go first? (yes/no) -> ");
! if (!gets(line)){
plot_finish();
fprintf(stderr, "Could not read input line.\n");
goodbye();
--- 221,227 ----
register char *cp;
printf("Would you like to go first? (yes/no) -> ");
! if (!fgets(line,256,stdin)){
plot_finish();
fprintf(stderr, "Could not read input line.\n");
goodbye();
***************
*** 620,627 ****
}
}
! printf("Do you need help (n/y)? -> ");
! if (!gets(line)){
fprintf(stderr, "Could not read input line\n");
goodbye();
}
--- 622,629 ----
}
}
! printf("Do you need help (y/n)? -> ");
! if (!fgets(line,256,stdin)){
fprintf(stderr, "Could not read input line\n");
goodbye();
}
--- c4.c.orig 2010-08-07 20:02:05.000000000 +0200
+++ c4.c 2010-08-07 20:23:15.000000000 +0200
@@ -14,7 +14,10 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
+#include <unistd.h>
#include <ctype.h>
#include <pwd.h>
#include <sys/time.h>
@@ -55,7 +58,6 @@ char **envp;
register int winner = DRAW;
int temp;
- envmesg(envp, "Connect Four");
do_args(argc, argv);
open_scorefile("a");
ask_help();
@@ -219,7 +221,7 @@ ask_turn()
register char *cp;
printf("Would you like to go first? (yes/no) -> ");
- if (!gets(line)){
+ if (!fgets(line,256,stdin)){
plot_finish();
fprintf(stderr, "Could not read input line.\n");
goodbye();
@@ -586,7 +588,7 @@ think_of_fucking_clever_move()
}
}
DP(d, "The best column is %d\n", best_col);
- DP(d, "Returning.\n\n\n", best_col);
+ DP(d, "Returning.\n\n\n");
if (best_col == -1){
print_game_record(CONFUSED);
@@ -620,8 +622,8 @@ ask_help()
}
}
- printf("Do you need help (n/y)? -> ");
- if (!gets(line)){
+ printf("Do you need help (y/n)? -> ");
+ if (!fgets(line,256,stdin)){
fprintf(stderr, "Could not read input line\n");
goodbye();
}
@@ -815,32 +817,3 @@ debug_off()
accept_move(turn);
}
-/*
- * Modify the environment to put message in the right place for
- * the w and ps commands to find. Code stolen from MFCF lock
- * program, originally by Ian!
- *
- */
-
-void
-envmesg(environ, message)
-char **environ;
-char *message;
-{
- /*
- * Note that this clobbers the environment, so we have to
- * do it last, after all the getenv and termcap calls.
- */
-
- char *last, *address;
- while( environ[1] != 0 ) ++environ;
- last = environ[0] + strlen(environ[0]);/* address of '\0' */
- last = (char *)((int)last&(~03));/* word boundary */
- *(int *)last = 0; /* clean out last word */
- address = last +3 -strlen(message);
- address = (char *)((int)address&(~03));/* word boundary */
- *(int *)(address-4) = 0; /* clean out word below */
- *(int *)(address-8) = 0; /* clean out word below */
- strcpy( address, message );
-}
-

View file

@ -1,23 +1,10 @@
*** screen.c.orig Tue Apr 15 22:06:03 1997
--- screen.c Tue Apr 15 22:16:30 1997
***************
*** 1,3 ****
--- 1,8 ----
+ /*
+ * Patched by Joel Sutton, 15th April 1997
+ * Added endwin to tidy things up as per usenet posted patch.
+ */
+
#include <stdio.h>
#include <curses.h>
#include "c4.h"
***************
*** 116,121 ****
--- 121,127 ----
refresh();
nocrmode();
echo();
+ endwin();
}
--- screen.c.orig 2010-08-07 20:02:05.000000000 +0200
+++ screen.c 2010-08-07 20:23:29.000000000 +0200
@@ -116,6 +116,7 @@ plot_finish()
refresh();
nocrmode();
echo();
+ endwin();
}

View file

@ -1,7 +1,5 @@
Please refer to the man page for instructions and further information.
This version contains my patches and man page.
Share and enjoy,
Joel...
The real-life version of connect4 is basically an upright hollow board
with several vertical columns and windows. Tokens are placed into the
columns alternately by each player until one of the players has four
tokens in a row. These four tokens must be adjacent to each other but
the series of four can be in any direction.

View file

@ -1,3 +1,4 @@
@comment $FreeBSD$
bin/connect4
share/connect4/scores
@dirrm share/connect4
@exec test -f %%SCOREFILE%% || install -o root -g games -m 664 /dev/null %%SCOREFILE%%
@unexec test -s %%SCOREFILE%% || rm -f %%SCOREFILE%%