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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [iconv/] [ces/] [us-ascii.c] - Blame information for rev 258

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

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * SUCH DAMAGE.
24
 */
25
#include "cesbi.h"
26
 
27
#if defined (ICONV_TO_UCS_CES_US_ASCII) \
28
 || defined (ICONV_FROM_UCS_CES_US_ASCII)
29
 
30
#include <_ansi.h>
31
#include <reent.h>
32
#include <sys/types.h>
33
#include "../lib/local.h"
34
#include "../lib/ucsconv.h"
35
 
36
/*
37
 * For optimization purposes us_ascii is implemented as separate CES converter.
38
 * Another possible way is to add us_ascii CCS and use table-based CES converter.
39
 */
40
 
41
#if defined (ICONV_FROM_UCS_CES_US_ASCII)
42
static size_t
43
_DEFUN(us_ascii_convert_from_ucs, (data, in, outbuf, outbytesleft),
44
                                  _VOID_PTR data         _AND
45
                                  ucs4_t in              _AND
46
                                  unsigned char **outbuf _AND
47
                                  size_t *outbytesleft)
48
{
49
  if (in  > 0x7F)
50
    return (size_t)ICONV_CES_INVALID_CHARACTER;
51
 
52
  *((char *)(*outbuf)) = (char)in;
53
 
54
  *outbuf += 1;
55
  *outbytesleft -= 1;
56
 
57
  return 1;
58
}
59
#endif /* ICONV_FROM_UCS_CES_US_ASCII */
60
 
61
#if defined (ICONV_TO_UCS_CES_US_ASCII)
62
static ucs4_t
63
_DEFUN(us_ascii_convert_to_ucs, (data, inbuf, inbytesleft),
64
                                _VOID_PTR data               _AND
65
                                _CONST unsigned char **inbuf _AND
66
                                size_t *inbytesleft)
67
{
68
  ucs4_t res;
69
 
70
  if (*inbytesleft < 1)
71
    return (ucs4_t)ICONV_CES_BAD_SEQUENCE;
72
 
73
  res = (ucs4_t)**inbuf;
74
 
75
  if (res  > 0x7F)
76
    return (ucs4_t)ICONV_CES_INVALID_CHARACTER;
77
 
78
  *inbytesleft -= 1;
79
  *inbuf += 1;
80
 
81
  return res;
82
}
83
#endif /* ICONV_TO_UCS_CES_US_ASCII */
84
 
85
static int
86
_DEFUN(us_ascii_get_mb_cur_max, (data),
87
                                _VOID_PTR data)
88
{
89
  return 2;
90
}
91
 
92
#if defined (ICONV_TO_UCS_CES_US_ASCII)
93
_CONST iconv_to_ucs_ces_handlers_t
94
_iconv_to_ucs_ces_handlers_us_ascii =
95
{
96
  NULL,
97
  NULL,
98
  us_ascii_get_mb_cur_max,
99
  NULL,
100
  NULL,
101
  NULL,
102
  us_ascii_convert_to_ucs
103
};
104
#endif
105
 
106
#if defined (ICONV_FROM_UCS_CES_US_ASCII)
107
_CONST iconv_from_ucs_ces_handlers_t
108
_iconv_from_ucs_ces_handlers_us_ascii =
109
{
110
  NULL,
111
  NULL,
112
  us_ascii_get_mb_cur_max,
113
  NULL,
114
  NULL,
115
  NULL,
116
  us_ascii_convert_from_ucs
117
};
118
#endif
119
 
120
#endif /* ICONV_TO_UCS_CES_US_ASCII || ICONV_FROM_UCS_CES_US_ASCII */
121
 

powered by: WebSVN 2.1.0

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