Changeset 1490
- Timestamp:
- 02/17/98 01:45:05 (11 years ago)
- Files:
-
- branches/GNU/src/chpdef.h (added)
- branches/GNU/src/cm.c (modified) (7 diffs)
- branches/GNU/src/cm.h (modified) (1 diff)
- branches/GNU/src/cmds.c (modified) (27 diffs)
- branches/GNU/src/coding.c (modified) (128 diffs)
- branches/GNU/src/coding.h (modified) (16 diffs)
- branches/GNU/src/commands.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/GNU/src/cm.c
r1488 r1490 36 36 37 37 /* ARGSUSED */ 38 int39 38 evalcost (c) 40 39 char c; … … 44 43 } 45 44 46 int47 45 cmputc (c) 48 46 char c; … … 138 136 */ 139 137 140 void141 138 cmcostinit () 142 139 { … … 178 175 */ 179 176 180 static int177 static 181 178 calccost (srcy, srcx, dsty, dstx, doit) 182 179 { … … 313 310 #define USECR 3 314 311 315 void316 312 cmgoto (row, col) 317 313 { … … 416 412 */ 417 413 418 void419 414 Wcm_clear () 420 415 { … … 431 426 */ 432 427 433 int434 428 Wcm_init () 435 429 { branches/GNU/src/cm.h
r1488 r1490 178 178 extern void cmcheckmagic (); 179 179 extern int cmputc (); 180 extern voidcmcostinit ();181 extern voidcmgoto ();182 extern voidWcm_clear ();180 extern int cmcostinit (); 181 extern int cmgoto (); 182 extern int Wcm_clear (); 183 183 extern int Wcm_init (); branches/GNU/src/cmds.c
r1488 r1490 1 1 /* Simple built-in editing commands. 2 Copyright (C) 1985, 93, 94, 95, 96, 97, 1998Free Software Foundation, Inc.2 Copyright (C) 1985, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. 3 3 4 4 This file is part of GNU Emacs. … … 28 28 #include "window.h" 29 29 #include "keyboard.h" 30 #include "dispextern.h"31 30 32 31 Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function; … … 41 40 Lisp_Object Vself_insert_face_command; 42 41 42 /* Offset to add to a non-ASCII value when inserting it. */ 43 int nonascii_insert_offset; 44 43 45 extern Lisp_Object Qface; 44 46 47 /* Return buffer position which is N characters after `point'. */ 48 int 49 forward_point (n) 50 int n; 51 { 52 int pos = PT, c; 53 54 if (!NILP (current_buffer->enable_multibyte_characters)) 55 { 56 /* Simply adding N to `point' doesn't work because of multi-byte 57 form. We had better not use INC_POS and DEC_POS because they 58 check the gap position every time. But, for the moment, we 59 need working code. */ 60 if (n > 0) 61 { 62 while (pos < ZV && n--) INC_POS (pos); 63 if (pos < ZV) n++; 64 } 65 else 66 { 67 while (pos > BEGV && n++) DEC_POS (pos); 68 if (pos > BEGV) n--; 69 } 70 } 71 pos += n; 72 73 return pos; 74 } 75 45 76 DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, 46 77 "Return buffer position N characters after (before if N negative) point.") … … 50 81 CHECK_NUMBER (n, 0); 51 82 52 return make_number ( PT + XINT (n));83 return make_number (forward_point (XINT (n))); 53 84 } 54 85 … … 70 101 proposed position, then set point. */ 71 102 { 72 int new_point = PT + XINT (n);103 int new_point = forward_point (XINT (n)); 73 104 74 105 if (new_point < BEGV) … … 115 146 Lisp_Object n; 116 147 { 117 int opoint = PT, opoint_byte = PT_BYTE; 118 int pos, pos_byte; 119 int count, shortage; 120 int temp; 148 int pos2 = PT; 149 int pos; 150 int count, shortage, negp; 121 151 122 152 if (NILP (n)) … … 128 158 } 129 159 130 if (count <= 0) 131 shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1); 132 else 133 shortage = scan_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, 1); 134 135 /* Since scan_newline does TEMP_SET_PT_BOTH, 136 and we want to set PT "for real", 137 go back to the old point and then come back here. */ 138 pos = PT; 139 pos_byte = PT_BYTE; 140 TEMP_SET_PT_BOTH (opoint, opoint_byte); 141 SET_PT_BOTH (pos, pos_byte); 142 160 negp = count <= 0; 161 pos = scan_buffer ('\n', pos2, 0, count - negp, &shortage, 1); 143 162 if (shortage > 0 144 && ( count <= 0163 && (negp 145 164 || (ZV > BEGV 146 && PT != opoint147 && (FETCH_BYTE (PT_BYTE - 1) != '\n'))))165 && pos != pos2 166 && FETCH_BYTE (pos - 1) != '\n'))) 148 167 shortage--; 149 150 return make_number ( count <= 0? - shortage : shortage);168 SET_PT (pos); 169 return make_number (negp ? - shortage : shortage); 151 170 } 152 171 … … 201 220 CHECK_NUMBER (n, 0); 202 221 203 pos = PT + XINT (n);222 pos = forward_point (XINT (n)); 204 223 if (NILP (killflag)) 205 224 { … … 237 256 Lisp_Object value; 238 257 int deleted_special = 0; 239 int pos, pos_byte,i;258 int pos, i; 240 259 241 260 CHECK_NUMBER (n, 0); … … 243 262 /* See if we are about to delete a tab or newline backwards. */ 244 263 pos = PT; 245 pos_byte = PT_BYTE; 246 for (i = 0; i < XINT (n) && pos_byte > BEGV_BYTE; i++) 264 for (i = 0; i < XINT (n) && pos > BEGV; i++) 247 265 { 248 266 int c; 249 267 250 DEC_ BOTH (pos, pos_byte);251 c = FETCH_BYTE (pos _byte);268 DEC_POS (pos); 269 c = FETCH_BYTE (pos); 252 270 if (c == '\t' || c == '\n') 253 271 { … … 262 280 && ! NILP (current_buffer->overwrite_mode) 263 281 && ! deleted_special 264 && ! (PT == ZV || FETCH_BYTE (PT _BYTE) == '\n'))282 && ! (PT == ZV || FETCH_BYTE (PT) == '\n')) 265 283 { 266 284 int column = current_column (); … … 269 287 i = column - current_column (); 270 288 Finsert_char (make_number (' '), make_number (i), Qnil); 271 /* Whitespace chars are ASCII chars, so we can simply subtract. */ 272 SET_PT_BOTH (PT - i, PT_BYTE - i); 289 SET_PT (PT - i); 273 290 } 274 291 else … … 297 314 We pass internal_self_insert the unmodified character 298 315 because it itself does this offsetting. */ 299 if (! NILP (current_buffer->enable_multibyte_characters)) 300 modified_char = unibyte_char_to_multibyte (modified_char); 316 if (modified_char >= 0200 && modified_char <= 0377 317 && ! NILP (current_buffer->enable_multibyte_characters)) 318 modified_char += nonascii_insert_offset; 301 319 302 320 XSETFASTINT (n, XFASTINT (n) - 2); … … 328 346 A value of 2 means this did things that call for an undo boundary. */ 329 347 330 int331 348 internal_self_insert (c, noautofill) 332 349 int c; … … 342 359 /* Working buffer and pointer for multi-byte form of C. */ 343 360 unsigned char workbuf[4], *str; 344 int chars_to_delete = 0;361 int number_to_delete = 0; 345 362 int spaces_to_insert = 0; 363 364 if (c >= 0200 && c <= 0377 365 && ! NILP (current_buffer->enable_multibyte_characters)) 366 c += nonascii_insert_offset; 346 367 347 368 overwrite = current_buffer->overwrite_mode; … … 352 373 /* At first, get multi-byte form of C in STR. */ 353 374 if (!NILP (current_buffer->enable_multibyte_characters)) 354 { 355 c = unibyte_char_to_multibyte (c); 356 len = CHAR_STRING (c, workbuf, str); 357 } 358 else 359 { 360 workbuf[0] = (SINGLE_BYTE_CHAR_P (c) 361 ? c 362 : multibyte_char_to_unibyte (c, Qnil)); 363 str = workbuf; 364 len = 1; 365 } 375 len = CHAR_STRING (c, workbuf, str); 376 else 377 workbuf[0] = c, str = workbuf, len = 1; 378 366 379 if (!NILP (overwrite) 367 380 && PT < ZV) … … 376 389 C2 and several characters following C2. */ 377 390 378 /* This is the character after point. */ 379 int c2 = FETCH_CHAR (PT_BYTE); 380 381 /* Column the cursor should be placed at after this insertion. 391 /* A code at `point'. Since this is checked only against 392 NEWLINE and TAB, we don't need a character code but only the 393 first byte of multi-byte form. */ 394 unsigned char c2 = FETCH_BYTE (PT); 395 /* A column the cursor should be placed at after this insertion. 382 396 The correct value should be calculated only when necessary. */ 383 397 int target_clm = 0; … … 394 408 && XINT (current_buffer->tab_width) > 0 395 409 && XFASTINT (current_buffer->tab_width) < 20 396 && (target_clm = (current_column () 397 + XINT (Fchar_width (make_number (c2)))), 410 && ((NILP (current_buffer->enable_multibyte_characters) 411 ? (target_clm = current_column () + 1) 412 : (target_clm = current_column () + WIDTH_BY_CHAR_HEAD (str[0]))), 398 413 target_clm % XFASTINT (current_buffer->tab_width))))) 399 414 { 400 415 int pos = PT; 401 int pos_byte = PT_BYTE;402 416 403 417 if (target_clm == 0) 404 chars_to_delete = 1;418 number_to_delete = forward_point (1) - PT; 405 419 else 406 420 { … … 413 427 = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); 414 428 415 chars_to_delete = PT - pos;429 number_to_delete = PT - pos; 416 430 417 431 if (actual_clm > target_clm) … … 422 436 } 423 437 } 424 SET_PT _BOTH (pos, pos_byte);438 SET_PT (pos); 425 439 hairy = 2; 426 440 } … … 453 467 } 454 468 455 if ( chars_to_delete)456 { 457 string = make_string _from_bytes (str, 1, len);469 if (number_to_delete) 470 { 471 string = make_string (str, len); 458 472 if (spaces_to_insert) 459 473 { … … 463 477 } 464 478 465 replace_range (PT, PT + chars_to_delete, string, 1, 1, 1);466 Fforward_char (make_number (1 + spaces_to_insert));479 replace_range (PT, PT + number_to_delete, string, 1, 1); 480 SET_PT (PT + XSTRING (string)->size); 467 481 } 468 482 else … … 476 490 477 491 if (c == '\n') 478 /* After inserting a newline, move to previous line and fill 479 that. Must have the newline in place already so filling and480 justification, if any, know where the end is going to be.*/481 SET_PT _BOTH (PT - 1, PT_BYTE- 1);492 /* After inserting a newline, move to previous line and fill */ 493 /* that. Must have the newline in place already so filling and */ 494 /* justification, if any, know where the end is going to be. */ 495 SET_PT (PT - 1); 482 496 tem = call0 (current_buffer->auto_fill_function); 483 497 if (c == '\n') 484 SET_PT _BOTH (PT + 1, PT_BYTE+ 1);498 SET_PT (PT + 1); 485 499 if (!NILP (tem)) 486 500 hairy = 2; … … 492 506 && EQ (current_kboard->Vlast_command, Vself_insert_face_command)) 493 507 { 494 Fput_text_property (make_number (PT - 1), make_number (PT), 495 Qface, Vself_insert_face, Qnil); 508 Lisp_Object before, after; 509 XSETINT (before, PT - len); 510 XSETINT (after, PT); 511 Fput_text_property (before, after, Qface, Vself_insert_face, Qnil); 496 512 Vself_insert_face = Qnil; 497 513 } … … 511 527 /* module initialization */ 512 528 513 void514 529 syms_of_cmds () 515 530 { … … 537 552 More precisely, a char with closeparen syntax is self-inserted."); 538 553 Vblink_paren_function = Qnil; 554 555 DEFVAR_INT ("nonascii-insert-offset", &nonascii_insert_offset, 556 "Offset to add to a non-ascii code 0200...0377 when inserting it.\n\ 557 This applies only when multibyte characters are enabled, and it serves\n\ 558 to convert a Latin-1 or similar 8-bit character code to the corresponding\n\ 559 Emacs character code."); 560 nonascii_insert_offset = 0; 539 561 540 562 defsubr (&Sforward_point); … … 551 573 } 552 574 553 void554 575 keys_of_cmds () 555 576 { branches/GNU/src/coding.c
r1488 r1490 1 1 /* Coding system handler (conversion, detection, and etc). 2 Copyright (C) 1995, 1997 , 1998Electrotechnical Laboratory, JAPAN.2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. 3 3 Licensed to the Free Software Foundation. 4 4 … … 26 26 3. ISO2022 handlers 27 27 4. Shift-JIS and BIG5 handlers 28 5. CCL handlers 29 6. End-of-line handlers 30 7. C library functions 31 8. Emacs Lisp library functions 32 9. Post-amble 28 5. End-of-line handlers 29 6. C library functions 30 7. Emacs Lisp library functions 31 8. Post-amble 33 32 34 33 */ … … 71 70 4. Raw text 72 71 73 A coding system for a text containing random 8-bit code. Emacs does 74 no code conversion on such a text except for end-of-line format. 72 A coding system to for a text containing random 8-bit code. Emacs 73 does no code conversion on such a text except for end-of-line 74 format. 75 75 76 76 5. Other … … 81 81 while reading/writing. 82 82 83 Emacs represents a coding system by a Lisp symbol that has a property84 `coding-system'. But, before actually using the coding system, the83 Emacs represents a coding-system by a Lisp symbol that has a property 84 `coding-system'. But, before actually using the coding-system, the 85 85 information about it is set in a structure of type `struct 86 86 coding_system' for rapid processing. See section 6 for more details. … … 93 93 instance, Unix's format is just one byte of `line-feed' code, 94 94 whereas DOS's format is two-byte sequence of `carriage-return' and 95 `line-feed' codes. MacOS's format is usually one byte of 96 `carriage-return'. 95 `line-feed' codes. MacOS's format is one byte of `carriage-return'. 97 96 98 97 Since text characters encoding and end-of-line encoding are … … 123 122 These functions decode SRC_BYTES length text at SOURCE encoded in 124 123 CODING to Emacs' internal format (emacs-mule). The resulting text 125 goes to a place pointed to by DESTINATION, the length of which 126 should not exceed DST_BYTES. These functions set the information of 127 original and decoded texts in the members produced, produced_char, 128 consumed, and consumed_char of the structure *CODING. 129 130 The return value is an integer (CODING_FINISH_XXX) indicating how 131 the decoding finished. 132 133 DST_BYTES zero means that source area and destination area are 134 overlapped, which means that we can produce a decoded text until it 135 reaches at the head of not-yet-decoded source text. 136 137 Below is a template of these functions. */ 124 goes to a place pointed to by DESTINATION, the length of which should 125 not exceed DST_BYTES. The number of bytes actually processed is 126 returned as *CONSUMED. The return value is the length of the decoded 127 text. Below is a template of these functions. */ 138 128 #if 0 139 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes )129 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes, consumed) 140 130 struct coding_system *coding; 141 131 unsigned char *source, *destination; 142 132 int src_bytes, dst_bytes; 133 int *consumed; 143 134 { 144 135 ... … … 151 142 internal format (emacs-mule) to CODING. The resulting text goes to 152 143 a place pointed to by DESTINATION, the length of which should not 153 exceed DST_BYTES. These functions set the information of 154 original and encoded texts in the members produced, produced_char, 155 consumed, and consumed_char of the structure *CODING. 156 157 The return value is an integer (CODING_FINISH_XXX) indicating how 158 the encoding finished. 159 160 DST_BYTES zero means that source area and destination area are 161 overlapped, which means that we can produce a decoded text until it 162 reaches at the head of not-yet-decoded source text. 163 164 Below is a template of these functions. */ 144 exceed DST_BYTES. The number of bytes actually processed is 145 returned as *CONSUMED. The return value is the length of the 146 encoded text. Below is a template of these functions. */ 165 147 #if 0 166 encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes )148 encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes, consumed) 167 149 struct coding_system *coding; 168 150 unsigned char *source, *destination; 169 151 int src_bytes, dst_bytes; 152 int *consumed; 170 153 { 171 154 ... … … 219 202 *dst++ = 0xA0, *dst++ = (c) | 0x80; \ 220 203 else \ 221 { \ 222 *dst++ = (c); \ 223 coding->produced_char++; \ 224 } \ 204 *dst++ = (c); \ 225 205 } while (0) 226 206 … … 234 214 *dst++ = leading_code + 0x20; \ 235 215 else \ 236 { \ 237 *dst++ = leading_code; \ 238 coding->produced_char++; \ 239 } \ 216 *dst++ = leading_code; \ 240 217 if (leading_code = CHARSET_LEADING_CODE_EXT (charset)) \ 241 218 *dst++ = leading_code; \ … … 278 255 Lisp_Object Qno_conversion, Qundecided; 279 256 Lisp_Object Qcoding_system_history; 280 Lisp_Object Qsafe_charsets;281 Lisp_Object Qvalid_codes;282 257 283 258 extern Lisp_Object Qinsert_file_contents, Qwrite_region; … … 285 260 Lisp_Object Qstart_process, Qopen_network_stream; 286 261 Lisp_Object Qtarget_idx; 287 288 Lisp_Object Vselect_safe_coding_system_function;289 262 290 263 /* Mnemonic character of each format of end-of-line. */ … … 300 273 #ifdef emacs 301 274 302 Lisp_Object Vcoding_system_list, Vcoding_system_alist; 303 304 Lisp_Object Qcoding_system_p, Qcoding_system_error; 305 306 /* Coding system emacs-mule and raw-text are for converting only 307 end-of-line format. */ 308 Lisp_Object Qemacs_mule, Qraw_text; 275 Lisp_Object Qcoding_system_spec, Qcoding_system_p, Qcoding_system_error; 276 277 /* Coding system emacs-mule is for converting only end-of-line format. */ 278 Lisp_Object Qemacs_mule; 309 279 310 280 /* Coding-systems are handed between Emacs Lisp programs and C internal … … 318 288 319 289 /* A vector of length 256 which contains information about special 320 Latin codes (espe cially for dealing with Microsoft codes). */290 Latin codes (espepcially for dealing with Microsoft code). */ 321 291 Lisp_Object Vlatin_extra_code_table; 322 292 323 293 /* Flag to inhibit code conversion of end-of-line format. */ 324 294 int inhibit_eol_conversion; 325 326 /* Flag to make buffer-file-coding-system inherit from process-coding. */327 int inherit_process_coding_system;328 295 329 296 /* Coding system to be used to encode text for terminal display. */ … … 337 304 struct coding_system keyboard_coding; 338 305 339 /* Default coding system to be used to write a file. */340 struct coding_system default_buffer_file_coding;341 342 306 Lisp_Object Vfile_coding_system_alist; 343 307 Lisp_Object Vprocess_coding_system_alist; … … 346 310 #endif /* emacs */ 347 311 348 Lisp_Object Qcoding_category , Qcoding_category_index;312 Lisp_Object Qcoding_category_index; 349 313 350 314 /* List of symbols `coding-category-xxx' ordered by priority. */ 351 315 Lisp_Object Vcoding_category_list; 352 316 353 /* Table of coding categories (Lisp symbols). */354 Lisp_Object Vcoding_category_table;317 /* Table of coding-systems currently assigned to each coding-category. */ 318 Lisp_Object coding_category_table[CODING_CATEGORY_IDX_MAX]; 355 319 356 320 /* Table of names of symbol for each coding-category. */ … … 359 323 "coding-category-sjis", 360 324 "coding-category-iso-7", 361 "coding-category-iso-7-tight",362 325 "coding-category-iso-8-1", 363 326 "coding-category-iso-8-2", 364 327 "coding-category-iso-7-else", 365 328 "coding-category-iso-8-else", 366 "coding-category-ccl",367 329 "coding-category-big5", 368 330 "coding-category-raw-text", … … 370 332 }; 371 333 372 /* Table of pointers to coding systems corresponding to each coding 373 categories. */ 374 struct coding_system *coding_system_table[CODING_CATEGORY_IDX_MAX]; 375 376 /* Table of coding category masks. Nth element is a mask for a coding 377 cateogry of which priority is Nth. */ 378 static 379 int coding_priorities[CODING_CATEGORY_IDX_MAX]; 380 381 /* Flag to tell if we look up translation table on character code 334 /* Flag to tell if we look up unification table on character code 382 335 conversion. */ 383 Lisp_Object Venable_character_translation; 384 /* Standard translation table to look up on decoding (reading). */ 385 Lisp_Object Vstandard_translation_table_for_decode; 386 /* Standard translation table to look up on encoding (writing). */ 387 Lisp_Object Vstandard_translation_table_for_encode; 388 389 Lisp_Object Qtranslation_table; 390 Lisp_Object Qtranslation_table_id; 391 Lisp_Object Qtranslation_table_for_decode; 392 Lisp_Object Qtranslation_table_for_encode; 336 Lisp_Object Venable_character_unification; 337 /* Standard unification table to look up on decoding (reading). */ 338 Lisp_Object Vstandard_character_unification_table_for_decode; 339 /* Standard unification table to look up on encoding (writing). */ 340 Lisp_Object Vstandard_character_unification_table_for_encode; 341 342 Lisp_Object Qcharacter_unification_table; 343 Lisp_Object Qcharacter_unification_table_for_decode; 344 Lisp_Object Qcharacter_unification_table_for_encode; 393 345 394 346 /* Alist of charsets vs revision number. */ … … 446 398 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 447 399 Check if a text is encoded in Emacs' internal format. If it is, 448 return CODING_CATEGORY_MASK_EMA CS_MULE, else return 0. */400 return CODING_CATEGORY_MASK_EMASC_MULE, else return 0. */ 449 401 450 402 int … … 656 608 enum iso_code_class_type iso_code_class[256]; 657 609 658 #define CHARSET_OK(idx, charset) \659 (coding_system_table[idx] \660 && (coding_system_table[idx]->safe_charsets[charset] \661 || (CODING_SPEC_ISO_REQUESTED_DESIGNATION \662 (coding_system_table[idx], charset) \663 != CODING_SPEC_ISO_NO_REQUESTED_DESIGNATION)))664 665 #define SHIFT_OUT_OK(idx) \666 (CODING_SPEC_ISO_INITIAL_DESIGNATION (coding_system_table[idx], 1) >= 0)667 668 610 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 669 611 Check if a text is encoded in ISO2022. If it is, returns an 670 612 integer in which appropriate flag bits any of: 671 613 CODING_CATEGORY_MASK_ISO_7 672 CODING_CATEGORY_MASK_ISO_7_TIGHT673 614 CODING_CATEGORY_MASK_ISO_8_1 674 615 CODING_CATEGORY_MASK_ISO_8_2 … … 682 623 unsigned char *src, *src_end; 683 624 { 684 int mask = CODING_CATEGORY_MASK_ISO; 685 int mask_found = 0; 686 int reg[4], shift_out = 0; 687 int c, c1, i, charset; 688 689 reg[0] = CHARSET_ASCII, reg[1] = reg[2] = reg[3] = -1; 625 int mask = (CODING_CATEGORY_MASK_ISO_7 626 | CODING_CATEGORY_MASK_ISO_8_1 627 | CODING_CATEGORY_MASK_ISO_8_2 628 | CODING_CATEGORY_MASK_ISO_7_ELSE 629 | CODING_CATEGORY_MASK_ISO_8_ELSE 630 ); 631 int g1 = 0; /* 1 iff designating to G1. */ 632 int c, i; 633 struct coding_system coding_iso_8_1, coding_iso_8_2; 634 635 /* Coding systems of these categories may accept latin extra codes. */ 636 setup_coding_system 637 (XSYMBOL (coding_category_table[CODING_CATEGORY_IDX_ISO_8_1])->value, 638 &coding_iso_8_1); 639 setup_coding_system 640 (XSYMBOL (coding_category_table[CODING_CATEGORY_IDX_ISO_8_2])->value, 641 &coding_iso_8_2); 642 690 643 while (mask && src < src_end) 691 644 { … … 697 650 break; 698 651 c = *src++; 699 if ( c >= '(' && c <= '/')652 if ((c >= '(' && c <= '/')) 700 653 { 701 654 /* Designation sequence for a charset of dimension 1. */ 702 655 if (src >= src_end) 703 656 break; 704 c1 = *src++; 705 if (c1 < ' ' || c1 >= 0x80 706 || (charset = iso_charset_table[0][c >= ','][c1]) < 0) 707 /* Invalid designation sequence. Just ignore. */ 708 break; 709 reg[(c - '(') % 4] = charset; 657 c = *src++; 658 if (c < ' ' || c >= 0x80) 659 /* Invalid designation sequence. */ 660 return 0; 710 661 } 711 662 else if (c == '$') … … 717 668 if (c >= '@' && c <= 'B') 718 669 /* Designation for JISX0208.1978, GB2312, or JISX0208. */ 719 reg[0] = charset = iso_charset_table[1][0][c];670 ; 720 671 else if (c >= '(' && c <= '/') 721 672 { 722 673 if (src >= src_end) 723 674 break; 724 c1 = *src++; 725 if (c1 < ' ' || c1 >= 0x80 726 || (charset = iso_charset_table[1][c >= ','][c1]) < 0) 727 /* Invalid designation sequence. Just ignore. */ 728 break; 729 reg[(c - '(') % 4] = charset; 675 c = *src++; 676 if (c < ' ' || c >= 0x80) 677 /* Invalid designation sequence. */ 678 return 0; 730 679 } 731 680 else 732 /* Invalid designation sequence. Just ignore.*/733 break;681 /* Invalid designation sequence. */ 682 return 0; 734 683 } 735 else if (c == 'N' || c == 'n') 736 { 737 if (shift_out == 0 738 && (reg[1] >= 0 739 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE) 740 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))) 741 { 742 /* Locking shift out. */ 743 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; 744 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; 745 shift_out = 1; 746 } 747 break; 748 } 749 else if (c == 'O' || c == 'o') 750 { 751 if (shift_out == 1) 752 { 753 /* Locking shift in. */ 754 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; 755 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; 756 shift_out = 0; 757 } 758 break; 759 } 684 else if (c == 'N' || c == 'O' || c == 'n' || c == 'o') 685 /* Locking shift. */ 686 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE 687 | CODING_CATEGORY_MASK_ISO_8_ELSE); 760 688 else if (c == '0' || c == '1' || c == '2') 761 /* Start/end composition. Just ignore.*/762 break;689 /* Start/end composition. */ 690 ; 763 691 else 764 /* Invalid escape sequence. Just ignore. */ 765 break; 766 767 /* We found a valid designation sequence for CHARSET. */ 768 mask &= ~CODING_CATEGORY_MASK_ISO_8BIT; 769 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7, charset)) 770 mask_found |= CODING_CATEGORY_MASK_ISO_7; 771 else 772 mask &= ~CODING_CATEGORY_MASK_ISO_7; 773 if (CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_TIGHT, charset)) 774 mask_found |= CODING_CATEGORY_MASK_ISO_7_TIGHT; 775 else 776 mask &= ~CODING_CATEGORY_MASK_ISO_7_TIGHT; 777 if (! CHARSET_OK (CODING_CATEGORY_IDX_ISO_7_ELSE, charset)) 778 mask &= ~CODING_CATEGORY_MASK_ISO_7_ELSE; 779 if (! CHARSET_OK (CODING_CATEGORY_IDX_ISO_8_ELSE, charset)) 780 mask &= ~CODING_CATEGORY_MASK_ISO_8_ELSE; 692 /* Invalid escape sequence. */ 693 return 0; 781 694 break; 782 695 783 696 case ISO_CODE_SO: 784 if (shift_out == 0 785 && (reg[1] >= 0 786 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_7_ELSE) 787 || SHIFT_OUT_OK (CODING_CATEGORY_IDX_ISO_8_ELSE))) 788 { 789 /* Locking shift out. */ 790 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT; 791 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT; 792 } 697 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE 698 | CODING_CATEGORY_MASK_ISO_8_ELSE); 793 699 break; 794 700 795 case ISO_CODE_SI:796 if (shift_out == 1)797 {798 /* Locking shift in. */799 mask &= ~CODING_CATEGORY_MASK_ISO_7BIT;800 mask_found |= CODING_CATEGORY_MASK_ISO_SHIFT;801 }802 break;803 804 701 case ISO_CODE_CSI: 805 702 case ISO_CODE_SS2: … … 808 705 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE; 809 706 810 if (c != ISO_CODE_CSI)811 {812 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags813 & CODING_FLAG_ISO_SINGLE_SHIFT)814 newmask |= CODING_CATEGORY_MASK_ISO_8_1;815 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags816 & CODING_FLAG_ISO_SINGLE_SHIFT)817 newmask |= CODING_CATEGORY_MASK_ISO_8_2;818 }819 707 if (VECTORP (Vlatin_extra_code_table) 820 708 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) 821 709 { 822 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags 823 & CODING_FLAG_ISO_LATIN_EXTRA) 710 if (coding_iso_8_1.flags & CODING_FLAG_ISO_LATIN_EXTRA) 824 711 newmask |= CODING_CATEGORY_MASK_ISO_8_1; 825 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags 826 & CODING_FLAG_ISO_LATIN_EXTRA) 712 if (coding_iso_8_2.flags & CODING_FLAG_ISO_LATIN_EXTRA) 827 713 newmask |= CODING_CATEGORY_MASK_ISO_8_2; 828 714 } 829 715 mask &= newmask; 830 mask_found |= newmask;831 716 } 832 717 break; … … 842 727 int newmask = 0; 843 728 844 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_1]->flags 845 & CODING_FLAG_ISO_LATIN_EXTRA) 729 if (coding_iso_8_1.flags & CODING_FLAG_ISO_LATIN_EXTRA) 846 730 newmask |= CODING_CATEGORY_MASK_ISO_8_1; 847 if (coding_system_table[CODING_CATEGORY_IDX_ISO_8_2]->flags 848 & CODING_FLAG_ISO_LATIN_EXTRA) 731 if (coding_iso_8_2.flags & CODING_FLAG_ISO_LATIN_EXTRA) 849 732 newmask |= CODING_CATEGORY_MASK_ISO_8_2; 850 733 mask &= newmask; 851 mask_found |= newmask;852 734 } 853 735 else … … 858 740 unsigned char *src_begin = src; 859 741 860 mask &= ~(CODING_CATEGORY_MASK_ISO_7 BIT742 mask &= ~(CODING_CATEGORY_MASK_ISO_7 861 743 | CODING_CATEGORY_MASK_ISO_7_ELSE); 862 mask_found |= CODING_CATEGORY_MASK_ISO_8_1;863 744 while (src < src_end && *src >= 0xA0) 864 745 src++; 865 746 if ((src - src_begin - 1) & 1 && src < src_end) 866 747 mask &= ~CODING_CATEGORY_MASK_ISO_8_2; 867 else868 mask_found |= CODING_CATEGORY_MASK_ISO_8_2;869 748 } 870 749 break; … … 872 751 } 873 752 874 return (mask & mask_found);753 return mask; 875 754 } 876 755 … … 892 771 coding->composing += 2; \ 893 772 } \ 894 if ( charset_alt >= 0)\773 if ((charset) >= 0) \ 895 774 { \ 896 if (CHARSET_DIMENSION (charset_alt) == 2) \ 897 { \ 898 ONE_MORE_BYTE (c2); \ 899 if (iso_code_class[(c2) & 0x7F] != ISO_0x20_or_0x7F \ 900 && iso_code_class[(c2) & 0x7F] != ISO_graphic_plane_0) \ 901 { \ 902 src--; \ 903 charset_alt = CHARSET_ASCII; \ 904 } \ 905 } \ 906 if (!NILP (translation_table) \ 907 && ((c_alt = translate_char (translation_table, \ 908 -1, charset_alt, c1, c2)) >= 0)) \ 775 if (CHARSET_DIMENSION (charset) == 2) \ 776 ONE_MORE_BYTE (c2); \ 777 if (!NILP (unification_table) \ 778 && ((c_alt = unify_char (unification_table, \ 779 -1, (charset), c1, c2)) >= 0)) \ 909 780 SPLIT_CHAR (c_alt, charset_alt, c1, c2); \ 910 781 } \ … … 921 792 922 793 /* Set designation state into CODING. */ 923 #define DECODE_DESIGNATION(reg, dimension, chars, final_char) \ 924 do { \ 925 int charset = ISO_CHARSET_TABLE (make_number (dimension), \ 926 make_number (chars), \ 927 make_number (final_char)); \ 928 if (charset >= 0 \ 929 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \ 930 || coding->safe_charsets[charset])) \ 931 { &n
