1998-04-26 18:44  Ulrich Drepper  <drepper@cygnus.com>

	* iconvdata/Makefile: Correct rules to generate gap table.
	* iconvdata/gap.pl: Simplify.
This commit is contained in:
Ulrich Drepper 1998-04-26 18:47:24 +00:00
parent 8babd571bf
commit 2fb2e75ae0
5 changed files with 56 additions and 40 deletions

View File

@ -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.

View File

@ -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 $@

View File

@ -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);

View File

@ -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;

View File

@ -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) \
if (ch <= 0x7f) \
{ \
result = GCONV_FULL_OUTPUT; \
break; \
} \
/* We must encode using ASCII. First write out the \
escape sequence. */ \
*outptr++ = SO; \
set = ASCII_set; \
\
*outptr++ = ch; \
} \
else \
{ \
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) \
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; \
} \
} \
} \
} \