[Midnightbsd-cvs] src [11359] trunk/contrib/libc-vis: update to 2017
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 6 08:41:27 EDT 2018
Revision: 11359
http://svnweb.midnightbsd.org/src/?rev=11359
Author: laffer1
Date: 2018-07-06 08:41:27 -0400 (Fri, 06 Jul 2018)
Log Message:
-----------
update to 2017
Modified Paths:
--------------
trunk/contrib/libc-vis/unvis.3
trunk/contrib/libc-vis/unvis.c
trunk/contrib/libc-vis/vis.3
trunk/contrib/libc-vis/vis.c
trunk/contrib/libc-vis/vis.h
Property Changed:
----------------
trunk/contrib/libc-vis/
Index: trunk/contrib/libc-vis
===================================================================
--- trunk/contrib/libc-vis 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis 2018-07-06 12:41:27 UTC (rev 11359)
Property changes on: trunk/contrib/libc-vis
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1 ##
-/vendor/NetBSD/libc-vis/dist:9106-9109
\ No newline at end of property
+/vendor/NetBSD/libc-vis/dist:9106-11358
\ No newline at end of property
Modified: trunk/contrib/libc-vis/unvis.3
===================================================================
--- trunk/contrib/libc-vis/unvis.3 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis/unvis.3 2018-07-06 12:41:27 UTC (rev 11359)
@@ -1,5 +1,5 @@
-.\" $NetBSD: unvis.3,v 1.27 2012/12/15 07:34:36 wiz Exp $
-.\" $FreeBSD: release/9.2.0/contrib/libc-vis/unvis.3 249560 2013-04-16 19:27:09Z brooks $
+.\" $NetBSD: unvis.3,v 1.29 2017/10/24 19:14:55 abhinav Exp $
+.\" $FreeBSD: stable/10/contrib/libc-vis/unvis.3 326324 2017-11-28 17:20:53Z brooks $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -35,7 +35,10 @@
.Os
.Sh NAME
.Nm unvis ,
-.Nm strunvis
+.Nm strunvis ,
+.Nm strnunvis ,
+.Nm strunvisx ,
+.Nm strnunvisx
.Nd decode a visual representation of characters
.Sh LIBRARY
.Lb libc
@@ -184,7 +187,7 @@
while ((ch = getchar()) != EOF) {
again:
- switch(unvis(\*[Am]out, ch, \*[Am]state, 0)) {
+ switch(unvis(&out, ch, &state, 0)) {
case 0:
case UNVIS_NOCHAR:
break;
@@ -198,7 +201,7 @@
errx(EXIT_FAILURE, "Bad character sequence!");
}
}
-if (unvis(\*[Am]out, '\e0', \*[Am]state, UNVIS_END) == UNVIS_VALID)
+if (unvis(&out, '\e0', &state, UNVIS_END) == UNVIS_VALID)
(void)putchar(out);
.Ed
.Sh ERRORS
Modified: trunk/contrib/libc-vis/unvis.c
===================================================================
--- trunk/contrib/libc-vis/unvis.c 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis/unvis.c 2018-07-06 12:41:27 UTC (rev 11359)
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $ */
+/* $NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,10 +34,10 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-__FBSDID("$FreeBSD: release/9.2.0/contrib/libc-vis/unvis.c 249560 2013-04-16 19:27:09Z brooks $");
+__FBSDID("$FreeBSD: stable/10/contrib/libc-vis/unvis.c 326324 2017-11-28 17:20:53Z brooks $");
#include "namespace.h"
#include <sys/types.h>
@@ -322,6 +322,12 @@
*/
*astate = SS(0, S_GROUND);
return UNVIS_NOCHAR;
+ default:
+ if (isgraph(c)) {
+ *cp = c;
+ *astate = SS(0, S_GROUND);
+ return UNVIS_VALID;
+ }
}
goto bad;
Modified: trunk/contrib/libc-vis/vis.3
===================================================================
--- trunk/contrib/libc-vis/vis.3 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis/vis.3 2018-07-06 12:41:27 UTC (rev 11359)
@@ -1,5 +1,5 @@
-.\" $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
-.\" $FreeBSD: release/9.2.0/contrib/libc-vis/vis.3 249560 2013-04-16 19:27:09Z brooks $
+.\" $NetBSD: vis.3,v 1.49 2017/08/05 20:22:29 wiz Exp $
+.\" $FreeBSD: stable/10/contrib/libc-vis/vis.3 326324 2017-11-28 17:20:53Z brooks $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd February 19, 2013
+.Dd April 22, 2017
.Dt VIS 3
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Nm vis ,
.Nm nvis ,
.Nm strvis ,
+.Nm stravis ,
.Nm strnvis ,
.Nm strvisx ,
.Nm strnvisx ,
@@ -60,6 +61,8 @@
.Ft int
.Fn strvis "char *dst" "const char *src" "int flag"
.Ft int
+.Fn stravis "char **dst" "const char *src" "int flag"
+.Ft int
.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
.Ft int
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
@@ -112,6 +115,7 @@
.Pp
The
.Fn strvis ,
+.Fn stravis ,
.Fn strnvis ,
.Fn strvisx ,
and
@@ -158,6 +162,9 @@
(not including the trailing
.Dv NUL ) .
The
+.Fn stravis
+function allocates space dynamically to hold the string.
+The
.Dq Nm n
versions of the functions also take an additional argument
.Fa dlen
@@ -236,15 +243,37 @@
The following flags
alter this:
.Bl -tag -width VIS_WHITEX
+.It Dv VIS_DQ
+Also encode double quotes
.It Dv VIS_GLOB
Also encode the magic characters
.Ql ( * ,
.Ql \&? ,
-.Ql \&[
+.Ql \&[ ,
and
.Ql # )
recognized by
.Xr glob 3 .
+.It Dv VIS_SHELL
+Also encode the meta characters used by shells (in addition to the glob
+characters):
+.Ql ( ' ,
+.Ql ` ,
+.Ql \&" ,
+.Ql \&; ,
+.Ql & ,
+.Ql < ,
+.Ql > ,
+.Ql \&( ,
+.Ql \&) ,
+.Ql \&| ,
+.Ql \&] ,
+.Ql \e ,
+.Ql $ ,
+.Ql \&! ,
+.Ql \&^ ,
+and
+.Ql ~ ) .
.It Dv VIS_SP
Also encode space.
.It Dv VIS_TAB
@@ -253,11 +282,10 @@
Also encode newline.
.It Dv VIS_WHITE
Synonym for
-.Dv VIS_SP
-\&|
-.Dv VIS_TAB
-\&|
-.Dv VIS_NL .
+.Dv VIS_SP | VIS_TAB | VIS_NL .
+.It Dv VIS_META
+Synonym for
+.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL .
.It Dv VIS_SAFE
Only encode
.Dq unsafe
@@ -284,7 +312,7 @@
.Dv VIS_NOSLASH
flag below).
.Pp
-There are four forms of encoding.
+There are six forms of encoding.
All forms use the backslash character
.Ql \e
to introduce a special
@@ -347,7 +375,6 @@
.It Dv \e240
Represents Meta-space.
.El
-.Pp
.It Dv VIS_CSTYLE
Use C-style backslash sequences to represent standard non-printable
characters.
@@ -376,6 +403,9 @@
.Fa nextc
is an octal digit, the latter representation is used to
avoid ambiguity.
+.Pp
+Non-printable characters without C-style
+backslash sequences use the default representation.
.It Dv VIS_OCTAL
Use a three digit octal sequence.
The form is
@@ -383,6 +413,11 @@
where
.Em d
represents an octal digit.
+.It Dv VIS_CSTYLE \&| Dv VIS_OCTAL
+Same as
+.Dv VIS_CSTYLE
+except that non-printable characters without C-style
+backslash sequences use a three digit octal sequence.
.It Dv VIS_HTTPSTYLE
Use URI encoding as described in RFC 1738.
The form is
@@ -418,6 +453,11 @@
environment variable which defines the set of characters
that can be copied without encoding.
.Pp
+If
+.Dv VIS_NOLOCALE
+is set, processing is done assuming the C locale and overriding
+any other environment settings.
+.Pp
When 8-bit data is present in the input,
.Ev LC_CTYPE
must be set to the correct locale or to the C locale.
@@ -510,9 +550,10 @@
and
.Fn strsnvisx Pc
appeared in
+.Nx 6.0
and
.Fx 9.2 .
-Myltibyte character support was added in
+Multibyte character support was added in
.Nx 7.0
and
.Fx 9.2 .
Modified: trunk/contrib/libc-vis/vis.c
===================================================================
--- trunk/contrib/libc-vis/vis.c 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis/vis.c 2018-07-06 12:41:27 UTC (rev 11359)
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $ */
+/* $NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,10 +57,10 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $");
+__RCSID("$NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
-__FBSDID("$FreeBSD: release/9.2.0/contrib/libc-vis/vis.c 249560 2013-04-16 19:27:09Z brooks $");
+__FBSDID("$FreeBSD: stable/10/contrib/libc-vis/vis.c 326324 2017-11-28 17:20:53Z brooks $");
#define _DIAGASSERT(x) assert(x)
#endif
@@ -97,7 +97,31 @@
#undef BELL
#define BELL L'\a'
+
+#if defined(LC_C_LOCALE)
+#define iscgraph(c) isgraph_l(c, LC_C_LOCALE)
+#else
+/* Keep it simple for now, no locale stuff */
+#define iscgraph(c) isgraph(c)
+#ifdef notyet
+#include <locale.h>
+static int
+iscgraph(int c) {
+ int rv;
+ char *ol;
+ ol = setlocale(LC_CTYPE, "C");
+ rv = isgraph(c);
+ if (ol)
+ setlocale(LC_CTYPE, ol);
+ return rv;
+}
+#endif
+#endif
+
+#define ISGRAPH(flags, c) \
+ (((flags) & VIS_NOLOCALE) ? iscgraph(c) : iswgraph(c))
+
#define iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
#define iswsafe(c) (c == L'\b' || c == BELL || c == L'\r')
@@ -104,8 +128,11 @@
#define xtoa(c) L"0123456789abcdef"[c]
#define XTOA(c) L"0123456789ABCDEF"[c]
-#define MAXEXTRAS 10
+#define MAXEXTRAS 30
+static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~";
+static const wchar_t char_glob[] = L"*?[#";
+
#if !HAVE_NBTOOL_CONFIG_H
#ifndef __NetBSD__
/*
@@ -213,8 +240,23 @@
*dst++ = L'0';
}
return dst;
+ /* We cannot encode these characters in VIS_CSTYLE
+ * because they special meaning */
+ case L'n':
+ case L'r':
+ case L'b':
+ case L'a':
+ case L'v':
+ case L't':
+ case L'f':
+ case L's':
+ case L'0':
+ case L'M':
+ case L'^':
+ case L'$': /* vis(1) -l */
+ break;
default:
- if (iswgraph(c)) {
+ if (ISGRAPH(flags, c) && !iswoctal(c)) {
*dst++ = L'\\';
*dst++ = c;
return dst;
@@ -266,7 +308,7 @@
uint64_t bmsk, wmsk;
iswextra = wcschr(extra, c) != NULL;
- if (!iswextra && (iswgraph(c) || iswwhite(c) ||
+ if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) ||
((flags & VIS_SAFE) && iswsafe(c)))) {
*dst++ = c;
return dst;
@@ -310,29 +352,34 @@
{
wchar_t *dst, *d;
size_t len;
+ const wchar_t *s;
+ mbstate_t mbstate;
+ bzero(&mbstate, sizeof(mbstate));
len = strlen(src);
if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
return NULL;
- if (mbstowcs(dst, src, len) == (size_t)-1) {
+ if ((flags & VIS_NOLOCALE) || mbsrtowcs(dst, &src, len, &mbstate) == (size_t)-1) {
size_t i;
for (i = 0; i < len; i++)
- dst[i] = (wint_t)(u_char)src[i];
+ dst[i] = (wchar_t)(u_char)src[i];
d = dst + len;
} else
d = dst + wcslen(dst);
- if (flags & VIS_GLOB) {
- *d++ = L'*';
- *d++ = L'?';
- *d++ = L'[';
- *d++ = L'#';
- }
+ if (flags & VIS_GLOB)
+ for (s = char_glob; *s; *d++ = *s++)
+ continue;
+ if (flags & VIS_SHELL)
+ for (s = char_shell; *s; *d++ = *s++)
+ continue;
+
if (flags & VIS_SP) *d++ = L' ';
if (flags & VIS_TAB) *d++ = L'\t';
if (flags & VIS_NL) *d++ = L'\n';
+ if (flags & VIS_DQ) *d++ = L'"';
if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\';
*d = L'\0';
@@ -345,7 +392,7 @@
* All user-visible functions call this one.
*/
static int
-istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
+istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
int flags, const char *mbextra, int *cerr_ptr)
{
wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
@@ -353,14 +400,24 @@
uint64_t bmsk, wmsk;
wint_t c;
visfun_t f;
- int clen = 0, cerr = 0, error = -1, i, shft;
+ int clen = 0, cerr, error = -1, i, shft;
+ char *mbdst, *mdst;
ssize_t mbslength, maxolen;
+ mbstate_t mbstate;
- _DIAGASSERT(mbdst != NULL);
- _DIAGASSERT(mbsrc != NULL);
+ _DIAGASSERT(mbdstp != NULL);
+ _DIAGASSERT(mbsrc != NULL || mblength == 0);
_DIAGASSERT(mbextra != NULL);
+ mbslength = (ssize_t)mblength;
/*
+ * When inputing a single character, must also read in the
+ * next character for nextc, the look-ahead character.
+ */
+ if (mbslength == 1)
+ mbslength++;
+
+ /*
* Input (mbsrc) is a char string considered to be multibyte
* characters. The input loop will read this string pulling
* one character, possibly multiple bytes, from mbsrc and
@@ -375,18 +432,28 @@
/* Allocate space for the wide char strings */
psrc = pdst = extra = NULL;
- if (!mblength)
- mblength = strlen(mbsrc);
- if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
+ mdst = NULL;
+ if ((psrc = calloc(mbslength + 1, sizeof(*psrc))) == NULL)
return -1;
- if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
+ if ((pdst = calloc((16 * mbslength) + 1, sizeof(*pdst))) == NULL)
goto out;
+ if (*mbdstp == NULL) {
+ if ((mdst = calloc((16 * mbslength) + 1, sizeof(*mdst))) == NULL)
+ goto out;
+ *mbdstp = mdst;
+ }
+
+ mbdst = *mbdstp;
dst = pdst;
src = psrc;
- /* Use caller's multibyte conversion error flag. */
- if (cerr_ptr)
- cerr = *cerr_ptr;
+ if (flags & VIS_NOLOCALE) {
+ /* Do one byte at a time conversion */
+ cerr = 1;
+ } else {
+ /* Use caller's multibyte conversion error flag. */
+ cerr = cerr_ptr ? *cerr_ptr : 0;
+ }
/*
* Input loop.
@@ -394,17 +461,11 @@
* stop at NULs because we may be processing a block of data
* that includes NULs.
*/
- mbslength = (ssize_t)mblength;
- /*
- * When inputing a single character, must also read in the
- * next character for nextc, the look-ahead character.
- */
- if (mbslength == 1)
- mbslength++;
+ bzero(&mbstate, sizeof(mbstate));
while (mbslength > 0) {
/* Convert one multibyte character to wchar_t. */
if (!cerr)
- clen = mbtowc(src, mbsrc, MB_LEN_MAX);
+ clen = mbrtowc(src, mbsrc, MB_LEN_MAX, &mbstate);
if (cerr || clen < 0) {
/* Conversion error, process as a byte instead. */
*src = (wint_t)(u_char)*mbsrc;
@@ -411,12 +472,13 @@
clen = 1;
cerr = 1;
}
- if (clen == 0)
+ if (clen == 0) {
/*
* NUL in input gives 0 return value. process
* as single NUL byte and keep going.
*/
clen = 1;
+ }
/* Advance buffer character pointer. */
src++;
/* Advance input pointer by number of bytes read. */
@@ -426,6 +488,7 @@
}
len = src - psrc;
src = psrc;
+
/*
* In the single character input case, we will have actually
* processed two characters, c and nextc. Reset len back to
@@ -441,7 +504,7 @@
errno = ENOSPC;
goto out;
}
- *mbdst = '\0'; /* can't create extra, return "" */
+ *mbdst = '\0'; /* can't create extra, return "" */
error = 0;
goto out;
}
@@ -475,9 +538,10 @@
len = wcslen(start);
maxolen = dlen ? *dlen : (wcslen(start) * MB_LEN_MAX + 1);
olen = 0;
+ bzero(&mbstate, sizeof(mbstate));
for (dst = start; len > 0; len--) {
if (!cerr)
- clen = wctomb(mbdst, *dst);
+ clen = wcrtomb(mbdst, *dst, &mbstate);
if (cerr || clen < 0) {
/*
* Conversion error, process as a byte(s) instead.
@@ -513,9 +577,11 @@
/* Terminate the output string. */
*mbdst = '\0';
- /* Pass conversion error flag out. */
- if (cerr_ptr)
- *cerr_ptr = cerr;
+ if (flags & VIS_NOLOCALE) {
+ /* Pass conversion error flag out. */
+ if (cerr_ptr)
+ *cerr_ptr = cerr;
+ }
free(extra);
free(pdst);
@@ -526,8 +592,18 @@
free(extra);
free(pdst);
free(psrc);
+ free(mdst);
return error;
}
+
+static int
+istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc,
+ int flags, const char *mbextra, int *cerr_ptr)
+{
+ return istrsenvisx(mbdstp, dlen, mbsrc,
+ mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
+}
+
#endif
#if !HAVE_SVIS
@@ -547,7 +623,7 @@
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -562,7 +638,7 @@
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -571,19 +647,19 @@
int
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, mbextra, NULL);
}
int
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, mbextra, NULL);
}
int
strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
}
int
@@ -590,7 +666,7 @@
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
}
int
@@ -597,7 +673,7 @@
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra, int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
}
#endif
@@ -614,7 +690,7 @@
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -629,7 +705,7 @@
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -646,15 +722,22 @@
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
- return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, "", NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, "", NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, "", NULL);
}
+int
+stravis(char **mbdstp, const char *mbsrc, int flags)
+{
+ *mbdstp = NULL;
+ return istrsenvisxl(mbdstp, NULL, mbsrc, flags, "", NULL);
+}
+
/*
* strvisx - visually encode characters from src into dst
*
@@ -669,13 +752,13 @@
int
strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, "", NULL);
}
int
strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", NULL);
}
int
@@ -682,6 +765,6 @@
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
}
#endif
Modified: trunk/contrib/libc-vis/vis.h
===================================================================
--- trunk/contrib/libc-vis/vis.h 2018-07-06 12:40:39 UTC (rev 11358)
+++ trunk/contrib/libc-vis/vis.h 2018-07-06 12:41:27 UTC (rev 11359)
@@ -1,5 +1,5 @@
-/* $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $ */
-/* $FreeBSD: release/9.2.0/contrib/libc-vis/vis.h 249560 2013-04-16 19:27:09Z brooks $ */
+/* $NetBSD: vis.h,v 1.25 2017/04/23 01:57:36 christos Exp $ */
+/* $FreeBSD: stable/10/contrib/libc-vis/vis.h 326324 2017-11-28 17:20:53Z brooks $ */
/*-
* Copyright (c) 1990, 1993
@@ -52,6 +52,7 @@
#define VIS_NL 0x0010 /* also encode newline */
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */
+#define VIS_DQ 0x8000 /* also encode double quotes */
/*
* other
@@ -64,6 +65,9 @@
#define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x0800 /* don't decode `\' */
#define _VIS_END 0x1000 /* for unvis */
+#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */
+#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL)
+#define VIS_NOLOCALE 0x4000 /* encode using the C locale */
/*
* unvis return codes
@@ -89,6 +93,7 @@
char *snvis(char *, size_t, int, int, int, const char *);
int strvis(char *, const char *, int);
+int stravis(char **, const char *, int);
int strnvis(char *, size_t, const char *, int);
int strsvis(char *, const char *, int, const char *);
More information about the Midnightbsd-cvs
mailing list