mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-27 07:41:28 -08:00
* src/coding.c (detect_coding_iso_2022): Reorganize code to clarify
structure.
This commit is contained in:
parent
0adf561883
commit
0e48bb227a
2 changed files with 85 additions and 79 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-03-15 Andreas Schwab <schwab@linux-m68k.org>
|
||||||
|
|
||||||
|
* coding.c (detect_coding_iso_2022): Reorganize code to clarify
|
||||||
|
structure.
|
||||||
|
|
||||||
2011-03-14 Juanma Barranquero <lekktu@gmail.com>
|
2011-03-14 Juanma Barranquero <lekktu@gmail.com>
|
||||||
|
|
||||||
* lisp.h (VWindow_system, Qfile_name_history):
|
* lisp.h (VWindow_system, Qfile_name_history):
|
||||||
|
|
|
||||||
159
src/coding.c
159
src/coding.c
|
|
@ -2954,12 +2954,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
||||||
const unsigned char *src_end = coding->source + coding->src_bytes;
|
const unsigned char *src_end = coding->source + coding->src_bytes;
|
||||||
int multibytep = coding->src_multibyte;
|
int multibytep = coding->src_multibyte;
|
||||||
int single_shifting = 0;
|
int single_shifting = 0;
|
||||||
|
int id;
|
||||||
/* FIXME: Does ID need to be initialized here? The "End of composition"
|
|
||||||
code below does not initialize ID even though ID is used
|
|
||||||
afterwards, and perhaps that is a bug. */
|
|
||||||
int id = 0;
|
|
||||||
|
|
||||||
int c, c1;
|
int c, c1;
|
||||||
int consumed_chars = 0;
|
int consumed_chars = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -2999,40 +2994,11 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
||||||
break;
|
break;
|
||||||
single_shifting = 0;
|
single_shifting = 0;
|
||||||
ONE_MORE_BYTE (c);
|
ONE_MORE_BYTE (c);
|
||||||
if (c >= '(' && c <= '/')
|
if (c == 'N' || c == 'O')
|
||||||
{
|
|
||||||
/* Designation sequence for a charset of dimension 1. */
|
|
||||||
ONE_MORE_BYTE (c1);
|
|
||||||
if (c1 < ' ' || c1 >= 0x80
|
|
||||||
|| (id = iso_charset_table[0][c >= ','][c1]) < 0)
|
|
||||||
/* Invalid designation sequence. Just ignore. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (c == '$')
|
|
||||||
{
|
|
||||||
/* Designation sequence for a charset of dimension 2. */
|
|
||||||
ONE_MORE_BYTE (c);
|
|
||||||
if (c >= '@' && c <= 'B')
|
|
||||||
/* Designation for JISX0208.1978, GB2312, or JISX0208. */
|
|
||||||
id = iso_charset_table[1][0][c];
|
|
||||||
else if (c >= '(' && c <= '/')
|
|
||||||
{
|
|
||||||
ONE_MORE_BYTE (c1);
|
|
||||||
if (c1 < ' ' || c1 >= 0x80
|
|
||||||
|| (id = iso_charset_table[1][c >= ','][c1]) < 0)
|
|
||||||
/* Invalid designation sequence. Just ignore. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Invalid designation sequence. Just ignore it. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (c == 'N' || c == 'O')
|
|
||||||
{
|
{
|
||||||
/* ESC <Fe> for SS2 or SS3. */
|
/* ESC <Fe> for SS2 or SS3. */
|
||||||
single_shifting = 1;
|
single_shifting = 1;
|
||||||
rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
|
rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (c == '1')
|
else if (c == '1')
|
||||||
{
|
{
|
||||||
|
|
@ -3048,36 +3014,66 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
||||||
{
|
{
|
||||||
/* ESC <Fp> for start/end composition. */
|
/* ESC <Fp> for start/end composition. */
|
||||||
composition_count = 0;
|
composition_count = 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Invalid escape sequence. Just ignore it. */
|
if (c >= '(' && c <= '/')
|
||||||
break;
|
{
|
||||||
}
|
/* Designation sequence for a charset of dimension 1. */
|
||||||
|
ONE_MORE_BYTE (c1);
|
||||||
|
if (c1 < ' ' || c1 >= 0x80
|
||||||
|
|| (id = iso_charset_table[0][c >= ','][c1]) < 0)
|
||||||
|
/* Invalid designation sequence. Just ignore. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (c == '$')
|
||||||
|
{
|
||||||
|
/* Designation sequence for a charset of dimension 2. */
|
||||||
|
ONE_MORE_BYTE (c);
|
||||||
|
if (c >= '@' && c <= 'B')
|
||||||
|
/* Designation for JISX0208.1978, GB2312, or JISX0208. */
|
||||||
|
id = iso_charset_table[1][0][c];
|
||||||
|
else if (c >= '(' && c <= '/')
|
||||||
|
{
|
||||||
|
ONE_MORE_BYTE (c1);
|
||||||
|
if (c1 < ' ' || c1 >= 0x80
|
||||||
|
|| (id = iso_charset_table[1][c >= ','][c1]) < 0)
|
||||||
|
/* Invalid designation sequence. Just ignore. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Invalid designation sequence. Just ignore it. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Invalid escape sequence. Just ignore it. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* We found a valid designation sequence for CHARSET. */
|
/* We found a valid designation sequence for CHARSET. */
|
||||||
rejected |= CATEGORY_MASK_ISO_8BIT;
|
rejected |= CATEGORY_MASK_ISO_8BIT;
|
||||||
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
|
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
|
||||||
id))
|
id))
|
||||||
found |= CATEGORY_MASK_ISO_7;
|
found |= CATEGORY_MASK_ISO_7;
|
||||||
else
|
else
|
||||||
rejected |= CATEGORY_MASK_ISO_7;
|
rejected |= CATEGORY_MASK_ISO_7;
|
||||||
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight],
|
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight],
|
||||||
id))
|
id))
|
||||||
found |= CATEGORY_MASK_ISO_7_TIGHT;
|
found |= CATEGORY_MASK_ISO_7_TIGHT;
|
||||||
else
|
else
|
||||||
rejected |= CATEGORY_MASK_ISO_7_TIGHT;
|
rejected |= CATEGORY_MASK_ISO_7_TIGHT;
|
||||||
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else],
|
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else],
|
||||||
id))
|
id))
|
||||||
found |= CATEGORY_MASK_ISO_7_ELSE;
|
found |= CATEGORY_MASK_ISO_7_ELSE;
|
||||||
else
|
else
|
||||||
rejected |= CATEGORY_MASK_ISO_7_ELSE;
|
rejected |= CATEGORY_MASK_ISO_7_ELSE;
|
||||||
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else],
|
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else],
|
||||||
id))
|
id))
|
||||||
found |= CATEGORY_MASK_ISO_8_ELSE;
|
found |= CATEGORY_MASK_ISO_8_ELSE;
|
||||||
else
|
else
|
||||||
rejected |= CATEGORY_MASK_ISO_8_ELSE;
|
rejected |= CATEGORY_MASK_ISO_8_ELSE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ISO_CODE_SO:
|
case ISO_CODE_SO:
|
||||||
|
|
@ -3105,13 +3101,32 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
||||||
rejected |= CATEGORY_MASK_ISO_7BIT;
|
rejected |= CATEGORY_MASK_ISO_7BIT;
|
||||||
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
|
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
|
||||||
& CODING_ISO_FLAG_SINGLE_SHIFT)
|
& CODING_ISO_FLAG_SINGLE_SHIFT)
|
||||||
found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1;
|
{
|
||||||
|
found |= CATEGORY_MASK_ISO_8_1;
|
||||||
|
single_shifting = 1;
|
||||||
|
}
|
||||||
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2])
|
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2])
|
||||||
& CODING_ISO_FLAG_SINGLE_SHIFT)
|
& CODING_ISO_FLAG_SINGLE_SHIFT)
|
||||||
found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1;
|
{
|
||||||
|
found |= CATEGORY_MASK_ISO_8_2;
|
||||||
|
single_shifting = 1;
|
||||||
|
}
|
||||||
if (single_shifting)
|
if (single_shifting)
|
||||||
break;
|
break;
|
||||||
goto check_extra_latin;
|
check_extra_latin:
|
||||||
|
if (! VECTORP (Vlatin_extra_code_table)
|
||||||
|
|| NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
|
||||||
|
{
|
||||||
|
rejected = CATEGORY_MASK_ISO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
|
||||||
|
& CODING_ISO_FLAG_LATIN_EXTRA)
|
||||||
|
found |= CATEGORY_MASK_ISO_8_1;
|
||||||
|
else
|
||||||
|
rejected |= CATEGORY_MASK_ISO_8_1;
|
||||||
|
rejected |= CATEGORY_MASK_ISO_8_2;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
|
|
@ -3162,20 +3177,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
check_extra_latin:
|
|
||||||
single_shifting = 0;
|
|
||||||
if (! VECTORP (Vlatin_extra_code_table)
|
|
||||||
|| NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
|
|
||||||
{
|
|
||||||
rejected = CATEGORY_MASK_ISO;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
|
|
||||||
& CODING_ISO_FLAG_LATIN_EXTRA)
|
|
||||||
found |= CATEGORY_MASK_ISO_8_1;
|
|
||||||
else
|
|
||||||
rejected |= CATEGORY_MASK_ISO_8_1;
|
|
||||||
rejected |= CATEGORY_MASK_ISO_8_2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
detect_info->rejected |= CATEGORY_MASK_ISO;
|
detect_info->rejected |= CATEGORY_MASK_ISO;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue