summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-03-13 23:11:17 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-03-13 23:11:17 +0000
commit0596009da3c2f5570c42b308f42df9ef9a19769f (patch)
treeb7e4aa8e2dbe026ab697b3ea97f2cb50b509645c
parentbd0d52a022b4c7a44957ca1a66183e9c86f241c3 (diff)
fix printing of "" and other weird chars. from alexander@beard.se
closes pr3146 and pr3147 ok millert@
-rw-r--r--usr.bin/banner/banner.c20
-rw-r--r--usr.bin/banner/banner.h3
-rw-r--r--usr.bin/banner/chset.c4
3 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/banner/banner.c b/usr.bin/banner/banner.c
index 0142bd30d4d..0c4c220f9c8 100644
--- a/usr.bin/banner/banner.c
+++ b/usr.bin/banner/banner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: banner.c,v 1.5 2001/11/19 19:02:13 mpech Exp $ */
+/* $OpenBSD: banner.c,v 1.6 2003/03/13 23:11:16 tedu Exp $ */
/* $NetBSD: banner.c,v 1.2 1995/04/09 06:00:15 cgd Exp $ */
/*
@@ -53,16 +53,13 @@
* SUCH DAMAGE.
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
#if 0
static char sccsid[] = "@(#)printjob.c 8.2 (Berkeley) 4/16/94";
#else
-static char rcsid[] = "$OpenBSD: banner.c,v 1.5 2001/11/19 19:02:13 mpech Exp $";
+static const char rcsid[] = "$OpenBSD: banner.c,v 1.6 2003/03/13 23:11:16 tedu Exp $";
#endif
#endif /* not lint */
@@ -139,15 +136,20 @@ scan_out(scfd, scsp, dlm)
for (scnhgt = 0; scnhgt++ < HEIGHT+DROP; ) {
strp = &outbuf[0];
sp = scsp;
- for (nchrs = 0; ; ) {
- c = TRC(cc = *sp++);
+ for (nchrs = 0; *sp != dlm && *sp != '\0'; ) {
+ cc = *sp++;
+ if ((unsigned char)cc < ' ' ||
+ (unsigned char)cc > 0x7f)
+ cc = INVALID;
+
+ c = TRC(cc);
d = dropit(c);
if ((!d && scnhgt > HEIGHT) || (scnhgt <= DROP && d))
for (j = WIDTH; --j;)
*strp++ = BACKGND;
else
strp = scnline(scnkey[(int)c][scnhgt-1-d], strp, cc);
- if (*sp == dlm || *sp == '\0' || nchrs++ >= PW/(WIDTH+1)-1)
+ if (nchrs++ >= PW/(WIDTH+1)-1)
break;
*strp++ = BACKGND;
#ifdef LPD_CHSET /* <sjg> */
diff --git a/usr.bin/banner/banner.h b/usr.bin/banner/banner.h
index c3b192f0d52..71398172305 100644
--- a/usr.bin/banner/banner.h
+++ b/usr.bin/banner/banner.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: banner.h,v 1.2 1996/06/26 05:31:34 deraadt Exp $ */
+/* $OpenBSD: banner.h,v 1.3 2003/03/13 23:11:16 tedu Exp $ */
/* $NetBSD: banner.h,v 1.2 1995/04/09 06:00:23 cgd Exp $ */
/*
@@ -22,6 +22,7 @@
#define LINELEN 132
#define BACKGND ' '
+#define INVALID '_'
#ifdef LPD_CHSET
#define HEIGHT 9 /* height of characters */
diff --git a/usr.bin/banner/chset.c b/usr.bin/banner/chset.c
index 6d63ed39c8d..2f906a0888c 100644
--- a/usr.bin/banner/chset.c
+++ b/usr.bin/banner/chset.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chset.c,v 1.2 1996/06/26 05:31:35 deraadt Exp $ */
+/* $OpenBSD: chset.c,v 1.3 2003/03/13 23:11:16 tedu Exp $ */
/* $NetBSD: chset.c,v 1.2 1995/04/09 06:00:26 cgd Exp $ */
/*
@@ -56,7 +56,7 @@
#if 0
static char sccsid[] = "@(#)lpdchar.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: chset.c,v 1.2 1996/06/26 05:31:35 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: chset.c,v 1.3 2003/03/13 23:11:16 tedu Exp $";
#endif
#endif /* not lint */