date and time created 89/05/23 10:06:08 by bostic
[unix-history] / usr / src / old / lib2648 / rdchar.c
CommitLineData
97e3edfb
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
8static char sccsid[] = "@(#)rdchar.c 5.1 (Berkeley) %G%";
9#endif not lint
10
d9fde7be
RC
11/*
12 * rdchar: returns a readable representation of an ASCII char, using ^ notation.
13 */
14
15#include <ctype.h>
16
17char *rdchar(c)
18char c;
19{
20 static char ret[4];
21 register char *p;
22
23 /*
24 * Due to a bug in isprint, this prints spaces as ^`, but this is OK
25 * because we want something to show up on the screen.
26 */
27 ret[0] = ((c&0377) > 0177) ? '\'' : ' ';
28 c &= 0177;
29 ret[1] = isprint(c) ? ' ' : '^';
30 ret[2] = isprint(c) ? c : c^0100;
31 ret[3] = 0;
32 for (p=ret; *p==' '; p++)
33 ;
34 return (p);
35}