diff options
author | max <max@FreeBSD.org> | 1997-01-30 07:12:59 +0000 |
---|---|---|
committer | max <max@FreeBSD.org> | 1997-01-30 07:12:59 +0000 |
commit | 0988434e5dc03c34f02e712f48e3cd9f66e8443e (patch) | |
tree | 69dd948eb7d0e51090079fb252afa1158177f968 /games/backgammon/teachgammon/teach.c | |
parent | 71baeec496d609059f7e6b14bd7cac2919adac98 (diff) | |
download | FreeBSD-src-0988434e5dc03c34f02e712f48e3cd9f66e8443e.zip FreeBSD-src-0988434e5dc03c34f02e712f48e3cd9f66e8443e.tar.gz |
Better handling of command-line argument:
1. Pass argc and argv to getarg and process them with getopt().
2. Instead of using an array to save arg characters, use array of
pointers and call backgammon/teachgammon with execv, instead of execl.
This should fix problems with calling teachgammon.
2.2 candidate.
Diffstat (limited to 'games/backgammon/teachgammon/teach.c')
-rw-r--r-- | games/backgammon/teachgammon/teach.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c index 9a97452..8d3ae25 100644 --- a/games/backgammon/teachgammon/teach.c +++ b/games/backgammon/teachgammon/teach.c @@ -41,6 +41,7 @@ static char copyright[] = static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #endif /* not lint */ +#include <string.h> #include "back.h" char *hello[]; @@ -78,6 +79,7 @@ char **argv; { register int i; + acnt = 1; signal (2,getout); if (gtty (0,&tty) == -1) /* get old tty mode */ errexit ("teachgammon(gtty)"); @@ -89,12 +91,7 @@ char **argv; #endif ospeed = tty.sg_ospeed; /* for termlib */ tflag = getcaps (getenv ("TERM")); -#ifdef V7 - while (*++argv != 0) -#else - while (*++argv != -1) -#endif - getarg (&argv); + getarg (argc, argv); if (tflag) { noech &= ~(CRMOD|XTABS); raw &= ~(CRMOD|XTABS); @@ -155,12 +152,18 @@ char **argv; } leave() { + register int i; if (tflag) clear(); else writec ('\n'); fixtty(old); - execl (EXEC,"backgammon",args,"n",0); + args[0] = strdup("backgammon"); + args[acnt++] = strdup("-n"); + args[acnt] = 0; + execv (EXEC,args); + for (i = 0; i < acnt; i++) + free(args[i]); writel ("Help! Backgammon program is missing\007!!\n"); exit (-1); } |