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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [wctomb.c] - Blame information for rev 862

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<wctomb>>---minimal wide char to multibyte converter
4
 
5
INDEX
6
        wctomb
7
 
8
ANSI_SYNOPSIS
9
        #include <stdlib.h>
10
        int wctomb(char *<[s]>, wchar_t <[wchar]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <stdlib.h>
14
        int wctomb(<[s]>, <[wchar]>)
15
        char *<[s]>;
16
        wchar_t <[wchar]>;
17
 
18
DESCRIPTION
19
When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
20
implementation of <<wctomb>>.  The
21
only ``wide characters'' recognized are single bytes,
22
and they are ``converted'' to themselves.
23
 
24
When _MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform
25
the conversion, passing a state variable to allow state dependent
26
decoding.  The result is based on the locale setting which may
27
be restricted to a defined set of locales.
28
 
29
Each call to <<wctomb>> modifies <<*<[s]>>> unless <[s]> is a null
30
pointer or _MB_CAPABLE is defined and <[wchar]> is invalid.
31
 
32
RETURNS
33
This implementation of <<wctomb>> returns <<0>> if
34
<[s]> is <<NULL>>; it returns <<-1>> if _MB_CAPABLE is enabled
35
and the wchar is not a valid multi-byte character, it returns <<1>>
36
if _MB_CAPABLE is not defined or the wchar is in reality a single
37
byte character, otherwise it returns the number of bytes in the
38
multi-byte character.
39
 
40
PORTABILITY
41
<<wctomb>> is required in the ANSI C standard.  However, the precise
42
effects vary with the locale.
43
 
44
<<wctomb>> requires no supporting OS subroutines.
45
*/
46
 
47
#ifndef _REENT_ONLY
48
 
49
#include <newlib.h>
50
#include <stdlib.h>
51
 
52
int
53
_DEFUN (wctomb, (s, wchar),
54
        char *s _AND
55
        wchar_t wchar)
56
{
57
#ifdef _MB_CAPABLE
58
        _REENT_CHECK_MISC(_REENT);
59
 
60
        return _wctomb_r (_REENT, s, wchar, &(_REENT_WCTOMB_STATE(_REENT)));
61
#else /* not _MB_CAPABLE */
62
        if (s == NULL)
63
                return 0;
64
 
65
        *s = (char) wchar;
66
        return 1;
67
#endif /* not _MB_CAPABLE */
68
}
69
 
70
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

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