Mercurial > emacs
comparison src/coding.c @ 23564:6eb3e346d1fd
(DECODE_CHARACTER_ASCII): Check validity of inserted
code.
(DECODE_CHARACTER_DIMENSION1): Likewise.
(DECODE_CHARACTER_DIMENSION2): Likewise.
(decode_coding_sjis_big5): Check the 2nd byte of SJIS correctly.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Wed, 28 Oct 1998 07:52:13 +0000 |
| parents | eaf358b2e8dd |
| children | 20d595402dea |
comparison
equal
deleted
inserted
replaced
| 23563:18c5f58b70b5 | 23564:6eb3e346d1fd |
|---|---|
| 217 do { \ | 217 do { \ |
| 218 if (COMPOSING_P (coding->composing)) \ | 218 if (COMPOSING_P (coding->composing)) \ |
| 219 { \ | 219 { \ |
| 220 *dst++ = 0xA0, *dst++ = (c) | 0x80; \ | 220 *dst++ = 0xA0, *dst++ = (c) | 0x80; \ |
| 221 coding->composed_chars++; \ | 221 coding->composed_chars++; \ |
| 222 if (((c) | 0x80) < 0xA0) \ | |
| 223 coding->fake_multibyte = 1; \ | |
| 222 } \ | 224 } \ |
| 223 else \ | 225 else \ |
| 224 { \ | 226 { \ |
| 225 *dst++ = (c); \ | 227 *dst++ = (c); \ |
| 226 coding->produced_char++; \ | 228 coding->produced_char++; \ |
| 229 if ((c) >= 0x80) \ | |
| 230 coding->fake_multibyte = 1; \ | |
| 227 } \ | 231 } \ |
| 228 } while (0) | 232 } while (0) |
| 229 | 233 |
| 230 /* Decode one DIMENSION1 character whose charset is CHARSET and whose | 234 /* Decode one DIMENSION1 character whose charset is CHARSET and whose |
| 231 position-code is C. */ | 235 position-code is C. */ |
| 244 coding->produced_char++; \ | 248 coding->produced_char++; \ |
| 245 } \ | 249 } \ |
| 246 if (leading_code = CHARSET_LEADING_CODE_EXT (charset)) \ | 250 if (leading_code = CHARSET_LEADING_CODE_EXT (charset)) \ |
| 247 *dst++ = leading_code; \ | 251 *dst++ = leading_code; \ |
| 248 *dst++ = (c) | 0x80; \ | 252 *dst++ = (c) | 0x80; \ |
| 253 if (((c) | 0x80) < 0xA0) \ | |
| 254 coding->fake_multibyte = 1; \ | |
| 249 } while (0) | 255 } while (0) |
| 250 | 256 |
| 251 /* Decode one DIMENSION2 character whose charset is CHARSET and whose | 257 /* Decode one DIMENSION2 character whose charset is CHARSET and whose |
| 252 position-codes are C1 and C2. */ | 258 position-codes are C1 and C2. */ |
| 253 | 259 |
| 254 #define DECODE_CHARACTER_DIMENSION2(charset, c1, c2) \ | 260 #define DECODE_CHARACTER_DIMENSION2(charset, c1, c2) \ |
| 255 do { \ | 261 do { \ |
| 256 DECODE_CHARACTER_DIMENSION1 (charset, c1); \ | 262 DECODE_CHARACTER_DIMENSION1 (charset, c1); \ |
| 257 *dst++ = (c2) | 0x80; \ | 263 *dst++ = (c2) | 0x80; \ |
| 264 if (((c2) | 0x80) < 0xA0) \ | |
| 265 coding->fake_multibyte = 1; \ | |
| 258 } while (0) | 266 } while (0) |
| 259 | 267 |
| 260 | 268 |
| 261 /*** 1. Preamble ***/ | 269 /*** 1. Preamble ***/ |
| 262 | 270 |
| 2020 --- CODE RANGE of SJIS --- | 2028 --- CODE RANGE of SJIS --- |
| 2021 (character set) (range) | 2029 (character set) (range) |
| 2022 ASCII 0x00 .. 0x7F | 2030 ASCII 0x00 .. 0x7F |
| 2023 KATAKANA-JISX0201 0xA0 .. 0xDF | 2031 KATAKANA-JISX0201 0xA0 .. 0xDF |
| 2024 JISX0208 (1st byte) 0x80 .. 0x9F and 0xE0 .. 0xEF | 2032 JISX0208 (1st byte) 0x80 .. 0x9F and 0xE0 .. 0xEF |
| 2025 (2nd byte) 0x40 .. 0xFF | 2033 (2nd byte) 0x40 .. 0x7E and 0x80 .. 0xFC |
| 2026 ------------------------------- | 2034 ------------------------------- |
| 2027 | 2035 |
| 2028 */ | 2036 */ |
| 2029 | 2037 |
| 2030 /* BIG5 is a coding system encoding two character sets: ASCII and | 2038 /* BIG5 is a coding system encoding two character sets: ASCII and |
| 2273 { | 2281 { |
| 2274 if (c1 < 0xA0 || (c1 >= 0xE0 && c1 < 0xF0)) | 2282 if (c1 < 0xA0 || (c1 >= 0xE0 && c1 < 0xF0)) |
| 2275 { | 2283 { |
| 2276 /* SJIS -> JISX0208 */ | 2284 /* SJIS -> JISX0208 */ |
| 2277 ONE_MORE_BYTE (c2); | 2285 ONE_MORE_BYTE (c2); |
| 2278 if (c2 >= 0x40) | 2286 if (c2 >= 0x40 && c2 != 0x7F && c2 <= 0xFC) |
| 2279 { | 2287 { |
| 2280 DECODE_SJIS (c1, c2, c3, c4); | 2288 DECODE_SJIS (c1, c2, c3, c4); |
| 2281 DECODE_SJIS_BIG5_CHARACTER (charset_jisx0208, c3, c4); | 2289 DECODE_SJIS_BIG5_CHARACTER (charset_jisx0208, c3, c4); |
| 2282 } | 2290 } |
| 2283 else | 2291 else |
