78 lines
2.0 KiB
Plaintext

$OpenBSD: patch-c4_c,v 1.4 2013/08/15 14:58:45 naddy Exp $
--- c4.c.orig Thu Aug 15 16:02:21 2013
+++ c4.c Thu Aug 15 16:02:21 2013
@@ -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, sizeof line, stdin)){
plot_finish();
fprintf(stderr, "Could not read input line.\n");
goodbye();
@@ -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, sizeof line, stdin)){
fprintf(stderr, "Could not read input line\n");
goodbye();
}
@@ -813,34 +815,5 @@ debug_off()
save = d;
d = NULL;
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 );
}