mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-28 16:21:07 -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>
|
||||
|
||||
* lisp.h (VWindow_system, Qfile_name_history):
|
||||
|
|
|
|||
93
src/coding.c
93
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;
|
||||
int multibytep = coding->src_multibyte;
|
||||
int single_shifting = 0;
|
||||
|
||||
/* 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 id;
|
||||
int c, c1;
|
||||
int consumed_chars = 0;
|
||||
int i;
|
||||
|
|
@ -2999,6 +2994,29 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
|||
break;
|
||||
single_shifting = 0;
|
||||
ONE_MORE_BYTE (c);
|
||||
if (c == 'N' || c == 'O')
|
||||
{
|
||||
/* ESC <Fe> for SS2 or SS3. */
|
||||
single_shifting = 1;
|
||||
rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
|
||||
}
|
||||
else if (c == '1')
|
||||
{
|
||||
/* End of composition. */
|
||||
if (composition_count < 0
|
||||
|| composition_count > MAX_COMPOSITION_COMPONENTS)
|
||||
/* Invalid */
|
||||
break;
|
||||
composition_count = -1;
|
||||
found |= CATEGORY_MASK_ISO;
|
||||
}
|
||||
else if (c >= '0' && c <= '4')
|
||||
{
|
||||
/* ESC <Fp> for start/end composition. */
|
||||
composition_count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c >= '(' && c <= '/')
|
||||
{
|
||||
/* Designation sequence for a charset of dimension 1. */
|
||||
|
|
@ -3027,29 +3045,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
|||
/* Invalid designation sequence. Just ignore it. */
|
||||
break;
|
||||
}
|
||||
else if (c == 'N' || c == 'O')
|
||||
{
|
||||
/* ESC <Fe> for SS2 or SS3. */
|
||||
single_shifting = 1;
|
||||
rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
|
||||
break;
|
||||
}
|
||||
else if (c == '1')
|
||||
{
|
||||
/* End of composition. */
|
||||
if (composition_count < 0
|
||||
|| composition_count > MAX_COMPOSITION_COMPONENTS)
|
||||
/* Invalid */
|
||||
break;
|
||||
composition_count = -1;
|
||||
found |= CATEGORY_MASK_ISO;
|
||||
}
|
||||
else if (c >= '0' && c <= '4')
|
||||
{
|
||||
/* ESC <Fp> for start/end composition. */
|
||||
composition_count = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invalid escape sequence. Just ignore it. */
|
||||
|
|
@ -3078,6 +3073,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
|||
found |= CATEGORY_MASK_ISO_8_ELSE;
|
||||
else
|
||||
rejected |= CATEGORY_MASK_ISO_8_ELSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case ISO_CODE_SO:
|
||||
|
|
@ -3105,13 +3101,32 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
|||
rejected |= CATEGORY_MASK_ISO_7BIT;
|
||||
if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
|
||||
& 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])
|
||||
& 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)
|
||||
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:
|
||||
if (c < 0)
|
||||
|
|
@ -3162,20 +3177,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
|
|||
}
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue