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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [stdlib/] [mbrtowc.c] - Blame information for rev 862

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

Line No. Rev Author Line
1 207 jeremybenn
#include <reent.h>
2
#include <newlib.h>
3
#include <wchar.h>
4
#include <stdlib.h>
5
#include <stdio.h>
6
#include <errno.h>
7
#include <string.h>
8
#include "local.h"
9
 
10
size_t
11
_DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps),
12
        struct _reent *ptr _AND
13
        wchar_t *pwc _AND
14
        const char *s _AND
15
        size_t n _AND
16
        mbstate_t *ps)
17
{
18
  int retval = 0;
19
 
20
#ifdef _MB_CAPABLE
21
  if (ps == NULL)
22
    {
23
      _REENT_CHECK_MISC(ptr);
24
      ps = &(_REENT_MBRTOWC_STATE(ptr));
25
    }
26
#endif
27
 
28
  if (s == NULL)
29
    retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps);
30
  else
31
    retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps);
32
 
33
  if (retval == -1)
34
    {
35
      ps->__count = 0;
36
      ptr->_errno = EILSEQ;
37
      return (size_t)(-1);
38
    }
39
  else
40
    return (size_t)retval;
41
}
42
 
43
#ifndef _REENT_ONLY
44
size_t
45
_DEFUN (mbrtowc, (pwc, s, n, ps),
46
        wchar_t *pwc _AND
47
        const char *s _AND
48
        size_t n _AND
49
        mbstate_t *ps)
50
{
51
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
52
  return _mbrtowc_r (_REENT, pwc, s, n, ps);
53
#else
54
  int retval = 0;
55
 
56
#ifdef _MB_CAPABLE
57
  if (ps == NULL)
58
    {
59
      _REENT_CHECK_MISC(_REENT);
60
      ps = &(_REENT_MBRTOWC_STATE(_REENT));
61
    }
62
#endif
63
 
64
  if (s == NULL)
65
    retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps);
66
  else
67
    retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
68
 
69
  if (retval == -1)
70
    {
71
      ps->__count = 0;
72
      _REENT->_errno = EILSEQ;
73
      return (size_t)(-1);
74
    }
75
  else
76
    return (size_t)retval;
77
#endif /* not PREFER_SIZE_OVER_SPEED */
78
}
79
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

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