Lowering the scope And cleaning up some warnings from static analysis
This commit is contained in:
parent
7c9a0bfb36
commit
46bb20deb3
6 changed files with 11 additions and 15 deletions
|
@ -774,11 +774,10 @@ static int quit(FILE *input)
|
|||
static int read(FILE *input, token_t verb, token_t obj)
|
||||
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
|
||||
{
|
||||
int i;
|
||||
int spk = ACTSPK[verb];
|
||||
if (obj == INTRANSITIVE) {
|
||||
obj = 0;
|
||||
for (i=1; i<=NOBJECTS; i++) {
|
||||
for (int i=1; i<=NOBJECTS; i++) {
|
||||
if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
|
||||
obj = obj * NOBJECTS + i;
|
||||
}
|
||||
|
|
2
advent.h
2
advent.h
|
@ -82,7 +82,7 @@ extern bool oldstyle, editline, prompt;
|
|||
#define READ_MODE "rb"
|
||||
#define WRITE_MODE "wb"
|
||||
extern char* xstrdup(const char*);
|
||||
extern void packed_to_token(long, char token[6]);
|
||||
extern void packed_to_token(long, char token[]);
|
||||
extern void newspeak(char*);
|
||||
extern void PSPEAK(vocab_t,int);
|
||||
extern void RSPEAK(vocab_t);
|
||||
|
|
|
@ -197,7 +197,7 @@ void MAPLIN(FILE *OPENED) {
|
|||
while (!feof(OPENED) && INLINE[1] == '#');
|
||||
|
||||
LNLENG = 0;
|
||||
for (size_t i = 1; i <= sizeof(INLINE) && INLINE[i] != 0; ++i)
|
||||
for (size_t i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i)
|
||||
{
|
||||
char val = INLINE[i];
|
||||
INLINE[i] = ascii_to_advent[(unsigned)val];
|
||||
|
@ -214,7 +214,7 @@ long GETNUM(FILE *source) {
|
|||
* scanned). If we're at the end of the line or encounter an illegal
|
||||
* character (not a digit, hyphen, or blank), we return 0. */
|
||||
|
||||
long DIGIT, GETNUM, SIGN;
|
||||
long GETNUM, SIGN;
|
||||
|
||||
if(source != NULL) MAPLIN(source);
|
||||
GETNUM = 0;
|
||||
|
@ -235,7 +235,7 @@ long GETNUM(FILE *source) {
|
|||
}
|
||||
while (!(LNPOSN > LNLENG || INLINE[LNPOSN] == 0))
|
||||
{
|
||||
DIGIT=INLINE[LNPOSN]-64;
|
||||
long DIGIT=INLINE[LNPOSN]-64;
|
||||
if(DIGIT < 0 || DIGIT > 9)
|
||||
{
|
||||
GETNUM=0;
|
||||
|
|
3
main.c
3
main.c
|
@ -860,10 +860,9 @@ static void listobjects(void)
|
|||
* get full score. */
|
||||
{
|
||||
if (!DARK(game.loc)) {
|
||||
long obj;
|
||||
++game.abbrev[game.loc];
|
||||
for (int i=game.atloc[game.loc]; i != 0; i=game.link[i]) {
|
||||
obj=i;
|
||||
long obj=i;
|
||||
if (obj > NOBJECTS)obj=obj-NOBJECTS;
|
||||
if (obj == STEPS && TOTING(NUGGET))
|
||||
continue;
|
||||
|
|
7
misc.c
7
misc.c
|
@ -541,7 +541,6 @@ void BUG(long num)
|
|||
|
||||
bool MAPLIN(FILE *fp)
|
||||
{
|
||||
long i, val;
|
||||
bool eof;
|
||||
|
||||
/* Read a line of input, from the specified input source.
|
||||
|
@ -577,7 +576,7 @@ bool MAPLIN(FILE *fp)
|
|||
if (!eof) {
|
||||
strncpy(rawbuf, cp, sizeof(rawbuf)-1);
|
||||
linenoiseHistoryAdd(rawbuf);
|
||||
strncat(rawbuf, "\n", sizeof(rawbuf)-1);
|
||||
strncat(rawbuf, "\n", sizeof(rawbuf) - strlen(rawbuf) - 1);
|
||||
linenoiseFree(cp);
|
||||
}
|
||||
}
|
||||
|
@ -624,8 +623,8 @@ bool MAPLIN(FILE *fp)
|
|||
* and is not changed thereafter unless the routines on this page choose
|
||||
* to do so. */
|
||||
LNLENG=0;
|
||||
for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
|
||||
val=INLINE[i];
|
||||
for (long i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
|
||||
long val=INLINE[i];
|
||||
INLINE[i]=ascii_to_advent[val];
|
||||
if (INLINE[i] != 0)
|
||||
LNLENG=i;
|
||||
|
|
|
@ -33,8 +33,7 @@ int saveresume(FILE *input, bool resume)
|
|||
{
|
||||
long i, k;
|
||||
FILE *fp = NULL;
|
||||
char *name;
|
||||
|
||||
|
||||
if (!resume) {
|
||||
/* Suspend. Offer to save things in a file, but charging
|
||||
* some points (so can't win by using saved games to retry
|
||||
|
@ -53,7 +52,7 @@ int saveresume(FILE *input, bool resume)
|
|||
}
|
||||
|
||||
while (fp == NULL) {
|
||||
name = linenoise("\nFile name: ");
|
||||
char* name = linenoise("\nFile name: ");
|
||||
if (name == NULL)
|
||||
return GO_TOP;
|
||||
fp = fopen(name,(resume ? READ_MODE : WRITE_MODE));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue