From: Aaron LI Date: Mon, 11 Jun 2018 04:44:07 +0000 (+0800) Subject: vis(3): Add VIS_ALL support X-Git-Tag: v5.5.0~437 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/9dbd27e25802bcfced6400231f9f622f9529c7f5 vis(3): Add VIS_ALL support OpenSSH requires VIS_ALL and therefore uses the version bundled with itself, but this causes the vis.o symbol conflicts between libc and libssh when crunching fstyp(8) with ssh(1). Bump __DragonFly_version. Based-on: OpenBSD --- diff --git a/include/vis.h b/include/vis.h index 75d34c3444..366eece888 100644 --- a/include/vis.h +++ b/include/vis.h @@ -57,6 +57,7 @@ typedef __size_t size_t; #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 */ +#define VIS_ALL 0x00010000 /* encode all characters */ /* * other @@ -105,7 +106,7 @@ int strsnvis(char *, size_t, const char *, int, const char *); int strvisx(char *, const char *, size_t, int); int strnvisx(char *, size_t, const char *, size_t, int); -int strenvisx(char *, size_t, const char *, size_t, int, int *); +int strenvisx(char *, size_t, const char *, size_t, int, int *); int strsvisx(char *, const char *, size_t, int, const char *); int strsnvisx(char *, size_t, const char *, size_t, int, const char *); diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c index f09a25cf72..c8d121ccf0 100644 --- a/lib/libc/gen/unvis.c +++ b/lib/libc/gen/unvis.c @@ -244,6 +244,10 @@ unvis(char *cp, int c, int *astate, int flag) case S_START: switch(c) { + case '-': + *cp = 0; + *astate = SS(0, S_GROUND); + return UNVIS_NOCHAR; case '\\': *cp = c; *astate = SS(0, S_GROUND); diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3 index 0faf612d2f..5b9b1c31f3 100644 --- a/lib/libc/gen/vis.3 +++ b/lib/libc/gen/vis.3 @@ -29,7 +29,7 @@ .\" .\" @(#)vis.3 8.1 (Berkeley) 6/9/93 .\" -.Dd April 9, 2018 +.Dd June 10, 2018 .Dt VIS 3 .Os .Sh NAME @@ -244,8 +244,10 @@ except space, tab, and newline are encoded (see The following flags alter this: .Bl -tag -width ".Dv VIS_HTTPSTYLE" +.It Dv VIS_ALL +Encode all characters, whether visible or not. .It Dv VIS_DQ -Also encode double quotes +Also encode double quotes. .It Dv VIS_GLOB Also encode the magic characters .Ql ( * , @@ -564,3 +566,7 @@ Multibyte character support was added in .Nx 7.0 and .Fx 9.2 . +The +.Dv VIS_ALL +flag first appeared in +.Ox 4.9 . diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c index f7f6be02cc..0e85d5faf6 100644 --- a/lib/libc/gen/vis.c +++ b/lib/libc/gen/vis.c @@ -88,7 +88,7 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *); #undef BELL #define BELL L'\a' - + #if defined(LC_C_LOCALE) #define iscgraph(c) isgraph_l(c, LC_C_LOCALE) #else @@ -241,8 +241,12 @@ do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra) case L't': case L'f': case L's': + case L'x': case L'0': + case L'E': + case L'F': case L'M': + case L'-': case L'^': case L'$': /* vis(1) -l */ break; @@ -299,8 +303,10 @@ do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra) uint64_t bmsk, wmsk; iswextra = wcschr(extra, c) != NULL; - if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) || - ((flags & VIS_SAFE) && iswsafe(c)))) { + if (((flags & VIS_ALL) == 0) && + !iswextra && + (ISGRAPH(flags, c) || iswwhite(c) || + ((flags & VIS_SAFE) && iswsafe(c)))) { *dst++ = c; return dst; } @@ -377,7 +383,7 @@ makeextralist(int flags, const char *src) /* * istrsenvisx() - * The main internal function. + * The main internal function. * All user-visible functions call this one. */ static int diff --git a/sys/sys/param.h b/sys/sys/param.h index 04205b5eb4..3ef2669bcf 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -181,9 +181,10 @@ * 500308 - xdr_uint16_t() * 500309 - drop support for some ancient ioctls (OSIOCGIF*) * 500310 - remove more unimplemented ioctls + * 500311 - add VIS_ALL to vis(3) */ #undef __DragonFly_version -#define __DragonFly_version 500310 /* propagated to newvers */ +#define __DragonFly_version 500311 /* propagated to newvers */ #include