Commit 10298658 authored by Simon Middleton's avatar Simon Middleton
Browse files

Fixed iso2202_write_escapes() (as used by JIS encoding) so that it actually works.

It also now assumes that the first write encoding is already set up.

Version 0.10. Tagged as 'Unicode-0_10'
parent e487a05f
/* (0.09) /* (0.10)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 0.09 #define Module_MajorVersion_CMHG 0.10
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 10 Dec 1997 #define Module_Date_CMHG 18 Dec 1997
#define Module_MajorVersion "0.09" #define Module_MajorVersion "0.10"
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "10 Dec 1997" #define Module_Date "18 Dec 1997"
...@@ -90,17 +90,20 @@ static EncList enclist[] = ...@@ -90,17 +90,20 @@ static EncList enclist[] =
{ csEUCKR /* 38 */, 0, "/EUC-KR/", lang_KOREAN, (EncodingPriv *)ENC_iso2022_euc, { csEUCKR /* 38 */, 0, "/EUC-KR/", lang_KOREAN, (EncodingPriv *)ENC_iso2022_euc,
"\x1B\x24\x29\x43" }, /* Select G1 = KS C 5601 */ "\x1B\x24\x29\x43" }, /* Select G1 = KS C 5601 */
{ csISO2022JP /* 39 */, 0, "/ISO-2022-JP/JIS_Encoding/", lang_JAPANESE, (EncodingPriv *)ENC_iso2022_escapes, NULL, { csISO2022JP /* 39 */, 0, "/ISO-2022-JP/JIS_Encoding/", lang_JAPANESE, (EncodingPriv *)ENC_iso2022_escapes, NULL,
"\x1B\x28\x42" /* "\x1B\x28\x42" ASCII */
"\x1B\x28\x4A" "\x1B\x28\x4A" /* JIS roman */
"\x1B\x24\x40" "\x1B\x24\x40" /* JIS C 1978 */
"\x1B\x24\x42" }, "\x1B\x24\x42" /* JIS X 1983 */
},
{ csISO2022JP2 /* 40 */, 0, "/ISO-2022-JP-2/", lang_JAPANESE, (EncodingPriv *)ENC_iso2022_escapes, NULL, { csISO2022JP2 /* 40 */, 0, "/ISO-2022-JP-2/", lang_JAPANESE, (EncodingPriv *)ENC_iso2022_escapes, NULL,
"\x1B\x28\x42" /* "\x1B\x28\x42" ASCII */
"\x1B\x28\x4A" "\x1B\x28\x4A"
"\x1B\x24\x40" "\x1B\x24\x40"
"\x1B\x24\x42" "\x1B\x24\x42"
"\x1B\x24\x28\x43" /* "\x1B\x24\x42" GB 2312-80 */
"\x1B\x24\x28\x44" }, /* "\x1B\x24\x28\x43" KS C 1992 */
"\x1B\x24\x28\x44" /* JIS X 1990 */
},
{ csISO2022CN /* 104 */, 0, "/ISO-2022-CN/", lang_CHINESE, (EncodingPriv *)ENC_iso2022 }, { csISO2022CN /* 104 */, 0, "/ISO-2022-CN/", lang_CHINESE, (EncodingPriv *)ENC_iso2022 },
{ csISO2022CN_EXT /* 105 */, 0, "/ISO-2022-CN-EXT/", lang_CHINESE, (EncodingPriv *)ENC_iso2022 }, { csISO2022CN_EXT /* 105 */, 0, "/ISO-2022-CN-EXT/", lang_CHINESE, (EncodingPriv *)ENC_iso2022 },
{ csUTF8 /* 106 */, 6, "/UTF-8/UNICODE-1-1-UTF-8/UNICODE-2-0-UTF-8/", lang_ANY, (EncodingPriv *)ENC_utf8 }, /* More general!!! */ { csUTF8 /* 106 */, 6, "/UTF-8/UNICODE-1-1-UTF-8/UNICODE-2-0-UTF-8/", lang_ANY, (EncodingPriv *)ENC_utf8 }, /* More general!!! */
......
...@@ -338,19 +338,25 @@ static int iso2022_reset(Encoding *e, int for_encoding) ...@@ -338,19 +338,25 @@ static int iso2022_reset(Encoding *e, int for_encoding)
if (s) if (s)
{ {
int tab = 0; int tab = 0;
const char *last_s = s; const char *last_s = NULL;
/* process the table specifying string, they will all place into G0 */ /* process the table specifying string, they will all place into G0 */
while (tab < MAX_TABLES) while (tab < MAX_TABLES)
{ {
int c = *s++; int c = *s;
if (c == 0 || c == 0x1B) if (c == 0 || c == 0x1B)
{
if (last_s)
{ {
i->table[tab].table = ((simple_set *)i->Set[G0])->table; i->table[tab].table = ((simple_set *)i->Set[G0])->table;
i->table[tab].esc_seq = last_s; i->table[tab].esc_seq = last_s;
i->table[tab].esc_seq_len = s - last_s; i->table[tab].esc_seq_len = s - last_s;
fdebugf(stderr, "iso2022_reset: loaded write table %d table %p esc_seq_len %d\n", tab, i->table[tab].table, i->table[tab].esc_seq_len);
tab++; tab++;
}
last_s = s; last_s = s;
} }
...@@ -361,6 +367,8 @@ static int iso2022_reset(Encoding *e, int for_encoding) ...@@ -361,6 +367,8 @@ static int iso2022_reset(Encoding *e, int for_encoding)
iso2022_esc(i); iso2022_esc(i);
else else
iso2022_esc_cont(i, c); iso2022_esc_cont(i, c);
s++;
} }
/* free the set used in G0 */ /* free the set used in G0 */
...@@ -368,7 +376,7 @@ static int iso2022_reset(Encoding *e, int for_encoding) ...@@ -368,7 +376,7 @@ static int iso2022_reset(Encoding *e, int for_encoding)
i->Set[G0] = 0; i->Set[G0] = 0;
} }
i->current_table = -1; i->current_table = 0; /* assume the first table is set initially */
} }
return 1; return 1;
...@@ -560,8 +568,9 @@ static unsigned int iso2022_read(EncodingPriv *e, ...@@ -560,8 +568,9 @@ static unsigned int iso2022_read(EncodingPriv *e,
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
static int write_index(int index, char *out, int table_size) static int write_index(int index, char *out, int table_size, int sevenbit)
{ {
int base = sevenbit ? 0x20 : 0xA0;
switch (table_size) switch (table_size)
{ {
case 32: case 32:
...@@ -570,11 +579,11 @@ static int write_index(int index, char *out, int table_size) ...@@ -570,11 +579,11 @@ static int write_index(int index, char *out, int table_size)
return 1; return 1;
case 94: case 94:
*out++ = 0xA1 + index; *out++ = base + 1 + index;
return 1; return 1;
case 96: case 96:
*out++ = 0xA0 + index; *out++ = base + index;
return 1; return 1;
case 94*94: case 94*94:
...@@ -582,8 +591,8 @@ static int write_index(int index, char *out, int table_size) ...@@ -582,8 +591,8 @@ static int write_index(int index, char *out, int table_size)
int c1 = index / 94; int c1 = index / 94;
int c2 = index % 94; int c2 = index % 94;
out[0] = 0xA1 + c1; out[0] = base + 1 + c1;
out[1] = 0xA1 + c2; out[1] = base + 1 + c2;
return 2; return 2;
} }
...@@ -628,21 +637,21 @@ static int iso2022_write_escapes(EncodingPriv *e, UCS4 u, char **ps, int *bufsiz ...@@ -628,21 +637,21 @@ static int iso2022_write_escapes(EncodingPriv *e, UCS4 u, char **ps, int *bufsiz
/* main chars */ /* main chars */
else if (iso2022_scan_tables(enc, u, &index, &tab, &n_entries)) else if (iso2022_scan_tables(enc, u, &index, &tab, &n_entries))
{ {
#if 0 /* fdebugf(stderr, "iso2022_write_escapes: u %04x index %d table %d n_entries %d\n", u, index, tab, n_entries); */
fprintf(stderr, "iso2022_write_escapes: u %04x index %d table %d n_entries %d\n", u, index, tab, n_entries);
#endif
if (enc->current_table != tab) if (enc->current_table != tab)
{ {
ISO2022_EncoderSet *eset = &enc->table[tab]; ISO2022_EncoderSet *eset = &enc->table[tab];
/* fdebugf(stderr, "iso2022_write_escapes: switch set\n"); */
memcpy(buf + out, eset->esc_seq, eset->esc_seq_len); memcpy(buf + out, eset->esc_seq, eset->esc_seq_len);
out += eset->esc_seq_len; out += eset->esc_seq_len;
enc->current_table = tab; enc->current_table = tab;
} }
out += write_index(index, buf + out, n_entries); out += write_index(index, buf + out, n_entries, 1);
} }
/* special chars */ /* special chars */
...@@ -748,17 +757,17 @@ static int iso2022_write_euc(EncodingPriv *e, UCS4 u, char **euc, int *bufsize) ...@@ -748,17 +757,17 @@ static int iso2022_write_euc(EncodingPriv *e, UCS4 u, char **euc, int *bufsize)
break; break;
case G1: case G1:
out += write_index(index, buf+out, n_entries); out += write_index(index, buf+out, n_entries, 0);
break; break;
case G2: case G2:
buf[out++] = SS2; buf[out++] = SS2;
out += write_index(index, buf+out, n_entries); out += write_index(index, buf+out, n_entries, 0);
break; break;
case G3: case G3:
buf[out++] = SS3; buf[out++] = SS3;
out += write_index(index, buf+out, n_entries); out += write_index(index, buf+out, n_entries, 0);
break; break;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment