diff options
Diffstat (limited to 'src/coding.h')
| -rw-r--r-- | src/coding.h | 158 |
1 files changed, 83 insertions, 75 deletions
diff --git a/src/coding.h b/src/coding.h index eb95fa13ddb..4e8b1056e43 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) |
| @@ -76,6 +76,14 @@ enum define_coding_ccl_arg_index | |||
| 76 | coding_arg_ccl_max | 76 | coding_arg_ccl_max |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | enum define_coding_undecided_arg_index | ||
| 80 | { | ||
| 81 | coding_arg_undecided_inhibit_null_byte_detection = coding_arg_max, | ||
| 82 | coding_arg_undecided_inhibit_iso_escape_detection, | ||
| 83 | coding_arg_undecided_prefer_utf_8, | ||
| 84 | coding_arg_undecided_max | ||
| 85 | }; | ||
| 86 | |||
| 79 | /* Hash table for all coding systems. Keys are coding system symbols | 87 | /* Hash table for all coding systems. Keys are coding system symbols |
| 80 | and values are spec vectors of the corresponding coding system. A | 88 | and values are spec vectors of the corresponding coding system. A |
| 81 | spec vector has the form [ ATTRS ALIASES EOL-TYPE ]. ATTRS is a | 89 | spec vector has the form [ ATTRS ALIASES EOL-TYPE ]. ATTRS is a |
| @@ -158,6 +166,10 @@ enum coding_attr_index | |||
| 158 | 166 | ||
| 159 | coding_attr_emacs_mule_full, | 167 | coding_attr_emacs_mule_full, |
| 160 | 168 | ||
| 169 | coding_attr_undecided_inhibit_null_byte_detection, | ||
| 170 | coding_attr_undecided_inhibit_iso_escape_detection, | ||
| 171 | coding_attr_undecided_prefer_utf_8, | ||
| 172 | |||
| 161 | coding_attr_last_index | 173 | coding_attr_last_index |
| 162 | }; | 174 | }; |
| 163 | 175 | ||
| @@ -214,7 +226,7 @@ enum coding_attr_index | |||
| 214 | hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ | 226 | hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ |
| 215 | coding_system_symbol, NULL) | 227 | coding_system_symbol, NULL) |
| 216 | 228 | ||
| 217 | /* Return 1 if CODING_SYSTEM_SYMBOL is a coding system. */ | 229 | /* Return true if CODING_SYSTEM_SYMBOL is a coding system. */ |
| 218 | 230 | ||
| 219 | #define CODING_SYSTEM_P(coding_system_symbol) \ | 231 | #define CODING_SYSTEM_P(coding_system_symbol) \ |
| 220 | (CODING_SYSTEM_ID (coding_system_symbol) >= 0 \ | 232 | (CODING_SYSTEM_ID (coding_system_symbol) >= 0 \ |
| @@ -228,7 +240,7 @@ enum coding_attr_index | |||
| 228 | if (CODING_SYSTEM_ID (x) < 0 \ | 240 | if (CODING_SYSTEM_ID (x) < 0 \ |
| 229 | && NILP (Fcheck_coding_system (x))) \ | 241 | && NILP (Fcheck_coding_system (x))) \ |
| 230 | wrong_type_argument (Qcoding_system_p, (x)); \ | 242 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 231 | } while (0) | 243 | } while (false) |
| 232 | 244 | ||
| 233 | 245 | ||
| 234 | /* 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 |
| @@ -244,7 +256,7 @@ enum coding_attr_index | |||
| 244 | } \ | 256 | } \ |
| 245 | if (NILP (spec)) \ | 257 | if (NILP (spec)) \ |
| 246 | wrong_type_argument (Qcoding_system_p, (x)); \ | 258 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 247 | } while (0) | 259 | } while (false) |
| 248 | 260 | ||
| 249 | 261 | ||
| 250 | /* 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 |
| @@ -261,7 +273,7 @@ enum coding_attr_index | |||
| 261 | } \ | 273 | } \ |
| 262 | if (id < 0) \ | 274 | if (id < 0) \ |
| 263 | wrong_type_argument (Qcoding_system_p, (x)); \ | 275 | wrong_type_argument (Qcoding_system_p, (x)); \ |
| 264 | } while (0) | 276 | } while (false) |
| 265 | 277 | ||
| 266 | 278 | ||
| 267 | /*** GENERAL section ***/ | 279 | /*** GENERAL section ***/ |
| @@ -272,37 +284,31 @@ enum coding_result_code | |||
| 272 | CODING_RESULT_SUCCESS, | 284 | CODING_RESULT_SUCCESS, |
| 273 | CODING_RESULT_INSUFFICIENT_SRC, | 285 | CODING_RESULT_INSUFFICIENT_SRC, |
| 274 | CODING_RESULT_INSUFFICIENT_DST, | 286 | CODING_RESULT_INSUFFICIENT_DST, |
| 275 | CODING_RESULT_INCONSISTENT_EOL, | ||
| 276 | CODING_RESULT_INVALID_SRC, | 287 | CODING_RESULT_INVALID_SRC, |
| 277 | CODING_RESULT_INTERRUPT, | 288 | CODING_RESULT_INTERRUPT |
| 278 | CODING_RESULT_INSUFFICIENT_MEM | ||
| 279 | }; | 289 | }; |
| 280 | 290 | ||
| 281 | 291 | ||
| 282 | /* Macros used for the member `mode' of the struct coding_system. */ | 292 | /* Macros used for the member `mode' of the struct coding_system. */ |
| 283 | 293 | ||
| 284 | /* If set, recover the original CR or LF of the already decoded text | ||
| 285 | when the decoding routine encounters an inconsistent eol format. */ | ||
| 286 | #define CODING_MODE_INHIBIT_INCONSISTENT_EOL 0x01 | ||
| 287 | |||
| 288 | /* If set, the decoding/encoding routines treat the current data as | 294 | /* If set, the decoding/encoding routines treat the current data as |
| 289 | the last block of the whole text to be converted, and do the | 295 | the last block of the whole text to be converted, and do the |
| 290 | appropriate finishing job. */ | 296 | appropriate finishing job. */ |
| 291 | #define CODING_MODE_LAST_BLOCK 0x02 | 297 | #define CODING_MODE_LAST_BLOCK 0x01 |
| 292 | 298 | ||
| 293 | /* If set, it means that the current source text is in a buffer which | 299 | /* If set, it means that the current source text is in a buffer which |
| 294 | enables selective display. */ | 300 | enables selective display. */ |
| 295 | #define CODING_MODE_SELECTIVE_DISPLAY 0x04 | 301 | #define CODING_MODE_SELECTIVE_DISPLAY 0x02 |
| 296 | 302 | ||
| 297 | /* This flag is used by the decoding/encoding routines on the fly. If | 303 | /* This flag is used by the decoding/encoding routines on the fly. If |
| 298 | set, it means that right-to-left text is being processed. */ | 304 | set, it means that right-to-left text is being processed. */ |
| 299 | #define CODING_MODE_DIRECTION 0x08 | 305 | #define CODING_MODE_DIRECTION 0x04 |
| 300 | 306 | ||
| 301 | #define CODING_MODE_FIXED_DESTINATION 0x10 | 307 | #define CODING_MODE_FIXED_DESTINATION 0x08 |
| 302 | 308 | ||
| 303 | /* If set, it means that the encoding routines produces some safe | 309 | /* If set, it means that the encoding routines produces some safe |
| 304 | ASCII characters (usually '?') for unsupported characters. */ | 310 | ASCII characters (usually '?') for unsupported characters. */ |
| 305 | #define CODING_MODE_SAFE_ENCODING 0x20 | 311 | #define CODING_MODE_SAFE_ENCODING 0x10 |
| 306 | 312 | ||
| 307 | /* For handling composition sequence. */ | 313 | /* For handling composition sequence. */ |
| 308 | #include "composite.h" | 314 | #include "composite.h" |
| @@ -355,13 +361,13 @@ struct iso_2022_spec | |||
| 355 | 361 | ||
| 356 | /* 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 |
| 357 | single-shift while encoding. */ | 363 | single-shift while encoding. */ |
| 358 | unsigned single_shifting : 1; | 364 | bool_bf single_shifting : 1; |
| 359 | 365 | ||
| 360 | /* True temporarily only when processing at beginning of line. */ | 366 | /* True temporarily only when processing at beginning of line. */ |
| 361 | unsigned bol : 1; | 367 | bool_bf bol : 1; |
| 362 | 368 | ||
| 363 | /* If true, we are now scanning embedded UTF-8 sequence. */ | 369 | /* If true, we are now scanning embedded UTF-8 sequence. */ |
| 364 | unsigned embedded_utf_8 : 1; | 370 | bool_bf embedded_utf_8 : 1; |
| 365 | 371 | ||
| 366 | /* The current composition. */ | 372 | /* The current composition. */ |
| 367 | struct composition_status cmp_status; | 373 | struct composition_status cmp_status; |
| @@ -372,7 +378,18 @@ struct emacs_mule_spec | |||
| 372 | struct composition_status cmp_status; | 378 | struct composition_status cmp_status; |
| 373 | }; | 379 | }; |
| 374 | 380 | ||
| 375 | struct ccl_spec; | 381 | struct undecided_spec |
| 382 | { | ||
| 383 | /* Inhibit null byte detection. 1 means always inhibit, | ||
| 384 | -1 means do not inhibit, 0 means rely on user variable. */ | ||
| 385 | int inhibit_nbd; | ||
| 386 | |||
| 387 | /* Inhibit ISO escape detection. -1, 0, 1 as above. */ | ||
| 388 | int inhibit_ied; | ||
| 389 | |||
| 390 | /* Prefer UTF-8 when the input could be other encodings. */ | ||
| 391 | bool prefer_utf_8; | ||
| 392 | }; | ||
| 376 | 393 | ||
| 377 | enum utf_bom_type | 394 | enum utf_bom_type |
| 378 | { | 395 | { |
| @@ -431,29 +448,38 @@ struct coding_system | |||
| 431 | struct utf_16_spec utf_16; | 448 | struct utf_16_spec utf_16; |
| 432 | enum utf_bom_type utf_8_bom; | 449 | enum utf_bom_type utf_8_bom; |
| 433 | struct emacs_mule_spec emacs_mule; | 450 | struct emacs_mule_spec emacs_mule; |
| 451 | struct undecided_spec undecided; | ||
| 434 | } spec; | 452 | } spec; |
| 435 | 453 | ||
| 436 | int max_charset_id; | 454 | int max_charset_id; |
| 437 | unsigned char *safe_charsets; | 455 | unsigned char *safe_charsets; |
| 438 | 456 | ||
| 439 | /* 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 |
| 440 | are represented in source and destination text respectively. 1 | 458 | are represented in source and destination text respectively. True |
| 441 | 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 |
| 442 | 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). */ |
| 443 | unsigned src_multibyte : 1; | 461 | bool_bf src_multibyte : 1; |
| 444 | unsigned dst_multibyte : 1; | 462 | bool_bf dst_multibyte : 1; |
| 445 | 463 | ||
| 446 | /* 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 |
| 447 | -1 in setup_coding_system, and updated by detect_coding. So, | 465 | -1 in setup_coding_system, and updated by detect_coding. So, |
| 448 | when this is equal to the byte length of the text being | 466 | when this is equal to the byte length of the text being |
| 449 | converted, we can skip the actual conversion process. */ | 467 | converted, we can skip the actual conversion process except for |
| 468 | the eol format. */ | ||
| 450 | ptrdiff_t head_ascii; | 469 | ptrdiff_t head_ascii; |
| 451 | 470 | ||
| 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; | ||
| 474 | |||
| 475 | /* Used internally in coding.c. See the comment of detect_ascii. */ | ||
| 476 | int eol_seen; | ||
| 477 | |||
| 452 | /* The following members are set by encoding/decoding routine. */ | 478 | /* The following members are set by encoding/decoding routine. */ |
| 453 | ptrdiff_t produced, produced_char, consumed, consumed_char; | 479 | ptrdiff_t produced, produced_char, consumed, consumed_char; |
| 454 | 480 | ||
| 455 | /* Number of error source data found in a decoding routine. */ | 481 | /* Number of error source data found in a decoding routine. */ |
| 456 | int errors; | 482 | ptrdiff_t errors; |
| 457 | 483 | ||
| 458 | /* Store the positions of error source data. */ | 484 | /* Store the positions of error source data. */ |
| 459 | ptrdiff_t *error_positions; | 485 | ptrdiff_t *error_positions; |
| @@ -486,10 +512,14 @@ struct coding_system | |||
| 486 | 512 | ||
| 487 | /* True if the source of conversion is not in the member | 513 | /* True if the source of conversion is not in the member |
| 488 | `charbuf', but at `src_object'. */ | 514 | `charbuf', but at `src_object'. */ |
| 489 | unsigned chars_at_source : 1; | 515 | bool_bf chars_at_source : 1; |
| 516 | |||
| 517 | /* Nonzero if the result of conversion is in `destination' | ||
| 518 | buffer rather than in `dst_object'. */ | ||
| 519 | bool_bf raw_destination : 1; | ||
| 490 | 520 | ||
| 491 | /* Set to 1 if charbuf contains an annotation. */ | 521 | /* Set to true if charbuf contains an annotation. */ |
| 492 | unsigned annotated : 1; | 522 | bool_bf annotated : 1; |
| 493 | 523 | ||
| 494 | unsigned char carryover[64]; | 524 | unsigned char carryover[64]; |
| 495 | int carryover_bytes; | 525 | int carryover_bytes; |
| @@ -515,28 +545,29 @@ struct coding_system | |||
| 515 | #define CODING_REQUIRE_DETECTION_MASK 0x1000 | 545 | #define CODING_REQUIRE_DETECTION_MASK 0x1000 |
| 516 | #define CODING_RESET_AT_BOL_MASK 0x2000 | 546 | #define CODING_RESET_AT_BOL_MASK 0x2000 |
| 517 | 547 | ||
| 518 | /* Return 1 if the coding context CODING requires annotation | 548 | /* Return nonzero if the coding context CODING requires annotation |
| 519 | handling. */ | 549 | handling. */ |
| 520 | #define CODING_REQUIRE_ANNOTATION(coding) \ | 550 | #define CODING_REQUIRE_ANNOTATION(coding) \ |
| 521 | ((coding)->common_flags & CODING_ANNOTATION_MASK) | 551 | ((coding)->common_flags & CODING_ANNOTATION_MASK) |
| 522 | 552 | ||
| 523 | /* Return 1 if the coding context CODING prefers decoding into unibyte. */ | 553 | /* Return nonzero if the coding context CODING prefers decoding into |
| 554 | unibyte. */ | ||
| 524 | #define CODING_FOR_UNIBYTE(coding) \ | 555 | #define CODING_FOR_UNIBYTE(coding) \ |
| 525 | ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK) | 556 | ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK) |
| 526 | 557 | ||
| 527 | /* 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 |
| 528 | attached at the tail of converted text. */ | 559 | attached at the tail of converted text. */ |
| 529 | #define CODING_REQUIRE_FLUSHING(coding) \ | 560 | #define CODING_REQUIRE_FLUSHING(coding) \ |
| 530 | ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) | 561 | ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) |
| 531 | 562 | ||
| 532 | /* Return 1 if the coding context CODING requires code conversion on | 563 | /* Return nonzero if the coding context CODING requires code conversion on |
| 533 | decoding. */ | 564 | decoding. */ |
| 534 | #define CODING_REQUIRE_DECODING(coding) \ | 565 | #define CODING_REQUIRE_DECODING(coding) \ |
| 535 | ((coding)->dst_multibyte \ | 566 | ((coding)->dst_multibyte \ |
| 536 | || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK) | 567 | || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK) |
| 537 | 568 | ||
| 538 | 569 | ||
| 539 | /* Return 1 if the coding context CODING requires code conversion on | 570 | /* Return nonzero if the coding context CODING requires code conversion on |
| 540 | encoding. | 571 | encoding. |
| 541 | 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 |
| 542 | unibyte strings/buffers generated by string-as-unibyte or | 573 | unibyte strings/buffers generated by string-as-unibyte or |
| @@ -547,12 +578,12 @@ struct coding_system | |||
| 547 | || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY) | 578 | || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY) |
| 548 | 579 | ||
| 549 | 580 | ||
| 550 | /* 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 |
| 551 | detection. */ | 582 | detection. */ |
| 552 | #define CODING_REQUIRE_DETECTION(coding) \ | 583 | #define CODING_REQUIRE_DETECTION(coding) \ |
| 553 | ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) | 584 | ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) |
| 554 | 585 | ||
| 555 | /* Return 1 if the coding context CODING requires code conversion on | 586 | /* Return nonzero if the coding context CODING requires code conversion on |
| 556 | decoding or some kind of code detection. */ | 587 | decoding or some kind of code detection. */ |
| 557 | #define CODING_MAY_REQUIRE_DECODING(coding) \ | 588 | #define CODING_MAY_REQUIRE_DECODING(coding) \ |
| 558 | (CODING_REQUIRE_DECODING (coding) \ | 589 | (CODING_REQUIRE_DECODING (coding) \ |
| @@ -576,7 +607,7 @@ struct coding_system | |||
| 576 | (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \ | 607 | (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \ |
| 577 | j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F)); \ | 608 | j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F)); \ |
| 578 | (code) = (j1 << 8) | j2; \ | 609 | (code) = (j1 << 8) | j2; \ |
| 579 | } while (0) | 610 | } while (false) |
| 580 | 611 | ||
| 581 | #define SJIS_TO_JIS2(code) \ | 612 | #define SJIS_TO_JIS2(code) \ |
| 582 | do { \ | 613 | do { \ |
| @@ -601,7 +632,7 @@ struct coding_system | |||
| 601 | j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \ | 632 | j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \ |
| 602 | } \ | 633 | } \ |
| 603 | (code) = (j1 << 8) | j2; \ | 634 | (code) = (j1 << 8) | j2; \ |
| 604 | } while (0) | 635 | } while (false) |
| 605 | 636 | ||
| 606 | 637 | ||
| 607 | #define JIS_TO_SJIS(code) \ | 638 | #define JIS_TO_SJIS(code) \ |
| @@ -616,7 +647,7 @@ struct coding_system | |||
| 616 | (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0), \ | 647 | (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0), \ |
| 617 | s2 = j2 + 0x7E); \ | 648 | s2 = j2 + 0x7E); \ |
| 618 | (code) = (s1 << 8) | s2; \ | 649 | (code) = (s1 << 8) | s2; \ |
| 619 | } while (0) | 650 | } while (false) |
| 620 | 651 | ||
| 621 | #define JIS_TO_SJIS2(code) \ | 652 | #define JIS_TO_SJIS2(code) \ |
| 622 | do { \ | 653 | do { \ |
| @@ -640,44 +671,32 @@ struct coding_system | |||
| 640 | s2 = j2 + 0x7E; \ | 671 | s2 = j2 + 0x7E; \ |
| 641 | } \ | 672 | } \ |
| 642 | (code) = (s1 << 8) | s2; \ | 673 | (code) = (s1 << 8) | s2; \ |
| 643 | } while (0) | 674 | } while (false) |
| 644 | 675 | ||
| 645 | /* Encode the file name NAME using the specified coding system | 676 | /* Encode the file name NAME using the specified coding system |
| 646 | for file names, if any. */ | 677 | for file names, if any. */ |
| 647 | #define ENCODE_FILE(name) \ | 678 | #define ENCODE_FILE(NAME) encode_file_name (NAME) |
| 648 | (! NILP (Vfile_name_coding_system) \ | ||
| 649 | ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ | ||
| 650 | : (! NILP (Vdefault_file_name_coding_system) \ | ||
| 651 | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ | ||
| 652 | : name)) | ||
| 653 | |||
| 654 | 679 | ||
| 655 | /* Decode the file name NAME using the specified coding system | 680 | /* Decode the file name NAME using the specified coding system |
| 656 | for file names, if any. */ | 681 | for file names, if any. */ |
| 657 | #define DECODE_FILE(name) \ | 682 | #define DECODE_FILE(NAME) decode_file_name (NAME) |
| 658 | (! NILP (Vfile_name_coding_system) \ | ||
| 659 | ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ | ||
| 660 | : (! NILP (Vdefault_file_name_coding_system) \ | ||
| 661 | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ | ||
| 662 | : name)) | ||
| 663 | |||
| 664 | 683 | ||
| 665 | /* Encode the string STR using the specified coding system | 684 | /* Encode the string STR using the specified coding system |
| 666 | for system functions, if any. */ | 685 | for system functions, if any. */ |
| 667 | #define ENCODE_SYSTEM(str) \ | 686 | #define ENCODE_SYSTEM(str) \ |
| 668 | (! NILP (Vlocale_coding_system) \ | 687 | (! NILP (Vlocale_coding_system) \ |
| 669 | ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ | 688 | ? code_convert_string_norecord (str, Vlocale_coding_system, true) \ |
| 670 | : str) | 689 | : str) |
| 671 | 690 | ||
| 672 | /* Decode the string STR using the specified coding system | 691 | /* Decode the string STR using the specified coding system |
| 673 | for system functions, if any. */ | 692 | for system functions, if any. */ |
| 674 | #define DECODE_SYSTEM(str) \ | 693 | #define DECODE_SYSTEM(str) \ |
| 675 | (! NILP (Vlocale_coding_system) \ | 694 | (! NILP (Vlocale_coding_system) \ |
| 676 | ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ | 695 | ? code_convert_string_norecord (str, Vlocale_coding_system, false) \ |
| 677 | : str) | 696 | : str) |
| 678 | 697 | ||
| 679 | /* 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. */ |
| 680 | #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) |
| 681 | 700 | ||
| 682 | /* Extern declarations. */ | 701 | /* Extern declarations. */ |
| 683 | extern Lisp_Object code_conversion_save (bool, bool); | 702 | extern Lisp_Object code_conversion_save (bool, bool); |
| @@ -688,6 +707,8 @@ extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, | |||
| 688 | Lisp_Object, bool, bool, bool); | 707 | Lisp_Object, bool, bool, bool); |
| 689 | extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, | 708 | extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, |
| 690 | bool); | 709 | bool); |
| 710 | extern Lisp_Object encode_file_name (Lisp_Object); | ||
| 711 | extern Lisp_Object decode_file_name (Lisp_Object); | ||
| 691 | extern Lisp_Object raw_text_coding_system (Lisp_Object); | 712 | extern Lisp_Object raw_text_coding_system (Lisp_Object); |
| 692 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); | 713 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); |
| 693 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); | 714 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); |
| @@ -721,26 +742,13 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf); | |||
| 721 | failure modes. STR itself is not modified. */ | 742 | failure modes. STR itself is not modified. */ |
| 722 | extern Lisp_Object from_unicode (Lisp_Object str); | 743 | extern Lisp_Object from_unicode (Lisp_Object str); |
| 723 | 744 | ||
| 745 | /* Convert WSTR to an Emacs string. */ | ||
| 746 | extern Lisp_Object from_unicode_buffer (const wchar_t* wstr); | ||
| 747 | |||
| 724 | #endif /* WINDOWSNT || CYGWIN */ | 748 | #endif /* WINDOWSNT || CYGWIN */ |
| 725 | 749 | ||
| 726 | /* Macros for backward compatibility. */ | 750 | /* Macros for backward compatibility. */ |
| 727 | 751 | ||
| 728 | #define decode_coding_region(coding, from, to) \ | ||
| 729 | decode_coding_object (coding, Fcurrent_buffer (), \ | ||
| 730 | from, CHAR_TO_BYTE (from), \ | ||
| 731 | to, CHAR_TO_BYTE (to), Fcurrent_buffer ()) | ||
| 732 | |||
| 733 | |||
| 734 | #define encode_coding_region(coding, from, to) \ | ||
| 735 | encode_coding_object (coding, Fcurrent_buffer (), \ | ||
| 736 | from, CHAR_TO_BYTE (from), \ | ||
| 737 | to, CHAR_TO_BYTE (to), Fcurrent_buffer ()) | ||
| 738 | |||
| 739 | |||
| 740 | #define decode_coding_string(coding, string, nocopy) \ | ||
| 741 | decode_coding_object (coding, string, 0, 0, SCHARS (string), \ | ||
| 742 | SBYTES (string), Qt) | ||
| 743 | |||
| 744 | #define encode_coding_string(coding, string, nocopy) \ | 752 | #define encode_coding_string(coding, string, nocopy) \ |
| 745 | (STRING_MULTIBYTE(string) ? \ | 753 | (STRING_MULTIBYTE(string) ? \ |
| 746 | (encode_coding_object (coding, string, 0, 0, SCHARS (string), \ | 754 | (encode_coding_object (coding, string, 0, 0, SCHARS (string), \ |
| @@ -754,7 +762,7 @@ extern Lisp_Object from_unicode (Lisp_Object str); | |||
| 754 | (coding)->src_chars = (coding)->src_bytes = (bytes); \ | 762 | (coding)->src_chars = (coding)->src_bytes = (bytes); \ |
| 755 | decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes), \ | 763 | decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes), \ |
| 756 | (dst_object)); \ | 764 | (dst_object)); \ |
| 757 | } while (0) | 765 | } while (false) |
| 758 | 766 | ||
| 759 | 767 | ||
| 760 | extern Lisp_Object preferred_coding_system (void); | 768 | extern Lisp_Object preferred_coding_system (void); |