Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hack Correctly print variables as strings, not as form...
details: https://anonhg.NetBSD.org/src/rev/7b07aeb19fec
branches: trunk
changeset: 765284:7b07aeb19fec
user: joerg <joerg%NetBSD.org@localhost>
date: Mon May 23 22:53:25 2011 +0000
description:
Correctly print variables as strings, not as format string.
diffstat:
games/hack/hack.apply.c | 6 +++---
games/hack/hack.eat.c | 6 +++---
games/hack/hack.invent.c | 8 ++++----
games/hack/hack.main.c | 10 ++++++----
games/hack/hack.options.c | 6 +++---
games/hack/hack.pager.c | 8 ++++----
games/hack/hack.potion.c | 6 +++---
games/hack/hack.rumors.c | 6 +++---
games/hack/hack.timeout.c | 6 +++---
9 files changed, 32 insertions(+), 30 deletions(-)
diffs (265 lines):
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.apply.c
--- a/games/hack/hack.apply.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.apply.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.apply.c,v 1.10 2009/06/07 18:30:39 dholland Exp $ */
+/* $NetBSD: hack.apply.c,v 1.11 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.apply.c,v 1.10 2009/06/07 18:30:39 dholland Exp $");
+__RCSID("$NetBSD: hack.apply.c,v 1.11 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include "hack.h"
@@ -383,7 +383,7 @@
digtxt = "Now what exactly was it that you were digging in?";
mnewsym(dpx, dpy);
prl(dpx, dpy);
- pline(digtxt); /* after mnewsym & prl */
+ pline("%s", digtxt); /* after mnewsym & prl */
return (0);
} else {
if (IS_WALL(levl[dpx][dpy].typ)) {
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.eat.c
--- a/games/hack/hack.eat.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.eat.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.eat.c,v 1.9 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.eat.c,v 1.10 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.eat.c,v 1.9 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.eat.c,v 1.10 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include "hack.h"
@@ -138,7 +138,7 @@
useup(tin.tin);
r = rn2(2 * TTSZ);
if (r < TTSZ) {
- pline(tintxts[r].txt);
+ pline("%s", tintxts[r].txt);
lesshungry(tintxts[r].nut);
if (r == 1) { /* SALMON */
Glib = rnd(15);
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.invent.c
--- a/games/hack/hack.invent.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.invent.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.invent.c,v 1.14 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.invent.c,v 1.15 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.invent.c,v 1.14 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.invent.c,v 1.15 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include <assert.h>
@@ -655,7 +655,7 @@
if (ckfn && !(*ckfn) (otmp))
continue;
if (!allflag) {
- pline(xprname(otmp, ilet));
+ pline("%s", xprname(otmp, ilet));
addtopl(" [nyaq]? ");
sym = readchar();
} else
@@ -699,7 +699,7 @@
void
prinv(struct obj *obj)
{
- pline(xprname(obj, obj_to_let(obj)));
+ pline("%s", xprname(obj, obj_to_let(obj)));
}
static char *
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.main.c
--- a/games/hack/hack.main.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.main.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.main.c,v 1.15 2010/02/03 15:34:38 roy Exp $ */
+/* $NetBSD: hack.main.c,v 1.16 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.main.c,v 1.15 2010/02/03 15:34:38 roy Exp $");
+__RCSID("$NetBSD: hack.main.c,v 1.16 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include <signal.h>
@@ -418,8 +418,10 @@
}
if (multi < 0) {
if (!++multi) {
- pline(nomovemsg ? nomovemsg :
- "You can move again.");
+ if (nomovemsg)
+ pline("%s", nomovemsg);
+ else
+ pline("You can move again.");
nomovemsg = 0;
if (afternmv)
(*afternmv) ();
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.options.c
--- a/games/hack/hack.options.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.options.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.options.c,v 1.10 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.options.c,v 1.11 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.options.c,v 1.10 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.options.c,v 1.11 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -271,7 +271,7 @@
if (*--eop == ',')
*eop = 0;
}
- pline(buf);
+ pline("%s", buf);
} else
parseoptions(buf, FALSE);
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.pager.c
--- a/games/hack/hack.pager.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.pager.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.pager.c,v 1.14 2010/02/03 15:34:38 roy Exp $ */
+/* $NetBSD: hack.pager.c,v 1.15 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.pager.c,v 1.14 2010/02/03 15:34:38 roy Exp $");
+__RCSID("$NetBSD: hack.pager.c,v 1.15 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
/* This file contains the command routine dowhatis() and a pager. */
@@ -114,7 +114,7 @@
buf[0] = q;
(void) strncpy(buf + 1, " ", 7);
}
- pline(buf);
+ pline("%s", buf);
if (ep[-1] == ';') {
pline("More info? ");
if (readchar() == 'y') {
@@ -302,7 +302,7 @@
}
/* --- now we really do it --- */
if (mode == 2 && linect == 1) /* topline only */
- pline(texthead->line_text);
+ pline("%s", texthead->line_text);
else if (mode == 2) {
int curline, lth;
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.potion.c
--- a/games/hack/hack.potion.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.potion.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.potion.c,v 1.8 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.potion.c,v 1.9 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.potion.c,v 1.8 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.potion.c,v 1.9 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include "hack.h"
@@ -286,7 +286,7 @@
if (flags.beginner)
pline("You have a strange feeling for a moment, then it passes.");
else
- pline(txt);
+ pline("%s", txt);
if (!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
docall(obj);
useup(obj);
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.rumors.c
--- a/games/hack/hack.rumors.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.rumors.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.rumors.c,v 1.7 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.rumors.c,v 1.8 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.rumors.c,v 1.7 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.rumors.c,v 1.8 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include "hack.h" /* for RUMORFILE and BSD (strchr) */
@@ -115,7 +115,7 @@
if ((ep = strchr(line, '\n')) != 0)
*ep = 0;
pline("This cookie has a scrap of paper inside! It reads: ");
- pline(line);
+ pline("%s", line);
}
void
diff -r e629e9060a68 -r 7b07aeb19fec games/hack/hack.timeout.c
--- a/games/hack/hack.timeout.c Mon May 23 22:49:59 2011 +0000
+++ b/games/hack/hack.timeout.c Mon May 23 22:53:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.timeout.c,v 1.8 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.timeout.c,v 1.9 2011/05/23 22:53:25 joerg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.timeout.c,v 1.8 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.timeout.c,v 1.9 2011/05/23 22:53:25 joerg Exp $");
#endif /* not lint */
#include "hack.h"
@@ -128,7 +128,7 @@
long i = (Stoned & TIMEOUT);
if (i > 0 && i <= SIZE(stoned_texts))
- pline(stoned_texts[SIZE(stoned_texts) - i]);
+ pline("%s", stoned_texts[SIZE(stoned_texts) - i]);
if (i == 5)
Fast = 0;
if (i == 3)
Home |
Main Index |
Thread Index |
Old Index