summaryrefslogtreecommitdiffstats
path: root/hack/hack.invent.c
diff options
context:
space:
mode:
Diffstat (limited to 'hack/hack.invent.c')
-rw-r--r--hack/hack.invent.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/hack/hack.invent.c b/hack/hack.invent.c
index 8b1e7cc8..3d7d8377 100644
--- a/hack/hack.invent.c
+++ b/hack/hack.invent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.invent.c,v 1.12 2009/06/07 20:13:18 dholland Exp $ */
+/* $NetBSD: hack.invent.c,v 1.13 2009/06/29 23:05:33 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,9 +63,10 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.invent.c,v 1.12 2009/06/07 20:13:18 dholland Exp $");
+__RCSID("$NetBSD: hack.invent.c,v 1.13 2009/06/29 23:05:33 dholland Exp $");
#endif /* not lint */
+#include <assert.h>
#include <stdlib.h>
#include "hack.h"
#include "extern.h"
@@ -555,7 +556,7 @@ ggetobj(const char *word, int (*fn)(struct obj *), int max)
char buf[BUFSZ];
char *ip;
char sym;
- int oletct = 0, iletct = 0;
+ unsigned oletct = 0, iletct = 0;
boolean allflag = FALSE;
char olets[20], ilets[20];
int (*ckfn)(struct obj *) =
@@ -586,6 +587,7 @@ ggetobj(const char *word, int (*fn)(struct obj *), int max)
if (invent)
ilets[iletct++] = 'a';
ilets[iletct] = 0;
+ assert(iletct < sizeof(ilets));
}
pline("What kinds of thing do you want to %s? [%s] ",
word, ilets);
@@ -614,6 +616,7 @@ ggetobj(const char *word, int (*fn)(struct obj *), int max)
olets[oletct++] = sym;
olets[oletct] = 0;
}
+ assert(oletct < sizeof(olets));
} else
pline("You don't have any %c's.", sym);
}
@@ -723,7 +726,7 @@ doinv(char *lets)
{
struct obj *otmp;
char ilet;
- int ct = 0;
+ unsigned ct = 0;
char any[BUFSZ];
morc = 0; /* just to be sure */
@@ -746,6 +749,7 @@ doinv(char *lets)
ilet = 'A';
}
any[ct] = 0;
+ assert(ct < sizeof(any));
cornline(2, any);
}
@@ -755,7 +759,7 @@ dotypeinv(void)
/* Changed to one type only, so he doesnt have to type cr */
char c, ilet;
char stuff[BUFSZ];
- int stct;
+ unsigned stct;
struct obj *otmp;
boolean billx = inshop() && doinvbill(0);
boolean unpd = FALSE;
@@ -781,6 +785,7 @@ dotypeinv(void)
if (billx)
stuff[stct++] = 'x';
stuff[stct] = 0;
+ assert(stct < sizeof(stuff));
if (stct > 1) {
pline("What type of object [%s] do you want an inventory of? ",
@@ -817,6 +822,8 @@ dotypeinv(void)
ilet = 'A';
}
stuff[stct] = '\0';
+ assert(stct < sizeof(stuff));
+
if (stct == 0)
pline("You have no such objects.");
else