Module Name: src Committed By: dholland Date: Mon Jul 20 05:44:02 UTC 2009
Modified Files: src/games/robots: auto.c flush_in.c init_field.c main.c make_level.c move.c move_robs.c play_level.c query.c rnd_pos.c robots.h score.c Log Message: ANSIfy. Use __dead. Object diffs checked. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/games/robots/auto.c \ src/games/robots/init_field.c cvs rdiff -u -r1.6 -r1.7 src/games/robots/flush_in.c \ src/games/robots/play_level.c src/games/robots/query.c cvs rdiff -u -r1.24 -r1.25 src/games/robots/main.c cvs rdiff -u -r1.7 -r1.8 src/games/robots/make_level.c \ src/games/robots/move_robs.c cvs rdiff -u -r1.12 -r1.13 src/games/robots/move.c cvs rdiff -u -r1.5 -r1.6 src/games/robots/rnd_pos.c cvs rdiff -u -r1.18 -r1.19 src/games/robots/robots.h src/games/robots/score.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/games/robots/auto.c diff -u src/games/robots/auto.c:1.8 src/games/robots/auto.c:1.9 --- src/games/robots/auto.c:1.8 Mon Apr 28 20:22:54 2008 +++ src/games/robots/auto.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: auto.c,v 1.8 2008/04/28 20:22:54 martin Exp $ */ +/* $NetBSD: auto.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -73,18 +73,16 @@ * return "move" number distance of the two coordinates */ static int -distance(x1, y1, x2, y2) - int x1, y1, x2, y2; +distance(int x1, int y1, int x2, int y2) { return MAX(ABS(ABS(x1) - ABS(x2)), ABS(ABS(y1) - ABS(y2))); -} /* end distance */ +} /* xinc(): * Return x coordinate moves */ static int -xinc(dir) - int dir; +xinc(int dir) { switch(dir) { case 'b': @@ -106,8 +104,7 @@ * Return y coordinate moves */ static int -yinc(dir) - int dir; +yinc(int dir) { switch(dir) { case 'k': @@ -129,7 +126,7 @@ * Find possible moves */ static const char * -find_moves() +find_moves(void) { int x, y; COORD test; @@ -169,8 +166,7 @@ * and put in dist its distance */ static COORD * -closest_robot(dist) - int *dist; +closest_robot(int *dist) { COORD *rob, *end, *minrob = NULL; int tdist, mindist; @@ -186,15 +182,14 @@ } *dist = mindist; return minrob; -} /* end closest_robot */ +} /* closest_heap(): * return the heap closest to us * and put in dist its distance */ static COORD * -closest_heap(dist) - int *dist; +closest_heap(int *dist) { COORD *hp, *end, *minhp = NULL; int mindist, tdist; @@ -212,14 +207,13 @@ } *dist = mindist; return minhp; -} /* end closest_heap */ +} /* move_towards(): * move as close to the given direction as possible */ static char -move_towards(dx, dy) - int dx, dy; +move_towards(int dx, int dy) { char ok_moves[10], best_move; char *ptr; @@ -242,30 +236,27 @@ } } return best_move; -} /* end move_towards */ +} /* move_away(): * move away form the robot given */ static char -move_away(rob) - COORD *rob; +move_away(COORD *rob) { int dx, dy; dx = sign(My_pos.x - rob->x); dy = sign(My_pos.y - rob->y); return move_towards(dx, dy); -} /* end move_away */ +} /* move_between(): * move the closest heap between us and the closest robot */ static char -move_between(rob, hp) - COORD *rob; - COORD *hp; +move_between(COORD *rob, COORD *hp) { int dx, dy; float slope, cons; @@ -314,15 +305,13 @@ CONSDEBUG(("me (%d,%d) robot(%d,%d) heap(%d,%d) delta(%d,%d)", My_pos.x, My_pos.y, rob->x, rob->y, hp->x, hp->y, dx, dy)); return move_towards(dx, dy); -} /* end move_between */ +} /* between(): * Return true if the heap is between us and the robot */ int -between(rob, hp) - COORD *rob; - COORD *hp; +between(COORD *rob, COORD *hp) { /* I = @ */ if (hp->x > rob->x && My_pos.x < rob->x) @@ -341,14 +330,14 @@ if (hp->y > rob->y && My_pos.y < rob->y) return 0; return 1; -} /* end between */ +} /* automove(): * find and do the best move if flag * else get the first move; */ char -automove() +automove(void) { #if 0 return find_moves()[0]; @@ -376,4 +365,4 @@ return move_between(robot_close, heap_close); #endif -} /* end automove */ +} Index: src/games/robots/init_field.c diff -u src/games/robots/init_field.c:1.8 src/games/robots/init_field.c:1.9 --- src/games/robots/init_field.c:1.8 Thu Aug 7 09:37:36 2003 +++ src/games/robots/init_field.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: init_field.c,v 1.8 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: init_field.c,v 1.9 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: init_field.c,v 1.8 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: init_field.c,v 1.9 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -49,7 +49,7 @@ * and initialize all the global variables. */ void -init_field() +init_field(void) { int i; static bool first = TRUE; @@ -123,8 +123,7 @@ } void -telmsg(on) - int on; +telmsg(int on) { move(tely, telx); addstr(on ? "Teleport!" : " "); Index: src/games/robots/flush_in.c diff -u src/games/robots/flush_in.c:1.6 src/games/robots/flush_in.c:1.7 --- src/games/robots/flush_in.c:1.6 Thu Aug 7 09:37:36 2003 +++ src/games/robots/flush_in.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: flush_in.c,v 1.6 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)flush_in.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: flush_in.c,v 1.6 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: flush_in.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ * Flush all pending input. */ void -flush_in() +flush_in(void) { tcflush(fileno(stdin), TCIFLUSH); } Index: src/games/robots/play_level.c diff -u src/games/robots/play_level.c:1.6 src/games/robots/play_level.c:1.7 --- src/games/robots/play_level.c:1.6 Thu Aug 7 09:37:37 2003 +++ src/games/robots/play_level.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: play_level.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ * Let the player play the current level */ void -play_level() +play_level(void) { COORD *cp; Index: src/games/robots/query.c diff -u src/games/robots/query.c:1.6 src/games/robots/query.c:1.7 --- src/games/robots/query.c:1.6 Thu Aug 7 09:37:37 2003 +++ src/games/robots/query.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: query.c,v 1.6 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: query.c,v 1.6 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: query.c,v 1.7 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,8 +45,7 @@ * Ask a question and get a yes or no answer. Default is "no". */ int -query(prompt) - const char *prompt; +query(const char *prompt) { int c, retval; int y, x; Index: src/games/robots/main.c diff -u src/games/robots/main.c:1.24 src/games/robots/main.c:1.25 --- src/games/robots/main.c:1.24 Fri Aug 8 16:10:47 2008 +++ src/games/robots/main.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $ */ +/* $NetBSD: main.c,v 1.25 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,21 +39,17 @@ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.24 2008/08/08 16:10:47 drochner Exp $"); +__RCSID("$NetBSD: main.c,v 1.25 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ # include "robots.h" -int main(int, char **); - extern const char *Scorefile; extern int Max_per_uid; int -main(ac, av) - int ac; - char **av; +main(int ac, char **av) { const char *sp; bool bad_arg; @@ -197,8 +193,7 @@ * Leave the program elegantly. */ void -quit(dummy) - int dummy __unused; +quit(int dummy __unused) { endwin(); exit(0); @@ -210,7 +205,7 @@ * See if another game is desired */ bool -another() +another(void) { int y; Index: src/games/robots/make_level.c diff -u src/games/robots/make_level.c:1.7 src/games/robots/make_level.c:1.8 --- src/games/robots/make_level.c:1.7 Thu Aug 7 09:37:36 2003 +++ src/games/robots/make_level.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: make_level.c,v 1.7 2003/08/07 09:37:36 agc Exp $ */ +/* $NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: make_level.c,v 1.7 2003/08/07 09:37:36 agc Exp $"); +__RCSID("$NetBSD: make_level.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ * Make the current level */ void -make_level() +make_level(void) { int i; COORD *cp; Index: src/games/robots/move_robs.c diff -u src/games/robots/move_robs.c:1.7 src/games/robots/move_robs.c:1.8 --- src/games/robots/move_robs.c:1.7 Thu Aug 7 09:37:37 2003 +++ src/games/robots/move_robs.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: move_robs.c,v 1.7 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move_robs.c,v 1.7 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: move_robs.c,v 1.8 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -45,8 +45,7 @@ * Move the robots around */ void -move_robots(was_sig) - int was_sig; +move_robots(int was_sig) { COORD *rp; @@ -129,8 +128,7 @@ * Add a score to the overall point total */ void -add_score(add) - int add; +add_score(int add) { Score += add; move(Y_SCORE, X_SCORE); @@ -142,8 +140,7 @@ * Return the sign of the number */ int -sign(n) - int n; +sign(int n) { if (n < 0) return -1; Index: src/games/robots/move.c diff -u src/games/robots/move.c:1.12 src/games/robots/move.c:1.13 --- src/games/robots/move.c:1.12 Fri Aug 27 09:07:08 2004 +++ src/games/robots/move.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $ */ +/* $NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $"); +__RCSID("$NetBSD: move.c,v 1.13 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -47,7 +47,7 @@ * Get and execute a move from the player */ void -get_move() +get_move(void) { int c; #ifdef FANCY @@ -208,7 +208,7 @@ * being eaten? */ bool -must_telep() +must_telep(void) { int x, y; static COORD newpos; @@ -240,8 +240,7 @@ * Execute a move */ bool -do_move(dy, dx) - int dy, dx; +do_move(int dy, int dx) { static COORD newpos; @@ -277,8 +276,7 @@ * Player would get eaten at this place */ bool -eaten(pos) - const COORD *pos; +eaten(const COORD *pos) { int x, y; @@ -300,7 +298,7 @@ * Reset the count variables */ void -reset_count() +reset_count(void) { Count = 0; Running = FALSE; @@ -313,7 +311,7 @@ * See if we are jumping, i.e., we should not refresh. */ bool -jumping() +jumping(void) { return (Jump && (Count || Running || Waiting)); } Index: src/games/robots/rnd_pos.c diff -u src/games/robots/rnd_pos.c:1.5 src/games/robots/rnd_pos.c:1.6 --- src/games/robots/rnd_pos.c:1.5 Thu Aug 7 09:37:37 2003 +++ src/games/robots/rnd_pos.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $ */ +/* $NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $"); +__RCSID("$NetBSD: rnd_pos.c,v 1.6 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -47,7 +47,7 @@ * Pick a random, unoccupied position */ COORD * -rnd_pos() +rnd_pos(void) { static COORD pos; static int call = 0; @@ -62,8 +62,7 @@ } int -rnd(range) - int range; +rnd(int range) { return rand() % range; Index: src/games/robots/robots.h diff -u src/games/robots/robots.h:1.18 src/games/robots/robots.h:1.19 --- src/games/robots/robots.h:1.18 Tue Jan 27 20:30:30 2004 +++ src/games/robots/robots.h Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: robots.h,v 1.18 2004/01/27 20:30:30 jsm Exp $ */ +/* $NetBSD: robots.h,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -117,7 +117,7 @@ extern jmp_buf End_move; /* - * functions types + * functions */ void add_score(int); @@ -135,7 +135,7 @@ bool must_telep(void); void play_level(void); int query(const char *); -void quit(int) __attribute__((__noreturn__)); +void quit(int) __dead; void reset_count(void); int rnd(int); COORD *rnd_pos(void); Index: src/games/robots/score.c diff -u src/games/robots/score.c:1.18 src/games/robots/score.c:1.19 --- src/games/robots/score.c:1.18 Fri Mar 17 23:11:47 2006 +++ src/games/robots/score.c Mon Jul 20 05:44:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $ */ +/* $NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.18 2006/03/17 23:11:47 abs Exp $"); +__RCSID("$NetBSD: score.c,v 1.19 2009/07/20 05:44:02 dholland Exp $"); #endif #endif /* not lint */ @@ -57,8 +57,7 @@ * Read the score file in MI format */ static void -read_score(inf) - int inf; +read_score(int inf) { SCORE *scp; @@ -85,8 +84,7 @@ * Write the score file in MI format */ static void -write_score(inf) - int inf; +write_score(int inf) { SCORE *scp; @@ -112,8 +110,7 @@ * top list. */ void -score(score_wfd) - int score_wfd; +score(int score_wfd) { int inf = score_wfd; SCORE *scp; @@ -189,8 +186,7 @@ } void -set_name(scp) - SCORE *scp; +set_name(SCORE *scp) { PASSWD *pp; @@ -205,8 +201,7 @@ * Compare two scores. */ int -cmp_sc(s1, s2) - const void *s1, *s2; +cmp_sc(const void *s1, const void *s2) { return ((const SCORE *)s2)->s_score - ((const SCORE *)s1)->s_score; } @@ -216,7 +211,7 @@ * Show the score list for the '-s' option. */ void -show_score() +show_score(void) { SCORE *scp; int inf;