Back to index

glibc  2.9
fgetws_u_chk.c File Reference
#include "libioP.h"
#include <wchar.h>
#include <sys/param.h>

Go to the source code of this file.


wchar_t * __fgetws_unlocked_chk (wchar_t *buf, size_t size, int n, _IO_FILE *fp)

Function Documentation

wchar_t* __fgetws_unlocked_chk ( wchar_t *  buf,
size_t  size,
int  n,
_IO_FILE fp 

Definition at line 33 of file fgetws_u_chk.c.

  _IO_size_t count;
  wchar_t *result;
  int old_error;
  if (n <= 0)
    return NULL;
  /* This is very tricky since a file descriptor may be in the
     non-blocking mode. The error flag doesn't mean much in this
     case. We return an error only when there is a new error. */
  old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
  fp->_IO_file_flags &= ~_IO_ERR_SEEN;
  count = _IO_getwline (fp, buf, MIN ((size_t) n - 1, size), L'\n', 1);
  /* If we read in some bytes and errno is EAGAIN, that error will
     be reported for next read. */
  if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN)
                   && errno != EAGAIN))
    result = NULL;
  else if (count >= size)
    __chk_fail ();
      buf[count] = '\0';
      result = buf;
  fp->_IO_file_flags |= old_error;
  return result;

Here is the call graph for this function: