* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)vis.c 5.3 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
* vis - visually encode characters
if (isascii(c
) && isgraph(c
) ||
((flag
& VIS_SP
) == 0 && c
== ' ') ||
((flag
& VIS_TAB
) == 0 && c
== '\t') ||
((flag
& VIS_NL
) == 0 && c
== '\n') ||
((flag
& VIS_SAFE
) && (c
== '\b' || c
== '\007' || c
== '\r'))) {
if (c
== '\\' && (flag
& VIS_NOSLASH
) == 0)
case '\007': /* waiting for ansi compiler */
if (((c
& 0177) == ' ') || (flag
& VIS_OCTAL
)) {
*dst
++ = ((u_char
)c
>> 6 & 07) + '0';
*dst
++ = ((u_char
)c
>> 3 & 07) + '0';
*dst
++ = ((u_char
)c
& 07) + '0';
if ((flag
& VIS_NOSLASH
) == 0)
* strvis, strvisx - visually encode characters from src into dst
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
register char *dst
, *src
;
dst
= vis(dst
, c
, flag
, *(src
+1));
strvisx(dst
, src
, len
, flag
)
register char *dst
, *src
;
dst
= vis(dst
, *src
, flag
, *(src
+1));
dst
= vis(dst
, *src
, flag
, '\0');