From f38b440c4b40777c25631323f2501ffb5ba98251 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 17:41:19 -0800 Subject: * coding.c (coding_set_source, coding_set_destination): Use "else { /* comment */ }" rather than "else /* comment */;" for clarity, and to avoid gcc -Wempty-body warning. --- src/coding.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index f6310369ad3..cb13793daba 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1051,9 +1051,10 @@ coding_set_source (struct coding_system *coding) coding->source = SDATA (coding->src_object) + coding->src_pos_byte; } else - /* Otherwise, the source is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the source is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } static void @@ -1079,9 +1080,10 @@ coding_set_destination (struct coding_system *coding) } } else - /* Otherwise, the destination is C string and is never relocated - automatically. Thus we don't have to update anything. */ - ; + { + /* Otherwise, the destination is C string and is never relocated + automatically. Thus we don't have to update anything. */ + } } -- cgit v1.2.1 From 2735d0606bd871584b2e6343f3dce4c1a155b296 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 20:37:19 -0800 Subject: * 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. --- src/coding.c | 101 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 51 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index cb13793daba..495e8148b05 100644 --- a/src/coding.c +++ b/src/coding.c @@ -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))); -- cgit v1.2.1 From e2f1bab96318b2809aad624ee9bbbdfd7fd6dd6e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 20:41:22 -0800 Subject: * coding.c (emacs_mule_char, encode_invocation_designation): Now static, since they're not used elsewhere. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 495e8148b05..4fdbd1fd752 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1982,7 +1982,7 @@ detect_coding_emacs_mule (struct coding_system *coding, the decoded character or rule. If an invalid byte is found, return -1. If SRC is too short, return -2. */ -int +static int emacs_mule_char (struct coding_system *coding, const unsigned char *src, int *nbytes, int *nchars, int *id, struct composition_status *cmp_status) @@ -4228,7 +4228,7 @@ decode_coding_iso_2022 (struct coding_system *coding) to use CHARSET. The element `spec.iso_2022' of *CODING is updated. Return new DST. */ -unsigned char * +static unsigned char * encode_invocation_designation (struct charset *charset, struct coding_system *coding, unsigned char *dst, int *p_nchars) -- cgit v1.2.1 From 413bb2db753528a2e4bd70f8bbabcd232b11b6d7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 21:28:41 -0800 Subject: * coding.c (decode_coding_iso_2022): Add "default: abort ();" as a safety check. --- src/coding.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 4fdbd1fd752..c9d32489351 100644 --- a/src/coding.c +++ b/src/coding.c @@ -3899,6 +3899,10 @@ decode_coding_iso_2022 (struct coding_system *coding) } continue; } + break; + + default: + abort (); } if (cmp_status->state == COMPOSING_NO -- cgit v1.2.1 From c4a63b128d3f8405fa1037e0c22bd8fabcbdd123 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:12:45 -0800 Subject: * coding.c: (decode_coding_object, encode_coding_object, detect_coding_system): Mark variables that gcc -Wuninitialized does not deduce are never used uninitialized. --- src/coding.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c9d32489351..75fc92eee8d 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7658,12 +7658,12 @@ decode_coding_object (struct coding_system *coding, Lisp_Object dst_object) { int count = SPECPDL_INDEX (); - unsigned char *destination; - EMACS_INT dst_bytes; + unsigned char *destination IF_LINT (= NULL); + EMACS_INT dst_bytes IF_LINT (= 0); EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; Lisp_Object old_deactivate_mark; @@ -7851,7 +7851,7 @@ encode_coding_object (struct coding_system *coding, EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; - int saved_pt = -1, saved_pt_byte; + int saved_pt = -1, saved_pt_byte IF_LINT (= 0); int need_marker_adjustment = 0; int kill_src_buffer = 0; Lisp_Object old_deactivate_mark; @@ -8184,8 +8184,8 @@ detect_coding_system (const unsigned char *src, base_category = XINT (CODING_ATTR_CATEGORY (attrs)); if (base_category == coding_category_undecided) { - enum coding_category category; - struct coding_system *this; + enum coding_category category IF_LINT (= 0); + struct coding_system *this IF_LINT (= NULL); int c, i; /* Skip all ASCII bytes except for a few ISO2022 controls. */ -- cgit v1.2.1 From 5f58e762f919864376efe785253006590a1e4dc5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:23:55 -0800 Subject: * coding.c: (ISO_CODE_LF, ISO_CODE_CR, CODING_ISO_FLAG_EUC_TW_SHIFT): (ONE_MORE_BYTE_NO_CHECK, UTF_BOM, UTF_16_INVALID_P): (SHIFT_OUT_OK, ENCODE_CONTROL_SEQUENCE_INTRODUCER): (ENCODE_DIRECTION_R2L, ENCODE_DIRECTION_L2R): Remove unused macros. --- src/coding.c | 57 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 75fc92eee8d..3df34cea173 100644 --- a/src/coding.c +++ b/src/coding.c @@ -395,8 +395,6 @@ Lisp_Object Vbig5_coding_system; /* Control characters of ISO2022. */ /* code */ /* function */ -#define ISO_CODE_LF 0x0A /* line-feed */ -#define ISO_CODE_CR 0x0D /* carriage-return */ #define ISO_CODE_SO 0x0E /* shift-out */ #define ISO_CODE_SI 0x0F /* shift-in */ #define ISO_CODE_SS2_7 0x19 /* single-shift-2 for 7-bit code */ @@ -479,7 +477,7 @@ enum iso_code_class_type #define CODING_ISO_FLAG_COMPOSITION 0x2000 -#define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 +/* #define CODING_ISO_FLAG_EUC_TW_SHIFT 0x4000 */ #define CODING_ISO_FLAG_USE_ROMAN 0x8000 @@ -721,25 +719,6 @@ static struct coding_system coding_categories[coding_category_max]; } while (0) -#define ONE_MORE_BYTE_NO_CHECK(c) \ - do { \ - c = *src++; \ - if (multibytep && (c & 0x80)) \ - { \ - if ((c & 0xFE) == 0xC0) \ - c = ((c & 1) << 6) | *src++; \ - else \ - { \ - src--; \ - c = - string_char (src, &src, NULL); \ - record_conversion_result \ - (coding, CODING_RESULT_INVALID_SRC); \ - } \ - } \ - consumed_chars++; \ - } while (0) - - /* Store a byte C in the place pointed by DST and increment DST to the next free point, and increment PRODUCED_CHARS. The caller should assure that C is 0..127, and declare and set the variable `dst' @@ -1219,7 +1198,6 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0) #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8) -#define UTF_BOM 0xFEFF #define UTF_8_BOM_1 0xEF #define UTF_8_BOM_2 0xBB #define UTF_8_BOM_3 0xBF @@ -1535,11 +1513,6 @@ encode_coding_utf_8 (struct coding_system *coding) #define UTF_16_LOW_SURROGATE_P(val) \ (((val) & 0xFC00) == 0xDC00) -#define UTF_16_INVALID_P(val) \ - (((val) == 0xFFFE) \ - || ((val) == 0xFFFF) \ - || UTF_16_LOW_SURROGATE_P (val)) - static int detect_coding_utf_16 (struct coding_system *coding, @@ -2905,10 +2878,6 @@ enum iso_code_class_type iso_code_class[256]; ((id) <= (coding)->max_charset_id \ && (coding)->safe_charsets[id] != 255) - -#define SHIFT_OUT_OK(category) \ - (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) - static void setup_iso_safe_charsets (Lisp_Object attrs) { @@ -4295,30 +4264,6 @@ encode_invocation_designation (struct charset *charset, return dst; } -/* The following three macros produce codes for indicating direction - of text. */ -#define ENCODE_CONTROL_SEQUENCE_INTRODUCER \ - do { \ - if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS) \ - EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '['); \ - else \ - EMIT_ONE_BYTE (ISO_CODE_CSI); \ - } while (0) - - -#define ENCODE_DIRECTION_R2L() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('2', ']'); \ - } while (0) - - -#define ENCODE_DIRECTION_L2R() \ - do { \ - ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst); \ - EMIT_TWO_ASCII_BYTES ('0', ']'); \ - } while (0) - /* Produce codes for designation and invocation to reset the graphic planes and registers to initial state. */ -- cgit v1.2.1 From ee05f96119932f5e4f33b59e1a2f4abdd9c0a34a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:34:38 -0800 Subject: * coding.c (decode_coding_emacs_mule): Mark variables that gcc -Wuninitialized does not deduce are never used uninitialized. --- src/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 3df34cea173..096268d1a72 100644 --- a/src/coding.c +++ b/src/coding.c @@ -2365,7 +2365,7 @@ decode_coding_emacs_mule (struct coding_system *coding) while (1) { - int c, id; + int c, id IF_LINT (= 0); src_base = src; consumed_chars_base = consumed_chars; @@ -2410,7 +2410,7 @@ decode_coding_emacs_mule (struct coding_system *coding) } else { - int nchars, nbytes; + int nchars IF_LINT (= 0), nbytes IF_LINT (= 0); /* emacs_mule_char can load a charset map from a file, which allocates a large structure and might cause buffer text to be relocated as result. Thus, we need to remember the -- cgit v1.2.1 From 160b01f65a12a9e6893c270662d6ae249a1db300 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2011 23:36:31 -0800 Subject: * coding.c (detect_coding_iso_2022): Initialize a local variable that might be used uninitialized. Leave a FIXME because it's not clear that this initialization is needed. --- src/coding.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 096268d1a72..9a6a4484e50 100644 --- a/src/coding.c +++ b/src/coding.c @@ -2954,7 +2954,12 @@ 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; - 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 consumed_chars = 0; int i; -- cgit v1.2.1 From 0e48bb227a5b9cdabeb845422de33d62ccb1edc5 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 15 Mar 2011 19:38:57 +0100 Subject: * src/coding.c (detect_coding_iso_2022): Reorganize code to clarify structure. --- src/coding.c | 159 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 80 insertions(+), 79 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 9a6a4484e50..0c2836c19f6 100644 --- a/src/coding.c +++ b/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,40 +2994,11 @@ detect_coding_iso_2022 (struct coding_system *coding, break; single_shifting = 0; ONE_MORE_BYTE (c); - if (c >= '(' && c <= '/') - { - /* 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') + if (c == 'N' || c == 'O') { /* ESC for SS2 or SS3. */ single_shifting = 1; rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT; - break; } else if (c == '1') { @@ -3048,36 +3014,66 @@ detect_coding_iso_2022 (struct coding_system *coding, { /* ESC for start/end composition. */ composition_count = 0; - break; } else { - /* Invalid escape sequence. Just ignore it. */ - break; - } + if (c >= '(' && c <= '/') + { + /* 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. */ - rejected |= CATEGORY_MASK_ISO_8BIT; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], - id)) - found |= CATEGORY_MASK_ISO_7; - else - rejected |= CATEGORY_MASK_ISO_7; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], - id)) - found |= CATEGORY_MASK_ISO_7_TIGHT; - else - rejected |= CATEGORY_MASK_ISO_7_TIGHT; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], - id)) - found |= CATEGORY_MASK_ISO_7_ELSE; - else - rejected |= CATEGORY_MASK_ISO_7_ELSE; - if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], - id)) - found |= CATEGORY_MASK_ISO_8_ELSE; - else - rejected |= CATEGORY_MASK_ISO_8_ELSE; + /* We found a valid designation sequence for CHARSET. */ + rejected |= CATEGORY_MASK_ISO_8BIT; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7], + id)) + found |= CATEGORY_MASK_ISO_7; + else + rejected |= CATEGORY_MASK_ISO_7; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight], + id)) + found |= CATEGORY_MASK_ISO_7_TIGHT; + else + rejected |= CATEGORY_MASK_ISO_7_TIGHT; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else], + id)) + found |= CATEGORY_MASK_ISO_7_ELSE; + else + rejected |= CATEGORY_MASK_ISO_7_ELSE; + if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else], + id)) + 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; -- cgit v1.2.1