replace old zzhack structure (YUCK!) and number(), boolean(), character(),

and address() macros with new macros of the same names (to get values),
and macros with those names but with "set" prepended and which take a
second argument (to set values).  The new macros use type casts to do
type conversion, which is much cleaner than using a union and making
endianness-related hacks to get the right 'short's and 'char's from
the right array indices.  (YUCK! again, for good measure.)
This commit is contained in:
cgd 1996-12-29 10:34:03 +00:00
parent f029ade219
commit 88caf985e6
7 changed files with 43 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: acu.c,v 1.3 1994/12/08 09:30:39 jtc Exp $ */
/* $NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $ */
/*
* Copyright (c) 1983, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: acu.c,v 1.3 1994/12/08 09:30:39 jtc Exp $";
static char rcsid[] = "$NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $";
#endif /* not lint */
#include "tip.h"
@ -89,7 +89,7 @@ connect()
printf("\ncall aborted\n");
logent(value(HOST), "", "", "call aborted");
if (acu != NOACU) {
boolean(value(VERBOSE)) = FALSE;
setboolean(value(VERBOSE), FALSE);
if (conflag)
disconnect(NOSTR);
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: cu.c,v 1.3 1994/12/08 09:30:48 jtc Exp $ */
/* $NetBSD: cu.c,v 1.4 1996/12/29 10:34:07 cgd Exp $ */
/*
* Copyright (c) 1983, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: cu.c,v 1.3 1994/12/08 09:30:48 jtc Exp $";
static char rcsid[] = "$NetBSD: cu.c,v 1.4 1996/12/29 10:34:07 cgd Exp $";
#endif /* not lint */
#include "tip.h"
@ -123,7 +123,7 @@ cumain(argc, argv)
user_uid();
vinit();
setparity("none");
boolean(value(VERBOSE)) = 0;
setboolean(value(VERBOSE), 0);
if (HW)
ttysetup(speed(BR));
if (connect()) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: remote.c,v 1.3 1994/12/08 09:31:03 jtc Exp $ */
/* $NetBSD: remote.c,v 1.4 1996/12/29 10:34:08 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: remote.c,v 1.3 1994/12/08 09:31:03 jtc Exp $";
static char rcsid[] = "$NetBSD: remote.c,v 1.4 1996/12/29 10:34:08 cgd Exp $";
#endif /* not lint */
#include <stdio.h>
@ -153,29 +153,29 @@ getremcap(host)
* see if uppercase mode should be turned on initially
*/
if (cgetflag("ra"))
boolean(value(RAISE)) = 1;
setboolean(value(RAISE), 1);
if (cgetflag("ec"))
boolean(value(ECHOCHECK)) = 1;
setboolean(value(ECHOCHECK), 1);
if (cgetflag("be"))
boolean(value(BEAUTIFY)) = 1;
setboolean(value(BEAUTIFY), 1);
if (cgetflag("nb"))
boolean(value(BEAUTIFY)) = 0;
setboolean(value(BEAUTIFY), 0);
if (cgetflag("sc"))
boolean(value(SCRIPT)) = 1;
setboolean(value(SCRIPT), 1);
if (cgetflag("tb"))
boolean(value(TABEXPAND)) = 1;
setboolean(value(TABEXPAND), 1);
if (cgetflag("vb"))
boolean(value(VERBOSE)) = 1;
setboolean(value(VERBOSE), 1);
if (cgetflag("nv"))
boolean(value(VERBOSE)) = 0;
setboolean(value(VERBOSE), 0);
if (cgetflag("ta"))
boolean(value(TAND)) = 1;
setboolean(value(TAND), 1);
if (cgetflag("nt"))
boolean(value(TAND)) = 0;
setboolean(value(TAND), 0);
if (cgetflag("rw"))
boolean(value(RAWFTP)) = 1;
setboolean(value(RAWFTP), 1);
if (cgetflag("hd"))
boolean(value(HALFDUPLEX)) = 1;
setboolean(value(HALFDUPLEX), 1);
if (RE == NOSTR)
RE = (char *)"tip.record";
if (EX == NOSTR)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $ */
/* $NetBSD: tip.c,v 1.9 1996/12/29 10:34:10 cgd Exp $ */
/*
* Copyright (c) 1983, 1993
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $";
static char rcsid[] = "$NetBSD: tip.c,v 1.9 1996/12/29 10:34:10 cgd Exp $";
#endif /* not lint */
/*
@ -360,7 +360,7 @@ tipin()
if (!(gch = escape()))
continue;
} else if (!cumode && gch == character(value(RAISECHAR))) {
boolean(value(RAISE)) = !boolean(value(RAISE));
setboolean(value(RAISE), !boolean(value(RAISE)));
continue;
} else if (gch == '\r') {
bol = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tip.h,v 1.4 1995/10/29 00:49:43 pk Exp $ */
/* $NetBSD: tip.h,v 1.5 1996/12/29 10:34:11 cgd Exp $ */
/*
* Copyright (c) 1989, 1993
@ -144,30 +144,18 @@ typedef
* initialize it in vars.c, so we cast it as needed to keep lint
* happy.
*/
typedef
union {
int zz_number;
short zz_boolean[2];
char zz_character[4];
int *zz_address;
}
zzhack;
#define value(v) vtable[v].v_value
#define number(v) ((((zzhack *)(&(v))))->zz_number)
#define number(v) ((long)(v))
#define boolean(v) ((short)(long)(v))
#define character(v) ((char)(long)(v))
#define address(v) ((long *)(v))
#if BYTE_ORDER == LITTLE_ENDIAN
#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0])
#define character(v) ((((zzhack *)(&(v))))->zz_character[0])
#endif
#if BYTE_ORDER == BIG_ENDIAN
#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1])
#define character(v) ((((zzhack *)(&(v))))->zz_character[3])
#endif
#define address(v) ((((zzhack *)(&(v))))->zz_address)
#define setnumber(v,n) do { (v) = (char *)(long)(n); } while (0)
#define setboolean(v,n) do { (v) = (char *)(long)(n); } while (0)
#define setcharacter(v,n) do { (v) = (char *)(long)(n); } while (0)
#define setaddress(v,n) do { (v) = (char *)(n); } while (0)
/*
* Escape command table definitions --

View File

@ -1,4 +1,4 @@
/* $NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $ */
/* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */
/*
* Copyright (c) 1983, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $";
static char rcsid[] = "$NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $";
#endif /* not lint */
#include "tip.h"
@ -83,14 +83,14 @@ intEMT()
if (boolean(value(SCRIPT)) && fscript != NULL)
fclose(fscript);
if (pline == line) {
boolean(value(SCRIPT)) = FALSE;
setboolean(value(SCRIPT), FALSE);
reply = 'y';
} else {
if ((fscript = fopen(line, "a")) == NULL)
reply = 'n';
else {
reply = 'y';
boolean(value(SCRIPT)) = TRUE;
setboolean(value(SCRIPT), TRUE);
}
}
write(repdes[1], &reply, 1);
@ -110,7 +110,7 @@ void
intSYS()
{
boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY));
setboolean(value(BEAUTIFY), !boolean(value(BEAUTIFY)));
longjmp(sigbuf, 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: value.c,v 1.3 1994/12/08 09:31:17 jtc Exp $ */
/* $NetBSD: value.c,v 1.4 1996/12/29 10:34:14 cgd Exp $ */
/*
* Copyright (c) 1983, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: value.c,v 1.3 1994/12/08 09:31:17 jtc Exp $";
static char rcsid[] = "$NetBSD: value.c,v 1.4 1996/12/29 10:34:14 cgd Exp $";
#endif /* not lint */
#include "tip.h"
@ -62,7 +62,7 @@ vinit()
if (cp = getenv(p->v_name))
p->v_value = cp;
if (p->v_type&IREMOTE)
number(p->v_value) = *address(p->v_value);
setnumber(p->v_value, *address(p->v_value));
}
/*
* Read the .tiprc file in the HOME directory
@ -118,19 +118,19 @@ vassign(p, v)
case NUMBER:
if (number(p->v_value) == number(v))
return;
number(p->v_value) = number(v);
setnumber(p->v_value, number(v));
break;
case BOOL:
if (boolean(p->v_value) == (*v != '!'))
return;
boolean(p->v_value) = (*v != '!');
setboolean(p->v_value, (*v != '!'));
break;
case CHAR:
if (character(p->v_value) == *v)
return;
character(p->v_value) = *v;
setcharacter(p->v_value, *v);
}
p->v_access |= CHANGED;
}