* coding.c (Fdefine_coding_system_internal): Don't redeclare 'i' inside

a block, when the outer 'i' will do.
(decode_coding_utf_8, decode_coding_utf_16, detect_coding_emacs_mule):
(emacs_mule_char, decode_coding_emacs_mule, detect_coding_iso_2022):
(decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5):
(decode_coding_raw_text, decode_coding_charset, get_translation_table):
(Fdecode_sjis_char, Fdefine_coding_system_internal):
Rename locals to avoid shadowing.
* character.h (FETCH_STRING_CHAR_ADVANCE): Likewise.
This commit is contained in:
Paul Eggert 2011-03-07 20:37:19 -08:00
parent f38b440c4b
commit 2735d0606b
3 changed files with 63 additions and 55 deletions

View file

@ -1320,7 +1320,7 @@ decode_coding_utf_8 (struct coding_system *coding)
int multibytep = coding->src_multibyte;
enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
Lisp_Object attr, charset_list;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
@ -1381,7 +1381,7 @@ decode_coding_utf_8 (struct coding_system *coding)
}
else if (UTF_8_1_OCTET_P (c1))
{
if (eol_crlf && c1 == '\r')
if (eol_dos && c1 == '\r')
ONE_MORE_BYTE (byte_after_cr);
c = c1;
}
@ -1639,7 +1639,7 @@ decode_coding_utf_16 (struct coding_system *coding)
enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
int surrogate = CODING_UTF_16_SURROGATE (coding);
Lisp_Object attr, charset_list;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr1 = -1, byte_after_cr2 = -1;
@ -1736,7 +1736,7 @@ decode_coding_utf_16 (struct coding_system *coding)
CODING_UTF_16_SURROGATE (coding) = surrogate = c;
else
{
if (eol_crlf && c == '\r')
if (eol_dos && c == '\r')
{
ONE_MORE_BYTE (byte_after_cr1);
ONE_MORE_BYTE (byte_after_cr2);
@ -1920,17 +1920,17 @@ detect_coding_emacs_mule (struct coding_system *coding,
it because analyzing it is too heavy for detecting. But,
at least, we check that the composite character
constitutes of more than 4 bytes. */
const unsigned char *src_base;
const unsigned char *src_start;
repeat:
src_base = src;
src_start = src;
do
{
ONE_MORE_BYTE (c);
}
while (c >= 0xA0);
if (src - src_base <= 4)
if (src - src_start <= 4)
break;
found = CATEGORY_MASK_EMACS_MULE;
if (c == 0x80)
@ -1990,7 +1990,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
const unsigned char *src_end = coding->source + coding->src_bytes;
const unsigned char *src_base = src;
int multibytep = coding->src_multibyte;
int charset_id;
int charset_ID;
unsigned code;
int c;
int consumed_chars = 0;
@ -2000,7 +2000,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
if (c < 0)
{
c = -c;
charset_id = emacs_mule_charset[0];
charset_ID = emacs_mule_charset[0];
}
else
{
@ -2036,7 +2036,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
switch (emacs_mule_bytes[c])
{
case 2:
if ((charset_id = emacs_mule_charset[c]) < 0)
if ((charset_ID = emacs_mule_charset[c]) < 0)
goto invalid_code;
ONE_MORE_BYTE (c);
if (c < 0xA0)
@ -2049,7 +2049,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
|| c == EMACS_MULE_LEADING_CODE_PRIVATE_12)
{
ONE_MORE_BYTE (c);
if (c < 0xA0 || (charset_id = emacs_mule_charset[c]) < 0)
if (c < 0xA0 || (charset_ID = emacs_mule_charset[c]) < 0)
goto invalid_code;
ONE_MORE_BYTE (c);
if (c < 0xA0)
@ -2058,7 +2058,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
}
else
{
if ((charset_id = emacs_mule_charset[c]) < 0)
if ((charset_ID = emacs_mule_charset[c]) < 0)
goto invalid_code;
ONE_MORE_BYTE (c);
if (c < 0xA0)
@ -2073,7 +2073,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
case 4:
ONE_MORE_BYTE (c);
if (c < 0 || (charset_id = emacs_mule_charset[c]) < 0)
if (c < 0 || (charset_ID = emacs_mule_charset[c]) < 0)
goto invalid_code;
ONE_MORE_BYTE (c);
if (c < 0xA0)
@ -2087,21 +2087,21 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
case 1:
code = c;
charset_id = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit;
charset_ID = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit;
break;
default:
abort ();
}
CODING_DECODE_CHAR (coding, src, src_base, src_end,
CHARSET_FROM_ID (charset_id), code, c);
CHARSET_FROM_ID (charset_ID), code, c);
if (c < 0)
goto invalid_code;
}
*nbytes = src - src_base;
*nchars = consumed_chars;
if (id)
*id = charset_id;
*id = charset_ID;
return (mseq_found ? -c : c);
no_more_source:
@ -2374,7 +2374,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
@ -2424,7 +2424,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
if (c < 0x80)
{
if (eol_crlf && c == '\r')
if (eol_dos && c == '\r')
ONE_MORE_BYTE (byte_after_cr);
id = charset_ascii;
if (cmp_status->state != COMPOSING_NO)
@ -3160,7 +3160,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
if (! single_shifting
&& ! (rejected & CATEGORY_MASK_ISO_8_2))
{
int i = 1;
int len = 1;
while (src < src_end)
{
src_base = src;
@ -3170,20 +3170,20 @@ detect_coding_iso_2022 (struct coding_system *coding,
src = src_base;
break;
}
i++;
len++;
}
if (i & 1 && src < src_end)
if (len & 1 && src < src_end)
{
rejected |= CATEGORY_MASK_ISO_8_2;
if (composition_count >= 0)
composition_count += i;
composition_count += len;
}
else
{
found |= CATEGORY_MASK_ISO_8_2;
if (composition_count >= 0)
composition_count += i / 2;
composition_count += len / 2;
}
}
break;
@ -3311,10 +3311,10 @@ detect_coding_iso_2022 (struct coding_system *coding,
} \
else /* new format (after ver.21) */ \
{ \
int c; \
int b; \
\
ONE_MORE_BYTE (c); \
rule = COMPOSITION_ENCODE_RULE (rule - 81, c - 32); \
ONE_MORE_BYTE (b); \
rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \
if (rule >= 0) \
rule += 0x100; /* to destinguish it from the old format */ \
nbytes = 2; \
@ -3506,7 +3506,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
int i;
@ -3626,7 +3626,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
break;
case ISO_control_0:
if (eol_crlf && c1 == '\r')
if (eol_dos && c1 == '\r')
ONE_MORE_BYTE (byte_after_cr);
MAYBE_FINISH_COMPOSITION ();
charset = CHARSET_FROM_ID (charset_ascii);
@ -4031,7 +4031,6 @@ decode_coding_iso_2022 (struct coding_system *coding)
const char *intermediate_char_94 = "()*+"; \
const char *intermediate_char_96 = ",-./"; \
int revision = -1; \
int c; \
\
if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION) \
revision = CHARSET_ISO_REVISION (charset); \
@ -4044,11 +4043,12 @@ decode_coding_iso_2022 (struct coding_system *coding)
EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC); \
if (CHARSET_DIMENSION (charset) == 1) \
{ \
int b; \
if (! CHARSET_ISO_CHARS_96 (charset)) \
c = intermediate_char_94[reg]; \
b = intermediate_char_94[reg]; \
else \
c = intermediate_char_96[reg]; \
EMIT_ONE_ASCII_BYTE (c); \
b = intermediate_char_96[reg]; \
EMIT_ONE_ASCII_BYTE (b); \
} \
else \
{ \
@ -4709,7 +4709,7 @@ decode_coding_sjis (struct coding_system *coding)
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
@ -4744,7 +4744,7 @@ decode_coding_sjis (struct coding_system *coding)
goto invalid_code;
if (c < 0x80)
{
if (eol_crlf && c == '\r')
if (eol_dos && c == '\r')
ONE_MORE_BYTE (byte_after_cr);
charset = charset_roman;
}
@ -4826,7 +4826,7 @@ decode_coding_big5 (struct coding_system *coding)
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
@ -4859,7 +4859,7 @@ decode_coding_big5 (struct coding_system *coding)
goto invalid_code;
if (c < 0x80)
{
if (eol_crlf && c == '\r')
if (eol_dos && c == '\r')
ONE_MORE_BYTE (byte_after_cr);
charset = charset_roman;
}
@ -5263,13 +5263,13 @@ encode_coding_ccl (struct coding_system *coding)
static void
decode_coding_raw_text (struct coding_system *coding)
{
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
coding->chars_at_source = 1;
coding->consumed_char = coding->src_chars;
coding->consumed = coding->src_bytes;
if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r')
if (eol_dos && coding->source[coding->src_bytes - 1] == '\r')
{
coding->consumed_char--;
coding->consumed--;
@ -5482,7 +5482,7 @@ decode_coding_charset (struct coding_system *coding)
int char_offset = coding->produced_char;
int last_offset = char_offset;
int last_id = charset_ascii;
int eol_crlf =
int eol_dos =
!inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
int byte_after_cr = -1;
@ -5516,7 +5516,7 @@ decode_coding_charset (struct coding_system *coding)
else
{
ONE_MORE_BYTE (c);
if (eol_crlf && c == '\r')
if (eol_dos && c == '\r')
ONE_MORE_BYTE (byte_after_cr);
}
if (c < 0)
@ -6609,15 +6609,15 @@ get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup)
}
else if (CONSP (translation_table))
{
Lisp_Object tail, val;
Lisp_Object tail;
for (tail = translation_table; CONSP (tail); tail = XCDR (tail))
if (CHAR_TABLE_P (XCAR (tail))
&& CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1)
{
val = XCHAR_TABLE (XCAR (tail))->extras[1];
if (NATNUMP (val) && *max_lookup < XFASTINT (val))
*max_lookup = XFASTINT (val);
Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1];
if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval))
*max_lookup = XFASTINT (tailval);
}
}
}
@ -9114,10 +9114,10 @@ Return the corresponding character. */)
}
else
{
int s1 = c >> 8, s2 = c & 0xFF;
int c1 = c >> 8, c2 = c & 0xFF;
if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF
|| s2 < 0x40 || s2 == 0x7F || s2 > 0xFC)
if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
|| c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
error ("Invalid code: %d", code);
SJIS_TO_JIS (c);
charset = charset_kanji;
@ -9800,7 +9800,6 @@ usage: (define-coding-system-internal ...) */)
else if (EQ (coding_type, Qiso_2022))
{
Lisp_Object initial, reg_usage, request, flags;
int i;
if (nargs < coding_arg_iso2022_max)
goto short_args;
@ -9832,12 +9831,12 @@ usage: (define-coding-system-internal ...) */)
for (tail = request; ! NILP (tail); tail = Fcdr (tail))
{
int id;
Lisp_Object tmp;
Lisp_Object tmp1;
val = Fcar (tail);
CHECK_CONS (val);
tmp = XCAR (val);
CHECK_CHARSET_GET_ID (tmp, id);
tmp1 = XCAR (val);
CHECK_CHARSET_GET_ID (tmp1, id);
CHECK_NATNUM_CDR (val);
if (XINT (XCDR (val)) >= 4)
error ("Invalid graphic register number: %d", XINT (XCDR (val)));