summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/Makefile.inc7
-rw-r--r--lib/libc/gen/Symbol.map17
-rw-r--r--lib/libc/gen/check_utility_compat.c12
-rw-r--r--lib/libc/gen/fmtmsg.c2
-rw-r--r--lib/libc/gen/fstab.c12
-rw-r--r--lib/libc/gen/getcap.c4
-rw-r--r--lib/libc/gen/getgrent.c8
-rw-r--r--lib/libc/gen/getnetgrent.c4
-rw-r--r--lib/libc/gen/getttyent.c2
-rw-r--r--lib/libc/gen/getusershell.c2
-rw-r--r--lib/libc/gen/getutxent.c2
-rw-r--r--lib/libc/gen/sysctlbyname.c9
-rw-r--r--lib/libc/gen/unvis-compat.c46
-rw-r--r--lib/libc/gen/unvis.3200
-rw-r--r--lib/libc/gen/unvis.c293
-rw-r--r--lib/libc/gen/vis.3308
-rw-r--r--lib/libc/gen/vis.c201
-rw-r--r--lib/libc/iconv/citrus_mmap.c6
-rw-r--r--lib/libc/locale/collate.c2
-rw-r--r--lib/libc/locale/setrunelocale.c18
-rw-r--r--lib/libc/nls/Makefile.inc3
-rw-r--r--lib/libc/nls/msgcat.c1
-rw-r--r--lib/libc/nls/zh_CN.GB18030.msg297
-rw-r--r--lib/libc/nls/zh_CN.GB2312.msg297
-rw-r--r--lib/libc/nls/zh_CN.UTF-8.msg295
-rw-r--r--lib/libc/sys/bind.22
-rw-r--r--lib/libc/sys/mlock.217
-rw-r--r--lib/libc/sys/mlockall.217
-rw-r--r--lib/libc/sys/socket.219
29 files changed, 1032 insertions, 1071 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 906f4ce..abface8 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -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
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index f5d4f71..0c6f48e 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -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;
};
diff --git a/lib/libc/gen/check_utility_compat.c b/lib/libc/gen/check_utility_compat.c
index 0ccdec1..04c594b 100644
--- a/lib/libc/gen/check_utility_compat.c
+++ b/lib/libc/gen/check_utility_compat.c
@@ -35,32 +35,28 @@ __FBSDID("$FreeBSD$");
* are threaded, so I'm not concerned about cancellation points or other
* niceties.
*/
+#include <sys/limits.h>
+
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifndef LINE_MAX
-#define LINE_MAX _POSIX2_LINE_MAX
-#endif
-
#define _PATH_UTIL_COMPAT "/etc/compat-FreeBSD-4-util"
#define _ENV_UTIL_COMPAT "_COMPAT_FreeBSD_4"
int
check_utility_compat(const char *utility)
{
- char buf[LINE_MAX];
+ char buf[PATH_MAX];
char *p, *bp;
int len;
if ((p = getenv(_ENV_UTIL_COMPAT)) != NULL) {
strlcpy(buf, p, sizeof buf);
} else {
- if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof buf)) < 0)
+ if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof(buf) - 1)) < 0)
return 0;
- if (len > sizeof buf)
- len = sizeof buf;
buf[len] = '\0';
}
if (buf[0] == '\0')
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c
index c6ecbd5..d2c67a6 100644
--- a/lib/libc/gen/fmtmsg.c
+++ b/lib/libc/gen/fmtmsg.c
@@ -83,7 +83,7 @@ def:
if (output == NULL)
return (MM_NOCON);
if (*output != '\0') {
- if ((fp = fopen("/dev/console", "a")) == NULL) {
+ if ((fp = fopen("/dev/console", "ae")) == NULL) {
free(output);
return (MM_NOCON);
}
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index b68db2e..6a77abd 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
#include <fstab.h>
#include <paths.h>
#include <stdio.h>
@@ -255,8 +254,6 @@ getfsfile(const char *name)
int
setfsent(void)
{
- int fd;
-
if (_fs_fp) {
rewind(_fs_fp);
LineNo = 0;
@@ -268,18 +265,11 @@ setfsent(void)
else
setfstab(getenv("PATH_FSTAB"));
}
- fd = _open(path_fstab, O_RDONLY | O_CLOEXEC);
- if (fd == -1) {
- error(errno);
- return (0);
- }
- _fs_fp = fdopen(fd, "r");
- if (_fs_fp != NULL) {
+ if ((_fs_fp = fopen(path_fstab, "re")) != NULL) {
LineNo = 0;
return (1);
}
error(errno);
- _close(fd);
return (0);
}
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index c321d12..f2f3777 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -654,7 +654,7 @@ cgetnext(char **bp, char **db_array)
if (dbp == NULL)
dbp = db_array;
- if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) {
+ if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
}
@@ -679,7 +679,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (0);
} else if ((pfp =
- fopen(*dbp, "r")) == NULL) {
+ fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
} else
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 18f64a8..f9480c3 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -810,7 +810,7 @@ files_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
break;
case ENDGRENT:
if (st->fp != NULL) {
@@ -861,7 +861,7 @@ files_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -1251,7 +1251,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
set_setent(dtab, mdata);
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
compatsrc, 0);
@@ -1335,7 +1335,7 @@ compat_group(void *retval, void *mdata, va_list ap)
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
rv = NS_UNAVAIL;
goto fin;
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 51b3e37..4c56461 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -173,7 +173,7 @@ setnetgrent(const char *group)
if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
errno == ENOENT) || _yp_statp.st_size == 0)
_use_only_yp = _netgr_yp_enabled = 1;
- if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){
+ if ((netf = fopen(_PATH_NETGROUP,"re")) != NULL ||_use_only_yp){
/*
* Icky: grab the first character of the netgroup file
* and turn on NIS if it's a '+'. rewind the stream
@@ -197,7 +197,7 @@ setnetgrent(const char *group)
return;
}
#else
- if ((netf = fopen(_PATH_NETGROUP, "r"))) {
+ if ((netf = fopen(_PATH_NETGROUP, "re"))) {
#endif
if (parse_netgrp(group))
endnetgrent();
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index f2fc298..b82c30a 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -211,7 +211,7 @@ setttyent(void)
if (tf) {
rewind(tf);
return (1);
- } else if ( (tf = fopen(_PATH_TTYS, "r")) )
+ } else if ( (tf = fopen(_PATH_TTYS, "re")) )
return (1);
return (0);
}
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index ce50069..53536e1 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -115,7 +115,7 @@ _local_initshells(rv, cb_data, ap)
sl_free(sl, 1);
sl = sl_init();
- if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+ if ((fp = fopen(_PATH_SHELLS, "re")) == NULL)
return NS_UNAVAIL;
cp = line;
diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c
index a2e938a..20e8859 100644
--- a/lib/libc/gen/getutxent.c
+++ b/lib/libc/gen/getutxent.c
@@ -71,7 +71,7 @@ setutxdb(int db, const char *file)
if (uf != NULL)
fclose(uf);
- uf = fopen(file, "r");
+ uf = fopen(file, "re");
if (uf == NULL)
return (-1);
diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c
index a2e0d5f..88b860d 100644
--- a/lib/libc/gen/sysctlbyname.c
+++ b/lib/libc/gen/sysctlbyname.c
@@ -19,13 +19,10 @@ sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
const void *newp, size_t newlen)
{
int real_oid[CTL_MAXNAME+2];
- int error;
size_t oidlen;
oidlen = sizeof(real_oid) / sizeof(int);
- error = sysctlnametomib(name, real_oid, &oidlen);
- if (error < 0)
- return (error);
- error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
- return (error);
+ if (sysctlnametomib(name, real_oid, &oidlen) < 0)
+ return (-1);
+ return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen));
}
diff --git a/lib/libc/gen/unvis-compat.c b/lib/libc/gen/unvis-compat.c
new file mode 100644
index 0000000..080143e
--- /dev/null
+++ b/lib/libc/gen/unvis-compat.c
@@ -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);
diff --git a/lib/libc/gen/unvis.3 b/lib/libc/gen/unvis.3
deleted file mode 100644
index 9164f79..0000000
--- a/lib/libc/gen/unvis.3
+++ /dev/null
@@ -1,200 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" 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.
-.\" 4. 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.
-.\"
-.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
-.Dd December 11, 1993
-.Dt UNVIS 3
-.Os
-.Sh NAME
-.Nm unvis ,
-.Nm strunvis
-.Nd decode a visual representation of characters
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In vis.h
-.Ft int
-.Fn unvis "char *cp" "int c" "int *astate" "int flag"
-.Ft int
-.Fn strunvis "char *dst" "const char *src"
-.Ft int
-.Fn strunvisx "char *dst" "const char *src" "int flag"
-.Sh DESCRIPTION
-The
-.Fn unvis ,
-.Fn strunvis
-and
-.Fn strunvisx
-functions
-are used to decode a visual representation of characters, as produced
-by the
-.Xr vis 3
-function, back into
-the original form.
-Unvis is called with successive characters in
-.Fa c
-until a valid
-sequence is recognized, at which time the decoded character is
-available at the character pointed to by
-.Fa cp .
-Strunvis decodes the
-characters pointed to by
-.Fa src
-into the buffer pointed to by
-.Fa dst .
-.Pp
-The
-.Fn strunvis
-function
-simply copies
-.Fa src
-to
-.Fa dst ,
-decoding any escape sequences along the way,
-and returns the number of characters placed into
-.Fa dst ,
-or \-1 if an
-invalid escape sequence was detected.
-The size of
-.Fa dst
-should be
-equal to the size of
-.Fa src
-(that is, no expansion takes place during
-decoding).
-.Pp
-The
-.Fn strunvisx
-function does the same as the
-.Fn strunvis
-function,
-but it allows you to add a flag that specifies the style the string
-.Fa src
-is encoded with.
-Currently, the only supported flag is
-.Dv VIS_HTTPSTYLE .
-.Pp
-The
-.Fn unvis
-function
-implements a state machine that can be used to decode an arbitrary
-stream of bytes.
-All state associated with the bytes being decoded
-is stored outside the
-.Fn unvis
-function (that is, a pointer to the state is passed in), so
-calls decoding different streams can be freely intermixed.
-To
-start decoding a stream of bytes, first initialize an integer
-to zero.
-Call
-.Fn unvis
-with each successive byte, along with a pointer
-to this integer, and a pointer to a destination character.
-The
-.Fn unvis
-function
-has several return codes that must be handled properly.
-They are:
-.Bl -tag -width UNVIS_VALIDPUSH
-.It Li \&0 (zero)
-Another character is necessary; nothing has been recognized yet.
-.It Dv UNVIS_VALID
-A valid character has been recognized and is available at the location
-pointed to by cp.
-.It Dv UNVIS_VALIDPUSH
-A valid character has been recognized and is available at the location
-pointed to by cp; however, the character currently passed in should
-be passed in again.
-.It Dv UNVIS_NOCHAR
-A valid sequence was detected, but no character was produced.
-This
-return code is necessary to indicate a logical break between characters.
-.It Dv UNVIS_SYNBAD
-An invalid escape sequence was detected, or the decoder is in an
-unknown state.
-The decoder is placed into the starting state.
-.El
-.Pp
-When all bytes in the stream have been processed, call
-.Fn unvis
-one more time with
-.Fa flag
-set to
-.Dv UNVIS_END
-to extract any remaining character (the character passed in is ignored).
-.Pp
-The
-.Fa flag
-argument is also used to specify the encoding style of the source.
-If set to
-.Dv VIS_HTTPSTYLE ,
-.Fn unvis
-will decode URI strings as specified in RFC 1808.
-.Pp
-The following code fragment illustrates a proper use of
-.Fn unvis .
-.Bd -literal -offset indent
-int state = 0;
-char out;
-
-while ((ch = getchar()) != EOF) {
-again:
- switch(unvis(&out, ch, &state, 0)) {
- case 0:
- case UNVIS_NOCHAR:
- break;
- case UNVIS_VALID:
- (void) putchar(out);
- break;
- case UNVIS_VALIDPUSH:
- (void) putchar(out);
- goto again;
- case UNVIS_SYNBAD:
- (void)fprintf(stderr, "bad sequence!\en");
- exit(1);
- }
-}
-if (unvis(&out, (char)0, &state, UNVIS_END) == UNVIS_VALID)
- (void) putchar(out);
-.Ed
-.Sh SEE ALSO
-.Xr vis 1 ,
-.Xr vis 3
-.Rs
-.%A R. Fielding
-.%T Relative Uniform Resource Locators
-.%O RFC1808
-.Re
-.Sh HISTORY
-The
-.Fn unvis
-function
-first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c
deleted file mode 100644
index 9069e55..0000000
--- a/lib/libc/gen/unvis.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * 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.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <vis.h>
-
-/*
- * decode driven by state machine
- */
-#define S_GROUND 0 /* haven't seen escape char */
-#define S_START 1 /* start decoding special sequence */
-#define S_META 2 /* metachar started (M) */
-#define S_META1 3 /* metachar more, regular char (-) */
-#define S_CTRL 4 /* control char started (^) */
-#define S_OCTAL2 5 /* octal digit 2 */
-#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX2 7 /* hex digit 2 */
-
-#define S_HTTP 0x080 /* %HEXHEX escape */
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define ishex(c) ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f'))
-
-/*
- * unvis - decode characters previously encoded by vis
- */
-int
-unvis(char *cp, int c, int *astate, int flag)
-{
-
- if (flag & UNVIS_END) {
- if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
- *astate = S_GROUND;
- return (UNVIS_VALID);
- }
- return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
- }
-
- switch (*astate & ~S_HTTP) {
-
- case S_GROUND:
- *cp = 0;
- if (c == '\\') {
- *astate = S_START;
- return (0);
- }
- if (flag & VIS_HTTPSTYLE && c == '%') {
- *astate = S_START | S_HTTP;
- return (0);
- }
- *cp = c;
- return (UNVIS_VALID);
-
- case S_START:
- if (*astate & S_HTTP) {
- if (ishex(tolower(c))) {
- *cp = isdigit(c) ? (c - '0') : (tolower(c) - 'a');
- *astate = S_HEX2;
- return (0);
- }
- }
- switch(c) {
- case '\\':
- *cp = c;
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- *cp = (c - '0');
- *astate = S_OCTAL2;
- return (0);
- case 'M':
- *cp = 0200;
- *astate = S_META;
- return (0);
- case '^':
- *astate = S_CTRL;
- return (0);
- case 'n':
- *cp = '\n';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'r':
- *cp = '\r';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'b':
- *cp = '\b';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'a':
- *cp = '\007';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'v':
- *cp = '\v';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 't':
- *cp = '\t';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'f':
- *cp = '\f';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 's':
- *cp = ' ';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'E':
- *cp = '\033';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '\n':
- /*
- * hidden newline
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- case '$':
- /*
- * hidden marker
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- }
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
-
- case S_META:
- if (c == '-')
- *astate = S_META1;
- else if (c == '^')
- *astate = S_CTRL;
- else {
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
- return (0);
-
- case S_META1:
- *astate = S_GROUND;
- *cp |= c;
- return (UNVIS_VALID);
-
- case S_CTRL:
- if (c == '?')
- *cp |= 0177;
- else
- *cp |= c & 037;
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
- */
- *cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
- return (0);
- }
- /*
- * no - done with current sequence, push back passed char
- */
- *astate = S_GROUND;
- return (UNVIS_VALIDPUSH);
-
- case S_OCTAL3: /* third possible octal digit */
- *astate = S_GROUND;
- if (isoctal(c)) {
- *cp = (*cp << 3) + (c - '0');
- return (UNVIS_VALID);
- }
- /*
- * we were done, push back passed char
- */
- return (UNVIS_VALIDPUSH);
-
- case S_HEX2: /* second mandatory hex digit */
- if (ishex(tolower(c))) {
- *cp = (isdigit(c) ? (*cp << 4) + (c - '0') : (*cp << 4) + (tolower(c) - 'a' + 10));
- }
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
- */
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
-}
-
-/*
- * strunvis - decode src into dst
- *
- * Number of chars decoded into dst is returned, -1 on error.
- * Dst is null terminated.
- */
-
-int
-strunvis(char *dst, const char *src)
-{
- char c;
- char *start = dst;
- int state = 0;
-
- while ( (c = *src++) ) {
- again:
- switch (unvis(dst, c, &state, 0)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strunvisx(char *dst, const char *src, int flag)
-{
- char c;
- char *start = dst;
- int state = 0;
-
- while ( (c = *src++) ) {
- again:
- switch (unvis(dst, c, &state, flag)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3
deleted file mode 100644
index 8ec16eb..0000000
--- a/lib/libc/gen/vis.3
+++ /dev/null
@@ -1,308 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" 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.
-.\" 4. 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.
-.\"
-.\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93
-.\" $FreeBSD$
-.\"
-.Dd April 9, 2006
-.Dt VIS 3
-.Os
-.Sh NAME
-.Nm vis
-.Nd visually encode characters
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In vis.h
-.Ft char *
-.Fn vis "char *dst" "int c" "int flag" "int nextc"
-.Ft int
-.Fn strvis "char *dst" "const char *src" "int flag"
-.Ft int
-.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
-.Sh DESCRIPTION
-The
-.Fn vis
-function
-copies into
-.Fa dst
-a string which represents the character
-.Fa c .
-If
-.Fa c
-needs no encoding, it is copied in unaltered.
-The string is
-null terminated, and a pointer to the end of the string is
-returned.
-The maximum length of any encoding is four
-characters (not including the trailing
-.Dv NUL ) ;
-thus, when
-encoding a set of characters into a buffer, the size of the buffer should
-be four times the number of characters encoded, plus one for the trailing
-.Dv NUL .
-The
-.Fa flag
-argument is used for altering the default range of
-characters considered for encoding and for altering the visual
-representation.
-The additional character,
-.Fa nextc ,
-is only used when selecting the
-.Dv VIS_CSTYLE
-encoding format (explained below).
-.Pp
-The
-.Fn strvis
-and
-.Fn strvisx
-functions copy into
-.Fa dst
-a visual representation of
-the string
-.Fa src .
-The
-.Fn strvis
-function encodes characters from
-.Fa src
-up to the
-first
-.Dv NUL .
-The
-.Fn strvisx
-function encodes exactly
-.Fa len
-characters from
-.Fa src
-(this
-is useful for encoding a block of data that may contain
-.Dv NUL Ns 's ) .
-Both forms
-.Dv NUL
-terminate
-.Fa dst .
-The size of
-.Fa dst
-must be four times the number
-of characters encoded from
-.Fa src
-(plus one for the
-.Dv NUL ) .
-Both
-forms return the number of characters in dst (not including
-the trailing
-.Dv NUL ) .
-.Pp
-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 strunvis 3
-functions.
-.Pp
-There are two parameters that can be controlled: the range of
-characters that are encoded, and the type
-of representation used.
-By default, all non-graphic characters
-except space, tab, and newline are encoded.
-(See
-.Xr isgraph 3 . )
-The following flags
-alter this:
-.Bl -tag -width VIS_WHITEX
-.It Dv VIS_GLOB
-Also encode magic characters
-.Ql ( * ,
-.Ql \&? ,
-.Ql \&[
-and
-.Ql # )
-recognized by
-.Xr glob 3 .
-.It Dv VIS_SP
-Also encode space.
-.It Dv VIS_TAB
-Also encode tab.
-.It Dv VIS_NL
-Also encode newline.
-.It Dv VIS_WHITE
-Synonym for
-.Dv VIS_SP
-\&|
-.Dv VIS_TAB
-\&|
-.Dv VIS_NL .
-.It Dv VIS_SAFE
-Only encode "unsafe" characters.
-Unsafe means control
-characters which may cause common terminals to perform
-unexpected functions.
-Currently this form allows space,
-tab, newline, backspace, bell, and return - in addition
-to all graphic characters - unencoded.
-.El
-.Pp
-There are four forms of encoding.
-Most forms use the backslash character
-.Ql \e
-to introduce a special
-sequence; two backslashes are used to represent a real backslash.
-These are the visual formats:
-.Bl -tag -width VIS_HTTPSTYLE
-.It (default)
-Use an
-.Ql M
-to represent meta characters (characters with the 8th
-bit set), and use caret
-.Ql ^
-to represent control characters see
-.Pf ( Xr iscntrl 3 ) .
-The following formats are used:
-.Bl -tag -width xxxxx
-.It Dv \e^C
-Represents the control character
-.Ql C .
-Spans characters
-.Ql \e000
-through
-.Ql \e037 ,
-and
-.Ql \e177
-(as
-.Ql \e^? ) .
-.It Dv \eM-C
-Represents character
-.Ql C
-with the 8th bit set.
-Spans characters
-.Ql \e241
-through
-.Ql \e376 .
-.It Dv \eM^C
-Represents control character
-.Ql C
-with the 8th bit set.
-Spans characters
-.Ql \e200
-through
-.Ql \e237 ,
-and
-.Ql \e377
-(as
-.Ql \eM^? ) .
-.It Dv \e040
-Represents
-.Tn ASCII
-space.
-.It Dv \e240
-Represents Meta-space.
-.El
-.Pp
-.It Dv VIS_CSTYLE
-Use C-style backslash sequences to represent standard non-printable
-characters.
-The following sequences are used to represent the indicated characters:
-.Pp
-.Bl -tag -width ".Li \e0" -offset indent -compact
-.It Li \ea
-.Dv BEL No (007)
-.It Li \eb
-.Dv BS No (010)
-.It Li \ef
-.Dv NP No (014)
-.It Li \en
-.Dv NL No (012)
-.It Li \er
-.Dv CR No (015)
-.It Li \es
-.Dv SP No (040)
-.It Li \et
-.Dv HT No (011)
-.It Li \ev
-.Dv VT No (013)
-.It Li \e0
-.Dv NUL No (000)
-.El
-.Pp
-When using this format, the
-.Fa nextc
-argument is looked at to determine
-if a
-.Dv NUL
-character can be encoded as
-.Ql \e0
-instead of
-.Ql \e000 .
-If
-.Fa nextc
-is an octal digit, the latter representation is used to
-avoid ambiguity.
-.It Dv VIS_HTTPSTYLE
-Use URI encoding as described in RFC 1808.
-The form is
-.Ql %dd
-where
-.Ar d
-represents a hexadecimal digit.
-.It Dv VIS_OCTAL
-Use a three digit octal sequence.
-The form is
-.Ql \eddd
-where
-.Ar d
-represents an octal digit.
-.El
-.Pp
-There is one additional flag,
-.Dv VIS_NOSLASH ,
-which inhibits the
-doubling of backslashes and the backslash before the default
-format (that is, control characters are represented by
-.Ql ^C
-and
-meta characters as
-.Ql M-C ) .
-With this flag set, the encoding is
-ambiguous and non-invertible.
-.Sh SEE ALSO
-.Xr unvis 1 ,
-.Xr unvis 3
-.Rs
-.%A R. Fielding
-.%T Relative Uniform Resource Locators
-.%O RFC1808
-.Re
-.Sh HISTORY
-These functions first appeared in
-.Bx 4.4 .
-.Sh BUGS
-The
-.Nm
-family of functions do not recognize multibyte characters, and thus
-may consider them to be non-printable when they are in fact printable
-(and vice versa.)
diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c
deleted file mode 100644
index 362f4dc..0000000
--- a/lib/libc/gen/vis.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * 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.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <limits.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <vis.h>
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-
-/*
- * vis - visually encode characters
- */
-char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, nextc;
- int flag;
-{
- c = (unsigned char)c;
-
- if (flag & VIS_HTTPSTYLE) {
- /* Described in RFC 1808 */
- if (!(isalnum(c) /* alpha-numeric */
- /* safe */
- || c == '$' || c == '-' || c == '_' || c == '.' || c == '+'
- /* extra */
- || c == '!' || c == '*' || c == '\'' || c == '('
- || c == ')' || c == ',')) {
- *dst++ = '%';
- snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c);
- dst += 2;
- goto done;
- }
- }
-
- if ((flag & VIS_GLOB) &&
- (c == '*' || c == '?' || c == '[' || c == '#'))
- ;
- else if (isgraph(c) ||
- ((flag & VIS_SP) == 0 && c == ' ') ||
- ((flag & VIS_TAB) == 0 && c == '\t') ||
- ((flag & VIS_NL) == 0 && c == '\n') ||
- ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
- *dst++ = c;
- if (c == '\\' && (flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- *dst = '\0';
- return (dst);
- }
-
- if (flag & VIS_CSTYLE) {
- switch(c) {
- case '\n':
- *dst++ = '\\';
- *dst++ = 'n';
- goto done;
- case '\r':
- *dst++ = '\\';
- *dst++ = 'r';
- goto done;
- case '\b':
- *dst++ = '\\';
- *dst++ = 'b';
- goto done;
- case '\a':
- *dst++ = '\\';
- *dst++ = 'a';
- goto done;
- case '\v':
- *dst++ = '\\';
- *dst++ = 'v';
- goto done;
- case '\t':
- *dst++ = '\\';
- *dst++ = 't';
- goto done;
- case '\f':
- *dst++ = '\\';
- *dst++ = 'f';
- goto done;
- case ' ':
- *dst++ = '\\';
- *dst++ = 's';
- goto done;
- case '\0':
- *dst++ = '\\';
- *dst++ = '0';
- if (isoctal(nextc)) {
- *dst++ = '0';
- *dst++ = '0';
- }
- goto done;
- }
- }
- if (((c & 0177) == ' ') || isgraph(c) || (flag & VIS_OCTAL)) {
- *dst++ = '\\';
- *dst++ = ((u_char)c >> 6 & 07) + '0';
- *dst++ = ((u_char)c >> 3 & 07) + '0';
- *dst++ = ((u_char)c & 07) + '0';
- goto done;
- }
- if ((flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- if (c & 0200) {
- c &= 0177;
- *dst++ = 'M';
- }
- if (iscntrl(c)) {
- *dst++ = '^';
- if (c == 0177)
- *dst++ = '?';
- else
- *dst++ = c + '@';
- } else {
- *dst++ = '-';
- *dst++ = c;
- }
-done:
- *dst = '\0';
- return (dst);
-}
-
-/*
- * strvis, strvisx - visually encode characters from src into dst
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NUL,
- * is returned.
- *
- * Strvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
- */
-int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
-{
- char c;
- char *start;
-
- for (start = dst; (c = *src); )
- dst = vis(dst, c, flag, *++src);
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
-{
- int c;
- char *start;
-
- for (start = dst; len > 1; len--) {
- c = *src;
- dst = vis(dst, c, flag, *++src);
- }
- if (len)
- dst = vis(dst, *src, flag, '\0');
- *dst = '\0';
-
- return (dst - start);
-}
diff --git a/lib/libc/iconv/citrus_mmap.c b/lib/libc/iconv/citrus_mmap.c
index dd5d059..2aaf73c 100644
--- a/lib/libc/iconv/citrus_mmap.c
+++ b/lib/libc/iconv/citrus_mmap.c
@@ -57,12 +57,8 @@ _citrus_map_file(struct _citrus_region * __restrict r,
_region_init(r, NULL, 0);
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
return (errno);
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- ret = errno;
- goto error;
- }
if (fstat(fd, &st) == -1) {
ret = errno;
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 676d41c..56513f4 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -135,7 +135,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
(void)strcat(buf, "/");
(void)strcat(buf, encoding);
(void)strcat(buf, "/LC_COLLATE");
- if ((fp = fopen(buf, "r")) == NULL)
+ if ((fp = fopen(buf, "re")) == NULL)
return (_LDP_ERROR);
if (fread(strbuf, sizeof(strbuf), 1, fp) != 1) {
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 3ffb649..49e6f6e 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -73,9 +73,11 @@ static int __setrunelocale(struct xlocale_ctype *l, const char *);
#define __collate_chain_pri_table (table->__collate_chain_pri_table)
-static void destruct_ctype(void *v)
+static void
+destruct_ctype(void *v)
{
struct xlocale_ctype *l = v;
+
if (strcmp(l->runes->__encoding, "EUC") == 0)
free(l->runes->__variable);
if (&_DefaultRuneLocale != l->runes)
@@ -83,13 +85,17 @@ static void destruct_ctype(void *v)
free(l);
}
-const _RuneLocale *__getCurrentRuneLocale(void)
+const _RuneLocale *
+__getCurrentRuneLocale(void)
{
+
return XLOCALE_CTYPE(__get_locale())->runes;
}
-static void free_runes(_RuneLocale *rl)
+static void
+free_runes(_RuneLocale *rl)
{
+
/* FIXME: The "EUC" check here is a hideous abstraction violation. */
if ((rl != &_DefaultRuneLocale) && (rl)) {
if (strcmp(rl->__encoding, "EUC") == 0) {
@@ -123,7 +129,7 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding)
(void) strcat(name, encoding);
(void) strcat(name, "/LC_CTYPE");
- if ((fp = fopen(name, "r")) == NULL)
+ if ((fp = fopen(name, "re")) == NULL)
return (errno == 0 ? ENOENT : errno);
if ((rl = _Read_RuneMagi(fp)) == NULL) {
@@ -191,7 +197,8 @@ __wrap_setrunelocale(const char *locale)
#ifndef __NO_TLS
void
-__set_thread_rune_locale(locale_t loc) {
+__set_thread_rune_locale(locale_t loc)
+{
if (loc == NULL) {
_ThreadRuneLocale = &_DefaultRuneLocale;
@@ -205,6 +212,7 @@ void *
__ctype_load(const char *locale, locale_t unused)
{
struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1);
+
l->header.header.destructor = destruct_ctype;
if (__setrunelocale(l, locale))
{
diff --git a/lib/libc/nls/Makefile.inc b/lib/libc/nls/Makefile.inc
index f5c6885..962d16b 100644
--- a/lib/libc/nls/Makefile.inc
+++ b/lib/libc/nls/Makefile.inc
@@ -36,3 +36,6 @@ NLS+= ru_RU.KOI8-R
NLS+= sk_SK.ISO8859-2
NLS+= sv_SE.ISO8859-1
NLS+= uk_UA.UTF-8
+NLS+= zh_CN.GB18030
+NLS+= zh_CN.GB2312
+NLS+= zh_CN.UTF-8
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index 44b1440..2859916 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
if (np != NULL) { \
np->name = strdup(n); \
np->path = NULL; \
+ np->catd = NLERR; \
np->lang = (l == NULL) ? NULL : \
strdup(l); \
np->caterrno = e; \
diff --git a/lib/libc/nls/zh_CN.GB18030.msg b/lib/libc/nls/zh_CN.GB18030.msg
new file mode 100644
index 0000000..0e35d7e
--- /dev/null
+++ b/lib/libc/nls/zh_CN.GB18030.msg
@@ -0,0 +1,297 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.GB18030 locale
+$
+$ Derived from FreeBSD: head/lib/libc/nls/zh_CN.UTF-8.msg 244756 2012-12-28 01:09:30Z delphij
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 不允许的操作
+$ ENOENT
+2 文件或目录不存在
+$ ESRCH
+3 进程不存在
+$ EINTR
+4 系统调用中止
+$ EIO
+5 输入/输出错误
+$ ENXIO
+6 未配置的设备
+$ E2BIG
+7 参数表过长
+$ ENOEXEC
+8 可执行文件格式错误
+$ EBADF
+9 文件描述符无效
+$ ECHILD
+10 指定子进程不存在
+$ EDEADLK
+11 此操作会导致死锁
+$ ENOMEM
+12 无法分配内存
+$ EACCES
+13 拒绝访问
+$ EFAULT
+14 无效地址
+$ ENOTBLK
+15 该操作需要块设备
+$ EBUSY
+16 设备使用中
+$ EEXIST
+17 文件已存在
+$ EXDEV
+18 链接跨设备
+$ ENODEV
+19 设备不支持此操作
+$ ENOTDIR
+20 对象非目录
+$ EISDIR
+21 对象为目录
+$ EINVAL
+22 参数无效
+$ ENFILE
+23 系统打开文件过多
+$ EMFILE
+24 进程打开文件过多
+$ ENOTTY
+25 无效设备 ioctl
+$ ETXTBSY
+26 可执行文件忙
+$ EFBIG
+27 文件过大
+$ ENOSPC
+28 设备无可用空间
+$ ESPIPE
+29 不允许执行 seek 操作
+$ EROFS
+30 文件系统只读
+$ EMLINK
+31 文件链接过多
+$ EPIPE
+32 管道已中止
+$ EDOM
+33 数值参数越界
+$ ERANGE
+34 结果过大
+$ EAGAIN, EWOULDBLOCK
+35 资源暂时不可用
+$ EINPROGRESS
+36 操作进行中
+$ EALREADY
+37 操作已开始
+$ ENOTSOCK
+38 尝试在非 socket 上执行 socket 操作
+$ EDESTADDRREQ
+39 需要目的地址
+$ EMSGSIZE
+40 消息过长
+$ EPROTOTYPE
+41 socket协议类型错误
+$ ENOPROTOOPT
+42 协议不可用
+$ EPROTONOSUPPORT
+43 不支持的协议
+$ ESOCKTNOSUPPORT
+44 不支持的 socket 类型
+$ EOPNOTSUPP
+45 不支持的操作
+$ EPFNOSUPPORT
+46 不支持的协议族
+$ EAFNOSUPPORT
+47 协议族不支持的地址族
+$ EADDRINUSE
+48 地址已被占用
+$ EADDRNOTAVAIL
+49 无法指定请求的地址
+$ ENETDOWN
+50 网络已关闭
+$ ENETUNREACH
+51 网络不可达
+$ ENETRESET
+52 复位导致网络连接丢失
+$ ECONNABORTED
+53 软件导致的连接中止
+$ ECONNRESET
+54 对方复位了连接
+$ ENOBUFS
+55 缓冲区空间不足
+$ EISCONN
+56 socket 已连接
+$ ENOTCONN
+57 socket 未连接
+$ ESHUTDOWN
+58 socket shutdown 之后无法发送数据
+$ ETOOMANYREFS
+59 引用数过多:无法拼接
+$ ETIMEDOUT
+60 操作超时
+$ ECONNREFUSED
+61 拒绝连接
+$ ELOOP
+62 符号链接层数过多
+$ ENAMETOOLONG
+63 文件名过长
+$ EHOSTDOWN
+64 主机已关闭
+$ EHOSTUNREACH
+65 没有到主机的路由
+$ ENOTEMPTY
+66 目录非空
+$ EPROCLIM
+67 进程数超限
+$ EUSERS
+68 用户数超限
+$ EDQUOT
+69 磁盘空间配额超限
+$ ESTALE
+70 NFS 文件句柄已失效
+$ EREMOTE
+71 远程目录层数过多
+$ EBADRPC
+72 RPC 结构无效
+$ ERPCMISMATCH
+73 RPC 版本错误
+$ EPROGUNAVAIL
+74 RPC 程序不可用
+$ EPROGMISMATCH
+75 程序版本错误
+$ EPROCUNAVAIL
+76 未提供的远程函数
+$ ENOLCK
+77 不支持锁
+$ ENOSYS
+78 功能未实现
+$ EFTYPE
+79 文件类型或格式无效
+$ EAUTH
+80 身份无效
+$ ENEEDAUTH
+81 无信任凭据
+$ EIDRM
+82 无标识符
+$ ENOMSG
+83 无消息类型
+$ EOVERFLOW
+84 数值溢出
+$ ECANCELED
+85 操作已取消
+$ EILSEQ
+86 无效字符序列
+$ ENOATTR
+87 无扩展属性
+$ EDOOFUS
+88 程序设计错误
+$ EBADMSG
+89 无效消息
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 协议错误
+$ ENOTCAPABLE
+93 权能不足
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 终端线路挂断
+$ SIGINT
+2 中断
+$ SIGQUIT
+3 退出
+$ SIGILL
+4 无效指令
+$ SIGTRAP
+5 跟踪/BPT 陷阱
+$ SIGABRT
+6 终止陷阱
+$ SIGEMT
+7 EMT 陷阱
+$ SIGFPE
+8 浮点异常
+$ SIGKILL
+9 强制终止进程
+$ SIGBUS
+10 系统内存访问越界
+$ SIGSEGV
+11 内存访问越界
+$ SIGSYS
+12 无效系统调用
+$ SIGPIPE
+13 写管道时读取者不存在
+$ SIGALRM
+14 实时倒计时到期
+$ SIGTERM
+15 终止
+$ SIGURG
+16 需立即处理的 I/O 紧急状况
+$ SIGSTOP
+17 挂起 (信号)
+$ SIGTSTP
+18 挂起
+$ SIGCONT
+19 继续运行
+$ SIGCHLD
+20 子进程终止
+$ SIGTTIN
+21 TTY 输入阻塞
+$ SIGTTOU
+22 TTY 输出阻塞
+$ SIGIO
+23 I/O 就绪
+$ SIGXCPU
+24 CPU 使用时间过长
+$ SIGXFSZ
+25 文件尺寸过大
+$ SIGVTALRM
+26 虚拟倒计时到期
+$ SIGPROF
+27 剖析倒计时到期
+$ SIGWINCH
+28 窗口尺寸变化
+$ SIGINFO
+29 请求信息
+$ SIGUSR1
+30 用户自定义信号 1
+$ SIGUSR2
+31 用户自定义信号 2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 主机名使用了不支持的地址类型
+$ EAI_AGAIN
+2 暂时无法解析名称
+$ EAI_BADFLAGS
+3 无效的 ai_flags 值
+$ EAI_FAIL
+4 解析名称时出现无法恢复的错误
+$ EAI_FAMILY
+5 不支持的地址信息类型
+$ EAI_MEMORY
+6 内存分配失败
+$ 7 (obsolete)
+7 主机名无相关联的地址
+$ EAI_NONAME
+8 未知的主机名或服务名
+$ EAI_SERVICE
+9 套接字类型不支持此服务名
+$ EAI_SOCKTYPE
+10 不支持的套接字类型
+$ EAI_SYSTEM
+11 系统调用返回了 errno 错误
+$ EAI_BADHINTS
+12 无效提示参数
+$ EAI_PROTOCOL
+13 未知协议
+$ EAI_OVERFLOW
+14 参数缓冲溢出
+$ 0
+32766 成功
+$ NL_MSGMAX
+32767 未知错误
diff --git a/lib/libc/nls/zh_CN.GB2312.msg b/lib/libc/nls/zh_CN.GB2312.msg
new file mode 100644
index 0000000..46ebb42
--- /dev/null
+++ b/lib/libc/nls/zh_CN.GB2312.msg
@@ -0,0 +1,297 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.GB2312 locale
+$
+$ Derived from FreeBSD: head/lib/libc/nls/zh_CN.UTF-8.msg 244756 2012-12-28 01:09:30Z delphij
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 不允许的操作
+$ ENOENT
+2 文件或目录不存在
+$ ESRCH
+3 进程不存在
+$ EINTR
+4 系统调用中止
+$ EIO
+5 输入/输出错误
+$ ENXIO
+6 未配置的设备
+$ E2BIG
+7 参数表过长
+$ ENOEXEC
+8 可执行文件格式错误
+$ EBADF
+9 文件描述符无效
+$ ECHILD
+10 指定子进程不存在
+$ EDEADLK
+11 此操作会导致死锁
+$ ENOMEM
+12 无法分配内存
+$ EACCES
+13 拒绝访问
+$ EFAULT
+14 无效地址
+$ ENOTBLK
+15 该操作需要块设备
+$ EBUSY
+16 设备使用中
+$ EEXIST
+17 文件已存在
+$ EXDEV
+18 链接跨设备
+$ ENODEV
+19 设备不支持此操作
+$ ENOTDIR
+20 对象非目录
+$ EISDIR
+21 对象为目录
+$ EINVAL
+22 参数无效
+$ ENFILE
+23 系统打开文件过多
+$ EMFILE
+24 进程打开文件过多
+$ ENOTTY
+25 无效设备 ioctl
+$ ETXTBSY
+26 可执行文件忙
+$ EFBIG
+27 文件过大
+$ ENOSPC
+28 设备无可用空间
+$ ESPIPE
+29 不允许执行 seek 操作
+$ EROFS
+30 文件系统只读
+$ EMLINK
+31 文件链接过多
+$ EPIPE
+32 管道已中止
+$ EDOM
+33 数值参数越界
+$ ERANGE
+34 结果过大
+$ EAGAIN, EWOULDBLOCK
+35 资源暂时不可用
+$ EINPROGRESS
+36 操作进行中
+$ EALREADY
+37 操作已开始
+$ ENOTSOCK
+38 尝试在非 socket 上执行 socket 操作
+$ EDESTADDRREQ
+39 需要目的地址
+$ EMSGSIZE
+40 消息过长
+$ EPROTOTYPE
+41 socket协议类型错误
+$ ENOPROTOOPT
+42 协议不可用
+$ EPROTONOSUPPORT
+43 不支持的协议
+$ ESOCKTNOSUPPORT
+44 不支持的 socket 类型
+$ EOPNOTSUPP
+45 不支持的操作
+$ EPFNOSUPPORT
+46 不支持的协议族
+$ EAFNOSUPPORT
+47 协议族不支持的地址族
+$ EADDRINUSE
+48 地址已被占用
+$ EADDRNOTAVAIL
+49 无法指定请求的地址
+$ ENETDOWN
+50 网络已关闭
+$ ENETUNREACH
+51 网络不可达
+$ ENETRESET
+52 复位导致网络连接丢失
+$ ECONNABORTED
+53 软件导致的连接中止
+$ ECONNRESET
+54 对方复位了连接
+$ ENOBUFS
+55 缓冲区空间不足
+$ EISCONN
+56 socket 已连接
+$ ENOTCONN
+57 socket 未连接
+$ ESHUTDOWN
+58 socket shutdown 之后无法发送数据
+$ ETOOMANYREFS
+59 引用数过多:无法拼接
+$ ETIMEDOUT
+60 操作超时
+$ ECONNREFUSED
+61 拒绝连接
+$ ELOOP
+62 符号链接层数过多
+$ ENAMETOOLONG
+63 文件名过长
+$ EHOSTDOWN
+64 主机已关闭
+$ EHOSTUNREACH
+65 没有到主机的路由
+$ ENOTEMPTY
+66 目录非空
+$ EPROCLIM
+67 进程数超限
+$ EUSERS
+68 用户数超限
+$ EDQUOT
+69 磁盘空间配额超限
+$ ESTALE
+70 NFS 文件句柄已失效
+$ EREMOTE
+71 远程目录层数过多
+$ EBADRPC
+72 RPC 结构无效
+$ ERPCMISMATCH
+73 RPC 版本错误
+$ EPROGUNAVAIL
+74 RPC 程序不可用
+$ EPROGMISMATCH
+75 程序版本错误
+$ EPROCUNAVAIL
+76 未提供的远程函数
+$ ENOLCK
+77 不支持锁
+$ ENOSYS
+78 功能未实现
+$ EFTYPE
+79 文件类型或格式无效
+$ EAUTH
+80 身份无效
+$ ENEEDAUTH
+81 无信任凭据
+$ EIDRM
+82 无标识符
+$ ENOMSG
+83 无消息类型
+$ EOVERFLOW
+84 数值溢出
+$ ECANCELED
+85 操作已取消
+$ EILSEQ
+86 无效字符序列
+$ ENOATTR
+87 无扩展属性
+$ EDOOFUS
+88 程序设计错误
+$ EBADMSG
+89 无效消息
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 协议错误
+$ ENOTCAPABLE
+93 权能不足
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 终端线路挂断
+$ SIGINT
+2 中断
+$ SIGQUIT
+3 退出
+$ SIGILL
+4 无效指令
+$ SIGTRAP
+5 跟踪/BPT 陷阱
+$ SIGABRT
+6 终止陷阱
+$ SIGEMT
+7 EMT 陷阱
+$ SIGFPE
+8 浮点异常
+$ SIGKILL
+9 强制终止进程
+$ SIGBUS
+10 系统内存访问越界
+$ SIGSEGV
+11 内存访问越界
+$ SIGSYS
+12 无效系统调用
+$ SIGPIPE
+13 写管道时读取者不存在
+$ SIGALRM
+14 实时倒计时到期
+$ SIGTERM
+15 终止
+$ SIGURG
+16 需立即处理的 I/O 紧急状况
+$ SIGSTOP
+17 挂起 (信号)
+$ SIGTSTP
+18 挂起
+$ SIGCONT
+19 继续运行
+$ SIGCHLD
+20 子进程终止
+$ SIGTTIN
+21 TTY 输入阻塞
+$ SIGTTOU
+22 TTY 输出阻塞
+$ SIGIO
+23 I/O 就绪
+$ SIGXCPU
+24 CPU 使用时间过长
+$ SIGXFSZ
+25 文件尺寸过大
+$ SIGVTALRM
+26 虚拟倒计时到期
+$ SIGPROF
+27 剖析倒计时到期
+$ SIGWINCH
+28 窗口尺寸变化
+$ SIGINFO
+29 请求信息
+$ SIGUSR1
+30 用户自定义信号 1
+$ SIGUSR2
+31 用户自定义信号 2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 主机名使用了不支持的地址类型
+$ EAI_AGAIN
+2 暂时无法解析名称
+$ EAI_BADFLAGS
+3 无效的 ai_flags 值
+$ EAI_FAIL
+4 解析名称时出现无法恢复的错误
+$ EAI_FAMILY
+5 不支持的地址信息类型
+$ EAI_MEMORY
+6 内存分配失败
+$ 7 (obsolete)
+7 主机名无相关联的地址
+$ EAI_NONAME
+8 未知的主机名或服务名
+$ EAI_SERVICE
+9 套接字类型不支持此服务名
+$ EAI_SOCKTYPE
+10 不支持的套接字类型
+$ EAI_SYSTEM
+11 系统调用返回了 errno 错误
+$ EAI_BADHINTS
+12 无效提示参数
+$ EAI_PROTOCOL
+13 未知协议
+$ EAI_OVERFLOW
+14 参数缓冲溢出
+$ 0
+32766 成功
+$ NL_MSGMAX
+32767 未知错误
diff --git a/lib/libc/nls/zh_CN.UTF-8.msg b/lib/libc/nls/zh_CN.UTF-8.msg
new file mode 100644
index 0000000..9475ea8
--- /dev/null
+++ b/lib/libc/nls/zh_CN.UTF-8.msg
@@ -0,0 +1,295 @@
+$ $FreeBSD$
+$
+$ Message catalog for zh_CN.UTF-8 locale
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 涓嶅厑璁哥殑鎿嶄綔
+$ ENOENT
+2 鏂囦欢鎴栫洰褰曚笉瀛樺湪
+$ ESRCH
+3 杩涚▼涓嶅瓨鍦
+$ EINTR
+4 绯荤粺璋冪敤涓
+$ EIO
+5 杈撳叆/杈撳嚭閿欒
+$ ENXIO
+6 鏈厤缃殑璁惧
+$ E2BIG
+7 鍙傛暟琛ㄨ繃闀
+$ ENOEXEC
+8 鍙墽琛屾枃浠舵牸寮忛敊璇
+$ EBADF
+9 鏂囦欢鎻忚堪绗︽棤鏁
+$ ECHILD
+10 鎸囧畾瀛愯繘绋嬩笉瀛樺湪
+$ EDEADLK
+11 姝ゆ搷浣滀細瀵艰嚧姝婚攣
+$ ENOMEM
+12 鏃犳硶鍒嗛厤鍐呭瓨
+$ EACCES
+13 鎷掔粷璁块棶
+$ EFAULT
+14 鏃犳晥鍦板潃
+$ ENOTBLK
+15 璇ユ搷浣滈渶瑕佸潡璁惧
+$ EBUSY
+16 璁惧浣跨敤涓
+$ EEXIST
+17 鏂囦欢宸插瓨鍦
+$ EXDEV
+18 閾炬帴璺ㄨ澶
+$ ENODEV
+19 璁惧涓嶆敮鎸佹鎿嶄綔
+$ ENOTDIR
+20 瀵硅薄闈炵洰褰
+$ EISDIR
+21 瀵硅薄涓虹洰褰
+$ EINVAL
+22 鍙傛暟鏃犳晥
+$ ENFILE
+23 绯荤粺鎵撳紑鏂囦欢杩囧
+$ EMFILE
+24 杩涚▼鎵撳紑鏂囦欢杩囧
+$ ENOTTY
+25 鏃犳晥璁惧 ioctl
+$ ETXTBSY
+26 鍙墽琛屾枃浠跺繖
+$ EFBIG
+27 鏂囦欢杩囧ぇ
+$ ENOSPC
+28 璁惧鏃犲彲鐢ㄧ┖闂
+$ ESPIPE
+29 涓嶅厑璁告墽琛 seek 鎿嶄綔
+$ EROFS
+30 鏂囦欢绯荤粺鍙
+$ EMLINK
+31 鏂囦欢閾炬帴杩囧
+$ EPIPE
+32 绠¢亾宸蹭腑姝
+$ EDOM
+33 鏁板煎弬鏁拌秺鐣
+$ ERANGE
+34 缁撴灉杩囧ぇ
+$ EAGAIN, EWOULDBLOCK
+35 璧勬簮鏆傛椂涓嶅彲鐢
+$ EINPROGRESS
+36 鎿嶄綔杩涜涓
+$ EALREADY
+37 鎿嶄綔宸插紑濮
+$ ENOTSOCK
+38 灏濊瘯鍦ㄩ潪 socket 涓婃墽琛 socket 鎿嶄綔
+$ EDESTADDRREQ
+39 闇瑕佺洰鐨勫湴鍧
+$ EMSGSIZE
+40 娑堟伅杩囬暱
+$ EPROTOTYPE
+41 socket鍗忚绫诲瀷閿欒
+$ ENOPROTOOPT
+42 鍗忚涓嶅彲鐢
+$ EPROTONOSUPPORT
+43 涓嶆敮鎸佺殑鍗忚
+$ ESOCKTNOSUPPORT
+44 涓嶆敮鎸佺殑 socket 绫诲瀷
+$ EOPNOTSUPP
+45 涓嶆敮鎸佺殑鎿嶄綔
+$ EPFNOSUPPORT
+46 涓嶆敮鎸佺殑鍗忚鏃
+$ EAFNOSUPPORT
+47 鍗忚鏃忎笉鏀寔鐨勫湴鍧鏃
+$ EADDRINUSE
+48 鍦板潃宸茶鍗犵敤
+$ EADDRNOTAVAIL
+49 鏃犳硶鎸囧畾璇锋眰鐨勫湴鍧
+$ ENETDOWN
+50 缃戠粶宸插叧闂
+$ ENETUNREACH
+51 缃戠粶涓嶅彲杈
+$ ENETRESET
+52 澶嶄綅瀵艰嚧缃戠粶杩炴帴涓㈠け
+$ ECONNABORTED
+53 杞欢瀵艰嚧鐨勮繛鎺ヤ腑姝
+$ ECONNRESET
+54 瀵规柟澶嶄綅浜嗚繛鎺
+$ ENOBUFS
+55 缂撳啿鍖虹┖闂翠笉瓒
+$ EISCONN
+56 socket 宸茶繛鎺
+$ ENOTCONN
+57 socket 鏈繛鎺
+$ ESHUTDOWN
+58 socket shutdown 涔嬪悗鏃犳硶鍙戦佹暟鎹
+$ ETOOMANYREFS
+59 寮曠敤鏁拌繃澶氾細鏃犳硶鎷兼帴
+$ ETIMEDOUT
+60 鎿嶄綔瓒呮椂
+$ ECONNREFUSED
+61 鎷掔粷杩炴帴
+$ ELOOP
+62 绗﹀彿閾炬帴灞傛暟杩囧
+$ ENAMETOOLONG
+63 鏂囦欢鍚嶈繃闀
+$ EHOSTDOWN
+64 涓绘満宸插叧闂
+$ EHOSTUNREACH
+65 娌℃湁鍒颁富鏈虹殑璺敱
+$ ENOTEMPTY
+66 鐩綍闈炵┖
+$ EPROCLIM
+67 杩涚▼鏁拌秴闄
+$ EUSERS
+68 鐢ㄦ埛鏁拌秴闄
+$ EDQUOT
+69 纾佺洏绌洪棿閰嶉瓒呴檺
+$ ESTALE
+70 NFS 鏂囦欢鍙ユ焺宸插け鏁
+$ EREMOTE
+71 杩滅▼鐩綍灞傛暟杩囧
+$ EBADRPC
+72 RPC 缁撴瀯鏃犳晥
+$ ERPCMISMATCH
+73 RPC 鐗堟湰閿欒
+$ EPROGUNAVAIL
+74 RPC 绋嬪簭涓嶅彲鐢
+$ EPROGMISMATCH
+75 绋嬪簭鐗堟湰閿欒
+$ EPROCUNAVAIL
+76 鏈彁渚涚殑杩滅▼鍑芥暟
+$ ENOLCK
+77 涓嶆敮鎸侀攣
+$ ENOSYS
+78 鍔熻兘鏈疄鐜
+$ EFTYPE
+79 鏂囦欢绫诲瀷鎴栨牸寮忔棤鏁
+$ EAUTH
+80 韬唤鏃犳晥
+$ ENEEDAUTH
+81 鏃犱俊浠诲嚟鎹
+$ EIDRM
+82 鏃犳爣璇嗙
+$ ENOMSG
+83 鏃犳秷鎭被鍨
+$ EOVERFLOW
+84 鏁板兼孩鍑
+$ ECANCELED
+85 鎿嶄綔宸插彇娑
+$ EILSEQ
+86 鏃犳晥瀛楃搴忓垪
+$ ENOATTR
+87 鏃犳墿灞曞睘鎬
+$ EDOOFUS
+88 绋嬪簭璁捐閿欒
+$ EBADMSG
+89 鏃犳晥娑堟伅
+$ EMULTIHOP
+90 Multihop attempted
+$ ENOLINK
+91 Link has been severed
+$ EPROTO
+92 鍗忚閿欒
+$ ENOTCAPABLE
+93 鏉冭兘涓嶈冻
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+1 缁堢绾胯矾鎸傛柇
+$ SIGINT
+2 涓柇
+$ SIGQUIT
+3 閫鍑
+$ SIGILL
+4 鏃犳晥鎸囦护
+$ SIGTRAP
+5 璺熻釜/BPT 闄烽槺
+$ SIGABRT
+6 缁堟闄烽槺
+$ SIGEMT
+7 EMT 闄烽槺
+$ SIGFPE
+8 娴偣寮傚父
+$ SIGKILL
+9 寮哄埗缁堟杩涚▼
+$ SIGBUS
+10 绯荤粺鍐呭瓨璁块棶瓒婄晫
+$ SIGSEGV
+11 鍐呭瓨璁块棶瓒婄晫
+$ SIGSYS
+12 鏃犳晥绯荤粺璋冪敤
+$ SIGPIPE
+13 鍐欑閬撴椂璇诲彇鑰呬笉瀛樺湪
+$ SIGALRM
+14 瀹炴椂鍊掕鏃跺埌鏈
+$ SIGTERM
+15 缁堟
+$ SIGURG
+16 闇绔嬪嵆澶勭悊鐨 I/O 绱фョ姸鍐
+$ SIGSTOP
+17 鎸傝捣 (淇″彿)
+$ SIGTSTP
+18 鎸傝捣
+$ SIGCONT
+19 缁х画杩愯
+$ SIGCHLD
+20 瀛愯繘绋嬬粓姝
+$ SIGTTIN
+21 TTY 杈撳叆闃诲
+$ SIGTTOU
+22 TTY 杈撳嚭闃诲
+$ SIGIO
+23 I/O 灏辩华
+$ SIGXCPU
+24 CPU 浣跨敤鏃堕棿杩囬暱
+$ SIGXFSZ
+25 鏂囦欢灏哄杩囧ぇ
+$ SIGVTALRM
+26 铏氭嫙鍊掕鏃跺埌鏈
+$ SIGPROF
+27 鍓栨瀽鍊掕鏃跺埌鏈
+$ SIGWINCH
+28 绐楀彛灏哄鍙樺寲
+$ SIGINFO
+29 璇锋眰淇℃伅
+$ SIGUSR1
+30 鐢ㄦ埛鑷畾涔変俊鍙 1
+$ SIGUSR2
+31 鐢ㄦ埛鑷畾涔変俊鍙 2
+$
+$ gai_strerror() support catalog
+$
+$set 3
+$ 1 (obsolete)
+1 涓绘満鍚嶄娇鐢ㄤ簡涓嶆敮鎸佺殑鍦板潃绫诲瀷
+$ EAI_AGAIN
+2 鏆傛椂鏃犳硶瑙f瀽鍚嶇О
+$ EAI_BADFLAGS
+3 鏃犳晥鐨 ai_flags 鍊
+$ EAI_FAIL
+4 瑙f瀽鍚嶇О鏃跺嚭鐜版棤娉曟仮澶嶇殑閿欒
+$ EAI_FAMILY
+5 涓嶆敮鎸佺殑鍦板潃淇℃伅绫诲瀷
+$ EAI_MEMORY
+6 鍐呭瓨鍒嗛厤澶辫触
+$ 7 (obsolete)
+7 涓绘満鍚嶆棤鐩稿叧鑱旂殑鍦板潃
+$ EAI_NONAME
+8 鏈煡鐨勪富鏈哄悕鎴栨湇鍔″悕
+$ EAI_SERVICE
+9 濂楁帴瀛楃被鍨嬩笉鏀寔姝ゆ湇鍔″悕
+$ EAI_SOCKTYPE
+10 涓嶆敮鎸佺殑濂楁帴瀛楃被鍨
+$ EAI_SYSTEM
+11 绯荤粺璋冪敤杩斿洖浜 errno 閿欒
+$ EAI_BADHINTS
+12 鏃犳晥鎻愮ず鍙傛暟
+$ EAI_PROTOCOL
+13 鏈煡鍗忚
+$ EAI_OVERFLOW
+14 鍙傛暟缂撳啿婧㈠嚭
+$ 0
+32766 鎴愬姛
+$ NL_MSGMAX
+32767 鏈煡閿欒
diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2
index fecc5fa..896b005 100644
--- a/lib/libc/sys/bind.2
+++ b/lib/libc/sys/bind.2
@@ -94,6 +94,8 @@ is not a socket.
The specified address is not available from the local machine.
.It Bq Er EADDRINUSE
The specified address is already in use.
+.It Bq Er EAFNOSUPPORT
+Addresses in the specified address family cannot be used with this socket.
.It Bq Er EACCES
The requested address is protected, and the current user
has inadequate permission to access it.
diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2
index ed9c15a..0e5fef8 100644
--- a/lib/libc/sys/mlock.2
+++ b/lib/libc/sys/mlock.2
@@ -28,7 +28,7 @@
.\" @(#)mlock.2 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd July 27, 2010
+.Dd December 25, 2012
.Dt MLOCK 2
.Os
.Sh NAME
@@ -94,12 +94,15 @@ limited in how much they can lock down.
A single process can
.Fn mlock
the minimum of
-a system-wide ``wired pages'' limit and
-the per-process
+a system-wide ``wired pages'' limit
+.Va vm.max_wired
+and the per-process
.Li RLIMIT_MEMLOCK
resource limit.
.Pp
-These calls are only available to the super-user.
+If
+.Va security.bsd.unprivileged_mlock
+is set to 0 these calls are only available to the super-user.
.Sh RETURN VALUES
.Rv -std
.Pp
@@ -112,7 +115,8 @@ system call
will fail if:
.Bl -tag -width Er
.It Bq Er EPERM
-The caller is not the super-user.
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
.It Bq Er EINVAL
The address given is not page aligned or the length is negative.
.It Bq Er EAGAIN
@@ -129,7 +133,8 @@ system call
will fail if:
.Bl -tag -width Er
.It Bq Er EPERM
-The caller is not the super-user.
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
.It Bq Er EINVAL
The address given is not page aligned or the length is negative.
.It Bq Er ENOMEM
diff --git a/lib/libc/sys/mlockall.2 b/lib/libc/sys/mlockall.2
index 54ae23e..23c644a 100644
--- a/lib/libc/sys/mlockall.2
+++ b/lib/libc/sys/mlockall.2
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 27, 2010
+.Dd December 25, 2012
.Dt MLOCKALL 2
.Os
.Sh NAME
@@ -68,11 +68,22 @@ Since physical memory is a potentially scarce resource, processes are
limited in how much they can lock down.
A single process can lock the minimum of a system-wide
.Dq wired pages
-limit and the per-process
+limit
+.Va vm.max_wired
+and the per-process
.Dv RLIMIT_MEMLOCK
resource limit.
.Pp
-These calls are only available to the super-user.
+If
+.Va security.bsd.unprivileged_mlock
+is set to 0 these calls are only available to the super-user.
+If
+.Va vm.old_mlock
+is set to 1 the per-process
+.Dv RLIMIT_MEMLOCK
+resource limit will not be applied for
+.Fn mlockall
+calls.
.Pp
The
.Fn munlockall
diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2
index dae33d0..24e4293 100644
--- a/lib/libc/sys/socket.2
+++ b/lib/libc/sys/socket.2
@@ -28,7 +28,7 @@
.\" From: @(#)socket.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd January 5, 2009
+.Dd December 7, 2012
.Dt SOCKET 2
.Os
.Sh NAME
@@ -248,21 +248,26 @@ The
.Fn socket
system call fails if:
.Bl -tag -width Er
-.It Bq Er EPROTONOSUPPORT
-The protocol type or the specified protocol is not supported
-within this domain.
+.It Bq Er EACCES
+Permission to create a socket of the specified type and/or protocol
+is denied.
+.It Bq Er EAFNOSUPPORT
+The address family (domain) is not supported or the
+specified domain is not supported by this protocol family.
.It Bq Er EMFILE
The per-process descriptor table is full.
.It Bq Er ENFILE
The system file table is full.
-.It Bq Er EACCES
-Permission to create a socket of the specified type and/or protocol
-is denied.
.It Bq Er ENOBUFS
Insufficient buffer space is available.
The socket cannot be created until sufficient resources are freed.
.It Bq Er EPERM
User has insufficient privileges to carry out the requested operation.
+.It Bq Er EPROTONOSUPPORT
+The protocol type or the specified protocol is not supported
+within this domain.
+.It Bq Er EPROTOTYPE
+The socket type is not supported by the protocol.
.El
.Sh SEE ALSO
.Xr accept 2 ,
OpenPOWER on IntegriCloud