4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1986 AT&T */
28 /* All Rights Reserved */
31 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
34 /* This module is created for NLS on Sep.03.86 */
37 * Ungetwc saves the process code c into the one character buffer
38 * associated with an input stream "iop". That character, c,
39 * will be returned by the next getwc call on that stream.
55 __ungetwc_impl(wint_t wc
, FILE *iop
, int orient
)
64 if (orient
&& GET_NO_MODE(iop
)) {
65 _setorientation(iop
, _WC_MODE
);
67 if ((wc
== WEOF
) || ((iop
->_flag
& _IOREAD
) == 0)) {
72 n
= wctomb(mbs
, (wchar_t)wc
);
78 if (iop
->_ptr
<= iop
->_base
) {
79 if (iop
->_base
== NULL
) {
83 if (iop
->_ptr
== iop
->_base
&& iop
->_cnt
== 0) {
85 } else if ((iop
->_ptr
- n
) < (iop
->_base
- PUSHBACK
)) {
91 p
= (unsigned char *)(mbs
+ n
- 1);
93 *--(iop
)->_ptr
= (*p
--);
96 iop
->_flag
&= ~_IOEOF
;
103 __ungetwc_xpg5(wint_t wc
, FILE *iop
)
105 return (__ungetwc_impl(wc
, iop
, 1));
109 ungetwc(wint_t wc
, FILE *iop
)
111 return (__ungetwc_impl(wc
, iop
, 0));