summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/Makefile.master1
-rw-r--r--usr/src/cmd/localedef/Makefile38
l---------usr/src/cmd/localedef/data/zz_AA.UTF-8.src1
-rw-r--r--usr/src/cmd/localedef/translations/zz_AA.UTF-8.po7
-rw-r--r--usr/src/cmd/localedef/translations/zz_AA.UTF-8.priv25
-rw-r--r--usr/src/cmd/sgs/rtld/common/external.c23
-rw-r--r--usr/src/head/string.h1
-rw-r--r--usr/src/lib/libc/inc/libc.h5
-rw-r--r--usr/src/lib/libc/port/gen/_libc_gettext.h8
-rw-r--r--usr/src/lib/libc/port/gen/catopen.c10
-rw-r--r--usr/src/lib/libc/port/gen/gettxt.c6
-rw-r--r--usr/src/lib/libc/port/gen/gtxt.c6
-rw-r--r--usr/src/lib/libc/port/gen/priv_str_xlate.c7
-rw-r--r--usr/src/lib/libc/port/gen/strerror.c18
-rw-r--r--usr/src/lib/libc/port/i18n/gettext.c31
-rw-r--r--usr/src/lib/libc/port/i18n/gettext.h6
-rw-r--r--usr/src/lib/libc/port/i18n/gettext_real.c16
-rw-r--r--usr/src/lib/libc/port/i18n/gettext_util.c5
-rw-r--r--usr/src/lib/libc/port/i18n/wdresolve.c6
-rw-r--r--usr/src/lib/libc/port/locale/setlocale.c4
-rw-r--r--usr/src/lib/libc/port/mapfile-vers5
-rw-r--r--usr/src/man/man3c/Makefile2
-rw-r--r--usr/src/man/man3c/newlocale.3c2
-rw-r--r--usr/src/man/man3c/strerror.3c50
-rw-r--r--usr/src/man/man3lib/libc.3lib4
-rw-r--r--usr/src/pkg/manifests/system-library.man3c.inc1
-rw-r--r--usr/src/pkg/manifests/system-test-libctest.mf23
-rw-r--r--usr/src/test/libc-tests/cfg/Makefile1
-rw-r--r--usr/src/test/libc-tests/cfg/symbols/string_h.cfg33
-rw-r--r--usr/src/test/libc-tests/runfiles/default.run5
-rw-r--r--usr/src/test/libc-tests/tests/Makefile12
-rw-r--r--usr/src/test/libc-tests/tests/catopen/Makefile51
-rw-r--r--usr/src/test/libc-tests/tests/catopen/catopen.c85
-rw-r--r--usr/src/test/libc-tests/tests/priv_gettext/Makefile51
-rw-r--r--usr/src/test/libc-tests/tests/priv_gettext/priv_gettext.c88
-rw-r--r--usr/src/test/libc-tests/tests/strerror/Makefile51
-rw-r--r--usr/src/test/libc-tests/tests/strerror/strerror.c100
-rw-r--r--usr/src/test/libc-tests/tests/symbols/Makefile1
-rw-r--r--usr/src/test/libc-tests/tests/symbols/symbols_test.c6
39 files changed, 720 insertions, 75 deletions
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master
index dd6b058b66..04eddd22de 100644
--- a/usr/src/Makefile.master
+++ b/usr/src/Makefile.master
@@ -187,6 +187,7 @@ UNIQ= /usr/bin/uniq
TAR= /usr/bin/tar
ASTBINDIR= /usr/ast/bin
MSGCC= $(ASTBINDIR)/msgcc
+MSGFMT= /usr/bin/msgfmt -s
FILEMODE= 644
DIRMODE= 755
diff --git a/usr/src/cmd/localedef/Makefile b/usr/src/cmd/localedef/Makefile
index 45cc1c88c0..03432dbcf8 100644
--- a/usr/src/cmd/localedef/Makefile
+++ b/usr/src/cmd/localedef/Makefile
@@ -202,7 +202,8 @@ UTF_8_LOCALES = \
ug_CN \
ur_IN ur_PK \
vi_VN \
- zh_CN zh_HK zh_MO zh_SG zh_TW
+ zh_CN zh_HK zh_MO zh_SG zh_TW \
+ zz_AA
UTF8SRCS = $(UTF_8_LOCALES:%=data/%.UTF-8.src)
@@ -245,11 +246,32 @@ ROOTLOCDIRS = $(LOCDIRS:%=$(ROOTLIB)/%)
ROOTCATDIRS = $(CATDIRS:%=$(ROOTLIB)/%)
ROOTDATA = $(DATA:%=$(ROOTLIB)/%)
+#
+# This is a list of locales that happen to have translations for them
+# present in the gate.
+#
+TRANSDIR = translations
+TRANSLOCS = \
+ zz_AA.UTF-8
+TRANSMOS = $(TRANSLOCS:%=$(TRANSDIR)/%.mo)
+
+OSTMOFILE = LC_MESSAGES/SUNW_OST_OSLIB.mo
+
+PRIVTRANSLOCS = \
+ zz_AA.UTF-8
+PRIVFILE = LC_MESSAGES/priv_names
+
+
+ROOTTRANSLATIONS = $(TRANSLOCS:%=$(ROOTLIB)/locale/%/$(OSTMOFILE))
+ROOTPRIVTRANS = $(PRIVTRANSLOCS:%=$(ROOTLIB)/locale/%/$(PRIVFILE))
+
$(ROOTDATA) := FILEMODE=0444
all: $(PROG) $(DATA)
-install: all $(ROOTPROG) $(ROOTDATA)
+translate: $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
+
+install: all $(ROOTPROG) $(ROOTDATA) $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
$(NDIR):
mkdir $@
@@ -282,6 +304,7 @@ clobber: clean
$(RM) $(CLOBBERFILES)
$(RM) -r $(LOCDIRS)
$(RM) -r $(NDIR)
+ $(RM) $(TRANSMOS)
$(POFILE): $(PIFILES)
$(RM) $@
@@ -364,3 +387,14 @@ $(ROOTDATA): $(ROOTLOCDIRS) $(ROOTCATDIRS) $(DATA)
$(RM) $@
$(CP) $(@:$(ROOTLIB)/%=%) $@
$(CHMOD) 0444 $@
+
+%.mo: %.po
+ $(MSGFMT) -o $@ $<
+
+$(ROOTLIB)/locale/%/$(OSTMOFILE): $(TRANSDIR)/%.mo
+ $(INS.rename)
+ $(CHMOD) 0444 $@
+
+$(ROOTLIB)/locale/%/$(PRIVFILE): $(TRANSDIR)/%.priv
+ $(INS.rename)
+ $(CHMOD) 0444 $@
diff --git a/usr/src/cmd/localedef/data/zz_AA.UTF-8.src b/usr/src/cmd/localedef/data/zz_AA.UTF-8.src
new file mode 120000
index 0000000000..8a3463821d
--- /dev/null
+++ b/usr/src/cmd/localedef/data/zz_AA.UTF-8.src
@@ -0,0 +1 @@
+en_US.UTF-8.src \ No newline at end of file
diff --git a/usr/src/cmd/localedef/translations/zz_AA.UTF-8.po b/usr/src/cmd/localedef/translations/zz_AA.UTF-8.po
new file mode 100644
index 0000000000..e1c551233f
--- /dev/null
+++ b/usr/src/cmd/localedef/translations/zz_AA.UTF-8.po
@@ -0,0 +1,7 @@
+#
+# The zz_AA locale is purely a test locale. These translations are
+# currently used for the strerror tests, to verify that strerror_l and
+# the various locale aware aspects of it are working correctly.
+#
+msgid "No such file or directory"
+msgstr "It's a trap!"
diff --git a/usr/src/cmd/localedef/translations/zz_AA.UTF-8.priv b/usr/src/cmd/localedef/translations/zz_AA.UTF-8.priv
new file mode 100644
index 0000000000..ad14a98a70
--- /dev/null
+++ b/usr/src/cmd/localedef/translations/zz_AA.UTF-8.priv
@@ -0,0 +1,25 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Joyent, Inc.
+#
+
+#
+#
+# This is a dummy version of the privilege names file. It is designed to
+# be used to test priv_gettext which does not use a normal message file.
+# See lib/libc/port/gen/priv_str_xlate.c for how this file is supposed
+# to be formatted.
+#
+
+dtrace_kernel
+ Ah Elbereth Gilthoniel
diff --git a/usr/src/cmd/sgs/rtld/common/external.c b/usr/src/cmd/sgs/rtld/common/external.c
index e2ebd89145..4a16ffcf9b 100644
--- a/usr/src/cmd/sgs/rtld/common/external.c
+++ b/usr/src/cmd/sgs/rtld/common/external.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2015 Joyent, Inc.
*/
/*
@@ -180,6 +181,7 @@
#include <synch.h>
#include <strings.h>
#include <stdio.h>
+#include <libintl.h>
#include <debug.h>
#include <libc_int.h>
#include "_elf.h"
@@ -718,3 +720,24 @@ isalnum(int c)
{
return ((isalpha(c) || isdigit(c)) ? 1 : 0);
}
+
+/*
+ * In a similar vein to the is* functions above, we also have to define our own
+ * version of strerror, as it is implemented in terms of the locale aware
+ * strerror_l, and we'd rather not have the full set of libc symbols used here.
+ */
+extern const char _sys_errs[];
+extern const int _sys_index[];
+extern int _sys_num_err;
+
+char *
+strerror(int errnum)
+{
+ if (errnum < _sys_num_err && errnum >= 0) {
+ return (dgettext("SUNW_OST_OSLIB",
+ (char *)&_sys_errs[_sys_index[errnum]]));
+ }
+
+ errno = EINVAL;
+ return (dgettext("SUNW_OST_OSLIB", "Unknown error"));
+}
diff --git a/usr/src/head/string.h b/usr/src/head/string.h
index 6801c7eb9d..30dc025467 100644
--- a/usr/src/head/string.h
+++ b/usr/src/head/string.h
@@ -103,6 +103,7 @@ extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
size_t, locale_t);
extern int strcasecmp_l(const char *, const char *, locale_t);
extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
+extern char *strerror_l(int, locale_t);
#endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */
diff --git a/usr/src/lib/libc/inc/libc.h b/usr/src/lib/libc/inc/libc.h
index 5feca8b80f..86d894b3de 100644
--- a/usr/src/lib/libc/inc/libc.h
+++ b/usr/src/lib/libc/inc/libc.h
@@ -311,6 +311,11 @@ extern wint_t _putwc(wint_t, FILE *);
*/
extern wint_t __ungetwc_xpg5(wint_t, FILE *);
+/*
+ * Defined in setlocale.c.
+ */
+extern char *current_locale(locale_t, int);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/lib/libc/port/gen/_libc_gettext.h b/usr/src/lib/libc/port/gen/_libc_gettext.h
index b73bc6e95c..868d85a2b8 100644
--- a/usr/src/lib/libc/port/gen/_libc_gettext.h
+++ b/usr/src/lib/libc/port/gen/_libc_gettext.h
@@ -27,15 +27,17 @@
#ifndef _LIBC_GETTEXT_H
#define _LIBC_GETTEXT_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <libintl.h>
+#include <locale.h>
+
+extern char *dgettext_l(const char *, const char *, locale_t);
/* Header file for _libc_gettext() macro. */
#if !defined(TEXT_DOMAIN) /* Should be defined thru -D flag. */
#define TEXT_DOMAIN "SYS_TEST"
#endif
-#define _libc_gettext(msg_id) dgettext(TEXT_DOMAIN, msg_id)
+#define _libc_gettext(msg_id) dgettext(TEXT_DOMAIN, (msg_id))
+#define _libc_gettext_l(msg_id, loc) dgettext_l(TEXT_DOMAIN, (msg_id), (loc))
#endif /* _LIBC_GETTEXT_H */
diff --git a/usr/src/lib/libc/port/gen/catopen.c b/usr/src/lib/libc/port/gen/catopen.c
index 0da2a749fa..8a0ca43a3c 100644
--- a/usr/src/lib/libc/port/gen/catopen.c
+++ b/usr/src/lib/libc/port/gen/catopen.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* catopen.c
*
@@ -103,10 +101,12 @@ process_nls_path(char *name, int oflag)
*
* Chose XPG4. If oflag == NL_CAT_LOCALE, use LC_MESSAGES.
*/
- if (oflag == NL_CAT_LOCALE)
- locale = setlocale(LC_MESSAGES, NULL);
- else
+ if (oflag == NL_CAT_LOCALE) {
+ locale_t loc = uselocale(NULL);
+ locale = current_locale(loc, LC_MESSAGES);
+ } else {
locale = getenv("LANG");
+ }
nlspath = getenv("NLSPATH");
lang = NULL;
diff --git a/usr/src/lib/libc/port/gen/gettxt.c b/usr/src/lib/libc/port/gen/gettxt.c
index 88e0b5b72c..a462c5ba1e 100644
--- a/usr/src/lib/libc/port/gen/gettxt.c
+++ b/usr/src/lib/libc/port/gen/gettxt.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#pragma weak _gettxt = gettxt
#include "lint.h"
@@ -91,6 +89,7 @@ gettxt(const char *msg_id, const char *dflt_str)
char *tokp;
size_t name_len;
char *curloc;
+ locale_t loc;
if ((msg_id == NULL) || (*msg_id == '\0')) {
return (handle_return(dflt_str));
@@ -121,7 +120,8 @@ gettxt(const char *msg_id, const char *dflt_str)
return (handle_return(dflt_str));
}
msgnum = atoi(msg_id + name_len + 1);
- curloc = setlocale(LC_MESSAGES, NULL);
+ loc = uselocale(NULL);
+ curloc = current_locale(loc, LC_MESSAGES);
lmutex_lock(&gettxt_lock);
diff --git a/usr/src/lib/libc/port/gen/gtxt.c b/usr/src/lib/libc/port/gen/gtxt.c
index 80936415dc..bd08e47262 100644
--- a/usr/src/lib/libc/port/gen/gtxt.c
+++ b/usr/src/lib/libc/port/gen/gtxt.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/* __gtxt(): Common part to gettxt() and pfmt() */
#pragma weak _setcat = setcat
@@ -260,6 +258,7 @@ __gtxt(const char *catname, int id, const char *dflt)
char *curloc;
struct db_info *db;
int err;
+ locale_t loc;
/* Check for invalid message id */
if (id < 0)
@@ -281,7 +280,8 @@ __gtxt(const char *catname, int id, const char *dflt)
lrw_unlock(&_rw_cur_cat);
}
- curloc = setlocale(LC_MESSAGES, NULL);
+ loc = uselocale(NULL);
+ curloc = current_locale(loc, LC_MESSAGES);
/* First look up the cache */
db = lookup_cache(NULL, curloc, catname);
diff --git a/usr/src/lib/libc/port/gen/priv_str_xlate.c b/usr/src/lib/libc/port/gen/priv_str_xlate.c
index 763665c492..9796a2d858 100644
--- a/usr/src/lib/libc/port/gen/priv_str_xlate.c
+++ b/usr/src/lib/libc/port/gen/priv_str_xlate.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* priv_str_xlate.c - Privilege translation routines.
*/
@@ -432,6 +430,7 @@ char *
priv_gettext(const char *priv)
{
char file[MAXPATHLEN];
+ locale_t curloc;
const char *loc;
char *ret;
@@ -439,8 +438,8 @@ priv_gettext(const char *priv)
if (priv_getbyname(priv) < 0)
return (NULL);
- if ((loc = setlocale(LC_MESSAGES, NULL)) == NULL)
- loc = "C";
+ curloc = uselocale(NULL);
+ loc = current_locale(curloc, LC_MESSAGES);
if (snprintf(file, sizeof (file),
_DFLT_LOC_PATH "%s/LC_MESSAGES/priv_names", loc) < sizeof (file)) {
diff --git a/usr/src/lib/libc/port/gen/strerror.c b/usr/src/lib/libc/port/gen/strerror.c
index 213d964cf3..2269e2cf65 100644
--- a/usr/src/lib/libc/port/gen/strerror.c
+++ b/usr/src/lib/libc/port/gen/strerror.c
@@ -23,12 +23,13 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "_libc_gettext.h"
#include <string.h>
@@ -40,13 +41,20 @@ extern const int _sys_index[];
extern int _sys_num_err;
char *
-strerror(int errnum)
+strerror_l(int errnum, locale_t loc)
{
if (errnum < _sys_num_err && errnum >= 0)
- return (_libc_gettext((char *)&_sys_errs[_sys_index[errnum]]));
+ return (_libc_gettext_l(&_sys_errs[_sys_index[errnum]],
+ loc));
errno = EINVAL;
- return (_libc_gettext("Unknown error"));
+ return (_libc_gettext_l("Unknown error", loc));
+}
+
+char *
+strerror(int errnum)
+{
+ return (strerror_l(errnum, uselocale(NULL)));
}
/*
diff --git a/usr/src/lib/libc/port/i18n/gettext.c b/usr/src/lib/libc/port/i18n/gettext.c
index 1922edae04..ef4a3db985 100644
--- a/usr/src/lib/libc/port/i18n/gettext.c
+++ b/usr/src/lib/libc/port/i18n/gettext.c
@@ -23,8 +23,9 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
#pragma weak _bindtextdomain = bindtextdomain
#pragma weak _textdomain = textdomain
@@ -125,7 +126,7 @@ gettext(const char *msg_id)
callout_lock_enter();
INIT_GT((char *)msg_id);
- res = _real_gettext_u(NULL, msg_id, NULL, 0, LC_MESSAGES, 0);
+ res = _real_gettext_u(NULL, msg_id, NULL, 0, LC_MESSAGES, 0, NULL);
callout_lock_exit();
errno = errno_save;
return (res);
@@ -143,7 +144,21 @@ dgettext(const char *domain, const char *msg_id)
callout_lock_enter();
INIT_GT((char *)msg_id);
- res = _real_gettext_u(domain, msg_id, NULL, 0, LC_MESSAGES, 0);
+ res = _real_gettext_u(domain, msg_id, NULL, 0, LC_MESSAGES, 0, NULL);
+ callout_lock_exit();
+ errno = errno_save;
+ return (res);
+}
+
+char *
+dgettext_l(const char *domain, const char *msg_id, locale_t loc)
+{
+ char *res;
+ int errno_save = errno;
+
+ callout_lock_enter();
+ INIT_GT((char *)msg_id);
+ res = _real_gettext_u(domain, msg_id, NULL, 0, LC_MESSAGES, 0, loc);
callout_lock_exit();
errno = errno_save;
return (res);
@@ -157,7 +172,7 @@ dcgettext(const char *domain, const char *msg_id, const int category)
callout_lock_enter();
INIT_GT((char *)msg_id);
- res = _real_gettext_u(domain, msg_id, NULL, 0, category, 0);
+ res = _real_gettext_u(domain, msg_id, NULL, 0, category, 0, NULL);
callout_lock_exit();
errno = errno_save;
return (res);
@@ -171,7 +186,7 @@ ngettext(const char *msgid1, const char *msgid2, unsigned long int n)
callout_lock_enter();
INIT_GT((char *)msgid1);
- res = _real_gettext_u(NULL, msgid1, msgid2, n, LC_MESSAGES, 1);
+ res = _real_gettext_u(NULL, msgid1, msgid2, n, LC_MESSAGES, 1, NULL);
callout_lock_exit();
errno = errno_save;
return (res);
@@ -186,7 +201,7 @@ dngettext(const char *domain, const char *msgid1, const char *msgid2,
callout_lock_enter();
INIT_GT((char *)msgid1);
- res = _real_gettext_u(domain, msgid1, msgid2, n, LC_MESSAGES, 1);
+ res = _real_gettext_u(domain, msgid1, msgid2, n, LC_MESSAGES, 1, NULL);
callout_lock_exit();
errno = errno_save;
return (res);
@@ -201,7 +216,7 @@ dcngettext(const char *domain, const char *msgid1, const char *msgid2,
callout_lock_enter();
INIT_GT((char *)msgid1);
- res = _real_gettext_u(domain, msgid1, msgid2, n, category, 1);
+ res = _real_gettext_u(domain, msgid1, msgid2, n, category, 1, NULL);
callout_lock_exit();
errno = errno_save;
return (res);
diff --git a/usr/src/lib/libc/port/i18n/gettext.h b/usr/src/lib/libc/port/i18n/gettext.h
index bbfdf66ade..ea52bd5c97 100644
--- a/usr/src/lib/libc/port/i18n/gettext.h
+++ b/usr/src/lib/libc/port/i18n/gettext.h
@@ -27,8 +27,6 @@
#ifndef _LIBC_PORT_I18N_GETTEXT_H
#define _LIBC_PORT_I18N_GETTEXT_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/param.h>
#include <iconv.h>
#include <synch.h>
@@ -149,7 +147,7 @@ struct msg_pack {
char *msgfile; /* msg catalog file to open */
char *domain; /* textdomain name */
char *binding; /* binding */
- char *locale; /* locale */
+ const char *locale; /* locale */
char *language; /* LANGUAGE env */
caddr_t addr; /* mmap'ed address */
size_t fsz; /* file size */
@@ -192,7 +190,7 @@ extern Gettext_t *global_gt;
extern char *_textdomain_u(const char *, char *);
extern char *_real_bindtextdomain_u(const char *, const char *, int);
extern char *_real_gettext_u(const char *, const char *,
- const char *, unsigned long int, int, int);
+ const char *, unsigned long int, int, int, locale_t);
extern char *handle_mo(struct msg_pack *);
extern int gnu_setmsg(Msg_node *, char *, size_t);
diff --git a/usr/src/lib/libc/port/i18n/gettext_real.c b/usr/src/lib/libc/port/i18n/gettext_real.c
index ff94e7fd70..6045d000fe 100644
--- a/usr/src/lib/libc/port/i18n/gettext_real.c
+++ b/usr/src/lib/libc/port/i18n/gettext_real.c
@@ -23,8 +23,9 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
#include "lint.h"
#include "mtlib.h"
@@ -55,12 +56,13 @@ static char *replace_nls_option(char *, const char *, char *,
char *
_real_gettext_u(const char *domain, const char *msgid1, const char *msgid2,
- unsigned long int ln, int category, int plural)
+ unsigned long int ln, int category, int plural, locale_t loc)
{
char msgfile[MAXPATHLEN]; /* 1024 */
char mydomain[TEXTDOMAINMAX + 1]; /* 256 + 1 */
char *cur_binding; /* points to current binding in list */
- char *cur_locale, *cur_domain, *result, *nlspath;
+ const char *cur_locale;
+ char *cur_domain, *result, *nlspath;
char *msgloc, *cb, *cur_domain_binding;
char *language;
unsigned int n = (unsigned int)ln; /* we don't need long for n */
@@ -86,7 +88,9 @@ _real_gettext_u(const char *domain, const char *msgid1, const char *msgid2,
* category may be LC_MESSAGES or LC_TIME
* locale contains the value of 'category'
*/
- cur_locale = setlocale(category, NULL);
+ if (loc == NULL)
+ loc = uselocale(NULL);
+ cur_locale = current_locale(loc, category);
language = getenv("LANGUAGE"); /* for GNU */
if (language) {
@@ -142,7 +146,7 @@ _real_gettext_u(const char *domain, const char *msgid1, const char *msgid2,
/* NLSPATH is set */
int ret;
- msgloc = setlocale(LC_MESSAGES, NULL);
+ msgloc = current_locale(loc, LC_MESSAGES);
ret = process_nlspath(cur_domain, msgloc,
(const char *)nlspath, &cur_binding);
diff --git a/usr/src/lib/libc/port/i18n/gettext_util.c b/usr/src/lib/libc/port/i18n/gettext_util.c
index d00c0edb4a..2898773e31 100644
--- a/usr/src/lib/libc/port/i18n/gettext_util.c
+++ b/usr/src/lib/libc/port/i18n/gettext_util.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "mtlib.h"
#include <ctype.h>
@@ -86,7 +84,8 @@ static const int category_name_len[] = {
char *
mk_msgfile(struct msg_pack *mp)
{
- char *p, *q;
+ const char *q;
+ char *p;
const char *catstr;
uint32_t cblen, loclen, catlen, totallen;
diff --git a/usr/src/lib/libc/port/i18n/wdresolve.c b/usr/src/lib/libc/port/i18n/wdresolve.c
index f5d137008d..3e8402de94 100644
--- a/usr/src/lib/libc/port/i18n/wdresolve.c
+++ b/usr/src/lib/libc/port/i18n/wdresolve.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "mtlib.h"
#include <sys/types.h>
@@ -64,13 +62,15 @@ _wdinitialize(void)
char wdmodpath[PATH_MAX];
char *loc;
size_t loclen;
+ locale_t curloc;
initialized = 1;
if (modhandle)
(void) dlclose(modhandle);
- loc = setlocale(LC_CTYPE, NULL); /* this never return NULL */
+ curloc = uselocale(NULL);
+ loc = current_locale(curloc, LC_CTYPE);
loclen = strlen(loc);
if (_DFLTLOCPATH_LEN + loclen + _WDMODPATH_LEN >= sizeof (wdmodpath)) {
/* pathname too long */
diff --git a/usr/src/lib/libc/port/locale/setlocale.c b/usr/src/lib/libc/port/locale/setlocale.c
index e0a56ef8de..18628a3135 100644
--- a/usr/src/lib/libc/port/locale/setlocale.c
+++ b/usr/src/lib/libc/port/locale/setlocale.c
@@ -51,13 +51,13 @@
#include "../i18n/_loc_path.h"
#include "localeimpl.h"
#include "../i18n/_locale.h"
+#include "libc.h"
/*
* Path to locale storage directory. See ../i18n/_loc_path.h
*/
char *_PathLocale = _DFLT_LOC_PATH;
-static char *current_locale(locale_t, int);
static void install_legacy(locale_t, int);
static mutex_t setlocale_lock = DEFAULTMUTEX;
@@ -119,7 +119,7 @@ setlocale(int category, const char *locname)
return (current_locale(loc, category));
}
-static char *
+char *
current_locale(locale_t loc, int cat)
{
switch (cat) {
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index c6967141b6..0b683fc923 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -93,6 +93,11 @@ $if _x86 && _ELF64
$add amd64
$endif
+SYMBOL_VERSION ILLUMOS_0.14 { # strerror_l
+ protected:
+ strerror_l;
+} ILLUMOS_0.13;
+
SYMBOL_VERSION ILLUMOS_0.13 { # eventfd
protected:
eventfd;
diff --git a/usr/src/man/man3c/Makefile b/usr/src/man/man3c/Makefile
index a31d024d15..eeb6267192 100644
--- a/usr/src/man/man3c/Makefile
+++ b/usr/src/man/man3c/Makefile
@@ -1159,6 +1159,7 @@ MANLINKS= FD_CLR.3c \
strcspn.3c \
strdup.3c \
strdupa.3c \
+ strerror_l.3c \
strerror_r.3c \
strfmon_l.3c \
strftime_l.3c \
@@ -2152,6 +2153,7 @@ sig2str.3c := LINKSRC = str2sig.3c
strcoll_l.3c := LINKSRC = strcoll.3c
+strerror_l.3c := LINKSRC = strerror.3c
strerror_r.3c := LINKSRC = strerror.3c
strfmon_l.3c := LINKSRC = strfmon.3c
diff --git a/usr/src/man/man3c/newlocale.3c b/usr/src/man/man3c/newlocale.3c
index 3f0c652d5a..b5102954e5 100644
--- a/usr/src/man/man3c/newlocale.3c
+++ b/usr/src/man/man3c/newlocale.3c
@@ -21,7 +21,7 @@ duplocale, freelocale, newlocale \- create, duplicate, and destroy locale object
.nf
#include <locale.h>
-\fBlocale_t\fR \fBnewlocale\fR(\fBint\fR \fIcategory_mask\fR, \fBconst char *\fR \fIlocale\fR,
+\fBlocale_t\fR \fBnewlocale\fR(\fBint\fR \fIcategory_mask\fR, \fBconst char *\fR\fIlocale\fR,
\fBlocale_t\fR \fIbase\fR);
.fi
.LP
diff --git a/usr/src/man/man3c/strerror.3c b/usr/src/man/man3c/strerror.3c
index d343e9b4b4..1694c42617 100644
--- a/usr/src/man/man3c/strerror.3c
+++ b/usr/src/man/man3c/strerror.3c
@@ -1,4 +1,5 @@
'\" te
+.\" Copyright 2015, Joyent, Inc.
.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
@@ -9,9 +10,9 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH STRERROR 3C "Mar 31, 2005"
+.TH STRERROR 3C "Aug 17, 2015"
.SH NAME
-strerror, strerror_r \- get error message string
+strerror, strerror_r, strerror_l \- get error message string
.SH SYNOPSIS
.LP
.nf
@@ -25,8 +26,11 @@ strerror, strerror_r \- get error message string
\fBint\fR \fBstrerror_r\fR(\fBint\fR \fIerrnum\fR, \fBchar *\fR\fIstrerrbuf\fR, \fBsize_t\fR \fIbuflen\fR);
.fi
+.LP
+.nf
+\fBchar *\fR\fBstrerror_l\fR(\fBint\fR \fIerrnum\fR, \fBlocale_t\fR \fIloc\fR);
+
.SH DESCRIPTION
-.sp
.LP
The \fBstrerror()\fR function maps the error number in \fIerrnum\fR to an error
message string, and returns a pointer to that string. It uses the same set of
@@ -35,23 +39,35 @@ overwritten.
.sp
.LP
The \fBstrerror_r()\fR function maps the error number in \fIerrnum\fR to
-anerror message string and returns the string in the buffer pointed to by
+an error message string and returns the string in the buffer pointed to by
\fIstrerrbuf\fR with length \fIbuflen\fR.
-.SH RETURN VALUES
.sp
.LP
-Upon successful completion, \fBstrerror()\fR returns a pointer to the generated
-message string. Otherwise, it sets \fBerrno\fR and returns a pointer to an
-error message string. It returns the string "Unknown error" if \fIerrnum\fR is
-not a valid error number.
+The \fBstrerror_l()\fR function maps the error number in \fIerrnum\fR to
+an error message string in the locale indicated by \fIloc\fR. The
+returned string should not be overwritten. If \fIloc\fR is passed the
+\fBNULL\fR pointer, then the locale of the calling thread's current locale
+will be used instead.
+.sp
+.LP
+Because the \fBstrerror()\fR and \fBstrerror_l()\fR functions, return localized
+strings in the event of an unknown error, one must use the value of \fBerrno\fR
+to detect an error. Callers should first set \fBerrno\fR to \fB0\fR before the
+call to either function and then check the value of \fBerrno\fR after the call.
+If the value of \fBerrno\fR is non-zero then an error has occurred.
+.SH RETURN VALUES
+.LP
+Upon successful completion, \fBstrerror()\fR and \fBstrerror_l()\fR return a
+pointer to the generated message string. Otherwise, they set \fBerrno\fR and
+returns a pointer to an error message string. They return the localized string
+"Unknown error" if \fIerrnum\fR is not a valid error number.
.sp
.LP
Upon successful completion, \fBstrerror_r()\fR returns 0. Otherwise it sets
\fBerrno\fR and returns the value of \fBerrno\fR to indicate the error. It
-returns the string "Unknown error" in the buffer pointed to by \fIstrerrbuf\fR
-if \fIerrnum\fR is not a valid error number.
+returns the localized string "Unknown error" in the buffer pointed to by
+\fIstrerrbuf\fR if \fIerrnum\fR is not a valid error number.
.SH ERRORS
-.sp
.LP
These functions may fail if:
.sp
@@ -77,12 +93,11 @@ generated message string.
.RE
.SH USAGE
-.sp
.LP
Messages returned from these functions are in the native language specified by
-the \fBLC_MESSAGES\fR locale category. See \fBsetlocale\fR(3C).
+the \fBLC_MESSAGES\fR locale category. See \fBsetlocale\fR(3C) and
+\fBuselocale\fR(3C).
.SH ATTRIBUTES
-.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
@@ -100,7 +115,6 @@ MT-Level Safe
.TE
.SH SEE ALSO
-.sp
.LP
-\fBgettext\fR(3C), \fBperror\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5),
-\fBstandards\fR(5)
+\fBgettext\fR(3C), \fBperror\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
+\fBattributes\fR(5), \fBstandards\fR(5)
diff --git a/usr/src/man/man3lib/libc.3lib b/usr/src/man/man3lib/libc.3lib
index 18d3e9416f..0ed2650dd3 100644
--- a/usr/src/man/man3lib/libc.3lib
+++ b/usr/src/man/man3lib/libc.3lib
@@ -6,7 +6,7 @@
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.\" Copyright 2011 by Delphix. All rights reserved.
-.TH LIBC 3LIB "Jan 14, 2014"
+.TH LIBC 3LIB "Sep 02, 2015"
.SH NAME
libc \- C library
.SH DESCRIPTION
@@ -681,7 +681,7 @@ l l .
\fBstrcmp\fR \fBstrcoll\fR
\fBstrcpy\fR \fBstrcspn\fR
\fBstrdup\fR \fBstrerror\fR
-\fBstrerror_r\fR
+\fBstrerror_l\fR \fBstrerror_r\fR
\fBstrfmon\fR \fBstrfmon_l\fR
\fBstrftime\fR \fBstrftime_l\fR
\fBstring_to_decimal\fR
diff --git a/usr/src/pkg/manifests/system-library.man3c.inc b/usr/src/pkg/manifests/system-library.man3c.inc
index 85b54e1430..3b67d7408b 100644
--- a/usr/src/pkg/manifests/system-library.man3c.inc
+++ b/usr/src/pkg/manifests/system-library.man3c.inc
@@ -1228,6 +1228,7 @@ link path=usr/share/man/man3c/strcpy.3c target=string.3c
link path=usr/share/man/man3c/strcspn.3c target=string.3c
link path=usr/share/man/man3c/strdup.3c target=string.3c
link path=usr/share/man/man3c/strdupa.3c target=string.3c
+link path=usr/share/man/man3c/strerror_l.3c target=strerror.3c
link path=usr/share/man/man3c/strerror_r.3c target=strerror.3c
link path=usr/share/man/man3c/strfmon_l.3c target=strfmon.3c
link path=usr/share/man/man3c/strftime_l.3c target=strftime.3c
diff --git a/usr/src/pkg/manifests/system-test-libctest.mf b/usr/src/pkg/manifests/system-test-libctest.mf
index 7494a6b518..e4e043ceca 100644
--- a/usr/src/pkg/manifests/system-test-libctest.mf
+++ b/usr/src/pkg/manifests/system-test-libctest.mf
@@ -29,6 +29,16 @@ dir path=opt/libc-tests/runfiles
dir path=opt/libc-tests/tests
dir path=opt/libc-tests/tests/random
dir path=opt/libc-tests/tests/symbols
+dir path=usr group=sys
+dir path=usr/lib
+dir path=usr/lib/locale
+dir path=usr/lib/locale/zz_AA.UTF-8
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_COLLATE
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_CTYPE
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_MESSAGES
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_MONETARY
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_NUMERIC
+dir path=usr/lib/locale/zz_AA.UTF-8/LC_TIME
file path=opt/libc-tests/README mode=0444
file path=opt/libc-tests/bin/libctest mode=0555
file path=opt/libc-tests/cfg/README mode=0444
@@ -44,6 +54,7 @@ file path=opt/libc-tests/cfg/symbols/pthread_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/signal_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/stdio_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/stdlib_h.cfg mode=0444
+file path=opt/libc-tests/cfg/symbols/string_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/strings_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/sys_stat_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/sys_time_h.cfg mode=0444
@@ -53,6 +64,7 @@ file path=opt/libc-tests/cfg/symbols/unistd_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/wchar_h.cfg mode=0444
file path=opt/libc-tests/cfg/symbols/wctype_h.cfg mode=0444
file path=opt/libc-tests/runfiles/default.run mode=0444
+file path=opt/libc-tests/tests/catopen mode=0555
file path=opt/libc-tests/tests/fpround_test mode=0555
file path=opt/libc-tests/tests/fpround_test.$(ARCH) mode=0555
file path=opt/libc-tests/tests/fpround_test.$(ARCH64) mode=0555
@@ -62,6 +74,7 @@ file path=opt/libc-tests/tests/newlocale_test.$(ARCH64) mode=0555
file path=opt/libc-tests/tests/nl_langinfo_test mode=0555
file path=opt/libc-tests/tests/nl_langinfo_test.$(ARCH) mode=0555
file path=opt/libc-tests/tests/nl_langinfo_test.$(ARCH64) mode=0555
+file path=opt/libc-tests/tests/priv_gettext mode=0555
file path=opt/libc-tests/tests/random/arc4key.ksh mode=0555
file path=opt/libc-tests/tests/random/arc4random mode=0555
file path=opt/libc-tests/tests/random/arc4random_fork mode=0555
@@ -82,6 +95,7 @@ file path=opt/libc-tests/tests/random/inz_region mode=0555
file path=opt/libc-tests/tests/random/inz_split mode=0555
file path=opt/libc-tests/tests/random/inz_split_vpp mode=0555
file path=opt/libc-tests/tests/random/inz_vpp mode=0555
+file path=opt/libc-tests/tests/strerror mode=0555
file path=opt/libc-tests/tests/symbols/setup mode=0555
file path=opt/libc-tests/tests/symbols/symbols_test.$(ARCH) mode=0555
file path=opt/libc-tests/tests/symbols/symbols_test.$(ARCH64) mode=0555
@@ -91,6 +105,14 @@ file path=opt/libc-tests/tests/wcsrtombs_test.$(ARCH64) mode=0555
file path=opt/libc-tests/tests/wctype_test mode=0555
file path=opt/libc-tests/tests/wctype_test.$(ARCH) mode=0555
file path=opt/libc-tests/tests/wctype_test.$(ARCH64) mode=0555
+file path=usr/lib/locale/zz_AA.UTF-8/LC_COLLATE/LCL_DATA mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_CTYPE/LCL_DATA mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_MESSAGES/LCL_DATA mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_MESSAGES/SUNW_OST_OSLIB.mo mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_MESSAGES/priv_names mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_MONETARY/LCL_DATA mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_NUMERIC/LCL_DATA mode=0444
+file path=usr/lib/locale/zz_AA.UTF-8/LC_TIME/LCL_DATA mode=0444
hardlink path=opt/libc-tests/tests/symbols/ctype_h target=setup
hardlink path=opt/libc-tests/tests/symbols/dirent_h target=setup
hardlink path=opt/libc-tests/tests/symbols/fcntl_h target=setup
@@ -101,6 +123,7 @@ hardlink path=opt/libc-tests/tests/symbols/pthread_h target=setup
hardlink path=opt/libc-tests/tests/symbols/signal_h target=setup
hardlink path=opt/libc-tests/tests/symbols/stdio_h target=setup
hardlink path=opt/libc-tests/tests/symbols/stdlib_h target=setup
+hardlink path=opt/libc-tests/tests/symbols/string_h target=setup
hardlink path=opt/libc-tests/tests/symbols/strings_h target=setup
hardlink path=opt/libc-tests/tests/symbols/sys_stat_h target=setup
hardlink path=opt/libc-tests/tests/symbols/sys_time_h target=setup
diff --git a/usr/src/test/libc-tests/cfg/Makefile b/usr/src/test/libc-tests/cfg/Makefile
index e4c43f3d7c..37b6b53c9f 100644
--- a/usr/src/test/libc-tests/cfg/Makefile
+++ b/usr/src/test/libc-tests/cfg/Makefile
@@ -29,6 +29,7 @@ CFGS = README \
symbols/signal_h.cfg \
symbols/stdio_h.cfg \
symbols/stdlib_h.cfg \
+ symbols/string_h.cfg \
symbols/strings_h.cfg \
symbols/sys_stat_h.cfg \
symbols/sys_time_h.cfg \
diff --git a/usr/src/test/libc-tests/cfg/symbols/string_h.cfg b/usr/src/test/libc-tests/cfg/symbols/string_h.cfg
new file mode 100644
index 0000000000..64506eb9dd
--- /dev/null
+++ b/usr/src/test/libc-tests/cfg/symbols/string_h.cfg
@@ -0,0 +1,33 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Joyent, Inc.
+#
+
+#
+# Definitions found in string.h
+#
+
+#
+# Types.
+#
+type | locale_t | string.h | -ALL +SUSv4+
+
+#
+# Values.
+#
+
+#
+# Functions
+#
+func | strerror_l | char * | int; locale_t | string.h |\
+ -ALL +SUSv4+
diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run
index 50c8f6fa46..1be23194df 100644
--- a/usr/src/test/libc-tests/runfiles/default.run
+++ b/usr/src/test/libc-tests/runfiles/default.run
@@ -51,6 +51,10 @@ outputdir = /var/tmp/test_results
[/opt/libc-tests/tests/random/arc4random_preforksig]
[/opt/libc-tests/tests/random/arc4key.ksh]
+[/opt/libc-tests/tests/catopen]
+[/opt/libc-tests/tests/priv_gettext]
+[/opt/libc-tests/tests/strerror]
+
[/opt/libc-tests/tests/symbols]
pre = setup
tests = [
@@ -64,6 +68,7 @@ tests = [
'signal_h',
'stdio_h',
'stdlib_h',
+ 'string_h',
'strings_h',
'sys_stat_h',
'sys_time_h',
diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile
index f50285b501..3aca9f17c1 100644
--- a/usr/src/test/libc-tests/tests/Makefile
+++ b/usr/src/test/libc-tests/tests/Makefile
@@ -14,7 +14,17 @@
# Copyright 2015 Garrett D'Amore <garrett@damore.org>
#
-SUBDIRS = fpround newlocale nl_langinfo symbols wcsrtombs wctype random
+SUBDIRS = \
+ catopen \
+ fpround \
+ newlocale \
+ nl_langinfo \
+ priv_gettext \
+ random \
+ strerror \
+ symbols \
+ wcsrtombs \
+ wctype
include $(SRC)/Makefile.master
include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/libc-tests/tests/catopen/Makefile b/usr/src/test/libc-tests/tests/catopen/Makefile
new file mode 100644
index 0000000000..30a296fd5a
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/catopen/Makefile
@@ -0,0 +1,51 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/libc-tests
+TESTDIR = $(ROOTOPTPKG)/tests
+
+PROGS = catopen
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROGS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) *.o
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/libc-tests/tests/catopen/catopen.c b/usr/src/test/libc-tests/tests/catopen/catopen.c
new file mode 100644
index 0000000000..3748515c68
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/catopen/catopen.c
@@ -0,0 +1,85 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
+
+#include <string.h>
+#include <locale.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <nl_types.h>
+#include <sys/types.h>
+
+/*
+ * This is designed to check that we properly are honoring the global and
+ * per-thread locale when opening up a message catalog. To do this, we use the
+ * "TEST" message catalog which only exists in the system in the C/POSIX
+ * locales and thus alternate with our test locale zz_AA.UTF-8 which should not
+ * have it.
+ */
+
+#define INVALID_CAT ((nl_catd)-1)
+
+static void
+catopen_verify(boolean_t find)
+{
+ nl_catd cat;
+
+ cat = catopen("TEST", NL_CAT_LOCALE);
+ if (find == B_TRUE) {
+ assert(cat != INVALID_CAT);
+ (void) catclose(cat);
+ } else {
+ assert(cat == INVALID_CAT);
+ }
+}
+
+int
+main(void)
+{
+ locale_t loc;
+
+ (void) setlocale(LC_ALL, "C");
+ catopen_verify(B_TRUE);
+
+ (void) setlocale(LC_ALL, "zz_AA.UTF-8");
+ catopen_verify(B_FALSE);
+
+ (void) setlocale(LC_MESSAGES, "C");
+ catopen_verify(B_TRUE);
+
+ (void) setlocale(LC_ALL, "C");
+ loc = newlocale(LC_MESSAGES_MASK, "zz_AA.UTF-8", NULL);
+ assert(loc != NULL);
+
+ catopen_verify(B_TRUE);
+ (void) uselocale(loc);
+ catopen_verify(B_FALSE);
+
+ (void) uselocale(LC_GLOBAL_LOCALE);
+ catopen_verify(B_TRUE);
+ freelocale(loc);
+
+ (void) setlocale(LC_ALL, "zz_AA.UTF-8");
+ catopen_verify(B_FALSE);
+
+ loc = newlocale(LC_MESSAGES_MASK, "C", NULL);
+ assert(loc != NULL);
+
+ catopen_verify(B_FALSE);
+ (void) uselocale(loc);
+ catopen_verify(B_TRUE);
+
+ return (0);
+}
diff --git a/usr/src/test/libc-tests/tests/priv_gettext/Makefile b/usr/src/test/libc-tests/tests/priv_gettext/Makefile
new file mode 100644
index 0000000000..8f8ee21fea
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/priv_gettext/Makefile
@@ -0,0 +1,51 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/libc-tests
+TESTDIR = $(ROOTOPTPKG)/tests
+
+PROGS = priv_gettext
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROGS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) *.o
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/libc-tests/tests/priv_gettext/priv_gettext.c b/usr/src/test/libc-tests/tests/priv_gettext/priv_gettext.c
new file mode 100644
index 0000000000..4f99a8130d
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/priv_gettext/priv_gettext.c
@@ -0,0 +1,88 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
+
+#include <string.h>
+#include <locale.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <priv.h>
+
+/*
+ * This tests priv_gettext(). The priv_gettext() function always falls back to
+ * the C locale if it can't find anything. To deal with that, we've defined a
+ * dummy translation for the zz_AA.UTF-8 locale which has a translation for the
+ * 'dtrace_kernel' privilege.
+ *
+ * Normally 'dtrace_kernel' has the following description:
+ *
+ * Allows DTrace kernel-level tracing.
+ *
+ * In the zz_AA.UTF-8 locale it has the following description:
+ *
+ * Ah Elbereth Gilthoniel
+ *
+ * We explicitly verify that things respect the global locale and per-thread
+ * locale.
+ */
+
+static const char *def = "Allows DTrace kernel-level tracing.\n";
+static const char *trans = "Ah Elbereth Gilthoniel\n";
+
+static void
+priv_verify(const char *exp)
+{
+ char *res = priv_gettext("dtrace_kernel");
+ assert(res != NULL);
+ assert(strcmp(res, exp) == 0);
+ free(res);
+}
+
+int
+main(void)
+{
+ locale_t loc;
+
+ (void) setlocale(LC_ALL, "C");
+ priv_verify(def);
+
+ (void) setlocale(LC_ALL, "zz_AA.UTF-8");
+ priv_verify(trans);
+
+ (void) setlocale(LC_ALL, "C");
+ loc = newlocale(LC_MESSAGES_MASK, "zz_AA.UTF-8", NULL);
+ assert(loc != NULL);
+ priv_verify(def);
+
+ (void) uselocale(loc);
+ priv_verify(trans);
+
+ (void) uselocale(LC_GLOBAL_LOCALE);
+ priv_verify(def);
+ freelocale(loc);
+
+ (void) setlocale(LC_ALL, "zz_AA.UTF-8");
+ loc = newlocale(LC_MESSAGES_MASK, "C", NULL);
+ assert(loc != NULL);
+ priv_verify(trans);
+
+ (void) uselocale(loc);
+ priv_verify(def);
+
+ (void) uselocale(LC_GLOBAL_LOCALE);
+ priv_verify(trans);
+ freelocale(loc);
+
+ return (0);
+}
diff --git a/usr/src/test/libc-tests/tests/strerror/Makefile b/usr/src/test/libc-tests/tests/strerror/Makefile
new file mode 100644
index 0000000000..fcf3b45ed3
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/strerror/Makefile
@@ -0,0 +1,51 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/libc-tests
+TESTDIR = $(ROOTOPTPKG)/tests
+
+PROGS = strerror
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROGS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) *.o
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/libc-tests/tests/strerror/strerror.c b/usr/src/test/libc-tests/tests/strerror/strerror.c
new file mode 100644
index 0000000000..78dce8e04f
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/strerror/strerror.c
@@ -0,0 +1,100 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Joyent, Inc.
+ */
+
+#include <string.h>
+#include <locale.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+
+/*
+ * This is designed to test strerorr and strerror_l's ability to react properly
+ * to being in various locales. This also serves as a regression test for
+ * illumos#6133.
+ *
+ * For this test, we utilize the poorly named 'zz_AA.UTF_8' locale which
+ * was created because it actually has a translation! It 'translates'
+ * the string:
+ *
+ * "No such file or directory" -> "It's a trap!"
+ *
+ * It's otherwise a boring en_US.UTF-8 locale under the hood.
+ *
+ * We explicitly want to verify the following cases:
+ *
+ * + strerror() honors the global locale before uselocale
+ * + strerror() honors the per-thread locale
+ * + strerror_l() always reflects the chosen locale
+ */
+
+static int err = ENOENT;
+static const char *en = "No such file or directory";
+static const char *trans = "It's a trap!";
+
+static void
+strerror_verify(const char *exp)
+{
+ const char *r;
+ errno = 0;
+ r = strerror(err);
+ assert(errno == 0);
+ assert(strcmp(r, exp) == 0);
+}
+
+static void
+strerror_l_verify(locale_t loc, const char *exp)
+{
+ const char *r;
+ errno = 0;
+ r = strerror_l(err, loc);
+ assert(errno == 0);
+ assert(strcmp(r, exp) == 0);
+}
+
+int
+main(void)
+{
+ locale_t loc;
+
+ (void) setlocale(LC_ALL, "C");
+ strerror_verify(en);
+
+ (void) setlocale(LC_ALL, "zz_AA.UTF-8");
+ strerror_verify(trans);
+
+ (void) setlocale(LC_MESSAGES, "C");
+ strerror_verify(en);
+
+ (void) setlocale(LC_ALL, "C");
+ loc = newlocale(LC_MESSAGES_MASK, "zz_AA.UTF-8", NULL);
+ assert(loc != NULL);
+
+ strerror_verify(en);
+ strerror_l_verify(NULL, en);
+ strerror_l_verify(loc, trans);
+
+ (void) uselocale(loc);
+ strerror_verify(trans);
+ strerror_l_verify(NULL, trans);
+ strerror_l_verify(loc, trans);
+
+ (void) uselocale(LC_GLOBAL_LOCALE);
+ strerror_verify(en);
+ strerror_l_verify(NULL, en);
+ strerror_l_verify(loc, trans);
+
+ freelocale(loc);
+ return (0);
+}
diff --git a/usr/src/test/libc-tests/tests/symbols/Makefile b/usr/src/test/libc-tests/tests/symbols/Makefile
index 9b9ceb0778..39947ee7b5 100644
--- a/usr/src/test/libc-tests/tests/symbols/Makefile
+++ b/usr/src/test/libc-tests/tests/symbols/Makefile
@@ -29,6 +29,7 @@ SYMTESTS = \
signal_h \
stdio_h \
stdlib_h \
+ string_h \
strings_h \
sys_stat_h \
sys_time_h \
diff --git a/usr/src/test/libc-tests/tests/symbols/symbols_test.c b/usr/src/test/libc-tests/tests/symbols/symbols_test.c
index fa96cfe73c..a20000fcd5 100644
--- a/usr/src/test/libc-tests/tests/symbols/symbols_test.c
+++ b/usr/src/test/libc-tests/tests/symbols/symbols_test.c
@@ -770,8 +770,10 @@ find_compiler(void)
break;
case 52: /* GCC */
test_debugf(t, "Found GNU C");
- c89flags = "-Wall -Werror -std=c89 " MFLAG;
- c99flags = "-Wall -Werror -std=c99 " MFLAG;
+ c89flags = "-Wall -Werror -std=c89 -nostdinc "
+ "-isystem /usr/include " MFLAG;
+ c99flags = "-Wall -Werror -std=c99 -nostdinc "
+ "-isystem /usr/include " MFLAG;
if (extra_debug) {
test_debugf(t, "c89flags: %s", c89flags);
test_debugf(t, "c99flags: %s", c99flags);