diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-05 22:19:39 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-05 22:19:39 -0700 |
| commit | 41cf7d1aec986e1b92ca14231ac4ec242c233d45 (patch) | |
| tree | 7360e455dc2e0043a31fda1d29cc6323aa213104 /src/coding.c | |
| parent | 1e3cdd8228651f226beb6ac75453968a6c64feff (diff) | |
| parent | b69769da408705e40929b793d79d3bfe6a3a5a48 (diff) | |
| download | emacs-41cf7d1aec986e1b92ca14231ac4ec242c233d45.tar.gz | |
Fix more problems found by GCC 4.6.0's static checks.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/src/coding.c b/src/coding.c index 9e28a1c9f9b..555c29cbdf3 100644 --- a/src/coding.c +++ b/src/coding.c @@ -753,7 +753,7 @@ static struct coding_system coding_categories[coding_category_max]; produced_chars++; \ if (multibytep) \ { \ - int ch = (c); \ + unsigned ch = (c); \ if (ch >= 0x80) \ ch = BYTE8_TO_CHAR (ch); \ CHAR_STRING_ADVANCE (ch, dst); \ @@ -770,7 +770,7 @@ static struct coding_system coding_categories[coding_category_max]; produced_chars += 2; \ if (multibytep) \ { \ - int ch; \ + unsigned ch; \ \ ch = (c1); \ if (ch >= 0x80) \ @@ -1296,13 +1296,10 @@ decode_coding_utf_8 (struct coding_system *coding) int consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); - Lisp_Object attr, charset_list; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; - CODING_GET_INFO (coding, attr, charset_list); - if (bom != utf_without_bom) { int c1, c2, c3; @@ -1610,13 +1607,10 @@ decode_coding_utf_16 (struct coding_system *coding) enum utf_bom_type bom = CODING_UTF_16_BOM (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_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr1 = -1, byte_after_cr2 = -1; - CODING_GET_INFO (coding, attr, charset_list); - if (bom == utf_with_bom) { int c, c1, c2; @@ -1736,11 +1730,8 @@ encode_coding_utf_16 (struct coding_system *coding) enum utf_bom_type bom = CODING_UTF_16_BOM (coding); int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; int produced_chars = 0; - Lisp_Object attrs, charset_list; int c; - CODING_GET_INFO (coding, attrs, charset_list); - if (bom != utf_without_bom) { ASSURE_DESTINATION (safe_room); @@ -2342,7 +2333,6 @@ decode_coding_emacs_mule (struct coding_system *coding) = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); int consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - Lisp_Object attrs, charset_list; int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -2351,8 +2341,6 @@ decode_coding_emacs_mule (struct coding_system *coding) int byte_after_cr = -1; struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; - CODING_GET_INFO (coding, attrs, charset_list); - if (cmp_status->state != COMPOSING_NO) { int i; @@ -3265,15 +3253,14 @@ detect_coding_iso_2022 (struct coding_system *coding, */ /* Decode a composition rule C1 and maybe one more byte from the - source, and set RULE to the encoded composition rule, NBYTES to the - length of the composition rule. If the rule is invalid, set RULE - to some negative value. */ + source, and set RULE to the encoded composition rule. If the rule + is invalid, goto invalid_code. */ -#define DECODE_COMPOSITION_RULE(rule, nbytes) \ +#define DECODE_COMPOSITION_RULE(rule) \ do { \ rule = c1 - 32; \ if (rule < 0) \ - break; \ + goto invalid_code; \ if (rule < 81) /* old format (before ver.21) */ \ { \ int gref = (rule) / 9; \ @@ -3281,17 +3268,16 @@ detect_coding_iso_2022 (struct coding_system *coding, if (gref == 4) gref = 10; \ if (nref == 4) nref = 10; \ rule = COMPOSITION_ENCODE_RULE (gref, nref); \ - nbytes = 1; \ } \ else /* new format (after ver.21) */ \ { \ int b; \ \ ONE_MORE_BYTE (b); \ + if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \ + goto invalid_code; \ rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ - if (rule >= 0) \ - rule += 0x100; /* to destinguish it from the old format */ \ - nbytes = 2; \ + rule += 0x100; /* Distinguish it from the old format. */ \ } \ } while (0) @@ -3476,7 +3462,7 @@ decode_coding_iso_2022 (struct coding_system *coding) struct charset *charset; int c; struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); - Lisp_Object attrs, charset_list; + Lisp_Object attrs = CODING_ID_ATTRS (coding->id); int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -3485,10 +3471,7 @@ decode_coding_iso_2022 (struct coding_system *coding) int byte_after_cr = -1; int i; - CODING_GET_INFO (coding, attrs, charset_list); setup_iso_safe_charsets (attrs); - /* Charset list may have been changed. */ - charset_list = CODING_ATTR_CHARSET_LIST (attrs); coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); if (cmp_status->state != COMPOSING_NO) @@ -3558,11 +3541,9 @@ decode_coding_iso_2022 (struct coding_system *coding) || cmp_status->state == COMPOSING_COMPONENT_RULE) && c1 != ISO_CODE_ESC) { - int rule, nbytes; + int rule; - DECODE_COMPOSITION_RULE (rule, nbytes); - if (rule < 0) - goto invalid_code; + DECODE_COMPOSITION_RULE (rule); STORE_COMPOSITION_RULE (rule); continue; } @@ -4878,13 +4859,12 @@ encode_coding_sjis (struct coding_system *coding) int produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; - struct charset *charset_roman, *charset_kanji, *charset_kana; + struct charset *charset_kanji, *charset_kana; struct charset *charset_kanji2; int c; CODING_GET_INFO (coding, attrs, charset_list); - val = charset_list; - charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); + val = XCDR (charset_list); charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); @@ -4970,12 +4950,11 @@ encode_coding_big5 (struct coding_system *coding) int produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; - struct charset *charset_roman, *charset_big5; + struct charset *charset_big5; int c; CODING_GET_INFO (coding, attrs, charset_list); - val = charset_list; - charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); + val = XCDR (charset_list); charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); @@ -5433,7 +5412,8 @@ decode_coding_charset (struct coding_system *coding) = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); int consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - Lisp_Object attrs, charset_list, valids; + Lisp_Object attrs = CODING_ID_ATTRS (coding->id); + Lisp_Object valids; int char_offset = coding->produced_char; int last_offset = char_offset; int last_id = charset_ascii; @@ -5441,7 +5421,6 @@ decode_coding_charset (struct coding_system *coding) !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); int byte_after_cr = -1; - CODING_GET_INFO (coding, attrs, charset_list); valids = AREF (attrs, coding_attr_charset_valids); while (1) |
