Author: brooks
Date: Tue Dec 18 16:37:24 2012
New Revision: 244401
URL: http://svnweb.freebsd.org/changeset/base/244401

Log:
  Replace our implementation of the vis(3) and unvis(3) APIs with
  NetBSD's.  This output size limited versions of vis and unvis functions
  as well as a set of vis variants that allow arbitrary characters to be
  specified for encoding.
  
  Finally, MIME Quoted-Printable encoding as described in RFC 2045 is
  supported.

Added:
  head/contrib/libc-vis/
     - copied from r244235, vendor/NetBSD/libc-vis/dist/
  head/lib/libc/gen/unvis-compat.c   (contents, props changed)
Deleted:
  head/include/vis.h
  head/lib/libc/gen/unvis.3
  head/lib/libc/gen/unvis.c
  head/lib/libc/gen/vis.3
  head/lib/libc/gen/vis.c
Modified:
  head/contrib/libc-vis/unvis.3
  head/contrib/libc-vis/unvis.c
  head/contrib/libc-vis/vis.3
  head/contrib/libc-vis/vis.c
  head/contrib/libc-vis/vis.h
  head/include/Makefile
  head/lib/libc/gen/Makefile.inc
  head/lib/libc/gen/Symbol.map

Modified: head/contrib/libc-vis/unvis.3
==============================================================================
--- vendor/NetBSD/libc-vis/dist/unvis.3 Fri Dec 14 23:13:06 2012        
(r244235)
+++ head/contrib/libc-vis/unvis.3       Tue Dec 18 16:37:24 2012        
(r244401)
@@ -1,4 +1,5 @@
 .\"    $NetBSD: unvis.3,v 1.23 2011/03/17 14:06:29 wiz Exp $
+.\"    $FreeBSD$
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -241,4 +242,6 @@ The
 and
 .Fn strnunvisx
 functions appeared in
-.Nx 6.0 .
+.Nx 6.0
+and
+.Fx 10.0 .

Modified: head/contrib/libc-vis/unvis.c
==============================================================================
--- vendor/NetBSD/libc-vis/dist/unvis.c Fri Dec 14 23:13:06 2012        
(r244235)
+++ head/contrib/libc-vis/unvis.c       Tue Dec 18 16:37:24 2012        
(r244401)
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)unvis.c   8.1 
 __RCSID("$NetBSD: unvis.c,v 1.40 2012/12/14 21:31:01 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
+__FBSDID("$FreeBSD$");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -48,6 +49,14 @@ __RCSID("$NetBSD: unvis.c,v 1.40 2012/12
 #include <errno.h>
 #include <vis.h>
 
+#define        _DIAGASSERT(x)  assert(x)
+
+/*
+ * Return the number of elements in a statically-allocated array,
+ * __x.
+ */
+#define        __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
+
 #ifdef __weak_alias
 __weak_alias(strnunvisx,_strnunvisx)
 #endif

Modified: head/contrib/libc-vis/vis.3
==============================================================================
--- vendor/NetBSD/libc-vis/dist/vis.3   Fri Dec 14 23:13:06 2012        
(r244235)
+++ head/contrib/libc-vis/vis.3 Tue Dec 18 16:37:24 2012        (r244401)
@@ -1,4 +1,5 @@
 .\"    $NetBSD: vis.3,v 1.29 2012/12/14 22:55:59 christos Exp $
+.\"    $FreeBSD$
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -438,7 +439,9 @@ The
 and
 .Fn strsvisx
 functions appeared in
-.Nx 1.5 .
+.Nx 1.5
+and
+.Fx 10.0 .
 The buffer size limited versions of the functions
 .Po Fn nvis ,
 .Fn strnvis ,
@@ -448,4 +451,6 @@ The buffer size limited versions of the 
 and
 .Fn strsnvisx Pc
 appeared in
-.Nx 6.0 .
+.Nx 6.0
+and
+.Fx 10.0 .

Modified: head/contrib/libc-vis/vis.c
==============================================================================
--- vendor/NetBSD/libc-vis/dist/vis.c   Fri Dec 14 23:13:06 2012        
(r244235)
+++ head/contrib/libc-vis/vis.c Tue Dec 18 16:37:24 2012        (r244401)
@@ -59,6 +59,7 @@
 #if defined(LIBC_SCCS) && !defined(lint)
 __RCSID("$NetBSD: vis.c,v 1.45 2012/12/14 21:38:18 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
+__FBSDID("$FreeBSD$");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -68,6 +69,8 @@ __RCSID("$NetBSD: vis.c,v 1.45 2012/12/1
 #include <errno.h>
 #include <stdlib.h>
 
+#define        _DIAGASSERT(x)  assert(x)
+
 #ifdef __weak_alias
 __weak_alias(strvisx,_strvisx)
 #endif

Modified: head/contrib/libc-vis/vis.h
==============================================================================
--- vendor/NetBSD/libc-vis/dist/vis.h   Fri Dec 14 23:13:06 2012        
(r244235)
+++ head/contrib/libc-vis/vis.h Tue Dec 18 16:37:24 2012        (r244401)
@@ -1,4 +1,5 @@
 /*     $NetBSD: vis.h,v 1.20 2012/12/14 21:36:59 christos Exp $        */
+/*     $FreeBSD$       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -58,11 +59,11 @@
 #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 */
+#define        VIS_GLOB        0x0100  /* encode glob(3) magic characters */
+#define        VIS_MIMESTYLE   0x0200  /* mime-style escape = HEX HEX */
+#define        VIS_HTTP1866    0x0400  /* http-style &#num; or &string; */
+#define        VIS_NOESCAPE    0x0800  /* don't decode `\' */
+#define        _VIS_END        0x1000  /* for unvis */
 
 /*
  * unvis return codes
@@ -106,7 +107,7 @@ int strunvisx(char *, const char *, int)
 int    strnunvisx(char *, size_t, const char *, int);
 
 #ifndef __LIBC12_SOURCE__
-int    unvis(char *, int, int *, int) __RENAME(__unvis50);
+int    unvis(char *, int, int *, int);
 #endif
 __END_DECLS
 

Modified: head/include/Makefile
==============================================================================
--- head/include/Makefile       Tue Dec 18 16:15:20 2012        (r244400)
+++ head/include/Makefile       Tue Dec 18 16:37:24 2012        (r244401)
@@ -23,9 +23,12 @@ INCS=        a.out.h ar.h assert.h bitstring.h 
        stdnoreturn.h stdio.h stdlib.h string.h stringlist.h \
        strings.h sysexits.h tar.h termios.h tgmath.h \
        time.h timeconv.h timers.h ttyent.h \
-       ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h vis.h \
+       ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h \
        wchar.h wctype.h wordexp.h xlocale.h
 
+.PATH: ${.CURDIR}/../contrib/libc-vis
+INCS+= vis.h
+
 MHDRS= float.h floatingpoint.h stdarg.h
 
 PHDRS= sched.h _semaphore.h

Modified: head/lib/libc/gen/Makefile.inc
==============================================================================
--- head/lib/libc/gen/Makefile.inc      Tue Dec 18 16:15:20 2012        
(r244400)
+++ head/lib/libc/gen/Makefile.inc      Tue Dec 18 16:37:24 2012        
(r244401)
@@ -32,13 +32,16 @@ SRCS+=  __getosreldate.c __xuname.c \
        sigsetops.c sleep.c srand48.c statvfs.c stringlist.c strtofflags.c \
        sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
        syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
-       ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis.c \
-       usleep.c utime.c utxdb.c valloc.c vis.c wait.c wait3.c waitpid.c \
+       ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis-compat.c \
+       usleep.c utime.c utxdb.c valloc.c wait.c wait3.c waitpid.c \
        waitid.c wordexp.c
 
 .PATH: ${.CURDIR}/../../contrib/libc-pwcache
 SRCS+= pwcache.c pwcache.h
 
+.PATH: ${.CURDIR}/../../contrib/libc-vis
+SRCS+= unvis.c vis.c
+
 MISRCS+=modf.c
 
 CANCELPOINTS_SRCS=sem.c sem_new.c

Modified: head/lib/libc/gen/Symbol.map
==============================================================================
--- head/lib/libc/gen/Symbol.map        Tue Dec 18 16:15:20 2012        
(r244400)
+++ head/lib/libc/gen/Symbol.map        Tue Dec 18 16:37:24 2012        
(r244401)
@@ -298,9 +298,6 @@ FBSD_1.0 {
        ualarm;
        ulimit;
        uname;
-       unvis;
-       strunvis;
-       strunvisx;
        usleep;
        utime;
        valloc;
@@ -388,9 +385,23 @@ FBSD_1.3 {
        __FreeBSD_libc_enter_restricted_mode;
        getcontextx;
        gid_from_group;
+       nvis;
        pwcache_userdb;
        pwcache_groupdb;
+       snvis;
+       strnunvis;
+       strnunvisx;
+       strunvis;
+       strunvisx;
+       strnvis;
+       strnvisx;
+       strsnvis;
+       strsnvisx;
+       strsvis;
+       strsvisx;
+       svis;
        uid_from_user;
+       unvis;
        waitid;
 };
 

Added: head/lib/libc/gen/unvis-compat.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/gen/unvis-compat.c    Tue Dec 18 16:37:24 2012        
(r244401)
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2012 SRI International
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <vis.h>
+
+#define        _UNVIS_END      1
+
+int
+__unvis_44bsd(char *cp, int c, int *astate, int flag)
+{
+
+       if (flag & _UNVIS_END)
+               flag = (flag & ~_UNVIS_END) ^ UNVIS_END;
+       return unvis(cp, c, astate, flag);
+}
+
+__sym_compat(unvis, __vis_44bsd, FBSD_1.0);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to