OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [mbstowcs_r.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
#include <stdlib.h>
2
#include <wchar.h>
3
 
4
size_t
5
_DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
6
        struct _reent *r    _AND
7
        wchar_t       *pwcs _AND
8
        const char    *s    _AND
9
        size_t         n    _AND
10
        mbstate_t     *state)
11
{
12
  wchar_t *ptr = pwcs;
13
  size_t max = n;
14
  char *t = (char *)s;
15
  int bytes;
16
 
17
  while (n > 0)
18
    {
19
      bytes = _mbtowc_r (r, ptr, t, MB_CUR_MAX, state);
20
      if (bytes < 0)
21
        {
22
          state->__count = 0;
23
          return -1;
24
        }
25
      else if (bytes == 0)
26
        return ptr - pwcs;
27
      t += bytes;
28
      ++ptr;
29
      --n;
30
    }
31
 
32
  return max;
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.