Update to a June 8th snapshot of (un)vis form NetBSD.
This adds stravis() and some new encoding flags VIS_SHELL, VIS_META, and VIS_NOLOCALE. Assorted cleanups and fixes includeing a manpage typo[0]. PR: 210013 [0] Submitted by: pi [0]
This commit is contained in:
@@ -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
|
* Copyright (c) 1989, 1993
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
|
||||||
#else
|
#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
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
@@ -322,6 +322,12 @@ unvis(char *cp, int c, int *astate, int flag)
|
|||||||
*/
|
*/
|
||||||
*astate = SS(0, S_GROUND);
|
*astate = SS(0, S_GROUND);
|
||||||
return UNVIS_NOCHAR;
|
return UNVIS_NOCHAR;
|
||||||
|
default:
|
||||||
|
if (isgraph(c)) {
|
||||||
|
*cp = c;
|
||||||
|
*astate = SS(0, S_GROUND);
|
||||||
|
return UNVIS_VALID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
|
|||||||
+40
-9
@@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
|
.\" $NetBSD: vis.3,v 1.45 2016/06/08 15:00:04 wiz Exp $
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1989, 1991, 1993
|
.\" Copyright (c) 1989, 1991, 1993
|
||||||
@@ -30,13 +30,14 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
|
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
|
||||||
.\"
|
.\"
|
||||||
.Dd February 19, 2013
|
.Dd January 14, 2015
|
||||||
.Dt VIS 3
|
.Dt VIS 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm vis ,
|
.Nm vis ,
|
||||||
.Nm nvis ,
|
.Nm nvis ,
|
||||||
.Nm strvis ,
|
.Nm strvis ,
|
||||||
|
.Nm stravis ,
|
||||||
.Nm strnvis ,
|
.Nm strnvis ,
|
||||||
.Nm strvisx ,
|
.Nm strvisx ,
|
||||||
.Nm strnvisx ,
|
.Nm strnvisx ,
|
||||||
@@ -60,6 +61,8 @@
|
|||||||
.Ft int
|
.Ft int
|
||||||
.Fn strvis "char *dst" "const char *src" "int flag"
|
.Fn strvis "char *dst" "const char *src" "int flag"
|
||||||
.Ft int
|
.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"
|
.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
|
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
|
||||||
@@ -112,6 +115,7 @@ encoding format (explained below).
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn strvis ,
|
.Fn strvis ,
|
||||||
|
.Fn stravis ,
|
||||||
.Fn strnvis ,
|
.Fn strnvis ,
|
||||||
.Fn strvisx ,
|
.Fn strvisx ,
|
||||||
and
|
and
|
||||||
@@ -158,6 +162,9 @@ forms return the number of characters in
|
|||||||
(not including the trailing
|
(not including the trailing
|
||||||
.Dv NUL ) .
|
.Dv NUL ) .
|
||||||
The
|
The
|
||||||
|
.Fn stravis
|
||||||
|
function allocates space dynamically to hold the string.
|
||||||
|
The
|
||||||
.Dq Nm n
|
.Dq Nm n
|
||||||
versions of the functions also take an additional argument
|
versions of the functions also take an additional argument
|
||||||
.Fa dlen
|
.Fa dlen
|
||||||
@@ -240,11 +247,31 @@ alter this:
|
|||||||
Also encode the magic characters
|
Also encode the magic characters
|
||||||
.Ql ( * ,
|
.Ql ( * ,
|
||||||
.Ql \&? ,
|
.Ql \&? ,
|
||||||
.Ql \&[
|
.Ql \&[ ,
|
||||||
and
|
and
|
||||||
.Ql # )
|
.Ql # )
|
||||||
recognized by
|
recognized by
|
||||||
.Xr glob 3 .
|
.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
|
.It Dv VIS_SP
|
||||||
Also encode space.
|
Also encode space.
|
||||||
.It Dv VIS_TAB
|
.It Dv VIS_TAB
|
||||||
@@ -253,11 +280,10 @@ Also encode tab.
|
|||||||
Also encode newline.
|
Also encode newline.
|
||||||
.It Dv VIS_WHITE
|
.It Dv VIS_WHITE
|
||||||
Synonym for
|
Synonym for
|
||||||
.Dv VIS_SP
|
.Dv VIS_SP | VIS_TAB | VIS_NL .
|
||||||
\&|
|
.It Dv VIS_META
|
||||||
.Dv VIS_TAB
|
Synonym for
|
||||||
\&|
|
.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL .
|
||||||
.Dv VIS_NL .
|
|
||||||
.It Dv VIS_SAFE
|
.It Dv VIS_SAFE
|
||||||
Only encode
|
Only encode
|
||||||
.Dq unsafe
|
.Dq unsafe
|
||||||
@@ -418,6 +444,11 @@ The encoding conversion is influenced by the setting of the
|
|||||||
environment variable which defines the set of characters
|
environment variable which defines the set of characters
|
||||||
that can be copied without encoding.
|
that can be copied without encoding.
|
||||||
.Pp
|
.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,
|
When 8-bit data is present in the input,
|
||||||
.Ev LC_CTYPE
|
.Ev LC_CTYPE
|
||||||
must be set to the correct locale or to the C locale.
|
must be set to the correct locale or to the C locale.
|
||||||
@@ -513,7 +544,7 @@ appeared in
|
|||||||
.Nx 6.0
|
.Nx 6.0
|
||||||
and
|
and
|
||||||
.Fx 9.2 .
|
.Fx 9.2 .
|
||||||
Myltibyte character support was added in
|
Multibyte character support was added in
|
||||||
.Nx 7.0
|
.Nx 7.0
|
||||||
and
|
and
|
||||||
.Fx 9.2 .
|
.Fx 9.2 .
|
||||||
|
|||||||
+106
-39
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */
|
/* $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
|
__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $");
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
#ifdef __FBSDID
|
#ifdef __FBSDID
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
@@ -97,6 +97,30 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
|
|||||||
|
|
||||||
#undef BELL
|
#undef BELL
|
||||||
#define BELL L'\a'
|
#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 iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
|
||||||
#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
|
#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
|
||||||
@@ -104,7 +128,10 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
|
|||||||
#define xtoa(c) L"0123456789abcdef"[c]
|
#define xtoa(c) L"0123456789abcdef"[c]
|
||||||
#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
|
#if !HAVE_NBTOOL_CONFIG_H
|
||||||
#ifndef __NetBSD__
|
#ifndef __NetBSD__
|
||||||
@@ -213,8 +240,23 @@ do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
|
|||||||
*dst++ = L'0';
|
*dst++ = L'0';
|
||||||
}
|
}
|
||||||
return dst;
|
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:
|
default:
|
||||||
if (iswgraph(c)) {
|
if (ISGRAPH(flags, c) && !iswoctal(c)) {
|
||||||
*dst++ = L'\\';
|
*dst++ = L'\\';
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
return dst;
|
return dst;
|
||||||
@@ -266,7 +308,7 @@ do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
|
|||||||
uint64_t bmsk, wmsk;
|
uint64_t bmsk, wmsk;
|
||||||
|
|
||||||
iswextra = wcschr(extra, c) != NULL;
|
iswextra = wcschr(extra, c) != NULL;
|
||||||
if (!iswextra && (iswgraph(c) || iswwhite(c) ||
|
if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) ||
|
||||||
((flags & VIS_SAFE) && iswsafe(c)))) {
|
((flags & VIS_SAFE) && iswsafe(c)))) {
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
return dst;
|
return dst;
|
||||||
@@ -310,25 +352,27 @@ makeextralist(int flags, const char *src)
|
|||||||
{
|
{
|
||||||
wchar_t *dst, *d;
|
wchar_t *dst, *d;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
const wchar_t *s;
|
||||||
|
|
||||||
len = strlen(src);
|
len = strlen(src);
|
||||||
if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
|
if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (mbstowcs(dst, src, len) == (size_t)-1) {
|
if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) {
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < len; 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;
|
d = dst + len;
|
||||||
} else
|
} else
|
||||||
d = dst + wcslen(dst);
|
d = dst + wcslen(dst);
|
||||||
|
|
||||||
if (flags & VIS_GLOB) {
|
if (flags & VIS_GLOB)
|
||||||
*d++ = L'*';
|
for (s = char_glob; *s; *d++ = *s++)
|
||||||
*d++ = L'?';
|
continue;
|
||||||
*d++ = L'[';
|
|
||||||
*d++ = L'#';
|
if (flags & VIS_SHELL)
|
||||||
}
|
for (s = char_shell; *s; *d++ = *s++)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (flags & VIS_SP) *d++ = L' ';
|
if (flags & VIS_SP) *d++ = L' ';
|
||||||
if (flags & VIS_TAB) *d++ = L'\t';
|
if (flags & VIS_TAB) *d++ = L'\t';
|
||||||
@@ -345,7 +389,7 @@ makeextralist(int flags, const char *src)
|
|||||||
* All user-visible functions call this one.
|
* All user-visible functions call this one.
|
||||||
*/
|
*/
|
||||||
static int
|
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)
|
int flags, const char *mbextra, int *cerr_ptr)
|
||||||
{
|
{
|
||||||
wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
|
wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
|
||||||
@@ -353,10 +397,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
|
|||||||
uint64_t bmsk, wmsk;
|
uint64_t bmsk, wmsk;
|
||||||
wint_t c;
|
wint_t c;
|
||||||
visfun_t f;
|
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;
|
ssize_t mbslength, maxolen;
|
||||||
|
|
||||||
_DIAGASSERT(mbdst != NULL);
|
_DIAGASSERT(mbdstp != NULL);
|
||||||
_DIAGASSERT(mbsrc != NULL || mblength == 0);
|
_DIAGASSERT(mbsrc != NULL || mblength == 0);
|
||||||
_DIAGASSERT(mbextra != NULL);
|
_DIAGASSERT(mbextra != NULL);
|
||||||
|
|
||||||
@@ -375,16 +420,28 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
|
|||||||
|
|
||||||
/* Allocate space for the wide char strings */
|
/* Allocate space for the wide char strings */
|
||||||
psrc = pdst = extra = NULL;
|
psrc = pdst = extra = NULL;
|
||||||
|
mdst = NULL;
|
||||||
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
|
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
|
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
if (*mbdstp == NULL) {
|
||||||
|
if ((mdst = calloc((4 * mblength) + 1, sizeof(*mdst))) == NULL)
|
||||||
|
goto out;
|
||||||
|
*mbdstp = mdst;
|
||||||
|
}
|
||||||
|
|
||||||
|
mbdst = *mbdstp;
|
||||||
dst = pdst;
|
dst = pdst;
|
||||||
src = psrc;
|
src = psrc;
|
||||||
|
|
||||||
/* Use caller's multibyte conversion error flag. */
|
if (flags & VIS_NOLOCALE) {
|
||||||
if (cerr_ptr)
|
/* Do one byte at a time conversion */
|
||||||
cerr = *cerr_ptr;
|
cerr = 1;
|
||||||
|
} else {
|
||||||
|
/* Use caller's multibyte conversion error flag. */
|
||||||
|
cerr = cerr_ptr ? *cerr_ptr : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Input loop.
|
* Input loop.
|
||||||
@@ -439,7 +496,7 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
|
|||||||
errno = ENOSPC;
|
errno = ENOSPC;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
*mbdst = '\0'; /* can't create extra, return "" */
|
*mbdst = '\0'; /* can't create extra, return "" */
|
||||||
error = 0;
|
error = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -511,9 +568,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
|
|||||||
/* Terminate the output string. */
|
/* Terminate the output string. */
|
||||||
*mbdst = '\0';
|
*mbdst = '\0';
|
||||||
|
|
||||||
/* Pass conversion error flag out. */
|
if (flags & VIS_NOLOCALE) {
|
||||||
if (cerr_ptr)
|
/* Pass conversion error flag out. */
|
||||||
*cerr_ptr = cerr;
|
if (cerr_ptr)
|
||||||
|
*cerr_ptr = cerr;
|
||||||
|
}
|
||||||
|
|
||||||
free(extra);
|
free(extra);
|
||||||
free(pdst);
|
free(pdst);
|
||||||
@@ -524,14 +583,15 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
|
|||||||
free(extra);
|
free(extra);
|
||||||
free(pdst);
|
free(pdst);
|
||||||
free(psrc);
|
free(psrc);
|
||||||
|
free(mdst);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
|
istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc,
|
||||||
int flags, const char *mbextra, int *cerr_ptr)
|
int flags, const char *mbextra, int *cerr_ptr)
|
||||||
{
|
{
|
||||||
return istrsenvisx(mbdst, dlen, mbsrc,
|
return istrsenvisx(mbdstp, dlen, mbsrc,
|
||||||
mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
|
mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,7 +614,7 @@ svis(char *mbdst, int c, int flags, int nextc, const char *mbextra)
|
|||||||
cc[0] = c;
|
cc[0] = c;
|
||||||
cc[1] = nextc;
|
cc[1] = nextc;
|
||||||
|
|
||||||
ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
|
ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, mbextra, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return mbdst + ret;
|
return mbdst + ret;
|
||||||
@@ -569,7 +629,7 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
|
|||||||
cc[0] = c;
|
cc[0] = c;
|
||||||
cc[1] = nextc;
|
cc[1] = nextc;
|
||||||
|
|
||||||
ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
|
ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, mbextra, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return mbdst + ret;
|
return mbdst + ret;
|
||||||
@@ -578,33 +638,33 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
|
|||||||
int
|
int
|
||||||
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
|
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
|
||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
|
return istrsenvisxl(&mbdst, NULL, mbsrc, flags, mbextra, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
|
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
|
||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
|
return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, mbextra, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
|
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
|
int
|
||||||
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
||||||
const char *mbextra)
|
const char *mbextra)
|
||||||
{
|
{
|
||||||
return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
|
return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
||||||
const char *mbextra, int *cerr_ptr)
|
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
|
#endif
|
||||||
|
|
||||||
@@ -621,7 +681,7 @@ vis(char *mbdst, int c, int flags, int nextc)
|
|||||||
cc[0] = c;
|
cc[0] = c;
|
||||||
cc[1] = nextc;
|
cc[1] = nextc;
|
||||||
|
|
||||||
ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
|
ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, "", NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return mbdst + ret;
|
return mbdst + ret;
|
||||||
@@ -636,7 +696,7 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
|
|||||||
cc[0] = c;
|
cc[0] = c;
|
||||||
cc[1] = nextc;
|
cc[1] = nextc;
|
||||||
|
|
||||||
ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
|
ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, "", NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return mbdst + ret;
|
return mbdst + ret;
|
||||||
@@ -653,13 +713,20 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
|
|||||||
int
|
int
|
||||||
strvis(char *mbdst, const char *mbsrc, int flags)
|
strvis(char *mbdst, const char *mbsrc, int flags)
|
||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
|
return istrsenvisxl(&mbdst, NULL, mbsrc, flags, "", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, &dlen, mbsrc, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -676,19 +743,19 @@ strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
|||||||
int
|
int
|
||||||
strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
|
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
|
int
|
||||||
strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
|
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
|
int
|
||||||
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
|
||||||
int *cerr_ptr)
|
int *cerr_ptr)
|
||||||
{
|
{
|
||||||
return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
|
return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $ */
|
/* $NetBSD: vis.h,v 1.24 2016/01/14 20:42:14 christos Exp $ */
|
||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@@ -64,6 +64,9 @@
|
|||||||
#define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */
|
#define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */
|
||||||
#define VIS_NOESCAPE 0x0800 /* don't decode `\' */
|
#define VIS_NOESCAPE 0x0800 /* don't decode `\' */
|
||||||
#define _VIS_END 0x1000 /* for unvis */
|
#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
|
* unvis return codes
|
||||||
@@ -89,6 +92,7 @@ char *svis(char *, int, int, int, const char *);
|
|||||||
char *snvis(char *, size_t, int, int, int, const char *);
|
char *snvis(char *, size_t, int, int, int, const char *);
|
||||||
|
|
||||||
int strvis(char *, const char *, int);
|
int strvis(char *, const char *, int);
|
||||||
|
int stravis(char **, const char *, int);
|
||||||
int strnvis(char *, size_t, const char *, int);
|
int strnvis(char *, size_t, const char *, int);
|
||||||
|
|
||||||
int strsvis(char *, const char *, int, const char *);
|
int strsvis(char *, const char *, int, const char *);
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ FBSD_1.4 {
|
|||||||
pthread_mutexattr_getrobust;
|
pthread_mutexattr_getrobust;
|
||||||
pthread_mutexattr_setrobust;
|
pthread_mutexattr_setrobust;
|
||||||
scandir_b;
|
scandir_b;
|
||||||
|
stravis;
|
||||||
};
|
};
|
||||||
|
|
||||||
FBSDprivate_1.0 {
|
FBSDprivate_1.0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user