Vendor import of NetBSD's (un)vis(3) at 2012-12-14

This commit is contained in:
Brooks Davis 2012-12-14 22:45:03 +00:00
parent 5f6a0f033f
commit 2efa758bee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/libc-vis/dist/; revision=244230
svn path=/vendor/NetBSD/libc-vis/20121412/; revision=244231; tag=vendor/NetBSD/libc-vis/20121214
4 changed files with 39 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: unvis.c,v 1.39 2012/03/13 21:13:37 christos Exp $ */
/* $NetBSD: unvis.c,v 1.40 2012/12/14 21:31:01 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: unvis.c,v 1.39 2012/03/13 21:13:37 christos Exp $");
__RCSID("$NetBSD: unvis.c,v 1.40 2012/12/14 21:31:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -81,7 +81,7 @@ __weak_alias(strnunvisx,_strnunvisx)
* RFC 1866
*/
static const struct nv {
const char *name;
const char name[7];
uint8_t value;
} nv[] = {
{ "AElig", 198 }, /* capital AE diphthong (ligature) */

14
vis.3
View File

@ -1,4 +1,4 @@
.\" $NetBSD: vis.3,v 1.27 2011/05/17 07:10:39 joerg Exp $
.\" $NetBSD: vis.3,v 1.28 2012/12/14 21:38:18 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
.Dd March 12, 2011
.Dd December 14, 2012
.Dt VIS 3
.Os
.Sh NAME
@ -219,6 +219,15 @@ 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
.Ql ( * ,
.Ql \&? ,
.Ql \&[
and
.Ql # )
recognized by
.Xr glob 3 .
.It Dv VIS_SP
Also encode space.
.It Dv VIS_TAB
@ -408,6 +417,7 @@ The destination buffer size is not large enough to perform the conversion.
.Sh SEE ALSO
.Xr unvis 1 ,
.Xr vis 1 ,
.Xr glob 3 ,
.Xr unvis 3
.Rs
.%A T. Berners-Lee

12
vis.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $ */
/* $NetBSD: vis.c,v 1.45 2012/12/14 21:38:18 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $");
__RCSID("$NetBSD: vis.c,v 1.45 2012/12/14 21:38:18 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -89,7 +89,7 @@ static char *do_svis(char *, size_t *, int, int, int, const char *);
#define xtoa(c) "0123456789abcdef"[c]
#define XTOA(c) "0123456789ABCDEF"[c]
#define MAXEXTRAS 5
#define MAXEXTRAS 9
#define MAKEEXTRALIST(flag, extra, orig_str) \
do { \
@ -103,6 +103,12 @@ do { \
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
continue; \
e--; \
if (flag & VIS_GLOB) { \
*e++ = '*'; \
*e++ = '?'; \
*e++ = '['; \
*e++ = '#'; \
} \
if (flag & VIS_SP) *e++ = ' '; \
if (flag & VIS_TAB) *e++ = '\t'; \
if (flag & VIS_NL) *e++ = '\n'; \

29
vis.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: vis.h,v 1.19 2011/03/12 19:52:45 christos Exp $ */
/* $NetBSD: vis.h,v 1.20 2012/12/14 21:36:59 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -39,29 +39,30 @@
/*
* to select alternate encoding format
*/
#define VIS_OCTAL 0x001 /* use octal \ddd format */
#define VIS_CSTYLE 0x002 /* use \[nrft0..] where appropiate */
#define VIS_OCTAL 0x0001 /* use octal \ddd format */
#define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropiate */
/*
* to alter set of characters encoded (default is to encode all
* non-graphic except space, tab, and newline).
*/
#define VIS_SP 0x004 /* also encode space */
#define VIS_TAB 0x008 /* also encode tab */
#define VIS_NL 0x010 /* also encode newline */
#define VIS_SP 0x0004 /* also encode space */
#define VIS_TAB 0x0008 /* also encode tab */
#define VIS_NL 0x0010 /* also encode newline */
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
#define VIS_SAFE 0x020 /* only encode "unsafe" characters */
#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */
/*
* other
*/
#define VIS_NOSLASH 0x040 /* inhibit printing '\' */
#define VIS_HTTP1808 0x080 /* http-style escape % hex hex */
#define VIS_HTTPSTYLE 0x080 /* http-style escape % hex hex */
#define VIS_MIMESTYLE 0x100 /* mime-style escape = HEX HEX */
#define VIS_HTTP1866 0x200 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x400 /* don't decode `\' */
#define _VIS_END 0x800 /* for unvis */
#define VIS_NOSLASH 0x0040 /* inhibit printing '\' */
#define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */
#define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */
#define VIS_MIMESTYLE 0x0100 /* mime-style escape = HEX HEX */
#define VIS_HTTP1866 0x0200 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x0400 /* don't decode `\' */
#define _VIS_END 0x0800 /* for unvis */
#define VIS_GLOB 0x1000 /* encode glob(3) magic characters */
/*
* unvis return codes