xref: /dragonfly/lib/libc/stdio/ungetwc.3 (revision cfd1aba3)
1.\"	$NetBSD: ungetwc.3,v 1.3 2002/02/07 07:00:27 ross Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Chris Torek and the American National Standards Committee X3,
8.\" on Information Processing Systems.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)ungetc.3	8.1 (Berkeley) 6/4/93
35.\" $FreeBSD: head/lib/libc/stdio/ungetwc.3 165903 2007-01-09 00:28:16Z imp $
36.\"
37.Dd December 26, 2013
38.Dt UNGETWC 3
39.Os
40.Sh NAME
41.Nm ungetwc ,
42.Nm ungetwc_l
43.Nd un-get wide character from input stream
44.Sh LIBRARY
45.Lb libc
46.Sh SYNOPSIS
47.In stdio.h
48.In wchar.h
49.Ft wint_t
50.Fn ungetwc "wint_t wc" "FILE *stream"
51.In xlocale.h
52.Ft wint_t
53.Fn ungetwc_l "wint_t wc" "FILE *stream" "locale_t locale"
54.Sh DESCRIPTION
55The
56.Fn ungetwc
57and
58.Fn ungetwc_l
59functions push the wide character
60.Fa wc
61(converted to an
62.Vt wchar_t )
63back onto the input stream pointed to by
64.Fa stream .
65The pushed-backed wide characters will be returned by subsequent reads on the
66stream (in reverse order).
67A successful intervening call, using the same stream, to one of the file
68positioning functions
69.Xr fseek 3 ,
70.Xr fsetpos 3 ,
71or
72.Xr rewind 3
73will discard the pushed back wide characters.
74.Pp
75One wide character of push-back is guaranteed,
76but as long as there is
77sufficient memory, an effectively infinite amount of pushback is allowed.
78.Pp
79If a character is successfully pushed-back,
80the end-of-file indicator for the stream is cleared.
81.Pp
82The
83.Fn ungetwc_l
84function takes an explicit
85.Fa locale
86argument, whereas the
87.Fn ungetwc
88function uses the current global or per-thread locale.
89.Sh RETURN VALUES
90The
91.Fn ungetwc
92and
93.Fn ungetwc_l
94functions return the wide character pushed-back after the conversion, or
95.Dv WEOF
96if the operation fails.
97If the value of the argument
98.Fa c
99character equals
100.Dv WEOF ,
101the operation will fail and the stream will remain unchanged.
102.Sh SEE ALSO
103.Xr fseek 3 ,
104.Xr getwc 3 ,
105.Xr xlocale 3
106.Sh STANDARDS
107The
108.Fn ungetwc
109function conforms to
110.St -isoC-99 .
111