OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [stdlib/] [wcrtomb.c] - Blame information for rev 252

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 "local.h"
8
 
9
size_t
10
_DEFUN (_wcrtomb_r, (ptr, s, wc, ps),
11
        struct _reent *ptr _AND
12
        char *s _AND
13
        wchar_t wc _AND
14
        mbstate_t *ps)
15
{
16
  int retval = 0;
17
  char buf[10];
18
 
19
#ifdef _MB_CAPABLE
20
  if (ps == NULL)
21
    {
22
      _REENT_CHECK_MISC(ptr);
23
      ps = &(_REENT_WCRTOMB_STATE(ptr));
24
    }
25
#endif
26
 
27
  if (s == NULL)
28
    retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps);
29
  else
30
    retval = __wctomb (ptr, s, wc, __locale_charset (), ps);
31
 
32
  if (retval == -1)
33
    {
34
      ps->__count = 0;
35
      ptr->_errno = EILSEQ;
36
      return (size_t)(-1);
37
    }
38
  else
39
    return (size_t)retval;
40
}
41
 
42
#ifndef _REENT_ONLY
43
size_t
44
_DEFUN (wcrtomb, (s, wc, ps),
45
        char *s _AND
46
        wchar_t wc _AND
47
        mbstate_t *ps)
48
{
49
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
50
  return _wcrtomb_r (_REENT, s, wc, ps);
51
#else
52
  int retval = 0;
53
  char buf[10];
54
 
55
#ifdef _MB_CAPABLE
56
  if (ps == NULL)
57
    {
58
      _REENT_CHECK_MISC(_REENT);
59
      ps = &(_REENT_WCRTOMB_STATE(_REENT));
60
    }
61
#endif
62
 
63
  if (s == NULL)
64
    retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps);
65
  else
66
    retval = __wctomb (_REENT, s, wc, __locale_charset (), ps);
67
 
68
  if (retval == -1)
69
    {
70
      ps->__count = 0;
71
      _REENT->_errno = EILSEQ;
72
      return (size_t)(-1);
73
    }
74
  else
75
    return (size_t)retval;
76
#endif /* not PREFER_SIZE_OVER_SPEED */
77
}
78
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

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