Skip to content

Commit 5175902

Browse files
committed
- make sure that the arguments to the printf like functions are correct
- add a makemsg() function to accompany makesignal.
1 parent 5e41115 commit 5175902

File tree

13 files changed

+103
-81
lines changed

13 files changed

+103
-81
lines changed

games/sail/assorted.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: assorted.c,v 1.5 1997/10/13 19:43:05 christos Exp $ */
1+
/* $NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
4040
#else
41-
__RCSID("$NetBSD: assorted.c,v 1.5 1997/10/13 19:43:05 christos Exp $");
41+
__RCSID("$NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -114,7 +114,7 @@ int rig, shot, hittable, roll;
114114
rigg[3] -= rhits;
115115
}
116116
if (rig && !rigg[2] && (!rigg[3] || rigg[3] == -1))
117-
makesignal(on, "dismasted!", (struct ship *)0);
117+
makemsg(on, "dismasted!");
118118
if (portside(from, on, 0)) {
119119
guns = on->specs->gunR;
120120
car = on->specs->carR;
@@ -152,19 +152,19 @@ int rig, shot, hittable, roll;
152152
Write(W_RIGG, on, 0, rigg[0], rigg[1], rigg[2], rigg[3]);
153153
switch (shot) {
154154
case L_ROUND:
155-
message = "firing round shot on %s (%c%c)";
155+
message = "firing round shot on $$";
156156
break;
157157
case L_GRAPE:
158-
message = "firing grape shot on %s (%c%c)";
158+
message = "firing grape shot on $$";
159159
break;
160160
case L_CHAIN:
161-
message = "firing chain shot on %s (%c%c)";
161+
message = "firing chain shot on $$";
162162
break;
163163
case L_DOUBLE:
164-
message = "firing double shot on %s (%c%c)";
164+
message = "firing double shot on $$";
165165
break;
166166
case L_EXPLODE:
167-
message = "exploding shot on %s (%c%c)";
167+
message = "exploding shot on $$";
168168
break;
169169
default:
170170
errx(1, "Unknown shot type %d", shot);
@@ -197,7 +197,7 @@ int rig, shot, hittable, roll;
197197
default:
198198
errx(1, "Bad Rhit = %d", Rhit);
199199
}
200-
makesignal(on, message, (struct ship *)0);
200+
makemsg(on, message);
201201
} else if (roll == 6) {
202202
switch (Hhit) {
203203
case 0:
@@ -225,17 +225,17 @@ int rig, shot, hittable, roll;
225225
default:
226226
errx(1, "Bad Hhit = %d", Hhit);
227227
}
228-
makesignal(on, message, (struct ship *)0);
228+
makemsg(on, message);
229229
}
230230
/*
231231
if (Chit > 1 && on->file->readyL&R_INITIAL && on->file->readyR&R_INITIAL) {
232232
on->specs->qual--;
233233
if (on->specs->qual <= 0) {
234-
makesignal(on, "crew mutinying!", (struct ship *)0);
234+
makemsg(on, "crew mutinying!");
235235
on->specs->qual = 5;
236236
Write(W_CAPTURED, on, 0, on->file->index, 0, 0, 0);
237237
} else
238-
makesignal(on, "crew demoralized", (struct ship *)0);
238+
makemsg(on, "crew demoralized");
239239
Write(W_QUAL, on, 0, on->specs->qual, 0, 0, 0);
240240
}
241241
*/

games/sail/dr_1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_1.c,v 1.5 1997/10/13 19:43:14 christos Exp $ */
1+
/* $NetBSD: dr_1.c,v 1.6 1997/10/13 21:03:09 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_1.c,v 1.5 1997/10/13 19:43:14 christos Exp $");
41+
__RCSID("$NetBSD: dr_1.c,v 1.6 1997/10/13 21:03:09 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -189,7 +189,7 @@ int key;
189189
unboard(to, from, 0);
190190
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
191191
subtract(to, totalto, crewto, tocap, pcto);
192-
makesignal(from, "boarders from %s repelled", to);
192+
makemsg(from, "boarders from %s repelled", to->shipname);
193193
(void) sprintf(message, "killed in melee: %d. %s: %d",
194194
totalto, from->shipname, totalfrom);
195195
Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0);

games/sail/dr_2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_2.c,v 1.5 1997/10/13 19:43:23 christos Exp $ */
1+
/* $NetBSD: dr_2.c,v 1.6 1997/10/13 21:03:18 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_2.c,v 1.5 1997/10/13 19:43:23 christos Exp $");
41+
__RCSID("$NetBSD: dr_2.c,v 1.6 1997/10/13 21:03:18 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -99,13 +99,13 @@ checkup()
9999
foreachship(sq)
100100
cleansnag(sp, sq, 1);
101101
if (sink != 1) {
102-
makesignal(sp, "exploding!", (struct ship *)0);
102+
makemsg(sp, "exploding!");
103103
foreachship(sq) {
104104
if (sp != sq && sq->file->dir && range(sp, sq) < 4)
105105
table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6);
106106
}
107107
} else
108-
makesignal(sp, "sinking!", (struct ship *)0);
108+
makemsg(sp, "sinking!");
109109
}
110110
}
111111

games/sail/dr_3.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_3.c,v 1.4 1997/10/13 19:43:32 christos Exp $ */
1+
/* $NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_3.c,v 1.4 1997/10/13 19:43:32 christos Exp $");
41+
__RCSID("$NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -134,12 +134,10 @@ moveall() /* move all comp ships */
134134
if (snagged2(sp, sq) && range(sp, sq) > 1)
135135
snap++;
136136
if (!range(sp, sq) && !fouled2(sp, sq)) {
137-
makesignal(sp,
138-
"collision with %s (%c%c)", sq);
137+
makesignal(sp, "collision with $$", sq);
139138
if (die() < 4) {
140-
makesignal(sp,
141-
"fouled with %s (%c%c)",
142-
sq);
139+
makesignal(sp, "fouled with $$",
140+
sq);
143141
Write(W_FOUL, sp, 0, l, 0, 0, 0);
144142
Write(W_FOUL, sq, 0, n, 0, 0, 0);
145143
}
@@ -283,10 +281,9 @@ char isdefense;
283281
Write(isdefense ? W_DBP : W_OBP, from, 0,
284282
n, turn, to->file->index, sections);
285283
if (isdefense)
286-
makesignal(from, "repelling boarders",
287-
(struct ship *)0);
284+
makemsg(from, "repelling boarders");
288285
else
289-
makesignal(from, "boarding the %s (%c%c)", to);
286+
makesignal(from, "boarding the $$", to);
290287
}
291288
}
292289

games/sail/dr_4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_4.c,v 1.5 1997/10/13 19:43:39 christos Exp $ */
1+
/* $NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95";
4040
#else
41-
__RCSID("$NetBSD: dr_4.c,v 1.5 1997/10/13 19:43:39 christos Exp $");
41+
__RCSID("$NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -58,7 +58,7 @@ struct ship *from, *to;
5858
while (--k >= 0) {
5959
if (friend || die() < 3) {
6060
cleangrapple(from, to, 0);
61-
makesignal(from, "ungrappling %s (%c%c)", to);
61+
makesignal(from, "ungrappling $$", to);
6262
}
6363
}
6464
}
@@ -71,5 +71,5 @@ struct ship *from, *to;
7171
return;
7272
Write(W_GRAP, from, 0, to->file->index, 0, 0, 0);
7373
Write(W_GRAP, to, 0, from->file->index, 0, 0, 0);
74-
makesignal(from, "grappled with %s (%c%c)", to);
74+
makesignal(from, "grappled with $$", to);
7575
}

games/sail/extern.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: extern.h,v 1.4 1997/10/13 19:44:01 christos Exp $ */
1+
/* $NetBSD: extern.h,v 1.5 1997/10/13 21:03:49 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -400,8 +400,10 @@ void loadplayer __P((void));
400400
void initscreen __P((void));
401401
void cleanupscreen __P((void));
402402
void newturn __P((int));
403-
void Signal __P((const char *, struct ship *, ...));
404-
void Msg __P((const char *, ...));
403+
void Signal __P((const char *, struct ship *, ...))
404+
__attribute__((__format__(__printf__,1,3)));
405+
void Msg __P((const char *, ...))
406+
__attribute__((__format__(__printf__,1,2)));
405407
void Scroll __P((void));
406408
void prompt __P((char *, struct ship *));
407409
void endprompt __P((int));
@@ -426,7 +428,10 @@ void initialize __P((void));
426428

427429
/* sync.c */
428430
void fmtship __P((char *, size_t, const char *, struct ship *));
429-
void makesignal __P((struct ship *, const char *, struct ship *, ...));
431+
void makesignal __P((struct ship *, const char *, struct ship *, ...))
432+
__attribute__((__format__(__printf__,2,4)));
433+
void makemsg __P((struct ship *, const char *, ...))
434+
__attribute__((__format__(__printf__,2,3)));
430435
int sync_exists __P((int));
431436
int sync_open __P((void));
432437
void sync_close __P((int));

games/sail/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: main.c,v 1.5 1997/10/13 19:44:30 christos Exp $ */
1+
/* $NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
4343
#if 0
4444
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95";
4545
#else
46-
__RCSID("$NetBSD: main.c,v 1.5 1997/10/13 19:44:30 christos Exp $");
46+
__RCSID("$NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $");
4747
#endif
4848
#endif /* not lint */
4949

@@ -65,7 +65,7 @@ main(argc, argv)
6565

6666
(void) srand(getpid());
6767
issetuid = getuid() != geteuid();
68-
if ((p = strrchr(*argv, '/')) != '\0')
68+
if ((p = strrchr(*argv, '/')) != NULL)
6969
p++;
7070
else
7171
p = *argv;

games/sail/pl_1.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pl_1.c,v 1.4 1997/10/13 19:44:53 christos Exp $ */
1+
/* $NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,13 +38,14 @@
3838
#if 0
3939
static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: pl_1.c,v 1.4 1997/10/13 19:44:53 christos Exp $");
41+
__RCSID("$NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

4545
#include "player.h"
4646
#include <sys/types.h>
4747
#include <sys/wait.h>
48+
#include <unistd.h>
4849

4950
/*
5051
* If we get here before a ship is chosen, then ms == 0 and
@@ -106,13 +107,14 @@ int conditions;
106107
if (ms != 0) {
107108
logger(ms);
108109
if (conditions != LEAVE_SYNC) {
109-
makesignal(ms, "Captain %s relinquishing.",
110-
(struct ship *)0, mf->captain);
110+
makemsg(ms, "Captain %s relinquishing.",
111+
mf->captain);
111112
Write(W_END, ms, 0, 0, 0, 0, 0);
112113
(void) Sync();
113114
}
114115
}
115116
sync_close(!hasdriver);
117+
sleep(5);
116118
cleanupscreen();
117119
exit(0);
118120
}

games/sail/pl_3.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pl_3.c,v 1.4 1997/10/13 19:45:10 christos Exp $ */
1+
/* $NetBSD: pl_3.c,v 1.5 1997/10/13 21:04:09 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: pl_3.c,v 1.4 1997/10/13 19:45:10 christos Exp $");
41+
__RCSID("$NetBSD: pl_3.c,v 1.5 1997/10/13 21:04:09 christos Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -99,7 +99,7 @@ acceptcombat()
9999
target = range(ms, closest);
100100
if (target > rangeofshot[load] || (!guns && target >= 3))
101101
goto cant;
102-
Signal("%$ within range of %s broadside.",
102+
Signal("$$ within range of %s broadside.",
103103
closest, r ? "right" : "left");
104104
if (load > L_CHAIN && target < 6) {
105105
switch (sgetch("Aim for hull or rigging? ",
@@ -133,9 +133,10 @@ acceptcombat()
133133
sternrake = temp > 4 && temp < 6;
134134
if (rakehim)
135135
if (!sternrake)
136-
Signal("%$ Raking the %s!", closest);
136+
Msg("Raking the %s!", closest->shipname);
137137
else
138-
Signal("%$ Stern Rake! %s splintering!", closest);
138+
Msg("Stern Rake! %s splintering!",
139+
closest->shipname);
139140
index = guns;
140141
if (target < 3)
141142
index += car;
@@ -224,15 +225,15 @@ grapungrap()
224225
continue;
225226
if (range(ms, sp) > 1 && !grappled2(ms, sp))
226227
continue;
227-
switch (sgetch("Attempt to grapple or ungrapple %s (%c%c): ",
228+
switch (sgetch("Attempt to grapple or ungrapple $$: ",
228229
sp, 1)) {
229230
case 'g':
230231
if (die() < 3
231232
|| ms->nationality == capship(sp)->nationality) {
232233
Write(W_GRAP, ms, 0, sp->file->index, 0, 0, 0);
233234
Write(W_GRAP, sp, 0, player, 0, 0, 0);
234235
Msg("Attempt succeeds!");
235-
makesignal(ms, "grappled with %s (%c%c)", sp);
236+
makesignal(ms, "grappled with $$", sp);
236237
} else
237238
Msg("Attempt fails.");
238239
break;
@@ -243,8 +244,7 @@ grapungrap()
243244
|| die() < 3) {
244245
cleangrapple(ms, sp, 0);
245246
Msg("Attempt succeeds!");
246-
makesignal(ms,
247-
"ungrappling with %s (%c%c)",
247+
makesignal(ms, "ungrappling with $$",
248248
sp);
249249
} else
250250
Msg("Attempt fails.");
@@ -263,13 +263,13 @@ unfoulplayer()
263263
foreachship(to) {
264264
if (fouled2(ms, to) == 0)
265265
continue;
266-
if (sgetch("Attempt to unfoul with the %s (%c%c)? ", to, 1) != 'y')
266+
if (sgetch("Attempt to unfoul with the $$? ", to, 1) != 'y')
267267
continue;
268268
for (i = fouled2(ms, to); --i >= 0;) {
269269
if (die() <= 2) {
270270
cleanfoul(ms, to, 0);
271271
Msg("Attempt succeeds!");
272-
makesignal(ms, "Unfouling %s (%c%c)", to);
272+
makesignal(ms, "Unfouling $$", to);
273273
} else
274274
Msg("Attempt fails.");
275275
}

0 commit comments

Comments
 (0)