diff options
author | phk <phk@FreeBSD.org> | 2003-10-30 10:40:49 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-10-30 10:40:49 +0000 |
commit | eae6949d99a11d72cef4ef9015743ae44c91c6d1 (patch) | |
tree | b475e5fcaa9bc6f1821bb3284b36570c3410a4fd /lib | |
parent | bbdba26328b9b5d6bc1b53351610790f6dc448c6 (diff) | |
download | FreeBSD-src-eae6949d99a11d72cef4ef9015743ae44c91c6d1.zip FreeBSD-src-eae6949d99a11d72cef4ef9015743ae44c91c6d1.tar.gz |
Add a new flag to vis(3): VIS_GLOB which encodes the glob(3) magic
characters '*', '?' and '['.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/vis.3 | 3 | ||||
-rw-r--r-- | lib/libc/gen/vis.c | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3 index 6f685a9..25f1365 100644 --- a/lib/libc/gen/vis.3 +++ b/lib/libc/gen/vis.3 @@ -137,6 +137,9 @@ except space, tab, and newline are encoded. The following flags alter this: .Bl -tag -width VIS_WHITEX +.It Dv VIS_GLOB +Also encode magic characters ('*', '?', '[') recognized by +.Xr glob 3 .It Dv VIS_SP Also encode space. .It Dv VIS_TAB diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c index 8868a70..4f594eb 100644 --- a/lib/libc/gen/vis.c +++ b/lib/libc/gen/vis.c @@ -71,7 +71,9 @@ vis(dst, c, flag, nextc) } } - if (isgraph(c) || + if ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[')) + ; + else if (isgraph(c) || ((flag & VIS_SP) == 0 && c == ' ') || ((flag & VIS_TAB) == 0 && c == '\t') || ((flag & VIS_NL) == 0 && c == '\n') || @@ -127,7 +129,7 @@ vis(dst, c, flag, nextc) goto done; } } - if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) { + if (((c & 0177) == ' ') || isgraph(c) || (flag & VIS_OCTAL)) { *dst++ = '\\'; *dst++ = ((u_char)c >> 6 & 07) + '0'; *dst++ = ((u_char)c >> 3 & 07) + '0'; |