Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/comsat Fix output to a tty that is missing ONLCR (eg...
details: https://anonhg.NetBSD.org/src/rev/b9a850488968
branches: trunk
changeset: 507120:b9a850488968
user: atatat <atatat%NetBSD.org@localhost>
date: Wed Mar 14 04:39:42 2001 +0000
description:
Fix output to a tty that is missing ONLCR (eg emacs, vi, mutt,
etc.). This became broken when strvis(3) started being used instead
of simply scanning for "bad" characters.
diffstat:
libexec/comsat/comsat.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (49 lines):
diff -r ccfceb027e9a -r b9a850488968 libexec/comsat/comsat.c
--- a/libexec/comsat/comsat.c Wed Mar 14 03:51:46 2001 +0000
+++ b/libexec/comsat/comsat.c Wed Mar 14 04:39:42 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: comsat.c,v 1.19 2001/02/19 22:46:13 cgd Exp $ */
+/* $NetBSD: comsat.c,v 1.20 2001/03/14 04:39:42 atatat Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "from: @(#)comsat.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: comsat.c,v 1.19 2001/02/19 22:46:13 cgd Exp $");
+__RCSID("$NetBSD: comsat.c,v 1.20 2001/03/14 04:39:42 atatat Exp $");
#endif
#endif /* not lint */
@@ -261,7 +261,7 @@
{
FILE *fi;
int linecnt, charcnt, inheader;
- char line[BUFSIZ], visline[BUFSIZ*4];
+ char line[BUFSIZ], visline[BUFSIZ*4], *nl;
if ((fi = fopen(name, "r")) == NULL)
return;
@@ -276,6 +276,7 @@
charcnt = 560;
inheader = 1;
while (fgets(line, sizeof(line), fi) != NULL) {
+ line[sizeof(line) - 1] = '\0';
if (inheader) {
if (line[0] == '\n') {
inheader = 0;
@@ -291,9 +292,12 @@
(void)fclose(fi);
return;
}
+ if ((nl = strchr(line, '\n')) != NULL)
+ *nl = '\0';
/* strip weird stuff so can't trojan horse stupid terminals */
(void)strvis(visline, line, VIS_CSTYLE);
- fputs(visline, tp);
+ (void)fputs(visline, tp);
+ (void)fputs(cr, tp);
--linecnt;
}
(void)fprintf(tp, "----%s\n", cr);
Home |
Main Index |
Thread Index |
Old Index