From owner-svn-src-all@freebsd.org Mon Nov 27 23:47:59 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77C2CDED04A; Mon, 27 Nov 2017 23:47:59 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F4476A4D4; Mon, 27 Nov 2017 23:47:59 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vARNlwcD037734; Mon, 27 Nov 2017 23:47:58 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vARNlwWj037730; Mon, 27 Nov 2017 23:47:58 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201711272347.vARNlwWj037730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 27 Nov 2017 23:47:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r326295 - vendor/NetBSD/libc-vis/dist X-SVN-Group: vendor X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: vendor/NetBSD/libc-vis/dist X-SVN-Commit-Revision: 326295 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Nov 2017 23:47:59 -0000 Author: brooks Date: Mon Nov 27 23:47:57 2017 New Revision: 326295 URL: https://svnweb.freebsd.org/changeset/base/326295 Log: Vendor import of NetBSD's (un)vis(3) at 2017-11-27 Modified: vendor/NetBSD/libc-vis/dist/unvis.3 vendor/NetBSD/libc-vis/dist/vis.3 vendor/NetBSD/libc-vis/dist/vis.c vendor/NetBSD/libc-vis/dist/vis.h Modified: vendor/NetBSD/libc-vis/dist/unvis.3 ============================================================================== --- vendor/NetBSD/libc-vis/dist/unvis.3 Mon Nov 27 22:38:44 2017 (r326294) +++ vendor/NetBSD/libc-vis/dist/unvis.3 Mon Nov 27 23:47:57 2017 (r326295) @@ -1,4 +1,4 @@ -.\" $NetBSD: unvis.3,v 1.27 2012/12/15 07:34:36 wiz Exp $ +.\" $NetBSD: unvis.3,v 1.29 2017/10/24 19:14:55 abhinav Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -34,7 +34,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 @@ -183,7 +186,7 @@ char out; 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; @@ -197,7 +200,7 @@ again: 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: vendor/NetBSD/libc-vis/dist/vis.3 ============================================================================== --- vendor/NetBSD/libc-vis/dist/vis.3 Mon Nov 27 22:38:44 2017 (r326294) +++ vendor/NetBSD/libc-vis/dist/vis.3 Mon Nov 27 23:47:57 2017 (r326295) @@ -1,4 +1,4 @@ -.\" $NetBSD: vis.3,v 1.45 2016/06/08 15:00:04 wiz Exp $ +.\" $NetBSD: vis.3,v 1.49 2017/08/05 20:22:29 wiz 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 January 14, 2015 +.Dd April 22, 2017 .Dt VIS 3 .Os .Sh NAME @@ -242,6 +242,8 @@ except space, tab, and newline are encoded (see 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 ( * , @@ -309,7 +311,7 @@ warning on the use of the .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 @@ -372,7 +374,6 @@ space. .It Dv \e240 Represents Meta-space. .El -.Pp .It Dv VIS_CSTYLE Use C-style backslash sequences to represent standard non-printable characters. @@ -401,6 +402,9 @@ If .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 @@ -408,6 +412,11 @@ The form is 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 Modified: vendor/NetBSD/libc-vis/dist/vis.c ============================================================================== --- vendor/NetBSD/libc-vis/dist/vis.c Mon Nov 27 22:38:44 2017 (r326294) +++ vendor/NetBSD/libc-vis/dist/vis.c Mon Nov 27 23:47:57 2017 (r326295) @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $ */ +/* $NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos 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$"); @@ -377,6 +377,7 @@ makeextralist(int flags, const char *src) 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'; @@ -405,7 +406,15 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *m _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 @@ -421,12 +430,12 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *m /* Allocate space for the wide char strings */ psrc = pdst = extra = NULL; mdst = NULL; - if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == 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((4 * mblength) + 1, sizeof(*mdst))) == NULL) + if ((mdst = calloc((16 * mbslength) + 1, sizeof(*mdst))) == NULL) goto out; *mbdstp = mdst; } @@ -449,13 +458,6 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *m * 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++; while (mbslength > 0) { /* Convert one multibyte character to wchar_t. */ if (!cerr) @@ -466,12 +468,13 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *m 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. */ @@ -481,6 +484,7 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *m } 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 Modified: vendor/NetBSD/libc-vis/dist/vis.h ============================================================================== --- vendor/NetBSD/libc-vis/dist/vis.h Mon Nov 27 22:38:44 2017 (r326294) +++ vendor/NetBSD/libc-vis/dist/vis.h Mon Nov 27 23:47:57 2017 (r326295) @@ -1,4 +1,4 @@ -/* $NetBSD: vis.h,v 1.24 2016/01/14 20:42:14 christos Exp $ */ +/* $NetBSD: vis.h,v 1.25 2017/04/23 01:57:36 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -51,6 +51,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