/* Copyright (C) 1993,1995,1997-2002,2004,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper <drepper@cygnus.com>.
Based on the single byte version by Per Bothner <bothner@cygnus.com>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link the code in this file with
files compiled with a GNU compiler to produce an executable,
that does not cause the resulting executable to be covered by
the GNU Lesser General Public License. This exception does not
however invalidate any other reasons why the executable file
might be covered by the GNU Lesser General Public License.
This exception applies to code released by its copyright holders
in files containing the exception. */
/* Generic or default I/O operations. */
#include "libioP.h"
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <string.h>
#include <wchar.h>
#ifndef _LIBC
# define __wmemcpy(dst, src, n) wmemcpy (dst, src, n)
#endif
static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW
#ifdef _LIBC
internal_function
#endif
;
/* Return minimum _pos markers
Assumes the current get area is the main get area. */
_IO_ssize_t _IO_least_wmarker (_IO_FILE *fp, wchar_t *end_p) __THROW;
_IO_ssize_t
_IO_least_wmarker (fp, end_p)
_IO_FILE *fp;
wchar_t *end_p;
{
_IO_ssize_t least_so_far = end_p - fp->_wide_data->_IO_read_base;
struct _IO_marker *mark;
for (mark = fp->_markers; mark != NULL; mark = mark->_next)
if (mark->_pos < least_so_far)
least_so_far = mark->_pos;
return least_so_far;
}
INTDEF(_IO_least_wmarker)
/* Switch current get area from backup buffer to (start of) main get area. */
void
_IO_switch_to_main_wget_area (fp)
_IO_FILE *fp;
{
wchar_t *tmp;
fp->_flags &= ~_IO_IN_BACKUP;
/* Swap _IO_read_end and _IO_save_end. */
tmp = fp->_wide_data->_IO_read_end;
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_save_end;
fp->_wide_data->_IO_save_end= tmp;
/* Swap _IO_read_base and _IO_save_base. */
tmp = fp->_wide_data->_IO_read_base;
fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_save_base;
fp->_wide_data->_IO_save_base = tmp;
/* Set _IO_read_ptr. */
fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
}
INTDEF(_IO_switch_to_main_wget_area)
/* Switch current get area from main get area to (end of) backup area. */
void
_IO_switch_to_wbackup_area (fp)
_IO_FILE *fp;
{
wchar_t *tmp;
fp->_flags |= _IO_IN_BACKUP;
/* Swap _IO_read_end and _IO_save_end. */
tmp = fp->_wide_data->