Module Name: src
Committed By: christos
Date: Sat Mar 12 19:52:48 UTC 2011
Modified Files:
src/distrib/sets/lists/base: ad.mips64eb ad.mips64el md.amd64
md.sparc64 shl.mi
src/distrib/sets/lists/comp: ad.mips64eb ad.mips64el md.amd64
md.sparc64 mi shl.mi
src/include: vis.h
src/lib/libc: shlib_version
src/lib/libc/compat/gen: Makefile.inc compat_unvis.c
src/lib/libc/compat/include: vis.h
src/lib/libc/gen: Makefile.inc unvis.3 unvis.c vis.3 vis.c
src/lib/libc/include: namespace.h
src/tests/lib/libc/gen: t_vis.c
Added Files:
src/lib/libc/compat/gen: compat___unvis13.c
Log Message:
Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/distrib/sets/lists/base/ad.mips64eb
cvs rdiff -u -r1.41 -r1.42 src/distrib/sets/lists/base/ad.mips64el
cvs rdiff -u -r1.116 -r1.117 src/distrib/sets/lists/base/md.amd64
cvs rdiff -u -r1.109 -r1.110 src/distrib/sets/lists/base/md.sparc64
cvs rdiff -u -r1.577 -r1.578 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.24 -r1.25 src/distrib/sets/lists/comp/ad.mips64eb \
src/distrib/sets/lists/comp/ad.mips64el
cvs rdiff -u -r1.102 -r1.103 src/distrib/sets/lists/comp/md.amd64
cvs rdiff -u -r1.88 -r1.89 src/distrib/sets/lists/comp/md.sparc64
cvs rdiff -u -r1.1597 -r1.1598 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.162 -r1.163 src/distrib/sets/lists/comp/shl.mi
cvs rdiff -u -r1.18 -r1.19 src/include/vis.h
cvs rdiff -u -r1.221 -r1.222 src/lib/libc/shlib_version
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/compat/gen/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/compat/gen/compat___unvis13.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/compat/gen/compat_unvis.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/compat/include/vis.h
cvs rdiff -u -r1.173 -r1.174 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/gen/unvis.3
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/gen/unvis.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/gen/vis.3
cvs rdiff -u -r1.43 -r1.44 src/lib/libc/gen/vis.c
cvs rdiff -u -r1.146 -r1.147 src/lib/libc/include/namespace.h
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/t_vis.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/base/ad.mips64eb
diff -u src/distrib/sets/lists/base/ad.mips64eb:1.43 src/distrib/sets/lists/base/ad.mips64eb:1.44
--- src/distrib/sets/lists/base/ad.mips64eb:1.43 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/base/ad.mips64eb Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64eb,v 1.43 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: ad.mips64eb,v 1.44 2011/03/12 19:52:45 christos Exp $
./libexec/ld.elf_so-64 base-compat-shlib compat,pic
./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic
./usr/lib/64 base-compat-lib
@@ -66,7 +66,7 @@
./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/64/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/64/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/64/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/64/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic
@@ -333,7 +333,7 @@
./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/o32/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/o32/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/o32/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic
Index: src/distrib/sets/lists/base/ad.mips64el
diff -u src/distrib/sets/lists/base/ad.mips64el:1.41 src/distrib/sets/lists/base/ad.mips64el:1.42
--- src/distrib/sets/lists/base/ad.mips64el:1.41 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/base/ad.mips64el Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64el,v 1.41 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: ad.mips64el,v 1.42 2011/03/12 19:52:45 christos Exp $
./libexec/ld.elf_so-64 base-compat-shlib compat,pic
./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic
./usr/lib/64 base-compat-lib
@@ -66,7 +66,7 @@
./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/64/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/64/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/64/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/64/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic
@@ -333,7 +333,7 @@
./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/o32/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/o32/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/o32/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic
Index: src/distrib/sets/lists/base/md.amd64
diff -u src/distrib/sets/lists/base/md.amd64:1.116 src/distrib/sets/lists/base/md.amd64:1.117
--- src/distrib/sets/lists/base/md.amd64:1.116 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/base/md.amd64 Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.116 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: md.amd64,v 1.117 2011/03/12 19:52:45 christos Exp $
./dev/lms0 base-obsolete obsolete
./dev/mms0 base-obsolete obsolete
./libexec/ld.elf_so-i386 base-sys-shlib compat,pic
@@ -69,7 +69,7 @@
./usr/lib/i386/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/i386/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/i386/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/i386/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/i386/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/i386/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/i386/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/i386/libcrypt.so.1 base-compat-shlib compat,pic
Index: src/distrib/sets/lists/base/md.sparc64
diff -u src/distrib/sets/lists/base/md.sparc64:1.109 src/distrib/sets/lists/base/md.sparc64:1.110
--- src/distrib/sets/lists/base/md.sparc64:1.109 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/base/md.sparc64 Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc64,v 1.109 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: md.sparc64,v 1.110 2011/03/12 19:52:45 christos Exp $
./libexec/ld.elf_so-sparc base-sysutil-bin compat,pic
./sbin/edlabel base-sysutil-root obsolete
./usr/bin/fdformat base-util-bin
@@ -67,7 +67,7 @@
./usr/lib/sparc/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/sparc/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/sparc/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/sparc/libc.so.12.176 base-compat-shlib compat,pic
+./usr/lib/sparc/libc.so.12.177 base-compat-shlib compat,pic
./usr/lib/sparc/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/sparc/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/sparc/libcrypt.so.1 base-compat-shlib compat,pic
Index: src/distrib/sets/lists/base/shl.mi
diff -u src/distrib/sets/lists/base/shl.mi:1.577 src/distrib/sets/lists/base/shl.mi:1.578
--- src/distrib/sets/lists/base/shl.mi:1.577 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/base/shl.mi Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.577 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: shl.mi,v 1.578 2011/03/12 19:52:45 christos Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -15,7 +15,7 @@
#
./lib/libc.so base-sys-shlib dynamicroot
./lib/libc.so.12 base-sys-shlib dynamicroot
-./lib/libc.so.12.176 base-sys-shlib dynamicroot
+./lib/libc.so.12.177 base-sys-shlib dynamicroot
./lib/libcrypt.so base-sys-shlib dynamicroot
./lib/libcrypt.so.1 base-sys-shlib dynamicroot
./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot
@@ -170,7 +170,7 @@
./usr/lib/libbz2.so.1.1 base-sys-shlib
./usr/lib/libc.so base-sys-shlib
./usr/lib/libc.so.12 base-sys-shlib
-./usr/lib/libc.so.12.176 base-sys-shlib
+./usr/lib/libc.so.12.177 base-sys-shlib
./usr/lib/libcdk.so base-obsolete obsolete
./usr/lib/libcom_err.so base-krb5-shlib kerberos
./usr/lib/libcom_err.so.6 base-krb5-shlib kerberos
Index: src/distrib/sets/lists/comp/ad.mips64eb
diff -u src/distrib/sets/lists/comp/ad.mips64eb:1.24 src/distrib/sets/lists/comp/ad.mips64eb:1.25
--- src/distrib/sets/lists/comp/ad.mips64eb:1.24 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/comp/ad.mips64eb Sat Mar 12 14:52:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64eb,v 1.24 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: ad.mips64eb,v 1.25 2011/03/12 19:52:46 christos Exp $
./usr/bin/elf2aout comp-obsolete obsolete
./usr/bin/elf2ecoff comp-sysutil-bin
./usr/include/mips comp-c-include
@@ -1153,7 +1153,7 @@
./usr/libdata/debug/usr/lib/64/libbluetooth.so.4.2.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libbz2.so.1.1.debug comp-sys-debug debug,compat
-./usr/libdata/debug/usr/lib/64/libc.so.12.176.debug comp-sys-debug debug,compat
+./usr/libdata/debug/usr/lib/64/libc.so.12.177.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libcom_err.so.6.0.debug comp-krb5-debug kerberos,debug,compat
./usr/libdata/debug/usr/lib/64/libcrypt.so.1.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libcrypto.so.6.1.debug comp-crypto-debug crypto,debug,compat
@@ -1345,7 +1345,7 @@
./usr/libdata/debug/usr/lib/o32/libbluetooth.so.4.2.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libbz2.so.1.1.debug comp-sys-debug debug,compat
-./usr/libdata/debug/usr/lib/o32/libc.so.12.176.debug comp-sys-debug debug,compat
+./usr/libdata/debug/usr/lib/o32/libc.so.12.177.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libcom_err.so.6.0.debug comp-krb5-debug kerberos,debug,compat
./usr/libdata/debug/usr/lib/o32/libcrypt.so.1.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libcrypto.so.6.1.debug comp-crypto-debug crypto,debug,compat
Index: src/distrib/sets/lists/comp/ad.mips64el
diff -u src/distrib/sets/lists/comp/ad.mips64el:1.24 src/distrib/sets/lists/comp/ad.mips64el:1.25
--- src/distrib/sets/lists/comp/ad.mips64el:1.24 Tue Feb 15 22:42:17 2011
+++ src/distrib/sets/lists/comp/ad.mips64el Sat Mar 12 14:52:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64el,v 1.24 2011/02/16 03:42:17 christos Exp $
+# $NetBSD: ad.mips64el,v 1.25 2011/03/12 19:52:46 christos Exp $
./usr/bin/elf2aout comp-obsolete obsolete
./usr/bin/elf2ecoff comp-sysutil-bin
./usr/include/mips comp-c-include
@@ -1153,7 +1153,7 @@
./usr/libdata/debug/usr/lib/64/libbluetooth.so.4.2.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libbz2.so.1.1.debug comp-sys-debug debug,compat
-./usr/libdata/debug/usr/lib/64/libc.so.12.176.debug comp-sys-debug debug,compat
+./usr/libdata/debug/usr/lib/64/libc.so.12.177.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libcom_err.so.6.0.debug comp-krb5-debug kerberos,debug,compat
./usr/libdata/debug/usr/lib/64/libcrypt.so.1.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/64/libcrypto.so.6.1.debug comp-crypto-debug crypto,debug,compat
@@ -1345,7 +1345,7 @@
./usr/libdata/debug/usr/lib/o32/libbluetooth.so.4.2.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libbz2.so.1.1.debug comp-sys-debug debug,compat
-./usr/libdata/debug/usr/lib/o32/libc.so.12.176.debug comp-sys-debug debug,compat
+./usr/libdata/debug/usr/lib/o32/libc.so.12.177.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libcom_err.so.6.0.debug comp-krb5-debug kerberos,debug,compat
./usr/libdata/debug/usr/lib/o32/libcrypt.so.1.0.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/lib/o32/libcrypto.so.6.1.debug comp-crypto-debug crypto,debug,compat
Index: src/distrib/sets/lists/comp/md.amd64
diff -u src/distrib/sets/lists/comp/md.amd64:1.102 src/distrib/sets/lists/comp/md.amd64:1.103
--- src/distrib/sets/lists/comp/md.amd64:1.102 Tue Feb 15 22:42:18 2011
+++ src/distrib/sets/lists/comp/md.amd64 Sat Mar 12 14:52:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.102 2011/02/16 03:42:18 christos Exp $
+# $NetBSD: md.amd64,v 1.103 2011/03/12 19:52:46 christos Exp $
./usr/include/amd64 comp-c-include
./usr/include/amd64/ansi.h comp-c-include
./usr/include/amd64/aout_machdep.h comp-c-include
@@ -932,7 +932,7 @@
./usr/libdata/debug/usr/lib/i386/libbluetooth.so.4.2.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/i386/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/i386/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug
-./usr/libdata/debug/usr/lib/i386/libc.so.12.176.debug comp-compat-shlib compat,pic,debug
+./usr/libdata/debug/usr/lib/i386/libc.so.12.177.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/i386/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,kerberos,debug
./usr/libdata/debug/usr/lib/i386/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/i386/libcrypto.so.6.1.debug comp-compat-shlib compat,pic,debug
Index: src/distrib/sets/lists/comp/md.sparc64
diff -u src/distrib/sets/lists/comp/md.sparc64:1.88 src/distrib/sets/lists/comp/md.sparc64:1.89
--- src/distrib/sets/lists/comp/md.sparc64:1.88 Tue Feb 15 22:42:18 2011
+++ src/distrib/sets/lists/comp/md.sparc64 Sat Mar 12 14:52:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc64,v 1.88 2011/02/16 03:42:18 christos Exp $
+# $NetBSD: md.sparc64,v 1.89 2011/03/12 19:52:46 christos Exp $
./usr/include/ieeefp.h comp-c-include
./usr/include/sparc comp-c-include
./usr/include/sparc/_G_config.h comp-obsolete obsolete
@@ -693,7 +693,7 @@
./usr/libdata/debug/usr/lib/sparc/libbluetooth.so.4.2.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/sparc/libbsdmalloc.so.0.0.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/sparc/libbz2.so.1.1.debug comp-compat-shlib compat,pic,debug
-./usr/libdata/debug/usr/lib/sparc/libc.so.12.176.debug comp-compat-shlib compat,pic,debug
+./usr/libdata/debug/usr/lib/sparc/libc.so.12.177.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/sparc/libcom_err.so.6.0.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/sparc/libcrypt.so.1.0.debug comp-compat-shlib compat,pic,debug
./usr/libdata/debug/usr/lib/sparc/libcrypto.so.6.1.debug comp-compat-shlib compat,pic,debug,crypto
Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1597 src/distrib/sets/lists/comp/mi:1.1598
--- src/distrib/sets/lists/comp/mi:1.1597 Fri Mar 11 14:50:33 2011
+++ src/distrib/sets/lists/comp/mi Sat Mar 12 14:52:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1597 2011/03/11 19:50:33 jruoho Exp $
+# $NetBSD: mi,v 1.1598 2011/03/12 19:52:46 christos Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -7487,6 +7487,7 @@
./usr/share/man/cat3/ntoa.0 comp-c-catman .cat
./usr/share/man/cat3/ntohl.0 comp-c-catman .cat
./usr/share/man/cat3/ntohs.0 comp-c-catman .cat
+./usr/share/man/cat3/nvis.0 comp-c-catman .cat
./usr/share/man/cat3/offsetof.0 comp-c-catman .cat
./usr/share/man/cat3/offtime.0 comp-c-catman .cat
./usr/share/man/cat3/offtime_r.0 comp-c-catman .cat
@@ -8336,6 +8337,7 @@
./usr/share/man/cat3/snprintb.0 comp-c-catman .cat
./usr/share/man/cat3/snprintb_m.0 comp-c-catman .cat
./usr/share/man/cat3/snprintf.0 comp-c-catman .cat
+./usr/share/man/cat3/snvis.0 comp-c-catman .cat
./usr/share/man/cat3/sockaddr_snprintf.0 comp-c-catman .cat
./usr/share/man/cat3/sockatmark.0 comp-c-catman .cat
./usr/share/man/cat3/sprintf.0 comp-c-catman .cat
@@ -8389,11 +8391,17 @@
./usr/share/man/cat3/strncpy.0 comp-c-catman .cat
./usr/share/man/cat3/strndup.0 comp-c-catman .cat
./usr/share/man/cat3/strnlen.0 comp-c-catman .cat
+./usr/share/man/cat3/strnunvis.0 comp-c-catman .cat
+./usr/share/man/cat3/strnunvisx.0 comp-c-catman .cat
+./usr/share/man/cat3/strnvis.0 comp-c-catman .cat
+./usr/share/man/cat3/strnvisx.0 comp-c-catman .cat
./usr/share/man/cat3/strpbrk.0 comp-c-catman .cat
./usr/share/man/cat3/strptime.0 comp-c-catman .cat
./usr/share/man/cat3/strrchr.0 comp-c-catman .cat
./usr/share/man/cat3/strsep.0 comp-c-catman .cat
./usr/share/man/cat3/strsignal.0 comp-c-catman .cat
+./usr/share/man/cat3/strsnvis.0 comp-c-catman .cat
+./usr/share/man/cat3/strsnvisx.0 comp-c-catman .cat
./usr/share/man/cat3/strspn.0 comp-c-catman .cat
./usr/share/man/cat3/strstr.0 comp-c-catman .cat
./usr/share/man/cat3/strsuftoll.0 comp-c-catman .cat
@@ -13509,6 +13517,7 @@
./usr/share/man/html3/ntoa.html comp-c-htmlman html
./usr/share/man/html3/ntohl.html comp-c-htmlman html
./usr/share/man/html3/ntohs.html comp-c-htmlman html
+./usr/share/man/html3/nvis.html comp-c-htmlman html
./usr/share/man/html3/offsetof.html comp-c-htmlman html
./usr/share/man/html3/offtime.html comp-c-htmlman html
./usr/share/man/html3/offtime_r.html comp-c-htmlman html
@@ -14334,6 +14343,7 @@
./usr/share/man/html3/snprintb.html comp-c-htmlman html
./usr/share/man/html3/snprintb_m.html comp-c-htmlman html
./usr/share/man/html3/snprintf.html comp-c-htmlman html
+./usr/share/man/html3/snvis.html comp-c-htmlman html
./usr/share/man/html3/sockaddr_snprintf.html comp-c-htmlman html
./usr/share/man/html3/sockatmark.html comp-c-htmlman html
./usr/share/man/html3/sprintf.html comp-c-htmlman html
@@ -14387,11 +14397,17 @@
./usr/share/man/html3/strncpy.html comp-c-htmlman html
./usr/share/man/html3/strndup.html comp-c-htmlman html
./usr/share/man/html3/strnlen.html comp-c-htmlman html
+./usr/share/man/html3/strnunvis.html comp-c-htmlman html
+./usr/share/man/html3/strnunvisx.html comp-c-htmlman html
+./usr/share/man/html3/strnvis.html comp-c-htmlman html
+./usr/share/man/html3/strnvisx.html comp-c-htmlman html
./usr/share/man/html3/strpbrk.html comp-c-htmlman html
./usr/share/man/html3/strptime.html comp-c-htmlman html
./usr/share/man/html3/strrchr.html comp-c-htmlman html
./usr/share/man/html3/strsep.html comp-c-htmlman html
./usr/share/man/html3/strsignal.html comp-c-htmlman html
+./usr/share/man/html3/strsnvis.html comp-c-htmlman html
+./usr/share/man/html3/strsnvisx.html comp-c-htmlman html
./usr/share/man/html3/strspn.html comp-c-htmlman html
./usr/share/man/html3/strstr.html comp-c-htmlman html
./usr/share/man/html3/strsuftoll.html comp-c-htmlman html
@@ -19523,6 +19539,7 @@
./usr/share/man/man3/ntoa.3 comp-c-man .man
./usr/share/man/man3/ntohl.3 comp-c-man .man
./usr/share/man/man3/ntohs.3 comp-c-man .man
+./usr/share/man/man3/nvis.3 comp-c-man .man
./usr/share/man/man3/offsetof.3 comp-c-man .man
./usr/share/man/man3/offtime.3 comp-c-man .man
./usr/share/man/man3/offtime_r.3 comp-c-man .man
@@ -20368,6 +20385,7 @@
./usr/share/man/man3/snprintb.3 comp-c-man .man
./usr/share/man/man3/snprintb_m.3 comp-c-man .man
./usr/share/man/man3/snprintf.3 comp-c-man .man
+./usr/share/man/man3/snvis.3 comp-c-man .man
./usr/share/man/man3/sockaddr_snprintf.3 comp-c-man .man
./usr/share/man/man3/sockatmark.3 comp-c-man .man
./usr/share/man/man3/sprintf.3 comp-c-man .man
@@ -20421,11 +20439,17 @@
./usr/share/man/man3/strncpy.3 comp-c-man .man
./usr/share/man/man3/strndup.3 comp-c-man .man
./usr/share/man/man3/strnlen.3 comp-c-man .man
+./usr/share/man/man3/strnunvis.3 comp-c-man .man
+./usr/share/man/man3/strnunvisx.3 comp-c-man .man
+./usr/share/man/man3/strnvis.3 comp-c-man .man
+./usr/share/man/man3/strnvisx.3 comp-c-man .man
./usr/share/man/man3/strpbrk.3 comp-c-man .man
./usr/share/man/man3/strptime.3 comp-c-man .man
./usr/share/man/man3/strrchr.3 comp-c-man .man
./usr/share/man/man3/strsep.3 comp-c-man .man
./usr/share/man/man3/strsignal.3 comp-c-man .man
+./usr/share/man/man3/strsnvis.3 comp-c-man .man
+./usr/share/man/man3/strsnvisx.3 comp-c-man .man
./usr/share/man/man3/strspn.3 comp-c-man .man
./usr/share/man/man3/strstr.3 comp-c-man .man
./usr/share/man/man3/strsuftoll.3 comp-c-man .man
Index: src/distrib/sets/lists/comp/shl.mi
diff -u src/distrib/sets/lists/comp/shl.mi:1.162 src/distrib/sets/lists/comp/shl.mi:1.163
--- src/distrib/sets/lists/comp/shl.mi:1.162 Tue Feb 15 22:42:18 2011
+++ src/distrib/sets/lists/comp/shl.mi Sat Mar 12 14:52:47 2011
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.162 2011/02/16 03:42:18 christos Exp $
+# $NetBSD: shl.mi,v 1.163 2011/03/12 19:52:47 christos Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -224,7 +224,7 @@
./usr/libdata/debug/usr/lib/libbluetooth.so.4.2.debug comp-sys-debug debug
./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug
./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug
-./usr/libdata/debug/usr/lib/libc.so.12.176.debug comp-sys-debug debug
+./usr/libdata/debug/usr/lib/libc.so.12.177.debug comp-sys-debug debug
./usr/libdata/debug/usr/lib/libcom_err.so.6.0.debug comp-krb5-debug kerberos,debug
./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug
./usr/libdata/debug/usr/lib/libcrypto.so.6.1.debug comp-crypto-debug crypto,debug
Index: src/include/vis.h
diff -u src/include/vis.h:1.18 src/include/vis.h:1.19
--- src/include/vis.h:1.18 Sat Nov 27 14:44:54 2010
+++ src/include/vis.h Sat Mar 12 14:52:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.18 2010/11/27 19:44:54 christos Exp $ */
+/* $NetBSD: vis.h,v 1.19 2011/03/12 19:52:45 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -61,6 +61,7 @@
#define VIS_MIMESTYLE 0x100 /* mime-style escape = HEX HEX */
#define VIS_HTTP1866 0x200 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x400 /* don't decode `\' */
+#define _VIS_END 0x800 /* for unvis */
/*
* unvis return codes
@@ -74,21 +75,37 @@
/*
* unvis flags
*/
-#define UNVIS_END 1 /* no more characters */
+#define UNVIS_END _VIS_END /* no more characters */
#include <sys/cdefs.h>
__BEGIN_DECLS
char *vis(char *, int, int, int);
+char *nvis(char *, size_t, int, int, int);
+
char *svis(char *, int, int, int, const char *);
+char *snvis(char *, size_t, int, int, int, const char *);
+
int strvis(char *, const char *, int);
+int strnvis(char *, size_t, const char *, int);
+
int strsvis(char *, const char *, int, const char *);
+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 strsvisx(char *, const char *, size_t, int, const char *);
+int strsnvisx(char *, size_t, const char *, size_t, int, const char *);
+
int strunvis(char *, const char *);
+int strnunvis(char *, size_t, const char *);
+
int strunvisx(char *, const char *, int);
+int strnunvisx(char *, size_t, const char *, int);
+
#ifndef __LIBC12_SOURCE__
-int unvis(char *, int, int *, int) __RENAME(__unvis13);
+int unvis(char *, int, int *, int) __RENAME(__unvis50);
#endif
__END_DECLS
Index: src/lib/libc/shlib_version
diff -u src/lib/libc/shlib_version:1.221 src/lib/libc/shlib_version:1.222
--- src/lib/libc/shlib_version:1.221 Fri Feb 4 17:07:41 2011
+++ src/lib/libc/shlib_version Sat Mar 12 14:52:47 2011
@@ -1,4 +1,4 @@
-# $NetBSD: shlib_version,v 1.221 2011/02/04 22:07:41 christos Exp $
+# $NetBSD: shlib_version,v 1.222 2011/03/12 19:52:47 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@@ -31,4 +31,4 @@
# it's insufficient bitwidth to implement all ctype class.
# see isblank's comment in ctype.h.
major=12
-minor=176
+minor=177
Index: src/lib/libc/compat/gen/Makefile.inc
diff -u src/lib/libc/compat/gen/Makefile.inc:1.13 src/lib/libc/compat/gen/Makefile.inc:1.14
--- src/lib/libc/compat/gen/Makefile.inc:1.13 Fri Apr 23 15:04:54 2010
+++ src/lib/libc/compat/gen/Makefile.inc Sat Mar 12 14:52:47 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.13 2010/04/23 19:04:54 drochner Exp $
+# $NetBSD: Makefile.inc,v 1.14 2011/03/12 19:52:47 christos Exp $
.PATH: ${COMPATDIR}/gen
SRCS+=compat_errlist.c compat_fts.c compat___fts13.c compat___fts30.c \
@@ -8,4 +8,5 @@
compat_times.c compat_timezone.c compat_unvis.c compat_utmpx.c \
compat__sys_errlist.c compat__sys_nerr.c compat__sys_siglist.c \
compat_time.c compat_utime.c compat_devname.c compat_alphasort.c \
- compat_getpwent.c compat___fts32.c compat_utmp.c compat___fts50.c
+ compat_getpwent.c compat___fts32.c compat_utmp.c compat___fts50.c \
+ compat___unvis13.c
Index: src/lib/libc/compat/gen/compat_unvis.c
diff -u src/lib/libc/compat/gen/compat_unvis.c:1.2 src/lib/libc/compat/gen/compat_unvis.c:1.3
--- src/lib/libc/compat/gen/compat_unvis.c:1.2 Fri Mar 9 20:13:14 2007
+++ src/lib/libc/compat/gen/compat_unvis.c Sat Mar 12 14:52:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_unvis.c,v 1.2 2007/03/10 01:13:14 hubertf Exp $ */
+/* $NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: compat_unvis.c,v 1.2 2007/03/10 01:13:14 hubertf Exp $");
+__RCSID("$NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -48,10 +48,6 @@
#include <vis.h>
#include <compat/include/vis.h>
-#ifdef __weak_alias
-__weak_alias(unvis,_unvis)
-#endif
-
#ifdef __warn_references
__warn_references(unvis,
"warning: reference to compatibility unvis(); include <vis.h> for correct reference")
@@ -60,5 +56,6 @@
int
unvis(char *cp, int c, int *astate, int flag)
{
- return __unvis13(cp, c, astate, flag);
+ flag = (flag & ~1) | ((flag & 1) ? UNVIS_END : 0);
+ return __unvis50(cp, c, astate, flag);
}
Index: src/lib/libc/compat/include/vis.h
diff -u src/lib/libc/compat/include/vis.h:1.1 src/lib/libc/compat/include/vis.h:1.2
--- src/lib/libc/compat/include/vis.h:1.1 Mon Sep 12 21:44:09 2005
+++ src/lib/libc/compat/include/vis.h Sat Mar 12 14:52:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: vis.h,v 1.2 2011/03/12 19:52:47 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,6 +37,7 @@
__BEGIN_DECLS
int unvis(char *, int, int *, int);
int __unvis13(char *, int, int *, int);
+int __unvis50(char *, int, int *, int);
__END_DECLS
#endif /* !_COMPAT_VIS_H_ */
Index: src/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.173 src/lib/libc/gen/Makefile.inc:1.174
--- src/lib/libc/gen/Makefile.inc:1.173 Sun Dec 12 15:22:48 2010
+++ src/lib/libc/gen/Makefile.inc Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.173 2010/12/12 20:22:48 christos Exp $
+# $NetBSD: Makefile.inc,v 1.174 2011/03/12 19:52:48 christos Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
@@ -155,8 +155,11 @@
syslog.3 vsyslogp.3 syslog.3 vsyslogp_r.3
MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 ttyname.3 ttyname_r.3
MLINKS+=unvis.3 strunvis.3 unvis.3 strunvisx.3
+MLINKS+=unvis.3 strnunvis.3 unvis.3 strnunvisx.3
MLINKS+=vis.3 svis.3 vis.3 strvis.3 vis.3 strvisx.3 vis.3 strsvis.3 \
- vis.3 strsvisx.3
+ vis.3 strsvisx.3 vis.3 nvis.3
+MLINKS+=vis.3 snvis.3 vis.3 strnvis.3 vis.3 strnvisx.3 vis.3 strsnvis.3 \
+ vis.3 strsnvisx.3
CPPFLAGS.ctype_.c+= -I${LIBCDIR}/locale
CPPFLAGS.isctype.c+= -I${LIBCDIR}/locale
Index: src/lib/libc/gen/unvis.3
diff -u src/lib/libc/gen/unvis.3:1.20 src/lib/libc/gen/unvis.3:1.21
--- src/lib/libc/gen/unvis.3:1.20 Sat Nov 27 20:28:21 2010
+++ src/lib/libc/gen/unvis.3 Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: unvis.3,v 1.20 2010/11/28 01:28:21 wiz Exp $
+.\" $NetBSD: unvis.3,v 1.21 2011/03/12 19:52:48 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
.\"
-.Dd November 27, 2010
+.Dd March 12, 2011
.Dt UNVIS 3
.Os
.Sh NAME
@@ -45,7 +45,11 @@
.Ft int
.Fn strunvis "char *dst" "const char *src"
.Ft int
+.Fn strnunvis "char *dst" "size_t dlen", "const char *src"
+.Ft int
.Fn strunvisx "char *dst" "const char *src" "int flag"
+.Ft int
+.Fn strnunvisx "char *dst" "size_t dlen", "const char *src" "int flag"
.Sh DESCRIPTION
The
.Fn unvis ,
@@ -191,6 +195,34 @@
if (unvis(\*[Am]out, '\e0', \*[Am]state, UNVIS_END) == UNVIS_VALID)
(void)putchar(out);
.Ed
+.Sh ERRORS
+The functions
+.Fn strunvis ,
+.Fn strnunvis ,
+.Fn strunvisx
+and
+.Fn strnunvisx
+will return
+.Dv -1
+on error and set
+.Va errno
+to:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+An invalid escape sequence was detected, or the decoder is in an unknown state.
+.El
+.Pp
+In addition the functions
+.Fn strnunvis
+and
+.Fn strnunvisx
+will can also set
+.Va errno
+on error to:
+.Bl -tag -width Er
+.It Bq Er ENOSPC
+Not enough space to perform the conversion.
+.El
.Sh SEE ALSO
.Xr unvis 1 ,
.Xr vis 1 ,
Index: src/lib/libc/gen/unvis.c
diff -u src/lib/libc/gen/unvis.c:1.33 src/lib/libc/gen/unvis.c:1.34
--- src/lib/libc/gen/unvis.c:1.33 Sat Feb 26 20:53:22 2011
+++ src/lib/libc/gen/unvis.c Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.33 2011/02/27 01:53:22 christos Exp $ */
+/* $NetBSD: unvis.c,v 1.34 2011/03/12 19:52:48 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.33 2011/02/27 01:53:22 christos Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.34 2011/03/12 19:52:48 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -45,10 +45,11 @@
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
+#include <errno.h>
#include <vis.h>
#ifdef __weak_alias
-__weak_alias(strunvis,_strunvis)
+__weak_alias(strnunvisx,_strnunvisx)
#endif
#if !HAVE_VIS
@@ -469,47 +470,76 @@
}
/*
- * strunvis - decode src into dst
+ * strnunvisx - decode src into dst
*
* Number of chars decoded into dst is returned, -1 on error.
* Dst is null terminated.
*/
int
-strunvisx(char *dst, const char *src, int flag)
+strnunvisx(char *dst, size_t dlen, const char *src, int flag)
{
char c;
- char *start = dst;
+ char t, *start = dst;
int state = 0;
_DIAGASSERT(src != NULL);
_DIAGASSERT(dst != NULL);
+#define CHECKSPACE() \
+ do { \
+ if (dlen-- == 0) { \
+ errno = ENOSPC; \
+ return -1; \
+ } \
+ } while (/*CONSTCOND*/0)
while ((c = *src++) != '\0') {
again:
- switch (unvis(dst, c, &state, flag)) {
+ switch (unvis(&t, c, &state, flag)) {
case UNVIS_VALID:
- dst++;
+ CHECKSPACE();
+ *dst++ = t;
break;
case UNVIS_VALIDPUSH:
- dst++;
+ CHECKSPACE();
+ *dst++ = t;
goto again;
case 0:
case UNVIS_NOCHAR:
break;
+ case UNVIS_SYNBAD:
+ errno = EINVAL;
+ return -1;
default:
- return (-1);
+ _DIAGASSERT(0);
+ errno = EINVAL;
+ return -1;
}
}
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
+ if (unvis(&t, c, &state, UNVIS_END) == UNVIS_VALID) {
+ CHECKSPACE();
+ *dst++ = t;
+ }
+ CHECKSPACE();
*dst = '\0';
return (int)(dst - start);
}
int
+strunvisx(char *dst, const char *src, int flag)
+{
+ return strnunvisx(dst, ~0, src, flag);
+}
+
+int
strunvis(char *dst, const char *src)
{
- return strunvisx(dst, src, 0);
+ return strnunvisx(dst, ~0, src, 0);
+}
+
+int
+strnunvis(char *dst, size_t dlen, const char *src)
+{
+ return strnunvisx(dst, dlen, src, 0);
}
#endif
Index: src/lib/libc/gen/vis.3
diff -u src/lib/libc/gen/vis.3:1.23 src/lib/libc/gen/vis.3:1.24
--- src/lib/libc/gen/vis.3:1.23 Tue Feb 10 18:06:31 2009
+++ src/lib/libc/gen/vis.3 Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: vis.3,v 1.23 2009/02/10 23:06:31 christos Exp $
+.\" $NetBSD: vis.3,v 1.24 2011/03/12 19:52:48 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,16 +29,22 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd February 10, 2009
+.Dd March 12, 2011
.Dt VIS 3
.Os
.Sh NAME
.Nm vis ,
+.Nm nvis ,
.Nm strvis ,
+.Nm strnvis ,
.Nm strvisx ,
+.Nm strnvisx ,
.Nm svis ,
+.Nm snvis ,
.Nm strsvis ,
+.Nm strsnvis ,
.Nm strsvisx
+.Nm strsnvisx
.Nd visually encode characters
.Sh LIBRARY
.Lb libc
@@ -46,16 +52,28 @@
.In vis.h
.Ft char *
.Fn vis "char *dst" "int c" "int flag" "int nextc"
+.Ft char *
+.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc"
.Ft int
.Fn strvis "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"
+.Ft int
+.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
.Ft char *
.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
+.Ft char *
+.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra"
.Ft int
.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra"
.Ft int
+.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra"
+.Ft int
.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
+.Ft int
+.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra"
.Sh DESCRIPTION
The
.Fn vis
@@ -86,9 +104,11 @@
encoding format (explained below).
.Pp
The
-.Fn strvis
+.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
and
-.Fn strvisx
+.Fn strnvisx
functions copy into
.Fa dst
a visual representation of
@@ -96,14 +116,18 @@
.Fa src .
The
.Fn strvis
-function encodes characters from
+and
+.Fn strnvis
+functions encode characters from
.Fa src
up to the
first
.Dv NUL .
The
.Fn strvisx
-function encodes exactly
+and
+.Fn strnvisx
+functions encode exactly
.Fa len
characters from
.Fa src
@@ -125,17 +149,42 @@
forms return the number of characters in dst (not including
the trailing
.Dv NUL ) .
+The
+.Dq n
+versions of the functions also take an additional argument
+.Fa dlen
+that indicates the length of the
+.Fa dst
+buffer.
+If
+.Fa dlen
+is not large enough to fix the converted string then the
+.Fn strnvis
+and
+.Fn strnvisx
+functions return
+.Dv -1
+and set x
+.Va errno
+to
+.Dv ENOSPC .
.Pp
The functions
.Fn svis ,
+.Fn snvis ,
.Fn strsvis ,
+.Fn strsnvis ,
+.Fn strsvisx ,
and
-.Fn strsvisx
+.Fn strsnvisx
correspond to
.Fn vis ,
+.Fn nvis ,
.Fn strvis ,
-and
+.Fn strnvis ,
.Fn strvisx
+and
+.Fn strnvisx
but have an additional argument
.Fa extra ,
pointing to a
@@ -149,17 +198,21 @@
The encoding is a unique, invertible representation composed entirely of
graphic characters; it can be decoded back into the original form using
the
-.Xr unvis 3
-or
+.Xr unvis 3 ,
.Xr strunvis 3
+or
+.Xr strnunvis 3
functions.
.Pp
There are two parameters that can be controlled: the range of
characters that are encoded (applies only to
.Fn vis ,
+.Fn nvis ,
.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
and
-.Fn strvisx ) ,
+.Fn strnvisx ) ,
and the type of representation used.
By default, all non-graphic characters,
except space, tab, and newline are encoded.
@@ -191,9 +244,12 @@
.Pp
(The above flags have no effect for
.Fn svis ,
+.Fn snvis ,
.Fn strsvis ,
-and
+.Fn strsnvis ,
.Fn strsvisx .
+and
+.Fn strsnvisx .
When using these functions, place all graphic characters to be
encoded in an array pointed to by
.Fa extra .
@@ -328,6 +384,31 @@
.Ql M-C ) .
With this flag set, the encoding is
ambiguous and non-invertible.
+.Sh ERRORS
+The functions
+.Fn nvis
+and
+.Fn snvis
+will return
+.Dv NULL
+and the functions
+.Fn strnvis ,
+.Fn strnvisx ,
+.Fn strsnvis ,
+and
+.Fn strsnvisx ,
+will return
+.Dv -1
+when the
+.Fa dlen
+destination buffer length size is not enough to perform the conversion while
+setting
+.Va errno
+to:
+.Bl -tag -width Er
+.It Bq Er ENOSPC
+The destination buffer size is not large enough to perform the conversion.
+.El
.Sh SEE ALSO
.Xr unvis 1 ,
.Xr vis 1 ,
@@ -339,16 +420,26 @@
.Re
.Sh HISTORY
The
-.Fa vis ,
-.Fa strvis ,
+.Fn vis ,
+.Fn strvis ,
and
.Fa strvisx
functions first appeared in
.Bx 4.4 .
The
-.Fa svis ,
-.Fa strsvis ,
+.Fn svis ,
+.Fn strsvis ,
and
-.Fa strsvisx
+.Fn strsvisx
functions appeared in
.Nx 1.5 .
+The buffer size limited versions of the functions (
+.Fn nvis ,
+.Fn strnvis ,
+.Fn strnvisx ,
+.Fn snvis ,
+.Fn strsnvis ,
+and
+.Fn strsnvisx )
+appeared in
+.Nx 1.6 .
Index: src/lib/libc/gen/vis.c
diff -u src/lib/libc/gen/vis.c:1.43 src/lib/libc/gen/vis.c:1.44
--- src/lib/libc/gen/vis.c:1.43 Sat Mar 12 00:23:41 2011
+++ src/lib/libc/gen/vis.c Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.43 2011/03/12 05:23:41 christos Exp $ */
+/* $NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.43 2011/03/12 05:23:41 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.44 2011/03/12 19:52:48 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -65,15 +65,11 @@
#include <assert.h>
#include <vis.h>
+#include <errno.h>
#include <stdlib.h>
#ifdef __weak_alias
-__weak_alias(strsvis,_strsvis)
-__weak_alias(strsvisx,_strsvisx)
-__weak_alias(strvis,_strvis)
__weak_alias(strvisx,_strvisx)
-__weak_alias(svis,_svis)
-__weak_alias(vis,_vis)
#endif
#if !HAVE_VIS || !HAVE_SVIS
@@ -118,7 +114,7 @@
* This is do_hvis, for HTTP style (RFC 1808)
*/
static char *
-do_hvis(char *dst, size_t *len, int c, int flag, int nextc, const char *extra)
+do_hvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
if ((isascii(c) && isalnum(c))
@@ -127,12 +123,12 @@
/* extra */
|| c == '!' || c == '*' || c == '\'' || c == '(' || c == ')'
|| c == ',') {
- dst = do_svis(dst, len, c, flag, nextc, extra);
+ dst = do_svis(dst, dlen, c, flag, nextc, extra);
} else {
- if (len) {
- if (*len < 3)
+ if (dlen) {
+ if (*dlen < 3)
return NULL;
- *len -= 3;
+ *dlen -= 3;
}
*dst++ = '%';
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
@@ -147,7 +143,7 @@
* NB: No handling of long lines or CRLF.
*/
static char *
-do_mvis(char *dst, size_t *len, int c, int flag, int nextc, const char *extra)
+do_mvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
if ((c != '\n') &&
/* Space at the end of the line */
@@ -156,16 +152,16 @@
(!isspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) ||
/* Specific char to be escaped */
strchr("#$@[\\]^`{|}~", c) != NULL)) {
- if (len) {
- if (*len < 3)
+ if (dlen) {
+ if (*dlen < 3)
return NULL;
- *len -= 3;
+ *dlen -= 3;
}
*dst++ = '=';
*dst++ = XTOA(((unsigned int)c >> 4) & 0xf);
*dst++ = XTOA((unsigned int)c & 0xf);
} else {
- dst = do_svis(dst, len, c, flag, nextc, extra);
+ dst = do_svis(dst, dlen, c, flag, nextc, extra);
}
return dst;
}
@@ -180,18 +176,18 @@
* backslash-protected.
*/
static char *
-do_svis(char *dst, size_t *len, int c, int flag, int nextc, const char *extra)
+do_svis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
int isextra;
- size_t olen = len ? *len : 0;
+ size_t odlen = dlen ? *dlen : 0;
isextra = strchr(extra, c) != NULL;
#define HAVE(x) \
do { \
- if (len) { \
- if (*len < (x)) \
+ if (dlen) { \
+ if (*dlen < (x)) \
goto out; \
- *len -= (x); \
+ *dlen -= (x); \
} \
} while (/*CONSTCOND*/0)
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) ||
@@ -240,8 +236,8 @@
*dst++ = '\\'; *dst++ = c;
return dst;
}
- if (len)
- *len = olen;
+ if (dlen)
+ *dlen = odlen;
}
}
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
@@ -275,7 +271,7 @@
}
return dst;
out:
- *len = olen;
+ *dlen = odlen;
return NULL;
}
@@ -295,11 +291,11 @@
}
/*
- * svis - visually encode characters, also encoding the characters
+ * isnvis - visually encode characters, also encoding the characters
* pointed to by `extra'
*/
-char *
-svis(char *dst, int c, int flag, int nextc, const char *extra)
+static char *
+isnvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
{
char *nextra = NULL;
visfun_t f;
@@ -308,16 +304,36 @@
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0'; /* can't create nextra, return "" */
return dst;
}
f = getvisfun(flag);
- dst = (*f)(dst, NULL, c, flag, nextc, nextra);
+ dst = (*f)(dst, dlen, c, flag, nextc, nextra);
free(nextra);
+ if (dst == NULL || (dlen && *dlen == 0)) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0';
return dst;
}
+char *
+svis(char *dst, int c, int flag, int nextc, const char *extra)
+{
+ return isnvis(dst, NULL, c, flag, nextc, extra);
+}
+
+char *
+snvis(char *dst, size_t dlen, int c, int flag, int nextc, const char *extra)
+{
+ return isnvis(dst, &dlen, c, flag, nextc, extra);
+}
+
/*
* strsvis, strsvisx - visually encode characters from src into dst
@@ -334,8 +350,8 @@
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int
-strsvis(char *dst, const char *csrc, int flag, const char *extra)
+static int
+istrsnvis(char *dst, size_t *dlen, const char *csrc, int flag, const char *extra)
{
int c;
char *start;
@@ -352,16 +368,37 @@
return 0;
}
f = getvisfun(flag);
- for (start = dst; (c = *src++) != '\0'; /* empty */)
- dst = (*f)(dst, NULL, c, flag, *src, nextra);
+ for (start = dst; (c = *src++) != '\0'; /* empty */) {
+ dst = (*f)(dst, dlen, c, flag, *src, nextra);
+ if (dst == NULL) {
+ errno = ENOSPC;
+ return -1;
+ }
+ }
free(nextra);
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0';
return (int)(dst - start);
}
+int
+strsvis(char *dst, const char *csrc, int flag, const char *extra)
+{
+ return istrsnvis(dst, NULL, csrc, flag, extra);
+}
int
-strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+strsnvis(char *dst, size_t dlen, const char *csrc, int flag, const char *extra)
+{
+ return istrsnvis(dst, &dlen, csrc, flag, extra);
+}
+
+static int
+istrsnvisx(char *dst, size_t *dlen, const char *csrc, size_t len, int flag,
+ const char *extra)
{
unsigned char c;
char *start;
@@ -374,6 +411,10 @@
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (! nextra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create nextra, return "" */
return 0;
}
@@ -381,20 +422,41 @@
f = getvisfun(flag);
for (start = dst; len > 0; len--) {
c = *src++;
- dst = (*f)(dst, NULL, c, flag, len > 1 ? *src : '\0', nextra);
+ dst = (*f)(dst, dlen, c, flag, len > 1 ? *src : '\0', nextra);
+ if (dst == NULL) {
+ errno = ENOSPC;
+ return -1;
+ }
}
free(nextra);
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0';
return (int)(dst - start);
}
+
+int
+strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+{
+ return istrsnvisx(dst, NULL, csrc, len, flag, extra);
+}
+
+int
+strsnvisx(char *dst, size_t dlen, const char *csrc, size_t len, int flag,
+ const char *extra)
+{
+ return istrsnvisx(dst, &dlen, csrc, len, flag, extra);
+}
#endif
#if !HAVE_VIS
/*
* vis - visually encode characters
*/
-char *
-vis(char *dst, int c, int flag, int nextc)
+static char *
+invis(char *dst, size_t *dlen, int c, int flag, int nextc)
{
char *extra = NULL;
unsigned char uc = (unsigned char)c;
@@ -404,16 +466,36 @@
MAKEEXTRALIST(flag, extra, "");
if (! extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0'; /* can't create extra, return "" */
return dst;
}
f = getvisfun(flag);
- dst = (*f)(dst, NULL, uc, flag, nextc, extra);
+ dst = (*f)(dst, dlen, uc, flag, nextc, extra);
free(extra);
+ if (dst == NULL || (dlen && *dlen == 0)) {
+ errno = ENOSPC;
+ return NULL;
+ }
*dst = '\0';
return dst;
}
+char *
+vis(char *dst, int c, int flag, int nextc)
+{
+ return invis(dst, NULL, c, flag, nextc);
+}
+
+char *
+nvis(char *dst, size_t dlen, int c, int flag, int nextc)
+{
+ return invis(dst, &dlen, c, flag, nextc);
+}
+
/*
* strvis, strvisx - visually encode characters from src into dst
@@ -425,36 +507,68 @@
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
-int
-strvis(char *dst, const char *src, int flag)
+static int
+istrnvis(char *dst, size_t *dlen, const char *src, int flag)
{
char *extra = NULL;
int rv;
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
- rv = strsvis(dst, src, flag, extra);
+ rv = istrsnvis(dst, dlen, src, flag, extra);
free(extra);
return rv;
}
+int
+strvis(char *dst, const char *src, int flag)
+{
+ return istrnvis(dst, NULL, src, flag);
+}
int
-strvisx(char *dst, const char *src, size_t len, int flag)
+strnvis(char *dst, size_t dlen, const char *src, int flag)
+{
+ return istrnvis(dst, &dlen, src, flag);
+}
+
+static int
+istrnvisx(char *dst, size_t *dlen, const char *src, size_t len, int flag)
{
char *extra = NULL;
int rv;
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ return -1;
+ }
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
- rv = strsvisx(dst, src, len, flag, extra);
+ rv = istrsnvisx(dst, dlen, src, len, flag, extra);
free(extra);
return rv;
}
+
+int
+strvisx(char *dst, const char *src, size_t len, int flag)
+{
+ return istrnvisx(dst, NULL, src, len, flag);
+}
+
+int
+strnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag)
+{
+ return istrnvisx(dst, &dlen, src, len, flag);
+}
+
#endif
Index: src/lib/libc/include/namespace.h
diff -u src/lib/libc/include/namespace.h:1.146 src/lib/libc/include/namespace.h:1.147
--- src/lib/libc/include/namespace.h:1.146 Thu Dec 16 13:38:06 2010
+++ src/lib/libc/include/namespace.h Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.146 2010/12/16 18:38:06 christos Exp $ */
+/* $NetBSD: namespace.h,v 1.147 2011/03/12 19:52:48 christos Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -591,11 +591,8 @@
#define strsignal _strsignal
#define strsuftoll _strsuftoll
#define strsuftollx _strsuftollx
-#define strsvis _strsvis
-#define strsvisx _strsvisx
#define strtok_r _strtok_r
-#define strunvis _strunvis
-#define strvis _strvis
+#define strnunvisx _strnunvisx
#define strvisx _strvisx
#define svc_auth_reg _svc_auth_reg
#define svc_create _svc_create
@@ -628,7 +625,6 @@
#define svcudp_bufcreate _svcudp_bufcreate
#define svcudp_create _svcudp_create
#define svcudp_enablecache _svcudp_enablecache
-#define svis _svis
#define sysarch _sys_sysarch
#define sysctl _sysctl
#define sysctlbyname _sysctlbyname
@@ -667,7 +663,6 @@
#define ualarm _ualarm
#define uname _uname
#define unsetenv _unsetenv
-#define unvis _unvis
#define user_from_uid _user_from_uid
#define usleep _usleep
#define utime _utime
@@ -675,7 +670,6 @@
#define uuid_is_nil _uuid_is_nil
#define valloc _valloc
#define vdprintf _vdprintf
-#define vis _vis
#define vdprintf _vdprintf
#ifndef vsnprintf
#define vsnprintf _vsnprintf
Index: src/tests/lib/libc/gen/t_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.1 src/tests/lib/libc/gen/t_vis.c:1.2
--- src/tests/lib/libc/gen/t_vis.c:1.1 Tue Dec 28 07:46:15 2010
+++ src/tests/lib/libc/gen/t_vis.c Sat Mar 12 14:52:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vis.c,v 1.1 2010/12/28 12:46:15 pgoyette Exp $ */
+/* $NetBSD: t_vis.c,v 1.2 2011/03/12 19:52:48 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -46,9 +46,9 @@
#if 0 /* Not reversible */
VIS_NOSLASH,
#endif
-#ifdef VIS_HTTPSTYLE
- VIS_HTTPSTYLE
-#endif
+ VIS_HTTP1808,
+ VIS_MIMESTYLE,
+ VIS_HTTP1866,
};
#define SIZE 256
@@ -75,13 +75,7 @@
for (i = 0; i < __arraycount(styles); i++) {
strsvisx(visbuf, srcbuf, SIZE, styles[i], "");
- /*
- * XXX: The strunvisx api is busted; flags should be
- * UNVIS_ flags, buf we follow FreeBSD's lead. This
- * needs to be redone, by moving UNVIS_END into the
- * VIS_ space, and bump the library/symbol.
- */
- strunvisx(dstbuf, visbuf, styles[i] & VIS_HTTPSTYLE);
+ strunvisx(dstbuf, visbuf, styles[i]);
for (j = 0; j < SIZE; j++)
if (dstbuf[j] != (char)j)
atf_tc_fail_nonfatal("Failed for style %x, "
Added files:
Index: src/lib/libc/compat/gen/compat___unvis13.c
diff -u /dev/null src/lib/libc/compat/gen/compat___unvis13.c:1.1
--- /dev/null Sat Mar 12 14:52:49 2011
+++ src/lib/libc/compat/gen/compat___unvis13.c Sat Mar 12 14:52:47 2011
@@ -0,0 +1,57 @@
+/* $NetBSD: compat___unvis13.c,v 1.1 2011/03/12 19:52:47 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: compat___unvis13.c,v 1.1 2011/03/12 19:52:47 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#define __LIBC12_SOURCE__
+
+#include "namespace.h"
+#include <sys/types.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <vis.h>
+#include <compat/include/vis.h>
+
+#ifdef __warn_references
+__warn_references(__unvis13,
+ "warning: reference to compatibility __unvis13(); include <vis.h> for correct reference")
+#endif
+
+int
+__unvis13(char *cp, int c, int *astate, int flag)
+{
+ flag = (flag & ~1) | ((flag & 1) ? UNVIS_END : 0);
+ return __unvis50(cp, c, astate, flag);
+}