summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-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
14 files changed, 84 insertions, 49 deletions
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;