sprintf -> snprintf
This commit is contained in:
parent
69388abb04
commit
0ed1b742e0
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: hunt.c,v 1.27 2008/08/08 16:10:47 drochner Exp $ */
|
||||
/* $NetBSD: hunt.c,v 1.28 2009/06/28 21:12:10 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: hunt.c,v 1.27 2008/08/08 16:10:47 drochner Exp $");
|
||||
__RCSID("$NetBSD: hunt.c,v 1.28 2009/06/28 21:12:10 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
# include <sys/param.h>
|
||||
|
@ -610,7 +610,8 @@ find_driver(do_startup)
|
|||
# endif
|
||||
hp = gethostbyaddr((char *) &hosts[i].sin_addr,
|
||||
sizeof hosts[i].sin_addr, AF_INET);
|
||||
(void) sprintf(buf, "%8c %.64s", 'a' + i,
|
||||
(void) snprintf(buf, sizeof(buf),
|
||||
"%8c %.64s", 'a' + i,
|
||||
hp != NULL ? hp->h_name
|
||||
: inet_ntoa(hosts->sin_addr));
|
||||
put_str(buf);
|
||||
|
|
|
@ -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 @@ answer()
|
|||
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 @@ stmonitor(pp)
|
|||
|
||||
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 @@ stplayer(newpp, enter_status)
|
|||
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 @@ stplayer(newpp, enter_status)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ drawstatus(pp)
|
|||
|
||||
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 @@ drawstatus(pp)
|
|||
|
||||
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 @@ drawstatus(pp)
|
|||
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);
|
||||
|
|
|
@ -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 @@ checkdam(ouch, gotcha, credit, amt, this_shot_type)
|
|||
# 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 @@ checkdam(ouch, gotcha, credit, amt, this_shot_type)
|
|||
# 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 @@ checkdam(ouch, gotcha, credit, amt, this_shot_type)
|
|||
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 @@ zap(pp, was_player, i)
|
|||
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 @@ zap(pp, was_player, i)
|
|||
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 @@ zap(pp, was_player, i)
|
|||
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++) {
|
||||
|
|
|
@ -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 @@ fire(pp, req_index)
|
|||
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 @@ fire_slime(pp, req_index)
|
|||
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 @@ cloak(pp)
|
|||
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 @@ scan(pp)
|
|||
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 @@ pickup(pp, y, x, prob, obj)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ faketalk()
|
|||
}
|
||||
|
||||
(void) fgets(buf, BUFSIZ, f);
|
||||
(void) sprintf(buf, "HELO HuntGame@%s\r\n", my_machine_name);
|
||||
(void) snprintf(buf, sizeof(buf),
|
||||
"HELO HuntGame@%s\r\n", my_machine_name);
|
||||
(void) write(service, buf, strlen(buf));
|
||||
(void) fgets(buf, BUFSIZ, f);
|
||||
(void) sprintf(buf, "EXPN %s@%s\r\n", RENDEZVOUS, my_machine_name);
|
||||
(void) snprintf(buf, sizeof(buf),
|
||||
"EXPN %s@%s\r\n", RENDEZVOUS, my_machine_name);
|
||||
(void) write(service, buf, strlen(buf));
|
||||
while (fgets(buf, BUFSIZ, f) != NULL) {
|
||||
char *s, *t;
|
||||
|
|
|
@ -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 @@ move_normal_shot(bp)
|
|||
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 @@ drone_move:
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue