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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [mbstowcs_r.c] - Blame information for rev 1774

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

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

powered by: WebSVN 2.1.0

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