diff options
| author | Paul Eggert | 2011-04-05 22:19:39 -0700 |
|---|---|---|
| committer | Paul Eggert | 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 emacs-41cf7d1aec986e1b92ca14231ac4ec242c233d45.zip | |
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]; | |||
| 753 | produced_chars++; \ | 753 | produced_chars++; \ |
| 754 | if (multibytep) \ | 754 | if (multibytep) \ |
| 755 | { \ | 755 | { \ |
| 756 | int ch = (c); \ | 756 | unsigned ch = (c); \ |
| 757 | if (ch >= 0x80) \ | 757 | if (ch >= 0x80) \ |
| 758 | ch = BYTE8_TO_CHAR (ch); \ | 758 | ch = BYTE8_TO_CHAR (ch); \ |
| 759 | CHAR_STRING_ADVANCE (ch, dst); \ | 759 | CHAR_STRING_ADVANCE (ch, dst); \ |
| @@ -770,7 +770,7 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 770 | produced_chars += 2; \ | 770 | produced_chars += 2; \ |
| 771 | if (multibytep) \ | 771 | if (multibytep) \ |
| 772 | { \ | 772 | { \ |
| 773 | int ch; \ | 773 | unsigned ch; \ |
| 774 | \ | 774 | \ |
| 775 | ch = (c1); \ | 775 | ch = (c1); \ |
| 776 | if (ch >= 0x80) \ | 776 | if (ch >= 0x80) \ |
| @@ -1296,13 +1296,10 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1296 | int consumed_chars = 0, consumed_chars_base = 0; | 1296 | int consumed_chars = 0, consumed_chars_base = 0; |
| 1297 | int multibytep = coding->src_multibyte; | 1297 | int multibytep = coding->src_multibyte; |
| 1298 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); | 1298 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); |
| 1299 | Lisp_Object attr, charset_list; | ||
| 1300 | int eol_dos = | 1299 | int eol_dos = |
| 1301 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1300 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 1302 | int byte_after_cr = -1; | 1301 | int byte_after_cr = -1; |
| 1303 | 1302 | ||
| 1304 | CODING_GET_INFO (coding, attr, charset_list); | ||
| 1305 | |||
| 1306 | if (bom != utf_without_bom) | 1303 | if (bom != utf_without_bom) |
| 1307 | { | 1304 | { |
| 1308 | int c1, c2, c3; | 1305 | int c1, c2, c3; |
| @@ -1610,13 +1607,10 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1610 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1607 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1611 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | 1608 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); |
| 1612 | int surrogate = CODING_UTF_16_SURROGATE (coding); | 1609 | int surrogate = CODING_UTF_16_SURROGATE (coding); |
| 1613 | Lisp_Object attr, charset_list; | ||
| 1614 | int eol_dos = | 1610 | int eol_dos = |
| 1615 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1611 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 1616 | int byte_after_cr1 = -1, byte_after_cr2 = -1; | 1612 | int byte_after_cr1 = -1, byte_after_cr2 = -1; |
| 1617 | 1613 | ||
| 1618 | CODING_GET_INFO (coding, attr, charset_list); | ||
| 1619 | |||
| 1620 | if (bom == utf_with_bom) | 1614 | if (bom == utf_with_bom) |
| 1621 | { | 1615 | { |
| 1622 | int c, c1, c2; | 1616 | int c, c1, c2; |
| @@ -1736,11 +1730,8 @@ encode_coding_utf_16 (struct coding_system *coding) | |||
| 1736 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1730 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1737 | int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | 1731 | int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; |
| 1738 | int produced_chars = 0; | 1732 | int produced_chars = 0; |
| 1739 | Lisp_Object attrs, charset_list; | ||
| 1740 | int c; | 1733 | int c; |
| 1741 | 1734 | ||
| 1742 | CODING_GET_INFO (coding, attrs, charset_list); | ||
| 1743 | |||
| 1744 | if (bom != utf_without_bom) | 1735 | if (bom != utf_without_bom) |
| 1745 | { | 1736 | { |
| 1746 | ASSURE_DESTINATION (safe_room); | 1737 | ASSURE_DESTINATION (safe_room); |
| @@ -2342,7 +2333,6 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2342 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); | 2333 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); |
| 2343 | int consumed_chars = 0, consumed_chars_base; | 2334 | int consumed_chars = 0, consumed_chars_base; |
| 2344 | int multibytep = coding->src_multibyte; | 2335 | int multibytep = coding->src_multibyte; |
| 2345 | Lisp_Object attrs, charset_list; | ||
| 2346 | int char_offset = coding->produced_char; | 2336 | int char_offset = coding->produced_char; |
| 2347 | int last_offset = char_offset; | 2337 | int last_offset = char_offset; |
| 2348 | int last_id = charset_ascii; | 2338 | int last_id = charset_ascii; |
| @@ -2351,8 +2341,6 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2351 | int byte_after_cr = -1; | 2341 | int byte_after_cr = -1; |
| 2352 | struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; | 2342 | struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; |
| 2353 | 2343 | ||
| 2354 | CODING_GET_INFO (coding, attrs, charset_list); | ||
| 2355 | |||
| 2356 | if (cmp_status->state != COMPOSING_NO) | 2344 | if (cmp_status->state != COMPOSING_NO) |
| 2357 | { | 2345 | { |
| 2358 | int i; | 2346 | int i; |
| @@ -3265,15 +3253,14 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3265 | */ | 3253 | */ |
| 3266 | 3254 | ||
| 3267 | /* Decode a composition rule C1 and maybe one more byte from the | 3255 | /* Decode a composition rule C1 and maybe one more byte from the |
| 3268 | source, and set RULE to the encoded composition rule, NBYTES to the | 3256 | source, and set RULE to the encoded composition rule. If the rule |
| 3269 | length of the composition rule. If the rule is invalid, set RULE | 3257 | is invalid, goto invalid_code. */ |
| 3270 | to some negative value. */ | ||
| 3271 | 3258 | ||
| 3272 | #define DECODE_COMPOSITION_RULE(rule, nbytes) \ | 3259 | #define DECODE_COMPOSITION_RULE(rule) \ |
| 3273 | do { \ | 3260 | do { \ |
| 3274 | rule = c1 - 32; \ | 3261 | rule = c1 - 32; \ |
| 3275 | if (rule < 0) \ | 3262 | if (rule < 0) \ |
| 3276 | break; \ | 3263 | goto invalid_code; \ |
| 3277 | if (rule < 81) /* old format (before ver.21) */ \ | 3264 | if (rule < 81) /* old format (before ver.21) */ \ |
| 3278 | { \ | 3265 | { \ |
| 3279 | int gref = (rule) / 9; \ | 3266 | int gref = (rule) / 9; \ |
| @@ -3281,17 +3268,16 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3281 | if (gref == 4) gref = 10; \ | 3268 | if (gref == 4) gref = 10; \ |
| 3282 | if (nref == 4) nref = 10; \ | 3269 | if (nref == 4) nref = 10; \ |
| 3283 | rule = COMPOSITION_ENCODE_RULE (gref, nref); \ | 3270 | rule = COMPOSITION_ENCODE_RULE (gref, nref); \ |
| 3284 | nbytes = 1; \ | ||
| 3285 | } \ | 3271 | } \ |
| 3286 | else /* new format (after ver.21) */ \ | 3272 | else /* new format (after ver.21) */ \ |
| 3287 | { \ | 3273 | { \ |
| 3288 | int b; \ | 3274 | int b; \ |
| 3289 | \ | 3275 | \ |
| 3290 | ONE_MORE_BYTE (b); \ | 3276 | ONE_MORE_BYTE (b); \ |
| 3277 | if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \ | ||
| 3278 | goto invalid_code; \ | ||
| 3291 | rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ | 3279 | rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ |
| 3292 | if (rule >= 0) \ | 3280 | rule += 0x100; /* Distinguish it from the old format. */ \ |
| 3293 | rule += 0x100; /* to destinguish it from the old format */ \ | ||
| 3294 | nbytes = 2; \ | ||
| 3295 | } \ | 3281 | } \ |
| 3296 | } while (0) | 3282 | } while (0) |
| 3297 | 3283 | ||
| @@ -3476,7 +3462,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3476 | struct charset *charset; | 3462 | struct charset *charset; |
| 3477 | int c; | 3463 | int c; |
| 3478 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); | 3464 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); |
| 3479 | Lisp_Object attrs, charset_list; | 3465 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 3480 | int char_offset = coding->produced_char; | 3466 | int char_offset = coding->produced_char; |
| 3481 | int last_offset = char_offset; | 3467 | int last_offset = char_offset; |
| 3482 | int last_id = charset_ascii; | 3468 | int last_id = charset_ascii; |
| @@ -3485,10 +3471,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3485 | int byte_after_cr = -1; | 3471 | int byte_after_cr = -1; |
| 3486 | int i; | 3472 | int i; |
| 3487 | 3473 | ||
| 3488 | CODING_GET_INFO (coding, attrs, charset_list); | ||
| 3489 | setup_iso_safe_charsets (attrs); | 3474 | setup_iso_safe_charsets (attrs); |
| 3490 | /* Charset list may have been changed. */ | ||
| 3491 | charset_list = CODING_ATTR_CHARSET_LIST (attrs); | ||
| 3492 | coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); | 3475 | coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); |
| 3493 | 3476 | ||
| 3494 | if (cmp_status->state != COMPOSING_NO) | 3477 | if (cmp_status->state != COMPOSING_NO) |
| @@ -3558,11 +3541,9 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3558 | || cmp_status->state == COMPOSING_COMPONENT_RULE) | 3541 | || cmp_status->state == COMPOSING_COMPONENT_RULE) |
| 3559 | && c1 != ISO_CODE_ESC) | 3542 | && c1 != ISO_CODE_ESC) |
| 3560 | { | 3543 | { |
| 3561 | int rule, nbytes; | 3544 | int rule; |
| 3562 | 3545 | ||
| 3563 | DECODE_COMPOSITION_RULE (rule, nbytes); | 3546 | DECODE_COMPOSITION_RULE (rule); |
| 3564 | if (rule < 0) | ||
| 3565 | goto invalid_code; | ||
| 3566 | STORE_COMPOSITION_RULE (rule); | 3547 | STORE_COMPOSITION_RULE (rule); |
| 3567 | continue; | 3548 | continue; |
| 3568 | } | 3549 | } |
| @@ -4878,13 +4859,12 @@ encode_coding_sjis (struct coding_system *coding) | |||
| 4878 | int produced_chars = 0; | 4859 | int produced_chars = 0; |
| 4879 | Lisp_Object attrs, charset_list, val; | 4860 | Lisp_Object attrs, charset_list, val; |
| 4880 | int ascii_compatible; | 4861 | int ascii_compatible; |
| 4881 | struct charset *charset_roman, *charset_kanji, *charset_kana; | 4862 | struct charset *charset_kanji, *charset_kana; |
| 4882 | struct charset *charset_kanji2; | 4863 | struct charset *charset_kanji2; |
| 4883 | int c; | 4864 | int c; |
| 4884 | 4865 | ||
| 4885 | CODING_GET_INFO (coding, attrs, charset_list); | 4866 | CODING_GET_INFO (coding, attrs, charset_list); |
| 4886 | val = charset_list; | 4867 | val = XCDR (charset_list); |
| 4887 | charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | ||
| 4888 | charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | 4868 | charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
| 4889 | charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | 4869 | charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); |
| 4890 | charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); | 4870 | charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); |
| @@ -4970,12 +4950,11 @@ encode_coding_big5 (struct coding_system *coding) | |||
| 4970 | int produced_chars = 0; | 4950 | int produced_chars = 0; |
| 4971 | Lisp_Object attrs, charset_list, val; | 4951 | Lisp_Object attrs, charset_list, val; |
| 4972 | int ascii_compatible; | 4952 | int ascii_compatible; |
| 4973 | struct charset *charset_roman, *charset_big5; | 4953 | struct charset *charset_big5; |
| 4974 | int c; | 4954 | int c; |
| 4975 | 4955 | ||
| 4976 | CODING_GET_INFO (coding, attrs, charset_list); | 4956 | CODING_GET_INFO (coding, attrs, charset_list); |
| 4977 | val = charset_list; | 4957 | val = XCDR (charset_list); |
| 4978 | charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); | ||
| 4979 | charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); | 4958 | charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); |
| 4980 | ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); | 4959 | ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); |
| 4981 | 4960 | ||
| @@ -5433,7 +5412,8 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5433 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 5412 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 5434 | int consumed_chars = 0, consumed_chars_base; | 5413 | int consumed_chars = 0, consumed_chars_base; |
| 5435 | int multibytep = coding->src_multibyte; | 5414 | int multibytep = coding->src_multibyte; |
| 5436 | Lisp_Object attrs, charset_list, valids; | 5415 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 5416 | Lisp_Object valids; | ||
| 5437 | int char_offset = coding->produced_char; | 5417 | int char_offset = coding->produced_char; |
| 5438 | int last_offset = char_offset; | 5418 | int last_offset = char_offset; |
| 5439 | int last_id = charset_ascii; | 5419 | int last_id = charset_ascii; |
| @@ -5441,7 +5421,6 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5441 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 5421 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 5442 | int byte_after_cr = -1; | 5422 | int byte_after_cr = -1; |
| 5443 | 5423 | ||
| 5444 | CODING_GET_INFO (coding, attrs, charset_list); | ||
| 5445 | valids = AREF (attrs, coding_attr_charset_valids); | 5424 | valids = AREF (attrs, coding_attr_charset_valids); |
| 5446 | 5425 | ||
| 5447 | while (1) | 5426 | while (1) |