diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | iconvdata/Makefile | 12 | ||||
-rw-r--r-- | iconvdata/gap.pl | 6 | ||||
-rw-r--r-- | iconvdata/iso-2022-jp.c | 2 | ||||
-rw-r--r-- | iconvdata/iso-2022-kr.c | 71 |
5 files changed, 56 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog index 8d1fead57b..7c34f02b54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1998-04-26 18:44 Ulrich Drepper <drepper@cygnus.com> + + * iconvdata/Makefile: Correct rules to generate gap table. + * iconvdata/gap.pl: Simplify. + 1998-04-26 Ulrich Drepper <drepper@cygnus.com> * iconvdata/Makefile: Add rules for ISO-2022-KR. diff --git a/iconvdata/Makefile b/iconvdata/Makefile index 276ae886ed..2b44ec190f 100644 --- a/iconvdata/Makefile +++ b/iconvdata/Makefile @@ -250,12 +250,12 @@ $(make-target-directory) ( echo "static const uint32_t to_ucs4[256] = {"; \ sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\(..\)[[:space:]]*<U\(....\)>.*/ [0x\1] = 0x\2,/p' -e d $^ | sort -u; \ echo "};"; \ - echo "static struct gap from_idx[] = {"; \ - sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\(..\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gap.pl; \ + echo "static const struct gap from_idx[] = {"; \ + sed -e 's/^[^[:space:]]*[[:space:]]*.x\(..\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gap.pl; \ echo " { start: 0xffff, end: 0xffff, idx: 0 }"; \ echo "};"; \ echo "static const char from_ucs4[] = {"; \ - sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\(..\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gaptab.pl; \ + sed -e 's/^[^[:space:]]*[[:space:]]*.x\(..\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gaptab.pl; \ echo "};" ) > $@.new && rm -f $@ && mv $@.new $@ endef @@ -358,12 +358,12 @@ $(objpfx)iso8859-7jp.h: ../localedata/charmaps/ISO-8859-7 Makefile ( echo "static const uint32_t iso88597_to_ucs4[96] = {"; \ sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\([A-F].\)[[:space:]]*<U\(....\)>.*/ [0x\1 - 0xA0] = 0x\2,/p' -e d $^ | sort -u; \ echo "};"; \ - echo "static struct gap from_idx[] = {"; \ - sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\([A-F].\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gap.pl; \ + echo "static const struct gap from_idx[] = {"; \ + sed -e 's/^[^[:space:]]*[[:space:]]*.x\([A-F].\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gap.pl; \ echo " { start: 0xffff, end: 0xffff, idx: 0 }"; \ echo "};"; \ echo "static const char iso88597_from_ucs4[] = {"; \ - sed -e '/^[^[:space:]]*[[:space:]]*.x00/d' -e 's/^[^[:space:]]*[[:space:]]*.x\([A-F].\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gaptab.pl; \ + sed -e 's/^[^[:space:]]*[[:space:]]*.x\([A-F].\)[[:space:]]*<U\(....\)>.*/0x\2 0x\1/p' -e d $^ | sort -u | $(PERL) gaptab.pl; \ echo "};" ) > $@.new && rm -f $@ && mv $@.new $@ diff --git a/iconvdata/gap.pl b/iconvdata/gap.pl index 8d595e327d..2a06adc36c 100644 --- a/iconvdata/gap.pl +++ b/iconvdata/gap.pl @@ -5,12 +5,12 @@ while (<>) { if ($u - $last > 6) { if ($last != 0) { printf (" { start: 0x%04x, end: 0x%04x, idx: %5d },\n", - $first, $last, $idx - $first); - $idx += $last - $first + 1; + $first, $last, $idx); + $idx -= $u - $last - 1; } $first=$u; } $last=$u; } printf (" { start: 0x%04x, end: 0x%04x, idx: %5d },\n", - $first, $last, $idx - $first); + $first, $last, $idx); diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c index 9ca648c3c2..2c0f701dfb 100644 --- a/iconvdata/iso-2022-jp.c +++ b/iconvdata/iso-2022-jp.c @@ -54,7 +54,7 @@ struct gap #define PREPARE_LOOP \ enum direction dir = ((struct iso2022jp_data *) step->data)->dir; \ enum variant var = ((struct iso2022jp_data *) step->data)->var; \ - int save_state; \ + int save_set; \ int set = data->statep->count; #define END_LOOP \ data->statep->count = set; diff --git a/iconvdata/iso-2022-kr.c b/iconvdata/iso-2022-kr.c index 16e656a5d3..69a1f5f89f 100644 --- a/iconvdata/iso-2022-kr.c +++ b/iconvdata/iso-2022-kr.c @@ -23,11 +23,17 @@ #include <string.h> #include "ksc5601.h" +#include <assert.h> + /* This makes obvious what everybody knows: 0x1b is the Esc character. */ +#define ESC 0x1b + +/* The shift sequences for this charset (we it does not use ESC). */ #define SI 0x0f #define SO 0x0e /* Definitions used in the body of the `gconv' function. */ +#define CHARSET_NAME "ISO-2022-KR//" #define DEFINE_INIT 1 #define DEFINE_FINI 1 #define FROM_LOOP from_iso2022kr_loop @@ -37,8 +43,10 @@ #define MIN_NEEDED_TO 4 #define MAX_NEEDED_TO 4 #define PREPARE_LOOP \ - int save_set; + int save_set; \ int set = data->statep->count; +#define EXTRA_LOOP_ARGS , set + /* The COUNT element of the state keeps track of the currently selected character set. The possible values are: */ @@ -58,7 +66,7 @@ enum if (step->data == &from_object) \ /* It's easy, we don't have to emit anything, we just reset the \ state for the input. */ \ - set = 0; \ + data->statep->count = 0; \ else \ { \ char *outbuf = data->outbuf; \ @@ -73,7 +81,7 @@ enum /* Write out the shift sequence. */ \ *outbuf++ = SO; \ data->outbuf = outbuf; \ - set = 0; \ + data->statep->count = 0; \ } \ } \ } @@ -221,43 +229,46 @@ enum later and now simply use a fixed order in which we test for \ availability */ \ \ - if (ch <= 0x7f) \ - { \ - /* We must encode using ASCII. First write out the \ - escape sequence. */ \ - *outptr++ = SO; \ - set = ASCII_set; \ - \ - if (NEED_LENGTH_TEST && outptr == outend) \ - { \ - result = GCONV_FULL_OUTPUT; \ - break; \ - } \ - \ - *outptr++ = ch; \ - } \ - else \ - { \ - written = ucs4_to_ksc5601 (ch, buf, 2); \ - if (written != UNKNOWN_10646_CHAR) \ + if (ch <= 0x7f) \ { \ - /* We use KSC 5601. */ \ - *outptr++ = SI; \ - set = KSC5601_set; \ + /* We must encode using ASCII. First write out the \ + escape sequence. */ \ + *outptr++ = SO; \ + set = ASCII_set; \ \ - if (NEED_LENGTH_TEST && outptr + 2 > outend) \ + if (NEED_LENGTH_TEST && outptr == outend) \ { \ result = GCONV_FULL_OUTPUT; \ break; \ } \ \ - *outptr++ = buf[0]; \ - *outptr++ = buf[1]; \ + *outptr++ = ch; \ } \ else \ { \ - result = GCONV_ILLEGAL_INPUT; \ - break; \ + char buf[2]; \ + \ + written = ucs4_to_ksc5601 (ch, buf, 2); \ + if (written != UNKNOWN_10646_CHAR) \ + { \ + /* We use KSC 5601. */ \ + *outptr++ = SI; \ + set = KSC5601_set; \ + \ + if (NEED_LENGTH_TEST && outptr + 2 > outend) \ + { \ + result = GCONV_FULL_OUTPUT; \ + break; \ + } \ + \ + *outptr++ = buf[0]; \ + *outptr++ = buf[1]; \ + } \ + else \ + { \ + result = GCONV_ILLEGAL_INPUT; \ + break; \ + } \ } \ } \ } \ |