Module Name: src
Committed By: dholland
Date: Sun Jun 28 21:12:35 UTC 2009
Modified Files:
src/games/hunt/huntd: answer.c draw.c driver.c execute.c faketalk.c
shots.c
Log Message:
sprintf -> snprintf
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/games/hunt/huntd/answer.c
cvs rdiff -u -r1.4 -r1.5 src/games/hunt/huntd/draw.c
cvs rdiff -u -r1.13 -r1.14 src/games/hunt/huntd/driver.c
cvs rdiff -u -r1.5 -r1.6 src/games/hunt/huntd/execute.c
cvs rdiff -u -r1.11 -r1.12 src/games/hunt/huntd/faketalk.c
cvs rdiff -u -r1.6 -r1.7 src/games/hunt/huntd/shots.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/hunt/huntd/answer.c
diff -u src/games/hunt/huntd/answer.c:1.10 src/games/hunt/huntd/answer.c:1.11
--- src/games/hunt/huntd/answer.c:1.10 Sun Jun 28 18:59:37 2009
+++ src/games/hunt/huntd/answer.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: answer.c,v 1.10 2009/06/28 18:59:37 dholland Exp $ */
+/* $NetBSD: answer.c,v 1.11 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: answer.c,v 1.10 2009/06/28 18:59:37 dholland Exp $");
+__RCSID("$NetBSD: answer.c,v 1.11 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
# include <ctype.h>
@@ -131,9 +131,10 @@
int n;
if (team == ' ')
- (void) sprintf(buf, "%s: ", name);
+ (void) snprintf(buf, sizeof(buf), "%s: ", name);
else
- (void) sprintf(buf, "%s[%c]: ", name, team);
+ (void) snprintf(buf, sizeof(buf), "%s[%c]: ", name,
+ team);
n = strlen(buf);
for (pp = Player; pp < End_player; pp++) {
cgoto(pp, HEIGHT, 0);
@@ -213,7 +214,8 @@
drawmaze(pp);
- (void) sprintf(Buf, "%5.5s%c%-10.10s %c", " ", stat_char(pp),
+ (void) snprintf(Buf, sizeof(Buf), "%5.5s%c%-10.10s %c", " ",
+ stat_char(pp),
pp->p_ident->i_name, pp->p_ident->i_team);
line = STAT_MON_ROW + 1 + (pp - Monitor);
for (npp = Player; npp < End_player; npp++) {
@@ -317,7 +319,8 @@
check(pp, y, x);
# endif
- (void) sprintf(Buf, "%5.2f%c%-10.10s %c", newpp->p_ident->i_score,
+ (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
+ newpp->p_ident->i_score,
stat_char(newpp), newpp->p_ident->i_name,
newpp->p_ident->i_team);
y = STAT_PLAY_ROW + 1 + (newpp - Player);
@@ -329,7 +332,8 @@
newpp->p_ammo += NSHOTS;
cgoto(pp, y, STAT_NAME_COL);
outstr(pp, Buf, STAT_NAME_LEN);
- (void) sprintf(smallbuf, "%3d", pp->p_ammo);
+ (void) snprintf(smallbuf, sizeof(smallbuf),
+ "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, smallbuf, 3);
}
Index: src/games/hunt/huntd/draw.c
diff -u src/games/hunt/huntd/draw.c:1.4 src/games/hunt/huntd/draw.c:1.5
--- src/games/hunt/huntd/draw.c:1.4 Mon Jan 28 03:23:29 2008
+++ src/games/hunt/huntd/draw.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: draw.c,v 1.4 2008/01/28 03:23:29 dholland Exp $ */
+/* $NetBSD: draw.c,v 1.5 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: draw.c,v 1.4 2008/01/28 03:23:29 dholland Exp $");
+__RCSID("$NetBSD: draw.c,v 1.5 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
# include "hunt.h"
@@ -79,7 +79,7 @@
cgoto(pp, STAT_AMMO_ROW, STAT_LABEL_COL);
outstr(pp, "Ammo:", 5);
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
@@ -90,20 +90,22 @@
cgoto(pp, STAT_DAM_ROW, STAT_LABEL_COL);
outstr(pp, "Damage:", 7);
- (void) sprintf(Buf, "%2d/%2d", pp->p_damage, pp->p_damcap);
+ (void) snprintf(Buf, sizeof(Buf), "%2d/%2d", pp->p_damage,
+ pp->p_damcap);
cgoto(pp, STAT_DAM_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 5);
cgoto(pp, STAT_KILL_ROW, STAT_LABEL_COL);
outstr(pp, "Kills:", 6);
- (void) sprintf(Buf, "%3d", (pp->p_damcap - MAXDAM) / 2);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", (pp->p_damcap - MAXDAM) / 2);
cgoto(pp, STAT_KILL_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
cgoto(pp, STAT_PLAY_ROW, STAT_LABEL_COL);
outstr(pp, "Player:", 7);
for (i = STAT_PLAY_ROW + 1, np = Player; np < End_player; np++) {
- (void) sprintf(Buf, "%5.2f%c%-10.10s %c", np->p_ident->i_score,
+ (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
+ np->p_ident->i_score,
stat_char(np), np->p_ident->i_name,
np->p_ident->i_team);
cgoto(pp, i++, STAT_NAME_COL);
@@ -114,7 +116,7 @@
cgoto(pp, STAT_MON_ROW, STAT_LABEL_COL);
outstr(pp, "Monitor:", 8);
for (i = STAT_MON_ROW + 1, np = Monitor; np < End_monitor; np++) {
- (void) sprintf(Buf, "%5.5s %-10.10s %c", " ",
+ (void) snprintf(Buf, sizeof(Buf), "%5.5s %-10.10s %c", " ",
np->p_ident->i_name, np->p_ident->i_team);
cgoto(pp, i++, STAT_NAME_COL);
outstr(pp, Buf, STAT_NAME_LEN);
Index: src/games/hunt/huntd/driver.c
diff -u src/games/hunt/huntd/driver.c:1.13 src/games/hunt/huntd/driver.c:1.14
--- src/games/hunt/huntd/driver.c:1.13 Mon Jan 28 03:23:29 2008
+++ src/games/hunt/huntd/driver.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: driver.c,v 1.13 2008/01/28 03:23:29 dholland Exp $ */
+/* $NetBSD: driver.c,v 1.14 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: driver.c,v 1.13 2008/01/28 03:23:29 dholland Exp $");
+__RCSID("$NetBSD: driver.c,v 1.14 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
# include <sys/ioctl.h>
@@ -490,7 +490,7 @@
# endif
ouch->p_damage += amt;
if (ouch->p_damage <= ouch->p_damcap) {
- (void) sprintf(Buf, "%2d", ouch->p_damage);
+ (void) snprintf(Buf, sizeof(Buf), "%2d", ouch->p_damage);
cgoto(ouch, STAT_DAM_ROW, STAT_VALUE_COL);
outstr(ouch, Buf, 2);
return;
@@ -541,13 +541,15 @@
# endif
}
if (credit == NULL) {
- (void) sprintf(ouch->p_death, "| %s by %s |", cp,
+ (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
+ "| %s by %s |", cp,
(this_shot_type == MINE || this_shot_type == GMINE) ?
"a mine" : "act of God");
return;
}
- (void) sprintf(ouch->p_death, "| %s by %s |", cp, credit->i_name);
+ (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
+ "| %s by %s |", cp, credit->i_name);
if (ouch == gotcha) { /* No use killing yourself */
credit->i_kills--;
@@ -572,13 +574,15 @@
gotcha->p_damage -= STABDAM;
if (gotcha->p_damage < 0)
gotcha->p_damage = 0;
- (void) sprintf(Buf, "%2d/%2d", gotcha->p_damage, gotcha->p_damcap);
+ (void) snprintf(Buf, sizeof(Buf), "%2d/%2d", gotcha->p_damage,
+ gotcha->p_damcap);
cgoto(gotcha, STAT_DAM_ROW, STAT_VALUE_COL);
outstr(gotcha, Buf, 5);
- (void) sprintf(Buf, "%3d", (gotcha->p_damcap - MAXDAM) / 2);
+ (void) snprintf(Buf, sizeof(Buf), "%3d",
+ (gotcha->p_damcap - MAXDAM) / 2);
cgoto(gotcha, STAT_KILL_ROW, STAT_VALUE_COL);
outstr(gotcha, Buf, 3);
- (void) sprintf(Buf, "%5.2f", gotcha->p_ident->i_score);
+ (void) snprintf(Buf, sizeof(Buf), "%5.2f", gotcha->p_ident->i_score);
for (ouch = Player; ouch < End_player; ouch++) {
cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player),
STAT_NAME_COL);
@@ -671,7 +675,7 @@
if (x > 0) {
(void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x,
(PLAYER *) NULL, TRUE, SPACE);
- (void) sprintf(Buf, "%s detonated.",
+ (void) snprintf(Buf, sizeof(Buf), "%s detonated.",
pp->p_ident->i_name);
for (np = Player; np < End_player; np++)
message(np, Buf);
@@ -747,7 +751,7 @@
memcpy(pp, End_player, sizeof (PLAYER));
fdset[i] = fdset[End_player - Player + 3];
fdset[End_player - Player + 3].fd = -1;
- (void) sprintf(Buf, "%5.2f%c%-10.10s %c",
+ (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
pp->p_ident->i_score, stat_char(pp),
pp->p_ident->i_name, pp->p_ident->i_team);
n = STAT_PLAY_ROW + 1 + (pp - Player);
@@ -786,7 +790,8 @@
memcpy(pp, End_monitor, sizeof (PLAYER));
fdset[i] = fdset[End_monitor - Monitor + MAXPL + 3];
fdset[End_monitor - Monitor + MAXPL + 3].fd = -1;
- (void) sprintf(Buf, "%5.5s %-10.10s %c", " ",
+ (void) snprintf(Buf, sizeof(Buf), "%5.5s %-10.10s %c",
+ " ",
pp->p_ident->i_name, pp->p_ident->i_team);
n = STAT_MON_ROW + 1 + (pp - Player);
for (np = Player; np < End_player; np++) {
Index: src/games/hunt/huntd/execute.c
diff -u src/games/hunt/huntd/execute.c:1.5 src/games/hunt/huntd/execute.c:1.6
--- src/games/hunt/huntd/execute.c:1.5 Mon Jan 28 03:23:29 2008
+++ src/games/hunt/huntd/execute.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: execute.c,v 1.5 2008/01/28 03:23:29 dholland Exp $ */
+/* $NetBSD: execute.c,v 1.6 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: execute.c,v 1.5 2008/01/28 03:23:29 dholland Exp $");
+__RCSID("$NetBSD: execute.c,v 1.6 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
# include <stdlib.h>
@@ -366,7 +366,7 @@
outstr(pp, " ", 3);
}
pp->p_ammo -= shot_req[req_index];
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
@@ -415,7 +415,7 @@
outstr(pp, " ", 3);
}
pp->p_ammo -= slime_req[req_index];
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
@@ -536,7 +536,7 @@
return;
}
# endif
- (void) sprintf(Buf, "%3d", --pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", --pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
@@ -560,7 +560,7 @@
message(pp, "No more charges");
return;
}
- (void) sprintf(Buf, "%3d", --pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", --pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
@@ -600,7 +600,7 @@
TRUE, pp->p_face);
else {
pp->p_ammo += req;
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
}
Index: src/games/hunt/huntd/faketalk.c
diff -u src/games/hunt/huntd/faketalk.c:1.11 src/games/hunt/huntd/faketalk.c:1.12
--- src/games/hunt/huntd/faketalk.c:1.11 Sat Dec 15 19:44:41 2007
+++ src/games/hunt/huntd/faketalk.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: faketalk.c,v 1.11 2007/12/15 19:44:41 perry Exp $ */
+/* $NetBSD: faketalk.c,v 1.12 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: faketalk.c,v 1.11 2007/12/15 19:44:41 perry Exp $");
+__RCSID("$NetBSD: faketalk.c,v 1.12 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
#include "bsd.h"
@@ -164,10 +164,12 @@
}
(void) fgets(buf, BUFSIZ, f);
- (void) sprintf(buf, "HELO huntg...@%s\r\n", my_machine_name);
+ (void) snprintf(buf, sizeof(buf),
+ "HELO huntg...@%s\r\n", my_machine_name);
(void) write(service, buf, strlen(buf));
(void) fgets(buf, BUFSIZ, f);
- (void) sprintf(buf, "EXPN %...@%s\r\n", RENDEZVOUS, my_machine_name);
+ (void) snprintf(buf, sizeof(buf),
+ "EXPN %...@%s\r\n", RENDEZVOUS, my_machine_name);
(void) write(service, buf, strlen(buf));
while (fgets(buf, BUFSIZ, f) != NULL) {
char *s, *t;
Index: src/games/hunt/huntd/shots.c
diff -u src/games/hunt/huntd/shots.c:1.6 src/games/hunt/huntd/shots.c:1.7
--- src/games/hunt/huntd/shots.c:1.6 Fri Mar 17 23:34:37 2006
+++ src/games/hunt/huntd/shots.c Sun Jun 28 21:12:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: shots.c,v 1.6 2006/03/17 23:34:37 abs Exp $ */
+/* $NetBSD: shots.c,v 1.7 2009/06/28 21:12:35 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: shots.c,v 1.6 2006/03/17 23:34:37 abs Exp $");
+__RCSID("$NetBSD: shots.c,v 1.7 2009/06/28 21:12:35 dholland Exp $");
#endif /* not lint */
# include <err.h>
@@ -316,7 +316,8 @@
message(pp, "Absorbed charge (good shield!)");
pp->p_ident->i_absorbed += bp->b_charge;
free((char *) bp);
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(Buf),
+ "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
return FALSE;
@@ -497,7 +498,7 @@
pp->p_ammo += bp->b_charge;
message(pp, "**** Absorbed drone ****");
free((char *) bp);
- (void) sprintf(Buf, "%3d", pp->p_ammo);
+ (void) snprintf(Buf, sizeof(buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
return FALSE;