diff options
| author | Joakim Verona | 2014-06-04 23:50:06 +0200 |
|---|---|---|
| committer | Joakim Verona | 2014-06-04 23:50:06 +0200 |
| commit | ce8171797dafbde765170b79e5f154afc4872e86 (patch) | |
| tree | 264b357b484de24929a3f2d20a34e0e43c006a15 /src/coding.h | |
| parent | c1c9aa247cab9148916b367e719219ea0f055adb (diff) | |
| parent | b5d6fe3bf6e728c82a3ff63723d75519f7853716 (diff) | |
| download | emacs-ce8171797dafbde765170b79e5f154afc4872e86.tar.gz emacs-ce8171797dafbde765170b79e5f154afc4872e86.zip | |
upstream
Diffstat (limited to 'src/coding.h')
| -rw-r--r-- | src/coding.h | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/src/coding.h b/src/coding.h index 2c01a05d197..f3efcca031d 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Header for coding system handler. | 1 | /* Header for coding system handler. |
| 2 | Copyright (C) 2001-2013 Free Software Foundation, Inc. | 2 | Copyright (C) 2001-2014 Free Software Foundation, Inc. |
| 3 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 4 | 2005, 2006, 2007, 2008, 2009, 2010, 2011 | 4 | 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
| 5 | National Institute of Advanced Industrial Science and Technology (AIST) | 5 | National Institute of Advanced Industrial Science and Technology (AIST) |
| @@ -226,7 +226,7 @@ enum coding_attr_index | |||
| 226 | hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ | 226 | hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ |
| 227 | coding_system_symbol, NULL) | 227 | coding_system_symbol, NULL) |
| 228 | 228 | ||
| 229 | /* Return 1 if CODING_SYSTEM_SYMBOL is a coding system. */ | 229 | /* Return true if CODING_SYSTEM_SYMBOL is a coding system. */ |
| 230 | 230 | ||
| 231 | #define CODING_SYSTEM_P(coding_system_symbol) \ | 231 | #define CODING_SYSTEM_P(coding_system_symbol) \ |
| 232 | (CODING_SYSTEM_ID (coding_system_symbol) >= 0 \ | 232 | (CODING_SYSTEM_ID (coding_system_symbol) >= 0 \ |
| @@ -240,7 +240,7 @@ enum coding_attr_index | |||
| 240 | if (CODING_SYSTEM_ID (x) < 0 \ | 240 | if (CODING_SYSTEM_ID (x) < 0 \ |
| 241 | && NILP (Fcheck_coding_system (x))) \ | 241 | && NILP (Fcheck_coding_system (x))) \ |
| 242 | wrong_type_argument (Qcoding_system_p, (x)); \ | 242 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 243 | } while (0) | 243 | } while (false) |
| 244 | 244 | ||
| 245 | 245 | ||
| 246 | /* Check if X is a coding system or not. If it is, set SEPC to the | 246 | /* Check if X is a coding system or not. If it is, set SEPC to the |
| @@ -256,7 +256,7 @@ enum coding_attr_index | |||
| 256 | } \ | 256 | } \ |
| 257 | if (NILP (spec)) \ | 257 | if (NILP (spec)) \ |
| 258 | wrong_type_argument (Qcoding_system_p, (x)); \ | 258 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 259 | } while (0) | 259 | } while (false) |
| 260 | 260 | ||
| 261 | 261 | ||
| 262 | /* Check if X is a coding system or not. If it is, set ID to the | 262 | /* Check if X is a coding system or not. If it is, set ID to the |
| @@ -273,7 +273,7 @@ enum coding_attr_index | |||
| 273 | } \ | 273 | } \ |
| 274 | if (id < 0) \ | 274 | if (id < 0) \ |
| 275 | wrong_type_argument (Qcoding_system_p, (x)); \ | 275 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 276 | } while (0) | 276 | } while (false) |
| 277 | 277 | ||
| 278 | 278 | ||
| 279 | /*** GENERAL section ***/ | 279 | /*** GENERAL section ***/ |
| @@ -361,13 +361,13 @@ struct iso_2022_spec | |||
| 361 | 361 | ||
| 362 | /* True temporarily only when graphic register 2 or 3 is invoked by | 362 | /* True temporarily only when graphic register 2 or 3 is invoked by |
| 363 | single-shift while encoding. */ | 363 | single-shift while encoding. */ |
| 364 | unsigned single_shifting : 1; | 364 | bool_bf single_shifting : 1; |
| 365 | 365 | ||
| 366 | /* True temporarily only when processing at beginning of line. */ | 366 | /* True temporarily only when processing at beginning of line. */ |
| 367 | unsigned bol : 1; | 367 | bool_bf bol : 1; |
| 368 | 368 | ||
| 369 | /* If true, we are now scanning embedded UTF-8 sequence. */ | 369 | /* If true, we are now scanning embedded UTF-8 sequence. */ |
| 370 | unsigned embedded_utf_8 : 1; | 370 | bool_bf embedded_utf_8 : 1; |
| 371 | 371 | ||
| 372 | /* The current composition. */ | 372 | /* The current composition. */ |
| 373 | struct composition_status cmp_status; | 373 | struct composition_status cmp_status; |
| @@ -455,11 +455,11 @@ struct coding_system | |||
| 455 | unsigned char *safe_charsets; | 455 | unsigned char *safe_charsets; |
| 456 | 456 | ||
| 457 | /* The following two members specify how binary 8-bit code 128..255 | 457 | /* The following two members specify how binary 8-bit code 128..255 |
| 458 | are represented in source and destination text respectively. 1 | 458 | are represented in source and destination text respectively. True |
| 459 | means they are represented by 2-byte sequence, 0 means they are | 459 | means they are represented by 2-byte sequence, false means they are |
| 460 | represented by 1-byte as is (see the comment in character.h). */ | 460 | represented by 1-byte as is (see the comment in character.h). */ |
| 461 | unsigned src_multibyte : 1; | 461 | bool_bf src_multibyte : 1; |
| 462 | unsigned dst_multibyte : 1; | 462 | bool_bf dst_multibyte : 1; |
| 463 | 463 | ||
| 464 | /* How may heading bytes we can skip for decoding. This is set to | 464 | /* How may heading bytes we can skip for decoding. This is set to |
| 465 | -1 in setup_coding_system, and updated by detect_coding. So, | 465 | -1 in setup_coding_system, and updated by detect_coding. So, |
| @@ -468,7 +468,9 @@ struct coding_system | |||
| 468 | the eol format. */ | 468 | the eol format. */ |
| 469 | ptrdiff_t head_ascii; | 469 | ptrdiff_t head_ascii; |
| 470 | 470 | ||
| 471 | ptrdiff_t detected_utf8_chars; | 471 | /* How many bytes/chars at the source are detected as valid utf-8 |
| 472 | sequence. Set by detect_coding_utf_8. */ | ||
| 473 | ptrdiff_t detected_utf8_bytes, detected_utf8_chars; | ||
| 472 | 474 | ||
| 473 | /* Used internally in coding.c. See the comment of detect_ascii. */ | 475 | /* Used internally in coding.c. See the comment of detect_ascii. */ |
| 474 | int eol_seen; | 476 | int eol_seen; |
| @@ -477,7 +479,7 @@ struct coding_system | |||
| 477 | ptrdiff_t produced, produced_char, consumed, consumed_char; | 479 | ptrdiff_t produced, produced_char, consumed, consumed_char; |
| 478 | 480 | ||
| 479 | /* Number of error source data found in a decoding routine. */ | 481 | /* Number of error source data found in a decoding routine. */ |
| 480 | int errors; | 482 | ptrdiff_t errors; |
| 481 | 483 | ||
| 482 | /* Store the positions of error source data. */ | 484 | /* Store the positions of error source data. */ |
| 483 | ptrdiff_t *error_positions; | 485 | ptrdiff_t *error_positions; |
| @@ -510,10 +512,14 @@ struct coding_system | |||
| 510 | 512 | ||
| 511 | /* True if the source of conversion is not in the member | 513 | /* True if the source of conversion is not in the member |
| 512 | `charbuf', but at `src_object'. */ | 514 | `charbuf', but at `src_object'. */ |
| 513 | unsigned chars_at_source : 1; | 515 | bool_bf chars_at_source : 1; |
| 514 | 516 | ||
| 515 | /* Set to 1 if charbuf contains an annotation. */ | 517 | /* Nonzero if the result of conversion is in `destination' |
| 516 | unsigned annotated : 1; | 518 | buffer rather than in `dst_object'. */ |
| 519 | bool_bf raw_destination : 1; | ||
| 520 | |||
| 521 | /* Set to true if charbuf contains an annotation. */ | ||
| 522 | bool_bf annotated : 1; | ||
| 517 | 523 | ||
| 518 | unsigned char carryover[64]; | 524 | unsigned char carryover[64]; |
| 519 | int carryover_bytes; | 525 | int carryover_bytes; |
| @@ -539,28 +545,29 @@ struct coding_system | |||
| 539 | #define CODING_REQUIRE_DETECTION_MASK 0x1000 | 545 | #define CODING_REQUIRE_DETECTION_MASK 0x1000 |
| 540 | #define CODING_RESET_AT_BOL_MASK 0x2000 | 546 | #define CODING_RESET_AT_BOL_MASK 0x2000 |
| 541 | 547 | ||
| 542 | /* Return 1 if the coding context CODING requires annotation | 548 | /* Return nonzero if the coding context CODING requires annotation |
| 543 | handling. */ | 549 | handling. */ |
| 544 | #define CODING_REQUIRE_ANNOTATION(coding) \ | 550 | #define CODING_REQUIRE_ANNOTATION(coding) \ |
| 545 | ((coding)->common_flags & CODING_ANNOTATION_MASK) | 551 | ((coding)->common_flags & CODING_ANNOTATION_MASK) |
| 546 | 552 | ||
| 547 | /* Return 1 if the coding context CODING prefers decoding into unibyte. */ | 553 | /* Return nonzero if the coding context CODING prefers decoding into |
| 554 | unibyte. */ | ||
| 548 | #define CODING_FOR_UNIBYTE(coding) \ | 555 | #define CODING_FOR_UNIBYTE(coding) \ |
| 549 | ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK) | 556 | ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK) |
| 550 | 557 | ||
| 551 | /* Return 1 if the coding context CODING requires specific code to be | 558 | /* Return nonzero if the coding context CODING requires specific code to be |
| 552 | attached at the tail of converted text. */ | 559 | attached at the tail of converted text. */ |
| 553 | #define CODING_REQUIRE_FLUSHING(coding) \ | 560 | #define CODING_REQUIRE_FLUSHING(coding) \ |
| 554 | ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) | 561 | ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) |
| 555 | 562 | ||
| 556 | /* Return 1 if the coding context CODING requires code conversion on | 563 | /* Return nonzero if the coding context CODING requires code conversion on |
| 557 | decoding. */ | 564 | decoding. */ |
| 558 | #define CODING_REQUIRE_DECODING(coding) \ | 565 | #define CODING_REQUIRE_DECODING(coding) \ |
| 559 | ((coding)->dst_multibyte \ | 566 | ((coding)->dst_multibyte \ |
| 560 | || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK) | 567 | || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK) |
| 561 | 568 | ||
| 562 | 569 | ||
| 563 | /* Return 1 if the coding context CODING requires code conversion on | 570 | /* Return nonzero if the coding context CODING requires code conversion on |
| 564 | encoding. | 571 | encoding. |
| 565 | The non-multibyte part of the condition is to support encoding of | 572 | The non-multibyte part of the condition is to support encoding of |
| 566 | unibyte strings/buffers generated by string-as-unibyte or | 573 | unibyte strings/buffers generated by string-as-unibyte or |
| @@ -571,12 +578,12 @@ struct coding_system | |||
| 571 | || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY) | 578 | || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY) |
| 572 | 579 | ||
| 573 | 580 | ||
| 574 | /* Return 1 if the coding context CODING requires some kind of code | 581 | /* Return nonzero if the coding context CODING requires some kind of code |
| 575 | detection. */ | 582 | detection. */ |
| 576 | #define CODING_REQUIRE_DETECTION(coding) \ | 583 | #define CODING_REQUIRE_DETECTION(coding) \ |
| 577 | ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) | 584 | ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) |
| 578 | 585 | ||
| 579 | /* Return 1 if the coding context CODING requires code conversion on | 586 | /* Return nonzero if the coding context CODING requires code conversion on |
| 580 | decoding or some kind of code detection. */ | 587 | decoding or some kind of code detection. */ |
| 581 | #define CODING_MAY_REQUIRE_DECODING(coding) \ | 588 | #define CODING_MAY_REQUIRE_DECODING(coding) \ |
| 582 | (CODING_REQUIRE_DECODING (coding) \ | 589 | (CODING_REQUIRE_DECODING (coding) \ |
| @@ -600,7 +607,7 @@ struct coding_system | |||
| 600 | (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \ | 607 | (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \ |
| 601 | j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F)); \ | 608 | j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F)); \ |
| 602 | (code) = (j1 << 8) | j2; \ | 609 | (code) = (j1 << 8) | j2; \ |
| 603 | } while (0) | 610 | } while (false) |
| 604 | 611 | ||
| 605 | #define SJIS_TO_JIS2(code) \ | 612 | #define SJIS_TO_JIS2(code) \ |
| 606 | do { \ | 613 | do { \ |
| @@ -625,7 +632,7 @@ struct coding_system | |||
| 625 | j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \ | 632 | j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \ |
| 626 | } \ | 633 | } \ |
| 627 | (code) = (j1 << 8) | j2; \ | 634 | (code) = (j1 << 8) | j2; \ |
| 628 | } while (0) | 635 | } while (false) |
| 629 | 636 | ||
| 630 | 637 | ||
| 631 | #define JIS_TO_SJIS(code) \ | 638 | #define JIS_TO_SJIS(code) \ |
| @@ -640,7 +647,7 @@ struct coding_system | |||
| 640 | (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0), \ | 647 | (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0), \ |
| 641 | s2 = j2 + 0x7E); \ | 648 | s2 = j2 + 0x7E); \ |
| 642 | (code) = (s1 << 8) | s2; \ | 649 | (code) = (s1 << 8) | s2; \ |
| 643 | } while (0) | 650 | } while (false) |
| 644 | 651 | ||
| 645 | #define JIS_TO_SJIS2(code) \ | 652 | #define JIS_TO_SJIS2(code) \ |
| 646 | do { \ | 653 | do { \ |
| @@ -664,44 +671,32 @@ struct coding_system | |||
| 664 | s2 = j2 + 0x7E; \ | 671 | s2 = j2 + 0x7E; \ |
| 665 | } \ | 672 | } \ |
| 666 | (code) = (s1 << 8) | s2; \ | 673 | (code) = (s1 << 8) | s2; \ |
| 667 | } while (0) | 674 | } while (false) |
| 668 | 675 | ||
| 669 | /* Encode the file name NAME using the specified coding system | 676 | /* Encode the file name NAME using the specified coding system |
| 670 | for file names, if any. */ | 677 | for file names, if any. */ |
| 671 | #define ENCODE_FILE(name) \ | 678 | #define ENCODE_FILE(NAME) encode_file_name (NAME) |
| 672 | (! NILP (Vfile_name_coding_system) \ | ||
| 673 | ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ | ||
| 674 | : (! NILP (Vdefault_file_name_coding_system) \ | ||
| 675 | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ | ||
| 676 | : name)) | ||
| 677 | |||
| 678 | 679 | ||
| 679 | /* Decode the file name NAME using the specified coding system | 680 | /* Decode the file name NAME using the specified coding system |
| 680 | for file names, if any. */ | 681 | for file names, if any. */ |
| 681 | #define DECODE_FILE(name) \ | 682 | #define DECODE_FILE(NAME) decode_file_name (NAME) |
| 682 | (! NILP (Vfile_name_coding_system) \ | ||
| 683 | ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ | ||
| 684 | : (! NILP (Vdefault_file_name_coding_system) \ | ||
| 685 | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ | ||
| 686 | : name)) | ||
| 687 | |||
| 688 | 683 | ||
| 689 | /* Encode the string STR using the specified coding system | 684 | /* Encode the string STR using the specified coding system |
| 690 | for system functions, if any. */ | 685 | for system functions, if any. */ |
| 691 | #define ENCODE_SYSTEM(str) \ | 686 | #define ENCODE_SYSTEM(str) \ |
| 692 | (! NILP (Vlocale_coding_system) \ | 687 | (! NILP (Vlocale_coding_system) \ |
| 693 | ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ | 688 | ? code_convert_string_norecord (str, Vlocale_coding_system, true) \ |
| 694 | : str) | 689 | : str) |
| 695 | 690 | ||
| 696 | /* Decode the string STR using the specified coding system | 691 | /* Decode the string STR using the specified coding system |
| 697 | for system functions, if any. */ | 692 | for system functions, if any. */ |
| 698 | #define DECODE_SYSTEM(str) \ | 693 | #define DECODE_SYSTEM(str) \ |
| 699 | (! NILP (Vlocale_coding_system) \ | 694 | (! NILP (Vlocale_coding_system) \ |
| 700 | ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ | 695 | ? code_convert_string_norecord (str, Vlocale_coding_system, false) \ |
| 701 | : str) | 696 | : str) |
| 702 | 697 | ||
| 703 | /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op. */ | 698 | /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op. */ |
| 704 | #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) | 699 | #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, true) |
| 705 | 700 | ||
| 706 | /* Extern declarations. */ | 701 | /* Extern declarations. */ |
| 707 | extern Lisp_Object code_conversion_save (bool, bool); | 702 | extern Lisp_Object code_conversion_save (bool, bool); |
| @@ -712,6 +707,8 @@ extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, | |||
| 712 | Lisp_Object, bool, bool, bool); | 707 | Lisp_Object, bool, bool, bool); |
| 713 | extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, | 708 | extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, |
| 714 | bool); | 709 | bool); |
| 710 | extern Lisp_Object encode_file_name (Lisp_Object); | ||
| 711 | extern Lisp_Object decode_file_name (Lisp_Object); | ||
| 715 | extern Lisp_Object raw_text_coding_system (Lisp_Object); | 712 | extern Lisp_Object raw_text_coding_system (Lisp_Object); |
| 716 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); | 713 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); |
| 717 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); | 714 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); |
| @@ -746,7 +743,7 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf); | |||
| 746 | extern Lisp_Object from_unicode (Lisp_Object str); | 743 | extern Lisp_Object from_unicode (Lisp_Object str); |
| 747 | 744 | ||
| 748 | /* Convert WSTR to an Emacs string. */ | 745 | /* Convert WSTR to an Emacs string. */ |
| 749 | extern Lisp_Object from_unicode_buffer (const wchar_t* wstr); | 746 | extern Lisp_Object from_unicode_buffer (const wchar_t *wstr); |
| 750 | 747 | ||
| 751 | #endif /* WINDOWSNT || CYGWIN */ | 748 | #endif /* WINDOWSNT || CYGWIN */ |
| 752 | 749 | ||
| @@ -765,7 +762,7 @@ extern Lisp_Object from_unicode_buffer (const wchar_t* wstr); | |||
| 765 | (coding)->src_chars = (coding)->src_bytes = (bytes); \ | 762 | (coding)->src_chars = (coding)->src_bytes = (bytes); \ |
| 766 | decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes), \ | 763 | decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes), \ |
| 767 | (dst_object)); \ | 764 | (dst_object)); \ |
| 768 | } while (0) | 765 | } while (false) |
| 769 | 766 | ||
| 770 | 767 | ||
| 771 | extern Lisp_Object preferred_coding_system (void); | 768 | extern Lisp_Object preferred_coding_system (void); |