lev_comp int vs long

Fix lev_comp's variable argument usage by changing it to make
add_opvars() expect an int rather than a long when given the "i"
indicator, and add "l" for really passing a long.  The ints are
conveted to longs when setting up the interpreter.  I think I changed
just about all the integer opvars to int, although there is one use
of "l" in lev_main.c just to make sure it works.  There could be
arguments that really do need to be 'long'; if so, the add_opvars()
calls for them will have to have its indicator string updated and
possibly add or remove some casts.

There's a lot of reformatting included but it's not consistent about
tab replacement.  Some of the changes are due to renaming long-named
'variable_definitions' to 'vardefs' to shorten a bunch of lines.

Updated sys/share/*_yacc.c will be checked in separately.  The ones
currently in the repository won't work with patched lev_main.c due to
that renamed variable.
This commit is contained in:
PatR
2018-11-27 18:21:58 -08:00
parent 554ec17c8b
commit 5d2686e7c1
6 changed files with 242 additions and 171 deletions
+15 -6
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 lev_main.c $NHDT-Date: 1501723418 2017/08/03 01:23:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.47 $ */
/* NetHack 3.6 lev_main.c $NHDT-Date: 1543371692 2018/11/28 02:21:32 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.56 $ */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
@@ -226,7 +226,7 @@ extern int nh_line_number;
extern int token_start_pos;
extern char curr_token[512];
struct lc_vardefs *variable_definitions = NULL;
struct lc_vardefs *vardefs = NULL;
struct lc_funcdefs *function_definitions = NULL;
extern int allow_break_statements;
@@ -641,9 +641,18 @@ VA_DECL2(sp_lev *, sp, const char *, fmt)
switch (*p) {
case ' ':
break;
case 'i': /* integer */
case 'i': /* integer (via plain 'int') */
{
struct opvar *ov = New(struct opvar);
set_opvar_int(ov, (long) VA_NEXT(la, int));
add_opcode(sp, SPO_PUSH, ov);
break;
}
case 'l': /* integer (via 'long int') */
{
struct opvar *ov = New(struct opvar);
set_opvar_int(ov, VA_NEXT(la, long));
add_opcode(sp, SPO_PUSH, ov);
break;
@@ -1105,8 +1114,8 @@ char *ldfname;
(*splev)->n_opcodes = 0;
(*splev)->opcodes = NULL;
vardef_free_all(variable_definitions);
variable_definitions = NULL;
vardef_free_all(vardefs);
vardefs = NULL;
}
/*
@@ -1436,7 +1445,7 @@ sp_lev *sp;
mbuf[((max_hig - 1) * max_len) + (max_len - 1) + 1] = '\0';
add_opvars(sp, "siio", VA_PASS4(mbuf, (long) max_hig, (long) max_len,
add_opvars(sp, "sllo", VA_PASS4(mbuf, (long) max_hig, (long) max_len,
SPO_MAP));
for (dy = 0; dy < max_hig; dy++)