summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2000-07-23 21:35:01 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2000-07-23 21:35:01 +0000
commitbb6ee9445b49236cf0f512084eb9cfb7c27b91fe (patch)
treef9ecc7b9713b531d2b33f45b1e85cbfb5c745a55
parentc56aedb53d54056ee135ae50bdfc16e586b0fe9d (diff)
Avoid calling functions that can call the exit-on-error handler from the
handler; use STD*_FILENO rather than 0-2.
-rw-r--r--games/backgammon/common_source/fancy.c7
-rw-r--r--games/backgammon/common_source/subs.c19
2 files changed, 15 insertions, 11 deletions
diff --git a/games/backgammon/common_source/fancy.c b/games/backgammon/common_source/fancy.c
index d1d5fe86447..315d39dd643 100644
--- a/games/backgammon/common_source/fancy.c
+++ b/games/backgammon/common_source/fancy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fancy.c,v 1.8 2000/04/21 03:10:30 pjanzen Exp $ */
+/* $OpenBSD: fancy.c,v 1.9 2000/07/23 21:35:00 pjanzen Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: fancy.c,v 1.8 2000/04/21 03:10:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: fancy.c,v 1.9 2000/07/23 21:35:00 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -474,7 +474,8 @@ newpos()
switch (mode) {
case -1: /* error! */
- write(2, "\r\nInternal cursor error.\r\n", 26);
+ write(STDERR_FILENO, "\r\nInternal cursor error.\r\n", 26);
+ tflag = 0; /* So we don't loop */
getout(0);
case 0: /* direct cursor motion */
diff --git a/games/backgammon/common_source/subs.c b/games/backgammon/common_source/subs.c
index 74492085889..c891a58c3e2 100644
--- a/games/backgammon/common_source/subs.c
+++ b/games/backgammon/common_source/subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subs.c,v 1.9 2000/04/21 03:10:30 pjanzen Exp $ */
+/* $OpenBSD: subs.c,v 1.10 2000/07/23 21:35:00 pjanzen Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: subs.c,v 1.9 2000/04/21 03:10:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: subs.c,v 1.10 2000/07/23 21:35:00 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -67,7 +67,7 @@ void
errexit(s)
const char *s;
{
- write(2, "\n", 1);
+ write(STDERR_FILENO, "\n", 1);
perror(s);
getout(0);
}
@@ -78,7 +78,7 @@ addbuf(c)
{
buffnum++;
if (buffnum == BUFSIZ) {
- if (write(1, outbuff, BUFSIZ) != BUFSIZ)
+ if (write(STDOUT_FILENO, outbuff, BUFSIZ) != BUFSIZ)
errexit("addbuf (write):");
buffnum = 0;
}
@@ -92,7 +92,7 @@ buflush()
if (buffnum < 0)
return;
buffnum++;
- if (write(1, outbuff, buffnum) != buffnum)
+ if (write(STDOUT_FILENO, outbuff, buffnum) != buffnum)
errexit("buflush (write):");
buffnum = -1;
}
@@ -418,7 +418,7 @@ fixtty(t)
if (tflag)
newpos();
buflush();
- if (tcsetattr(0, TCSADRAIN, t) < 0)
+ if (tcsetattr(STDIN_FILENO, TCSADRAIN, t) < 0)
errexit("fixtty");
}
@@ -430,11 +430,14 @@ getout(dummy)
if (tflag) {
curmove(23, 0);
cline();
+ newpos();
} else
writec('\n');
- /* fix terminal status */
- fixtty(&old);
+ /* fix terminal status; avoid calling fixtty() to avoid loop */
+ if (buffnum >= 0)
+ write(STDOUT_FILENO, outbuff, buffnum + 1);
+ tcsetattr(STDIN_FILENO, TCSADRAIN, &old);
exit(0);
}