games/atc WARNS6 [PATCH]

Peter Avalos pavalos at theshell.com
Fri Aug 4 10:08:45 PDT 2006


I just realized that all the WARNS6 stuff on the wiki is no longer there,
so I'd like to submit what I have still laying around in my tree.  Here's
one for games/atc.  Thanks to swildner for the lex/yacc hints!

http://www.theshell.com/~pavalos/wip/atc.diff
Index: games/atc/Makefile
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- games/atc/Makefile	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/Makefile	4 Aug 2006 15:59:58 -0000
@@ -12,6 +12,7 @@
 FILES=  Game_List Killer crossover default easy game_2
 FILESDIR=	${SHAREDIR}/games/atc
 HIDEGAME=hidegame
+WARNS?=	6
 
 .PATH: ${.CURDIR}/games
 
Index: games/atc/extern.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/extern.c,v
retrieving revision 1.2
diff -u -r1.2 extern.c
--- games/atc/extern.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/extern.c	4 Aug 2006 15:59:58 -0000
@@ -53,7 +53,7 @@
 
 int		clck, safe_planes, start_time, test_mode;
 
-const char	*file;
+const char	*filename;
 
 FILE		*filein, *fileout;
 
Index: games/atc/extern.h
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/extern.h,v
retrieving revision 1.1
diff -u -r1.1 extern.h
--- games/atc/extern.h	17 Jun 2003 02:49:20 -0000	1.1
+++ games/atc/extern.h	4 Aug 2006 16:33:47 -0000
@@ -46,7 +46,7 @@
  */
 
 extern char		GAMES[];
-extern const char	*file;
+extern const char	*filename;
 
 extern int		clck, safe_planes, start_time, test_mode;
 
@@ -60,4 +60,39 @@
 
 extern DISPLACEMENT	displacement[MAXDIR];
 
-extern PLANE		*findplane(), *newplane();
+extern int	yyparse(void);
+
+/* graphics.c */
+extern void	done_screen(void);
+extern void	draw_all(void);
+extern void	erase_all(void);
+extern int	getAChar(void);
+extern void	init_gr(void);
+extern void	ioaddstr(int, const char *);
+extern void	ioclrtobot(void);
+extern void	ioclrtoeol(int);
+extern void	ioerror(int, int, const char *);
+extern void	iomove(int);
+extern void	loser(const PLANE *, const char *);
+extern void	planewin(void);
+extern void	redraw(void);
+extern void	setup_screen(const C_SCREEN *);
+extern void	quit(void);
+/* input.c */
+extern int	dir_no(char);
+extern int	getcommand(void);
+/* list.c */
+extern void	append(LIST *, PLANE *);
+extern void	delete(LIST *, PLANE *);
+extern PLANE	*newplane(void);
+/* log.c */
+extern int	log_score(int);
+extern void	open_score_file(void);
+/* update.c */
+extern int	addplane(void);
+extern const char	*command(const PLANE *);
+extern PLANE	*findplane(int);
+extern char	name(const PLANE *);
+extern char	number(char);
+extern void	update(void);
+
Index: games/atc/grammar.y
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/grammar.y,v
retrieving revision 1.2
diff -u -r1.2 grammar.y
--- games/atc/grammar.y	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/grammar.y	4 Aug 2006 16:27:22 -0000
@@ -63,6 +63,16 @@
 %{
 #include "include.h"
 
+extern int	yyerror(const char *);
+extern int	yylex(void);
+
+void	check_edge(int, int);
+void	check_point(int, int);
+void	check_linepoint(int, int);
+void	check_line(int, int, int, int);
+void	check_edir(int, int, int);
+int	checkdefs(void);
+
 int	errors = 0;
 int	line = 1;
 %}
@@ -244,7 +254,6 @@
 		sp->airport[sp->num_airports].y = $3;
 		sp->airport[sp->num_airports].dir = dir;
 		check_point($2, $3);
-		check_adir($2, $3, dir);
 		sp->num_airports++;
 		}
 	;
@@ -280,14 +289,16 @@
 	;
 %%
 
-check_edge(x, y)
+void
+check_edge(int x, int y)
 {
 	if (!(x == 0) && !(x == sp->width - 1) && 
 	    !(y == 0) && !(y == sp->height - 1))
 		yyerror("edge value not on edge.");
 }
 
-check_point(x, y)
+void
+check_point(int x, int y)
 {
 	if (x < 1 || x >= sp->width - 1)
 		yyerror("X value out of range.");
@@ -295,7 +306,8 @@
 		yyerror("Y value out of range.");
 }
 
-check_linepoint(x, y)
+void
+check_linepoint(int x, int y)
 {
 	if (x < 0 || x >= sp->width)
 		yyerror("X value out of range.");
@@ -303,30 +315,32 @@
 		yyerror("Y value out of range.");
 }
 
-check_line(x1, y1, x2, y2)
+void
+check_line(int x1, int y_1, int x2, int y2)
 {
 	int	d1, d2;
 
-	check_linepoint(x1, y1);
+	check_linepoint(x1, y_1);
 	check_linepoint(x2, y2);
 
 	d1 = ABS(x2 - x1);
-	d2 = ABS(y2 - y1);
+	d2 = ABS(y2 - y_1);
 
 	if (!(d1 == d2) && !(d1 == 0) && !(d2 == 0))
 		yyerror("Bad line endpoints.");
 }
 
-yyerror(s)
-	char *s;
+int
+yyerror(const char *s)
 {
-	fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s);
+	fprintf(stderr, "\"%s\": line %d: %s\n", filename, line, s);
 	errors++;
 
 	return (errors);
 }
 
-check_edir(x, y, dir)
+void
+check_edir(int x, int y, int dir)
 {
 	int	bad = 0;
 
@@ -357,11 +371,8 @@
 		yyerror("Bad direction for entrance at exit.");
 }
 
-check_adir(x, y, dir)
-{
-}
-
-checkdefs()
+int
+checkdefs(void)
 {
 	int	err = 0;
 
Index: games/atc/graphics.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/graphics.c,v
retrieving revision 1.2
diff -u -r1.2 graphics.c
--- games/atc/graphics.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/graphics.c	4 Aug 2006 15:59:58 -0000
@@ -47,7 +47,6 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <string.h>
 #include "include.h"
 #ifdef SYSV
 #include <errno.h>
@@ -63,7 +62,11 @@
 
 WINDOW	*radar, *cleanradar, *credit, *input, *planes;
 
-getAChar()
+static void	draw_line(WINDOW *, int, int, int, int, const char *);
+
+
+int
+getAChar(void)
 {
 #ifdef BSD
 	return (getchar());
@@ -76,7 +79,8 @@
 #endif
 }
 
-erase_all()
+void
+erase_all(void)
 {
 	PLANE	*pp;
 
@@ -90,7 +94,8 @@
 	}
 }
 
-draw_all()
+void
+draw_all(void)
 {
 	PLANE	*pp;
 
@@ -109,7 +114,8 @@
 	fflush(stdout);
 }
 
-init_gr()
+void
+init_gr(void)
 {
 	static char	buffer[BUFSIZ];
 
@@ -121,8 +127,8 @@
 	planes = newwin(LINES - INPUT_LINES, PLANE_COLS, 0, COLS - PLANE_COLS);
 }
 
-setup_screen(scp)
-	const C_SCREEN	*scp;
+void
+setup_screen(const C_SCREEN *scp)
 {
 	int		i, j;
 	char		str[3];
@@ -213,10 +219,8 @@
 	fflush(stdout);
 }
 
-draw_line(w, x, y, lx, ly, s)
-	WINDOW		*w;
-	int		x, y, lx, ly;
-	const char	*s;
+static void
+draw_line(WINDOW *w, int x, int y, int lx, int ly, const char *s)
 {
 	int	dx, dy;
 
@@ -232,7 +236,8 @@
 	}
 }
 
-ioclrtoeol(pos)
+void
+ioclrtoeol(int pos)
 {
 	wmove(input, 0, pos);
 	wclrtoeol(input);
@@ -240,15 +245,16 @@
 	fflush(stdout);
 }
 
-iomove(pos)
+void
+iomove(int pos)
 {
 	wmove(input, 0, pos);
 	wrefresh(input);
 	fflush(stdout);
 }
 
-ioaddstr(pos, str)
-	const char	*str;
+void
+ioaddstr(int pos, const char *str)
 {
 	wmove(input, 0, pos);
 	waddstr(input, str);
@@ -256,15 +262,16 @@
 	fflush(stdout);
 }
 
-ioclrtobot()
+void
+ioclrtobot(void)
 {
 	wclrtobot(input);
 	wrefresh(input);
 	fflush(stdout);
 }
 
-ioerror(pos, len, str)
-	const char	*str;
+void
+ioerror(int pos, int len, const char *str)
 {
 	int	i;
 
@@ -277,7 +284,8 @@
 	fflush(stdout);
 }
 
-quit()
+void
+quit(void)
 {
 	int			c, y, x;
 #ifdef BSD
@@ -317,10 +325,10 @@
 	return;
 }
 
-planewin()
+void
+planewin(void)
 {
 	PLANE	*pp;
-	char	*command();
 	int	warning = 0;
 
 #ifdef BSD
@@ -360,9 +368,8 @@
 	fflush(stdout);
 }
 
-loser(p, s)
-	const PLANE	*p;
-	const char	*s;
+void
+loser(const PLANE *p, const char *s)
 {
 	int			c;
 #ifdef BSD
@@ -394,7 +401,8 @@
 	exit(0);
 }
 
-redraw()
+void
+redraw(void)
 {
 	clear();
 	refresh();
@@ -412,8 +420,8 @@
 	fflush(stdout);
 }
 
-
-done_screen()
+void
+done_screen(void)
 {
 	clear();
 	refresh();
Index: games/atc/include.h
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/include.h,v
retrieving revision 1.1
diff -u -r1.1 include.h
--- games/atc/include.h	17 Jun 2003 02:49:20 -0000	1.1
+++ games/atc/include.h	4 Aug 2006 15:59:58 -0000
@@ -56,10 +56,11 @@
 #include <sys/file.h>
 #endif
 
-#ifdef SYSV
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
+#include <stdlib.h>
+#ifdef SYSV
 #include <sys/utsname.h>
 #endif
 
Index: games/atc/input.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/input.c,v
retrieving revision 1.2
diff -u -r1.2 input.c
--- games/atc/input.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/input.c	4 Aug 2006 15:59:58 -0000
@@ -47,8 +47,8 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <stdlib.h>
-#include <string.h>
+#include <sys/wait.h>
+
 #include "include.h"
 #include "pathnames.h"
 
@@ -69,7 +69,7 @@
 	int		token;
 	int		to_state;
 	const char	*str;
-	const char	*(*func)();
+	const char	*(*func)(int);
 } RULE;
 
 typedef struct {
@@ -95,10 +95,32 @@
 
 #define NUMSTATES	NUMELS(st)
 
-const char	*setplane(), *circle(), *left(), *right(), *Left(), *Right(),
-	*beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(),
-	*benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(),
-	*airport(), *turn(), *ignore();
+static int	pop(void);
+static void	rezero(void);
+static void	push(int, int);
+static void	noise(void);
+static int	gettoken(void);
+static const char	*setplane(int);
+static const char	*turn(int);
+static const char	*circle(int);
+static const char	*left(int);
+static const char	*right(int);
+static const char	*Left(int);
+static const char	*Right(int);
+static const char	*delayb(int);
+static const char	*beacon(int);
+static const char	*ex_it(int);
+static const char	*airport(int);
+static const char	*climb(int);
+static const char	*descend(int);
+static const char	*setalt(int);
+static const char	*setrelalt(int);
+static const char	*benum(int);
+static const char	*to_dir(int);
+static const char	*rel_dir(int);
+static const char	*mark(int);
+static const char	*unmark(int);
+static const char	*ignore(int);
 
 RULE	state0[] = {	{ ALPHATOKEN,	1,	"%c:",		setplane},
 			{ RETTOKEN,	-1,	"",		NULL	},
@@ -192,7 +214,9 @@
 int	tval;
 int	dest_type, dest_no, dir;
 
-pop()
+
+static int
+pop(void)
 {
 	if (level == 0)
 		return (-1);
@@ -206,7 +230,8 @@
 	return (0);
 }
 
-rezero()
+static void
+rezero(void)
 {
 	iomove(0);
 
@@ -218,7 +243,8 @@
 	strcpy(T_STR, "");
 }
 
-push(ruleno, ch)
+static void
+push(int ruleno, int ch)
 {
 	int	newstate, newpos;
 
@@ -239,10 +265,11 @@
 	strcpy(T_STR, "");
 }
 
-getcommand()
+int
+getcommand(void)
 {
 	int		c, i, done;
-	const char	*s, *(*func)();
+	const char	*s, *(*func)(int);
 	PLANE		*pp;
 
 	rezero();
@@ -297,13 +324,15 @@
 	return (0);
 }
 
-noise()
+static void
+noise(void)
 {
 	putchar('\07');
 	fflush(stdout);
 }
 
-gettoken()
+static int
+gettoken(void)
 {
 	while ((tval = getAChar()) == REDRAWTOKEN || tval == SHELLTOKEN)
 	{
@@ -368,8 +397,8 @@
 		return (tval);
 }
 
-const char	*
-setplane(c)
+static const char *
+setplane(int c)
 {
 	PLANE	*pp;
 
@@ -381,16 +410,16 @@
 	return (NULL);
 }
 
-const char	*
-turn(c)
+static const char *
+turn(__unused int c)
 {
 	if (p.altitude == 0)
 		return ("Planes at airports may not change direction");
 	return (NULL);
 }
 
-const char	*
-circle(c)
+static const char *
+circle(__unused int c)
 {
 	if (p.altitude == 0)
 		return ("Planes cannot circle on the ground");
@@ -398,8 +427,8 @@
 	return (NULL);
 }
 
-const char	*
-left(c)
+static const char *
+left(__unused int c)
 {
 	dir = D_LEFT;
 	p.new_dir = p.dir - 1;
@@ -408,8 +437,8 @@
 	return (NULL);
 }
 
-const char	*
-right(c)
+static const char *
+right(__unused int c)
 {
 	dir = D_RIGHT;
 	p.new_dir = p.dir + 1;
@@ -418,8 +447,8 @@
 	return (NULL);
 }
 
-const char	*
-Left(c)
+static const char *
+Left(__unused int c)
 {
 	p.new_dir = p.dir - 2;
 	if (p.new_dir < 0)
@@ -427,8 +456,8 @@
 	return (NULL);
 }
 
-const char	*
-Right(c)
+static const char *
+Right(__unused int c)
 {
 	p.new_dir = p.dir + 2;
 	if (p.new_dir >= MAXDIR)
@@ -436,8 +465,8 @@
 	return (NULL);
 }
 
-const char	*
-delayb(c)
+static const char *
+delayb(int c)
 {
 	int	xdiff, ydiff;
 
@@ -481,43 +510,43 @@
 	return (NULL);
 }
 
-const char	*
-beacon(c)
+static const char *
+beacon(__unused int c)
 {
 	dest_type = T_BEACON;
 	return (NULL);
 }
 
-const char	*
-ex_it(c)
+static const char *
+ex_it(__unused int c)
 {
 	dest_type = T_EXIT;
 	return (NULL);
 }
 
-const char	*
-airport(c)
+static const char *
+airport(__unused int c)
 {
 	dest_type = T_AIRPORT;
 	return (NULL);
 }
 
-const char	*
-climb(c)
+static const char *
+climb(__unused int c)
 {
 	dir = D_UP;
 	return (NULL);
 }
 
-const char	*
-descend(c)
+static const char *
+descend(__unused int c)
 {
 	dir = D_DOWN;
 	return (NULL);
 }
 
-const char	*
-setalt(c)
+static const char *
+setalt(int c)
 {
 	if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
 		return ("Already at that altitude");
@@ -525,8 +554,8 @@
 	return (NULL);
 }
 
-const char	*
-setrelalt(c)
+static const char *
+setrelalt(int c)
 {
 	if (c == 0)
 		return ("altitude not changed");
@@ -549,8 +578,8 @@
 	return (NULL);
 }
 
-const char	*
-benum(c)
+static const char *
+benum(int c)
 {
 	dest_no = c -= '0';
 
@@ -580,15 +609,15 @@
 	return (NULL);
 }
 
-const char	*
-to_dir(c)
+static const char *
+to_dir(int c)
 {
 	p.new_dir = dir_no(c);
 	return (NULL);
 }
 
-const char	*
-rel_dir(c)
+static const char *
+rel_dir(int c)
 {
 	int	angle;
 
@@ -611,8 +640,8 @@
 	return (NULL);
 }
 
-const char	*
-mark(c)
+static const char *
+mark(__unused int c)
 {
 	if (p.altitude == 0)
 		return ("Cannot mark planes on the ground");
@@ -622,8 +651,8 @@
 	return (NULL);
 }
 
-const char	*
-unmark(c)
+static const char *
+unmark(__unused int c)
 {
 	if (p.altitude == 0)
 		return ("Cannot unmark planes on the ground");
@@ -633,8 +662,8 @@
 	return (NULL);
 }
 
-const char	*
-ignore(c)
+static const char *
+ignore(__unused int c)
 {
 	if (p.altitude == 0)
 		return ("Cannot ignore planes on the ground");
@@ -644,23 +673,23 @@
 	return (NULL);
 }
 
-dir_no(ch)
-	char	ch;
+int
+dir_no(char ch)
 {
-	int	dir;
+	int	dirno = dir;
 
 	switch (ch) {
-	case 'w':	dir = 0;	break;
-	case 'e':	dir = 1;	break;
-	case 'd':	dir = 2;	break;
-	case 'c':	dir = 3;	break;
-	case 'x':	dir = 4;	break;
-	case 'z':	dir = 5;	break;
-	case 'a':	dir = 6;	break;
-	case 'q':	dir = 7;	break;
+	case 'w':	dirno = 0;	break;
+	case 'e':	dirno = 1;	break;
+	case 'd':	dirno = 2;	break;
+	case 'c':	dirno = 3;	break;
+	case 'x':	dirno = 4;	break;
+	case 'z':	dirno = 5;	break;
+	case 'a':	dirno = 6;	break;
+	case 'q':	dirno = 7;	break;
 	default:
 		fprintf(stderr, "bad character in dir_no\n");
 		break;
 	}
-	return (dir);
+	return (dirno);
 }
Index: games/atc/lex.l
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/lex.l,v
retrieving revision 1.2
diff -u -r1.2 lex.l
--- games/atc/lex.l	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/lex.l	4 Aug 2006 16:59:45 -0000
@@ -46,8 +46,12 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include "y.tab.h"
+#include	<unistd.h>
+#include	"y.tab.h"
+
+#define		YY_NO_UNPUT
 extern int	line;
+extern int	yylex(void);
 
 %}
 %%
Index: games/atc/list.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/list.c,v
retrieving revision 1.2
diff -u -r1.2 list.c
--- games/atc/list.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/list.c	4 Aug 2006 15:59:58 -0000
@@ -47,18 +47,17 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <stdlib.h>
 #include "include.h"
 
+
 PLANE	*
-newplane()
+newplane(void)
 {
 	return ((PLANE *) calloc(1, sizeof (PLANE)));
 }
 
-append(l, p)
-	LIST	*l;
-	PLANE	*p;
+void
+append(LIST *l, PLANE *p)
 {
 	PLANE 	*q = NULL, *r = NULL;
 
@@ -94,9 +93,8 @@
 	}
 }
 
-delete(l, p)
-	LIST	*l;
-	PLANE	*p;
+void
+delete(LIST *l, PLANE *p)
 {
 	if (l->head == NULL)
 		loser(p, "deleted a non-existant plane! Get help!");
Index: games/atc/log.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/log.c,v
retrieving revision 1.2
diff -u -r1.2 log.c
--- games/atc/log.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/log.c	4 Aug 2006 15:59:58 -0000
@@ -47,7 +47,9 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <string.h>
+#include <sys/stat.h>
+#include <err.h>
+
 #include "include.h"
 #include "pathnames.h"
 
@@ -57,9 +59,12 @@
 
 static FILE *score_fp;
 
-int
-compar(va, vb)
-	const void *va, *vb;
+static int	compar(const void *, const void *);
+static const char	*timestr(int);
+
+
+static int
+compar(const void *va, const void *vb)
 {
 	const SCORE	*a, *b;
 
@@ -82,8 +87,8 @@
 #define MIN(t)		(((t) % SECAHOUR) / SECAMIN)
 #define SEC(t)		((t) % SECAMIN)
 
-const char	*
-timestr(t)
+static const char *
+timestr(int t)
 {
 	static char	s[80];
 
@@ -102,7 +107,7 @@
 }
 
 void
-open_score_file()
+open_score_file(void)
 {
 	mode_t old_mask;
 	int score_fd;
@@ -135,8 +140,7 @@
 }
 
 int
-log_score(list_em)
-	int list_em;
+log_score(int list_em)
 {
 	int		i, num_scores = 0, good, changed = 0, found = 0;
 	struct passwd	*pw;
@@ -191,9 +195,9 @@
 		strcpy(thisscore.host, name.nodename);
 #endif
 
+		cp = rindex(filename, '/');
 		if (cp == NULL) {
-			fprintf(stderr, "log: where's the '/' in %s?\n", file);
+			fprintf(stderr, "log: where's the '/' in %s?\n", filename);
 			return (-1);
 		}
 		cp++;
Index: games/atc/main.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/main.c,v
retrieving revision 1.2
diff -u -r1.2 main.c
--- games/atc/main.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/main.c	4 Aug 2006 16:34:07 -0000
@@ -48,24 +48,27 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <string.h>
 #include "include.h"
 #include "pathnames.h"
 
-main(ac, av)
-	int	ac;
-	char	*av[];
+extern FILE	*yyin;
+static int	read_file(const char *);
+static const char	*default_game(void);
+static const char	*okay_game(const char *);
+static int	list_games(void);
+
+
+int
+main(__unused int ac, char **av)
 {
 	int                     seed = 0;
 	int			f_usage = 0, f_list = 0, f_showscore = 0;
 	int			f_printpath = 0;
 	const char		*file = NULL;
-	char			*name, *ptr;
+	char			*p_name, *ptr;
 #ifdef BSD
 	struct itimerval	itv;
 #endif
-	extern const char	*default_game(), *okay_game();
-	extern void		log_score(), quit(), update();
 
 	/* Open the score file then revoke setgid privileges */
 	open_score_file();
@@ -73,7 +76,7 @@
 
 	start_time = time(0);
 
-	name = *av++;
+	p_name = *av++;
 	while (*av) {
 #ifndef SAVEDASH
 		if (**av == '-')
@@ -122,7 +125,7 @@
 	if (f_usage)
 		fprintf(stderr,
 		    "Usage: %s -[u?lstp] [-[gf] game_name] [-r random seed]\n",
-			name);
+			p_name);
 	if (f_showscore)
 		log_score(1);
 	if (f_list)
@@ -151,14 +154,14 @@
 
 	addplane();
 
-	signal(SIGINT, quit);
-	signal(SIGQUIT, quit);
+	signal(SIGINT, (sig_t)quit);
+	signal(SIGQUIT, (sig_t)quit);
 #ifdef BSD
 	signal(SIGTSTP, SIG_IGN);
 	signal(SIGSTOP, SIG_IGN);
 #endif
-	signal(SIGHUP, log_score);
-	signal(SIGTERM, log_score);
+	signal(SIGHUP, (sig_t)log_score);
+	signal(SIGTERM, (sig_t)log_score);
 
 #ifdef BSD
 	ioctl(fileno(stdin), TIOCGETP, &tty_start);
@@ -178,7 +181,7 @@
 	ioctl(fileno(stdin), TCSETAW, &tty_new);
 #endif
 
-	signal(SIGALRM, update);
+	signal(SIGALRM, (sig_t)update);
 
 #ifdef BSD
 	itv.it_value.tv_sec = 0;
@@ -220,13 +223,12 @@
 	}
 }
 
-read_file(s)
-	const char	*s;
+static int
+read_file(const char *s)
 {
-	extern FILE	*yyin;
 	int		retval;
 
-	file = s;
+	filename = s;
 	yyin = fopen(s, "r");
 	if (yyin == NULL) {
 		perror(s);
@@ -241,8 +243,8 @@
 		return (0);
 }
 
-const char	*
-default_game()
+static const char *
+default_game(void)
 {
 	FILE		*fp;
 	static char	file[256];
@@ -266,9 +268,8 @@
 	return (file);
 }
 
-const char	*
-okay_game(s)
-	char	*s;
+static const char *
+okay_game(const char *s)
 {
 	FILE		*fp;
 	static char	file[256];
@@ -302,7 +303,8 @@
 	return (ret);
 }
 
-list_games()
+static int
+list_games(void)
 {
 	FILE		*fp;
 	char		line[256], games[256];
Index: games/atc/update.c
===================================================================
RCS file: /ftp/pub/DragonFly/dcvs/src/games/atc/update.c,v
retrieving revision 1.2
diff -u -r1.2 update.c
--- games/atc/update.c	17 Jun 2003 04:25:22 -0000	1.2
+++ games/atc/update.c	4 Aug 2006 15:59:58 -0000
@@ -47,15 +47,18 @@
  * For more info on this and all of my stuff, mail edjames at xxxxxxxxxxxxx
  */
 
-#include <string.h>
 #include "include.h"
 
-char name();
+static int	next_plane(void);
+static int	too_close(const PLANE *, const PLANE *, int);
+static int	dir_deg(int);
 
-update()
+
+void
+update(void)
 {
 	int	i, dir_diff, mask, unclean;
-	PLANE	*pp, *p1, *p2, *p;
+	PLANE	*pp, *p1, *p2;
 
 #ifdef BSD
 	mask = sigblock(sigmask(SIGINT));
@@ -223,11 +226,9 @@
 }
 
 const char *
-command(pp)
-	const PLANE	*pp;
+command(const PLANE *pp)
 {
 	static char	buf[50], *bp, *comm_start;
-	char	*index();
 
 	buf[0] = '\0';
 	bp = buf;
@@ -256,8 +257,7 @@
 
 /* char */
 char
-name(p)
-	const PLANE	*p;
+name(const PLANE *p)
 {
 	if (p->plane_type == 0)
 		return ('A' + p->plane_no);
@@ -265,7 +265,8 @@
 		return ('a' + p->plane_no);
 }
 
-number(l)
+char
+number(char l)
 {
 	if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
 		return (-1);
@@ -275,7 +276,8 @@
 		return (l - 'A');
 }
 
-next_plane()
+static int
+next_plane(void)
 {
 	static int	last_plane = -1;
 	PLANE		*pp;
@@ -303,10 +305,11 @@
 	return (last_plane);
 }
 
-addplane()
+int
+addplane(void)
 {
 	PLANE	p, *pp, *p1;
-	int	i, num_starts, close, rnd, rnd2, pnum;
+	int	i, num_starts, is_close, rnd, rnd2, pnum;
 
 	bzero(&p, sizeof (p));
 
@@ -336,13 +339,13 @@
 			p.ypos = sp->exit[rnd2].y;
 			p.new_dir = p.dir = sp->exit[rnd2].dir;
 			p.altitude = p.new_altitude = 7;
-			close = 0;
+			is_close = 0;
 			for (p1 = air.head; p1 != NULL; p1 = p1->next)
 				if (too_close(p1, &p, 4)) {
-					close++;
+					is_close++;
 					break;
 				}
-			if (close)
+			if (is_close)
 				continue;
 		} else {
 			p.orig_type = T_AIRPORT;
@@ -373,9 +376,8 @@
 	return (pp->dest_type);
 }
 
-PLANE	*
-findplane(n)
-	int	n;
+PLANE *
+findplane(int n)
 {
 	PLANE	*pp;
 
@@ -388,10 +390,8 @@
 	return (NULL);
 }
 
-int
-too_close(p1, p2, dist)
-	const PLANE	*p1, *p2;
-	int		dist;
+static int
+too_close(const PLANE *p1, const PLANE *p2, int dist)
 {
 	if (ABS(p1->altitude - p2->altitude) <= dist &&
 	    ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)
@@ -400,7 +400,8 @@
 		return (0);
 }
 
-dir_deg(d)
+static int
+dir_deg(int d)
 {
 	switch (d) {
 	case 0: return (0);
Attachment:
pgp00001.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00001.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20060804/7381a1f6/attachment-0018.obj>


More information about the Submit mailing list