/* Conversion to and from the various ISO 646 CCS.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The implementation of the conversion which can be performed by this
module are not very sophisticated and not tuned at all. There are
enum variant
{
illegal_var,
- US, /* ANSI_X3.4-1968 */
GB, /* BS_4730 */
CA, /* CSA_Z243.4-1985-1 */
CA2, /* CSA_Z243.4-1985-2 */
static const char *names[] =
{
- [US] = "ANSI_X3.4-1968//",
[GB] = "BS_4730//",
[CA] = "CSA_Z243.4-1985-1//",
[CA2] = "CSA_Z243.4-1985-2//",
};
+extern int gconv_init (struct __gconv_step *step);
int
gconv_init (struct __gconv_step *step)
{
new_data->var = var;
step->__data = new_data;
- if (var == from_iso646)
+ if (dir == from_iso646)
{
step->__min_needed_from = MIN_NEEDED_FROM;
step->__max_needed_from = MIN_NEEDED_FROM;
}
+extern void gconv_end (struct __gconv_step *data);
void
gconv_end (struct __gconv_step *data)
{
when we reach the default case in the `switch' statement. */ \
if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
- if (! ignore_errors_p ()) \
- { \
- /* Exit the loop with an error. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++*irreversible; \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
else \
{ \
#define LOOPFCT TO_LOOP
#define BODY \
{ \
- unsigned char ch; \
+ unsigned int ch; \
int failure = __GCONV_OK; \
\
ch = get32 (inptr); \
- switch (*((uint32_t *) inptr)) \
+ switch (ch) \
{ \
case 0x23: \
if (var == GB || var == ES || var == IT || var == FR || var == FR1 \
ch = 0x5d; \
break; \
default: \
- if (*((uint32_t *) inptr) > 0x7f) \
- failure = __GCONV_ILLEGAL_INPUT; \
+ if (__glibc_unlikely (ch > 0x7f)) \
+ { \
+ UNICODE_TAG_HANDLER (ch, 4); \
+ failure = __GCONV_ILLEGAL_INPUT; \
+ } \
break; \
} \
\
if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
- if (step_data->__trans.__trans_fct != NULL) \
- { \
- result = DL_CALL_FCT (step_data->__trans.__trans_fct, \
- (step, step_data, *inptrp, &inptr, inend, \
- &outptr, irreversible)); \
- if (result != __GCONV_OK) \
- break; \
- } \
- else if (! ignore_errors_p ()) \
- { \
- /* Exit the loop with an error. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- else \
- { \
- ++*irreversible; \
- inptr += 4; \
- } \
- continue; \
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
- else \
- *outptr++ = (unsigned char) ch; \
+ \
+ *outptr++ = (unsigned char) ch; \
inptr += 4; \
}
#define LOOP_NEED_FLAGS