Skip to content

Commit

Permalink
* iconvdata/sjis.c (BODY): Don't advance inptr before
Browse files Browse the repository at this point in the history
	STANDARD_FROM_LOOP_ERR_HANDLER (2) for 2 byte invalid input.
	Use STANDARD_FROM_LOOP_ERR_HANDLER with 2 instead of 1 for
	two byte chars.
  • Loading branch information
Ulrich Drepper committed Apr 24, 2009
1 parent 705341a commit f397be1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2009-04-24 Jakub Jelinek <jakub@redhat.com>

* iconvdata/sjis.c (BODY): Don't advance inptr before
STANDARD_FROM_LOOP_ERR_HANDLER (2) for 2 byte invalid input.
Use STANDARD_FROM_LOOP_ERR_HANDLER with 2 instead of 1 for
two byte chars.

2009-04-24 Ulrich Drepper <drepper@redhat.com>

* locale/locarchive.h (struct locarhandle): Rename len field to
Expand Down
28 changes: 16 additions & 12 deletions iconvdata/sjis.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Mapping tables for SJIS handling.
Copyright (C) 1997-2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1997-2001, 2002, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand Down Expand Up @@ -4372,15 +4372,19 @@ static const char from_ucs4_extra[0x100][2] =
\
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
if (__builtin_expect (ch2 < 0x40, 0) \
|| (__builtin_expect (idx > 0x84be, 0) && idx < 0x889f) \
|| (__builtin_expect (idx > 0x88fc, 0) && idx < 0x8940) \
|| (__builtin_expect (idx > 0x9ffc, 0) && idx < 0xe040) \
|| __builtin_expect (idx > 0xeaa4, 0)) \
if (__builtin_expect (ch2 < 0x40, 0)) \
{ \
/* This is illegal. */ \
STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
else if ((__builtin_expect (idx > 0x84be && idx < 0x889f, 0)) \
|| (__builtin_expect (idx > 0x88fc && idx < 0x8940, 0)) \
|| (__builtin_expect (idx > 0x9ffc && idx < 0xe040, 0)) \
|| __builtin_expect (idx > 0xeaa4, 0)) \
{ \
/* This is illegal. */ \
STANDARD_FROM_LOOP_ERR_HANDLER (2); \
} \
else \
{ \
/* We could pack the data a bit more dense. The second \
Expand All @@ -4395,13 +4399,13 @@ static const char from_ucs4_extra[0x100][2] =
else \
ch = cjk_block4[(ch - 0xe0) * 192 + ch2 - 0x40]; \
\
inptr += 2; \
} \
if (__builtin_expect (ch == 0, 0)) \
{ \
/* This is an illegal character. */ \
STANDARD_FROM_LOOP_ERR_HANDLER (2); \
} \
\
if (__builtin_expect (ch == 0, 0)) \
{ \
/* This is an illegal character. */ \
STANDARD_FROM_LOOP_ERR_HANDLER (2); \
inptr += 2; \
} \
} \
\
Expand Down

0 comments on commit f397be1

Please sign in to comment.