summaryrefslogtreecommitdiff
path: root/openbsd-compat/vis.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-04-14 00:22:33 +1000
committerDamien Miller <djm@mindrot.org>2001-04-14 00:22:33 +1000
commit6e77a538ca63f2ecbab74656839e77084a2db425 (patch)
tree03dd15234a4ccc802fba338e7b1e54e3a9e71b94 /openbsd-compat/vis.c
parent92d4a020011565d766153cbf85210157c33c541c (diff)
- Sync with OpenBSD glob.c, strlcat.c and vis.c changes
Diffstat (limited to 'openbsd-compat/vis.c')
-rw-r--r--openbsd-compat/vis.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c
index f49277eb3..7eb2d6cd9 100644
--- a/openbsd-compat/vis.c
+++ b/openbsd-compat/vis.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: vis.c,v 1.5 2000/07/19 15:25:13 deraadt Exp $"; 35static char rcsid[] = "$OpenBSD: vis.c,v 1.6 2000/11/21 00:47:28 millert Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include "includes.h" 38#include "includes.h"
@@ -40,18 +40,20 @@ static char rcsid[] = "$OpenBSD: vis.c,v 1.5 2000/07/19 15:25:13 deraadt Exp $";
40#ifndef HAVE_VIS 40#ifndef HAVE_VIS
41 41
42#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') 42#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
43#define isvisible(c) (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \
44 isgraph((u_char)(c))) || \
45 ((flag & VIS_SP) == 0 && (c) == ' ') || \
46 ((flag & VIS_TAB) == 0 && (c) == '\t') || \
47 ((flag & VIS_NL) == 0 && (c) == '\n') || \
48 ((flag & VIS_SAFE) && \
49 ((c) == '\b' || (c) == '\007' || (c) == '\r')))
43 50
44/* 51/*
45 * vis - visually encode characters 52 * vis - visually encode characters
46 */ 53 */
47char *vis(char *dst, int c, int flag, int nextc) 54char *vis(char *dst, int c, int flag, int nextc)
48{ 55{
49 if (((u_int)c <= UCHAR_MAX && isascii((u_char)c) && 56 if (isvisible(c)) {
50 isgraph((u_char)c)) ||
51 ((flag & VIS_SP) == 0 && c == ' ') ||
52 ((flag & VIS_TAB) == 0 && c == '\t') ||
53 ((flag & VIS_NL) == 0 && c == '\n') ||
54 ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
55 *dst++ = c; 57 *dst++ = c;
56 if (c == '\\' && (flag & VIS_NOSLASH) == 0) 58 if (c == '\\' && (flag & VIS_NOSLASH) == 0)
57 *dst++ = '\\'; 59 *dst++ = '\\';