* fix a long-term annoyance with tip: if raisechar or force are set to

"", (usually in .tiprc with lines like `raisechar='), don't activate
  feature if NUL (\0) is the received character
* on a related note, don't barf if the following variables are defined
  to "": disconnect, log, parity, record
This commit is contained in:
lukem 1997-11-22 08:29:58 +00:00
parent e37283e126
commit 6b9d2f6aae
3 changed files with 20 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.8 1997/11/22 07:28:41 lukem Exp $ */
/* $NetBSD: cmds.c,v 1.9 1997/11/22 08:29:58 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: cmds.c,v 1.8 1997/11/22 07:28:41 lukem Exp $");
__RCSID("$NetBSD: cmds.c,v 1.9 1997/11/22 08:29:58 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -628,7 +628,7 @@ setscript()
* enable TIPOUT side for dialogue
*/
kill(pid, SIGEMT);
if (boolean(value(SCRIPT)))
if (boolean(value(SCRIPT)) && strlen(value(RECORD)))
write(fildes[1], value(RECORD), strlen(value(RECORD)));
write(fildes[1], "\n", 1);
/*
@ -682,7 +682,8 @@ finish(dummy)
{
char *dismsg;
if ((dismsg = value(DISCONNECT)) != NULL) {
dismsg = value(DISCONNECT);
if (dismsg != NULL && dismsg[0] != '\0') {
write(FD, dismsg, strlen(dismsg));
sleep(5);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: log.c,v 1.5 1997/11/22 07:28:44 lukem Exp $ */
/* $NetBSD: log.c,v 1.6 1997/11/22 08:29:59 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: log.c,v 1.5 1997/11/22 07:28:44 lukem Exp $");
__RCSID("$NetBSD: log.c,v 1.6 1997/11/22 08:29:59 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -87,8 +87,13 @@ logent(group, num, acu, message)
void
loginit()
{
flog = fopen(value(LOG), "a");
char *logfile;
logfile = value(LOG);
if (logfile[0] == '\0') /* sanity check */
return;
flog = fopen(logfile, "a");
if (flog == NULL)
fprintf(stderr, "can't open log file %s.\r\n", value(LOG));
fprintf(stderr, "can't open log file %s.\r\n", logfile);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: tip.c,v 1.15 1997/11/22 07:28:47 lukem Exp $ */
/* $NetBSD: tip.c,v 1.16 1997/11/22 08:30:01 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: tip.c,v 1.15 1997/11/22 07:28:47 lukem Exp $");
__RCSID("$NetBSD: tip.c,v 1.16 1997/11/22 08:30:01 lukem Exp $");
#endif /* not lint */
/*
@ -101,7 +101,6 @@ main(argc, argv)
exit(1);
}
/* XXX: use getopt */
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
system = argv[1];
@ -385,7 +384,8 @@ tipin()
if ((gch == character(value(ESCAPE))) && bol) {
if (!(gch = escape()))
continue;
} else if (!cumode && gch == character(value(RAISECHAR))) {
} else if (!cumode &&
gch && gch == character(value(RAISECHAR))) {
setboolean(value(RAISE), !boolean(value(RAISE)));
continue;
} else if (gch == '\r') {
@ -394,7 +394,7 @@ tipin()
if (boolean(value(HALFDUPLEX)))
printf("\r\n");
continue;
} else if (!cumode && gch == character(value(FORCE)))
} else if (!cumode && gch && gch == character(value(FORCE)))
gch = getchar()&STRIP_PAR;
bol = any(gch, value(EOL));
if (boolean(value(RAISE)) && islower(gch))
@ -581,7 +581,7 @@ setparity(defparity)
int i, flip, clr, set;
char *parity;
if (value(PARITY) == NULL)
if (value(PARITY) == NULL || (value(PARITY))[0] == '\0')
value(PARITY) = defparity;
parity = value(PARITY);
if (equal(parity, "none")) {