summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc/port/stdio')
-rw-r--r--usr/src/lib/libc/port/stdio/data.c7
-rw-r--r--usr/src/lib/libc/port/stdio/mse.c149
-rw-r--r--usr/src/lib/libc/port/stdio/vwscanf.c14
3 files changed, 13 insertions, 157 deletions
diff --git a/usr/src/lib/libc/port/stdio/data.c b/usr/src/lib/libc/port/stdio/data.c
index 42293e2a75..b38494f3a5 100644
--- a/usr/src/lib/libc/port/stdio/data.c
+++ b/usr/src/lib/libc/port/stdio/data.c
@@ -27,7 +27,10 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
#pragma weak __iob = _iob
@@ -53,7 +56,7 @@ Uchar _smbuf[_NFILE + 1][_SMBFSZ] = {0}; /* shared library compatibility */
#define DEFAULTMBSTATE \
- { NULL, NULL, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0}}
+ { 0 }
#ifdef _LP64
diff --git a/usr/src/lib/libc/port/stdio/mse.c b/usr/src/lib/libc/port/stdio/mse.c
index 4d5ee6874a..2b50dfbc69 100644
--- a/usr/src/lib/libc/port/stdio/mse.c
+++ b/usr/src/lib/libc/port/stdio/mse.c
@@ -24,7 +24,10 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
#include "lint.h"
#include "mtlib.h"
@@ -43,21 +46,6 @@
/*
* DESCRIPTION:
- * This function sets the error indicator for the specified stream.
- * This is a private API for the L10N method functions, especially
- * for fgetwc().
- *
- * The stream needs to have been properly locked. Usually, the wrapper
- * function of fgetwc() locks the stream.
- */
-void
-__fseterror_u(FILE *iop)
-{
- iop->_flag |= _IOERR;
-}
-
-/*
- * DESCRIPTION:
* This function/macro gets the orientation bound to the specified iop.
*
* RETURNS:
@@ -104,132 +92,3 @@ _setorientation(FILE *iop, _IOP_orientation_t mode)
break;
}
}
-
-static mbstate_t **__top_mbstates = NULL;
-static mutex_t __top_mbstates_lock = DEFAULTMUTEX;
-
-void
-_clear_internal_mbstate(void)
-{
- int i;
-
- lmutex_lock(&__top_mbstates_lock);
- if (__top_mbstates) {
- for (i = 0; i <= _MAX_MB_FUNC; i++) {
- if (*(__top_mbstates + i)) {
- lfree(*(__top_mbstates + i),
- sizeof (mbstate_t));
- }
- }
- lfree(__top_mbstates,
- (_MAX_MB_FUNC + 1) * sizeof (mbstate_t *));
- __top_mbstates = NULL;
- }
- lmutex_unlock(&__top_mbstates_lock);
-}
-
-mbstate_t *
-_get_internal_mbstate(int item)
-{
- if (item < 0 || item > _MAX_MB_FUNC)
- return (NULL);
-
- lmutex_lock(&__top_mbstates_lock);
- if (__top_mbstates == NULL) {
- __top_mbstates =
- lmalloc((_MAX_MB_FUNC + 1) * sizeof (mbstate_t *));
- if (__top_mbstates == NULL) {
- lmutex_unlock(&__top_mbstates_lock);
- return (NULL);
- }
- *(__top_mbstates + item) = lmalloc(sizeof (mbstate_t));
- if (*(__top_mbstates + item) == NULL) {
- lmutex_unlock(&__top_mbstates_lock);
- return (NULL);
- }
- lmutex_unlock(&__top_mbstates_lock);
- return (*(__top_mbstates + item));
- }
- if (*(__top_mbstates + item) == NULL) {
- *(__top_mbstates + item) = lmalloc(sizeof (mbstate_t));
- if (*(__top_mbstates + item) == NULL) {
- lmutex_unlock(&__top_mbstates_lock);
- return (NULL);
- }
- }
- lmutex_unlock(&__top_mbstates_lock);
- return (*(__top_mbstates + item));
-}
-
-/*
- * From page 32 of XSH5
- * Once a wide-character I/O function has been applied
- * to a stream without orientation, the stream becomes
- * wide-orientated. Similarly, once a byte I/O function
- * has been applied to a stream without orientation,
- * the stream becomes byte-orientated. Only a call to
- * the freopen() function or the fwide() function can
- * otherwise alter the orientation of a stream.
- */
-
-/*
- * void
- * _set_orientation_byte(FILE *iop)
- *
- * Note: this is now implemented as macro __SET_ORIENTATION_BYTE()
- * (in libc/inc/mse.h) for performance improvement.
- */
-
-/* Returns the value of 'ps->__nconsumed' */
-char
-__mbst_get_nconsumed(const mbstate_t *ps)
-{
- return (ps->__nconsumed);
-}
-
-/* Sets 'n' to 'ps->__nconsumed' */
-void
-__mbst_set_nconsumed(mbstate_t *ps, char n)
-{
- ps->__nconsumed = n;
-}
-
-/* Copies 'len' bytes from '&ps->__consumed[index]' to 'str' */
-int
-__mbst_get_consumed_array(const mbstate_t *ps, char *str,
- size_t index, size_t len)
-{
- if ((index + len) > 8) {
- /* The max size of __consumed[] is 8 */
- return (-1);
- }
- (void) memcpy((void *)str, (const void *)&ps->__consumed[index], len);
- return (0);
-}
-
-/* Copies 'len' bytes from 'str' to '&ps->__consumed[index]' */
-int
-__mbst_set_consumed_array(mbstate_t *ps, const char *str,
- size_t index, size_t len)
-{
- if ((index + len) > 8) {
- /* The max size of __consumed[] is 8 */
- return (-1);
- }
- (void) memcpy((void *)&ps->__consumed[index], (const void *)str, len);
- return (0);
-}
-
-/* Returns 'ps->__lc_locale' */
-void *
-__mbst_get_locale(const mbstate_t *ps)
-{
- return (ps->__lc_locale);
-}
-
-/* Sets 'loc' to 'ps->__lc_locale' */
-void
-__mbst_set_locale(mbstate_t *ps, const void *loc)
-{
- ps->__lc_locale = (void *)loc;
-}
diff --git a/usr/src/lib/libc/port/stdio/vwscanf.c b/usr/src/lib/libc/port/stdio/vwscanf.c
index 7448e6ffad..76cfabf4ae 100644
--- a/usr/src/lib/libc/port/stdio/vwscanf.c
+++ b/usr/src/lib/libc/port/stdio/vwscanf.c
@@ -54,11 +54,8 @@ vwscanf(const wchar_t *fmt, va_list ap)
FLOCKFILE(lk, stdin);
- if (_set_orientation_wide(stdin, NULL, NULL, 0) == -1) {
- errno = EBADF;
- FUNLOCKFILE(lk);
- return (EOF);
- }
+ if (GET_NO_MODE(stdin))
+ _setorientation(stdin, _WC_MODE);
#ifdef _C89_INTMAX32
ret = __wdoscan_u(stdin, fmt, ap, _F_INTMAX32);
@@ -81,11 +78,8 @@ vfwscanf(FILE *iop, const wchar_t *fmt, va_list ap)
FLOCKFILE(lk, iop);
- if (_set_orientation_wide(iop, NULL, NULL, 0) == -1) {
- errno = EBADF;
- FUNLOCKFILE(lk);
- return (EOF);
- }
+ if (GET_NO_MODE(iop))
+ _setorientation(iop, _WC_MODE);
#ifdef _C89_INTMAX32